/* Buchhaltung MeinArztbedarf – Design-Tokens, Layout, Komponenten */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --border: #e2e8ee;
  --border-strong: #cdd6df;
  --text: #17212b;
  --text-2: #4a5866;
  --text-3: #7a8794;
  --primary: #0f766e;
  --primary-2: #0d5f59;
  --primary-soft: #e6f4f2;
  --ok: #15803d;
  --ok-soft: #e8f6ed;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --info: #1d4ed8;
  --info-soft: #e9f0fe;
  --muted: #64748b;
  --muted-soft: #eef2f5;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --nav-w: 232px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418; --surface: #161d23; --surface-2: #1b232a; --border: #26313a; --border-strong: #34424e;
    --text: #e6edf3; --text-2: #b3c0cc; --text-3: #8696a4;
    --primary: #2bb3a6; --primary-2: #4cc9bc; --primary-soft: #0f2e2c;
    --ok: #4ade80; --ok-soft: #10261a; --warn: #fbbf24; --warn-soft: #2b2110; --danger: #f87171; --danger-soft: #2c1414;
    --info: #93b4ff; --info-soft: #141f36; --muted: #94a3b8; --muted-soft: #1f2933;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; }
h1 { font-size: 1.45rem; font-weight: 650; }
h2 { font-size: 1.12rem; font-weight: 650; }
h3 { font-size: .98rem; font-weight: 650; }
p { margin: .3rem 0 .8rem; }
small, .small { font-size: .84rem; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.mono { font-family: var(--mono); font-size: .92em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ---------- Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--nav-w); flex: 0 0 var(--nav-w); background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); display: grid; place-items: center; color: #fff; font-weight: 700; }
.brand-name { font-weight: 700; font-size: .95rem; line-height: 1.1; }
.brand-sub { font-size: .76rem; color: var(--text-3); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 520; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav svg { width: 18px; height: 18px; flex: 0 0 18px; }
.nav .count { margin-left: auto; font-size: .75rem; background: var(--warn-soft); color: var(--warn); border-radius: 99px; padding: 0 7px; font-weight: 650; }
.sidebar .bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 10px; font-size: .85rem; color: var(--text-3); }
.sidebar .bottom form { display: inline; }
.main { flex: 1; min-width: 0; padding: 22px 28px 60px; max-width: 1500px; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.topbar h1 { margin: 0; }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.mobile-nav { display: none; }

/* ---------- Karten, Grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid > .card { margin-bottom: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.topbar .actions select, .topbar .actions input[type=search] { width: auto; }
.split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.sticky { position: sticky; top: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); color: var(--text); display: block; }
a.stat:hover { text-decoration: none; border-color: var(--border-strong); }
.stat .label { font-size: .8rem; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 1.55rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .84rem; color: var(--text-2); }
.stat.warn .value { color: var(--warn); }
.stat.danger .value { color: var(--danger); }
.stat.ok .value { color: var(--ok); }
.stat.primary .value { color: var(--primary); }

/* ---------- Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .76rem; font-weight: 650; padding: 2px 8px; border-radius: 99px; white-space: nowrap; background: var(--muted-soft); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }

/* ---------- Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); padding: 7px 13px; border-radius: var(--radius-sm); font: inherit; font-weight: 560; cursor: pointer; line-height: 1.25; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.btn.danger.solid { background: var(--danger); color: #fff; }
.btn.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 9px; font-size: .85rem; }
.btn.lg { padding: 12px 18px; font-size: 1.02rem; }
.btn.block { width: 100%; }
.btn-group { display: inline-flex; gap: 0; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn.is-active.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.is-active.warn { background: var(--warn); color: #fff; border-color: var(--warn); }
.btn.is-active.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.inline { display: inline; }

/* ---------- Formulare */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-2); margin-bottom: 3px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email], input[type=search], input[type=time],
select, textarea { width: 100%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: var(--radius-sm);
  padding: 7px 10px; font: inherit; min-height: 36px; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }
input.mono { font-family: var(--mono); }
.field { margin-bottom: 11px; }
.field .hint { font-size: .78rem; color: var(--text-3); margin-top: 2px; }
.field.changed input, .field.changed select { border-color: var(--warn); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; }
.form-grid .full, .form-grid-3 .full { grid-column: 1 / -1; }
.check { display: flex; align-items: flex-start; gap: 8px; font-weight: 500; color: var(--text); font-size: .92rem; margin: 6px 0; cursor: pointer; }
.check input { margin-top: 3px; width: 17px; height: 17px; flex: 0 0 17px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px 4px; margin: 0 0 12px; }
legend { font-size: .8rem; font-weight: 700; color: var(--text-2); padding: 0 6px; text-transform: uppercase; letter-spacing: .03em; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row > * { flex: 1; }
.input-row > .btn { flex: 0 0 auto; }

/* ---------- Tabellen */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-3); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table td.amount, .table th.amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.table tr.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.table tr.row-danger td:first-child { box-shadow: inset 3px 0 0 var(--danger); }

/* ---------- Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 8px 12px; color: var(--text-2); border-bottom: 2px solid transparent; font-weight: 560; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .n { font-size: .75rem; background: var(--muted-soft); color: var(--muted); border-radius: 99px; padding: 0 6px; margin-left: 4px; }
.tabs a.active .n { background: var(--primary-soft); color: var(--primary); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { max-width: 280px; }
.filters select { width: auto; }

/* ---------- Meldungen / Checks */
.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 10px; border: 1px solid; white-space: pre-line; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.flash.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.flash.danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.flash.info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; gap: 9px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: .9rem; }
.checks li:last-child { border-bottom: 0; }
.checks .ico { flex: 0 0 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 800; color: #fff; margin-top: 1px; }
.checks .error .ico { background: var(--danger); }
.checks .warn .ico { background: var(--warn); }
.checks .info .ico { background: var(--info); }
.checks .ok .ico { background: var(--ok); }
.callout { border-radius: var(--radius-sm); padding: 10px 12px; margin: 8px 0; border: 1px solid var(--border); background: var(--surface-2); }
.callout.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.callout.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }

