:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --line: #e2e5ea;
  --line-strong: #cdd2da;
  --text: #1c2430;
  --muted: #667085;
  --accent: #27548a;
  --accent-soft: #e8eff7;
  --ms: #f2c8c3;
  --ms-text: #8a3a33;
  --ms-soft: #fae8e5;
  --basis: #bfd6ef;
  --basis-text: #24507f;
  --plus-a: #dfeaf6;
  --plus-b: #c9dcf0;
  --bonus-a: #dcefeb;
  --bonus-b: #c3e3dd;
  --bonus-text: #1f5f59;
  --ez: #e6e3f1;
  --ez-text: #4f4a6e;
  --edge: #d98f87;
  --good: #1f8a4c;
  --mid: #c47a12;
  --bad: #c8342b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 45, .05), 0 1px 6px rgba(20, 30, 45, .04);
  --label-w: 172px;
  --cell-w: 62px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
h2 { font-size: 15px; margin: 0; font-weight: 650; letter-spacing: -.005em; }
h3 { font-size: 12px; margin: 18px 0 8px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
button, input, select { font: inherit; color: inherit; }

/* Menü */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 20px;
  padding: 9px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 680; font-size: 15px; white-space: nowrap; }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, var(--basis-text) 50%, var(--edge) 50%); }
.menu { display: flex; align-items: center; gap: 2px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.menu button { border: 0; background: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; color: #3a4557; }
.menu button:hover { background: var(--accent-soft); color: var(--accent); }
.menu button:disabled { opacity: .4; cursor: default; background: none; color: inherit; }
.menu .sep { width: 1px; height: 18px; background: var(--line); margin: 0 6px; }

.page { padding: 16px 20px 32px; max-width: 1760px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }

/* Zusammenfassung */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow); }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.stat .s { color: var(--muted); font-size: 12px; }
.stat .v.warn { color: var(--bad); }

/* Zeitleiste */
.timeline-head { display: flex; align-items: center; gap: 18px; padding: 12px 16px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 12px; border-radius: 3px; display: inline-block; }
.horizon { margin-left: auto; color: var(--muted); font-size: 12px; display: flex; gap: 6px; align-items: center; }
.horizon select { padding: 3px 6px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); }
.timeline-scroll { overflow-x: auto; }
.tl { display: grid; width: 100%; }
.tl .c {
  min-width: 0; min-height: 30px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 12px; padding: 0 2px; position: relative;
  background: var(--surface);
}
.tl .lab {
  position: sticky; left: 0; z-index: 4; justify-content: flex-start; padding: 0 10px 0 12px; color: var(--muted);
  border-right: 1px solid var(--line-strong); background: var(--surface); white-space: nowrap; gap: 6px;
}
.tl .lab b { color: var(--text); font-weight: 600; }
.tl .lab .rest { margin-left: auto; font-size: 11px; color: var(--muted); }
.tl .head { background: var(--surface-2); flex-direction: column; line-height: 1.2; min-height: 40px; }
.tl .head b { font-size: 12px; }
.tl .head small { color: var(--muted); font-size: 10px; }
.tl .head.pre b { color: var(--muted); font-weight: 500; }
.tl .c.birth-edge { border-right: 2px solid var(--edge); }
.tl .person {
  position: sticky; left: 0; z-index: 4; grid-column: 1 / -1; background: var(--surface-2); min-height: 30px;
  justify-content: flex-start; padding: 0; border-top: 1px solid var(--line-strong);
}
.person-btn {
  position: sticky; left: 0; display: inline-flex; gap: 10px; align-items: center; border: 0; background: none; cursor: pointer;
  padding: 6px 12px; font-weight: 650; color: var(--text);
}
.person-btn small { font-weight: 400; color: var(--muted); }
.person-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.person.sel-person { background: var(--accent-soft); }
.person.sel-person .dot { background: var(--accent); }
.tl button.cell {
  width: 100%; height: 100%; min-height: 30px; border: 0; background: none; cursor: pointer; font-size: 11px; padding: 0;
  display: flex; align-items: center; justify-content: center; color: inherit; touch-action: none; user-select: none;
}
.tl button.cell:hover, .tl .val:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.tl button.cell:focus-visible, .tl .val:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tl button.cell.locked { cursor: not-allowed; }
.tl button.cell.locked:hover { box-shadow: none; }
.tl .sel { box-shadow: inset 0 0 0 2px var(--accent); }
.tl .c:has(> .sel)::after { content: ''; position: absolute; inset: 0; background: rgba(39, 84, 138, .13); pointer-events: none; }

