/* ---------- Design-Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f4f3f0;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e0da;
  --grid: #e8e6e1;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7973;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --series-1: #2a78d6; /* Immobilien */
  --series-2: #eb6834; /* DJ */
  --forecast-fill: #d9e7f8;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-ink: #006300;
  --warning-ink: #7a5200;
  --serious-ink: #9a3e14;
  --critical-ink: #a32424;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
  --radius: 12px;
  /* Kategorie-Farben (validiert: farbenblind-sicher, feste Reihenfolge) */
  --cat-1: #2a78d6; --cat-2: #eb6834; --cat-3: #1baf7a; --cat-4: #eda100;
  --cat-5: #e87ba4; --cat-6: #008300; --cat-7: #6250d6; --cat-8: #e34948;
  --surplus: #d6d4cd;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface-1: #1a1a19;
    --surface-2: #262624;
    --border: #33332f;
    --grid: #2c2c29;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e86;
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --forecast-fill: #1f3553;
    --good-ink: #5fd35f;
    --warning-ink: #fac55a;
    --serious-ink: #f2a483;
    --critical-ink: #f08a8a;
    --shadow: none;
    --cat-1: #3987e5; --cat-2: #d95926; --cat-3: #199e70; --cat-4: #c98500;
    --cat-5: #d55181; --cat-6: #008300; --cat-7: #9085e9; --cat-8: #e66767;
    --surplus: #44443f;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface-1: #1a1a19; --surface-2: #262624; --border: #33332f; --grid: #2c2c29;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
  --accent: #3987e5; --series-1: #3987e5; --series-2: #d95926; --forecast-fill: #1f3553;
  --good-ink: #5fd35f; --warning-ink: #fac55a; --serious-ink: #f2a483; --critical-ink: #f08a8a;
  --shadow: none;
  --cat-1: #3987e5; --cat-2: #d95926; --cat-3: #199e70; --cat-4: #c98500;
  --cat-5: #d55181; --cat-6: #008300; --cat-7: #9085e9; --cat-8: #e66767;
  --surplus: #44443f;
}