/* ---------- Belegansicht */
.viewer { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.viewer-bar { display: flex; gap: 6px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.viewer-pages { max-height: calc(100vh - 140px); overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.viewer-pages img { width: 100%; height: auto; border-radius: 4px; box-shadow: var(--shadow); background: #fff; cursor: zoom-in; }
.viewer-pages.zoom img { width: 180%; max-width: none; cursor: zoom-out; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: .92rem; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.step { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; background: var(--surface-2); font-size: .88rem; }
.step .name { font-weight: 650; margin-bottom: 2px; }
.confirm-box { border: 2px solid var(--primary); }
.pos-table input { min-height: 32px; padding: 4px 6px; }
.filename { font-family: var(--mono); font-size: .82rem; word-break: break-all; background: var(--surface-2); border: 1px solid var(--border); padding: 6px 8px; border-radius: 6px; }

/* ---------- Liquiditaet */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .bar-committed { fill: var(--primary); }
.chart .bar-open { fill: var(--warn); }
.chart .bar-paused { fill: var(--border-strong); }
.chart .line { stroke: var(--danger); stroke-width: 2; fill: none; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .84rem; color: var(--text-2); }
.legend .sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.sw.committed { background: var(--primary); } .sw.open { background: var(--warn); } .sw.paused { background: var(--border-strong); } .sw.line { background: var(--danger); }

/* ---------- Upload (mobil) */
.upload-wrap { max-width: 560px; margin: 0 auto; }
.company-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.company-pick button { border: 2px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 14px 10px; font: inherit; font-weight: 650; color: var(--text); cursor: pointer; text-align: left; display: flex; gap: 10px; align-items: center; min-height: 58px; }
.company-pick button.selected { border-color: var(--primary); background: var(--primary-soft); }
.company-pick svg { flex: 0 0 14px; }
.big-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.big-actions .btn { padding: 18px 10px; font-size: 1.02rem; flex-direction: column; gap: 4px; }
.big-actions svg { width: 28px; height: 28px; }
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 10px; }
.page-thumb { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); aspect-ratio: 3/4; display: grid; place-items: center; }
.page-thumb img { width: 100%; height: 100%; object-fit: contain; }
.page-thumb .nr { position: absolute; left: 4px; top: 4px; background: rgba(0,0,0,.65); color: #fff; font-size: .72rem; border-radius: 4px; padding: 0 5px; }
.page-thumb .rm { position: absolute; right: 4px; top: 4px; border: 0; background: rgba(185,28,28,.9); color: #fff; width: 24px; height: 24px; border-radius: 50%; cursor: pointer; font-weight: 700; }
.page-thumb .pdf { font-weight: 700; color: var(--text-2); padding: 8px; text-align: center; font-size: .8rem; word-break: break-all; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 99px; padding: 3px 10px; font-size: .84rem; cursor: pointer; color: var(--text-2); }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.progress { height: 8px; background: var(--muted-soft); border-radius: 99px; overflow: hidden; margin: 10px 0; }
.progress > div { height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.success-box { text-align: center; padding: 26px 16px; }
.success-box .big { font-size: 2.6rem; color: var(--ok); line-height: 1; }

/* ---------- Zuschnitt-Editor */
.cropper { position: fixed; inset: 0; background: #0b0f12; z-index: 100; display: flex; flex-direction: column; touch-action: none; user-select: none; -webkit-user-select: none; }
.cropper-stage { position: relative; flex: 1; overflow: hidden; }
.cropper-stage canvas { position: absolute; left: 0; top: 0; }
.cropper-bar { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #12181d; flex-wrap: wrap; justify-content: center; }
.cropper-bar .btn { background: #1f2a33; border-color: #2c3a45; color: #e6edf3; }
.cropper-bar .btn.primary { background: var(--primary); border-color: var(--primary); }
.cropper-hint { color: #b3c0cc; font-size: .82rem; text-align: center; padding: 6px 10px 0; background: #12181d; }
.cropper-busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.55); color: #fff; font-weight: 600; z-index: 5; }

/* ---------- Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; padding: 26px; }
.login .brand { justify-content: center; padding-bottom: 20px; }

/* ---------- Dialog */
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); padding: 18px 20px; max-width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 15, 20, .45); }
.folder-list { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; margin: 8px 0; }
.folder-list button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border); background: transparent; padding: 7px 10px; cursor: pointer; font: inherit; color: var(--text); }
.folder-list button:hover { background: var(--surface-2); }

/* ---------- Responsiv */
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .viewer-pages { max-height: 70vh; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .sidebar { display: none; }
  .main { padding: 14px 16px 92px; }
  .mobile-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .68rem; color: var(--text-3); padding: 2px 6px; min-width: 56px; }
  .mobile-nav a.active { color: var(--primary); }
  .mobile-nav a:hover { text-decoration: none; }
  .mobile-nav svg { width: 22px; height: 22px; }
  .mobile-nav .plus { background: var(--primary); color: #fff; border-radius: 50%; width: 46px; height: 46px; display: grid; place-items: center; margin-top: -16px; box-shadow: var(--shadow-lg); }
  .mobile-nav .plus svg { width: 26px; height: 26px; }
  .grid-2, .grid-3, .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 1.25rem; }
  .table.responsive thead { display: none; }
  .table.responsive tr { display: block; border-bottom: 1px solid var(--border); padding: 8px 0; }
  .table.responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 3px 4px; text-align: right; }
  .table.responsive td::before { content: attr(data-label); color: var(--text-3); font-size: .8rem; text-align: left; flex: 0 0 auto; }
  .table.responsive td.amount { text-align: right; }
  .topbar .actions { margin-left: 0; width: 100%; }
}
@media print {
  .sidebar, .mobile-nav, .topbar .actions, .btn { display: none !important; }
  .main { padding: 0; }
  .card { box-shadow: none; }
}
