/* TT Zeiterfassung – Komponenten. Nur Variablen aus theme.css verwenden. Mobile first. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0 0 .75em; }
code, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
code { font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: var(--fs-sm); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pad { padding: 16px; }
.icon { flex: none; vertical-align: middle; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.hide-mobile { display: none !important; }
@media (min-width: 900px) {
  .hide-mobile { display: initial !important; }
  .hide-desktop { display: none !important; }
}
/* Fokusrahmen: deutlich sichtbar (WCAG 1.4.11, ≥ 3:1 zum Hintergrund) – der frühere Schein (--focus) erreichte nur ~1.5:1 */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--radius-sm); }

/* ------------------------------------------------------------------ App-Layout */
.app { min-height: 100vh; min-height: 100dvh; }
.sidebar { display: none; }
.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-actions { display: flex; align-items: center; gap: 6px; min-width: 0; }
/* Ein Modal/Bottom-Sheet aus der Kopfzeile (z.B. Konto-Menü) muss über der Tab-Leiste liegen */
.topbar:has(.modal-backdrop) { z-index: 150; }
.content {
  padding: 16px max(14px, env(safe-area-inset-right)) calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  max-width: var(--content-max); margin: 0 auto;
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-muted); font-size: 11px; font-weight: 500; text-decoration: none !important;
}
.tab.is-active { color: var(--brand); }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }
  /* Nur die Navigation scrollt – Konto und «Abmelden» (sidebar-foot) bleiben auch bei 720 px Höhe sichtbar */
  .sidebar {
    display: flex; flex-direction: column; gap: 8px;
    position: sticky; top: 0; height: 100vh; overflow: hidden;
    padding: 18px 12px; background: var(--surface); border-right: 1px solid var(--border);
  }
  .sidebar .nav { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 3px; margin: -3px; } /* Padding: Fokusring nicht abschneiden */
  .topbar, .tabbar { display: none; }
  .content { padding: 28px 32px 48px; }
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 10px; }
.brand-name { font-weight: 650; font-size: var(--fs); }
/* Logo-Kasten: immer weiss (Logo ist für hellen Grund gestaltet), auch im Dunkelmodus */
.brand-mark {
  display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; padding: 3px; border-radius: 9px;
  background: #fff; border: 1px solid var(--border);
}
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand-mark-lg { width: 60px; height: 60px; padding: 6px; border-radius: 14px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-section { margin: 14px 10px 4px; font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
.nav > .nav-section:first-child { margin-top: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: var(--radius-sm); border: 0; background: none;
  color: var(--text); font: inherit; font-size: var(--fs); text-align: left; cursor: pointer; text-decoration: none !important;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link.is-active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.nav-link .icon { color: var(--text-muted); }
.nav-link.is-active .icon { color: var(--brand); }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 8px; display: flex; flex-direction: column; gap: 2px; }

.ws-name { font-weight: 650; padding: 0 8px; }
.ws-switch { position: relative; display: flex; align-items: center; }
.ws-switch select {
  appearance: none; -webkit-appearance: none; width: 100%;
  font: inherit; font-weight: 650; color: var(--text);
  padding: 8px 32px 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer;
}
.ws-switch .icon { position: absolute; right: 8px; pointer-events: none; color: var(--text-muted); }
.ws-compact { font-size: var(--fs-lg); padding: 0; }
.ws-compact.ws-switch select { border: 0; background: transparent; padding-left: 0; font-size: var(--fs-lg); min-width: 0; text-overflow: ellipsis; }
.topbar > .ws-switch, .topbar > .ws-name { flex: 1 1 auto; min-width: 0; }
.topbar > .ws-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .topbar-actions { flex: none; }
.topbar .timer-pill { flex: none; min-width: auto; }
@media (max-width: 429px) { .topbar .timer-pill-ws { display: none; } }

.sidebar-timer:empty { display: none; }
.sidebar-timer .timer-pill { width: 100%; justify-content: center; }
.timer-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; min-width: 0;
  background: var(--accent-soft); color: var(--accent-strong); font-weight: 650; text-decoration: none !important;
  box-shadow: var(--shadow-sm);
}
/* Timer läuft in einem anderen Arbeitsbereich: gestrichelt, mit Namen; antippen wechselt */
.timer-pill-elsewhere {
  border: 1px dashed var(--accent); background: var(--surface); font: inherit; font-weight: 650; cursor: pointer;
}
.timer-pill-elsewhere:hover { background: var(--accent-soft); }
.timer-pill-ws {
  font-size: var(--fs-sm); font-weight: 500; color: var(--text-muted);
  max-width: 11em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .timer-pill-ws { max-width: 6.5em; }
@media (max-width: 379px) { .topbar .timer-pill-ws { display: none; } }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: .35; } 100% { opacity: 1; } }

