:root {
  --bg: #f4f5f3;
  --surface: #ffffff;
  --ink: #14181c;
  --ink-muted: #5c6670;
  --ink-faint: #8b939b;
  --line: #dee2e0;
  --line-soft: #ebeeec;
  --navy: #1f3a52;
  --navy-deep: #142639;
  --teal: #1f7a68;
  --amber: #b8791f;
  --amber-bg: #fbf1e0;
  --rust: #b8402a;
  --rust-bg: #fbeae6;
  --green-bg: #e8f3ee;
  --radius: 10px;
  --font-display: "Space Grotesk", "Inter", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* The [hidden] attribute only works if nothing else sets `display` on the
   element - .app and .login-screen both unconditionally set display:flex,
   which silently defeats the browser's built-in [hidden]{display:none} rule
   at equal specificity (an author rule beats the UA stylesheet). Toggling
   .hidden via JS was doing nothing on either element without this override. */
.app[hidden], .login-screen[hidden] { display: none; }

/* ---------- Login screen ---------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: 0 8px 24px rgba(20, 24, 28, 0.06);
}

.login-card .field { margin-bottom: 0; }

/* ---------- Offline banner ---------- */

.offline-banner {
  background: var(--amber-bg);
  color: var(--amber);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  padding: 8px 16px;
}

/* ---------- Topbar ---------- */

.topbar {
  background: var(--navy-deep);
  color: #fff;
  padding: 18px 28px 0;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  color: var(--teal);
  font-size: 10px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 12px;
  color: #9fb2c2;
}

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 0;
}

.tab {
  appearance: none;
  border: none;
  background: transparent;
  color: #b7c4cf;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13.5px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab:hover { color: #fff; }

.tab.active {
  color: #fff;
  border-bottom-color: var(--teal);
}

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

.hamburger span {
  display: block;
  height: 2px;
  width: 100%;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.hamburger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 720px) {
  .hamburger { display: flex; }
  .tabs {
    display: none;
    flex-direction: column;
    gap: 0;
    padding-bottom: 8px;
    overflow-x: visible;
  }
  .tabs.open { display: flex; }
  .tab {
    width: 100%;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 2px solid transparent;
    padding: 12px 10px;
  }
  .tab.active {
    border-left-color: var(--teal);
    background: rgba(255, 255, 255, 0.04);
  }
}

/* ---------- Layout ---------- */

.content {
  flex: 1;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.panel { display: none; }
.panel.active { display: block; animation: fade-in 0.2s ease; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-head h1 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}

.panel-head p {
  color: var(--ink-muted);
  margin: 0 0 24px;
  font-size: 14.5px;
}

/* ---------- Query controls ---------- */

.query-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap; /* default, not a modifier - a combo box alone (280px min-width)
    plus a button already exceeds a phone viewport, and a per-panel "wrap"
    class is too easy to forget to add (confirmed: it was, once) */
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-muted);
  font-weight: 500;
}

.field.grow { flex: 1; }
.field.grow-2 { flex: 2; }

.field-inline { display: flex; gap: 6px; }

input[type="text"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="email"],
input[type="password"],
select {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus-visible, select:focus-visible {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(31, 58, 82, 0.12);
}

.btn {
  appearance: none;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn.primary {
  background: var(--navy);
  color: #fff;
}

.btn.primary:hover:not(:disabled) { background: var(--navy-deep); }

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

.btn.ghost {
  background: transparent;
  color: var(--rust);
  padding: 6px 10px;
  font-size: 13px;
}

/* ---------- Searchable combo ---------- */

.combo { position: relative; min-width: 280px; }

.combo input { width: 100%; }

.combo-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(20, 24, 28, 0.1);
  z-index: 10;
}

.combo-option {
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13.5px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.combo-option:hover, .combo-option.highlighted { background: var(--green-bg); }

.combo-option .plate {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faint);
}

.combo-empty { padding: 10px 12px; font-size: 13px; color: var(--ink-faint); }

/* ---------- Result area / cards ---------- */

.result-area { min-height: 40px; }

.status-msg {
  color: var(--ink-muted);
  font-size: 13.5px;
  padding: 10px 0;
}

.status-msg.error { color: var(--rust); }

.status-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
}

.status-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.status-vehicle-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
}

.online-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.online-pill.online { background: var(--green-bg); color: var(--teal); }
.online-pill.offline { background: var(--line-soft); color: var(--ink-faint); }

.status-address {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 4px;
}

.status-coords {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faint);
  margin-bottom: 18px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}

.stat-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 15px;
  font-weight: 600;
}

.stat-value .unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
}

/* ---------- Tables ---------- */

table.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 13.5px;
}

/* A table's cell content can force it wider than its container fits (a
   long address, four columns of padding on a narrow phone) - without this,
   that overflow escapes the table and widens the whole page instead of
   just scrolling within its own box. min-width keeps columns from getting
   uselessly cramped before the scroll kicks in, rather than compressing
   text illegibly first. */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll table.data-table {
  min-width: 560px;
}

table.data-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-faint);
  padding: 10px 14px;
  background: var(--line-soft);
  font-weight: 600;
}

table.data-table td {
  padding: 10px 14px;
  border-top: 1px solid var(--line-soft);
  vertical-align: top;
}

table.data-table td.mono, td.mono { font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted); }

table.data-table tbody tr:hover { background: #fafbfa; }

/* ---------- Hour tabs (overnight parking check) ---------- */

.hour-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.hour-tab {
  appearance: none;
  border: none;
  background: transparent;
  padding: 10px 16px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.hour-tab.active {
  color: var(--ink);
  border-bottom-color: var(--navy);
  font-weight: 600;
}

.hour-tab .flag-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rust);
  display: none;
}

.hour-tab.has-flags .flag-dot { display: inline-block; }

.hour-summary {
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 14px;
}

.hour-summary .flag-count { color: var(--rust); font-weight: 600; }

/* row status pills inside tables */

.row-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 12.5px;
  padding: 3px 9px;
  border-radius: 20px;
}

.row-status.parked { background: var(--green-bg); color: var(--teal); }
.row-status.flagged { background: var(--rust-bg); color: var(--rust); }
.row-status.no-data { background: var(--line-soft); color: var(--ink-faint); }

/* ---------- Parking locations panel ---------- */

.location-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.field-hint {
  display: block;
  font-size: 12px;
  color: var(--ink-faint);
  margin-top: 5px;
}

.field-hint[hidden] { display: none; }

.field-hint.confirmed {
  color: var(--teal);
  font-weight: 600;
}

/* Google Places Autocomplete dropdown - matches the app's own combo styling */
.pac-container {
  font-family: var(--font-body);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 4px;
  box-shadow: 0 8px 24px rgba(20, 24, 28, 0.1);
}

.pac-item {
  padding: 8px 12px;
  font-size: 13.5px;
}

.locations-list { display: flex; flex-direction: column; gap: 10px; }

.location-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
}

.location-row-main { display: flex; flex-direction: column; gap: 2px; }

.location-row-name { font-weight: 600; font-size: 14px; }

.location-row-address { font-size: 13px; color: var(--ink-muted); }

.location-row-radius { font-family: var(--font-mono); font-size: 12px; color: var(--ink-faint); }

@media (max-width: 640px) {
  .content { padding: 20px 16px 60px; }
  .query-row { flex-direction: column; align-items: stretch; }
  .location-form { flex-direction: column; align-items: stretch; }
}
