:root {
  color-scheme: light;
  --brand: #1e6b45;
  --brand-soft: #e3f3e9;
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-2: #f7f8f6;
  --text: #1d2621;
  --text-2: #52514e;
  --muted: #6b756f;
  --line: #e1e7e3;
  --grid: #e9ece9;
  --series-1: #2a78d6; /* Einnahmen / Anwesenheit */
  --series-2: #eb6834; /* Ausgaben */
  --warn-bg: #fff3dc;
  --neg: #b3261e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 2px 10px rgba(0, 0, 0, .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --brand: #2f8c5d;
    --brand-soft: #1d3a2b;
    --bg: #111613;
    --surface: #1a1f1c;
    --surface-2: #202622;
    --text: #eef1ee;
    --text-2: #c3c2b7;
    --muted: #a3ada6;
    --line: #2d3530;
    --grid: #2a312d;
    --series-1: #3987e5;
    --series-2: #d95926;
    --warn-bg: #3d3220;
    --neg: #f2817a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", Tahoma, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--neg); }

/* ---------- Kopf */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--brand); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 8px; }
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { font-size: 13px; opacity: .85; }
.top-right { display: flex; align-items: center; gap: 10px; position: relative; }
.stamp { font-size: 13px; opacity: .9; white-space: nowrap; }
@media (max-width: 560px) { .stamp { display: none; } }
.icon-btn { min-width: 42px; min-height: 42px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .4); background: transparent; color: #fff; font-size: 20px; cursor: pointer; }
.menu { position: absolute; top: 100%; inset-inline-end: 0; margin-top: 6px; background: var(--surface); color: var(--text); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18); display: flex; flex-direction: column; min-width: 200px; overflow: hidden; }
.menu button { border: 0; background: none; text-align: start; padding: 13px 16px; font: inherit; color: inherit; cursor: pointer; }
.menu button + button { border-top: 1px solid var(--line); }

main { max-width: 1180px; margin: 0 auto; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 16px; }
h2.section { font-size: 17px; margin: 0 0 4px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

/* ---------- Formulare */
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
input { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%; }
button { font: inherit; }
button.primary { background: var(--brand); border: 1px solid var(--brand); color: #fff; font-weight: 700; border-radius: 10px; min-height: 46px; padding: 0 18px; cursor: pointer; }
.dlg-actions button:not(.primary) { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 10px; min-height: 44px; padding: 0 16px; cursor: pointer; }
.link { border: 0; background: none; color: var(--brand); text-decoration: underline; cursor: pointer; margin-top: 8px; }
.error { color: var(--neg); margin: 0; font-size: 14px; }
input:focus, button:focus-visible, .tabs button:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 1px; }
.login { max-width: 420px; margin: 32px auto; display: flex; flex-direction: column; gap: 6px; }
.login h1 { margin: 0; font-size: 22px; }
.login form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }

/* ---------- Hinweise & Reiter */
.readonly { display: inline-block; font-size: 12.5px; color: var(--text-2); background: var(--brand-soft); border-radius: 999px; padding: 3px 10px; margin-bottom: 10px; }
.notice { background: var(--warn-bg); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; font-size: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; color: var(--muted); padding: 10px 14px; font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--brand); }

/* ---------- Kennzahlen */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { font-size: 13px; color: var(--muted); }
.tile .value { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .hint { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.grid2 { display: grid; gap: 16px; grid-template-columns: 1fr; margin-bottom: 16px; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Diagramme */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--line); stroke-width: 1; }
.chart .s1 { fill: var(--series-1); }
.chart .s2 { fill: var(--series-2); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar-group .bar, .chart g.col:hover .bar { opacity: .85; }
.chart .vlabel { fill: var(--text-2); font-size: 10.5px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend i.s1 { background: var(--series-1); }
.legend i.s2 { background: var(--series-2); }
.tooltip { position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; box-shadow: 0 6px 20px rgba(0, 0, 0, .15); max-width: 260px; }
.tooltip b { display: block; margin-bottom: 2px; }
.tooltip .row { display: flex; align-items: center; gap: 6px; }

/* horizontale Balken */
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.hbar .track { height: 12px; background: var(--surface-2); border-radius: 0 4px 4px 0; }
.hbar .fill { height: 12px; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
[dir="rtl"] .hbar .track, [dir="rtl"] .hbar .fill { border-radius: 4px 0 0 4px; }

/* ---------- Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: start; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:hover td { background: var(--surface-2); }
td.heat { text-align: center; font-variant-numeric: tabular-nums; border: 2px solid var(--surface); border-radius: 4px; min-width: 52px; }
.search { max-width: 280px; margin-bottom: 10px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; }

dialog { border: 0; border-radius: 16px; padding: 18px; width: min(420px, calc(100vw - 32px)); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog h2 { margin: 0; font-size: 19px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; }
.toast { position: fixed; inset-inline: 16px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 30; max-width: 420px; margin: 0 auto;
  padding: 12px 16px; border-radius: 12px; background: #1d2621; color: #fff; text-align: center; font-weight: 600; }
.toast.err { background: var(--neg); }
@media print { .top, .tabs, .readonly { display: none !important; } body { background: #fff; } .card, .tile { box-shadow: none; } }
.tooltip .legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tooltip .legend-dot.s1 { background: var(--series-1); }
.tooltip .legend-dot.s2 { background: var(--series-2); }