.tl button.cell.p-ez, .legend .p-ez { background: var(--ez); color: var(--ez-text); font-weight: 600; }
.tl button.cell.p-ms, .legend .p-ms { background: var(--ms); color: var(--ms-text); font-weight: 600; }
.tl button.cell.p-msz { background: var(--ms-soft); color: var(--ms-text); font-weight: 600; }
.tl button.cell.p-basis, .legend .p-basis { background: var(--basis); color: var(--basis-text); font-weight: 600; }
.tl button.cell.p-plus, .legend .p-plus {
  color: var(--basis-text); font-weight: 600;
  background: repeating-linear-gradient(135deg, var(--plus-a) 0 6px, var(--plus-b) 6px 12px);
}
.tl button.cell.p-bonus, .legend .p-bonus {
  color: var(--bonus-text); font-weight: 600;
  background: repeating-linear-gradient(135deg, var(--bonus-a) 0 6px, var(--bonus-b) 6px 12px);
}

.val { width: 100%; height: 100%; min-height: 30px; display: flex; align-items: center; justify-content: center; cursor: text; border: 0; background: none; gap: 2px; font-size: 11.5px; padding: 0; }
.val.auto { color: var(--muted); }
.val.manual { font-weight: 600; }
.work-input { position: absolute; inset: 0; z-index: 3; width: 100%; min-width: 0; height: 100%; padding: 0; border: 0; text-align: center; font-size: 11.5px; background: #fff; outline: 2px solid var(--accent); outline-offset: -2px; }
.warnsym { color: var(--mid); font-weight: 800; font-size: 12px; }
.warnsym.err { color: var(--bad); }
.net { color: #3f4c60; font-size: 11.5px; }
.eg { font-weight: 650; font-size: 11.5px; }
.eg.max { color: var(--good); }
.eg.mid { color: var(--mid); }
.eg.min { color: var(--bad); }
.eg.ms { color: var(--muted); }
.eg.none { color: var(--bad); }
.sum { font-weight: 650; font-size: 11.5px; background: var(--surface-2) !important; }

.c.problem { box-shadow: inset 0 0 0 2px var(--bad); z-index: 2; }
.c.hinweis { box-shadow: inset 0 0 0 2px var(--mid); z-index: 2; }

/* Tooltip */
.tooltip {
  position: fixed; z-index: 50; max-width: 300px; padding: 9px 11px; background: #1f2835; color: #fff; border-radius: 8px;
  font-size: 12px; line-height: 1.4; pointer-events: none; box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
}
.tooltip strong { display: block; margin-bottom: 2px; }
.tooltip .e { color: #ffb4ae; margin-top: 5px; }
.tooltip .w { color: #ffd591; margin-top: 5px; }
.tooltip .d { color: #c4cbd6; }
.tooltip .h { margin-top: 6px; font-weight: 600; }
[data-hint] { cursor: help; }
[data-hint] input { cursor: text; }

/* Panels */
.panels { display: grid; grid-template-columns: minmax(250px, 300px) minmax(380px, 1fr) minmax(280px, 360px); gap: 14px; align-items: start; }
.panel { padding: 14px 16px 16px; }
.panel-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.field { display: grid; gap: 3px; margin-bottom: 10px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.field.inline { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13.5px; }
.field input[type=text], .field input[type=number], .field input[type=date], .field select {
  width: 100%; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 13.5px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field small { color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
.row-income { display: grid; grid-template-columns: 1fr 120px 30px; gap: 8px; align-items: end; margin-bottom: 8px; }
.row-income .field { margin: 0; }
.income-head { margin-bottom: 3px; font-size: 12.5px; color: var(--muted); }
.row-income select option:disabled { color: #a3aab5; }
.row-sib { display: grid; grid-template-columns: 1fr auto 30px; gap: 8px; align-items: center; margin-bottom: 8px; }
.icon-btn { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 6px; height: 32px; cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--bad); border-color: var(--bad); }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 2px 0; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }
.net-box {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; cursor: pointer;
  padding: 10px 14px; margin: 8px 0 4px; background: var(--accent-soft); border: 1px solid #cbdbec; border-radius: 8px;
}
.net-box:hover { border-color: var(--accent); }
.net-box .big { font-size: 20px; font-weight: 680; color: var(--accent); white-space: nowrap; }
.net-box small { display: block; color: var(--muted); }

.hint { padding: 9px 11px; border-radius: 8px; margin-bottom: 8px; font-size: 13px; border-left: 3px solid var(--line-strong); background: var(--surface-2); cursor: default; }
.hint strong { display: block; font-weight: 620; }
.bemess { margin: 8px 0 2px; }
.hint.error { border-left-color: var(--bad); background: #fbeeed; }
.hint.warn { border-left-color: var(--mid); background: #fbf4e7; }
.hint.tip { border-left-color: var(--good); background: #ebf6ef; }
.hint.info { border-left-color: var(--accent); background: var(--accent-soft); }
.hints-empty { color: var(--muted); }
.badge { font-size: 11px; color: var(--muted); }

/* Dialog */
.dialog { border: 0; border-radius: 12px; padding: 0; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 16px 48px rgba(20, 30, 45, .28); color: var(--text); }
.dialog::backdrop { background: rgba(20, 28, 40, .42); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dlg-head h2 { font-size: 16px; }
.dlg-body { padding: 14px 18px 20px; }
.dlg-close { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; padding: 2px 6px; }
table.calc { width: 100%; border-collapse: collapse; font-size: 13px; }
table.calc td, table.calc th { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.calc td.n, table.calc th.n { text-align: right; white-space: nowrap; }
table.calc tr.t td { font-weight: 650; border-top: 1.5px solid var(--text); border-bottom: 0; }
table.calc small { color: var(--muted); }
table.calc tr.best td { background: #ebf6ef; }
.dlg-note { color: var(--muted); font-size: 12.5px; }
.btn { border: 1px solid var(--line-strong); background: var(--surface); padding: 5px 10px; border-radius: 6px; cursor: pointer; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

.selbar {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 6px 20px rgba(20, 30, 45, .16); font-size: 13px; white-space: nowrap;
}
.selbar[hidden] { display: none; }
.selbar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
.selbar small { color: var(--muted); }
.kind-head { display: flex; justify-content: space-between; align-items: center; }
.kind-head h3 { margin-bottom: 6px; }
.slot-row { display: flex; gap: 8px; margin-bottom: 12px; }
.slot-row input { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 6px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1f2835; color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 60; font-size: 13px; }
.report { display: none; }

@media (max-width: 1180px) {
  .panels { grid-template-columns: 1fr 1fr; }
  #hints { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  :root { --label-w: 110px; --cell-w: 56px; }
  .topbar { flex-direction: column; align-items: stretch; gap: 6px; padding: 8px 16px; position: static; }
  .menu { justify-content: flex-start; }
  .page { padding: 12px 16px 24px; }
  .panels { grid-template-columns: minmax(0, 1fr); }
  .tl .lab .rest { display: none; }
}

@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff; font-size: 11px; }
  .topbar, .page, .tooltip, .toast, .selbar, dialog { display: none !important; }
  .report { display: block; }
  .report h1 { font-size: 18px; margin: 0 0 2px; }
  .report h2 { font-size: 13px; margin: 14px 0 5px; }
  .report table { width: 100%; border-collapse: collapse; font-size: 10px; }
  .report td, .report th { border: 1px solid #bbb; padding: 2px 3px; text-align: right; }
  .report td:first-child, .report th:first-child { text-align: left; }
  .report tr { break-inside: avoid; }
  .report .note { color: #555; font-size: 10px; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
