/* Verwaltung M15 – Oberfläche
   Schriften: Source Sans 3 (Oberfläche, Zahlen) und Source Serif 4 (Seitentitel, Kennzahlen), beide SIL OFL, lokal eingebunden. */

@font-face { font-family: "Source Sans 3"; src: url("fonts/source-sans-3-latin-wght-normal.woff2") format("woff2"); font-weight: 200 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("fonts/source-serif-4-latin-wght-normal.woff2") format("woff2"); font-weight: 200 900; font-style: normal; font-display: swap; }

/* ---------- Farben: Rollen, keine Rohwerte in Komponenten ---------- */
:root {
  color-scheme: light dark;

  --paper: #f2efe7;        /* Grund hinter den Karten */
  --surface: #fcfbf8;      /* Karten, Felder */
  --sunken: #ebe7dc;       /* Tabellenkopf, Zeilen-Hover */
  --ink: #1b2127;          /* Haupttext */
  --ink-2: #4f5a65;        /* Zweittext */
  --line: #ddd7c9;         /* feine Trennung */
  --line-strong: #b9b2a0;  /* kräftigere Trennlinie */
  --edge: #857f6e;         /* Feldrand, leere Balken (mind. 3:1) */

  --accent: #1f4f7b;       /* Hauptaktion, Links */
  --on-accent: #ffffff;
  --accent-hover: #173d60;
  --link: #1f4f7b;
  --focus: #1f4f7b;

  --shell: #1d2a33;        /* Seitenleiste */
  --shell-hi: #2c3e4a;
  --shell-ink: #eef2f4;
  --shell-ink-2: #a9bac5;
  --shell-line: #34464f;
  --shell-focus: #ffd58a;

  --ok: #1b6b3b;    --ok-bg: #e2f1e8;    --ok-solid: #2f8a52;
  --warn: #8a4f00;  --warn-bg: #fbebc7;  --warn-solid: #c77b0a;
  --bad: #a3281b;   --bad-bg: #fbe2de;   --bad-solid: #c4392b;
  --wait: #56606b;  --wait-bg: #e9e6dd;

  --shadow: rgba(27, 33, 39, 0.16);
  --selection: #cfe0f0;

  --font-ui: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;

  --r-sm: 6px;
  --r-md: 10px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12171b;
    --surface: #1a2127;
    --sunken: #222b32;
    --ink: #e7eaed;
    --ink-2: #a3afb9;
    --line: #2b353d;
    --line-strong: #4a5864;
    --edge: #6b7a87;

    --accent: #86b9e8;
    --on-accent: #0c1b29;
    --accent-hover: #a5cdf0;
    --link: #8fc0ec;
    --focus: #9cc9f1;

    --shell: #0d1215;
    --shell-hi: #1d282f;
    --shell-ink: #e7ecef;
    --shell-ink-2: #9aabb6;
    --shell-line: #222e35;
    --shell-focus: #ffd58a;

    --ok: #6fd596;    --ok-bg: #16301f;    --ok-solid: #3fa465;
    --warn: #f0b64f;  --warn-bg: #352809;  --warn-solid: #d6921f;
    --bad: #ff9a8f;   --bad-bg: #3a1a17;   --bad-solid: #e0594a;
    --wait: #a3afb9;  --wait-bg: #252e35;

    --shadow: rgba(0, 0, 0, 0.5);
    --selection: #2c4b66;
  }
}

