/* Reisekasse – Fjord-Palette: Fichtengrün + Signalgelb, kühler Nebel-Hintergrund */
:root {
  --bg: #e9efee;
  --surface: #ffffff;
  --surface-2: #f4f7f6;
  --ink: #15302e;
  --ink-2: #4b6461;
  --line: #d3dedc;
  --accent: #f2b705;
  --accent-ink: #1d1a05;
  --spruce: #1f5c55;
  --plus: #237a4b;
  --minus: #b93a26;
  --focus: #1f6fd1;
  --shadow: 0 1px 0 rgba(21, 48, 46, .06), 0 8px 24px -12px rgba(21, 48, 46, .25);
  --r-s: 8px;
  --r-m: 14px;
  --r-l: 22px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1918; --surface: #152523; --surface-2: #1b2e2b; --ink: #e2ecea; --ink-2: #93aba7;
    --line: #27403c; --accent: #f5c33b; --accent-ink: #1d1a05; --spruce: #7cc5b9; --plus: #5fcf8f;
    --minus: #f08a74; --focus: #7ab4ff; --shadow: 0 1px 0 rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1918; --surface: #152523; --surface-2: #1b2e2b; --ink: #e2ecea; --ink-2: #93aba7;
  --line: #27403c; --accent: #f5c33b; --accent-ink: #1d1a05; --spruce: #7cc5b9; --plus: #5fcf8f;
  --minus: #f08a74; --focus: #7ab4ff; --shadow: 0 1px 0 rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font-text); font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
h1, h2, h3 { font-family: var(--font); line-height: 1.15; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 750; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--spruce); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; white-space: nowrap; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Grundlayout ---------- */
.shell { max-width: 820px; margin: 0 auto; padding: 0 16px calc(110px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner { max-width: 820px; margin: 0 auto; padding: 12px 16px; display: flex; gap: 12px; align-items: center; }
.topbar .title { flex: 1; min-width: 0; }
.topbar .title h1 { font-size: 1.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title p { font-size: .85rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.iconbtn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); display: inline-grid; place-items: center; cursor: pointer; flex: none;
}
.iconbtn svg { width: 20px; height: 20px; }

/* Navigation: unten auf Mobil, oben auf Desktop */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tabs a {
  flex: 1; max-width: 180px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; text-decoration: none; color: var(--ink-2); font-size: .75rem; font-weight: 600; border-radius: var(--r-m);
}
.tabs a svg { width: 24px; height: 24px; }
.tabs a[aria-current="page"] { color: var(--ink); }
.tabs a[aria-current="page"] svg { color: var(--spruce); }
@media (min-width: 760px) {
  .tabs { position: sticky; top: calc(64px + env(safe-area-inset-top)); bottom: auto; border: 0; background: transparent; padding: 4px 16px 0; z-index: 15; }
  .tabs-inner { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
  .tabs a { flex-direction: row; gap: 8px; font-size: .9rem; padding: 8px 18px; border-radius: 999px; max-width: none; }
  .tabs a svg { width: 18px; height: 18px; }
  .tabs a[aria-current="page"] { background: var(--ink); color: var(--bg); }
  .tabs a[aria-current="page"] svg { color: var(--accent); }
  .shell { padding-bottom: 80px; }
}
@media (max-width: 759px) { .tabs-inner { display: contents; } }

.section { margin-top: 24px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }

/* ---------- Kennzahlen ---------- */
.summary { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 1px; background: var(--line); border-radius: var(--r-l); overflow: hidden; margin-top: 16px; border: 1px solid var(--line); }
.summary > div { background: var(--surface); padding: 14px 16px; }
.summary .label { font-size: .8rem; color: var(--ink-2); }
.summary .value { font-family: var(--font); font-size: 1.35rem; font-weight: 800; margin-top: 2px; }
.summary .big .value { font-size: 1.9rem; }
@media (max-width: 520px) {
  .summary { grid-template-columns: 1fr 1fr; }
  .summary .big { grid-column: 1 / -1; }
}

/* ---------- Listen ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; }
.day { font-size: .82rem; font-weight: 700; color: var(--ink-2); padding: 18px 4px 6px; }
.row {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px;
  border-top: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-bottom: 0;
  width: 100%; text-align: left; color: inherit; font: inherit; cursor: pointer;
}
.row:first-child { border-top: 0; }
.row:hover { background: var(--surface-2); }
.row[disabled] { cursor: default; }
.row[disabled]:hover { background: none; }
.cat {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2);
  color: var(--spruce); border: 1px solid var(--line);
}
.cat svg { width: 20px; height: 20px; }
.cat.transfer { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); color: var(--ink); border-color: transparent; }
.row .main { min-width: 0; }
.row .main strong { display: block; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .main span { display: block; font-size: .83rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amt { text-align: right; }
.row .amt strong { display: block; font-weight: 700; }
.row .amt span { display: block; font-size: .8rem; color: var(--ink-2); }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.empty h2 { color: var(--ink); margin-bottom: 6px; }

/* ---------- Abrechnung: Überweisungs-Tickets (das prägende Element) ---------- */
.tickets { display: grid; gap: 12px; }
.ticket {
  --notch: 11px;
  position: relative; display: grid; grid-template-columns: 1fr auto; background: var(--surface);
  border-radius: var(--r-m); box-shadow: var(--shadow);
  -webkit-mask: radial-gradient(circle var(--notch) at calc(100% - 132px) 0, #0000 98%, #000) top / 100% 51% no-repeat,
                radial-gradient(circle var(--notch) at calc(100% - 132px) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
          mask: radial-gradient(circle var(--notch) at calc(100% - 132px) 0, #0000 98%, #000) top / 100% 51% no-repeat,
                radial-gradient(circle var(--notch) at calc(100% - 132px) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
}
.ticket .who { padding: 16px 18px; display: grid; gap: 6px; min-width: 0; }
.ticket .who .from, .ticket .who .to { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ticket .who b { font-family: var(--font); font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket .who small { color: var(--ink-2); font-size: .78rem; width: 52px; flex: none; }
.ticket .stub {
  width: 132px; padding: 14px 14px; border-left: 2px dashed var(--line); display: flex; flex-direction: column;
  justify-content: center; align-items: flex-end; gap: 8px; background: color-mix(in srgb, var(--accent) 16%, var(--surface));
}
.ticket .stub .value { font-family: var(--font); font-weight: 800; font-size: 1.25rem; }
.ticket .stub button { font-size: .78rem; padding: 6px 10px; }
.settled {
  display: flex; gap: 14px; align-items: center; padding: 18px; border-radius: var(--r-m);
  background: color-mix(in srgb, var(--plus) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--plus) 35%, var(--line));
}

/* Salden-Balken */
.balances { display: grid; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 8px 0; }
.bal { display: grid; grid-template-columns: minmax(80px, 140px) 1fr minmax(88px, auto); align-items: center; gap: 12px; padding: 8px 16px; }
.bal .name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bal .name small { display: block; font-weight: 400; color: var(--ink-2); font-size: .78rem; }
.bal .track { position: relative; height: 12px; }
.bal .track::before { content: ""; position: absolute; left: 50%; top: -6px; bottom: -6px; width: 1px; background: var(--line); }
.bal .bar { position: absolute; top: 0; height: 100%; border-radius: 6px; }
.bal .bar.pos { left: 50%; background: var(--plus); }
.bal .bar.neg { right: 50%; background: var(--minus); }
.bal .v { text-align: right; font-weight: 700; }
@media (max-width: 600px) {
  .bal { grid-template-columns: 1fr auto; row-gap: 6px; padding: 10px 16px; }
  .bal .track { grid-column: 1 / -1; grid-row: 2; height: 8px; }
}
.pos-t { color: var(--plus); }
.neg-t { color: var(--minus); }

.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 14px; border-top: 1px solid var(--line); font-size: .92rem; vertical-align: middle; }
.table thead th { border-top: 0; font-size: .8rem; color: var(--ink-2); font-weight: 600; background: var(--surface-2); }
.table td.r, .table th.r { text-align: right; }
.table-wrap { overflow-x: auto; border-radius: var(--r-l); }

/* ---------- Buttons & Formulare ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit;
  font-weight: 650; padding: 10px 16px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center;
  gap: 8px; justify-content: center; text-decoration: none; line-height: 1.2;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.04); }
.btn.dark { background: var(--ink); color: var(--bg); border-color: transparent; }
.btn.danger { color: var(--minus); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }

.fab {
  position: fixed; right: max(18px, calc(50% - 410px + 18px)); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 30;
  width: 60px; height: 60px; border-radius: 20px; border: 0; background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 10px 26px -8px rgba(160, 120, 0, .55); cursor: pointer; display: grid; place-items: center;
}
.fab svg { width: 28px; height: 28px; }
@media (min-width: 760px) { .fab { bottom: 28px; } }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-s); padding: 11px 12px; min-height: 44px;
}
.input:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.amount-row { display: grid; grid-template-columns: 1fr 120px; gap: 10px; }
.amount-row .input:first-child { font-family: var(--font); font-size: 1.6rem; font-weight: 800; }
.hint { font-size: .83rem; color: var(--ink-2); margin-top: -6px; margin-bottom: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 7px 12px;
  font: inherit; font-size: .88rem; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip svg { width: 16px; height: 16px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; cursor: pointer; }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked { background: var(--spruce); }
.switch input:checked::after { transform: translateX(18px); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 18px; }
.card + .card { margin-top: 12px; }
.person-head { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font); font-weight: 800;
  background: var(--surface-2); color: var(--spruce); border: 1px solid var(--line); flex: none;
}
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); margin-left: 6px; vertical-align: middle; }
.badge.gold { background: color-mix(in srgb, var(--accent) 30%, var(--surface)); color: var(--ink); border-color: transparent; }
.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1rem; letter-spacing: .08em; font-weight: 700; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.notice { padding: 12px 14px; border-radius: var(--r-m); background: color-mix(in srgb, var(--accent) 18%, var(--surface)); font-size: .9rem; margin-top: 14px; }
.notice.err { background: color-mix(in srgb, var(--minus) 14%, var(--surface)); }

/* ---------- Dialog / Bottom Sheet ---------- */
dialog.sheet {
  border: 0; padding: 0; background: var(--surface); color: var(--ink); width: min(560px, 100%); max-height: 92dvh;
  border-radius: var(--r-l); box-shadow: 0 30px 80px -20px rgba(0,0,0,.5);
}
dialog.sheet::backdrop { background: rgba(8, 20, 19, .45); backdrop-filter: blur(2px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.sheet-body { padding: 10px 18px 18px; overflow: auto; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
.sheet-foot .spacer { flex: 1; }
dialog.sheet[open] { animation: sheet-in .22s ease-out; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
@media (max-width: 600px) {
  dialog.sheet { margin: auto 0 0; max-width: 100%; width: 100%; border-radius: var(--r-l) var(--r-l) 0 0; max-height: 94dvh; display: none; flex-direction: column; }
  dialog.sheet[open] { display: flex; }
  dialog.sheet form { display: flex; flex-direction: column; min-height: 0; }
}

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-box { width: min(420px, 100%); }
.mark { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.mark img { width: 52px; height: 52px; border-radius: 14px; }
.mark span { font-family: var(--font); font-weight: 800; font-size: 1.3rem; }
.login h1 { font-size: 2rem; margin-bottom: 8px; }
.login p.lead { color: var(--ink-2); margin-bottom: 26px; }
.code-input {
  width: 100%; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1.9rem; font-weight: 700; letter-spacing: .18em;
  text-align: center; text-transform: uppercase; padding: 16px; border-radius: var(--r-m); border: 2px solid var(--line);
  background: var(--surface); color: var(--ink);
}
.code-input:focus { outline: none; border-color: var(--spruce); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--ink-2); font-size: .85rem; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Admin ---------- */
.admin-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.trip-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.cur-edit { display: grid; grid-template-columns: 70px 1fr 150px 40px; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.cur-edit:first-child { border-top: 0; }
@media (max-width: 560px) { .cur-edit { grid-template-columns: 56px 1fr 40px; } .cur-edit .rate { grid-column: 1 / -1; } }
.search { position: relative; }
.search .input { padding-left: 38px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--ink-2); }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: .9rem;
  box-shadow: var(--shadow); max-width: calc(100% - 32px);
}
.toast.err { background: var(--minus); color: #fff; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--spruce); border-radius: 50%; animation: spin .8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.row .main strong .badge { display: inline-block; font-size: .7rem; white-space: nowrap; }
