/* PV5 Journal – lokale Styles, keine externen Ressourcen.
   Farbwelt orientiert sich an der aktuellen Kia-App (Navy-Flächen, weiße Schrift,
   grüner Akku-Balken). Keine Marken- oder Fahrzeugbilder. */

:root {
  color-scheme: dark;
  --bg: #0B1620;
  --surface: #1C252D;
  --elev: #2A333B;
  --elev-2: #353F48;
  --text: #FFFFFF;
  --text-2: #C5CAD0;
  --muted: #9AA4AD;
  --line: rgba(197, 202, 208, 0.14);
  --line-strong: rgba(197, 202, 208, 0.28);
  --green: #8CC63F;
  --green-text: #A6D867;
  --track: #58636D;
  --ok: #A6D867;
  --ok-bg: rgba(140, 198, 63, 0.14);
  --warn: #F4C152;
  --warn-bg: rgba(244, 193, 82, 0.13);
  --warn-line: #F4C152;
  --danger: #FF8A7A;
  --danger-bg: rgba(255, 138, 122, 0.13);
  --info: #8DC3F5;
  --info-bg: rgba(141, 195, 245, 0.12);
  --focus: #FFFFFF;
  --btn-primary-bg: #FFFFFF;
  --btn-primary-fg: #0B1620;
  --btn-secondary-bg: #2A333B;
  --btn-secondary-fg: #FFFFFF;
  --btn-final-bg: #F4C152;
  --btn-final-fg: #0B1620;
  --backdrop: rgba(3, 8, 12, 0.84);
  --radius: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --nav-w: 256px;
  --tap: 44px;
  --font: "Aptos", "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Roboto", "Ubuntu", "Noto Sans", "Cantarell", system-ui, "Helvetica Neue", Arial, sans-serif;
  --font-num: "Bahnschrift", "Aptos", "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, "Roboto", "Ubuntu", "Noto Sans", system-ui, sans-serif;
  --font-mono: "Cascadia Mono", "Consolas", "SFMono-Regular", "Menlo", "DejaVu Sans Mono", monospace;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #EDF0F3;
  --surface: #FFFFFF;
  --elev: #F2F4F6;
  --elev-2: #E3E7EB;
  --text: #0B1620;
  --text-2: #36424D;
  --muted: #56626D;
  --line: rgba(11, 22, 32, 0.12);
  --line-strong: rgba(11, 22, 32, 0.26);
  --green: #6FAE2A;
  --green-text: #3D6B10;
  --track: #C6CDD3;
  --ok: #3D6B10;
  --ok-bg: rgba(111, 174, 42, 0.14);
  --warn: #7A4F00;
  --warn-bg: #FFF2D3;
  --warn-line: #E09A00;
  --danger: #A8261B;
  --danger-bg: #FCE9E6;
  --info: #1C578F;
  --info-bg: #E5F0FB;
  --focus: #0B1620;
  --btn-primary-bg: #0B1620;
  --btn-primary-fg: #FFFFFF;
  --btn-secondary-bg: #E3E7EB;
  --btn-secondary-fg: #0B1620;
  --btn-final-bg: #7A4F00;
  --btn-final-fg: #FFFFFF;
  --backdrop: rgba(11, 22, 32, 0.45);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm { width: 18px; height: 18px; }

a { color: inherit; }
a:not(.btn):not(.nav-link):not(.trip-card):not(.wordmark) { text-decoration-thickness: 1px; text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }

.muted { color: var(--text-2); }
.subtle { color: var(--muted); }
.small { font-size: 0.875rem; }
.xsmall { font-size: 0.78rem; }
.mono { font-family: var(--font-mono); font-size: 0.85em; word-break: break-all; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.stack { display: grid; gap: 12px; }
.stack-lg { display: grid; gap: 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  z-index: 100;
  padding: 12px 16px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.skip-link:focus { top: 12px; }

.noscript { padding: 24px; text-align: center; }

/* ---------- Wortmarke ---------- */
.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.28em;
  text-decoration: none;
  font-family: var(--font-num);
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  line-height: 1;
  color: var(--text);
  min-height: var(--tap);
  align-items: center;
}
.wm-pv5 { font-weight: 700; letter-spacing: 0.04em; }
.wm-slash { font-weight: 200; color: var(--muted); transform: skewX(-8deg); }
.wm-journal { font-weight: 300; letter-spacing: 0.22em; }
.wordmark-lg { font-size: 1.7rem; }
.wm-trim {
  width: 54px; height: 3px; margin-top: 2px;
  background: var(--text-2);
  clip-path: polygon(3px 0, 100% 0, calc(100% - 3px) 100%, 0 100%);
  opacity: 0.55;
}
.wm-sub { margin-top: 8px; color: var(--muted); font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--btn-primary-bg); color: var(--btn-primary-fg); }
.btn-primary:hover:not(:disabled) { opacity: 0.9; }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-fg); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { border-color: var(--line-strong); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--elev); }
.btn-final { background: transparent; color: var(--warn); border: 1.5px solid var(--warn-line); }
.btn-final:hover:not(:disabled) { background: var(--warn-bg); }
.btn-final-solid { background: var(--btn-final-bg); color: var(--btn-final-fg); }
.btn-final-solid:disabled { background: var(--elev-2); color: var(--muted); opacity: 1; }
.btn-danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); }
.btn-block { width: 100%; }
.btn-small { min-height: var(--tap); padding: 8px 14px; font-size: 0.875rem; }
.btn .icon { width: 18px; height: 18px; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.link-btn {
  background: none; border: 0; padding: 0;
  font: inherit; color: inherit;
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer; min-height: var(--tap);
}

/* ---------- Boot & Login ---------- */
.boot {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-content: center; justify-items: center;
  gap: 18px; padding: 24px; text-align: center;
}
.boot-text { color: var(--text-2); max-width: 36ch; }

.login {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center;
  padding: 24px 16px calc(24px + var(--safe-bottom));
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border-radius: 28px;
  padding: 32px 24px;
  display: grid; gap: 18px;
}
.login-title { font-size: 1.4rem; margin-top: 6px; }
.fineprint { font-size: 0.78rem; color: var(--muted); line-height: 1.45; }

/* ---------- App-Layout ---------- */
.app { min-height: 100vh; min-height: 100dvh; }

.sidebar { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 14px 6px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .wordmark { font-size: 0.95rem; gap: 0.2em; }
.topbar .wm-journal { letter-spacing: 0.14em; }
.topbar .status-pill { padding: 4px 10px; gap: 6px; }
.topbar-status { flex: 1 1 auto; min-width: 0; display: flex; justify-content: flex-end; }

.main {
  outline: none;
  padding: 18px 16px calc(96px + var(--safe-bottom));
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.18);
  padding-bottom: var(--safe-bottom);
}
.bottom-nav ul {
  list-style: none; margin: 0; padding: 4px 4px 2px;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
}
.bottom-nav .nav-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; min-height: 58px; padding: 6px 2px;
  text-decoration: none; color: var(--muted);
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0;
  border-radius: 14px; min-width: 0;
}
.bottom-nav .nav-link span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottom-nav .nav-link[aria-current="page"] { color: var(--text); }
.bottom-nav .nav-link[aria-current="page"] .icon { stroke-width: 2.2; }
.bottom-nav .nav-link { position: relative; }
.bottom-nav .nav-link[aria-current="page"]::after {
  content: ""; position: absolute; bottom: 4px; left: 50%; width: 18px; height: 3px; margin-left: -9px; border-radius: 2px; background: var(--text);
}

