/* Mobile-first styles: base rules target small screens, @media widens up. */

:root {
  color-scheme: dark;
  --bg: #0f1115;
  --surface: #1a1d24;
  --surface-2: #22262f;
  --text: #f2f3f5;
  --text-dim: #9aa1ac;
  --green: #37b24d;
  --red: #e03131;
  --amber: #f08c00;
  --blue: #339af0;
  --border: #2c3038;
  --radius: 14px;
  --nav-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  padding-bottom: calc(var(--nav-h) + 16px);
  min-height: 100vh;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 8px;
}

h1 {
  font-size: 1.4rem;
  margin: 4px 0 16px;
}

h2 {
  font-size: 1.05rem;
  margin: 0 0 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

a { color: var(--blue); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.car-hero { position: relative; text-align: center; margin-bottom: 16px; }
.car-image-wrap { position: relative; }
.car-image-wrap img { display: block; width: 100%; height: auto; border-radius: var(--radius) var(--radius) 0 0; }

.car-hero.charging {
  border-radius: var(--radius);
  border: 3px solid transparent;
  background: conic-gradient(from var(--charge-angle), transparent 0deg, var(--green) 40deg, transparent 95deg, transparent 360deg) border-box;
  animation: charge-spin 4s linear infinite;
}

.car-battery-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}
.car-battery-badge.soc-low { color: #ffc9c9; }
.car-battery-badge.soc-mid { color: #ffe8cc; }
.car-battery-badge.soc-high { color: #d3f9d8; }
.signal-off-icon { vertical-align: middle; margin-left: 2px; color: #ffc9c9; }

@keyframes battery-fill-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.battery-fill-pulse {
  animation: battery-fill-pulse 1.4s ease-in-out infinite;
}

.car-power-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.car-mode-badge {
  display: none;
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.car-session-cost-badge {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

@keyframes bolt-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.charging-pulse-icon {
  transform-origin: center;
  animation: bolt-pulse 1.2s ease-in-out infinite;
}

.car-status-overlay {
  padding: 10px 14px;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
}

.car-status-overlay .sub {
  display: block;
  font-size: 0.8rem;
  font-weight: 400;
  margin-top: 4px;
  opacity: 0.95;
}

.car-status-overlay.no { background: color-mix(in srgb, var(--red) 55%, rgba(0, 0, 0, 0.55)); color: #ffc9c9; }
.car-status-overlay.unknown { background: color-mix(in srgb, var(--amber) 55%, rgba(0, 0, 0, 0.55)); color: #ffe8cc; }
.car-status-overlay.idle { background: rgba(0, 0, 0, 0.6); color: #fff; }

.car-status-overlay.ok {
  background: color-mix(in srgb, var(--green) 35%, transparent);
  color: #d3f9d8;
}

.car-status-overlay.paused {
  background: color-mix(in srgb, var(--amber) 45%, transparent);
  color: #ffe8cc;
}

.car-status-overlay.done {
  background: color-mix(in srgb, var(--green) 35%, transparent);
  color: #d3f9d8;
}

.badge {
  display: block;
  text-align: center;
  border-radius: var(--radius);
  padding: 22px 16px;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.badge .sub {
  display: block;
  font-size: 0.85rem;
  font-weight: 400;
  margin-top: 6px;
  opacity: 0.9;
}

.badge.no { background: color-mix(in srgb, var(--red) 25%, var(--surface)); border: 1px solid var(--red); color: #ffc9c9; }
.badge.unknown { background: color-mix(in srgb, var(--amber) 25%, var(--surface)); border: 1px solid var(--amber); color: #ffe8cc; }
.badge.idle { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }

@property --charge-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

@keyframes charge-spin {
  to { --charge-angle: 360deg; }
}

.badge.ok {
  color: #d3f9d8;
  border: 2px solid transparent;
  background:
    linear-gradient(color-mix(in srgb, var(--green) 25%, var(--surface)), color-mix(in srgb, var(--green) 25%, var(--surface))) padding-box,
    conic-gradient(from var(--charge-angle), var(--green), color-mix(in srgb, var(--green) 10%, transparent) 50%, var(--green)) border-box;
  animation: charge-spin 2.5s linear infinite;
}

.badge-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 16px;
}

.badge-main { flex: 2 1 0; min-width: 0; }
.badge-main .badge { margin-bottom: 0; height: 100%; }

.badge-soc {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 12px;
  text-align: center;
}

.badge-soc-title {
  font-size: 0.66rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.badge-soc-value { font-size: 1.5rem; font-weight: 700; }
.badge-soc-time { font-size: 0.72rem; color: var(--text-dim); margin-top: 6px; }

.badge-soc.soc-low { background: color-mix(in srgb, var(--red) 25%, var(--surface-2)); border-color: var(--red); }
.badge-soc.soc-mid { background: color-mix(in srgb, var(--amber) 25%, var(--surface-2)); border-color: var(--amber); }
.badge-soc.soc-high { background: color-mix(in srgb, var(--green) 25%, var(--surface-2)); border-color: var(--green); }

.stat-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-row-3col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat {
  flex: 1 1 120px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px;
}

.stat .value {
  font-size: 1.3rem;
  font-weight: 700;
}

.stat .label {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.stat .cost {
  margin-top: 2px;
}

.stat .price-fixed {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-dim);
}

form.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  font-size: 0.85rem;
  color: var(--text-dim);
  display: block;
  margin-bottom: 4px;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="datetime-local"],
input[type="date"],
select {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.charge-limit-slider {
  width: 100%;
  display: block;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkbox-row input { width: 20px; height: 20px; }

button, .btn {
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 16px;
  border-radius: 10px;
  border: none;
  background: var(--blue);
  color: #06131f;
  cursor: pointer;
}

button:active { opacity: 0.85; }

button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

th { color: var(--text-dim); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; }

.chart {
  width: 100%;
  height: auto;
  display: block;
}
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--text-dim); font-size: 8px; }
.chart-empty { fill: var(--text-dim); font-size: 12px; }

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

.field-hint { font-size: 0.78rem; color: var(--text-dim); margin-top: -6px; }

.ready-at-display { font-size: 0.92rem; color: var(--text-dim); margin-top: 14px; }
.ready-at-caveat { font-size: 0.72rem; color: var(--text-dim); margin-top: 2px; }

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.status-pill.on { background: color-mix(in srgb, var(--green) 30%, transparent); color: #d3f9d8; }
.status-pill.off { background: color-mix(in srgb, var(--red) 30%, transparent); color: #ffc9c9; }

.mode-select summary,
.collapsible summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  list-style: none;
}

.mode-select summary::-webkit-details-marker,
.mode-select summary::marker,
.collapsible summary::-webkit-details-marker,
.collapsible summary::marker { display: none; content: ""; }

.mode-select summary .chevron,
.collapsible summary .chevron {
  color: var(--text-dim);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.mode-select[open] summary .chevron,
.collapsible[open] summary .chevron { transform: rotate(180deg); }

.mode-select .mode-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.mode-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
}

.mode-option:has(input:checked) { border-color: var(--blue); }

.mode-option input { margin-top: 3px; width: 18px; height: 18px; flex-shrink: 0; }

.mode-title { display: block; font-weight: 600; }

.mode-desc {
  display: block;
  margin-top: 3px;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-dim);
  line-height: 1.35;
}

/* Bottom app-style navigation */
nav.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 640px;
  margin: 0 auto;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 10;
}

nav.bottom-nav a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  text-decoration: none;
}

nav.bottom-nav a .icon {
  width: 26px;
  height: 26px;
  transition: color 0.15s ease;
}

nav.bottom-nav a.active { color: var(--blue); }

/* Login screen with numeric keypad */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 22px;
}

.login-screen h1 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pin-dots {
  display: flex;
  gap: 18px;
}

.pin-dots .dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  transition: background 0.15s, border-color 0.15s;
}

.pin-dots .dot.filled {
  background: var(--blue);
  border-color: var(--blue);
}

.pin-error {
  color: var(--red);
  font-size: 0.85rem;
  min-height: 1.2em;
  margin: 0;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 18px;
}

.keypad .key {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.keypad .key:active {
  background: var(--surface);
}

.keypad .key-empty {
  background: transparent;
  border: none;
}

.keypad .key-del {
  font-size: 1.2rem;
  background: transparent;
  border: none;
  color: var(--text-dim);
}

/* Desktop: widen content, keep bottom nav fixed but roomier */
@media (min-width: 720px) {
  main { max-width: 860px; padding: 24px 24px 8px; }

  nav.bottom-nav { max-width: 860px; }

  .car-mode-badge { display: block; }

  .stat-row { flex-wrap: nowrap; }
}
