/* olditours – ruhiges, professionelles Layout ohne externe Abhängigkeiten */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-text: #ffffff;
  --accent: #eff4ff;
  --ok: #15803d;
  --ok-bg: #e7f6ec;
  --warn: #b45309;
  --warn-bg: #fdf3e2;
  --bad: #b91c1c;
  --bad-bg: #fdecec;
  --nav-bg: #0f1b2d;
  --nav-text: #b6c2d4;
  --nav-muted: #6b7a91;
  --nav-hover: #1a2a42;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05);
  --sidebar: 236px;
  --topbar: 60px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14.5px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --surface: #161b22; --surface-2: #1c222b; --text: #e6edf3; --text-2: #c9d1d9; --muted: #8b949e;
    --border: #2a313c; --border-strong: #3a4350; --primary: #4c8dff; --primary-hover: #6aa1ff; --accent: #172238;
    --ok: #3fb950; --ok-bg: #12261a; --warn: #d29922; --warn-bg: #2a2111; --bad: #f85149; --bad-bg: #2d1416;
    --nav-bg: #0a0e14; --nav-hover: #151c27; --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; font-weight: 650; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 1rem; font-weight: 650; margin: 0 0 .85rem; }
h3 { font-size: .95rem; font-weight: 600; margin: .5rem 0; }
.muted { color: var(--muted); }
.small, small { font-size: .84rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.center { text-align: center; }
pre { white-space: pre-wrap; font-size: .8rem; max-height: 300px; overflow: auto; background: var(--surface-2); padding: .75rem; border-radius: 6px; }

.icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- Seitenleiste ---------- */
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar); z-index: 30;
  display: flex; flex-direction: column; padding: 0 .75rem .75rem;
  background: var(--nav-bg); color: var(--nav-text); overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: .65rem; height: var(--topbar); padding: 0 .5rem; margin-bottom: .5rem;
  color: #fff; font-weight: 700; font-size: 1.05rem; letter-spacing: .01em; border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; }