@media (min-width: 900px) {
  .app {
    display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr);
    background: linear-gradient(to right, var(--surface) 0, var(--surface) var(--nav-w), var(--bg) var(--nav-w));
  }
  .topbar, .bottom-nav { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 22px;
    position: sticky; top: 0; height: 100vh; height: 100dvh;
    overflow-y: auto;
    padding: 26px 18px 20px;
    background: var(--surface);
    border-right: 1px solid var(--line);
  }
  .sidebar .brand { padding: 0 8px; }
  .side-nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
  .side-nav .nav-link {
    display: flex; align-items: center; gap: 12px;
    min-height: 48px; padding: 10px 14px;
    border-radius: 14px;
    color: var(--text-2); text-decoration: none; font-weight: 600;
  }
  .side-nav .nav-link:hover { background: var(--elev); color: var(--text); }
  .side-nav .nav-link[aria-current="page"] { background: var(--elev); color: var(--text); }
  .side-nav .nav-link { position: relative; }
  .side-nav .nav-link[aria-current="page"]::before {
    content: ""; position: absolute; left: 4px; top: 50%; width: 3px; height: 20px; margin-top: -10px; border-radius: 2px; background: var(--text);
  }
  .sidebar-status { padding: 0 6px; }
  .sidebar-foot { margin-top: auto; display: grid; gap: 8px; }
  .sidebar-foot .btn { min-height: var(--tap); font-size: 0.875rem; padding: 8px 14px; }
  .main { padding: 32px 36px 48px; }
}