/* ---------- Grundlagen ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-block-start: 1rem; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: lining-nums;
}
::selection { background: var(--selection); color: var(--ink); }
:root { accent-color: var(--accent); caret-color: var(--accent); scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: from-font; }
a:hover { text-decoration-thickness: 2px; }
.skip { position: absolute; inset-inline-start: var(--space-4); inset-block-start: -4rem; background: var(--surface); color: var(--ink); padding: var(--space-2) var(--space-4); border-radius: var(--r-sm); z-index: 10; }
.skip:focus { inset-block-start: var(--space-3); }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 0.8125rem; height: 0.8125rem; stroke-width: 2.25; }

/* ---------- Rahmen: Seitenleiste links, Inhalt rechts ---------- */
.app { min-height: 100dvh; }
.side { background: var(--shell); color: var(--shell-ink); padding: var(--space-3) var(--space-4) var(--space-4); }
.side a { color: inherit; text-decoration: none; }
.side :focus-visible { outline-color: var(--shell-focus); }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-block-end: var(--space-3); }
.brand { display: flex; align-items: center; gap: var(--space-2); font-family: var(--font-display); font-size: 1.1875rem; font-weight: 600; letter-spacing: -0.005em; }
.brand .icon { width: 1.625rem; height: 1.625rem; stroke-width: 1.5; color: var(--shell-focus); }
.side-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-1); }
.side-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 3.25rem; padding: var(--space-2) 2px; border-radius: var(--r-sm); font-size: 0.8125rem; font-weight: 500; color: var(--shell-ink-2); text-align: center; hyphens: auto; }
.side-nav a:hover { background: var(--shell-hi); color: var(--shell-ink); }
.side-nav a[aria-current="page"] { background: var(--shell-hi); color: var(--shell-ink); font-weight: 650; }
.side-nav a[aria-current="page"] .icon { color: var(--shell-focus); }
.side-user { display: flex; align-items: center; gap: var(--space-2); font-size: 0.875rem; color: var(--shell-ink-2); }
.side-user form { margin: 0; }
.side-user button.link { background: none; border: 0; padding: var(--space-2) var(--space-1); min-height: 2.75rem; color: var(--shell-ink); font: inherit; font-size: 0.875rem; font-weight: 500; text-decoration: underline; text-underline-offset: 0.18em; cursor: pointer; }
.side-user button.link:hover { background: none; color: var(--shell-ink); text-decoration-thickness: 2px; }

main { max-width: 74rem; padding: var(--space-5) var(--space-4) var(--space-4); }
.app.solo main { margin-inline: auto; }
.foot { margin-block-start: var(--space-6); padding-block-start: var(--space-4); border-block-start: 1px solid var(--line); color: var(--ink-2); font-size: 0.8125rem; }

@media (min-width: 62rem) {
  .app { display: grid; grid-template-columns: 15rem minmax(0, 1fr); }
  .app.solo { display: block; }
  .side { position: sticky; inset-block-start: 0; height: 100dvh; display: flex; flex-direction: column; padding: var(--space-5) var(--space-3) var(--space-4); }
  .side-top { display: block; margin: 0 var(--space-3) var(--space-5); }
  .side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
  .side-nav a { flex-direction: row; justify-content: flex-start; gap: var(--space-3); min-height: 2.75rem; padding: var(--space-2) var(--space-3); font-size: 0.9375rem; text-align: start; hyphens: none; }
  .side-user { flex-direction: column; align-items: flex-start; gap: 0; padding: var(--space-3) var(--space-3) 0; border-block-start: 1px solid var(--shell-line); }
  .side-user button.link { padding-inline: 0; }
  main { padding: var(--space-6) var(--space-7) var(--space-5); }
}

/* ---------- Seitenkopf und Überschriften ---------- */
h1 { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.5rem, 1.25rem + 1vw, 1.875rem); line-height: 1.2; letter-spacing: -0.012em; margin: 0 0 var(--space-4); text-wrap: balance; }
h2 { font-size: 1.0625rem; font-weight: 650; line-height: 1.3; margin: 0 0 var(--space-3); text-wrap: balance; }
p { margin: 0 0 var(--space-3); }
.mute { color: var(--ink-2); }
.row { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-5); align-items: center; margin: 0 0 var(--space-5); }