/* ---------- Grundlayout ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text-primary);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.5rem; font-weight: 650; }
h2 { font-size: 1.1rem; font-weight: 620; }
h3 { font-size: .95rem; font-weight: 600; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.small { font-size: .85rem; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; padding: 20px 14px;
  background: var(--surface-1); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}
.brand { white-space: nowrap; font-weight: 700; font-size: 1.05rem; padding: 4px 10px 16px; letter-spacing: -.01em; }
.brand span { color: var(--accent); }
.nav-link {
  display: block; padding: 8px 10px; border-radius: 8px; color: var(--text-secondary);
  text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-link.active { background: var(--surface-2); color: var(--text-primary); font-weight: 600; }
.nav-section { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: 14px 10px 4px; }
.sidebar .spacer { flex: 1; }

.main { flex: 1; min-width: 0; padding: 28px 32px 48px; max-width: 1180px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head p { margin-top: 4px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 14px; }
.card-head p { margin-top: 2px; }
.stack > * + * { margin-top: 16px; }

/* ---------- Kennzahlen ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.tile .label { font-size: .8rem; color: var(--text-secondary); }
.tile .value { font-size: 1.35rem; font-weight: 650; letter-spacing: -.01em; margin-top: 2px; white-space: nowrap; }
.tile .sub { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.value.neg { color: var(--critical-ink); }

/* ---------- Status-Badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: .82rem; font-weight: 600; background: var(--surface-2); color: var(--text-primary); white-space: nowrap;
}
.badge::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.badge .ico { font-size: .8rem; }
.badge.ok { color: var(--good-ink); }
.badge.warning { color: var(--warning-ink); }
.badge.critical, .badge.tolerance { color: var(--serious-ink); }
.badge.lost { color: var(--critical-ink); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Balken (Grenze) ---------- */
.gauge { position: relative; padding: 34px 0 26px; }
.gauge-track {
  position: relative; height: 28px; border-radius: 6px; background: var(--surface-2); overflow: hidden;
  display: flex;
}
.seg { height: 100%; position: relative; }
.seg + .seg { box-shadow: inset 2px 0 0 var(--surface-1); }
.seg.rent { background: var(--series-1); }
.seg.dj { background: var(--series-2); }
.seg.forecast {
  background: repeating-linear-gradient(135deg, var(--forecast-fill) 0 6px, transparent 6px 10px);
  box-shadow: inset 0 0 0 1.5px var(--series-1);
  border-radius: 0 4px 4px 0;
}
.seg.over { box-shadow: inset 0 0 0 1.5px var(--critical); }
.marker { position: absolute; top: 28px; bottom: 20px; width: 0; border-left: 2px solid var(--text-primary); pointer-events: none; }
.marker.tol { border-left-style: dashed; border-left-color: var(--text-secondary); }
.marker-label {
  position: absolute; top: 0; transform: translateX(-50%); font-size: .75rem; white-space: nowrap;
  color: var(--text-secondary); line-height: 1.2; text-align: center;
}
.marker-label b { color: var(--text-primary); font-weight: 600; display: block; }
.marker-label.right { transform: translateX(-100%); text-align: right; }
.marker-label.left { transform: none; text-align: left; }
.marker-label.below { top: auto; bottom: 0; }
.gauge-axis { display: flex; justify-content: space-between; font-size: .75rem; color: var(--text-muted); margin-top: 10px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .82rem; color: var(--text-secondary); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.rent { background: var(--series-1); }
.legend i.dj { background: var(--series-2); }
.legend i.forecast { background: repeating-linear-gradient(135deg, var(--forecast-fill) 0 3px, transparent 3px 5px); box-shadow: inset 0 0 0 1.5px var(--series-1); }
.legend i.line { height: 0; width: 16px; border-radius: 0; border-top: 2px solid var(--text-primary); vertical-align: 3px; }
.legend i.line.dash { border-top-style: dashed; border-top-color: var(--text-secondary); }

/* ---------- Diagramm ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--text-muted); font-size: 11px; }
.chart .ref { stroke: var(--text-primary); stroke-width: 1.5; }
.chart .ref.tol { stroke: var(--text-secondary); stroke-dasharray: 5 4; }
.chart .ref-label { fill: var(--text-secondary); font-size: 11px; }
.chart .line-actual { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line-proj { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-dasharray: 5 4; stroke-linecap: round; }
.chart .area-actual { fill: var(--series-1); opacity: .12; }
.chart .dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.chart .today { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .crosshair { stroke: var(--text-muted); stroke-width: 1; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: .82rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.12); white-space: nowrap; opacity: 0; transition: opacity .1s;
}
.tooltip.show { opacity: 1; }
.tooltip .t-head { font-weight: 600; margin-bottom: 2px; }
.tooltip .t-row { display: flex; justify-content: space-between; gap: 16px; color: var(--text-secondary); }
.tooltip .t-row b { color: var(--text-primary); font-weight: 600; }

/* ---------- Hinweise ---------- */
.note {
  border-radius: 10px; padding: 10px 14px; font-size: .88rem; background: var(--surface-2); color: var(--text-secondary);
  border-left: 3px solid var(--text-muted);
}
.note.warn { border-left-color: var(--warning); }
.note.danger { border-left-color: var(--critical); }
.note.good { border-left-color: var(--good); }
.note strong { color: var(--text-primary); }

/* ---------- Tabellen & Formulare ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .78rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
td.r, th.r { text-align: right; }
tfoot td { font-weight: 600; border-bottom: none; }
.tag { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-secondary); white-space: nowrap; }
.tag.joint { box-shadow: inset 0 0 0 1px var(--text-muted); }

input, select, button { font: inherit; color: inherit; }
input[type="text"], input[type="password"], select {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-primary); min-width: 0;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input.amount { text-align: right; font-variant-numeric: tabular-nums; }
label.field { display: block; }
label.field > span { display: block; font-size: .8rem; color: var(--text-secondary); margin-bottom: 4px; }
label.field > small { display: block; font-size: .78rem; color: var(--text-muted); margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-1); cursor: pointer; font-weight: 550; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-secondary); padding: 6px 8px; }
.btn.ghost:hover { background: var(--surface-2); color: var(--text-primary); }
.btn.danger:hover { color: var(--critical-ink); }
.btn.icon { width: 34px; height: 34px; padding: 0; }

.form-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1.4fr auto; gap: 10px; align-items: end; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.saved { font-size: .82rem; color: var(--good-ink); opacity: 0; transition: opacity .2s; }
.saved.show { opacity: 1; }
.error-msg { color: var(--critical-ink); font-size: .85rem; min-height: 1.2em; }

.year-switch { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.year-switch strong { min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; }

details.datatable summary { cursor: pointer; font-size: .85rem; color: var(--text-secondary); }
details.datatable[open] summary { margin-bottom: 8px; }

.footnote { font-size: .8rem; color: var(--text-muted); margin-top: 24px; line-height: 1.6; }

/* ---------- Haushaltsrechnung ---------- */
.hh-top { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.tiles-3 { grid-template-columns: repeat(3, 1fr); }
.hero { margin: 4px 0 16px; }
.hero-label { font-size: .85rem; color: var(--text-secondary); }
.hero-value { font-size: 2.6rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.hero-value.neg, .neg-text { color: var(--critical-ink); }

.donut-wrap { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: center; margin-top: 20px; }
.donut svg { display: block; width: 100%; max-width: 220px; margin: 0 auto; }
.donut .seg-arc { stroke: var(--surface-1); stroke-width: 2; stroke-linejoin: round; cursor: default; transition: opacity .12s; }
.donut svg:hover .seg-arc { opacity: .55; }
.donut svg .seg-arc:hover { opacity: 1; }
.donut-k { fill: var(--text-muted); font-size: 12px; }
.donut-v { fill: var(--text-primary); font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; }
.donut-legend table td { padding: 6px 4px; }
.sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; background: var(--surface-2); }
.sw.surplus { box-shadow: inset 0 0 0 1px var(--border); }
.hatch, .sw.hatch {
  background: repeating-linear-gradient(135deg, var(--text-secondary) 0 2px, transparent 2px 5px) !important;
  box-shadow: inset 0 0 0 1.5px var(--text-secondary);
}

/* Bankansicht */
.quota { background: var(--surface-2); border-radius: 10px; padding: 14px; position: relative; }
.quota-head { display: flex; justify-content: space-between; align-items: baseline; font-size: .85rem; color: var(--text-secondary); }
.quota-head strong { font-size: 1.5rem; color: var(--text-primary); font-weight: 650; }
.quota input[type="range"] {
  --fill: 50%;
  width: 100%; margin: 10px 0 4px; height: 6px; border-radius: 999px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--border) var(--fill));
}
.quota input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-1);
  border: 2px solid var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.quota input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: var(--surface-1); border: 2px solid var(--accent);
}
.quota-axis { display: flex; justify-content: space-between; font-size: .72rem; color: var(--text-muted); }
.quota .saved { position: absolute; top: 14px; right: 70px; }
.kv { margin: 14px 0 0; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.kv dt { color: var(--text-secondary); }
.kv dd { margin: 0; white-space: nowrap; }
.kv .sum dt, .kv .sum dd { color: var(--text-primary); font-weight: 600; }
.kv .total { border-bottom: none; padding-top: 12px; }
.kv .total dt { color: var(--text-primary); font-weight: 600; align-self: center; }
.kv .total dd { font-size: 1.45rem; font-weight: 700; }
.kv .total.neg dd { color: var(--critical-ink); }
.kv .hint { border-bottom: none; padding: 2px 0; font-size: .82rem; }
.kv .hint dt, .kv .hint dd { color: var(--text-muted); }

/* Sparquote */
.save-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.save-head .hero-value { font-size: 2.2rem; }
.save-bar { display: flex; height: 22px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.save-bar .seg { height: 100%; }
.save-bar .seg + .seg { box-shadow: inset 2px 0 0 var(--surface-1); }
.save-bar .seg.hatch { box-shadow: inset 0 0 0 1.5px var(--text-secondary); }
.save-axis { display: flex; justify-content: space-between; font-size: .72rem; color: var(--text-muted); margin-top: 6px !important; }
.calc-table td { padding: 7px 4px; }
.calc-table tr.sum td { font-weight: 650; }
.calc-table tr:last-child td { border-bottom: none; font-size: 1.05rem; }

/* Kredite */
a.btn { text-decoration: none; color: inherit; }
.show-sm { display: none; }
.loan-edit { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr auto; gap: 10px; align-items: end; }
.loan-edit strong { align-self: center; }
@media (max-width: 720px) {
  .loan-edit { grid-template-columns: 1fr 1fr; }
  .loan-edit strong, .loan-edit .actions { grid-column: 1 / -1; }
  .show-sm { display: inline; }
  table.loans th, table.loans td { padding-left: 4px; padding-right: 4px; }
}
.nowrap { white-space: nowrap; }
tr.editing td { background: var(--surface-2); }

/* Kategorien & Posten */
.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 28px; align-items: start; }
.cat-group { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 6px; border-bottom: 2px solid var(--text-primary); }
.group-head h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.group-head span { font-weight: 650; }
.cat { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-1); box-shadow: inset 4px 0 0 var(--c); }
.cat-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 10px 12px 10px 16px; background: var(--surface-2); }
.cat-head h3 { font-size: .98rem; }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.cat-total { margin-left: auto; font-weight: 650; }
.cat-actions { display: flex; gap: 2px; width: 100%; justify-content: flex-end; margin-top: -2px; }
.cat-actions .btn { font-size: .8rem; padding: 3px 8px; }
.cat-actions .btn.icon { width: 28px; height: 28px; padding: 0; }
.btn:disabled { opacity: .35; cursor: default; }
.tag.savings { color: var(--good-ink); box-shadow: inset 0 0 0 1px currentColor; background: transparent; }
.cat table.items td { padding: 7px 10px 7px 16px; font-size: .9rem; }
.cat table.items tr:last-child td { border-bottom: none; }
.cat table.items td.amt { width: 120px; white-space: nowrap; }
.cat tr.item { cursor: pointer; }
.cat tr.item:hover td, .cat tr.item:focus-visible td { background: var(--surface-2); }
.cat tr.item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.row-actions { width: 1%; white-space: nowrap; }
.row-actions .btn { font-size: .78rem; padding: 2px 6px; opacity: 0; }
.cat tr.item:hover .row-actions .btn, .cat tr.item:focus-within .row-actions .btn { opacity: 1; }
.row-note { width: 1%; white-space: nowrap; }
.cat tr.editing input, .cat tr.editing select { padding: 5px 8px; }
.edit-grid { display: grid; grid-template-columns: 1fr; gap: 6px; }
.cat .empty { padding: 10px 16px; }
.add-item { margin: 4px 8px 6px; font-size: .85rem; color: var(--accent); }
.cat.rent .cat-head .tag { font-size: .7rem; }
.cat.rent tr.ro td { color: var(--text-secondary); }
.result-row {
  grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline;
  padding: 14px 16px; border-radius: 10px; background: var(--surface-2); font-weight: 600;
}
.result-row strong { font-size: 1.4rem; }
.result-row.neg strong { color: var(--critical-ink); }

