/* Kontor – ruhige Oberfläche, Zahlen im Mittelpunkt. */
:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --ink: #18222d;
  --muted: #5d6b79;
  --line: #d6dde4;
  --accent: #1e5a8c;
  --accent-ink: #ffffff;
  --accent-soft: #e2ebf4;
  --pos: #2b6e45;
  --pos-soft: #e3f1e8;
  --neg: #a8372e;
  --neg-soft: #f8e5e3;
  --warn: #835600;
  --warn-soft: #fbf0d9;
  --side: #18222d;
  --side-ink: #c9d3dc;
  --side-active: #ffffff;
  --focus: #2f7dc4;
  --figure: "Charter", "Bitstream Charter", "Iowan Old Style", "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f151b;
    --surface: #172029;
    --surface-2: #1c2630;
    --ink: #e5eaef;
    --muted: #97a5b3;
    --line: #2b3844;
    --accent: #6ea7da;
    --accent-ink: #0c1620;
    --accent-soft: #1d3247;
    --pos: #74c493;
    --pos-soft: #183224;
    --neg: #ee8a80;
    --neg-soft: #3a1f1c;
    --warn: #e6b45a;
    --warn-soft: #3a2e14;
    --side: #0b1015;
    --side-ink: #9fb0bf;
    --focus: #8cc0f0;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--text); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--figure); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; max-width: 72ch; }
small, .muted { color: var(--muted); }
.num, td.num, th.num { font-variant-numeric: tabular-nums lining-nums; }
td.num, th.num { text-align: right; white-space: nowrap; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

/* Layout */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 1.25rem 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: block; padding: 0 1.25rem 1.25rem; color: var(--side-active); text-decoration: none; font-family: var(--figure); font-size: 1.35rem; }
.brand small { display: block; font-family: var(--text); font-size: .75rem; color: var(--side-ink); margin-top: .15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-group { margin: 0 0 1rem; }
.nav-group > span { display: block; padding: .25rem 1.25rem; font-size: .78rem; color: var(--side-ink); opacity: .7; }
.side a.nav { display: block; padding: .4rem 1.25rem; color: var(--side-ink); text-decoration: none; border-left: 3px solid transparent; }
.side a.nav:hover { color: var(--side-active); background: rgba(255,255,255,.04); }
.side a.nav.active { color: var(--side-active); border-left-color: var(--accent); background: rgba(255,255,255,.06); }
.side form { padding: .4rem 1.25rem; margin: 0; }
.side .link-button { color: var(--side-ink); }
main { padding: 1.75rem 2rem 4rem; max-width: 1240px; width: 100%; }
.mobile-bar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .shell > .side { display: none; }
  .mobile-bar { display: block; background: var(--side); color: var(--side-ink); }
  .mobile-bar summary { list-style: none; padding: .8rem 1rem; cursor: pointer; color: var(--side-active); font-family: var(--figure); font-size: 1.15rem; }
  .mobile-bar summary::-webkit-details-marker { display: none; }
  .mobile-bar .side { position: static; height: auto; padding-top: 0; }
  main { padding: 1.25rem 1rem 3rem; }
}

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin: .25rem 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.actions form { margin: 0; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush > h2 { padding: 1rem 1.25rem 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; }
.cols-2-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 1000px) { .cols-2-1 { grid-template-columns: 1fr; } }

/* Kennzahlen: die großen Zahlen sind das Gesicht der Anwendung */
.ledger { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 1.5rem; overflow: hidden; }
.ledger > div { padding: 1.1rem 1.25rem 1.2rem; border-right: 1px solid var(--line); }
.ledger > div:last-child { border-right: 0; }
.ledger .value { display: block; font-family: var(--figure); font-size: 2rem; font-variant-numeric: tabular-nums lining-nums; letter-spacing: -.01em; line-height: 1.15; }
.ledger .label { color: var(--muted); font-size: .9rem; }
.ledger a { color: inherit; text-decoration: none; }
.ledger a:hover .label { text-decoration: underline; }
@media (max-width: 700px) { .ledger > div { border-right: 0; border-bottom: 1px solid var(--line); } }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; font-size: .85rem; color: var(--muted); background: var(--surface-2); }
tbody tr:hover { background: var(--surface-2); }
tr.is-muted td { color: var(--muted); }
tfoot td { font-weight: 600; border-bottom: 0; }
td a.row-link { color: var(--ink); text-decoration: none; font-weight: 600; }
td a.row-link:hover { text-decoration: underline; }
.empty { padding: 2rem 1.25rem; text-align: center; color: var(--muted); }
.empty p { margin: 0 auto .75rem; }

