/* ==========================================================================
   Praxis-Arbeitskorb – Demo. Ruhig, klinisch, hell. Akzent: Petrol.
   Rot nur für "dringend", Gelb/Orange für "Signatur". Systemschrift.
   ========================================================================== */
:root {
  --bg: #f4f7f9;
  --surface: #ffffff;
  --line: #e1e8ee;
  --line-strong: #cbd6df;
  --text: #1c2a35;
  --muted: #5d6e7c;
  --accent: #0f6f8c;
  --accent-dark: #0a566d;
  --accent-soft: #e5f2f6;
  --urgent: #c0392b;
  --urgent-soft: #fdecea;
  --sign: #b25e00;
  --sign-soft: #fff3de;
  --ok: #1f7a4a;
  --ok-soft: #e7f4ed;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 40, 55, .06), 0 2px 8px rgba(20, 40, 55, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
button, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------- Kopfzeile ---------------- */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 12px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  position: relative;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--accent);
  flex: none;
}
.brand-mark::before, .brand-mark::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 2px;
}
.brand-mark::before { left: 14px; top: 8px; width: 6px; height: 18px; }
.brand-mark::after { left: 8px; top: 14px; width: 18px; height: 6px; }
.brand-name { font-weight: 600; font-size: 17px; }
.brand-sub { font-size: 12.5px; color: var(--muted); }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; text-align: center; }
.topright { display: flex; justify-content: flex-end; align-items: center; gap: 20px; }
.ki-status { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.ki-status .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #2fb36d;
  box-shadow: 0 0 0 4px rgba(47, 179, 109, .18);
}
.role-pick { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.role-pick select {
  padding: 6px 28px 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

/* ---------------- Demo-Leiste / Ersparnis ---------------- */
.demobar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 20px;
  padding: 9px 28px;
  background: var(--accent-soft);
  border-bottom: 1px solid #cfe5ec;
  font-size: 14px;
}
.savings b { color: var(--accent-dark); font-weight: 600; }
.demo-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.eta { font-size: 13px; color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }

/* ---------------- Buttons ---------------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 500;
  background: var(--accent);
  color: #fff;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--accent-dark); }
.btn:focus-visible, .tile:focus-visible, .tab:focus-visible, .row:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--line-strong); }
.btn-ghost:hover { background: #f1f5f8; }
.btn-sign { background: var(--sign); }
.btn-sign:hover { background: #8f4b00; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn[disabled]:hover { background: var(--accent); }
.btn-ghost[disabled]:hover { background: #fff; }

/* ---------------- Seitenlayout ---------------- */
.page { flex: 1; width: 100%; max-width: 1440px; margin: 0 auto; padding: 22px 28px 28px; }

/* ---------------- Kacheln ---------------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.tile {
  appearance: none;
  position: relative;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 13px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color .12s, transform .12s;
  min-height: 108px;
}
.tile:hover { border-color: var(--accent); }
.tile.is-sel { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.tile-count { font-size: 30px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-label { margin-top: 4px; font-weight: 500; }
.tile-hint { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.tile-flags { display: flex; gap: 6px; flex-wrap: wrap; position: absolute; top: 12px; right: 12px; }
.flag { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; font-weight: 500; white-space: nowrap; }
.flag-urgent { background: var(--urgent-soft); color: var(--urgent); }
.flag-warn { background: var(--sign-soft); color: var(--sign); }
.tile-signatur .tile-count { color: var(--sign); }
.tile.is-off { opacity: .42; cursor: not-allowed; box-shadow: none; background: #eef2f5; }
.tile.is-off:hover { border-color: var(--line); }
.tile-role { display: inline-block; font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* ---------------- Tabs ---------------- */
.tabs { display: flex; gap: 4px; margin: 26px 0 14px; border-bottom: 1px solid var(--line-strong); }
.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 9px 16px 8px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.is-sel { color: var(--accent-dark); border-bottom-color: var(--accent); }
.tab .n {
  display: inline-block;
  min-width: 22px;
  padding: 0 7px;
  margin-left: 6px;
  border-radius: 999px;
  background: #e8eef2;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}
.tab.is-sel .n { background: var(--accent); color: #fff; }

/* ---------------- Aufgabenliste ---------------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-title { font-size: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 6px 3px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 13px;
}
.chip button { appearance: none; border: none; background: none; cursor: pointer; font-size: 15px; line-height: 1; color: inherit; padding: 2px 6px; border-radius: 50%; }
.chip button:hover { background: rgba(15, 111, 140, .15); }
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: 100px 1fr 130px 130px;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.row:last-child { border-bottom: none; }
.row:hover { background: #f8fafb; }
.row-title { font-weight: 500; }
.row-sub { font-size: 13px; color: var(--muted); margin-top: 1px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-src { font-size: 13.5px; color: var(--muted); }
.row-time { font-size: 13px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.row.is-processing { cursor: default; background: #fafcfd; color: var(--muted); }
.row.is-processing:hover { background: #fafcfd; }
.row.is-new { animation: fresh 2.4s ease-out; }
@keyframes fresh { from { background: var(--accent-soft); } to { background: transparent; } }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; text-align: center; white-space: nowrap; }
.b-urgent { background: var(--urgent-soft); color: var(--urgent); }
.b-sign { background: var(--sign-soft); color: var(--sign); }
.b-normal { background: #e9eff3; color: #44596a; }
.b-eingang { background: var(--accent-soft); color: var(--accent-dark); display: inline-flex; align-items: center; gap: 7px; }
.tag-warn { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--sign-soft); color: var(--sign); font-weight: 500; }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(15, 111, 140, .25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Tabellen (Signatur, Protokoll) ---------------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafcfd; white-space: nowrap; }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl.clickable tbody tr { cursor: pointer; }
.tbl.clickable tbody tr:hover { background: #f8fafb; }
.tbl .c-check { width: 40px; }
.tbl .c-time { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.tbl .exec td { padding-top: 2px; padding-bottom: 6px; color: var(--ok); font-size: 13.5px; border-bottom: none; }
.tbl .exec + tr:not(.exec) td, .tbl tr.grp-start td { border-top: none; }
.tbl tr.grp-end td { border-bottom: 1px solid var(--line); }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.note { padding: 12px 18px; font-size: 13.5px; color: var(--muted); border-bottom: 1px solid var(--line); background: #fafcfd; }

/* ---------------- Detail-Seitenpanel ---------------- */
.backdrop { position: fixed; inset: 0; background: rgba(20, 35, 48, .38); z-index: 40; animation: fadein .15s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(1120px, 96vw);
  background: var(--bg);
  z-index: 41;
  display: flex; flex-direction: column;
  box-shadow: -8px 0 32px rgba(20, 35, 48, .22);
  animation: slidein .18s ease-out;
}
@keyframes slidein { from { transform: translateX(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: flex-start; gap: 14px; padding: 18px 24px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.drawer-head .grow { flex: 1; min-width: 0; }
.drawer-title { font-size: 18px; margin-top: 6px; }
.drawer-meta { font-size: 13.5px; color: var(--muted); margin-top: 3px; }
.btn-close { appearance: none; border: 1px solid var(--line-strong); background: #fff; border-radius: 8px; width: 36px; height: 36px; cursor: pointer; font-size: 18px; line-height: 1; color: var(--muted); }
.btn-close:hover { background: #f1f5f8; color: var(--text); }
.drawer-body { flex: 1; overflow: auto; padding: 18px 24px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { padding: 11px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-head small { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.card-body { padding: 14px 16px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 12px; margin: 0 0 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.prewrap { white-space: pre-wrap; font-size: 14.5px; background: #f8fafb; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.draft-area {
  width: 100%;
  min-height: 300px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  line-height: 1.5;
  font-size: 14.5px;
}
.draft-area[readonly] { background: #f4f7f9; color: #3b4b58; }
.draft-hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.labtbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.labtbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.labtbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.labtbl tr:last-child td { border-bottom: none; }
.labtbl tr.flag-row td { background: var(--accent-soft); }
.labtbl tr.flag-crit td { background: var(--urgent-soft); }
.labtbl .val { font-weight: 600; }
.labtbl tr.flag-crit .val { color: var(--urgent); }
.mark { margin-left: 4px; font-size: 12px; }

.cand { margin: 8px 0 0; padding: 0; list-style: none; }
.cand li { display: grid; grid-template-columns: 1fr 70px; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.cand li:last-child { border-bottom: none; }
.bar { height: 7px; border-radius: 4px; background: #e6edf2; overflow: hidden; margin-top: 4px; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.low > span { background: var(--sign); }
.cand .pct { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.below { margin-top: 18px; display: grid; grid-template-columns: 1fr 260px; gap: 18px; align-items: start; }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { padding: 6px 0 6px 26px; position: relative; font-size: 14.5px; }
.checks li::before { position: absolute; left: 2px; top: 6px; font-weight: 700; }
.checks .ok::before { content: "\2713"; color: var(--ok); }
.checks .warn::before { content: "\26A0"; color: var(--sign); }
.checks .warn { color: #6b3b00; }

.conf-label { font-size: 13px; color: var(--muted); }
.conf-value { font-size: 20px; font-weight: 600; margin: 2px 0 8px; }
.meter { display: flex; gap: 5px; }
.meter i { flex: 1; height: 9px; border-radius: 3px; background: #e3eaef; }
.meter i.on { background: var(--accent); }
.conf-note { font-size: 12.5px; margin-top: 8px; color: var(--muted); }
.conf-note.low { color: var(--sign); }

.drawer-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 24px; background: var(--surface); border-top: 1px solid var(--line); }
.drawer-foot .hint { color: var(--muted); font-size: 13.5px; flex: 1; min-width: 200px; }
.spacer { flex: 1; }

/* ---------------- Dialog (Signatur) ---------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 35, 48, .5); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadein .15s; }
.modal { width: min(520px, 100%); background: var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(20, 35, 48, .35); padding: 24px 26px 22px; }
.modal h2 { font-size: 19px; margin-bottom: 12px; }
.reader { display: flex; align-items: center; gap: 16px; padding: 16px; background: var(--sign-soft); border: 1px solid #f0d9b0; border-radius: 10px; margin: 14px 0; }
.reader-icon { position: relative; flex: none; width: 54px; height: 70px; border-radius: 7px; background: #4b5b68; }
.reader-icon::before { content: ""; position: absolute; left: 8px; right: 8px; top: 9px; height: 16px; border-radius: 3px; background: #c9e6d4; }
.reader-icon::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 9px; height: 24px; background:
  radial-gradient(circle, #9fb0bd 2px, transparent 2.5px) 0 0 / 10px 8px; }
.reader-text { font-weight: 600; color: #6b3b00; }
.progress { height: 10px; border-radius: 5px; background: #e3eaef; overflow: hidden; margin: 14px 0 8px; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s ease; }
.done-mark { display: flex; align-items: center; gap: 12px; margin: 10px 0 6px; font-size: 18px; font-weight: 600; color: var(--ok); }
.done-mark i { display: inline-flex; width: 34px; height: 34px; border-radius: 50%; background: var(--ok-soft); align-items: center; justify-content: center; font-style: normal; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.center-wait { display: flex; align-items: center; gap: 12px; padding: 14px 0; font-weight: 500; }
.center-wait .spinner { width: 20px; height: 20px; border-width: 3px; }

/* ---------------- Toasts ---------------- */
.toasts { position: fixed; right: 20px; bottom: 56px; z-index: 80; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 40px)); }
.toast {
  background: #1f3442; color: #fff;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  box-shadow: 0 6px 22px rgba(20, 35, 48, .3);
  border-left: 4px solid var(--accent);
  cursor: pointer;
  animation: toastin .2s ease-out;
}
.toast.kind-sign { border-left-color: #f0a030; }
.toast.kind-ok { border-left-color: #43c283; }
.toast.kind-info { border-left-color: #8aa0b0; }
@keyframes toastin { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- Fußzeile ---------------- */
.footer { text-align: center; padding: 14px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); background: var(--surface); }

/* ---------------- Responsiv ---------------- */
@media (max-width: 1100px) {
  .topbar { grid-template-columns: 1fr auto; }
  .clock { grid-column: 1 / -1; grid-row: 2; text-align: left; }
}
@media (max-width: 960px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .cols, .below { grid-template-columns: 1fr; }
  .row { grid-template-columns: 90px 1fr 100px; }
  .row-time { display: none; }
  .page { padding: 16px; }
  .topbar, .demobar { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 560px) {
  .tiles { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
