/* =========================================================================
   Beschaffungsnavigator – Design-System & Layout
   Web first, Mobile ergänzend (Konzept-PDF §8)
   ========================================================================= */
:root {
  --accent: #1d4f91;
  --accent-dark: #163a6b;
  --accent-soft: #e8eef7;
  --bg: #f3f5f9;
  --card: #ffffff;
  --ink: #1a2334;
  --muted: #5b6474;
  --line: #dfe5ef;
  --ok: #1a7f4b;
  --ok-bg: #e6f4ec;
  --warn: #9a6a12;
  --warn-bg: #fdf3dd;
  --bad: #b3352c;
  --bad-bg: #fbeae8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 55, .05), 0 4px 14px rgba(20, 30, 55, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.18rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 1rem 0; }
a { color: var(--accent); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--ink);
  font-weight: 700; font-size: 1.02rem; min-width: 0;
}
.brand-mark { color: var(--accent); font-size: 1.1rem; }
.brand-tag {
  font-weight: 500; font-size: .72rem; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 2px 10px;
  white-space: nowrap;
}
.topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.project-switch {
  max-width: 220px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); font: inherit;
}
.badge-local {
  font-size: .72rem; color: var(--ok); background: var(--ok-bg);
  border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}

/* ---------- Layout ---------- */
.layout {
  max-width: 1180px; margin: 0 auto;
  display: grid; grid-template-columns: 240px minmax(0, 1fr);
  gap: 20px; padding: 20px;
  align-items: start;
}
.sidebar { position: sticky; top: 74px; }
.sidebar.hidden { display: none; }
/* E22/M21-1: ohne aktive Akte (Sidebar versteckt) 1-Spalten-Layout, sonst würde main
   in den 240-px-Erstspalten-Track auto-platziert (Hero in 240 px breit). */
.layout.no-sidebar { grid-template-columns: 1fr; }
.main { min-width: 0; }
.page { display: block; }
.page-head { margin-bottom: 14px; }
.page-head h1 { margin-top: 6px; }

/* ---------- Sidebar Steps ---------- */
.steps { display: flex; flex-direction: column; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow); }
.step {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  text-decoration: none; color: var(--ink); font-weight: 500; font-size: .92rem;
}
.step:hover { background: var(--bg); }
.step.active { background: var(--accent-soft); color: var(--accent-dark); }
.step-num {
  flex: 0 0 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: #eef1f7; color: var(--muted); font-size: .78rem; font-weight: 700;
}
.step.done .step-num { background: var(--ok-bg); color: var(--ok); }
.step-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-badge {
  background: var(--accent); color: #fff; border-radius: 999px;
  font-size: .7rem; font-weight: 700; padding: 1px 8px;
}

/* ---------- Cards & Content ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card h2 { margin-bottom: 12px; }
.hero { padding: 28px; }
.hero h1 { font-size: 1.7rem; margin-bottom: 8px; }
.lead { color: var(--muted); font-size: 1.02rem; max-width: 62ch; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.badge {
  display: inline-block; font-size: .75rem; font-weight: 600;
  background: #eef1f7; color: var(--muted);
  border-radius: 999px; padding: 3px 12px;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-accent { background: var(--accent-soft); color: var(--accent-dark); }
.badge-ok-card { border-color: var(--ok); background: var(--ok-bg); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 9px; padding: 10px 16px;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: #fff; color: var(--bad); border-color: #e8c9c6; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.icon-btn {
  border: none; background: transparent; cursor: pointer;
  color: var(--muted); font-size: .9rem; padding: 2px 6px; border-radius: 6px;
}
.icon-btn:hover { background: var(--bad-bg); color: var(--bad); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.field input[type="text"], .field textarea, .field input[type="number"], .field select {
  width: 100%; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; background: #fff;
}
.field textarea { resize: vertical; min-height: 110px; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
.field input[type="file"] { font-size: .9rem; }
.hint { display: block; color: var(--muted); font-size: .82rem; font-style: normal; margin-top: 6px; }
.hint-error { color: var(--bad); font-weight: 600; }
fieldset { border: none; margin: 0 0 16px; padding: 0; }
fieldset legend { font-weight: 600; font-size: .92rem; padding: 0; margin-bottom: 6px; }

/* ---------- Preset-Karten ---------- */
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.preset-card {
  display: grid; grid-template-columns: 30px 1fr; grid-template-rows: auto auto;
  gap: 2px 10px; align-items: center;
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 10px 12px; cursor: pointer; background: #fff;
}
.preset-card:hover { border-color: var(--accent); }
.preset-card input { position: absolute; opacity: 0; pointer-events: none; }
.preset-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.preset-icon { grid-row: span 2; font-size: 1.4rem; }
.preset-label { font-weight: 700; font-size: .92rem; }
.preset-desc { grid-column: 2; color: var(--muted); font-size: .78rem; }

