/* iCarsBook Web-App. Farben als Tokens; Dunkelmodus folgt dem System oder dem Umschalter. */
:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --border: #e1e6ee;
  --text: #191c22;
  --text-2: #5d6675;
  --text-3: #8a93a3;
  --primary: #2370cd;
  --primary-hover: #1b64be;
  --primary-soft: #e3effd;
  --on-primary: #ffffff;
  --accent: #f47230;
  --series-1: #257de0;
  --series-2: #f47230;
  --grid: #e8ecf2;
  --good: #0a8a3a;
  --good-soft: #e3f6ea;
  --warn: #a86400;
  --warn-soft: #fff2d9;
  --bad: #c62d2e;
  --bad-soft: #fde7e7;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 14px;
  --radius-sm: 9px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1218;
    --surface: #171b23;
    --surface-2: #1e2430;
    --border: #2a3140;
    --text: #edf0f5;
    --text-2: #a3acbb;
    --text-3: #758095;
    --primary: #4a9bf0;
    --primary-hover: #66abf3;
    --primary-soft: #1a2c45;
    --on-primary: #0b1220;
    --accent: #e76624;
    --series-1: #338ced;
    --series-2: #e76624;
    --grid: #262d3a;
    --good: #3ccf73;
    --good-soft: #132c1e;
    --warn: #f0b44c;
    --warn-soft: #33270f;
    --bad: #f26b6c;
    --bad-soft: #3a1a1b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1218;
  --surface: #171b23;
  --surface-2: #1e2430;
  --border: #2a3140;
  --text: #edf0f5;
  --text-2: #a3acbb;
  --text-3: #758095;
  --primary: #4a9bf0;
  --primary-hover: #66abf3;
  --primary-soft: #1a2c45;
  --on-primary: #0b1220;
  --accent: #e76624;
  --series-1: #338ced;
  --series-2: #e76624;
  --grid: #262d3a;
  --good: #3ccf73;
  --good-soft: #132c1e;
  --warn: #f0b44c;
  --warn-soft: #33270f;
  --bad: #f26b6c;
  --bad-soft: #3a1a1b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -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; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
