/* MobilityHub design system — mobile-first, brand-driven via CSS custom properties */

:root {
  --primary: #ED1C24;
  --primary-dark: #B5121A;
  --secondary: #003DA5;
  --secondary-dark: #00276b;
  --accent: #FFB81C;
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --ink: #101317;
  --ink-muted: #5B6472;
  --success: #1C8A4B;
  --danger: #D6304B;
  --warning: #C6790C;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(16,19,23,0.06), 0 1px 1px rgba(16,19,23,0.04);
  --shadow-md: 0 8px 24px rgba(16,19,23,0.10), 0 2px 6px rgba(16,19,23,0.06);
  --shadow-lg: 0 16px 48px rgba(16,19,23,0.16);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 64px;
  --max-w: 480px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0 0 8px; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; display: block; }

.app-shell {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
}
.app-shell.no-nav { padding-bottom: calc(var(--safe-bottom) + 12px); }

.desktop-frame {
  background: #e8e9ec;
  min-height: 100vh;
}
@media (min-width: 560px) {
  .desktop-frame .app-shell {
    box-shadow: var(--shadow-lg);
    min-height: calc(100vh - 32px);
    margin: 16px auto;
    border-radius: var(--radius-lg);
    overflow: hidden;
  }
}

/* Top bar */
.topbar {
  padding: calc(14px + var(--safe-top)) 20px 14px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid rgba(16,19,23,0.06);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; }
.topbar .icon-btn { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--bg); border: none; }

/* Header hero */
.hero {
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: calc(20px + var(--safe-top)) 20px 28px;
  border-radius: 0 0 28px 28px;
}
.hero .greeting { font-size: 13px; opacity: 0.85; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.hero h1 { font-size: 24px; margin-top: 2px; }
.hero .disclaimer { font-size: 11px; opacity: 0.75; margin-top: 10px; }

.container { padding: 16px; }
.container-tight { padding: 0 16px; }

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid rgba(16,19,23,0.04);
}
.card-tap { cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.card-tap:active { transform: scale(0.985); box-shadow: var(--shadow-sm); }

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

.action-tile {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px 14px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
  border: 1px solid rgba(16,19,23,0.04);
}
.action-tile .tile-icon {
  width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: rgba(237,28,36,0.1); color: var(--primary);
}
.action-tile.primary { background: linear-gradient(160deg, var(--primary), var(--primary-dark)); color: #fff; }
.action-tile.primary .tile-icon { background: rgba(255,255,255,0.18); color: #fff; }
.action-tile .tile-title { font-weight: 700; font-size: 15px; }
.action-tile .tile-sub { font-size: 12px; color: var(--ink-muted); }
.action-tile.primary .tile-sub { color: rgba(255,255,255,0.85); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700; font-size: 15px; border-radius: var(--radius-sm);
  padding: 15px 20px; border: none; cursor: pointer; width: 100%;
  transition: transform 0.1s ease, opacity 0.15s ease;
  min-height: 50px;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(237,28,36,0.28); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--ink); border: 1.5px solid rgba(16,19,23,0.12); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 9px 14px; font-size: 13px; min-height: 36px; width: auto; }
.btn-block-row { display: flex; gap: 10px; }

/* Bottom nav */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: var(--max-w); margin: 0 auto;
  background: var(--surface);
  border-top: 1px solid rgba(16,19,23,0.07);
  display: flex; padding-bottom: var(--safe-bottom);
  box-shadow: 0 -4px 16px rgba(16,19,23,0.06);
}
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 8px; color: var(--ink-muted); font-size: 10.5px; font-weight: 600; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav svg { width: 22px; height: 22px; }
.bottom-nav .scan-fab {
  width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; margin: -20px auto 0;
  box-shadow: 0 8px 20px rgba(237,28,36,0.4); border: 4px solid var(--surface);
}
.bottom-nav .scan-fab svg { width: 24px; height: 24px; }

/* Badges / pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.pill-available { background: rgba(28,138,75,0.12); color: var(--success); }
.pill-offline { background: rgba(91,100,114,0.12); color: var(--ink-muted); }
.pill-busy { background: rgba(198,121,12,0.12); color: var(--warning); }
.pill-danger { background: rgba(214,48,75,0.12); color: var(--danger); }
.pill-info { background: rgba(0,61,165,0.1); color: var(--secondary); }
.pill-demo { background: rgba(255,184,28,0.18); color: #8a5c00; }

.badge-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.03em; }
.field input, .field select {
  width: 100%; padding: 13px 14px; border-radius: var(--radius-sm); border: 1.5px solid rgba(16,19,23,0.14);
  font-size: 15px; background: var(--surface); color: var(--ink);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--secondary); }
.field .hint { font-size: 11.5px; color: var(--ink-muted); margin-top: 5px; }
.checkbox-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--ink); }
.checkbox-row input { width: 18px; height: 18px; }

/* Section headers */
.section-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-muted); margin: 20px 4px 10px; }
.section-title:first-child { margin-top: 4px; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--ink-muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11px; }

