:root {
  --c-bg: #f5f6f8;
  --c-card: #ffffff;
  --c-border: #e1e4ea;
  --c-text: #1f2937;
  --c-muted: #6b7280;
  --c-primary: #2563eb;
  --c-primary-hover: #1d4ed8;
  --c-secondary: #475569;
  --c-rot: #dc2626;
  --c-gelb: #f59e0b;
  --c-gruen: #16a34a;
  --c-rot-bg: #fee2e2;
  --c-gelb-bg: #fef3c7;
  --c-gruen-bg: #dcfce7;
  --c-edeka: #ffd400;
  --c-edeka-blue: #003c8f;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.5;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.topbar {
  background: var(--c-edeka-blue);
  color: white;
  border-bottom: 3px solid var(--c-edeka);
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 32px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-weight: 600;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  background: var(--c-edeka);
  color: var(--c-edeka-blue);
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: .5px;
  font-size: 13px;
}
.brand-text { font-size: 15px; }

.topnav {
  display: flex;
  gap: 4px;
  flex: 1;
}
.topnav a {
  color: rgba(255,255,255,.85);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 14px;
}
.topnav a:hover {
  background: rgba(255,255,255,.1);
  color: white;
  text-decoration: none;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.user-name { font-weight: 600; }
.user-rolle {
  background: rgba(255,255,255,.15);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
}
.logout {
  color: rgba(255,255,255,.85);
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: var(--radius);
}
.logout:hover { background: rgba(255,255,255,.1); text-decoration: none; }

/* ---------- Layout ---------- */
.content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.flash-container {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid;
}
.flash-success { background: var(--c-gruen-bg); border-color: var(--c-gruen); color: #065f46; }
.flash-error   { background: var(--c-rot-bg); border-color: var(--c-rot); color: #991b1b; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: white;
  color: var(--c-text);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: all .12s ease;
}
.btn:hover { border-color: #c0c5cf; background: #f9fafb; text-decoration: none; }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: white; }
.btn-primary:hover { background: var(--c-primary-hover); border-color: var(--c-primary-hover); color: white; }
.btn-secondary { background: var(--c-secondary); border-color: var(--c-secondary); color: white; }
.btn-secondary:hover { background: #334155; color: white; }
.btn-danger { background: var(--c-rot); border-color: var(--c-rot); color: white; }
.btn-danger:hover { background: #b91c1c; color: white; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--c-secondary); }
.btn-ghost:hover { background: #eef2f7; color: var(--c-text); }
.btn-small { padding: 4px 10px; font-size: 13px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--c-card);
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--c-edeka-blue);
  margin-bottom: 16px;
}
.login-card h1 { margin: 0 0 20px; font-size: 22px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 500;
  font-size: 13px;
}
.login-card input {
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
}
.login-card input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.login-card .btn-primary { padding: 10px; font-weight: 600; margin-top: 8px; }
.login-hint {
  margin-top: 22px;
  padding: 12px;
  background: #f9fafb;
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--c-muted);
}
.login-hint strong { color: var(--c-text); }
.login-hint ul { margin: 6px 0 0; padding-left: 18px; }
.login-hint code { background: #eef2f7; padding: 1px 5px; border-radius: 3px; }

/* ---------- Dashboard Header ---------- */
.dashboard-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 16px;
  gap: 24px;
  flex-wrap: wrap;
}
.dashboard-head h1 { margin: 0; font-size: 24px; }
.subtitle { margin: 4px 0 0; color: var(--c-muted); font-size: 13px; }
.subtitle.small { font-size: 12px; }
.status-summary { display: flex; gap: 8px; }

/* ---------- Toolbar / Search ---------- */
.toolbar {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  justify-content: space-between;
}
.searchbar {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 320px;
  max-width: 720px;
}
.searchbar input[type="search"] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
}
.searchbar input[type="search"]:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.searchbar select {
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 14px;
  background: white;
  font-family: inherit;
}
.actions { display: flex; gap: 8px; }

/* ---------- Search hits ---------- */
.suchtreffer {
  background: white;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.suchtreffer h2 { margin: 0 0 12px; font-size: 15px; color: var(--c-muted); font-weight: 600; }
.treffer-liste { list-style: none; margin: 0; padding: 0; }
.treffer-liste li { padding: 6px 0; border-bottom: 1px solid #f1f3f7; }
.treffer-liste li:last-child { border-bottom: 0; }
.treffer-liste a { display: flex; align-items: center; gap: 10px; color: var(--c-text); }
.treffer-liste a:hover { text-decoration: none; }

/* ---------- Markt list ---------- */
.markt-liste { display: flex; flex-direction: column; gap: 10px; }
.markt-card {
  background: white;
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.markt-card-rot   { border-left-color: var(--c-rot); }
.markt-card-gelb  { border-left-color: var(--c-gelb); }
.markt-card-gruen { border-left-color: var(--c-gruen); }

.markt-card > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  user-select: none;
}
.markt-card > summary::-webkit-details-marker { display: none; }
.markt-card > summary::before {
  content: "▸";
  color: var(--c-muted);
  font-size: 12px;
  transition: transform .15s ease;
  display: inline-block;
}
.markt-card[open] > summary::before { transform: rotate(90deg); }
.markt-card > summary:hover { background: #fafbfc; }
.markt-name { flex: 1; }
.markt-meta { display: flex; gap: 6px; }

.markt-body {
  padding: 4px 18px 18px 40px;
  border-top: 1px solid #f1f3f7;
}
.markt-toolbar {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

/* ---------- Asset tree ---------- */
.asset-tree {
  list-style: none;
  margin: 0;
  padding: 0 0 0 18px;
  border-left: 1px dashed #d1d5db;
}
.asset-tree-flat { padding-left: 0; border-left: 0; }

.asset-node {
  margin: 4px 0;
}
.asset-node > details > summary,
.asset-node > .leaf {
  list-style: none;
  cursor: pointer;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 4px;
  flex-wrap: wrap;
}
.asset-node > .leaf { cursor: default; }
.asset-node > details > summary::-webkit-details-marker { display: none; }
.asset-node > details > summary::before {
  content: "▸";
  color: var(--c-muted);
  font-size: 10px;
  transition: transform .15s ease;
  display: inline-block;
  width: 10px;
}
.asset-node > details[open] > summary::before { transform: rotate(90deg); }
.asset-node > details > summary:hover,
.asset-node > .leaf:hover { background: #f6f8fb; }

.asset-link { color: var(--c-text); }
.asset-link:hover { color: var(--c-primary); text-decoration: none; }

/* ---------- Status indicators ---------- */
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-rot   { background: var(--c-rot); }
.status-gelb  { background: var(--c-gelb); }
.status-gruen { background: var(--c-gruen); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: #eef2f7;
  color: var(--c-text);
  white-space: nowrap;
}
.badge-rot   { background: var(--c-rot-bg);   color: #991b1b; }
.badge-gelb  { background: var(--c-gelb-bg);  color: #92400e; }
.badge-gruen { background: var(--c-gruen-bg); color: #065f46; }
.badge-rolle { background: #e0e7ff; color: #3730a3; }

.muted { color: var(--c-muted); }
.muted.small { font-size: 12px; }

/* ---------- Empty state ---------- */
.empty-state {
  background: white;
  border: 1px dashed var(--c-border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  color: var(--c-muted);
}
.empty-state .btn { margin-top: 12px; }

/* ---------- Detail pages ---------- */
.detail-page { display: flex; flex-direction: column; gap: 16px; }
.breadcrumbs {
  font-size: 13px;
  color: var(--c-muted);
}
.breadcrumbs a { color: var(--c-muted); }
.breadcrumbs a:hover { color: var(--c-primary); }
.breadcrumbs span { color: var(--c-text); font-weight: 500; }

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
}
.detail-head h1 {
  margin: 0;
  font-size: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: white;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--c-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.card h3 {
  margin: 16px 0 8px;
  font-size: 13px;
  color: var(--c-secondary);
  text-transform: uppercase;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
}

.dl-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 18px;
  margin: 0;
}
.dl-grid dt { color: var(--c-muted); font-weight: 500; }
.dl-grid dd { margin: 0; }

.kritisch-liste {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.placeholder-plan {
  background: #f9fafb;
  border: 2px dashed var(--c-border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
}

/* ---------- Forms ---------- */
.form-page { display: flex; flex-direction: column; gap: 16px; max-width: 960px; }
.form-page h1 { margin: 0; font-size: 22px; }

.form-card {
  background: white;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.form-card fieldset {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  margin: 0;
}
.form-card legend {
  padding: 0 8px;
  font-weight: 600;
  color: var(--c-secondary);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 16px;
}
.form-card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text);
}
.form-card input,
.form-card select,
.form-card textarea {
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: white;
}
.form-card input:focus,
.form-card select:focus,
.form-card textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-card input:disabled {
  background: #f9fafb;
  color: var(--c-muted);
  cursor: not-allowed;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}
.info-box {
  padding: 10px 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  color: #1e3a8a;
}

.custom-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr 160px auto;
  gap: 8px;
  margin-bottom: 8px;
}

/* ---------- Tables ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #f1f3f7;
}
.table th {
  color: var(--c-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.table tr:last-child td { border-bottom: 0; }

/* ---------- Supportfall-Liste in Karten ---------- */
.fall-liste {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fall-card {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: #fafbfc;
  color: var(--c-text);
  transition: all .12s ease;
}
.fall-card:hover {
  background: white;
  border-color: var(--c-primary);
  text-decoration: none;
  box-shadow: 0 1px 4px rgba(37,99,235,.12);
}
.fall-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.fall-card-head strong { color: var(--c-text); }
.fall-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 12px;
}
.fall-card-meta code {
  background: white;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--c-border);
}

/* ---------- Placeholder pages ---------- */
.placeholder {
  background: white;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}
.placeholder h2 { margin: 0 0 12px; color: var(--c-secondary); }
.placeholder ul { padding-left: 20px; }
.placeholder li { margin-bottom: 6px; }

.rollen-erklaerung {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rollen-erklaerung li {
  padding: 8px 12px;
  background: #f9fafb;
  border-radius: var(--radius);
  border-left: 3px solid var(--c-secondary);
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .topbar-inner { padding: 0 12px; gap: 12px; }
  .brand-text { display: none; }
  .topnav { gap: 0; }
  .topnav a { padding: 8px; font-size: 13px; }
  .user-info { font-size: 12px; }
  .user-rolle { display: none; }
  .content { padding: 16px 12px; }
  .custom-field-row { grid-template-columns: 1fr; }
  .head-actions { width: 100%; }
}
