:root {
  --bg: #eceff2;
  --surface: #ffffff;
  --surface-2: #f4f6f8;
  --surface-3: #e8edf1;
  --ink: #121a21;
  --muted: #5c6b78;
  --line: #ccd6de;
  --line-soft: #e2e8ed;
  --accent: #0d6e75;
  --accent-ink: #0a5257;
  --accent-soft: #dcecec;
  --good: #1c6b45;
  --good-soft: #dcefe3;
  --warn: #95580a;
  --warn-soft: #f7ead4;
  --crit: #8d2b2e;
  --crit-soft: #f5dedd;
  --info: #1f5288;
  --info-soft: #dde8f4;
  --radius: 4px;
  --f-sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418;
    --surface: #171e24;
    --surface-2: #1d262d;
    --surface-3: #232d35;
    --ink: #e3eaf0;
    --muted: #93a3af;
    --line: #2c373f;
    --line-soft: #232d35;
    --accent: #4fb9bf;
    --accent-ink: #7fd2d6;
    --accent-soft: #143138;
    --good: #6cc79a;
    --good-soft: #16302a;
    --warn: #d9a466;
    --warn-soft: #302719;
    --crit: #dd8688;
    --crit-soft: #33201f;
    --info: #7fb0e0;
    --info-soft: #1a2836;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-sans);
  font-size: 14.5px;
  line-height: 1.55;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Rahmen ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { font-weight: 600; font-size: 16px; letter-spacing: -0.01em; margin-bottom: 2px; }
.brand small { display: block; font-family: var(--f-mono); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent); font-weight: 400; }