/* Dialog */
.dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); color: var(--text-primary);
  padding: 22px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.dialog::backdrop { background: rgba(0,0,0,.35); }
fieldset.field { border: none; padding: 0; margin: 0; }
fieldset.field > legend { font-size: .8rem; color: var(--text-secondary); margin-bottom: 6px; padding: 0; }
.seg-control > label { display: inline-block; }
.seg-control input { position: absolute; opacity: 0; }
.seg-control span { display: inline-block; padding: 7px 16px; border: 1px solid var(--border); cursor: pointer; font-weight: 550; }
.seg-control label:first-of-type span { border-radius: 8px 0 0 8px; }
.seg-control label:last-of-type span { border-radius: 0 8px 8px 0; margin-left: -1px; }
.seg-control input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg-control input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch input { position: absolute; opacity: 0; }
.swatch span { display: block; width: 30px; height: 30px; border-radius: 50%; background: var(--c); cursor: pointer; box-shadow: inset 0 0 0 2px var(--surface-1); }
.swatch input:checked + span { outline: 2px solid var(--text-primary); outline-offset: 2px; }
.swatch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--accent); }
.check small { display: block; color: var(--text-muted); font-size: .8rem; }

/* ---------- Profil ---------- */
.profile-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
.form-grid .full { grid-column: 1 / -1; }
input[type="email"], input[type="tel"], input[type="date"], textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-primary); min-width: 0; font: inherit;
}
textarea { resize: vertical; }
textarea:focus, input[type="email"]:focus, input[type="tel"]:focus, input[type="date"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.photo-box { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.photo-frame {
  width: 120px; height: 140px; border-radius: 10px; background: var(--surface-2); overflow: hidden;
  display: grid; place-items: center; border: 1px solid var(--border);
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.note a { color: var(--accent); }
#pdf-submit:disabled { opacity: .6; cursor: progress; }

/* ---------- DJ Gigs ---------- */
table.gigs td.c, table.gigs th.c { text-align: center; }
table.gigs tr.played td:first-child { box-shadow: inset 4px 0 0 var(--good); }
table.gigs tr.open td:first-child { box-shadow: inset 4px 0 0 var(--border); }
table.gigs td:first-child, table.gigs th:first-child { padding-left: 14px; }
table.gigs tr.open td { color: var(--text-secondary); }
table.gigs .info-cell { color: var(--text-secondary); font-size: .85rem; max-width: 280px; }
table.gigs .icon-sm { width: 30px; height: 30px; padding: 0; }
table.gigs input.inv { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
.legend i.played { background: var(--good); }
.legend i.open { background: var(--border); }
.gig-form { display: grid; grid-template-columns: 150px 2fr 1fr 1fr; gap: 10px; align-items: end; }
.gig-form .info { grid-column: 1 / 3; }
.gig-form .check.inline { align-items: center; padding-bottom: 9px; }
.gig-form .check.inline input { margin-top: 0; }
.gig-form .actions { grid-column: 4; }
@media (max-width: 720px) {
  table.gigs th, table.gigs td { padding-left: 3px; padding-right: 3px; font-size: .84rem; }
  table.gigs td:first-child, table.gigs th:first-child { padding-left: 9px; }
  table.gigs .icon-sm { width: 26px; height: 26px; display: block; }
  table.gigs .row-btns { width: 1%; }
}
@media (max-width: 900px) {
  .gig-form { grid-template-columns: 1fr 1fr; }
  .gig-form .event, .gig-form .info, .gig-form .actions { grid-column: 1 / -1; }
  .gig-form .check.inline { grid-column: 1 / -1; padding-bottom: 0; }
}

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-size: 1.3rem; margin-bottom: 4px; }

/* ---------- Mobil ---------- */
@media (max-width: 900px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr 1fr; }
  .form-row .name, .form-row .actions { grid-column: 1 / -1; }
  .hh-top, .cats, .profile-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: auto; flex-direction: row; align-items: center; padding: 10px 16px; gap: 4px;
    border-right: none; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; overflow-x: auto;
  }
  .brand { padding: 0 8px 0 0; }
  .nav-section, .sidebar .spacer { display: none; }
  .sidebar .logout { margin-left: auto; }
  .main { padding: 20px 16px 40px; }
  .card { padding: 16px; }
  .tile .value { font-size: 1.15rem; }
  .form-grid { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .tiles-3 { grid-template-columns: 1fr 1fr; }
  .tiles-3 .tile:last-child { grid-column: 1 / -1; }
  .hero-value { font-size: 2.1rem; }
  .donut-wrap { grid-template-columns: 1fr; gap: 12px; }
  .donut svg { max-width: 200px; }
  .row-actions .btn { opacity: 1; }
  .cat table.items td.amt { width: auto; }
}
