:root {
  --bg: #0f1117;
  --surface: #1c1f2b;
  --surface-elevated: #252a3d;
  --border: rgba(255,255,255,0.08);
  --accent: #34c759; /* Apple Green */
  --accent-blue: #007aff;
  --text: #ffffff;
  --text-muted: #8e8e93;
  --danger: #ff3b30;
  --radius-card: 20px;
  --radius-pill: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html[data-theme="light"] {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-elevated: #fbfbfd;
  --border: rgba(0,0,0,0.05);
  --accent: #28cd41;
  --accent-blue: #007aff;
  --text: #000000;
  --text-muted: #8e8e93;
  --danger: #ff3b30;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
}

body {
  font-family: var(--font);
  color: var(--text);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(92px + env(safe-area-inset-bottom)); /* Space for bottom nav */
}

/* ── App Shell ── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  padding: calc(6px + env(safe-area-inset-top)) 16px 10px;
  min-height: calc(48px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

header .logo {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.4px;
  white-space: nowrap;
  line-height: 1.1;
}
header .subtitle { display: none; }

.theme-toggle {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  cursor: pointer;
}

.container {
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
}

section { margin-bottom: 24px; }
section.transparent { background: transparent; padding: 0; box-shadow: none; border: none; backdrop-filter: none; }

h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
  padding-left: 4px;
}

/* ── Status Hero ── */
.status-hero { margin-bottom: 16px; }
.status-pill {
  padding: 14px 18px;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  font-weight: 600;
  font-size: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.status-pill i { width: 24px; height: 24px; }
.status-pill.is-good { color: var(--accent); background: color-mix(in oklab, var(--accent) 10%, var(--surface)); border-color: color-mix(in oklab, var(--accent) 30%, var(--border)); }
.status-pill.is-bad { color: var(--danger); }

.reco-pill {
  margin-top: -4px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 10px;
}
.reco-pill i { width: 16px; height: 16px; color: var(--accent-blue); }
.reco-pill strong { display: block; font-size: 13px; }
.reco-pill small { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.reco-pill.good { border-color: color-mix(in oklab, var(--accent) 35%, var(--border)); }
.reco-pill.warn { border-color: color-mix(in oklab, #ff9500 50%, var(--border)); }
.reco-pill.neutral { opacity: .96; }

.month-bar {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.month-bar input {
  flex: 1; height: 44px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 0 12px; font-size: 15px; font-family: inherit;
}
.month-bar button {
  padding: 0 20px; border-radius: var(--radius-pill);
  background: var(--accent-blue); color: white; border: none;
  font-weight: 600; font-size: 15px;
}

.quick-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.quick-nav a {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-pill); height: 48px;
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  text-decoration: none; color: var(--text); font-size: 14px; font-weight: 600;
}
.quick-nav a i { width: 18px; height: 18px; color: var(--accent-blue); }

.car-card {
  margin-top: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 12px;
}

.car-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.car-header i { width: 16px; height: 16px; color: var(--accent-blue); }
.stale-badge {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
}

.health-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 8px;
}
.health-pill.ok { background: rgba(52,199,89,.15); color: #34c759; }
.health-pill.warn { background: rgba(255,149,0,.15); color: #ff9500; }
.health-pill i { width: 14px; height: 14px; }

.car-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.car-grid div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
}
.car-grid .k { font-size: 11px; color: var(--text-muted); }
.car-grid .v { font-size: 13px; font-weight: 700; color: var(--text); }

/* ── KPIs ── */
.kpi-grid-v2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kpi-card-v2 {
  background: var(--surface); border-radius: var(--radius-card); padding: 16px;
  border: 1px solid var(--border);
}
.kpi-card-v2.primary { background: linear-gradient(135deg, var(--accent-blue), #5856d6); color: white; }
.kpi-card-v2.primary .label, .kpi-card-v2.primary .sub { color: rgba(255,255,255,0.8); }
.kpi-card-v2.highlight { background: var(--surface-elevated); }
.kpi-card-v2 .label { font-size: 12px; font-weight: 600; text-transform: uppercase; opacity: 0.6; margin-bottom: 4px; }
.kpi-card-v2 .value { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.kpi-card-v2 .value small { font-size: 14px; opacity: 0.7; }
.kpi-card-v2 .sub { font-size: 12px; margin-top: 4px; opacity: 0.7; }

/* ── Smart Cards ── */
.card-stack { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.smart-card {
  background: var(--surface); border-radius: var(--radius-card);
  border: 1px solid var(--border); padding: 16px;
}
.card-main { display: flex; align-items: center; gap: 12px; }
.status-icon { width: 12px; height: 12px; border-radius: 50%; background: #ccc; flex-shrink: 0; }
.status-icon.free { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.status-icon.busy { background: var(--danger); }
.smart-card .info { flex: 1; }
.smart-card .name { font-weight: 700; font-size: 17px; letter-spacing: -0.3px; }
.smart-card .meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.watch-pill {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-elevated);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted);
}
.watch-pill.active { color: #ffcc00; background: rgba(255,204,0,0.1); border-color: rgba(255,204,0,0.2); }

.card-footer {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.card-footer .status-text { font-size: 13px; font-weight: 600; opacity: 0.8; }
.card-footer details summary { font-size: 12px; color: var(--accent-blue); cursor: pointer; }

/* ── Timeline ── */
.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline-card {
  background: var(--surface); border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.timeline-card summary {
  list-style: none;
  cursor: pointer;
  padding: 14px;
}
.timeline-card summary::-webkit-details-marker { display: none; }
.timeline-card .date { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.timeline-card .main { display: flex; justify-content: space-between; align-items: flex-start; }
.timeline-card .station { font-weight: 600; font-size: 15px; }
.timeline-card .amount { text-align: right; }
.timeline-card .eur { display: block; font-weight: 700; font-size: 16px; color: var(--accent); }
.timeline-card .kwh { font-size: 12px; color: var(--text-muted); }
.timeline-card .details-content {
  border-top: 1px solid var(--border);
  padding: 10px 14px 12px;
  background: color-mix(in oklab, var(--surface2) 55%, transparent);
}
.timeline-card .meta-row { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.timeline-card .notes { margin-top: 8px; font-size: 13px; color: var(--text-muted); font-style: italic; }
.timeline-card .notes.muted { opacity: .8; font-style: normal; }

/* ── Forms ── */
.form-v2 { display: flex; flex-direction: column; gap: 12px; }
.form-v2 label { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: -4px; }
.form-v2 input, .form-v2 select, .form-v2 textarea {
  height: 48px; border-radius: var(--radius-pill);
  background: var(--surface-elevated); border: 1px solid var(--border);
  color: var(--text); padding: 0 14px; font-size: 16px; font-family: inherit;
}
.form-v2 textarea { height: 80px; padding: 12px 14px; resize: none; }
.primary-btn {
  height: 50px; border-radius: var(--radius-pill);
  background: var(--accent-blue); color: white; border: none;
  font-weight: 700; font-size: 16px; margin-top: 8px;
}

/* ── Upload ── */
.upload-card {
  background: var(--surface); border-radius: var(--radius-card); padding: 20px;
  border: 2px dashed var(--border); text-align: center;
}
.file-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.file-drop i { width: 32px; height: 32px; color: var(--accent-blue); }
.file-drop span { font-size: 14px; font-weight: 600; opacity: 0.7; }
.file-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + env(safe-area-inset-bottom));
  padding: 0 8px env(safe-area-inset-bottom);
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 1000;
  transform: translateZ(0);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-muted); text-decoration: none; gap: 4px;
}
.bottom-nav a i { width: 24px; height: 24px; }
.bottom-nav a span { font-size: 10px; font-weight: 600; }
.bottom-nav a.active { color: var(--accent-blue); }

/* ── Drawers / Details ── */
.add-drawer { background: var(--surface-elevated); border-radius: var(--radius-pill); overflow: hidden; }
.add-drawer summary { height: 48px; display: flex; align-items: center; gap: 10px; padding: 0 16px; font-weight: 600; cursor: pointer; list-style: none; }
.add-drawer summary::-webkit-details-marker { display: none; }
.drawer-content { padding: 16px; border-top: 1px solid var(--border); }

.input-row { display: flex; gap: 8px; }
.input-row > * { flex: 1; }

.maps-card { margin-bottom: 20px; }
.maps-card .input-row button {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--accent-blue); font-weight: 600; border-radius: var(--radius-pill);
  padding: 0 16px;
}

@media (max-width: 380px) {
  h2 { font-size: 20px; }
  .status-pill { font-size: 14px; }
  .kpi-card-v2 .value { font-size: 20px; }
}