.hotelbox {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 11px; margin: 14px 0 12px;
}
.hotelbox .name { font-weight: 600; font-size: 14px; }
.hotelbox .meta { color: var(--muted); font-size: 12px; }
.hotelbox a { font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-radius: var(--radius); color: var(--ink); font-size: 14px;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav .sep { font-family: var(--f-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin: 14px 0 4px 10px; }
.badge-count {
  font-family: var(--f-mono); font-size: 11px; background: var(--surface-3);
  border-radius: 10px; padding: 1px 7px; color: var(--muted);
}
.nav a.active .badge-count { background: var(--surface); color: var(--accent-ink); }

.main { padding: 26px 30px 60px; max-width: 1500px; }

.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
  flex-wrap: wrap; margin-bottom: 20px; }
.pagehead h1 { font-size: 25px; margin: 0 0 3px; letter-spacing: -0.015em; }
.pagehead p { margin: 0; color: var(--muted); font-size: 14px; }
.pagehead .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Meldungen ---------- */
.flash { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 18px; font-size: 14px;
  border: 1px solid; }
.flash.ok { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.flash.err { background: var(--crit-soft); border-color: var(--crit); color: var(--crit); }
.flash.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.flash.info { background: var(--info-soft); border-color: var(--info); color: var(--info); }
/* Meldungsleiste: bleibt beim Scrollen oben sichtbar, wegklickbar (Review 12.09.) */
.flashbar { position: sticky; top: 0; z-index: 30; padding-top: 2px; margin-bottom: 6px; background: var(--bg); }
.flashbar .flash { margin-bottom: 8px; padding-right: 40px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.flashclose { position: absolute; top: 6px; right: 6px; border: 0; background: transparent; font-size: 20px; line-height: 1;
  cursor: pointer; color: var(--muted); padding: 2px 8px; border-radius: 6px; }
.flashclose:hover { background: var(--surface-2); color: var(--text); }
/* Fortschrittsbalken oben, solange ein Formular läuft */
.busybar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100; background: var(--accent-soft); overflow: hidden; }
.busybar::after { content: ""; position: absolute; left: -40%; width: 40%; height: 100%; background: var(--accent); animation: busyslide 1.1s linear infinite; }
@keyframes busyslide { from { left: -40%; } to { left: 100%; } }
button.busy { opacity: .6; cursor: progress; }

/* ---------- Karten ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 24px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 17px; }
.card .label { font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); }
.card .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px;
  font-variant-numeric: tabular-nums; }
.card .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card.alert { border-left: 3px solid var(--crit); }
.card.attention { border-left: 3px solid var(--warn); }
.card.ok { border-left: 3px solid var(--good); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 22px; overflow: hidden; }
.panel > h2 { font-size: 15px; margin: 0; padding: 13px 17px; border-bottom: 1px solid var(--line-soft);
  display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel > h2 .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.panel .body { padding: 17px; }
.panel .body.tight { padding: 0; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 22px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 22px; align-items: start; }

/* ---------- Tabellen ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-family: var(--f-mono); font-size: 11.5px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); font-weight: 500; padding: 9px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.mono, .mono { font-family: var(--f-mono); font-size: 12.5px; }
tr.overdue td:first-child { box-shadow: inset 3px 0 0 var(--crit); }
.empty { padding: 26px 17px; color: var(--muted); text-align: center; }

/* ---------- Plaketten ---------- */
.badge { display: inline-block; font-size: 12px; padding: 1.5px 8px; border-radius: 10px;
  border: 1px solid; white-space: nowrap; }
.badge.good { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.badge.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.badge.crit { background: var(--crit-soft); border-color: var(--crit); color: var(--crit); }
.badge.info { background: var(--info-soft); border-color: var(--info); color: var(--info); }
.badge.neutral { background: var(--surface-3); border-color: var(--line); color: var(--muted); }
.badge.muted { background: transparent; border-color: var(--line); color: var(--muted); }

/* ---------- Formulare ---------- */
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=search], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font-family: inherit; font-size: 14px;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
.field { margin-bottom: 13px; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 16px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 14px; color: var(--ink); }
.check input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 18px; }
legend { font-family: var(--f-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); padding: 0 6px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 13.5px;
  font-family: inherit; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { border-color: var(--crit); color: var(--crit); }
.btn.danger:hover { background: var(--crit-soft); }
.btn.small { padding: 3.5px 10px; font-size: 12.5px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .field { margin: 0; min-width: 150px; }
.filters .field.wide { min-width: 280px; flex: 1; }

/* ---------- Details ---------- */
.dl { display: grid; grid-template-columns: 168px 1fr; gap: 6px 14px; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0;
  border-bottom: 1px dashed var(--line-soft); font-size: 13.5px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-variant-numeric: tabular-nums; text-align: right; }
.kv.total { font-weight: 600; font-size: 15px; border-top: 1px solid var(--line); border-bottom: 0;
  margin-top: 4px; padding-top: 8px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 14px 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 5px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent); }
.timeline .when { font-family: var(--f-mono); font-size: 11px; color: var(--muted); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }

.purpose { font-size: 13px; color: var(--muted); max-width: 460px; overflow-wrap: anywhere; }
.mailbody { white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; background: var(--surface-2);
  border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px; max-height: 520px;
  overflow: auto; }
.proposal { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  margin-bottom: 10px; background: var(--surface-2); }
.proposal.best { border-color: var(--accent); background: var(--accent-soft); }
.proposal .rule { font-weight: 600; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px;
  font-size: 13px; color: var(--muted); }

/* ---------- Anmeldung ---------- */
.centerpage { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.loginbox { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 30px 32px; width: 100%; max-width: 400px; }
.loginbox h1 { font-size: 21px; margin: 0 0 4px; }
.loginbox p.lead { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.hotelpick { display: grid; gap: 12px; }
.hotelpick button {
  display: block; width: 100%; text-align: left; padding: 15px 17px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface-2); cursor: pointer; font-family: inherit;
  color: var(--ink);
}
.hotelpick button:hover { border-color: var(--accent); background: var(--accent-soft); }
.hotelpick .name { font-weight: 600; font-size: 16px; }
.hotelpick .meta { color: var(--muted); font-size: 13px; }

@media (max-width: 940px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: column; }
  .main { padding: 20px 16px 50px; }
}

/* ---------- Spaltenfilter ---------- */
th.tf-head { position: relative; white-space: nowrap; }
.tf-label { cursor: pointer; }
.tf-label:hover { color: var(--ink); }
th.tf-asc .tf-label::after { content: " ↑"; }
th.tf-desc .tf-label::after { content: " ↓"; }
.tf-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px;
  padding: 0 4px; margin-left: 4px; font-family: var(--f-mono); border-radius: 3px; }
.tf-btn:hover { color: var(--accent-ink); background: var(--surface-3); }
th.tf-active { color: var(--accent-ink); }
th.tf-active .tf-btn { color: var(--accent-ink); background: var(--accent-soft); font-weight: 600; }
.tf-panel { z-index: 30; min-width: 240px; max-width: 360px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 10px; text-transform: none; letter-spacing: 0;
  font-family: var(--f-sans); font-size: 13px; font-weight: 400; color: var(--ink); white-space: normal; }
.tf-panel input[type=search] { width: 100%; padding: 5px 8px; font-size: 13px; margin-bottom: 6px; }
.tf-tools { display: flex; gap: 12px; font-size: 12px; margin-bottom: 6px; }
.tf-list { max-height: 280px; overflow-y: auto; border-top: 1px solid var(--line-soft); padding-top: 6px; }
.tf-list label { display: flex; align-items: center; gap: 6px; padding: 3px 2px; margin: 0; cursor: pointer;
  color: var(--ink); font-size: 13px; border-radius: 3px; }
.tf-list label:hover { background: var(--surface-2); }
.tf-list input { width: auto; margin: 0; }
.tf-count { margin-left: auto; font-family: var(--f-mono); font-size: 11px; color: var(--muted); }
.tf-status { display: flex; align-items: center; gap: 12px; padding: 7px 12px; font-size: 12.5px;
  color: var(--muted); border-bottom: 1px solid var(--line-soft); background: var(--surface-2); }
.tf-status button:disabled { opacity: .45; cursor: default; }
.tf-status { flex-wrap: wrap; }
.tf-status > span:first-child { flex: 1 1 auto; white-space: nowrap; }
.tf-search { flex: 0 0 240px; width: 240px; padding: 4px 8px; font-size: 12.5px; margin: 0; }
.tf-search-active { border-color: var(--accent); }
.tf-range { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tf-range input[type=date], .tf-range select { width: auto; padding: 3px 6px; font-size: 12.5px; margin: 0; }
.tf-range-active { color: var(--accent-ink); font-weight: 600; }
.tf-range-active input[type=date] { border-color: var(--accent); }
.tf-reset-active { border-color: var(--accent); color: var(--accent-ink); }
[hidden] { display: none !important; }
tfoot .tf-total td { border-top: 2px solid var(--line); background: var(--surface-2); font-size: 13.5px; padding-top: 9px; padding-bottom: 9px; }
tfoot .tf-total .purpose { font-weight: 400; }

/* Ansichten-Leiste (ersetzt das Filterformular über den Tabellen) */
.views { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 14px; }
.views a:not(.btn) { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 13px; color: var(--ink); text-decoration: none; background: var(--surface); }
.views a:not(.btn):hover { border-color: var(--accent); }
.views a.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.views .spacer { margin-left: auto; }

/* ---------- Suchbare Auswahl ---------- */
.pk { position: relative; }
.pk input[type=text] { padding-right: 30px; }
.pk-hidden { display: none !important; }
.pk-clear { position: absolute; right: 4px; top: 4px; width: 24px; height: 24px; border: 0; background: transparent;
  color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; border-radius: 3px; display: none; }
.pk.pk-has .pk-clear { display: block; }
.pk-clear:hover { background: var(--surface-3); color: var(--ink); }
.pk-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 40; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.14);
  max-height: 340px; overflow-y: auto; margin-top: 2px; }