h1:focus { outline: none; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

/* ---------- Start (vor Blazor) ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 18px; }
.boot-bar { width: 140px; height: 4px; border-radius: 4px; background: var(--border); overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: var(--blazor-load-percentage, 10%); background: var(--primary); transition: width .2s; }

#blazor-error-ui {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  padding: 12px 16px; background: var(--bad-soft); color: var(--bad); border-top: 1px solid var(--bad);
  gap: 12px; align-items: center;
}
#blazor-error-ui [data-lang] { display: none; }
html[lang="de"] #blazor-error-ui [data-lang="de"],
html[lang="en"] #blazor-error-ui [data-lang="en"],
html[lang="es"] #blazor-error-ui [data-lang="es"],
html[lang="it"] #blazor-error-ui [data-lang="it"] { display: inline; }
#blazor-error-ui .reload { font-weight: 700; }
#blazor-error-ui .dismiss { margin-left: auto; background: none; border: 0; color: inherit; font-size: 1.1rem; cursor: pointer; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: var(--text); font-weight: 750; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 550;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.nav-link svg { width: 20px; height: 20px; flex: none; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 10px; padding: 12px 6px 0; border-top: 1px solid var(--border); }
.user-chip { font-size: .85rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 6px; }

.main { min-width: 0; padding: 28px 32px 64px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; margin-bottom: 22px; }
.page-head .sub { color: var(--text-2); margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.topbar { display: none; }
.bottom-nav { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar {
    display: flex; position: sticky; top: 0; z-index: 20; align-items: center; justify-content: space-between;
    padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .topbar .brand { padding: 0; }
  .main { padding: 18px 16px 96px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav .nav-link { flex-direction: column; gap: 2px; padding: 6px 2px; font-size: .7rem; text-align: center; justify-content: center; }
  h1 { font-size: 1.35rem; }
}

/* ---------- Bausteine ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head .hint { color: var(--text-2); font-size: .85rem; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.stack { display: grid; gap: 16px; }

.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { color: var(--text-2); font-size: .82rem; font-weight: 550; }
.kpi .value { font-size: 1.45rem; font-weight: 720; letter-spacing: -.01em; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .value small { font-size: .8rem; font-weight: 600; color: var(--text-2); margin-left: 4px; }
.kpi .foot { color: var(--text-3); font-size: .78rem; margin-top: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: .85rem; }
.btn-icon { width: 36px; min-height: 36px; padding: 0; }
.btn-block { width: 100%; }

.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--text-2); }
.field .help { font-size: .8rem; color: var(--text-3); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; min-height: 42px; width: 100%; min-width: 0;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .nav-link:focus-visible, .seg button:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}
input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; accent-color: var(--primary); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 550; cursor: pointer; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.validation-message, .form-error { color: var(--bad); font-size: .85rem; }
.form-error { background: var(--bad-soft); border-radius: var(--radius-sm); padding: 10px 12px; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--text-2); font: inherit; font-weight: 600; font-size: .85rem; padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; background: none; font: inherit; font-weight: 600; color: var(--text-2); padding: 10px 14px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 650; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.blue { background: var(--primary-soft); color: var(--primary); }

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data th.right, table.data td.right { text-align: right; }
table.data th button { all: unset; cursor: pointer; }

.empty { text-align: center; padding: 36px 16px; color: var(--text-2); }
.empty svg { width: 44px; height: 44px; color: var(--text-3); margin-bottom: 8px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }

.vehicle-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.vehicle-card { display: grid; gap: 12px; color: var(--text); }
.vehicle-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.vehicle-card .top { display: flex; gap: 12px; align-items: center; }
.vehicle-card .avatar { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.vehicle-card .avatar svg { width: 24px; height: 24px; }
.vehicle-card .name { font-weight: 700; font-size: 1.05rem; }
.vehicle-card .meta { display: flex; flex-wrap: wrap; gap: 6px; }
.vehicle-card .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.vehicle-card .stats div { min-width: 0; }
.vehicle-card .stats b { display: block; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vehicle-card .stats span { font-size: .75rem; color: var(--text-2); }

.due-list { display: grid; gap: 8px; }
.due-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); }
.due-item:hover { text-decoration: none; }
.due-item .what { font-weight: 650; }
.due-item .when { margin-left: auto; text-align: right; font-size: .85rem; }

.list { display: grid; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.info-grid .k { font-size: .8rem; color: var(--text-2); }
.info-grid .v { font-weight: 650; }

.code-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.5rem; font-weight: 700; letter-spacing: .12em; background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 12px 16px; text-align: center; }

.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
.loading { display: grid; place-items: center; padding: 48px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Dialog ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(10, 14, 22, .5); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { width: min(640px, 100%); background: var(--surface); border-radius: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); border: 1px solid var(--border); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal.sm { width: min(440px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }

/* ---------- Meldungen ---------- */
.toasts { position: fixed; z-index: 200; right: 16px; bottom: 16px; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
@media (max-width: 900px) { .toasts { bottom: 84px; } }
.toast { background: var(--text); color: var(--bg); padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: flex-start; font-weight: 550; }
.toast.error { background: var(--bad); color: #fff; }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; font-size: 1rem; }

/* ---------- Anmeldung ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--primary-soft), transparent), var(--bg); }
.auth-card { width: min(420px, 100%); display: grid; gap: 18px; padding: 28px; }
.auth-card .brand { justify-content: center; padding: 0; font-size: 1.3rem; }
.auth-card .brand img { width: 44px; height: 44px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: .8rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn-apple { background: #000; color: #fff; border-color: #000; }
.btn-apple:hover { background: #222; }
:root[data-theme="dark"] .btn-apple { background: #fff; color: #000; border-color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-apple { background: #fff; color: #000; border-color: #fff; } }
.google-slot { display: flex; justify-content: center; min-height: 44px; }
.auth-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .85rem; }

/* ---------- Diagramme ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart .axis-label { fill: var(--text-3); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .base-line { stroke: var(--border); stroke-width: 1; }
.chart .crosshair { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .tip {
  position: absolute; pointer-events: none; z-index: 5; transform: translate(-50%, calc(-100% - 10px));
  background: var(--text); color: var(--bg); border-radius: 8px; padding: 6px 10px; font-size: .8rem; white-space: nowrap; box-shadow: var(--shadow);
}
.chart .tip b { display: block; font-variant-numeric: tabular-nums; }
.chart-empty { display: grid; place-items: center; color: var(--text-3); font-size: .9rem; border: 1px dashed var(--border); border-radius: var(--radius-sm); }

.receipt-img { max-width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; margin: 0 auto; }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 16px; display: flex; gap: 12px; align-items: center; background: var(--surface-2); }
.dropzone input[type=file] { border: 0; background: none; padding: 0; min-height: 0; }

.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 32%) 1fr auto; gap: 12px; align-items: center; }
.hbar-label { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 0 4px 4px 0; }
.hbar-value { font-size: .85rem; font-weight: 650; min-width: 72px; text-align: right; }

.prefs { display: flex; align-items: center; gap: 6px; }
.prefs-lang { display: flex; align-items: center; gap: 6px; color: var(--text-2); flex: 1; }
.prefs-lang svg { width: 18px; height: 18px; flex: none; }
.prefs-lang select { min-height: 34px; padding: 4px 8px; font-size: .85rem; }
.topbar .prefs-lang select { width: auto; }
.badge svg { width: 12px; height: 12px; }
svg.icon { vertical-align: -0.2em; flex: none; }
.chart .avg-label { fill: var(--text-2); font-weight: 650; stroke: var(--surface); stroke-width: 4px; paint-order: stroke; stroke-linejoin: round; }