/* Full screen states (auth/fueling) */
.fullscreen-state {
  position: fixed; inset: 0; z-index: 100; background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; padding-top: calc(24px + var(--safe-top));
}
.fullscreen-state.dark { background: linear-gradient(180deg, #14181f, #0c0e12); color: #fff; }
.spinner {
  width: 56px; height: 56px; border-radius: 50%;
  border: 4px solid rgba(0,0,0,0.08); border-top-color: var(--primary);
  animation: spin 0.9s linear infinite;
}
.dark .spinner { border-color: rgba(255,255,255,0.15); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }
.pulse { animation: pulse 1.6s ease-in-out infinite; }

.big-amount { font-size: 40px; font-weight: 800; letter-spacing: -0.02em; margin: 10px 0 4px; }
.big-amount .cur { font-size: 20px; font-weight: 700; opacity: 0.7; margin-right: 4px; }

/* Fueling gauge */
.fuel-gauge { width: 100%; max-width: 320px; margin: 20px auto; }
.fuel-litres { font-size: 52px; font-weight: 800; letter-spacing: -0.02em; }
.fuel-progress-track { height: 10px; border-radius: 999px; background: rgba(255,255,255,0.14); overflow: hidden; margin: 16px 0; }
.dark .fuel-progress-track { background: rgba(255,255,255,0.12); }
.fuel-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--primary)); border-radius: 999px; transition: width 0.4s ease; }

/* Receipt */
.receipt {
  background: var(--surface); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-md);
}
.receipt-head { background: var(--success); color: #fff; padding: 28px 20px; text-align: center; }
.receipt-check { width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,0.2); margin: 0 auto 12px; display:flex; align-items:center; justify-content:center; }
.receipt-body { padding: 20px; }
.receipt-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 14px; border-bottom: 1px dashed rgba(16,19,23,0.08); }
.receipt-row:last-child { border-bottom: none; }
.receipt-row .label { color: var(--ink-muted); }
.receipt-total { display: flex; justify-content: space-between; font-size: 20px; font-weight: 800; padding: 14px 0 4px; }
.receipt-divider { border-top: 2px dashed rgba(16,19,23,0.12); margin: 8px 0; }

/* Demo mode timeline */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 10px; top: 6px; bottom: 6px; width: 2px; background: rgba(16,19,23,0.1); }
.timeline-step { position: relative; padding-bottom: 22px; }
.timeline-step .dot {
  position: absolute; left: -28px; top: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg); border: 2px solid rgba(16,19,23,0.18); display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: var(--ink-muted);
}
.timeline-step.done .dot { background: var(--success); border-color: var(--success); color: #fff; }
.timeline-step.active .dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.timeline-step .step-title { font-weight: 700; font-size: 14px; }
.timeline-step .step-detail { font-size: 12.5px; color: var(--ink-muted); margin-top: 2px; }

/* Advanced view event cards */
.event-card { border: 1px solid rgba(16,19,23,0.08); border-radius: var(--radius-sm); margin-bottom: 10px; overflow: hidden; }
.event-card summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.event-card summary::-webkit-details-marker { display: none; }
.event-card pre { background: #0d1117; color: #c9d1d9; font-size: 11px; padding: 12px; margin: 0; overflow-x: auto; max-height: 280px; }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 0 14px 12px; font-size: 12px; }
.kv-grid .k { color: var(--ink-muted); }

/* Utility */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.w-full { width: 100%; }

/* Admin */
.admin-shell { max-width: 1100px; margin: 0 auto; padding: 20px; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px; background: var(--surface); padding: 6px; border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
.admin-nav a { padding: 9px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-muted); }
.admin-nav a.active { background: var(--ink); color: #fff; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.stat-card { background: var(--surface); border-radius: var(--radius-md); padding: 16px; box-shadow: var(--shadow-sm); }
.stat-card .stat-value { font-size: 26px; font-weight: 800; }
.stat-card .stat-label { font-size: 12px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.pump-admin-card { background: var(--surface); border-radius: var(--radius-md); padding: 16px; box-shadow: var(--shadow-sm); }
table.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-sm); }
table.admin-table th, table.admin-table td { padding: 10px 12px; text-align: left; font-size: 13px; border-bottom: 1px solid rgba(16,19,23,0.06); }
table.admin-table th { background: rgba(16,19,23,0.03); text-transform: uppercase; font-size: 11px; letter-spacing: 0.04em; color: var(--ink-muted); }
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; }

.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; }
.login-card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 32px 26px; width: 100%; max-width: 380px; }

/* Map */
#map { width: 100%; height: 360px; border-radius: var(--radius-md); overflow: hidden; }
.leaflet-popup-content { font-family: inherit; }
.map-station-card { min-width: 200px; }
.map-station-card h4 { margin-bottom: 4px; font-size: 14px; }
.map-station-card .dist { font-size: 12px; color: var(--ink-muted); margin-bottom: 8px; }

/* Toast */
#toast-root { position: fixed; top: calc(var(--safe-top) + 10px); left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; width: calc(100% - 32px); max-width: var(--max-w); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 13.5px; box-shadow: var(--shadow-md); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* Sheets */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(16,19,23,0.45); z-index: 200; display: flex; align-items: flex-end; }
.sheet { background: var(--surface); width: 100%; border-radius: 24px 24px 0 0; padding: 8px 20px calc(20px + var(--safe-bottom)); max-height: 85vh; overflow-y: auto; }
.sheet-handle { width: 40px; height: 4px; background: rgba(16,19,23,0.15); border-radius: 999px; margin: 8px auto 14px; }

.skeleton { background: linear-gradient(90deg, rgba(0,0,0,0.06) 25%, rgba(0,0,0,0.1) 37%, rgba(0,0,0,0.06) 63%); background-size: 400% 100%; animation: skeleton 1.4s ease infinite; border-radius: 8px; }
@keyframes skeleton { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
