:root {
  --paper: #e9edf0; --card: #ffffff; --ink: #16222d; --muted: #566675; --line: #c6cfd6; --line-soft: #e1e6ea;
  --post: #0a6b7c; --post-dark: #064c59; --post-tint: #dcecef;
  --amber: #8a5200; --amber-bg: #fbeed0; --red: #a2262b; --red-bg: #f9dedc; --green: #1f6b45; --green-bg: #dcefe3;
  --font: "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #10181f; --card: #18232d; --ink: #e6ecf0; --muted: #98a8b5; --line: #33434f; --line-soft: #26343f;
    --post: #4fb3c4; --post-dark: #7cd0de; --post-tint: #17353c;
    --amber: #f0b45a; --amber-bg: #3a2c12; --red: #ff8f8f; --red-bg: #40191b; --green: #7bd3a0; --green-bg: #17352a;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.5 var(--font); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 24px; } h2 { font-size: 18px; } h3 { font-size: 14px; }
.muted { color: var(--muted); } .error { color: var(--red); } .num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--post); outline-offset: 2px; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }

/* Anmeldung */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); background: var(--card); border: 1px solid var(--line); border-top: 6px solid var(--post); padding: 28px; display: grid; gap: 14px; }

/* Rahmen */
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100%; }
.nav { background: #16222d; color: #e6ecf0; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.nav .brand { font-weight: 700; font-size: 17px; padding: 4px 10px 16px; }
.nav button.nav-item { text-align: left; background: none; border: 0; color: inherit; padding: 9px 10px; border-radius: 4px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.nav button.nav-item:hover { background: #24343f; }
.nav button.nav-item[aria-current="page"] { background: var(--post); color: #fff; }
.nav .badge { background: #f0b45a; color: #3a2400; border-radius: 9px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.nav .spacer { flex: 1; }
.nav .who { padding: 8px 10px; color: #a9b8c4; font-size: 13px; }
.main { padding: 22px 26px 40px; min-width: 0; }
.main:focus { outline: none; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }

/* Buttons und Formulare */
.btn { border: 1px solid var(--line); background: var(--card); padding: 7px 13px; border-radius: 4px; cursor: pointer; }
.btn:hover { border-color: var(--post); }
.btn.primary { background: var(--post); border-color: var(--post); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--post-dark); }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input[type=text], input[type=password], input[type=search], input[type=number], input:not([type]), select, textarea {
  border: 1px solid var(--line); background: var(--card); padding: 7px 9px; border-radius: 4px; width: 100%; font-weight: 400; }
textarea { min-height: 70px; resize: vertical; }

/* Fächer (Dashboard) */
.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 6px 0 22px; }
.slot { text-align: left; cursor: pointer; background: var(--card); border: 2px solid var(--line); border-top: 0; border-bottom-width: 6px;
  box-shadow: inset 0 10px 10px -10px rgba(0, 0, 0, .35); padding: 18px 14px 12px; min-height: 108px; display: grid; align-content: space-between; }
.slot:hover { border-color: var(--post); }
.slot .n { font-size: 32px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.slot .l { font-size: 13px; color: var(--muted); }
.slot.review { border-bottom-color: #d99a2b; } .slot.err { border-bottom-color: var(--red); } .slot.ok { border-bottom-color: var(--green); } .slot.wait { border-bottom-color: var(--post); }
.panel { background: var(--card); border: 1px solid var(--line); padding: 16px; margin-bottom: 16px; }
.panel h2, .panel h3 { margin-bottom: 8px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; overflow-wrap: anywhere; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.banner { padding: 8px 12px; border-left: 4px solid var(--post); background: var(--post-tint); margin-bottom: 16px; }
.banner.warn { border-left-color: #d99a2b; background: var(--amber-bg); }

/* Posteingang */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 8px 12px; cursor: pointer; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--post); font-weight: 600; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 520px); gap: 16px; align-items: start; }
.split.single { grid-template-columns: minmax(0, 1fr); }
.toolbar { display: flex; gap: 10px; margin-bottom: 10px; }
.toolbar input { max-width: 340px; }
.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--paper); white-space: nowrap; }
tr.row { cursor: pointer; } tr.row:hover td { background: var(--post-tint); } tr.row.sel td { background: var(--post-tint); box-shadow: inset 3px 0 0 var(--post); }
td .sub { color: var(--muted); font-size: 13px; max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.review { background: var(--amber-bg); color: var(--amber); } .pill.err { background: var(--red-bg); color: var(--red); }
.pill.ok { background: var(--green-bg); color: var(--green); } .pill.wait { background: var(--post-tint); color: var(--post-dark); }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 10px; }

/* Detail */
.detail { background: var(--card); border: 1px solid var(--line); position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
.detail > section { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.detail > section:last-child { border-bottom: 0; }
.detail header { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
.detail header h2 { overflow-wrap: anywhere; }
pre.body { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.5 var(--mono); background: var(--paper); padding: 10px; margin: 0; max-height: 280px; overflow: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--paper); border: 1px solid var(--line); border-radius: 3px; padding: 1px 8px; font-size: 12px; }
.chip.warn { background: var(--amber-bg); border-color: transparent; color: var(--amber); }
.chip.bad { background: var(--red-bg); border-color: transparent; color: var(--red); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
details summary { cursor: pointer; font-weight: 600; }

/* Laufweg */
.route { list-style: none; display: flex; margin: 0; padding: 0; }
.route li { flex: 1; position: relative; padding-top: 22px; font-size: 12px; text-align: center; color: var(--muted); }
.route li::before { content: ""; position: absolute; top: 6px; left: -50%; width: 100%; height: 3px; background: var(--line); }
.route li:first-child::before { display: none; }
.route li::after { content: ""; position: absolute; top: 0; left: calc(50% - 7px); width: 14px; height: 14px; border-radius: 50%; background: var(--card); border: 3px solid var(--line); }
.route li.done { color: var(--ink); } .route li.done::before { background: var(--post); } .route li.done::after { background: var(--post); border-color: var(--post); }
.route li.current { color: var(--ink); font-weight: 600; } .route li.current::before { background: var(--post); } .route li.current::after { border-color: #d99a2b; background: var(--amber-bg); }
.route li.blocked { color: var(--red); font-weight: 600; } .route li.blocked::before { background: var(--post); } .route li.blocked::after { border-color: var(--red); background: var(--red-bg); }
.route small { display: block; font-weight: 400; color: var(--muted); }

/* Dialog, Toast */
.dlg { border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 20px; width: min(520px, 94vw); }
.dlg::backdrop { background: rgba(10, 20, 28, .55); }
.dlg form { display: grid; gap: 12px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #16222d; color: #fff; padding: 10px 16px; border-radius: 4px; max-width: 90vw; opacity: 0; pointer-events: none; transition: opacity .15s; }
.toast.show { opacity: 1; } .toast.bad { background: var(--red); color: #fff; }
.empty { padding: 30px 16px; text-align: center; color: var(--muted); }

@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } .detail { position: static; max-height: none; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; } .nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav .brand { padding: 4px 10px; } .nav .spacer { display: none; } .main { padding: 14px; } .grid2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