.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill.paid, .pill.matched, .pill.accepted { background: var(--pos-soft); color: var(--pos); border-color: transparent; }
.pill.overdue, .pill.declined, .pill.cancelled { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.pill.open, .pill.sent, .pill.partial { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.btn, button { display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-weight: 600; padding: .5rem .95rem; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; line-height: 1.3; }
.btn:hover, button:hover { border-color: var(--muted); }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover, button.primary:hover { filter: brightness(1.08); }
.btn.danger, button.danger { color: var(--neg); }
.btn.small, button.small { padding: .25rem .6rem; font-size: .85rem; }
button.link-button { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 400; text-decoration: underline; cursor: pointer; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem 1.1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.field .req { color: var(--neg); }
.field .help { display: block; margin-top: .25rem; font-size: .82rem; }
.field .error { display: block; margin-top: .25rem; color: var(--neg); font-size: .85rem; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--neg); }
.field-check { display: flex; gap: .5rem; align-items: flex-start; flex-wrap: wrap; }
.field-check label { font-weight: 400; margin: 0; }
.field-check .help, .field-check .error { flex-basis: 100%; margin: 0 0 0 1.6rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=url], input:not([type]), select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: .45rem .6rem;
}
input[type=number] { font-variant-numeric: tabular-nums; }
textarea { resize: vertical; min-height: 2.4rem; }
input[type=checkbox] { width: 1.05rem; height: 1.05rem; margin-top: .2rem; accent-color: var(--accent); }
input[type=file] { font: inherit; max-width: 100%; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin: 0 0 1.25rem; }
legend { font-weight: 600; padding: 0 .4rem; }
details.more > summary { cursor: pointer; color: var(--accent); margin: .5rem 0; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filters input, .filters select { width: auto; min-width: 10rem; }
.form-errors { background: var(--neg-soft); color: var(--neg); padding: .75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.25rem; }

.items td { padding: .4rem .35rem; }
.items th { padding: .45rem .35rem; }
.items .c-desc { min-width: 240px; width: 46%; }
.items .c-qty { width: 6.5rem; }
.items .c-unit { width: 7rem; }
.items .c-price { width: 8rem; }
.items .c-rate { width: 6rem; }
.items .c-total { width: 8rem; text-align: right; padding-top: .9rem; }
.items .c-del { width: 2.5rem; text-align: center; }
.items tr.is-deleted { opacity: .4; }
.items input[type=checkbox][name$="-DELETE"] { display: none; }
.items .error { color: var(--neg); font-size: .82rem; display: block; }
.totals { margin-left: auto; max-width: 360px; }
.totals td { border: 0; padding: .25rem .75rem; }
.totals tr.grand td { font-family: var(--figure); font-size: 1.3rem; border-top: 2px solid var(--ink); padding-top: .5rem; }

.messages { list-style: none; margin: 0 0 1.25rem; padding: 0; }
.messages li { padding: .7rem 1rem; border-radius: 6px; margin-bottom: .5rem; background: var(--accent-soft); color: var(--ink); border-left: 4px solid var(--accent); }
.messages li.success { background: var(--pos-soft); border-color: var(--pos); }
.messages li.error { background: var(--neg-soft); border-color: var(--neg); }
.messages li.warning { background: var(--warn-soft); border-color: var(--warn); }
.notice { padding: .8rem 1rem; border-radius: 6px; background: var(--warn-soft); border-left: 4px solid var(--warn); margin-bottom: 1.25rem; }
.notice ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.notice p:last-child { margin-bottom: 0; }
.notice.info { background: var(--accent-soft); border-color: var(--accent); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.25rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth .panel { width: 100%; max-width: 420px; padding: 2rem; }
.auth .brand-big { font-family: var(--figure); font-size: 2rem; margin: 0 0 1.5rem; }
.qr { background: #fff; padding: .75rem; border-radius: 6px; width: 220px; height: 220px; display: block; margin: 1rem 0; }
code.secret { font-size: 1rem; letter-spacing: .05em; word-break: break-all; }

.pagination { display: flex; gap: .75rem; align-items: center; padding: 1rem 1.25rem; }
.mapping-preview td, .mapping-preview th { font-size: .85rem; white-space: nowrap; max-width: 18rem; overflow: hidden; text-overflow: ellipsis; }
.hash { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; word-break: break-all; color: var(--muted); }
.inline-form { display: inline; margin: 0; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
@media print { .side, .mobile-bar, .actions, .filters { display: none !important; } .shell { display: block; } main { padding: 0; } }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.timer-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1rem; margin: 0 0 1.25rem; border-radius: 6px; background: var(--accent-soft); border-left: 4px solid var(--accent); }
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li { display: flex; gap: .75rem; align-items: flex-start; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.task-list li:last-child { border-bottom: 0; }
.task-list .task-main { flex: 1; min-width: 0; }
.task-list .done .task-title { text-decoration: line-through; color: var(--muted); }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: .35rem; }
.meter > span { display: block; height: 100%; background: var(--accent); }
.meter.over > span { background: var(--neg); }
.day-head td { background: var(--surface-2); font-weight: 600; }
progress.meter { display: block; width: 100%; height: 6px; margin-top: .4rem; border: 0; border-radius: 3px; background: var(--surface-2); accent-color: var(--accent); }
progress.meter::-webkit-progress-bar { background: var(--surface-2); border-radius: 3px; }
progress.meter::-webkit-progress-value { background: var(--accent); border-radius: 3px; }
progress.meter::-moz-progress-bar { background: var(--accent); }
progress.meter.over::-webkit-progress-value { background: var(--neg); }
progress.meter.over::-moz-progress-bar { background: var(--neg); }