.pk-item { padding: 7px 10px; font-size: 13.5px; cursor: pointer; border-bottom: 1px solid var(--line-soft);
  font-variant-numeric: tabular-nums; }
.pk-item:last-child { border-bottom: 0; }
.pk-item:hover, .pk-item.pk-active { background: var(--accent-soft); color: var(--accent-ink); }
.pk-item.pk-selected { font-weight: 600; }
.pk-none { padding: 9px 10px; font-size: 12.5px; color: var(--muted); }
.pk-hint { font-size: 12px; color: var(--muted); margin-top: 3px; min-height: 14px; }
.pk-hint.pk-error { color: var(--crit); }

/* Belegprüfung */
.bar { display:inline-block; vertical-align:middle; width:110px; height:8px; background:var(--surface-3); border-radius:4px; overflow:hidden; margin-right:6px; }
.bar i { display:block; height:100%; background:var(--good); }

/* Kontoauszüge zum Aufklappen (Reiter „Kontoauszüge“) */
details.auszug { margin-bottom: 8px; }
details.auszug > summary { list-style: none; font-size: 13.5px; }
details.auszug > summary::-webkit-details-marker { display: none; }
details.auszug > summary::before { content: "▸"; color: var(--muted); font-size: 12px; width: 12px; }
details.auszug[open] > summary::before { content: "▾"; }
details.auszug > summary:hover { background: var(--surface-2); }
#auszug-leiste .tf-search { flex: 1 1 320px; width: auto; }

/* Seitenleiste: Jahre ein-/ausblenden */
.yearbox .years { display:flex; flex-wrap:wrap; gap:6px; margin:6px 0 8px; }
.yearbox form { margin:0; }
.yearbox .year { font: 600 13px var(--f-mono); padding:4px 10px; border-radius:6px; border:1px solid var(--line); cursor:pointer; }
.yearbox .year.on { background: var(--accent); color:#fff; border-color: var(--accent); }
.yearbox .year.off { background: var(--surface); color: var(--muted); text-decoration: line-through; }
.yearbox .year:hover { filter: brightness(1.08); }

/* Excel-Export */
.tf-status .tf-excel { margin-left: auto; }
.tf-excel-only { justify-content: flex-end; }

/* Startseite: Kacheln als Links (Marc 12.09.) */
a.card.tile { display: block; color: inherit; text-decoration: none; transition: border-color .12s, transform .12s; }
a.card.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
a.card.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hotelpick .todo { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.hotelpick .todo span { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--text); }
.hotelpick .todo span.warn { background: #fdecc8; }
.hotelpick .todo span.crit { background: #f8d7da; }