.actor { font-size: 0.85rem; color: var(--muted); }

/* ---------- Status-Pille ---------- */
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 32px; padding: 4px 12px;
  border-radius: 999px;
  background: var(--elev);
  color: var(--text-2);
  font-size: 0.8rem; font-weight: 600;
  max-width: 100%;
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status-pill.ok .dot { background: var(--green); }
.status-pill.warn .dot { background: var(--warn); }
.status-pill.danger .dot { background: var(--danger); }
.status-pill.info .dot { background: var(--info); }
.status-pill span.txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-block { display: grid; gap: 6px; font-size: 0.82rem; color: var(--muted); }
.status-block .status-pill { justify-self: start; }

/* ---------- Seitenkopf ---------- */
.page-head { display: grid; gap: 6px; margin-bottom: 20px; }
.page-head .row-between { align-items: flex-end; }
.page-title:focus { outline: none; }
details.raw-like > summary { list-style: none; width: fit-content; }
details.raw-like > summary::-webkit-details-marker { display: none; }
.page-sub { color: var(--text-2); max-width: 70ch; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--tap); color: var(--text-2); text-decoration: none; font-weight: 600;
}
.back-link:hover { color: var(--text); }

/* ---------- Karten ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { display: flex; align-items: center; gap: 8px; }
.card-note { margin-top: 12px; font-size: 0.8rem; color: var(--muted); }
.card-elev { background: var(--elev); }

.layout { display: grid; gap: 16px; }
.layout-dash { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1100px) {
  .layout-dash { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
  .layout-dash .span-2 { grid-column: 1 / -1; }
}
.cards-2 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.masonry { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .masonry { display: block; column-count: 2; column-gap: 16px; }
  .masonry > * { break-inside: avoid; margin-bottom: 16px; display: block; }
}
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.section-head h2 { font-size: 1.05rem; color: var(--text-2); font-weight: 600; }
@media (min-width: 760px) { .cards-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Hero (Akku) ---------- */
.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 85% -10%, color-mix(in srgb, var(--elev) 70%, transparent) 0%, transparent 60%),
    var(--surface);
  border-radius: 26px;
  padding: 24px 22px 22px;
  display: grid; gap: 18px;
}
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hero-stamp { font-size: 0.8rem; color: var(--muted); white-space: nowrap; padding-top: 4px; }
.hero-name { font-size: 1.25rem; font-weight: 600; }
.hero-owner { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.hero-soc { display: grid; gap: 14px; }
.soc-value {
  font-family: var(--font-num);
  font-weight: 300;
  font-size: clamp(4rem, 3rem + 6vw, 6.4rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 6px;
}
.soc-value .unit { font-size: 0.36em; font-weight: 400; letter-spacing: 0; color: var(--text-2); }
.soc-value.is-missing { font-size: 2.4rem; color: var(--muted); }
.soc-label { font-size: 0.82rem; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.soc-bar {
  position: relative;
  width: 100%;
  height: 8px;
  background: var(--track);
  clip-path: polygon(5px 0, 100% 0, calc(100% - 5px) 100%, 0 100%);
}
.soc-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--green); transition: width 0.6s ease; }
.soc-secondary {
  display: grid; grid-template-columns: repeat(2, minmax(0, max-content)); gap: 4px 36px;
  margin: 2px 0 0;
}
.soc-secondary dt { font-size: 0.74rem; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.soc-secondary dd { margin: 2px 0 0; font-family: var(--font-num); font-size: 1.35rem; font-weight: 400; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hero-chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; list-style: none; margin: 0; padding: 0; }
@media (min-width: 600px) { .hero-chips { display: flex; flex-wrap: wrap; } }
.hero-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.82rem; color: var(--muted); }

/* Zustands-Chips: bewusst flach und eckiger als Buttons – reine Anzeige. */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 30px; padding: 4px 9px;
  border-radius: 8px;
  background: var(--elev);
  color: var(--text-2);
  font-size: 0.8rem; font-weight: 600;
}
.chip .icon { width: 14px; height: 14px; }
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-2); flex: none; }
.chip.chip-warn { color: var(--warn); }
.chip.chip-warn .chip-dot { background: var(--warn); }
.chip.chip-muted { color: var(--muted); }

