/* Gemeinsames Design für Login und Dashboard – mobil zuerst, Desktop als Ergänzung. */
:root {
  /* Farben von aveora.ch */
  --bg: #FAFAF8; --surface: #FFFFFF; --surface2: #F3F1EA; --line: #E4E2DC;
  --text: #0B1220; --muted: #5F5F63; --accent: #0B1220; --accent-ink: #FFFFFF; --gold: #B8975A; --gold-soft: #D4B97E;
  --hero: #0E1421; --hero-ink: #F2F1EC;
  --ok: #3f7a52; --warn: #a8742a; --bad: #a8433a;
  --shadow: 0 1px 1px rgba(60,45,20,.04), 0 12px 32px rgba(60,45,20,.06);
  --r: 20px;
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif; --sans: "DM Sans", "Helvetica Neue", Arial, system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1421; --surface: #141B2A; --surface2: #1B2333; --line: #242B3A;
    --text: #F2F1EC; --muted: #A3A7B3; --accent: #D4B97E; --accent-ink: #0B1220; --gold: #D4B97E; --gold-soft: #D4B97E;
    --hero: #1B2333; --hero-ink: #F2F1EC;
    --ok: #7fb08c; --warn: #d6a35a; --bad: #d9877e;
    --shadow: 0 1px 1px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.28);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15.5px/1.55 var(--sans); -webkit-font-smoothing: antialiased; min-height: 100dvh; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; letter-spacing: -.015em; line-height: 1.2; margin: 0; }
.serif { font-family: var(--serif); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; font-size: 15px; cursor: pointer; text-decoration: none; transition: transform .12s, background .15s, opacity .15s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:hover { border-color: var(--muted); }
.btn-primary:hover { border-color: var(--accent); opacity: .92; }
.btn-danger { color: var(--bad); }
.btn-block { width: 100%; }
label.btn { text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--text); margin: 0; }
label.btn-sm { font-size: 12px; }
.btn-sm { min-height: 38px; padding: 0 16px; font-size: 14px; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer; }