/* ---------- Projektkarten ---------- */
.project-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: #fff; }
.project-card-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.project-card h3 { margin: 0 0 2px; }
.stage-dots { display: flex; gap: 5px; padding-top: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #e3e8f1; }
.dot-on { background: var(--ok); }
.project-card .actions { margin-top: 0; }

/* ---------- Löschfristen (E17) ---------- */
.da-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; font-size: .85rem; }
.da-row input[type="date"] {
  font: inherit; font-size: .85rem; color: var(--ink);
  padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.da-log { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.da-log h3 { margin: 0 0 6px; font-size: .98rem; }
.da-log ul { list-style: none; margin: 0 0 8px; padding: 0; font-size: .85rem; color: var(--muted); }
.da-log li { padding: 3px 0; }
.da-log .hint { display: block; margin: 0; }

/* ---------- Medien ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin: 4px 0 14px; }
.media-item { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.media-item img { width: 100%; height: 74px; object-fit: cover; display: block; }
.media-video { width: 100%; height: 74px; max-height: 74px; object-fit: contain; display: block; background: #0b0e14; }
.media-file { height: 74px; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; background: var(--bg); }
.media-item figcaption { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 4px 6px; font-size: .75rem; }
.media-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-btns { display: inline-flex; gap: 2px; align-items: center; }
.icon-btn-dl { color: var(--muted); text-decoration: none; }
.icon-btn-dl:hover { background: var(--bg); color: var(--accent); }

/* ---------- Freigaben ---------- */
.approval-list { list-style: none; margin: 0; padding: 0; }
.approval-item {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 4px; border-bottom: 1px solid var(--line);
}
.approval-item:last-child { border-bottom: none; }
.approval-item.done { opacity: .72; }
.approval-text strong { display: block; }
.approval-text em { color: var(--muted); font-style: normal; font-size: .85rem; }

/* ---------- Audit-Tabelle ---------- */
.table-card { padding: 6px 10px; }
.audit-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.audit-table th { text-align: left; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.audit-table td { padding: 9px 10px; border-bottom: 1px solid #edf0f6; vertical-align: top; }
.audit-table tr:last-child td { border-bottom: none; }
.td-time { white-space: nowrap; color: var(--muted); }

/* ---------- Bedarfsprofil (Wizard & Ansicht) ---------- */
.q-opts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.q-opt {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 4px 12px; font: inherit; font-size: .8rem; cursor: pointer; color: var(--muted);
}
.q-opt:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-soft); }
.badge-must { background: var(--accent-soft); color: var(--accent-dark); }
.badge-can { background: #eef1f7; color: var(--muted); }
.req-list { list-style: none; margin: 0 0 14px; padding: 0; }
.req-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid #edf0f6; }
.req-item:last-child { border-bottom: none; }
.req-text { min-width: 0; line-height: 1.5; }
.req-src { font-size: .78rem; }
.req-actions { flex: 0 0 auto; display: flex; gap: 6px; }
.req-edit-form { display: block; width: 100%; }
.req-edit-form input[type="text"] { width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; background: #fff; margin-bottom: 8px; }
.req-edit-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.req-edit-row select { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.req-edit-btns { display: inline-flex; gap: 6px; margin-left: auto; }
.req-add-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.req-add-row input[type="text"] { flex: 1 1 220px; font: inherit; border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; background: #fff; }
.req-add-row select { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.fact-list { list-style: none; margin: 0; padding: 0; }
.fact-item { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid #edf0f6; line-height: 1.5; }
.fact-item:last-child { border-bottom: none; }
.actions-row .actions { margin-top: 0; }

/* ---------- Anbieter-Vorauswahl ---------- */
.supplier-count { font-size: .95rem; margin-bottom: 14px; }
.supplier-list { list-style: none; display: grid; gap: 12px; margin: 0 0 18px; padding: 0; }
.supplier-item {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--card, #fff); border: 1px solid var(--line, #e2e6ee); border-radius: 12px;
  padding: 14px 16px;
}
.supplier-item.selected { border-color: var(--primary, #2f5fe0); box-shadow: 0 0 0 2px rgba(47, 95, 224, .15); }
.supplier-check { display: inline-flex; padding-top: 3px; }
.supplier-check input { width: 20px; height: 20px; accent-color: var(--primary, #2f5fe0); cursor: pointer; }
.supplier-main { min-width: 0; flex: 1; display: grid; gap: 4px; }
.supplier-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .98rem; }
.supplier-spec { color: var(--ink, #1c2434); font-size: .9rem; }
.supplier-reasons { font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Offertanfrage & Privacy-Layer ---------- */
.req-card-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.req-card-head h2 { margin: 0; }
.req-tabs { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.req-tab {
  border: 1px solid var(--line, #e2e6ee); background: #fff; color: var(--ink, #1c2434);
  border-radius: 999px; padding: 6px 14px; font-size: .85rem; cursor: pointer;
}
.req-tab.active { background: var(--primary, #2f5fe0); border-color: var(--primary, #2f5fe0); color: #fff; }
#reqtext, .req-preview {
  width: 100%; box-sizing: border-box; font-family: ui-monospace, Consolas, monospace;
  font-size: .85rem; line-height: 1.5; border: 1px solid var(--line, #e2e6ee); border-radius: 10px; padding: 12px; resize: vertical;
}
.req-preview { background: #f6f8fc; }
.req-user-grid { margin-bottom: 8px; }
.req-map-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: .9rem; }
.req-map-table th, .req-map-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line, #e2e6ee); }
.req-map-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted, #6b7280); }

/* ---------- Offerteneingang & Analyse (E9) ---------- */
.offer-card { margin-bottom: 14px; }
.offer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.offer-head > div { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.offer-price { font-size: 1.15rem; font-weight: 700; white-space: nowrap; }
.offer-scope, .offer-exc { margin: 10px 0 0; font-size: .92rem; }
.offer-exc .badge { margin-right: 6px; }
.offer-meta { display: flex; flex-wrap: wrap; gap: 14px; font-size: .9rem; color: var(--muted, #6b7280); margin: 12px 0 10px; }
.badge-src { background: #eef2fb; color: #35508c; }
.list-head { margin: 26px 0 12px; font-size: 1.1rem; }
.offer-parsed-table { width: 100%; border-collapse: collapse; font-size: .9rem; margin: 12px 0; }
.offer-parsed-table th, .offer-parsed-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line, #e2e6ee); }
.offer-parsed-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted, #6b7280); }

/* ---------- Vergleich & Entscheidung (E11) ---------- */
.dec-table { width: 100%; border-collapse: collapse; font-size: .9rem; margin: 10px 0; }
.dec-table th, .dec-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line, #e2e6ee); vertical-align: middle; }
.dec-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted, #6b7280); }
.dec-table .td-num { text-align: center; white-space: nowrap; }
.dec-table input[type=number] { width: 78px; }
.dec-table select { min-width: 52px; }
.dec-rank { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: #eef2fb; color: #35508c; font-weight: 700; margin-right: 6px; }
.dec-top { border-left: 4px solid var(--primary, #2f5fe0); }
.dec-list { margin: 10px 0; font-size: .9rem; }
.dec-list ul { margin: 6px 0 0 18px; padding: 0; }
.dec-list li { margin: 3px 0; }
.dec-rec { border-left: 4px solid var(--ok, #2e8b57); }
.dec-decided { border-left: 4px solid var(--ok, #2e8b57); }
.dec-reason { margin: 10px 0; }
.actions-row { margin-top: 6px; }

/* ---------- Lock-Karte ---------- */
.lock-card { text-align: center; padding: 40px 24px; }
.lock-icon { font-size: 2.2rem; margin-bottom: 8px; }
.lock-card .actions { justify-content: center; }

/* ---------- Footer ---------- */
.footer {
  max-width: 1180px; margin: 10px auto 0; padding: 14px 20px 26px;
  color: var(--muted); font-size: .8rem; text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 14px; gap: 12px; }
  .sidebar { position: static; min-width: 0; }
  .steps { flex-direction: row; overflow-x: auto; padding: 6px; -webkit-overflow-scrolling: touch; }
  .step { flex: 0 0 auto; padding: 8px 10px; font-size: .85rem; }
  .step-label { max-width: 120px; }
  .grid-2 { grid-template-columns: 1fr; }
  .project-switch { max-width: 140px; }
  .offer-head { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 600px) {
  body { font-size: 14.5px; }
  .topbar { padding: 8px 12px; }
  .brand-text { font-size: .95rem; }
  .brand-tag { display: none; }
  .badge-local { display: none; }
  .hero { padding: 20px; }
  .hero h1 { font-size: 1.35rem; }
  .card { padding: 16px; }
  .preset-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.3rem; }
  .actions .btn { flex: 1; text-align: center; }
  .approval-item { flex-direction: column; align-items: flex-start; }
  .audit-table thead { display: none; }
  .audit-table tr { display: block; padding: 6px 0; }
  .audit-table td { display: block; border: none; padding: 2px 0; }
}