/* ---------- Kacheln ---------- */
.tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.tile {
  background: var(--elev);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: grid; gap: 4px; align-content: start;
  min-width: 0;
}
.tile-label { font-size: 0.8rem; color: var(--text-2); font-weight: 600; }
.tile-value { font-size: 1.1rem; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile-value .unit { font-weight: 400; color: var(--text-2); font-size: 0.85em; }
.tile-raw { font-size: 0.76rem; color: var(--muted); overflow-wrap: anywhere; }
.tile-note { font-size: 0.76rem; color: var(--muted); }
.tile-path { font-size: 0.72rem; color: var(--muted); overflow-wrap: anywhere; }
.tile-path a { color: var(--muted); }
.tile.is-missing .tile-value { color: var(--muted); font-weight: 500; }
.tile.tone-warn { box-shadow: inset 3px 0 0 var(--warn-line); }
.tile.tone-danger { box-shadow: inset 3px 0 0 var(--danger); }
.tile.tone-unknown .tile-value { color: var(--text-2); }
body:not(.show-paths) .tile-path { display: none; }

/* ---------- Kennzahl-Reihe ---------- */
.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }
.stat { background: var(--elev); border-radius: var(--radius-md); padding: 14px 16px; display: grid; gap: 2px; grid-template-rows: 1fr auto; }
.stat-label { font-size: 0.78rem; color: var(--text-2); font-weight: 600; }
.stat-value { font-family: var(--font-num); font-size: 1.45rem; font-weight: 400; font-variant-numeric: tabular-nums; }
.stat.highlight { box-shadow: inset 0 0 0 1.5px var(--warn-line); background: var(--warn-bg); }

