/* HubTime Zeiterfassung – mobile-first, große Bedienelemente.
   Gestaltungsidee: ruhige, kühle Oberfläche; einziges lautes Element ist die
   Stempeluhr (dunkles Zifferblatt mit Statusfarbe). Keine Webfonts – die App
   muss offline sofort starten. */

:root {
  --ink: #16242e;
  --ink-soft: #2c3e4a;
  --bg: #edf1f0;
  --surface: #ffffff;
  --line: #cfd8d6;
  --muted: #5b6b73;
  --come: #17804f;
  --pause: #b87900;
  --go: #b3362a;
  --link: #1f5f8b;
  --warn-bg: #fff4d6;
  --err-bg: #fde8e6;
  --ok-bg: #e3f4ea;
  --radius-s: 6px;
  --radius-m: 12px;
  --tap: 52px;
  --nav-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e6eef0;
    --ink-soft: #c5d2d6;
    --bg: #0f171c;
    --surface: #182329;
    --line: #2b3a42;
    --muted: #93a4ab;
    --come: #2fbf7a;
    --pause: #f0b429;
    --go: #ef6a5b;
    --link: #7cc0ec;
    --warn-bg: #3a3014;
    --err-bg: #3d1d1a;
    --ok-bg: #173325;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--link); }
h1 { font-size: 1.5rem; line-height: 1.2; margin: 0.4rem 0 0.8rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 0.5rem; }
h3 { font-size: 0.95rem; margin: 1rem 0 0.3rem; color: var(--muted); font-weight: 600; }
small, .small { font-size: 0.85rem; }
.muted { color: var(--muted); }
.boot { padding: 2rem; color: var(--muted); }

#view {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom));
  outline: none;
}