/* ---------- Karten ---------- */
.card {
  --cardbg: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--space-4) var(--space-4) var(--space-3);
  margin: 0 0 var(--space-5);
  overflow-x: auto;
  /* Schattenkante zeigt, dass seitlich weitere Spalten liegen */
  background:
    linear-gradient(to right, var(--cardbg) 30%, transparent) left center / 2.5rem 100% no-repeat local,
    linear-gradient(to left, var(--cardbg) 30%, transparent) right center / 2.5rem 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--shadow), transparent) left center / 0.75rem 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--shadow), transparent) right center / 0.75rem 100% no-repeat scroll,
    var(--surface);
}
@media (min-width: 40rem) { .card { padding: var(--space-5) var(--space-5) var(--space-4); } }

/* ---------- Kennzahlen und offene Punkte ---------- */
.summary { display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-6); margin: 0 0 var(--space-5); padding: 0 0 var(--space-5); border-block-end: 1px solid var(--line); }
.summary dl { display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-6); margin: 0; flex: 1 1 24rem; }
.summary dl > div { min-width: 7.5rem; }
.summary dt { font-size: 0.8125rem; color: var(--ink-2); }
.summary dd { margin: 0; font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; line-height: 1.25; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.summary dd.neg { color: var(--bad); }
.todo { flex: 1 1 18rem; margin: 0; padding: 0; list-style: none; display: grid; gap: var(--space-1); align-content: start; }
.todo li { display: flex; gap: var(--space-2); align-items: baseline; }
.todo a { font-weight: 600; }
.todo li.bad .icon { color: var(--bad); }
.todo li.ok .icon { color: var(--ok); }
.todo li.warn .icon { color: var(--warn); }
.todo .icon { position: relative; inset-block-start: 2px; }

/* ---------- Tabellen ---------- */
table { border-collapse: collapse; width: 100%; font-size: 0.9375rem; }
th, td { padding: 0.5rem 0.625rem; border-block-end: 1px solid var(--line); text-align: start; vertical-align: top; }
th { color: var(--ink-2); font-size: 0.8125rem; font-weight: 600; white-space: nowrap; background: var(--sunken); }
tr:first-child > th:first-child { border-start-start-radius: var(--r-sm); }
tr:first-child > th:last-child { border-start-end-radius: var(--r-sm); }
td.n, th.n { text-align: end; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
tr:last-child > td, tr:last-child > th { border-block-end: 0; }
tr:has(> th:first-child):not(:first-child) th { background: transparent; color: var(--ink); font-size: 0.9375rem; font-weight: 650; border-block-start: 2px solid var(--line-strong); }
@media (hover: hover) { tbody tr:hover > td, table tr:hover > td { background: var(--sunken); } }
td a { font-weight: 550; }
.neg { color: var(--bad); }
.pos { color: var(--ok); }

/* ---------- Status ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px 1px 7px; border-radius: 99px; font-size: 0.8125rem; font-weight: 600; white-space: nowrap; line-height: 1.5; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.wait, .chip.none { background: var(--wait-bg); color: var(--wait); }

/* Mietbalken: zwölf Monate je Einheit. Form und Füllung tragen die Bedeutung, nicht nur die Farbe. */
.mb { display: inline-flex; align-items: stretch; gap: 2px; height: 1.125rem; vertical-align: middle; }
.mb i { display: block; width: 0.5625rem; border: 1px solid transparent; border-radius: 2px; }
.mb .s-ok { background: var(--ok-solid); border-color: var(--ok-solid); }
.mb .s-teil { border-color: var(--warn-solid); background: linear-gradient(to top, var(--warn-solid) 50%, transparent 50%); }
.mb .s-offen { border-color: var(--bad-solid); background: repeating-linear-gradient(135deg, var(--bad-solid) 0 2px, transparent 2px 4px); }
.mb .s-zukunft { border-color: var(--edge); background: transparent; }
.mb .s-leer { align-self: center; height: 2px; border: 0; border-radius: 1px; background: var(--edge); }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); margin: var(--space-3) 0 0; padding: 0; list-style: none; font-size: 0.8125rem; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: var(--space-2); }
.legend .mb { height: 1rem; }