/* ------------------------------------------------------------------ Seitenkopf */
.page { display: flex; flex-direction: column; gap: 16px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.page-header-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.page-title { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.01em; }
.page-subtitle { margin: 2px 0 0; color: var(--text-muted); font-size: var(--fs-sm); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
@media (min-width: 900px) { .page-title { font-size: var(--fs-xxl); } }

/* ------------------------------------------------------------------ Karten & Listen */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card-pad { padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-title { font-size: var(--fs-lg); font-weight: 650; }
.list-card { padding: 4px 0; overflow: hidden; }
.list-link {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 10px 16px;
  border: 0; border-bottom: 1px solid var(--border); background: none; font: inherit; color: var(--text); text-align: left; cursor: pointer;
  text-decoration: none !important;
}
.list-link:last-child { border-bottom: 0; }
.list-link > span { flex: 1; }
.list-link:hover { background: var(--surface-2); }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat-label { font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-value { font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat-sub { font-size: var(--fs-sm); color: var(--text-muted); }

/* ------------------------------------------------------------------ Tabellen */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--border-strong); border-bottom: 0; }
.table .num { text-align: right; }
@media (min-width: 900px) { .table { font-size: var(--fs); } }

/* ------------------------------------------------------------------ Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: var(--fs); line-height: 1.1; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s; text-decoration: none !important;
  user-select: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--brand-contrast); }
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: var(--danger-contrast); }
.btn-danger:hover:not(:disabled) { filter: brightness(.95); }
.btn-accent { background: var(--accent); color: var(--accent-contrast); }
.btn-accent:hover:not(:disabled) { filter: brightness(.95); }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: var(--fs-sm); }
.btn-lg { min-height: 48px; padding: 12px 18px; font-size: var(--fs-lg); }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: 40px; min-width: 40px; }
.btn-icon.btn-sm { width: 32px; min-width: 32px; }
/* Touch-Ziele ≥ 44 px bei pointer: coarse oder Viewport < 900 px (SPEC §11 Kern) */
@media (pointer: coarse), (max-width: 899px) {
  .btn, .btn-sm { min-height: var(--tap); }
  .btn-icon, .btn-icon.btn-sm { width: var(--tap); min-width: var(--tap); }
  .input, .input-sm, .picker { min-height: var(--tap); }
  .segmented { padding: 2px; }
  .segmented-item { min-height: var(--tap); }
  .daterange-label, .chip { min-height: var(--tap); }
  .timer-pill { min-height: var(--tap); }
  .menu-item { min-height: var(--tap); }
  .nav-link { min-height: var(--tap); }
  .ws-switch select { min-height: var(--tap); }
  .check, .toggle { min-height: var(--tap); }
}

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-sm); cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.chip.is-active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); font-weight: 600; }

/* ------------------------------------------------------------------ Formulare */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1 1 0; }
.field-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
.field-hint { font-size: var(--fs-xs); color: var(--text-faint); }
.field-error { font-size: var(--fs-xs); color: var(--danger); font-weight: 600; }
.has-error .input { border-color: var(--danger); }
.field-inline { flex-direction: row; align-items: center; gap: 10px; }
.form-row { display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 600px) { .form-row { flex-direction: row; } }
.form { display: flex; flex-direction: column; gap: 14px; }
.input {
  width: 100%; min-height: 42px; padding: 9px 11px;
  font: inherit; font-size: 16px; /* 16px verhindert Zoom auf iOS */
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
}
@media (min-width: 900px) { .input { font-size: var(--fs); } }
.input:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.input:disabled { background: var(--surface-2); color: var(--text-muted); }
textarea.input { min-height: 80px; resize: vertical; line-height: 1.4; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.input-code { font-family: var(--font-mono); font-size: 22px; letter-spacing: .3em; text-align: center; }
.input-sm { min-height: 34px; padding: 5px 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: var(--fs); }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }

.search-input { position: relative; }
.search-input .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }
.search-input .input { padding-left: 34px; }

.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-track { width: 40px; height: 24px; border-radius: 999px; background: var(--border-strong); position: relative; flex: none; transition: background .15s; }
.toggle-thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.toggle input:checked + .toggle-track { background: var(--brand); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--brand); outline-offset: 2px; }
.toggle-text { display: flex; flex-direction: column; }
.toggle-text small { color: var(--text-muted); font-size: var(--fs-xs); }
.toggle.is-disabled { opacity: .55; cursor: not-allowed; }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); gap: 2px; max-width: 100%; overflow-x: auto; }
.segmented-item { border: 0; background: transparent; padding: 6px 12px; border-radius: 5px; font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.segmented-item.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Projekt-Auswahl */
.picker {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 42px; padding: 7px 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
  font: inherit; color: var(--text); text-align: left; cursor: pointer;
}
.picker:hover { border-color: var(--brand); }
.picker.is-empty { color: var(--text-muted); }
.picker-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.2; }
.picker-main, .picker-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.picker-caret { color: var(--text-faint); }
.picker-compact { border-color: transparent; background: transparent; padding-left: 4px; }
.picker-compact:hover { background: var(--surface-2); border-color: transparent; }
.picker-list { margin-top: 10px; max-height: 60vh; overflow-y: auto; }
.picker-group-label { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); padding: 10px 8px 4px; }
.picker-option { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px; border: 0; border-radius: var(--radius-sm); background: none; font: inherit; color: var(--text); text-align: left; cursor: pointer; }
/* In der Liste lange Namen auf zwei Zeilen zeigen (z.B. «Bundesamt für … BLV» – sonst fehlt das unterscheidende Ende) */
.picker-option .picker-main { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.picker-option:hover { background: var(--surface-2); }
.picker-option.is-selected { background: var(--brand-soft); font-weight: 600; }
.picker-option.is-active { background: var(--surface-3); box-shadow: inset 3px 0 0 var(--brand); }
.picker-option.is-selected.is-active { background: var(--brand-soft); }
.dot { display: inline-block; border-radius: 50%; flex: none; filter: var(--dot-filter, none); }
.dot-empty { width: 10px; height: 10px; border: 2px dashed var(--border-strong); }

/* Zeitraum */
.daterange { display: inline-flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; max-width: 100%; }
.daterange-label { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; font: inherit; color: var(--text); padding: 6px 8px; cursor: pointer; border-radius: 5px; min-width: 0; }
.daterange-label:hover { background: var(--surface-2); }
.daterange-label > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preset-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

/* ------------------------------------------------------------------ Badges, Avatar, Alerts */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; line-height: 1.5; }
.badge-neutral { background: var(--surface-3); color: var(--text-muted); }
.badge-brand { background: var(--brand-soft); color: var(--brand-strong); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); font-size: var(--fs-sm); }
.alert .icon { margin-top: 1px; }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-success { background: var(--success-soft); color: var(--success); }

/* ------------------------------------------------------------------ Modal / Sheet */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(10, 20, 26, .45);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out;
}
.modal {
  width: 100%; max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-lg);
  padding-bottom: env(safe-area-inset-bottom); animation: slideup .2s ease-out;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 10px 6px 18px; }