/* ---------- Kopf ---------- */
header.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--ink); color: #fff;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) header.top { background: #070c0f; } }
.brand { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.brand span { font-weight: 400; opacity: 0.75; }
.sync {
  flex: 1; min-width: 0; text-align: left;
  border: 0; background: transparent; color: #fff; font: inherit; font-size: 0.8rem;
  padding: 6px 8px; border-radius: var(--radius-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sync::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #8a9aa2; vertical-align: 1px; }
.sync.ok::before { background: #2fbf7a; }
.sync.wait::before { background: #f0b429; }
.sync.err { background: #b3362a; }
.sync.err::before { background: #fff; }
.menu { position: relative; }
.menu summary {
  list-style: none; cursor: pointer; min-width: 40px; height: 40px; border-radius: 20px; padding: 0 10px;
  display: grid; place-items: center; background: rgba(255,255,255,0.14); font-weight: 600; font-size: 0.85rem;
}
.menu summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: 48px; min-width: 200px; padding: 12px 16px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-m);
  box-shadow: 0 8px 24px rgba(0,0,0,0.18); display: grid; gap: 10px;
}
.menu-pop p { margin: 0; }
.linklike { background: none; border: 0; padding: 0; color: var(--link); font: inherit; text-align: left; cursor: pointer; }

/* ---------- Navigation unten ---------- */
nav.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.bottom a {
  flex: 1; min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; color: var(--muted); font-size: 0.72rem; gap: 2px;
}
nav.bottom .ico { font-size: 1.25rem; line-height: 1; }
nav.bottom a.active { color: var(--ink); font-weight: 600; box-shadow: inset 0 3px 0 var(--come); }

/* ---------- Buttons & Formulare ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; margin: 4px 4px 4px 0;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.danger { color: var(--go); border-color: currentColor; background: transparent; }
.btn.big { min-height: var(--tap); width: 100%; font-size: 1.05rem; }
.btn.small { min-height: 36px; padding: 0 10px; font-size: 0.85rem; }
.btn.icon { min-width: 44px; padding: 0; font-size: 1.4rem; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, summary:focus-visible, .sync:focus-visible {
  outline: 3px solid var(--link); outline-offset: 2px;
}
.fab { position: fixed; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 5; box-shadow: 0 6px 18px rgba(0,0,0,0.25); min-height: var(--tap); }

label { display: grid; gap: 4px; font-size: 0.9rem; color: var(--muted); font-weight: 500; }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 1.05rem;
}
textarea { min-height: 72px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 22px; min-height: 22px; height: 22px; accent-color: var(--ink); }
label.check { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row input { flex: 1; min-width: 160px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: flex; gap: 8px; }
.seg label {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
  border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font-size: 1rem;
}
.seg label:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-weight: 600; }
form[inert] { opacity: 0.55; }
.form-error { color: var(--go); margin: 0; font-weight: 500; }
.info p { margin: 0 0 4px; }
.info .warn { color: var(--pause); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px; margin: 12px 0; }
details.card > summary { cursor: pointer; min-height: 32px; }
details.card[open] > summary { margin-bottom: 12px; }

.alert { display: block; padding: 12px 14px; border-radius: var(--radius-s); background: var(--warn-bg); margin: 8px 0; color: var(--ink); text-decoration: none; }
.alert.error { background: var(--err-bg); }
.badge { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 2px 7px; border-radius: 10px; margin-left: 4px; vertical-align: 1px; background: var(--line); color: var(--ink); white-space: nowrap; }
.badge.wait { background: var(--warn-bg); color: var(--pause); }
.badge.err { background: var(--err-bg); color: var(--go); }
.badge.ok { background: var(--ok-bg); color: var(--come); }
.badge.late { background: transparent; border: 1px solid var(--pause); color: var(--pause); }

/* ---------- Anmeldung ---------- */
.auth { max-width: 420px; margin: 8vh auto 0; }
.auth-title { font-size: 2rem; margin-bottom: 0; }

/* ---------- Müll ---------- */
.waste-banner {
  display: grid; gap: 2px; margin: 4px 0 12px; padding: 14px 16px 14px 20px;
  background: var(--bin, var(--surface)); color: var(--bin-ink, var(--ink));
  border-radius: var(--radius-m); text-decoration: none; position: relative;
}
.waste-banner strong { font-size: 1.2rem; line-height: 1.25; }
.waste-banner.soft { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.waste-kicker { font-size: 0.85rem; opacity: 0.85; }
a.waste-kicker { color: inherit; text-decoration: none; }
.putouts { display: grid; gap: 6px; margin-top: 8px; }
.putout.done { font-weight: 600; }
.putout.done .linklike { color: inherit; text-decoration: underline; margin-left: 6px; font-weight: 400; }
.putout-btn { margin: 0; min-height: 48px; background: rgba(255,255,255,0.92); color: #16242e; border-color: transparent; }
.waste-banner.soft .putout-btn { background: var(--ink); color: var(--bg); }
.bin { display: inline-block; padding: 2px 8px; border-radius: 10px; background: var(--bin); color: var(--bin-ink); font-size: 0.8rem; border: 1px solid rgba(255,255,255,0.5); }
.waste-list { list-style: none; padding: 0; margin: 0; }
.waste-list li { display: grid; grid-template-columns: 14px 88px 1fr auto; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.swatch { width: 14px; height: 28px; border-radius: 3px; background: var(--bin); }
.waste-date { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Stempeluhr (das eine laute Element) ---------- */
.today-line { margin: 4px 0 8px; color: var(--muted); font-weight: 500; }
.clock {
  --state: #8a9aa2;
  background: #16242e; color: #fff; border-radius: 18px; padding: 24px 18px 18px;
  box-shadow: inset 0 7px 0 var(--state);
}
.clock.is-running { --state: #2fbf7a; }
.clock.is-paused { --state: #f0b429; }
.clock-face {
  font-family: ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  font-variant-numeric: tabular-nums; font-weight: 700;
  font-size: clamp(3.4rem, 17vw, 5.2rem); line-height: 1; letter-spacing: -0.02em; text-align: center; padding: 8px 0 4px;
}
.clock-face.idle { opacity: 0.55; font-weight: 500; }
.clock.is-paused .clock-face { color: #f0b429; }
.clock-meta { text-align: center; margin: 6px 0 14px; color: #c5d2d6; }
.clock-activity { color: #c5d2d6; margin: 10px 0 14px; }
.clock-activity select { background: #22343f; color: #fff; border-color: #3b4f5a; }
.clock-actions { display: flex; gap: 10px; }
.stamp { flex: 1; min-height: 72px; font-size: 1.3rem; border: 0; margin: 0; border-radius: 12px; color: #fff; }
.stamp.come { background: #17804f; }
.stamp.pause { background: #b87900; }
.stamp.go { background: #b3362a; }
.stamp:active { transform: translateY(1px); }

/* ---------- Listen ---------- */
.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.section-head .sum { font-variant-numeric: tabular-nums; font-weight: 600; }
.entry-list { list-style: none; margin: 0 0 8px; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.entry-list li + li { border-top: 1px solid var(--line); }
.entry-list a { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: baseline; padding: 12px 14px; color: var(--ink); text-decoration: none; min-height: var(--tap); }
.entry-list .t { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; min-width: 7.2em; }
.entry-list .a small { display: block; color: var(--muted); }
.entry-list .d { font-variant-numeric: tabular-nums; text-align: right; }
.entry-list .badge { grid-column: 2 / -1; justify-self: start; margin: 0; }
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.month-nav h1 { text-align: center; margin: 0.4rem 0; }
.month-nav h1 small { font-weight: 400; color: var(--muted); }
.totals { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; margin: 4px 0 12px; }
.big { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.vacation { margin: 4px 0 8px; }
.abs-list, .user-list, .plain { list-style: none; padding: 0; margin: 0; }
.abs-list li, .user-list li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.abs-list li.st-abgelehnt, .abs-list li.st-storniert, .user-list li.inactive, .act-list li.inactive { opacity: 0.55; }
.abs-list li.st-beantragt { border-left: 4px solid var(--pause); padding-left: 10px; }
.plain li { padding: 6px 0; }
.act-list li { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.user-list summary { cursor: pointer; padding: 4px 0; }
.user-form { margin: 12px 0; }
.invite { background: var(--ok-bg); padding: 12px; border-radius: var(--radius-s); margin: 8px 0; }
.invite p { margin: 0 0 6px; word-break: break-all; }
.code { font-size: 1.3rem; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }

/* ---------- Letzter Besuch ---------- */
.visits { margin-top: 16px; }
.visit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.visit { background: var(--surface); border: 1px solid var(--line); border-top: 5px solid var(--line); border-radius: var(--radius-m); padding: 10px 12px; display: grid; gap: 3px; font-size: 0.92rem; }
.visit-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.amp-label { font-size: 0.72rem; font-weight: 700; white-space: nowrap; }
.visit.amp-gruen { border-top-color: var(--come); }
.visit.amp-gruen .amp-label { color: var(--come); }
.visit.amp-gelb { border-top-color: #e0a800; background: var(--warn-bg); }
.visit.amp-gelb .amp-label { color: var(--pause); }
.visit.amp-rot { border-top-color: var(--go); background: var(--err-bg); }
.visit.amp-rot .amp-label { color: var(--go); }
.visit-now { font-weight: 600; color: var(--come); }
.visit-hint { font-size: 0.8rem; font-weight: 600; color: var(--pause); }

/* ---------- Geräte ---------- */
.appliances { margin-top: 8px; }
.appl { background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px; margin: 8px 0; }
.appl.phase-laeuft { border-left-color: var(--come); }
.appl.phase-fertig { border-left-color: var(--pause); background: var(--warn-bg); }
.appl-head { display: flex; align-items: center; gap: 10px; }
.appl-icon { font-size: 1.5rem; line-height: 1; }
.appl-state { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.phase-fertig .appl-state { color: var(--pause); }
.appl-detail { margin: 6px 0 0; color: var(--muted); }
.phase-fertig .appl-detail { color: var(--ink); }
.watts { white-space: nowrap; font-variant-numeric: tabular-nums; }
.appl-actions { display: flex; flex-wrap: wrap; gap: 0 4px; margin-top: 6px; }
.appl-start { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
.appl-start .row input { min-width: 100px; }

/* ---------- Verdienst ---------- */
.earn .earn-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.earn .earn-row strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.earn p { margin: 6px 0 0; }
.meter { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; margin-top: 10px; }
.meter span { display: block; height: 100%; background: var(--come); }
.earn.over .meter span { background: var(--go); }

/* ---------- Kalender ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-head { text-align: center; font-size: 0.75rem; color: var(--muted); padding: 4px 0; }
.cal-cell { min-height: 64px; background: var(--surface); border-radius: 4px; padding: 3px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-cell.empty { background: transparent; }
.cal-cell.we { background: transparent; border: 1px solid var(--line); }
.cal-cell.hol { background: var(--warn-bg); }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--ink); }
.cal-day { font-size: 0.8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-hol { font-size: 0.6rem; line-height: 1.1; color: var(--muted); }
.chip { display: inline-block; font-size: 0.7rem; font-weight: 700; padding: 1px 5px; border-radius: 4px; color: #fff; background: #1f5f8b; }
.chip.k-urlaub { background: #1f5f8b; }
.chip.k-abwesend { background: #6b7280; }
.chip.k-krank { background: #b3362a; }
.chip.k-beantragt { background: transparent; color: var(--ink); border: 1px dashed var(--muted); }
.legend { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }

/* ---------- Verwaltung ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 0 -16px 8px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 12px 10px; white-space: nowrap; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.tabs a.active { color: var(--ink); box-shadow: inset 0 -3px 0 var(--ink); }
.table-wrap { overflow-x: auto; margin: 8px 0 12px; }
table.grid { border-collapse: collapse; width: 100%; font-size: 0.9rem; background: var(--surface); }
table.grid th, table.grid td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.grid th { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
table.grid .r { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tr.deleted td { text-decoration: line-through; opacity: 0.55; }
.nowrap { white-space: nowrap; }
.audit ol { padding-left: 1.2rem; }
.audit li { margin-bottom: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 50;
  max-width: 560px; margin: 0 auto; padding: 14px 16px; border-radius: var(--radius-m);
  background: var(--ink); color: var(--bg); font-weight: 500;
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: none; }
.toast.warn { background: var(--pause); color: #fff; }
.toast.error { background: var(--go); color: #fff; }

@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media (min-width: 720px) { .row2 { gap: 16px; } }