.flash { display: block; padding: var(--space-3) var(--space-4); border-radius: var(--r-sm); margin: 0 0 var(--space-4); font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--bad-bg); color: var(--bad); }

/* ---------- Formulare und Schaltflächen ---------- */
label { display: block; font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); }
input, select, textarea, button { font: inherit; color: var(--ink); }
input, select, textarea { display: block; width: 100%; margin-block-start: 3px; padding: 0.5rem 0.625rem; min-height: 2.5rem; border: 1px solid var(--edge); border-radius: var(--r-sm); background: var(--surface); font-size: 1rem; font-weight: 400; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-2); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--focus); }
input::placeholder, textarea::placeholder { color: var(--ink-2); opacity: 0.8; }
input[type="checkbox"], input[type="radio"] { display: inline-block; width: 1.125rem; min-height: 0; margin: 0 var(--space-2) 0 0; vertical-align: -3px; }
form.grid, .grid-in { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: var(--space-3) var(--space-4); align-items: end; }
form.inl { display: inline-flex; gap: var(--space-2); align-items: center; margin: 0; }
form.inl label { display: inline-flex; align-items: center; gap: var(--space-2); }
form.inl select { width: auto; margin: 0; }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); padding: 0.5rem 1rem; min-height: 2.5rem; border: 1px solid var(--accent); border-radius: var(--r-sm); background: var(--accent); color: var(--on-accent); font-weight: 600; text-decoration: none; cursor: pointer; }
button:hover, .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
button.sec, .btn.sec { background: transparent; color: var(--accent); }
button.sec:hover, .btn.sec:hover { background: var(--sunken); color: var(--accent-hover); }
button.link { background: none; border: 0; color: var(--link); text-decoration: underline; padding: var(--space-1); min-height: 0; font-weight: 500; }
button:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
details > summary { cursor: pointer; font-weight: 600; padding-block: var(--space-2); min-height: 2.5rem; }
details[open] > summary { margin-block-end: var(--space-3); }
textarea { resize: vertical; }
input[type="file"] { padding: 0.3125rem; font-size: 0.875rem; color: var(--ink-2); }
input[type="file"]::file-selector-button { margin-inline-end: var(--space-3); padding: 0.3125rem 0.75rem; border: 1px solid var(--accent); border-radius: var(--r-sm); background: transparent; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
input[type="file"]::file-selector-button:hover { background: var(--sunken); }
td input[type="file"] { min-width: 11rem; }
td form.inl { flex-wrap: wrap; }
td form.inl input[name="jahr"] { width: 5.5rem; }

.login { max-width: 24rem; margin: 12vh auto 0; }
.login-brand { display: flex; align-items: center; gap: var(--space-2); justify-content: center; margin: 0 0 var(--space-4); font-family: var(--font-display); font-size: 1.375rem; font-weight: 600; }
.login-brand .icon { width: 2rem; height: 2rem; stroke-width: 1.5; color: var(--accent); }

@media (pointer: coarse) {
  input, select, button, .btn { min-height: 2.75rem; }
  th, td { padding-block: 0.625rem; }
}
@media (prefers-reduced-motion: no-preference) {
  button, .btn, .side-nav a, input, select, textarea { transition: background-color 0.12s ease-out, border-color 0.12s ease-out, color 0.12s ease-out; }
}
@media (max-width: 26rem) {
  .side-nav a { font-size: 0.75rem; padding-inline: 0; }
}
@media (max-width: 40rem) {
  th, td { padding-inline: 0.4375rem; }
  .summary dd { font-size: 1.3125rem; }
}
@media print {
  .side, .foot, form, .noprint, .skip { display: none !important; }
  .app { display: block; }
  body { background: #fff; color: #000; }
  .card { border: 0; padding: 0; background: none; overflow: visible; }
}

.grid > .span { grid-column: 1 / -1; }
.grid > .wide { grid-column: span 2; }
@media (max-width: 40rem) { .grid > .wide { grid-column: 1 / -1; } }
.scroll { overflow-x: auto; }