.modal-title { font-size: var(--fs-lg); font-weight: 650; min-width: 0; }
.modal-body { padding: 6px 18px 18px; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-foot .btn-left { margin-right: auto; }
.dialog-message { font-size: var(--fs); margin: 0; }
@media (min-width: 720px) {
  .modal-backdrop { align-items: center; padding: 24px max(24px, env(safe-area-inset-right)) 24px max(24px, env(safe-area-inset-left)); }
  .modal { border-radius: var(--radius-lg); max-height: 88vh; padding-bottom: 0; animation: pop .15s ease-out; }
  .modal-sm { max-width: 440px; }
  .modal-md { max-width: 600px; }
  .modal-lg { max-width: 860px; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideup { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: scale(.97); opacity: .6; } to { transform: none; opacity: 1; } }

/* Menü */
.menu { position: relative; display: inline-flex; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 60; min-width: 200px; max-width: min(320px, calc(100vw - 16px)); padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.menu-left { right: auto; left: 0; }
.menu-up { top: auto; bottom: calc(100% + 4px); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: var(--radius-sm); font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--surface-2); }
.menu-item:focus-visible { outline-offset: -2px; }
/* Handy: Aktionen als Bottom-Sheet (Modal) mit grossen Zeilen */
.menu-sheet { position: static; min-width: 0; max-width: none; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: none; }
/* Titel des Sheets (z.B. «Aktionen für <langer Name>») höchstens zwei Zeilen */
.menu-sheet-modal .modal-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.menu-sheet .menu-item { min-height: 52px; padding: 12px 10px; gap: 14px; font-size: var(--fs-lg); }
.menu-sheet .menu-item .icon { color: var(--text-muted); }
.menu-sheet .menu-item.is-danger .icon { color: var(--danger); }
.menu-sheet-modal .modal-body { padding-bottom: 12px; }
.menu-item:disabled { opacity: .5; cursor: not-allowed; }
.menu-item.is-danger { color: var(--danger); }

/* Toasts */
.toasts { position: fixed; z-index: 200; left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 520px; padding: 11px 14px; border-radius: var(--radius); background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; animation: slideup .2s ease-out; }
.toast-action {
  margin-left: 6px; padding: 6px 10px; min-height: 36px; border-radius: var(--radius-sm); border: 1px solid currentColor;
  background: transparent; color: inherit; font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.toast-error { background: var(--danger); color: var(--danger-contrast); }
.toast-success { background: var(--success); color: var(--success-contrast); }
@media (min-width: 900px) { .toasts { left: auto; right: 24px; bottom: 24px; align-items: flex-end; } }
/* Handy mit offenem Dialog (Bottom-Sheet, Aktionen unten): Meldungen oben, damit sie keine Schaltfläche verdecken */
@media (max-width: 899px) { body:has(.modal-backdrop) .toasts { top: calc(12px + env(safe-area-inset-top)); bottom: auto; } }

/* Laden & Leer */
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--brand); animation: spin .8s linear infinite; display: inline-block; flex: none; }
.spinner-sm { width: 16px; height: 16px; border-width: 2px; border-color: rgba(128,128,128,.35); border-color: color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px 16px; color: var(--text-muted); }
.empty { text-align: center; padding: 40px 16px; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty h3 { color: var(--text); font-size: var(--fs-lg); }
.empty p { max-width: 420px; margin: 0; }
.empty-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); margin-bottom: 4px; }

/* ------------------------------------------------------------------ Login / Einrichtung */
.auth-page { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px 14px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 24px 20px; display: flex; flex-direction: column; gap: 14px; }
.auth-card-wide { max-width: 560px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.auth-brand h1 { font-size: var(--fs-xl); }
.auth-brand p { margin: 0; }
.auth-hint { font-size: var(--fs-sm); text-align: center; margin: 0; }
@media (min-width: 600px) { .auth-card { padding: 32px 28px; } }

/* ------------------------------------------------------------------ Druck */
@media print {
  .sidebar, .topbar, .tabbar, .toasts, .page-actions { display: none !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { border: 0; box-shadow: none; }
}

/* Sehr schmale Handys: Kalender-Symbol im Zeitraum weglassen, damit «Dieser Monat» ganz sichtbar bleibt */
@media (max-width: 380px) { .daterange-label > .icon { display: none; } }
@media (pointer: coarse), (max-width: 899px) { .toast-action { min-height: var(--tap); } }
