:root {
  --canvas: #f2f6fa;
  --card: #ffffff;
  --ink: #1b2b3a;
  --ink-2: #5c6f82;
  --rule: #e2e9f0;
  --brand: #0d7fd6;
  --brand-2: #0a6ab3;
  --brand-soft: #e6f2fc;
  --teal: #14b8a6;
  --red: #e0453b;
  --red-soft: #fdeceb;
  --amber: #f0a020;
  --amber-soft: #fef4e2;
  --green: #22a06b;
  --green-soft: #e6f7ef;
  --shadow: 0 1px 2px rgba(27, 43, 58, 0.04), 0 8px 24px rgba(27, 43, 58, 0.06);
  --radius: 16px;
}
* { box-sizing: border-box; }
html { font: 16px/1.55 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--canvas); }
body { margin: 0; min-height: 100vh; }
a { color: var(--brand); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }
:focus-visible { outline: 3px solid rgba(13, 127, 214, 0.35); outline-offset: 2px; border-radius: 6px; }

/* Navigation */
.side { position: fixed; inset: 0 auto 0 0; width: 240px; padding: 24px 16px; background: var(--card); border-right: 1px solid var(--rule); display: flex; flex-direction: column; gap: 2px; }
.side .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--ink); padding: 6px 10px; margin-bottom: 18px; letter-spacing: -0.01em; }
.side .brand .logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--teal)); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1rem; }
.side a:not(.brand) { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 500; }
.side a:not(.brand):hover { background: var(--canvas); color: var(--ink); text-decoration: none; }
.side a.on { background: var(--brand-soft); color: var(--brand-2); font-weight: 600; }
.side a svg { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side .who { margin-top: auto; padding: 14px 12px 4px; border-top: 1px solid var(--rule); font-size: 0.9rem; display: flex; flex-direction: column; gap: 2px; }
.side .who span { font-weight: 600; }
.side .who small { color: var(--ink-2); }
.side .who .version { font-size: 0.75rem; margin-top: 6px; }
main.with-nav { margin-left: 240px; padding: 36px 44px 80px; max-width: 1180px; }
main.solo { padding: 60px 24px; display: flex; justify-content: center; }

/* Typography */
h1 { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 6px; }
h2 { font-size: 1.1rem; font-weight: 700; margin: 0 0 14px; }
h3 { font-size: 0.95rem; font-weight: 700; margin: 20px 0 8px; }
p { margin: 0 0 12px; max-width: 72ch; }
.muted { color: var(--ink-2); }
.hint { margin-top: 12px; font-size: 0.9rem; }
.pre { white-space: pre-wrap; }
header.page { margin-bottom: 28px; }
section { margin-bottom: 28px; }
.error { color: var(--red); font-weight: 600; }
.notice { padding: 12px 16px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-2); font-weight: 500; }