/* Formulare */
label { display: block; font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px; }
.field { margin-bottom: 14px; }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; outline: none; min-height: 48px; }
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 18%, transparent); }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; color: var(--text); font-weight: 400; letter-spacing: 0; text-transform: none; }
.check input { width: 22px; height: 22px; min-height: 0; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.error { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); padding: 10px 14px; border-radius: 12px; font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.seg { display: flex; background: var(--surface2); border-radius: 999px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 500; font-size: 14px; padding: 9px 8px; border-radius: 999px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Karten */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.kpis > .card, .accounts > .card, .list > .card, .form-grid > .card, .row-3 > * { margin-top: 0; }
.row-3 .btn { padding: 0 8px; font-size: 14px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 34px 0 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.section-title h2 { font-size: 24px; }
.section-title a { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--gold-soft); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; letter-spacing: .02em; padding: 3px 9px; border-radius: 999px; background: var(--surface2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

/* Login */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px 18px; background: radial-gradient(700px 420px at 85% -10%, color-mix(in srgb, var(--gold) 20%, transparent), transparent), var(--bg); }
.login { padding: 30px 26px; border-radius: 28px; }
.login { width: 100%; max-width: 400px; }
.brand { display: flex; align-items: flex-end; gap: 2px; line-height: 1; color: var(--text); text-decoration: none; }
.brand img { height: 17px; width: auto; display: block; }
.brand i { font-family: var(--serif); font-style: italic; color: var(--gold); font-size: 22px; line-height: .8; }
.logo-light { display: none !important; }
@media (prefers-color-scheme: dark) { .logo-dark { display: none !important; } .logo-light { display: block !important; } }
.login .brand { margin-bottom: 30px; }
.who { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.who button { border: 1px solid var(--line); background: var(--surface); border-radius: 18px; padding: 16px 6px; font: inherit; font-weight: 500; color: var(--text); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.who button .av { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-family: var(--serif); font-style: italic; font-size: 20px; }
.who button.on { border-color: var(--c); box-shadow: 0 0 0 1px var(--c), 0 10px 24px color-mix(in srgb, var(--c) 18%, transparent); }

/* App-Gerüst */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.topbar .title { font-family: var(--serif); font-weight: 400; font-size: 24px; letter-spacing: -.01em; }
.me { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-family: var(--serif); font-style: italic; font-size: 18px; }
main.app { padding: 14px 16px calc(100px + env(safe-area-inset-bottom)); max-width: 1100px; margin: 0 auto; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: grid; grid-template-columns: repeat(6, 1fr); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; font-size: 11px; font-weight: 500; letter-spacing: .02em; color: var(--muted); text-decoration: none; border-radius: 12px; }
.tabbar a.on { color: var(--text); }
.tabbar a.on svg { color: var(--gold); }
.tabbar a.plus span.pl { width: 48px; height: 48px; margin-top: -20px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 10px 24px rgba(11,18,32,.25); border: 3px solid var(--bg); }
.sidebar { display: none; }

/* Übersicht */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpi { padding: 14px 16px; }
.kpi .k { font-size: 11.5px; color: var(--muted); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; }
.kpi .v { font-family: var(--serif); font-size: clamp(19px, 5.4vw, 26px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 400; letter-spacing: -.02em; margin-top: 4px; }
.kpi.hl { background: var(--hero); color: var(--hero-ink); border-color: transparent; position: relative; overflow: hidden; }
.kpi.hl::after { content: ''; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--gold) 45%, transparent), transparent); }
.kpi.hl .k { color: var(--gold-soft); }
.splitbar { display: flex; height: 6px; border-radius: 99px; overflow: hidden; margin: 14px 0 12px; gap: 3px; }
.splitbar span { border-radius: 99px; }
.splitbar span { display: block; }
.accounts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.acc { position: relative; overflow: hidden; padding: 18px 18px 14px; }
.acc::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--c); }
.acc .head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.acc .head .avatar { width: 34px; height: 34px; background: var(--c); }
.acc .head h3 { font-size: 21px; }
.acc .saldo { font-family: var(--serif); font-size: 36px; font-weight: 350; letter-spacing: -.02em; line-height: 1.15; }
.acc .lines { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 14px; margin: 14px 0; padding-top: 12px; border-top: 1px solid var(--line); }
.acc .lines span:nth-child(even) { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.chart { width: 100%; height: 180px; display: block; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Listen */
.list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.item { display: flex; gap: 12px; align-items: center; padding: 14px 16px; cursor: pointer; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .amt { font-family: var(--serif); font-size: 17px; font-weight: 400; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item .ic { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface2); }
.amt.in { color: var(--ok); } .amt.out { color: var(--bad); } .amt.pay { color: var(--gold); }
.item.storno { opacity: .55; } .item.storno .t { text-decoration: line-through; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 999px; color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); font-variant-numeric: tabular-nums; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 160px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* Fahrzeuge */
.fleet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.car-tile { padding: 0; overflow: hidden; cursor: pointer; }
.car-tile .body { padding: 14px 16px 16px; }
.car-tile .t { font-family: var(--serif); font-size: 20px; }
.car-tile .s { font-size: 13px; color: var(--muted); }
.pic { aspect-ratio: 3 / 2; display: grid; place-items: center; overflow: hidden; background: radial-gradient(120% 90% at 80% 10%, color-mix(in srgb, var(--gold) 14%, transparent), transparent 60%), var(--surface2); }
.pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pic img.contain { object-fit: contain; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.img-tile { position: relative; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); }
.img-tile .cover-badge { position: absolute; left: 8px; top: 8px; }
.img-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; }
.img-actions .btn { flex: 1; min-height: 32px; padding: 0 8px; font-size: 12px; }

/* Formular-Abschnitte */
.form-sec { margin-bottom: 14px; }
.form-sec h3 { font-size: 21px; display: flex; align-items: baseline; gap: 10px; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.form-sec h3 .n { font-family: var(--serif); font-style: italic; color: var(--gold); font-size: 16px; }
.sigpad { position: relative; border: 1px solid var(--line); border-radius: 16px; background: #fffdf9; touch-action: none; height: 200px; }
.sigpad canvas { width: 100%; height: 100%; display: block; border-radius: 12px; }
.sigpad .hint { position: absolute; left: 18px; bottom: 34px; right: 18px; border-top: 1px solid #cdbf9f; padding-top: 6px; font-size: 12px; color: #9a9080; font-family: var(--serif); font-style: italic; pointer-events: none; }
.sigpad.signed .hint { color: transparent; }
.sticky-submit { position: sticky; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 5; padding-top: 10px; }
.terms { font-size: 13px; color: var(--muted); background: var(--surface2); border-radius: 12px; padding: 12px 14px; max-height: 150px; overflow: auto; margin-bottom: 12px; }
.terms ol { margin: 0; padding-left: 18px; }

/* Audit */
.audit .e { padding: 14px 16px; }
.audit .h { display: flex; align-items: center; gap: 8px; font-size: 14px; flex-wrap: wrap; }
.audit .chg { font-size: 13px; margin-top: 8px; display: grid; gap: 3px; }
.audit .chg .from { color: var(--bad); text-decoration: line-through; }
.audit .chg .to { color: var(--ok); font-weight: 600; }
.reason { margin-top: 8px; font-size: 13px; padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--text); }
.reason b { color: var(--warn); font-weight: 600; }

/* Dialoge */
dialog { border: 0; padding: 0; background: transparent; max-width: none; max-height: none; width: 100%; height: 100%; margin: 0; }
dialog::backdrop { background: rgba(8,10,20,.55); backdrop-filter: blur(3px); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow: auto; background: var(--bg); border-radius: 24px 24px 0 0; padding: 10px 18px calc(24px + env(safe-area-inset-bottom)); animation: up .22s ease-out; }
.sheet .grab { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 12px; }
.sheet .sh { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.sheet .sh h2 { font-size: 26px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.sigimg { background: #fff; border-radius: 12px; border: 1px solid var(--line); max-width: 100%; height: 120px; object-fit: contain; display: block; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px; z-index: 100; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

/* Druckansicht Vertrag */
#print { display: none; }
@media print {
  body > *:not(#print) { display: none !important; }
  #print { display: block; color: #000; font: 12px/1.45 system-ui, sans-serif; }
  #print h1 { font-size: 20px; margin-bottom: 4px; }
  #print table { width: 100%; border-collapse: collapse; margin: 10px 0; }
  #print td { border: 1px solid #bbb; padding: 5px 8px; vertical-align: top; }
  #print td:first-child { width: 34%; color: #444; }
  #print img { height: 90px; }
}

/* Desktop */
@media (min-width: 900px) {
  .tabbar { display: none; }
  .sidebar { display: flex; flex-direction: column; gap: 4px; position: fixed; top: 0; bottom: 0; left: 0; width: 230px; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line); z-index: 31; }
  .sidebar a.brand, .sidebar a.brand:hover { padding: 10px 14px 30px; background: transparent; border-radius: 0; }
  .sidebar a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 999px; color: var(--muted); font-weight: 500; text-decoration: none; }
  .sidebar a.on, .sidebar a:hover { background: var(--surface2); color: var(--text); }
  .sidebar a.on svg { color: var(--gold); }
  .topbar, main.app { margin-left: 230px; }
  main.app { padding: 24px 32px 48px; }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .accounts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sticky-submit { bottom: 16px; }
  .sheet { left: 50%; top: 50%; bottom: auto; transform: translate(-50%, -50%); width: min(620px, calc(100% - 48px)); max-height: 88dvh; border-radius: 24px; padding: 22px 26px 26px; animation: none; }
  .sheet .grab { display: none; }
  .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
  .form-grid .full { grid-column: 1 / -1; }
  .form-grid .form-sec { margin: 0; }
  .toast { bottom: 24px; }
}
