/* ========== Design-Token & Resets ========== */
:root {
  --bg: #0b0e14;
  --bg-2: #0f1422;
  --card: #121723;
  --muted: #9aa4b2;
  --text: #e6e9ef;
  --brand: #5b8cff;
  --brand-2: #5bffb0;
  --ring: #2a5fff;
  --danger: #ff6b6b;
  --ok: #4cd97b;
  --border: rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.14);
  --shadow: 0 12px 30px rgba(0,0,0,.35), 0 6px 16px rgba(0,0,0,.25);

  /* Typografie (fluid) */
  --fs-xs: clamp(11px, 2.5vw, 12px);
  --fs-sm: clamp(13px, 2.8vw, 14px);
  --fs-md: clamp(15px, 3.2vw, 16px);
  --fs-lg: clamp(18px, 3.8vw, 20px);
  --fs-xl: clamp(20px, 4.6vw, 28px);

  /* Spacing */
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 16px;
}

/* System Dark-Mode Unterstützung (falls Browser-Default hell ist) */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #0b0e14; /* Wir bleiben bewusst dunkel */
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: linear-gradient(180deg, var(--bg), var(--bg) 40%, var(--bg-2) 100%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Color Emoji", "Apple Color Emoji";
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ========== Layout ========== */
.wrap {
  max-width: 980px;
  margin: var(--space-5) auto;
  padding: 0 var(--space-3);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

h1 {
  margin: 0;
  font-size: var(--fs-xl);
  letter-spacing: .2px;
}

/* Tabs (Switch Volvo/Tiguan) */
.tabs {
  display: inline-flex;
  background: rgba(255,255,255,.05);
  padding: var(--space-1);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: 100%;
  gap: var(--space-1);
}
@media (min-width: 480px) {
  .tabs { width: auto; }
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  font-size: var(--fs-md);
  transition: background .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
  min-width: 44%;              /* mobile: große Ziel-Fläche */
  text-align: center;
}
.tab[aria-selected="true"] {
  background: #131a2b;
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06), 0 6px 16px rgba(0,0,0,.35);
}
.tab:hover { color: #fff; }
.tab:active { transform: translateY(1px); }

/* Grid: mobile einspaltig, ab 860px zweispaltig */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}
@media (min-width: 860px) {
  .grid { grid-template-columns: 1.2fr .8fr; }
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: clip;
}
.card .head {
  padding: var(--space-4) var(--space-4) 0 var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.card .body {
  padding: var(--space-2) var(--space-4) var(--space-4) var(--space-4);
}

/* Inputs & Felder */
.field {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-3);
  background: rgba(255,255,255,.03);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
@media (min-width: 560px) {
  .field {
    grid-template-columns: 1fr auto;
  }
}

.field + .field {
  margin-top: 8px; /* oder 6px, wenn es noch dezenter sein soll */
}


.label {
  font-size: var(--fs-sm);
  color: var(--muted);
  margin-bottom: 4px;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.num {
  width: 100%;
  min-height: 44px; /* Touch-Ziel */
  appearance: textfield;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: var(--fs-md);
  outline: none;
  transition: border .15s ease, box-shadow .15s ease, background .15s ease;
}
@media (min-width: 560px) {
  .num { width: 160px; }
}

.num:focus-visible {
  border-color: var(--ring);
  box-shadow: 0 0 0 4px rgba(42,95,255,.18);
}
.num::placeholder { color: #7e8aa0; }

.unit {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 64px;
  text-align: right;
  font-size: var(--fs-sm);
}

/* Breite der rechten Einheit (CHF/l, CHF/kWh) und der Lücke – damit der Platz stimmt */
:root {
  --unit-w: 64px; /* entspricht deiner .unit min-width */
  --gap-w: 8px;   /* entspricht deiner .input-wrap gap */
}

/* Damit absolute Positionierung funktioniert */
.input-wrap { position: relative; }

/* Schloss-Icon: sitzt zwischen Input und .unit, ohne Layout zu verschieben */
.lock-icon {
  position: absolute;
  right: calc(var(--unit-w) + var(--gap-w) + 10px); /* Platz vor der Einheit lassen */
  top: 50%;
  transform: translateY(-50%);
  color: #9aa4b2;            /* harmoniert mit deinem muted-Farbton */
  opacity: .95;
  display: none;             /* per JS ein/aus */
  line-height: 0;            /* kein zusätzlicher Zeilenabstand */
  pointer-events: auto;      /* Tooltip/Title anzeigen lassen */
}
.lock-icon svg { display: block; }

/* Optional: disabled Inputs dezent als gesperrt zeigen */
input:disabled {
  opacity: .55;
  cursor: not-allowed;
  background: #0e1220;
  border-color: rgba(255,255,255,.08);
}

/* helle Pfeile in number inputs */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: inner-spin-button !important;
  opacity: 1;
  background: transparent;
  filter: invert(1) brightness(1.4); /* hellere Darstellung */
}


/* Textstile */
.kicker {
  color: var(--muted);
  font-size: var(--fs-xs);
  letter-spacing: .3px;
  text-transform: uppercase;
}

.result {
  font-size: clamp(28px, 6vw, 44px);
  font-weight: 800;
  letter-spacing: .3px;
  margin: 8px 0 2px;
}
.muted { color: var(--muted); font-size: var(--fs-sm); }

/* Aktionen / Buttons */
.actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: 800;
  letter-spacing: .3px;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: var(--fs-md);
  min-height: 44px; /* Touch-Ziel */
  color: #fff;
  background: rgba(255,255,255,.06);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
}
.btn:hover { border-color: var(--border-strong); background: rgba(255,255,255,.09); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(42,95,255,.2); border-color: var(--ring); }

.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #0b0e14;
  border-color: transparent;
  box-shadow: 0 10px 20px rgba(91,140,255,.25);
}
.btn.primary:hover { filter: saturate(1.1); }

.btn.warn {
  background: rgba(255,107,107,.15);
  color: #fff;
  border-color: rgba(255,107,107,.4);
}

/* Hinweisbox */
.note {
  background: rgba(255,255,255,.04);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  border: 1px solid var(--border);
}
.list { margin: 8px 0 0 0; padding-left: 18px; color: var(--muted); }

/* Footer */
footer {
  margin: var(--space-5) 0;
  color: var(--muted);
  font-size: var(--fs-sm);
  text-align: center;
  display: grid;
  gap: 6px;
}
footer .link {
  color: #9ec5ff;
  cursor: pointer;
  text-decoration: none;
}
footer .link:hover { text-decoration: underline; }

/* Utils */
.hide { display: none !important; }

/* ========== Modal (Login) ========== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: var(--space-3);
}
.modal {
  width: min(520px, 100%);
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--space-4);
  border: 1px solid var(--border);
}
.modal h3 {
  margin: 0 0 8px 0;
  font-size: var(--fs-lg);
}
.row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 10px 0;
}
@media (min-width: 520px) {
  .row { grid-template-columns: 140px 1fr; align-items: center; }
}
.row label {
  color: var(--muted);
  font-size: var(--fs-sm);
}
.row input[type="text"], .row input[type="password"] {
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: #fff;
  border-radius: 12px;
  padding: 12px;
  font-size: var(--fs-md);
  min-height: 44px;
}
.modal .actions { justify-content: flex-end; }

/* ========== Toast ========== */
.toast {
  position: fixed;
  right: 14px;
  bottom: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: none;
  z-index: 60;
  font-size: var(--fs-sm);
}

/* ========== Fokus & Barrierefreiheit ========== */
:focus-visible {
  outline: 2px solid transparent;
  box-shadow: 0 0 0 4px rgba(42,95,255,.24);
  border-radius: 12px;
}

/* ========== Motion Preferences ========== */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ========== Feinheiten für große Screens ========== */
@media (min-width: 1080px) {
  .wrap { max-width: 1040px; }
  .num { width: 180px; }
}