/* Übersicht: Begrüßung, Kacheln, Fortschritt */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; margin-bottom: 24px; }
.hero h1 { margin-bottom: 2px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 28px; }
.tile { background: var(--card); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; color: var(--ink); }
.tile:hover { text-decoration: none; transform: translateY(-1px); }
.tile .n { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.tile .l { color: var(--ink-2); font-size: 0.9rem; }
.tile.red .n { color: var(--red); }
.tile.amber .n { color: var(--amber); }
.tile.green .n { color: var(--green); }
.tile.brand .n { color: var(--brand); }
.progress { background: var(--card); border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow); margin-bottom: 28px; }
.progress .bar { height: 10px; border-radius: 999px; background: var(--canvas); overflow: hidden; margin: 10px 0 12px; }
.progress .bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--teal)); }
.progress ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 6px 20px; font-size: 0.92rem; }
.progress li { display: flex; gap: 8px; align-items: center; color: var(--ink-2); }
.progress li.ok { color: var(--ink); }
.progress li .tick { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--rule); flex: none; display: grid; place-items: center; font-size: 0.7rem; }
.progress li.ok .tick { background: var(--green); border-color: var(--green); color: #fff; }

/* Fristenliste: die Ampel ist der einzige starke Akzent */
h2.overdue { color: var(--red); }
h2.soon { color: var(--amber); }
h2.upcoming { color: var(--green); }
h2.later { color: var(--ink-2); }
.items { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item { display: grid; grid-template-columns: 6px 100px 1fr auto auto; gap: 0 18px; align-items: start; padding: 14px 20px 14px 0; border-bottom: 1px solid var(--rule); }
.item:last-child { border-bottom: 0; }
.item .dot { width: 6px; height: 100%; min-height: 24px; border-radius: 0 4px 4px 0; background: var(--rule); }
.item.overdue .dot { background: var(--red); }
.item.soon .dot { background: var(--amber); }
.item.upcoming .dot { background: var(--green); }
.item .date { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.item .body { display: flex; flex-direction: column; }
.item .body small { color: var(--ink-2); max-width: 70ch; }
.item .body small.law { font-size: 0.8rem; }
.item .left { white-space: nowrap; font-size: 0.85rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--canvas); color: var(--ink-2); }
.item.overdue .left { background: var(--red-soft); color: var(--red); }
.item.soon .left { background: var(--amber-soft); color: #9a6200; }
.item.upcoming .left { background: var(--green-soft); color: var(--green); }
.item .actions { display: flex; gap: 12px; }
.items.dim { opacity: 0.65; }

/* Cards, tables, forms */
.card { background: var(--card); border-radius: var(--radius); padding: 24px 26px; box-shadow: var(--shadow); }
.card.narrow { width: 100%; max-width: 440px; }
table { border-collapse: collapse; width: 100%; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--rule); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { font-size: 0.82rem; color: var(--ink-2); font-weight: 600; background: #f8fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

label { display: flex; flex-direction: column; gap: 5px; font-size: 0.88rem; font-weight: 500; color: var(--ink-2); }
input, select, textarea { font: inherit; color: var(--ink); padding: 10px 12px; border: 1.5px solid var(--rule); border-radius: 10px; background: var(--card); }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgba(13, 127, 214, 0.15); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.grid .wide { grid-column: 1 / -1; }
.grid > div { grid-column: 1 / -1; }
label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--ink); grid-column: 1 / -1; font-weight: 400; }
.row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.inline { display: inline; }
form.inline button { padding: 0; }
button, .button { font: inherit; font-weight: 600; cursor: pointer; padding: 10px 18px; border-radius: 999px; border: 1.5px solid var(--brand); background: var(--card); color: var(--brand); }
button:hover, .button:hover { background: var(--brand-soft); text-decoration: none; }
button.primary { background: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-2); }
button.link { border: 0; background: none; padding: 0; color: var(--brand); font-weight: 500; }
button.link:hover { background: none; text-decoration: underline; }
button.link.danger { color: var(--red); }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0; }
dl.facts dt { color: var(--ink-2); }
dl.facts dd { margin: 0; }
dl.facts dd.strong { font-weight: 700; color: var(--brand-2); }
code.url { display: block; padding: 12px 14px; background: var(--canvas); border-radius: 10px; word-break: break-all; font-size: 0.9rem; }
.badge { display: inline-block; font-size: 0.7rem; font-weight: 700; color: #fff; background: var(--amber); border-radius: 999px; padding: 2px 8px; margin-left: auto; }

details.auth { margin-bottom: 12px; padding: 0; }
details.auth summary { cursor: pointer; padding: 16px 24px; display: flex; gap: 20px; align-items: baseline; list-style: none; }
details.auth summary::-webkit-details-marker { display: none; }
details.auth summary .name { font-weight: 700; min-width: 280px; }
details.auth[open] summary { border-bottom: 1px solid var(--rule); }
details.auth form, details.auth dl { padding: 20px 24px; }

@media (max-width: 860px) {
  .side { position: static; width: auto; flex-direction: row; flex-wrap: wrap; padding: 10px 12px; gap: 4px; }
  .side .brand { margin: 0 8px 0 0; }
  .side a:not(.brand) span { display: none; }
  .side .who { margin: 0 0 0 auto; border: 0; padding: 0 8px; }
  .side .who .version { display: none; }
  main.with-nav { margin: 0; padding: 20px 14px 60px; }
  .item { grid-template-columns: 6px 1fr; padding-right: 14px; }
  .item .date, .item .body, .item .left, .item .actions { grid-column: 2; }
  .grid { grid-template-columns: 1fr; }
  details.auth summary { flex-direction: column; gap: 4px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; transform: none !important; } }

/* Belege */
.months { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.month { padding: 6px 14px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); color: var(--ink-2); font-weight: 600; font-size: 0.9rem; }
.month.on { background: var(--brand); color: #fff; }
.month.locked:not(.on) { color: var(--green); }
.month:hover { text-decoration: none; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--canvas); color: var(--ink-2); font-size: 0.82rem; font-weight: 600; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: var(--amber-soft); color: #9a6200; }
.pill.red { background: var(--red-soft); color: var(--red); }
.drop { border: 2px dashed var(--rule); box-shadow: none; }
.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.preview iframe, .preview img { width: 100%; height: 640px; border: 0; border-radius: 10px; background: var(--canvas); object-fit: contain; }
.preview img { height: auto; max-height: 640px; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } .preview iframe { height: 480px; } }
.wide-tile { display: flex; flex-direction: row; align-items: center; gap: 20px; margin-bottom: 14px; }
.wide-tile .l { font-size: 0.95rem; max-width: 80ch; }
.month.empty { opacity: 0.45; }
.month.inbox b { background: var(--amber); color: #fff; border-radius: 999px; padding: 0 7px; margin-left: 4px; }
.months.years { margin-bottom: 10px; }

/* Mandanten-Umschalter */
.switcher { display: flex; flex-direction: column; gap: 4px; margin: -8px 0 14px; padding-bottom: 12px; border-bottom: 1px solid var(--rule); }
.switcher form { display: contents; }
.mandant { display: grid; grid-template-columns: 10px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; text-align: left; width: 100%; padding: 8px 10px; border-radius: 10px; border: 1.5px solid transparent; background: none; color: var(--ink-2); font-weight: 500; }
.mandant i { grid-row: 1 / 3; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.mandant span { font-size: 0.92rem; color: var(--ink); font-weight: 600; }
.mandant small { font-size: 0.75rem; color: var(--ink-2); }
button.mandant { cursor: pointer; }
button.mandant:hover { background: var(--canvas); }
.mandant.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 8%, white); }

/* Bank */
table.bank td { vertical-align: top; }
tr.tx.offen td:first-child { box-shadow: inset 4px 0 0 var(--red); }
tr.tx.zugeordnet td:first-child { box-shadow: inset 4px 0 0 var(--green); }
tr.tx.kein_beleg td:first-child { box-shadow: inset 4px 0 0 var(--rule); }
td.pos { color: var(--green); font-weight: 600; }
td.neg { font-weight: 600; }
table.payroll td, table.payroll th { padding: 8px 6px; font-size: 0.9rem; }
tr.dim { opacity: 0.55; }