/* ---------- Badges & Hinweise ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700; line-height: 1.5;
  background: var(--elev-2); color: var(--text-2);
  white-space: nowrap;
}
.badge .icon { width: 14px; height: 14px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.cat-business { background: var(--elev-2); color: var(--text); }
.badge.cat-private { background: var(--elev-2); color: var(--text); }
.badge.cat-commute { background: var(--elev-2); color: var(--text); }
.badge.cat-unclassified { background: var(--warn-bg); color: var(--warn); }

.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--elev);
  color: var(--text);
  font-size: 0.92rem;
}
.notice .icon { margin-top: 1px; }
.notice > div { display: grid; gap: 4px; min-width: 0; }
.notice.warn { background: var(--warn-bg); }
.notice.warn .icon { color: var(--warn); }
.notice.danger { background: var(--danger-bg); }
.notice.danger .icon { color: var(--danger); }
.notice.ok { background: var(--ok-bg); }
.notice.ok .icon { color: var(--ok); }
.notice.info { background: var(--info-bg); }
.notice.info .icon { color: var(--info); }
.notice strong { font-weight: 700; }
.notice.info strong { font-weight: 600; }

.issue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.disclaimer {
  font-size: 0.8rem; color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 12px; margin-top: 4px;
}

/* ---------- Formulare ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .label, fieldset > legend {
  font-size: 0.85rem; font-weight: 600; color: var(--text-2);
}
.field .hint { font-size: 0.8rem; color: var(--muted); }
.field .hint.is-error { color: var(--danger); font-weight: 600; }
.input-row { display: flex; gap: 8px; }
.input-row > input { flex: 1 1 auto; min-width: 0; }

input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="month"], select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--elev);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
select { appearance: none; padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
input[readonly] { color: var(--text-2); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
input[type="month"]::-webkit-calendar-picker-indicator { filter: invert(1); opacity: 0.85; cursor: pointer; }
[data-theme="light"] input[type="month"]::-webkit-calendar-picker-indicator { filter: none; }
[data-theme="light"] .chip { background: var(--elev-2); }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset > .hint { margin-top: 8px; font-size: 0.8rem; color: var(--muted); }
fieldset > .hint.is-error { color: var(--danger); font-weight: 600; }
.choices { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); margin-top: 6px; }
.choice span { overflow-wrap: anywhere; hyphens: auto; }
.choice {
  display: flex; gap: 10px; align-items: center;
  min-height: 52px; padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--elev);
  border: 1.5px solid var(--line);
  cursor: pointer; font-weight: 600;
}
.choice:has(input:checked) { border-color: var(--text); background: var(--elev-2); }
.choice input { width: 20px; height: 20px; margin: 0; accent-color: var(--text); flex: none; }
.check {
  display: flex; gap: 12px; align-items: flex-start;
  min-height: var(--tap); padding: 10px 0; cursor: pointer;
}
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--text); flex: none; }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-actions .btn { flex: 1 1 200px; }
@media (min-width: 760px) { .form-actions .btn { flex: 0 0 auto; } }
.form-error { color: var(--danger); font-weight: 600; font-size: 0.9rem; }
.dirty-flag { font-size: 0.82rem; color: var(--warn); font-weight: 700; }
.dirty-flag.is-clean { color: var(--muted); font-weight: 500; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.toolbar .field { flex: 1 1 180px; }
.month-nav {
  display: grid; gap: 8px; flex: 1 1 100%;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas: "field field" "prev next";
}
.month-nav .mn-prev { grid-area: prev; }
.month-nav .mn-next { grid-area: next; }
.month-nav .mn-field { grid-area: field; min-width: 0; }
.month-nav input { min-width: 0; }
@media (min-width: 700px) {
  .month-nav { flex: 2 1 460px; grid-template-columns: auto minmax(150px, 1fr) auto; grid-template-areas: "prev field next"; align-items: end; }
}

/* ---------- Fahrtenliste ---------- */
.day-group { display: grid; gap: 10px; }
.day-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; font-size: 0.85rem; font-weight: 700; color: var(--text-2); margin: 10px 4px 0; }
.day-head .day-sum { font-weight: 600; color: var(--muted); }
.trip-card {
  display: grid; gap: 8px;
  padding: 16px 18px;
  background: var(--surface);
  border-radius: var(--radius-md);
  text-decoration: none; color: inherit;
  border: 1px solid transparent;
}
.trip-card:hover { border-color: var(--line-strong); }
.trip-line1 { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.trip-time { font-family: var(--font-num); font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.trip-km { font-family: var(--font-num); font-size: 1.15rem; font-variant-numeric: tabular-nums; font-weight: 500; }
.trip-route { color: var(--text-2); overflow-wrap: anywhere; }
.trip-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 0.82rem; color: var(--muted); }

/* ---------- Detail ---------- */
.kv { display: grid; grid-template-columns: minmax(110px, max-content) minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.kv dt { color: var(--text-2); font-size: 0.88rem; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (max-width: 559px) {
  .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .kv dt { font-size: 0.78rem; color: var(--muted); }
  .kv dd { margin-bottom: 10px; }
  .kv dd:last-child { margin-bottom: 0; }
}
.loc-block { display: grid; gap: 8px; padding: 14px 16px; border-radius: var(--radius-md); background: var(--elev); }
.loc-title { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.loc-name { font-size: 1.05rem; }
.lock-banner { display: flex; gap: 12px; align-items: center; }
.countdown { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

details.raw { border-radius: var(--radius-sm); background: var(--elev); }
details.raw > summary {
  cursor: pointer; list-style: none;
  min-height: var(--tap); padding: 12px 16px;
  font-weight: 600; font-size: 0.9rem; color: var(--text-2);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
details.raw > summary::-webkit-details-marker { display: none; }
details.raw > summary::after { content: "anzeigen ▾"; font-size: 0.78rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
details.raw[open] > summary::after { content: "ausblenden ▴"; }
details.raw-compact { background: transparent; border: 1px solid var(--line); margin-top: 4px; }
details.raw-compact > summary { min-height: var(--tap); padding: 10px 14px; font-size: 0.82rem; }
details.raw-compact > .raw-body { padding: 0 14px 12px; }
details.raw-compact .kv dd { font-size: 0.85rem; color: var(--text-2); }
details.raw > .raw-body { padding: 0 16px 14px; }
pre.json {
  margin: 0; padding: 12px; border-radius: 10px;
  background: var(--bg); color: var(--text-2);
  font-family: var(--font-mono); font-size: 0.78rem; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  max-height: 420px; overflow: auto;
}

/* ---------- Feld-Explorer ---------- */
.field-group { background: var(--surface); border-radius: var(--radius-md); overflow: hidden; }
.field-group > summary {
  list-style: none; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 52px; padding: 12px 18px;
  font-weight: 700;
}
.field-group > summary::-webkit-details-marker { display: none; }
.field-group > summary .count { font-weight: 600; color: var(--muted); font-size: 0.85rem; }
.field-group > summary::before {
  content: ""; width: 8px; height: 8px; flex: none;
  border-right: 2px solid var(--text-2); border-bottom: 2px solid var(--text-2);
  transform: rotate(-45deg); transition: transform 0.15s ease;
  margin-right: 4px;
}
.field-group[open] > summary::before { transform: rotate(45deg); }
.field-group > summary .grow { display: flex; align-items: center; gap: 8px; }
.field-rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.field-row {
  display: grid; gap: 2px 16px;
  grid-template-columns: minmax(0, 1fr);
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
}
.field-row:last-child { border-bottom: 0; }
.field-path { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-2); word-break: break-all; user-select: all; }
.field-value { font-family: var(--font-mono); font-size: 0.92rem; color: var(--text); word-break: break-word; }
.field-meta { font-size: 0.76rem; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
@media (min-width: 900px) {
  .field-row { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.4fr) minmax(0, 1.2fr); align-items: baseline; }
  .field-meta { justify-content: flex-end; }
}
mark { background: var(--warn-bg); color: inherit; border-radius: 3px; padding: 0 1px; box-shadow: 0 0 0 1px var(--warn-line); }

/* ---------- Listen (Orte, Tokens, Audit) ---------- */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.list-item { background: var(--elev); border-radius: var(--radius-md); padding: 14px 16px; display: grid; gap: 10px; }
.list-item .row-between { align-items: flex-start; }
.audit-item { background: var(--elev); border-radius: var(--radius-sm); }
.audit-item > summary {
  list-style: none; cursor: pointer;
  display: grid; gap: 2px; padding: 12px 16px; min-height: var(--tap);
}
.audit-item > summary::-webkit-details-marker { display: none; }
.audit-item .audit-line { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: baseline; }
.audit-item .audit-kind { font-weight: 700; }
.audit-body { padding: 0 16px 14px; display: grid; gap: 10px; }
.hash { font-family: var(--font-mono); font-size: 0.8rem; word-break: break-all; color: var(--text-2); user-select: all; }

/* ---------- Leere & Ladezustände ---------- */
.empty { text-align: center; padding: 36px 20px; display: grid; gap: 10px; justify-items: center; color: var(--text-2); }
.empty h2 { color: var(--text); }
.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 0%, var(--elev) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  min-height: 120px;
}
.skeleton.short { min-height: 64px; border-radius: var(--radius-md); }
.skeleton.tall { min-height: 260px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---------- Dialoge ---------- */
dialog {
  border: 0;
  padding: 0;
  max-width: 560px;
  width: calc(100% - 24px);
  max-height: calc(100dvh - 32px);
  border-radius: 26px;
  background: var(--surface);
  color: var(--text);
  overflow: auto;
}
dialog::backdrop { background: var(--backdrop); }
.dialog-inner { padding: 22px 20px 20px; display: grid; gap: 16px; }
.dialog-head { display: grid; gap: 6px; }
.dialog-head h2 { font-size: 1.25rem; }
.dialog-actions { display: flex; gap: 10px; flex-wrap: wrap-reverse; justify-content: flex-end; }
.dialog-actions .btn { flex: 1 1 180px; }
.sheet { padding: 22px 20px calc(20px + var(--safe-bottom)); }
.sheet .dialog-head { margin-bottom: 10px; }
.sheet .actor { margin-bottom: 14px; }
@media (max-width: 599px) {
  dialog { margin: auto 0 0; width: 100%; max-width: none; border-radius: 26px 26px 0 0; max-height: 92dvh; }
  .dialog-inner { padding-bottom: calc(20px + var(--safe-bottom)); }
}
.summary-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.summary-table th { text-align: left; font-weight: 600; color: var(--text-2); padding: 6px 12px 6px 0; vertical-align: top; width: 38%; }
.summary-table td { padding: 6px 0; overflow-wrap: anywhere; }
.summary-table tr + tr th, .summary-table tr + tr td { border-top: 1px solid var(--line); }
.token-box { display: grid; gap: 8px; }
.token-box input { font-family: var(--font-mono); font-size: 0.85rem; }

/* ---------- Toasts ---------- */
.toast-region {
  position: fixed; z-index: 60;
  left: 12px; right: 12px; bottom: calc(80px + var(--safe-bottom));
  display: grid; gap: 8px; justify-items: center;
  pointer-events: none;
}
@media (min-width: 900px) { .toast-region { left: auto; right: 24px; bottom: 24px; justify-items: end; width: 420px; } }
.toast {
  pointer-events: auto;
  display: flex; gap: 10px; align-items: flex-start;
  width: 100%; max-width: 480px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--elev-2);
  color: var(--text);
  font-size: 0.92rem;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
.toast.ok { border-left: 4px solid var(--green); }
.toast.warn { border-left: 4px solid var(--warn); }
.toast.danger { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }
.toast p { flex: 1 1 auto; }
.toast .btn { min-height: 36px; padding: 6px 12px; font-size: 0.82rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

@media print {
  .sidebar, .topbar, .bottom-nav, .toast-region, .btn, .toolbar { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .trip-card, .tile, .stat { background: #fff; border: 1px solid #ccc; }
}