.nav-new {
  display: flex; align-items: center; justify-content: center; gap: .45rem; margin: .5rem 0 .75rem; padding: .6rem .75rem;
  background: var(--primary); color: #fff; border-radius: var(--radius); font-weight: 600;
}
.nav-new:hover, .nav-new.active { background: var(--primary-hover); text-decoration: none; }
.nav-group { margin: 1rem .6rem .35rem; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--nav-muted); }
.nav-link { display: flex; align-items: center; gap: .7rem; padding: .5rem .65rem; border-radius: 6px; color: var(--nav-text); font-weight: 500; }
.nav-link:hover { background: var(--nav-hover); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--nav-hover); color: #fff; box-shadow: inset 3px 0 0 var(--primary); }
.nav-link.active .icon { color: #7aa7ff; }
.nav-foot { margin-top: auto; padding: 1rem .6rem 0; font-size: .75rem; color: var(--nav-muted); }

/* ---------- Kopfleiste ---------- */
.topbar {
  position: fixed; top: 0; right: 0; left: var(--sidebar); height: var(--topbar); z-index: 20;
  display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 600; color: var(--text-2); }
.topbar-user { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.user-chip { display: flex; align-items: center; gap: .6rem; padding: .3rem .6rem .3rem .3rem; border-radius: 99px; color: var(--text); }
.user-chip:hover { background: var(--surface-2); text-decoration: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--primary); font-weight: 700; }
.user-name { display: flex; flex-direction: column; line-height: 1.2; font-size: .88rem; font-weight: 600; }
.user-name small { font-size: .74rem; font-weight: 500; color: var(--muted); }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-toggle { display: none; background: none; border: 0; font-size: 1.35rem; color: var(--text); cursor: pointer; padding: .25rem .5rem; }

.content { margin: var(--topbar) 0 0 var(--sidebar); padding: 1.75rem 2rem 3rem; max-width: calc(1440px + var(--sidebar)); }

@media (max-width: 900px) {
  .nav-toggle { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .topbar { left: 0; padding: 0 1rem; }
  .content { margin-left: 0; padding: 1.25rem 1rem 2rem; }
  .user-name { display: none; }
}

/* ---------- Anmeldung ---------- */
body.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem;
  background: linear-gradient(160deg, #0f1b2d 0%, #1a2f52 100%); }
.auth-box { width: 100%; max-width: 400px; padding: 2.25rem; background: var(--surface); border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-box h1 { margin-bottom: .2rem; }
.auth-version { margin-top: 1.25rem; font-size: .75rem; color: #8ea0bb; }

/* ---------- Bausteine ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head .actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .table th:first-child, .card-flush .table td:first-child { padding-left: 1.25rem; }
.card-flush .table th:last-child, .card-flush .table td:last-child { padding-right: 1.25rem; }
.card-flush .table tr:last-child td { border-bottom: 0; }
.card-warn { border-left: 3px solid var(--warn); }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.count { display: inline-block; min-width: 1.5em; padding: 0 .45em; margin-left: .3rem; border-radius: 99px; background: var(--warn-bg); color: var(--warn); font-size: .8rem; text-align: center; }
.empty { margin: 0; padding: 2rem 1.25rem; text-align: center; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.span-2 { grid-column: 1 / -1; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

.tiles {
  display: flex; flex-wrap: wrap; gap: 1px; margin-bottom: 1.25rem;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.tile { flex: 1 1 0; min-width: 0; background: var(--surface); padding: .6rem .95rem .65rem; }
@media (max-width: 900px) { .tile { flex: 1 1 140px; } }
.tile-label { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value { font-size: 1.2rem; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile-sub { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn {
  display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--primary); background: var(--primary); color: var(--primary-text);
  padding: .48rem .95rem; border-radius: 6px; font: inherit; font-weight: 600; font-size: .9rem; line-height: 1.3; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); text-decoration: none; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn-ok { background: var(--ok); border-color: var(--ok); }
.btn-ok:hover { background: #116a32; border-color: #116a32; }
.btn-danger { background: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: #991b1b; border-color: #991b1b; }
.btn-sm { padding: .28rem .6rem; font-size: .82rem; }
.inline { display: inline; }
.danger-zone { margin-top: 1rem; text-align: right; }

.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; border-left-width: 3px; font-size: .92rem; }
.flash-success { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.flash-error { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.flash-warning { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .6rem .7rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th {
  background: var(--surface-2); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); white-space: nowrap;
}
.table th.num, .table td.num { text-align: right; }
.table tr.total td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border-strong); }
.table.small { font-size: .85rem; }
.table.small th, .table.small td { padding: .45rem .6rem; }
.card > .table-wrap:first-child, .card > .table:first-child { margin-top: -.25rem; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent); }
.inactive { opacity: .55; }
.thumb-cell { width: 52px; padding-right: 0 !important; }
.avatar-img { width: 38px; height: 38px; object-fit: cover; border-radius: 6px; display: block; background: var(--accent); }
.input-sm { width: 6.5rem !important; padding: .3rem .5rem !important; text-align: right; }
.actions-cell { text-align: right; }

.badge { display: inline-block; padding: .12rem .5rem; border-radius: 4px; font-size: .74rem; font-weight: 600; background: var(--accent); color: var(--primary); white-space: nowrap; }
a.badge:hover { text-decoration: none; filter: brightness(.95); }
.badge-bestaetigt, .badge-durchgefuehrt { background: var(--ok-bg); color: var(--ok); }
.badge-angefragt { background: var(--warn-bg); color: var(--warn); }
.badge-storniert { background: var(--bad-bg); color: var(--bad); }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .45rem; vertical-align: middle; }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: 0 0 .75rem; font-size: .92rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.list { margin: 0; padding-left: 1.1rem; }
.list li { margin: .3rem 0; }
.checks { list-style: none; padding: 0; }
.checks li { padding: .2rem 0; }
.checks .ok { color: var(--ok); }
.checks .bad { color: var(--bad); }

/* ---------- Formulare ---------- */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .86rem; font-weight: 600; color: var(--text-2); }
label small { font-weight: 400; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; }
input, select, textarea {
  font: inherit; font-size: .92rem; font-weight: 400; padding: .5rem .65rem; border: 1px solid var(--border-strong); border-radius: 6px;
  background: var(--surface); color: var(--text); width: 100%;
}
input[type=checkbox], input[type=color] { width: auto; }
input[type=color] { height: 2.2rem; padding: .1rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.narrow { max-width: 640px; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; }
.row > label { flex: 1 1 160px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem 2rem; }
.form-grid fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .8rem; min-width: 0; }
.form-grid legend { width: 100%; font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  padding: 0 0 .45rem; margin-bottom: .6rem; border-bottom: 1px solid var(--border); }
.form-actions { display: flex; gap: .5rem; margin-top: .5rem; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.filters label { flex: 0 1 170px; }
.hint { font-size: .85rem; color: var(--muted); }
.hint.warn { color: var(--bad); font-weight: 600; }
#guest-table input { min-width: 6rem; }

/* ---------- Bilder ---------- */
.round { border-radius: 50% !important; }
.hero-img { width: 100%; max-height: 260px; object-fit: cover; border-radius: var(--radius); margin-bottom: 1rem; background: var(--accent); }
.hero-img.round { width: 160px; height: 160px; display: block; }
.preview { max-width: 200px; border-radius: var(--radius); }
.media { display: flex; gap: 1rem; align-items: flex-start; }
.thumb { width: 110px; height: 80px; object-fit: cover; border-radius: 6px; }

.fuel, .meter { display: block; height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; margin: .3rem 0 .15rem; max-width: 220px; }
.meter { display: inline-block; width: 60px; vertical-align: middle; margin: 0 .35rem 0 0; }
.fuel-bar { display: block; height: 100%; }
.fuel-ok { background: var(--ok); } .fuel-mid { background: var(--warn); } .fuel-low { background: var(--bad); }

/* ---------- Balken ---------- */
.bars { display: flex; flex-direction: column; gap: .4rem; }
.bar-row { display: grid; grid-template-columns: 5.5rem 1fr 6rem; gap: .6rem; align-items: center; font-size: .84rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.bar-track { background: var(--surface-2); border: 1px solid var(--border); height: 10px; border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Kalender ---------- */
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; margin-bottom: 1.25rem;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-head { background: var(--surface-2); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: .5rem .6rem; }
.cal-day { background: var(--surface); min-height: 120px; padding: .4rem; display: flex; flex-direction: column; gap: 3px; }
.cal-empty { background: var(--surface-2); }
.cal-today { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-num { display: flex; justify-content: space-between; font-size: .8rem; font-weight: 600; color: var(--muted); }
.cal-add { opacity: 0; font-weight: 700; padding: 0 .3rem; }
.cal-day:hover .cal-add { opacity: 1; }
.cal-trip {
  display: block; font-size: .75rem; line-height: 1.25; padding: .28rem .4rem; border-radius: 4px; color: var(--text);
  background: color-mix(in srgb, var(--c) 14%, transparent); border-left: 3px solid var(--c);
}
.cal-trip:hover { text-decoration: none; filter: brightness(.96); }
.cal-trip span { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-trip.status-storniert { opacity: .45; text-decoration: line-through; }
.cal-trip.status-angefragt { border-left-style: dashed; }
/* Auf dem Handy ersetzt die Liste das Monatsraster */
@media (max-width: 760px) {
  .calendar { display: none; }
}

/* ---------- Kompaktes Formular (Fahrt) ---------- */
.form-compact { padding: 0; }
.fsec { display: grid; grid-template-columns: 150px 1fr; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.fsec h3 { margin: .45rem 0 0; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.fsec > details, .fsec > .fgrid + * { grid-column: 2; }
.fgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .65rem .9rem; align-items: end; }
.fgrid .c2 { grid-column: span 2; }
.fgrid label { font-size: .8rem; gap: .2rem; }
.fgrid input, .fgrid select, .fgrid textarea { padding: .4rem .55rem; font-size: .9rem; }
.fgrid .hint { align-self: center; margin: 0; }
.pay-box { align-self: end !important; padding: .45rem .6rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; font-size: .8rem; color: var(--text-2); }
details.guests { margin-top: .25rem; }
details.guests summary { cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--primary); padding: .25rem 0; }
details.guests .table { margin: .5rem 0; }
.form-foot { display: flex; align-items: center; gap: .5rem; padding: .9rem 1.25rem; background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.form-foot-right { margin-left: auto; display: flex; gap: .5rem; }
@media (max-width: 1000px) {
  .fsec { grid-template-columns: 1fr; gap: .5rem; }
  .fsec > details, .fsec > .fgrid + * { grid-column: 1; }
}
@media (max-width: 640px) {
  .fgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Freigabe melden ---------- */
.card-head .inline { display: inline-flex; gap: .4rem; align-items: center; }
.notify-select { width: auto; padding: .28rem .5rem; font-size: .82rem; }
.wa-panel { margin: 0 0 1rem; padding: .9rem 1rem; border: 1px solid #b7e4c7; background: #f0faf3; border-radius: var(--radius); }
.wa-panel h3 { margin: 0 0 .2rem; color: #15803d; }
.wa-panel p { margin: 0 0 .6rem; }
.wa-buttons { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.wa-link.done { opacity: .5; }
.wa-link.done::after { content: " ✓"; }
.wa-panel textarea { margin-top: .4rem; font-size: .85rem; }
@media (prefers-color-scheme: dark) { .wa-panel { background: #12261a; border-color: #1f4d2c; } .wa-panel h3 { color: #3fb950; } }

/* ---------- Handkasse & Abrechnung ---------- */
.amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.amount.pos { color: var(--ok); }
.amount.neg { color: var(--bad); }
.intro { margin: -.5rem 0 1rem; }
tr.selected-row td { background: var(--accent); }
.offer-empty { margin: 0; color: var(--muted); }
.card-offer { border-left: 3px solid var(--ok); }
.card-offer .count { background: var(--ok-bg); color: var(--ok); }
.head-actions { margin-left: auto; display: inline-flex; gap: .3rem; }
.tiles-inline { margin-bottom: 1rem; }
.tiles-inline { box-shadow: none; }
.tiles-inline .tile { background: var(--surface-2); }
.tile-cash .tile-sub { white-space: normal; }
.fgrid .span-all { grid-column: 1 / -1; }
.btn-row { display: flex; gap: .4rem; align-items: end; }
.form-editing { box-shadow: 0 0 0 2px var(--primary); }
.tile-warn { box-shadow: inset 3px 0 0 var(--warn); }
.tile-warn .tile-value { color: var(--warn); }
.tile-ok .tile-value { color: var(--ok); }

/* ---------- Einheitliche Feldhöhen ---------- */
input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]), select { height: 2.35rem; line-height: 1.2; }
input[type=date], input[type=time] { padding-top: 0; padding-bottom: 0; }
.fgrid input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]), .fgrid select { height: 2.15rem; }

/* ---------- Filterleiste ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: .6rem .75rem; align-items: flex-end; padding: .75rem 1rem; }
.filter-bar label { flex: 1 1 140px; max-width: 220px; gap: .25rem; font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.filter-bar input:not([type=checkbox]), .filter-bar select { height: 2.1rem !important; padding: 0 .55rem; font-size: .88rem; color: var(--text); }
.filter-bar .filter-actions { margin-left: auto; display: flex; gap: .4rem; align-items: center; }
.filter-bar .btn { height: 2.1rem; }

/* ---------- Karten mit Tabelle (Kopfzeile innen) ---------- */
.card-flush > .card-head { margin: 0; padding: .85rem 1.25rem .75rem; border-bottom: 1px solid var(--border); }
.card-flush > .card-head h2 { font-size: .95rem; }
.text-warn { color: var(--warn); font-weight: 600; }
.text-ok { color: var(--ok); font-weight: 600; }

/* ---------- Kräftige Abschnitts-Überschriften in Karten ---------- */
.card > h2:first-child,
.card > .card-head:first-child {
  margin: -1.25rem -1.25rem 1rem; padding: .75rem 1.25rem;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0; box-shadow: inset 3px 0 0 var(--primary);
}
.card > h2:first-child { font-size: 1rem; font-weight: 700; letter-spacing: -.005em; }
.card-flush > .card-head:first-child { margin: 0; background: var(--surface-2); box-shadow: inset 3px 0 0 var(--primary); }
.card-head h2 { font-size: 1rem; font-weight: 700; }
.card-warn > h2:first-child, .card-warn > .card-head:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.card-offer > .card-head:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.card-warn, .card-offer { border-left-width: 1px; }
.card h3 { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 1.1rem 0 .45rem; }
.fsec h3 { margin-top: .45rem; }
.wa-panel h3 { text-transform: none; letter-spacing: 0; font-size: .95rem; margin-top: 0; }

/* ---------- Kompakter Monatskalender ---------- */
.cal-head { padding: .35rem .5rem; font-size: .66rem; }
.cal-day { min-height: 76px; padding: .25rem .3rem; gap: 2px; }
.cal-num { font-size: .72rem; line-height: 1.2; }
.cal-trip { font-size: .7rem; line-height: 1.2; padding: .15rem .3rem; border-radius: 3px; border-left-width: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-trip b { font-weight: 700; }
.cal-trip span { font-size: .66rem; }
.cal-trip em { font-style: normal; color: var(--warn); }
.cal-trip em.miss { color: var(--bad); }

/* ---------- Fahrtenliste mit Schnellbearbeitung ---------- */
.trips-table .chev { display: inline-block; width: 1rem; color: var(--muted); transition: transform .15s; }
.trips-table tr.open .chev { transform: rotate(90deg); color: var(--primary); }
.trips-table tr.open td { background: var(--accent); border-bottom-color: transparent; }
.trips-table .trip-group:target .trip-row td { animation: flash-row 2s ease-out; }
@keyframes flash-row { from { background: color-mix(in srgb, var(--ok) 22%, transparent); } to { background: transparent; } }
.quick-row > td { background: var(--accent); padding: 0 1.25rem 1rem !important; border-bottom: 2px solid var(--primary); }
.quick-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem .75rem; box-shadow: var(--shadow); }
.quick-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .55rem .75rem; }
.quick-grid .q2 { grid-column: span 2; }
.quick-grid label { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); gap: .2rem; }
.quick-grid input:not([type=checkbox]), .quick-grid select { height: 2.05rem !important; padding: 0 .5rem; font-size: .88rem; color: var(--text); text-transform: none; letter-spacing: 0; }
.quick-actions { display: flex; gap: .4rem; align-items: center; margin-top: .75rem; padding-top: .65rem; border-top: 1px solid var(--border); }
.quick-actions .spacer { flex: 1; }
@media (max-width: 1100px) { .quick-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .quick-grid .q2 { grid-column: 1 / -1; } }

/* ---------- Detailseite einspaltig ---------- */
.detail-stack > .card { margin-bottom: 1rem; }
.detail-stack .dl { grid-template-columns: max-content minmax(0, 1fr) max-content minmax(0, 1fr); column-gap: 1.5rem; }
@media (max-width: 900px) { .detail-stack .dl { grid-template-columns: max-content minmax(0, 1fr); } }

/* =====================================================================
   Handy / Tablet – App-artig mit Tab-Leiste unten (z. B. iPhone 13 mini)
   ===================================================================== */
.tabbar, .topbar-page, .nav-backdrop { display: none; }

@media (max-width: 900px) {
  .topbar { padding-top: env(safe-area-inset-top); height: calc(var(--topbar) + env(safe-area-inset-top)); }
  .content { margin-top: calc(var(--topbar) + env(safe-area-inset-top)); padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
  .topbar-title { display: none; }
  .topbar-page { display: block; font-weight: 700; font-size: 1rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar { z-index: 40; padding-top: env(safe-area-inset-top); }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(15, 23, 42, .45); }

  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
  }
  .tab {
    flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; min-width: 0;
    padding: 6px 2px 4px; border: 0; background: none; font: inherit; font-size: .64rem; font-weight: 600;
    color: var(--muted); text-decoration: none; -webkit-tap-highlight-color: transparent; cursor: pointer;
  }
  .tab:hover { text-decoration: none; }
  .tab .icon { width: 23px; height: 23px; }
  .tab.active { color: var(--primary); }
  .tab-new .icon { width: 34px; height: 34px; padding: 6px; margin-top: -10px; border-radius: 50%; background: var(--primary); color: #fff; box-shadow: 0 3px 10px color-mix(in srgb, var(--primary) 40%, transparent); }
  .tab-new.active { color: var(--primary); }
}

@media (max-width: 640px) {
  :root { --topbar: 52px; }
  input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px !important; } /* verhindert Auto-Zoom auf dem iPhone */
  .content { padding-left: .75rem; padding-right: .75rem; padding-top: .9rem; }
  .topbar { padding-left: .5rem; padding-right: .5rem; gap: .5rem; }
  .icon-btn { width: 40px; height: 40px; }
  .page-head { margin-bottom: .75rem; gap: .5rem; }
  .page-head h1 { font-size: 1.2rem; }
  .intro { margin-top: 0; }
  .card { padding: 1rem; margin-bottom: .85rem; }
  .card > h2:first-child, .card > .card-head:first-child { margin: -1rem -1rem .85rem; padding: .65rem 1rem; }
  .card-flush > .card-head:first-child { margin: 0; }
  .card-head { gap: .35rem .75rem; }
  .head-actions { margin-left: 0; }
  .flash { font-size: .88rem; }

  .tile { flex: 1 1 40%; padding: .55rem .8rem; }
  .tile-value { font-size: 1.1rem; }
  .btn { min-height: 40px; justify-content: center; }
  .btn-sm { min-height: 34px; }
  .dl { grid-template-columns: max-content minmax(0, 1fr) !important; gap: .35rem .9rem; }

  .filter-bar label { flex: 1 1 45%; max-width: none; }
  .filter-bar .filter-actions { margin-left: 0; width: 100%; }
  .filter-bar .filter-actions .btn { flex: 1; }
  .fsec { padding: .85rem 1rem; }
  .form-foot, .quick-actions { flex-wrap: wrap; }
  .form-foot-right { width: 100%; }
  .form-foot-right .btn { flex: 1; }
  .quick-row > td { padding: 0 .5rem .75rem !important; }

  /* Tabellen als Karten */
  table.stackable, table.stackable > tbody, table.stackable > tbody > tr, table.stackable > tbody > tr > td,
  table.stackable > tr, table.stackable > tr > td { display: block; width: 100%; }
  table.stackable > thead, table.stackable tr.head-row { display: none; }
  table.stackable tr { position: relative; padding: .65rem 1rem; border-bottom: 1px solid var(--border); }
  table.stackable tr.clickable:hover td { background: transparent; }
  table.stackable tr.clickable:active { background: var(--accent); }
  table.stackable td {
    display: flex !important; justify-content: space-between; align-items: baseline; gap: 1rem;
    padding: .12rem 0 !important; border: 0 !important; text-align: right; white-space: normal;
  }
  table.stackable td::before {
    content: attr(data-label); flex-shrink: 0; text-align: left;
    font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  }
  table.stackable td:not([data-label])::before, table.stackable td[data-label=""]::before { display: none; }
  table.stackable td:first-child { justify-content: flex-start; text-align: left; font-size: 1rem; padding-bottom: .3rem !important; }
  table.stackable td:first-child::before { display: none; }
  table.stackable td:empty, table.stackable td.thumb-cell { display: none !important; }
  table.stackable td.actions-cell, table.stackable td:last-child:has(.btn, form) { justify-content: flex-end; gap: .4rem; padding-top: .45rem !important; flex-wrap: wrap; }
  table.stackable td.actions-cell::before, table.stackable td:last-child:has(.btn, form)::before { display: none; }
  table.stackable tr.total { background: var(--surface-2); }
  table.stackable tr.total td:first-child { font-size: .9rem; }
  table.stackable tr.quick-row { padding: 0; }
  table.stackable tr.quick-row > td { display: block !important; }
  table.stackable tr.quick-row > td::before { display: none; }
  table.stackable .chev { display: none; }
  .trips-table tr.open { background: var(--accent); }
  .input-sm { width: 7rem !important; }
}
@media (max-width: 640px) {
  table.stackable td { justify-content: flex-start; }
  table.stackable td::before { margin-right: auto; padding-right: 1rem; }
  table.stackable td > .dot { margin-left: 0; }
  .card:not(.card-flush) table.stackable tr { padding-left: 0; padding-right: 0; }
  table.stackable tbody:last-child > tr:last-child, table.stackable > tr:last-child { border-bottom: 0; }
}

/* ---------- Sortierbare Spalten ---------- */
th.sortable { cursor: pointer; user-select: none; -webkit-user-select: none; }
th.sortable:hover { color: var(--text); }
th.sortable::after { content: "↕"; margin-left: .35em; opacity: .35; font-size: .9em; }
th.sortable.sorted { color: var(--primary); }
th.sortable.sorted::after { content: "▲"; opacity: 1; font-size: .75em; }
th.sortable.sorted[data-dir="desc"]::after { content: "▼"; }

/* ---------- Formular-Abschnitte: klare Kopfspalte mit Nummer ---------- */
.form-compact { counter-reset: fsec; overflow: hidden; }
.fsec { grid-template-columns: 210px minmax(0, 1fr); gap: 0; padding: 0; align-items: stretch; }
.fsec:last-of-type { border-bottom-color: var(--border-strong); }
.fsec > h3 {
  grid-row: 1 / span 3; display: flex; align-items: flex-start; gap: .65rem;
  margin: 0; padding: 1.05rem 1.25rem; background: var(--surface-2); border-right: 1px solid var(--border);
  box-shadow: inset 3px 0 0 var(--primary);
  font-size: .98rem; font-weight: 700; text-transform: none; letter-spacing: -.005em; color: var(--text); line-height: 1.3;
}
.fsec > h3::before {
  counter-increment: fsec; content: counter(fsec);
  flex-shrink: 0; display: grid; place-items: center; width: 1.55rem; height: 1.55rem; margin-top: -.08rem;
  border-radius: 50%; background: var(--primary); color: #fff; font-size: .78rem; font-weight: 700;
}
.fsec > .fgrid { padding: 1rem 1.25rem; }
.fsec > .fgrid + .fgrid { padding-top: 0; }
.fsec > details { margin: -.35rem 1.25rem .9rem; }
.fsec > .fgrid + * { grid-column: 2; }
.fgrid label { color: var(--text-2); font-weight: 600; }
.fgrid label small { color: var(--muted); font-weight: 400; }
.fgrid .hint.muted { font-size: .78rem; }
.form-foot { border-top: 1px solid var(--border); }
@media (max-width: 1000px) {
  .fsec { grid-template-columns: 1fr; }
  .fsec > h3 { grid-row: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: .7rem 1rem; }
  .fsec > .fgrid + * { grid-column: 1; }
}
@media (max-width: 640px) {
  .fsec { padding: 0; }
  .fsec > .fgrid { padding: .85rem 1rem; }
  .fsec > details { margin: -.35rem 1rem .85rem; }
}

/* ---------- Kundenliste im Fahrtformular ---------- */
.fgrid-1 { grid-template-columns: 1fr; }
.cust-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; }
.cust-table { margin: 0; }
.cust-table th { background: var(--surface-2); }
.cust-table td { padding: .35rem .4rem; }
.cust-table td:first-child { min-width: 11rem; }
.cust-table input, .cust-table select { height: 2rem !important; padding: 0 .45rem; font-size: .88rem; }
.cust-table .cust-seats { width: 4.5rem; text-align: right; }
.cust-table .cust-price { width: 6.5rem; text-align: right; }
.cust-table .cust-paid { width: 6.5rem; }
.cust-table tbody tr:last-child td { border-bottom: 0; }
.cust-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-top: .6rem; }
.cust-sum { font-size: .85rem; font-weight: 600; color: var(--text-2); }
.cust-total { margin-left: auto; flex-direction: row !important; align-items: center; gap: .5rem !important; font-size: .8rem; }
.cust-total input { width: 5rem; text-align: right; }
input[readonly] { background: var(--surface-2); color: var(--text-2); }
@media (max-width: 640px) {
  .cust-wrap { border: 0; }
  .cust-table tr.cust-row { border: 1px solid var(--border) !important; border-radius: 6px; margin-bottom: .5rem; padding: .5rem .6rem !important; }
  .cust-table td:first-child { min-width: 0; }
  .cust-table td input, .cust-table td select { width: 60% !important; }
  .cust-total { margin-left: 0; }
}

/* ---------- Statistik ---------- */
.share { display: inline-block; width: 46px; height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; vertical-align: middle; }
.share > span { display: block; height: 100%; background: var(--primary); }
.bar-cell { display: flex; align-items: center; gap: .6rem; min-width: 220px; }
.bar-cell .inline-bar { flex: 1; height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.bar-cell .inline-bar > span { display: block; height: 100%; background: var(--primary); }
.bar-cell > span:first-child:empty { flex: 1; }
.bar-cell .num { min-width: 6.5rem; }
.week-chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: .75rem; align-items: end; max-width: 640px; }
.wk { display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.wk-val { font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.wk-bar { width: 100%; max-width: 44px; height: 90px; display: flex; align-items: flex-end; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.wk-bar > span { display: block; width: 100%; background: var(--primary); border-radius: 6px 6px 0 0; }
.wk-lbl { font-size: .72rem; font-weight: 600; color: var(--muted); }
@media (max-width: 640px) { .bar-cell { min-width: 0; } .bar-cell .inline-bar { max-width: 120px; } }

/* ---------- E-Mail-Vorlagen & Postausgang ---------- */
.fgrid .c3 { grid-column: span 3; }
.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tabs a { padding: .55rem 1rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.tpl-card .tpl-info { margin: -.25rem 0 .9rem; }
.tpl-off { opacity: .7; }
.tpl-off .card-head:first-child { box-shadow: inset 3px 0 0 var(--border-strong); }
.tpl-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; }
.tpl-edit { display: flex; flex-direction: column; gap: .7rem; }
.tpl-edit textarea { font-family: inherit; line-height: 1.45; min-height: 14rem; }
.tpl-vars { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip { border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2); border-radius: 99px; padding: .15rem .55rem;
  font: 600 .74rem ui-monospace, SFMono-Regular, Menlo, monospace; cursor: pointer; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.tpl-preview-head { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .3rem; }
.mail-preview { border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); padding: .75rem .9rem; }
.mail-subject { font-weight: 700; padding-bottom: .5rem; margin-bottom: .5rem; border-bottom: 1px solid var(--border); }
.mail-preview pre { margin: 0; padding: 0; background: none; font-family: inherit; font-size: .88rem; max-height: none; white-space: pre-wrap; }
.switch { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: .45rem !important; font-size: .82rem; font-weight: 600; cursor: pointer; }
.switch input { width: 2.2rem; height: 1.2rem; appearance: none; -webkit-appearance: none; border-radius: 99px; background: var(--border-strong); position: relative; cursor: pointer; border: 0; padding: 0; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: calc(1.2rem - 4px); height: calc(1.2rem - 4px); border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(1rem); }
@media (max-width: 900px) { .tpl-grid { grid-template-columns: 1fr; } }

/* ---------- Umschalter (Segmente) ---------- */
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--text-2); font: inherit; font-size: .8rem; font-weight: 600; padding: .3rem .7rem; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.active { background: var(--primary); color: #fff; }
.head-actions { display: inline-flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.testmail-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.testmail-form label { flex: 1 1 260px; max-width: 360px; }
.check-cell { width: 2.2rem; }
.check-cell input { width: auto; height: auto; }

/* ---------- WhatsApp ---------- */
.nav-count { margin-left: auto; min-width: 1.4rem; padding: 0 .4rem; border-radius: 99px; background: #25d366; color: #0b3d1e; font-size: .72rem; font-weight: 700; text-align: center; line-height: 1.4rem; }
.btn-wa { background: #25d366; border-color: #25d366; color: #0b3d1e; }
.btn-wa:hover { background: #1ebe5b; border-color: #1ebe5b; color: #0b3d1e; }
.wa-done { color: var(--ok); font-size: .82rem; font-weight: 600; white-space: nowrap; }
.wa-group textarea { width: 100%; min-height: 12rem; font-size: .88rem; line-height: 1.45; }
.wa-group .quick-actions { margin-top: .5rem; }
.wa-list td { vertical-align: middle; }

/* ---------- Kalender-Abos ---------- */
.howto { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; font-size: .88rem; }
.howto h3 { margin-top: 0; }
.howto ol, .howto ul { margin: 0; padding-left: 1.1rem; }
.howto li { margin: .25rem 0; }
.feeds .feed-name { font-weight: 700; min-width: 14rem; }
.feeds label.check { font-weight: 500; margin: .1rem 0; }
.feeds .feed-link { min-width: 18rem; }
.feeds .feed-link input { font-size: .78rem !important; color: var(--muted); }
.feed-actions { display: flex; gap: .35rem; margin-top: .35rem; }
.feeds td { vertical-align: top; }
@media (max-width: 1000px) { .howto { grid-template-columns: 1fr; } }
.feed-url-small { margin-top: .6rem; font-size: .78rem !important; color: var(--muted); }

/* ---------- Weitere Busse (Konvoi) ---------- */
.conv-head { font-size: .88rem; }
.conv-head .muted { display: block; margin-top: .15rem; }
.conv-pos { font-weight: 700; white-space: nowrap; width: 4.5rem; }
#conv-table select { min-width: 12rem; }
.convoy-list .is-current td { background: var(--accent); }

/* ---------- Geblockte Tage ---------- */
.cal-blocked { background: repeating-linear-gradient(135deg, var(--surface) 0 8px, var(--bad-bg) 8px 16px); }
.cal-block-note { font-size: .68rem; font-weight: 700; color: var(--bad); }
.cal-block-btn { border: 0; background: none; padding: 0 .2rem; font-size: .68rem; color: var(--muted); cursor: pointer; opacity: 0; }
.cal-day:hover .cal-block-btn, .cal-blocked .cal-block-btn { opacity: 1; }
.cal-blocked .cal-block-btn { color: var(--primary); font-weight: 600; }
.cal-staff-blocks { font-size: .66rem; color: var(--bad); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block-form { padding: 0 0 .75rem; box-shadow: none; border: 0; }
@media (hover: none) { .cal-block-btn { opacity: 1; } }
.feed-box { padding: .75rem 0; border-top: 1px solid var(--border); }
.feed-box:first-of-type { border-top: 0; padding-top: .25rem; }
.feed-box .feed-actions { margin-top: .5rem; flex-wrap: wrap; }
.feed-help { margin-top: .5rem; }
.feed-help summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.feed-help ol { margin: .4rem 0 0; padding-left: 1.2rem; }
.feed-help li { margin: .25rem 0; }
.cal-staff-blocks:first-of-type { margin-top: auto; }
.cal-block-note, .cal-staff-blocks { padding: .1rem .3rem; border-radius: 3px; background: var(--bad-bg); }
