/* Kogga-EOB — app.css
 * Dunkles, werkzeughaftes Design. Eine Akzentfarbe (Bernstein), Rot nur für
 * Stop/Warnungen. Abstandsskala 4/8/12/16/24/32. Mobile-first (380 px),
 * am Desktop zentrierte Spalte mit max. 720 px. Touch-Ziele ≥ 48 px.
 */

/* ---------- Grundgerüst ---------- */

:root {
  --bg: #111418;
  --bg-karte: #191e24;
  --bg-erhoben: #222932;
  --rand: #2b333d;
  --text: #e9ecef;
  --text-dim: #98a3ae;
  --akzent: #f5a524;
  --akzent-text: #1a1204;
  --rot: #e5484d;
  --rot-text: #ffffff;
  --gruen: #4fb364;
  --fokus: #f5a524;
  --schrift: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, Menlo, monospace;
  --radius: 12px;
  --tabbar-hoehe: 64px;
}

* {
  box-sizing: border-box;
}

[x-cloak] {
  display: none !important;
}

html {
  background: var(--bg);
  color-scheme: dark;
}

body {
  margin: 0;
  font-family: var(--schrift);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

#inhalt {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-hoehe) + env(safe-area-inset-bottom, 0px) + 24px);
}

h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 8px 0 16px;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 12px;
}

h2 small {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 8px;
}

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Kopfleiste ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: rgba(17, 20, 24, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rand);
}

.marke {
  font-size: 16px;
  letter-spacing: 0.02em;
  color: var(--text-dim);
}

.marke b {
  color: var(--akzent);
  font-weight: 800;
}

.verbindung {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

.punkt {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.punkt.online { background: var(--gruen); box-shadow: 0 0 6px var(--gruen); }
.punkt.offline { background: var(--rot); box-shadow: 0 0 6px var(--rot); }

.sync-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: var(--akzent);
  color: var(--akzent-text);
  font-size: 12px;
  font-weight: 700;
}

/* ---------- Update-Banner ---------- */

.update-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-erhoben);
  border-bottom: 1px solid var(--rand);
  font-size: 14px;
}

/* ---------- Karten & Grundelemente ---------- */

.karte {
  background: var(--bg-karte);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.karte.gedimmt { opacity: 0.75; }
.karte.ok-karte { border-color: var(--gruen); }

.karten-reihe {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.karten-reihe .karte { margin-bottom: 16px; }

.hinweis {
  font-size: 13px;
  color: var(--text-dim);
  margin: 8px 0 0;
}

.fehler {
  color: var(--rot);
  font-size: 14px;
  margin: 8px 0;
}

.laedt, .leer {
  color: var(--text-dim);
  font-size: 14px;
  margin: 12px 0;
}

.summe {
  text-align: right;
  color: var(--text-dim);
  margin: 8px 4px 0;
}

.summe b { color: var(--text); }

/* ---------- Formulare ---------- */

label {
  display: block;
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  min-height: 48px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--rand);
  border-radius: 8px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--fokus);
  outline-offset: 0;
  border-color: var(--akzent);
}

input::placeholder, textarea::placeholder { color: #5d6873; }

textarea { resize: vertical; min-height: 96px; }

input.schmal { max-width: 160px; }

label.check {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  min-height: 48px;
  margin-bottom: 4px;
}

label.check input {
  width: 22px;
  height: 22px;
  min-height: 0;
  margin: 0;
  accent-color: var(--akzent);
  flex: none;
}

.feld-raster {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.zeit-zeile {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-erhoben);
  border: 1px solid var(--rand);
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 120ms ease, transform 80ms ease;
}

.btn:active { transform: scale(0.97); }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn.primaer {
  background: var(--akzent);
  border-color: var(--akzent);
  color: var(--akzent-text);
}

.btn.gefahr {
  background: transparent;
  border-color: var(--rot);
  color: var(--rot);
}

.btn.breit { width: 100%; }

.btn.klein {
  min-height: 40px;
  padding: 8px 12px;
  font-size: 14px;
}

.btn.rund {
  min-width: 48px;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
}

.btn.rund.klein {
  min-width: 40px;
  width: 40px;
  height: 40px;
  font-size: 15px;
}

.btn.gross {
  min-height: 56px;
  font-size: 17px;
  flex: 1;
}

.btn.ja { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); }
.btn.nein { background: transparent; border-color: var(--rot); color: var(--rot); }

.knopfzeile {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.btn.mikro { min-width: 56px; }

.btn.mikro.aktiv {
  background: var(--rot);
  border-color: var(--rot);
  color: var(--rot-text);
  animation: mikro-puls 1.4s ease-in-out infinite;
}

@keyframes mikro-puls {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.5); }
  50% { box-shadow: 0 0 0 10px rgba(229, 72, 77, 0); }
}

/* ---------- HEUTE ---------- */

.heute-datum {
  text-align: center;
  color: var(--text-dim);
  font-size: 15px;
  margin: 4px 0 12px;
}

.startstop-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0 16px;
}

.startstop {
  width: min(64vw, 300px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 4px solid var(--akzent);
  background: radial-gradient(circle at 50% 35%, #2a2313, var(--bg-karte) 70%);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: 0 0 32px rgba(245, 165, 36, 0.18);
  transition: transform 80ms ease, box-shadow 200ms ease;
}

.startstop:active { transform: scale(0.97); }

.startstop .ss-aktion {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--akzent);
  text-transform: uppercase;
}

.startstop .ss-zeit {
  font-family: var(--mono);
  font-size: 26px;
  font-variant-numeric: tabular-nums;
}

.startstop .ss-hinweis {
  font-size: 14px;
  color: var(--text-dim);
}

.startstop.laeuft {
  border-color: var(--rot);
  background: radial-gradient(circle at 50% 35%, #2a1414, var(--bg-karte) 70%);
  box-shadow: 0 0 32px rgba(229, 72, 77, 0.22);
}

.startstop.laeuft .ss-aktion { color: var(--rot); }

.sync-info {
  text-align: center;
  color: var(--akzent);
  font-size: 14px;
  margin: 0 0 16px;
}

.af-karte .af-zeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.af-btn {
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--rand);
  background: var(--bg-erhoben);
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 80ms ease;
}

.af-btn:active { transform: scale(0.94); }

.af-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.af-btn.plus {
  background: var(--akzent);
  border-color: var(--akzent);
  color: var(--akzent-text);
}

.af-wert {
  font-size: 34px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: center;
}

.verdienst {
  font-size: 28px;
  font-weight: 800;
  margin: 4px 0 0;
}

.verdienst small {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
}

.notiz-zeile { margin-top: 4px; }

.notiz-zeile input { margin-bottom: 4px; }

/* ---------- TAGE ---------- */

.monat-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.monat-nav h1 { margin: 0; text-align: center; flex: 1; }

.tage-liste {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tag-zeile {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 64px;
  font: inherit;
  text-align: left;
  color: var(--text);
  background: var(--bg-karte);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  cursor: pointer;
}

.tag-zeile:active { background: var(--bg-erhoben); }

.tz-warn {
  color: var(--rot);
  font-size: 18px;
  flex: none;
}

.tz-haupt {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tz-datum { font-weight: 700; }

.tz-fenster {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tz-zahlen {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex: none;
}

.tz-betrag { font-weight: 700; color: var(--akzent); }

.tz-aw { font-size: 13px; color: var(--text-dim); }

/* ---------- TAG-DETAIL ---------- */

.detail-kopf {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.detail-kopf h1 { margin: 0; flex: 1; }

.warn-titel { color: var(--rot); }

.warn-liste {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
  font-size: 14px;
}

.warn-liste li { margin-bottom: 4px; }

.log-vorschau {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  background: var(--bg);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}

.detail-zahlen {
  font-size: 14px;
  color: var(--text-dim);
  margin: 12px 0 0;
}

.detail-zahlen b { color: var(--text); }

.session-block, .kd-block {
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.kd-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.kd-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.kd-ordnung {
  display: inline-flex;
  gap: 8px;
  flex: none;
}

.kd-felder {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}

.kd-felder label:nth-child(3) { grid-column: 1 / -1; }

.notiz-liste {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.notiz-liste li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rand);
  font-size: 14px;
}

.notiz-liste li:last-child { border-bottom: none; }

/* ---------- IMPORT ---------- */

.datei-feld {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  margin-bottom: 12px;
  padding: 12px;
  border: 2px dashed var(--rand);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  text-align: center;
}

.datei-feld:focus-within {
  outline: 2px solid var(--fokus);
  outline-offset: 2px;
}

.datei-feld input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  opacity: 0;
}

.import-karte {
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.import-karte.entschieden-ja { border-color: var(--akzent); }
.import-karte.entschieden-nein { border-color: var(--rot); opacity: 0.8; }

.import-details {
  font-size: 13px;
  color: var(--text-dim);
  margin: 4px 0 8px;
}

.import-karte .frage {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 8px;
}

.ja-nein {
  display: flex;
  gap: 12px;
}

.import-liste {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
}

.import-liste li {
  padding: 8px 0;
  border-bottom: 1px solid var(--rand);
}

.import-liste li:last-child { border-bottom: none; }

.import-liste span { color: var(--text-dim); }

/* ---------- EXPORT ---------- */

.schnellwahl { margin-bottom: 12px; }

.schnellwahl .btn { flex: 1 1 auto; }

/* ---------- DASHBOARD ---------- */

.jahr-wahl {
  width: auto;
  min-width: 110px;
  margin-top: 0;
}

.dash-zeile { margin-bottom: 20px; }

.dash-zeile:last-child { margin-bottom: 0; }

.dash-kopf {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.dash-kopf b { color: var(--akzent); }

.balken {
  height: 10px;
  border-radius: 5px;
  background: var(--bg);
  border: 1px solid var(--rand);
  overflow: hidden;
}

.balken-fuellung {
  height: 100%;
  background: var(--akzent);
  border-radius: 5px;
  transition: width 300ms ease;
}

.dash-details {
  font-size: 13px;
  color: var(--text-dim);
  margin: 4px 0 0;
}

.dash-details b { color: var(--text); font-variant-numeric: tabular-nums; }

.summen-karte { border-color: var(--akzent); }

.jahres-betrag {
  font-size: 30px;
  font-weight: 800;
  color: var(--akzent);
  margin: 0 0 4px;
}

/* ---------- EINSTELLUNGEN ---------- */

.anker-tabelle {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-bottom: 12px;
}

.anker-tabelle th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 600;
  padding: 8px 8px 8px 0;
  border-bottom: 1px solid var(--rand);
}

.anker-tabelle td {
  padding: 8px 8px 8px 0;
  border-bottom: 1px solid var(--rand);
}

.anker-tabelle .num { text-align: right; }

.anker-neu {
  display: grid;
  grid-template-columns: 80px 1fr 72px auto;
  gap: 8px;
  align-items: center;
}

.anker-neu input { margin-top: 0; }

/* ---------- LOGIN ---------- */

.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70dvh;
}

.login-karte {
  width: 100%;
  max-width: 380px;
  text-align: center;
  padding: 32px 24px;
}

.login-karte h1 { margin: 12px 0 24px; }

.login-karte form { text-align: left; }

.login-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  background: var(--bg);
  border: 2px solid var(--akzent);
  color: var(--akzent);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.04em;
}

/* ---------- Tab-Leiste ---------- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 0;
  background: rgba(17, 20, 24, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--rand);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tabbar button {
  flex: 1;
  max-width: 144px;
  min-height: var(--tabbar-hoehe);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  font: inherit;
  font-size: 12px;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
}

.tabbar button svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.tabbar button.aktiv { color: var(--akzent); }

/* ---------- "Mehr"-Menü (Bottom-Sheet) ---------- */

.sheet-hintergrund {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  width: 100%;
  max-width: 720px;
  background: var(--bg-karte);
  border: 1px solid var(--rand);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet button {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 12px 16px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-erhoben);
  border: 1px solid var(--rand);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}

.sheet button svg {
  width: 22px;
  height: 22px;
  fill: var(--akzent);
  flex: none;
}

.sheet .sheet-schliessen {
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dim);
  font-weight: 500;
}

/* ---------- Modal (KI-Dialog) ---------- */

.modal-hintergrund {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 85dvh;
  overflow-y: auto;
  background: var(--bg-karte);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 24px;
}

.modal h2 {
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  font-size: 18px;
}

.modal h3 {
  color: var(--text-dim);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 16px 0 4px;
}

.polish-text {
  font-family: var(--schrift);
  font-size: 14px;
  white-space: pre-wrap;
  background: var(--bg);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 12px;
  margin: 0;
}

.polish-text.nachher { border-color: var(--akzent); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-hoehe) + env(safe-area-inset-bottom, 0px) + 16px);
  transform: translateX(-50%);
  z-index: 50;
  max-width: min(92vw, 480px);
  padding: 12px 20px;
  border-radius: 10px;
  background: var(--bg-erhoben);
  border: 1px solid var(--rand);
  color: var(--text);
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.toast.ok { border-color: var(--gruen); }
.toast.fehler { border-color: var(--rot); }

/* ---------- Desktop ---------- */

@media (min-width: 760px) {
  #inhalt { padding-top: 24px; }

  .startstop { width: min(40vw, 300px); }

  .feld-raster { grid-template-columns: 1fr 1fr 1fr 1fr; gap: 0 16px; }

  .kd-felder { grid-template-columns: 1fr 1fr 1fr auto; align-items: end; }

  .kd-felder label:nth-child(3) { grid-column: auto; }
}
