:root {
  --bg-page: #f4f6f9;
  --bg-panel: #ffffff;
  --bg-panel-alt: #f8f9fb;
  --line: #e4e7ec;
  --text-primary: #1f2937;
  --text-dim: #6b7280;
  --text-faint: #9ca3af;
  --accent: #2196f3;
  --accent-dark: #1976d2;
  --accent-bg: #e8f3fe;
  --success: #43a047;
  --success-bg: #e6f4ea;
  --warn: #ffa000;
  --warn-bg: #fff4e0;
  --danger: #e53953;
  --danger-bg: #fde8ec;
  --purple: #8e24aa;
  --purple-bg: #f3e5f7;
  --font-ui: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, 0.16);
}

body.dark-theme {
  --bg-page: #12181f;
  --bg-panel: #1a222b;
  --bg-panel-alt: #212b36;
  --line: #2c3844;
  --text-primary: #e8ecf1;
  --text-dim: #9aa7b5;
  --text-faint: #6b7889;
  --accent-bg: #1c3450;
  --success-bg: #16311e;
  --warn-bg: #3a2c0d;
  --danger-bg: #3a1520;
  --purple-bg: #331a3d;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.5);
}
body.dark-theme { background: var(--bg-page); color: var(--text-primary); }

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
}

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

/* ================= Login screen ================= */

.login-screen {
  height: 100vh; width: 100vw;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  overflow: hidden;
  background: #dde3ea;
}

.login-bg-map {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}


.login-card {
  width: 340px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 36px 30px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 2;
}

.login-card h1 { font-size: 19px; margin: 0 0 4px; color: var(--text-primary); }
.login-logo { width: 100%; max-width: 220px; height: auto; display: block; margin: 0 auto 8px; }
.login-sub { color: var(--text-dim); font-size: 12.5px; margin: 0 0 22px; }

.login-card input {
  width: 100%;
  background: var(--bg-panel-alt);
  border: 1px solid var(--line);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 11px 13px;
  font-size: 13.5px;
  margin-bottom: 11px;
  box-sizing: border-box;
}
.login-card input:focus { outline: none; border-color: var(--accent); background: #fff; }

.login-card button[type="submit"] {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 11px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  margin-top: 4px;
}
.login-card button[type="submit"]:hover { background: var(--accent-dark); }

.login-error { color: var(--danger); font-size: 11.5px; margin: 10px 0 0; }
.login-hint { color: var(--text-faint); font-size: 10.5px; margin: 18px 0 0; line-height: 1.5; }

/* ================= App shell / topbar ================= */

.app { height: 100vh; width: 100vw; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 56px; flex-shrink: 0;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  box-shadow: var(--shadow);
  z-index: 500;
}

.topbar-left { display: flex; align-items: center; gap: 30px; }
.brand { font-size: 15px; font-weight: 700; color: var(--text-primary); display: flex; align-items: center; gap: 8px; letter-spacing: 0.02em; }
.brand-icon { height: 26px; width: auto; }

.nav-tabs { display: flex; gap: 2px; }
.nav-tab {
  background: none; border: none; color: var(--text-dim);
  font-size: 13px; font-weight: 500; padding: 9px 14px; cursor: pointer; border-radius: 6px;
}
.nav-tab:hover { color: var(--text-primary); background: var(--bg-panel-alt); }
.nav-tab.active { color: var(--accent); background: var(--accent-bg); }

.topbar-right { display: flex; align-items: center; gap: 12px; position: relative; }

.user-menu { position: relative; }
.user-btn {
  background: var(--bg-panel-alt); border: 1px solid var(--line); color: var(--text-primary);
  border-radius: 6px; padding: 7px 12px; font-size: 12.5px; cursor: pointer; font-weight: 500;
}
.user-dropdown {
  position: absolute; top: 42px; right: 0; z-index: 1300;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  min-width: 210px; overflow: hidden; box-shadow: var(--shadow-lg);
}
.user-dropdown button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: var(--text-primary); padding: 11px 15px; font-size: 12.5px; cursor: pointer;
}
.user-dropdown button:hover { background: var(--bg-panel-alt); }

.bell-btn {
  position: relative;
  background: var(--bg-panel-alt); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 10px;
  font-size: 15px; cursor: pointer; color: var(--text-dim);
}
.bell-btn:hover { color: var(--text-primary); }

.bell-badge {
  position: absolute;
  top: -5px; right: -5px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 8px;
  line-height: 1.3;
  font-family: var(--font-mono);
}

/* ================= Views ================= */

.view { flex: 1; overflow-y: auto; padding: 22px 26px; }
#view-map { display: flex; padding: 0; overflow: hidden; }

.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.view-header h1 { font-size: 18px; margin: 0; font-weight: 700; }

.btn-primary {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 9px 16px; font-size: 12.5px; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-block;
}
.btn-primary:hover { background: var(--accent-dark); }

/* ================= Dashboard hero header ================= */

.dash-hero { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.dash-hero-title { font-size: 22px; font-weight: 800; margin: 0 0 4px; }
.dash-hero-date { font-size: 12.5px; color: var(--text-dim); margin: 0; }

/* ================= Dashboard stat cards ================= */

.cards-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }

.stat-card {
  flex: 1; min-width: 130px;
  border: none; border-radius: 12px;
  padding: 16px 18px; color: #fff;
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.stat-icon { font-size: 20px; margin-bottom: 6px; opacity: 0.9; }
.stat-card.c-all { background: linear-gradient(135deg, var(--purple), #7b1fa2); }
.stat-card.c-running { background: linear-gradient(135deg, var(--success), #2e7d32); }
.stat-card.c-idling { background: linear-gradient(135deg, var(--warn), #f57c00); }
.stat-card.c-stopped { background: linear-gradient(135deg, var(--danger), #c2185b); }
.stat-card.c-offline { background: linear-gradient(135deg, #607d8b, #455a64); }
.stat-card.c-towed { background: linear-gradient(135deg, #d81b60, #ad1457); }

.stat-num { font-size: 26px; font-weight: 700; font-family: var(--font-mono); }
.stat-label { font-size: 11px; opacity: 0.92; margin-top: 3px; font-weight: 500; }

.dash-columns-featured .dash-col { min-height: 260px; }

.dash-columns { display: flex; gap: 18px; flex-wrap: wrap; }
.dash-col {
  flex: 1; min-width: 320px;
  background: var(--bg-panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px;
  box-shadow: var(--shadow);
}
.dash-col.dash-col-narrow { flex: 0 0 260px; min-width: 260px; }
.dash-col h2 { font-size: 13.5px; margin: 0 0 14px; font-weight: 700; }

.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.donut-chart {
  width: 160px; height: 160px; border-radius: 50%;
  background: conic-gradient(var(--line) 0deg 360deg); /* fallback when no data */
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.donut-chart::after {
  content: ''; position: absolute; width: 96px; height: 96px; border-radius: 50%;
  background: var(--bg-panel);
}
.donut-center { position: relative; z-index: 1; text-align: center; }
.donut-center .num { font-size: 22px; font-weight: 800; font-family: var(--font-mono); }
.donut-center .lbl { font-size: 9.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.donut-legend { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.donut-legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.donut-legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.donut-legend-item .legend-label { flex: 1; color: var(--text-dim); }
.donut-legend-item .legend-val { font-weight: 700; font-family: var(--font-mono); }

.mini-device-list, .mini-alert-list { max-height: 340px; overflow-y: auto; }

.mini-row {
  display: flex; justify-content: space-between; padding: 9px 0;
  border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.mini-row:last-child { border-bottom: none; }
.mini-row-clickable { cursor: pointer; border-radius: 6px; padding-left: 8px; padding-right: 8px; margin: 0 -8px; }
.mini-row-clickable:hover { background: var(--bg-panel-alt); }

/* Simple CSS bar chart */
.bar-chart { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.bar-chart-row { display: flex; align-items: center; gap: 10px; font-size: 11.5px; }
.bar-chart-label { width: 90px; flex-shrink: 0; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-chart-track { flex: 1; background: var(--bg-panel-alt); border-radius: 4px; height: 16px; position: relative; overflow: hidden; }
.bar-chart-fill { background: var(--accent); height: 100%; border-radius: 4px; transition: width 0.3s; }
.bar-chart-value { width: 56px; text-align: right; font-family: var(--font-mono); color: var(--text-primary); font-weight: 600; flex-shrink: 0; }

/* ================= Search / filter ================= */

.search-row { padding: 16px 18px 0; }
.search-row input, .filter-row input, .filter-row select {
  width: 100%; background: var(--bg-panel-alt); border: 1px solid var(--line);
  color: var(--text-primary); border-radius: 6px; padding: 9px 11px; font-size: 12.5px; box-sizing: border-box;
}
.search-row input:focus, .filter-row input:focus { outline: none; border-color: var(--accent); background: #fff; }

.filter-row { display: flex; gap: 10px; margin-bottom: 16px; }
.filter-row input { flex: 1; }
.filter-row select { width: 180px; }

/* ================= Data tables ================= */

.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; background: var(--bg-panel); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
.data-table th {
  text-align: left; color: var(--text-dim); font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.03em; padding: 12px 14px; border-bottom: 1px solid var(--line);
  background: var(--bg-panel-alt);
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--line); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-panel-alt); }

.icon-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 13px; padding: 4px 6px; }
.icon-btn:hover { color: var(--text-primary); }

.badge { font-size: 10px; padding: 3px 9px; border-radius: 10px; font-family: var(--font-mono); font-weight: 600; }
.badge.active { background: var(--success-bg); color: var(--success); }
.badge.inactive { background: var(--danger-bg); color: var(--danger); }

/* ================= Report cards ================= */

.report-section { margin-bottom: 28px; }
.report-section-title { font-size: 14px; font-weight: 700; margin: 0 0 14px; color: var(--text-primary); }
.report-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.report-card { background: var(--bg-panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; box-shadow: var(--shadow); cursor: pointer; transition: box-shadow 0.15s, transform 0.15s; }
.report-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.report-icon {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 12px;
}
.icon-blue { background: #e3f2fd; }
.icon-green { background: #e6f4ea; }
.icon-purple { background: #f3e5f7; }
.icon-teal { background: #e0f7f5; }
.icon-slate { background: #eef1f5; }
.icon-orange { background: #fff4e0; }
.icon-red { background: #fde8ec; }
.icon-yellow { background: #fff9db; }
.report-card h3 { font-size: 13.5px; margin: 0 0 8px; font-weight: 700; }
.report-card p { font-size: 11.5px; color: var(--text-dim); line-height: 1.5; margin: 0 0 14px; }

/* ================= Modal ================= */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16, 24, 40, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 2000;
}
.modal {
  width: 400px; max-height: 84vh; overflow-y: auto;
  background: var(--bg-panel); border-radius: 12px; padding: 24px;
  box-shadow: var(--shadow-lg);
}
.modal.modal-wide { width: min(920px, 92vw); }
.modal h2 { font-size: 15px; margin: 0 0 18px; font-weight: 700; }
.modal .field-row label { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.modal .field-row input, .modal .field-row select {
  width: 100%; background: var(--bg-panel-alt); border: 1px solid var(--line);
  color: var(--text-primary); border-radius: 6px; padding: 9px 11px; font-size: 12.5px; box-sizing: border-box;
}
.modal .field-row { margin-bottom: 13px; padding-bottom: 0; border: none; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.modal-actions button {
  padding: 9px 18px; border-radius: 6px; font-size: 12.5px; cursor: pointer; border: 1px solid var(--line);
  background: none; color: var(--text-primary); font-weight: 500;
}
.modal-actions button.primary { background: var(--accent); color: #fff; border: none; font-weight: 600; }

.close-x {
  position: absolute; top: 18px; right: 18px; background: none; border: none;
  color: var(--text-dim); cursor: pointer; font-size: 16px;
}
.close-x:hover { color: var(--text-primary); }

/* Report modal filter row */
.report-filters { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.report-filters .field-row { margin-bottom: 0; min-width: 130px; }
.report-filters button.primary {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 9px 16px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}

/* ================= Sidebar (Live Map) ================= */

.sidebar {
  width: 330px; flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 16px 0;
}

.status-line {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  padding: 10px 18px 4px;
}
.status-line.live { color: var(--success); font-weight: 600; }
.status-line.live::before { content: "● "; }

.device-list { flex: 1; overflow-y: auto; padding: 8px 0; }

.empty-hint { color: var(--text-faint); font-size: 12.5px; line-height: 1.5; padding: 20px; }

.device-card { padding: 12px 18px; border-bottom: 1px solid var(--line); cursor: pointer; }
.device-card:hover { background: var(--bg-panel-alt); }
.device-card.selected { background: var(--accent-bg); border-left: 3px solid var(--accent); }

.device-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.device-name { font-size: 13px; font-weight: 600; }
.device-dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd2db; flex-shrink: 0; }
.device-dot.online { background: var(--success); box-shadow: 0 0 5px var(--success); }

.device-imei { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); }
.device-meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); margin-top: 5px; display: flex; gap: 10px; }

.status-chips { display: flex; gap: 5px; margin-top: 6px; }
.status-chip {
  font-size: 9px; padding: 2px 6px; border-radius: 4px; font-weight: 600; font-family: var(--font-mono);
  background: transparent; color: var(--text-faint); border: 1px solid var(--line);
}
.status-chip.on { background: transparent; color: var(--success); border-color: var(--success); }
.status-chip.off { background: transparent; color: var(--danger); border-color: var(--danger); }

/* ---- Redesigned device card (v2) ---- */

.device-card2 {
  position: relative; display: flex; cursor: pointer;
  border-bottom: 1px solid var(--line); transition: background 0.15s;
  overflow: hidden;
}
.device-card2:hover { background: var(--bg-panel-alt); }
.device-card2.selected { background: var(--accent-bg); }
.device-card2-accent { width: 3px; flex-shrink: 0; background: transparent; }
.device-card2.selected .device-card2-accent { background: var(--accent-dark, #1976d2); }

.device-card2-body { display: flex; gap: 12px; padding: 14px 16px; flex: 1; min-width: 0; }
.device-avatar {
  width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-panel-alt); border: 1px solid var(--line);
}
.device-card2.selected .device-avatar { background: var(--bg-panel); border-color: var(--accent); }
.device-avatar::after {
  content: ''; position: absolute; top: -3px; right: -3px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--dot, var(--text-faint)); border: 2px solid var(--bg-panel);
}
.device-card2-main { flex: 1; min-width: 0; }
.device-card2-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 2px; }
.device-card2-top .device-name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-status-pill {
  font-size: 9.5px; font-weight: 600; padding: 3px 9px; border-radius: 10px;
  border: 1px solid; white-space: nowrap; flex-shrink: 0;
}
.device-speed-row { display: flex; align-items: baseline; justify-content: space-between; margin: 6px 0 2px; }
.device-speed-big { font-family: var(--font-mono); font-size: 20px; font-weight: 800; color: var(--text-primary); }
.device-speed-big small { font-size: 10px; font-weight: 500; color: var(--text-dim); margin-left: 3px; }
.device-speed-big.over-limit { color: var(--danger); }
.device-lastseen { font-size: 10px; color: var(--text-dim); }

/* ================= Map area ================= */

.map-wrap { flex: 1; position: relative; }
#map { width: 100%; height: 100%; background: #dde5ec; }
.leaflet-container { background: #dde5ec; font-family: var(--font-ui); }

/* ================= Detail panel ================= */

.panel {
  position: absolute; top: 16px; right: 16px; width: 384px;
  background: var(--bg-panel); border-radius: 12px; padding: 0;
  box-shadow: var(--shadow-lg); z-index: 1000; max-height: calc(100% - 32px); overflow-y: auto;
}

.panel-header {
  padding: 16px 18px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
}
.panel-header h2 { font-size: 14px; margin: 0; font-weight: 700; }
.close-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 14px; }
.close-btn:hover { color: var(--text-primary); }

.panel-body { padding: 16px 18px; }

.status-pill {
  display: inline-block; padding: 4px 12px; border-radius: 14px; font-size: 11px; font-weight: 700;
  margin-bottom: 12px;
}
.status-pill.online { background: var(--success-bg); color: var(--success); }
.status-pill.offline { background: var(--danger-bg); color: var(--danger); }

.tabs { display: flex; gap: 0; margin-bottom: 14px; border-bottom: 1px solid var(--line); padding: 0 10px; overflow: visible; }
.tab-btn {
  background: none; border: none; color: var(--text-dim); font-size: 11.5px; font-weight: 500;
  padding: 10px 4px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
  flex: 1; text-align: center; min-width: 0;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.tab-panel { padding: 0 18px 16px; }

.panel-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.panel-row span:first-child { color: var(--text-dim); }
.panel-row span:last-child { font-weight: 500; text-align: right; }

/* Activity summary card */
.activity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.activity-cell { background: var(--bg-panel-alt); border-radius: 8px; padding: 12px; text-align: center; }
.activity-cell .val { font-size: 18px; font-weight: 700; font-family: var(--font-mono); color: var(--text-primary); }
.activity-cell .lbl { font-size: 10px; color: var(--text-dim); margin-top: 3px; }
.activity-cell.wide { grid-column: 1 / -1; }

/* ================= Controls tab ================= */

.field-row { margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.field-row label { display: block; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 8px; font-weight: 600; }

.inline-input { display: flex; gap: 6px; align-items: center; }
.inline-input input {
  flex: 1; background: var(--bg-panel-alt); border: 1px solid var(--line); color: var(--text-primary);
  border-radius: 6px; padding: 7px 9px; font-family: var(--font-mono); font-size: 12px; width: 0;
}
.inline-input .unit { font-size: 11px; color: var(--text-dim); }

.inline-input button, .field-row > button, .geofence-controls button {
  background: var(--accent-bg); border: 1px solid var(--accent); color: var(--accent);
  border-radius: 6px; padding: 7px 11px; font-size: 11px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.inline-input button:hover, .field-row > button:hover, .geofence-controls button:hover { background: var(--accent); color: #fff; }

.toggle-btn { background: var(--bg-panel-alt); border: 1px solid var(--line); color: var(--text-primary); border-radius: 6px; padding: 7px 15px; font-size: 11px; cursor: pointer; }
.toggle-btn.on { border-color: var(--success); color: var(--success); background: var(--success-bg); }

.geofence-controls { display: flex; flex-direction: column; gap: 8px; }

.danger-zone .hint-text { font-size: 10.5px; color: var(--warn); line-height: 1.5; margin: 0 0 10px; }
.button-row { display: flex; gap: 8px; }
.btn-danger, .btn-safe { flex: 1; padding: 9px; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer; border: 1px solid; }
.btn-danger { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-safe { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.btn-safe:hover { background: var(--success); color: #fff; }

.status-text { font-size: 10.5px; color: var(--text-dim); margin: 8px 0 0; font-family: var(--font-mono); }

/* ================= History tab ================= */

.history-controls { display: flex; gap: 8px; margin-bottom: 12px; }
.history-controls button { background: var(--accent-bg); border: 1px solid var(--accent); color: var(--accent); border-radius: 6px; padding: 7px 11px; font-size: 11px; font-weight: 600; cursor: pointer; }

.history-item { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); padding: 7px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; }

.playback-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-panel-alt); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; margin-bottom: 12px;
}
.playback-play-btn {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #fff; border: none; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.playback-info { flex: 1; min-width: 0; }
.playback-time { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.playback-progress-track { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.playback-progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.15s linear; }
#playbackSpeed { flex-shrink: 0; background: var(--bg-panel); border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; font-size: 11px; color: var(--text-primary); }

/* ================= Alerts panel ================= */

.alerts-panel {
  position: absolute; top: 16px; right: 16px; width: 330px; max-height: 78vh;
  background: var(--bg-panel); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 1100;
  display: flex; flex-direction: column;
}
.alerts-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.alerts-header h2 { font-size: 14px; margin: 0; font-weight: 700; }
.alerts-list { overflow-y: auto; padding: 8px 0; }

.alert-item { padding: 11px 18px; border-bottom: 1px solid var(--line); font-size: 11.5px; }
.alert-item .alert-type { font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--warn); margin-bottom: 3px; font-weight: 700; }
.alert-item.type-speed .alert-type, .alert-item.type-continuous_overspeed .alert-type { color: var(--warn); }
.alert-item.type-geofence_enter .alert-type, .alert-item.type-geofence_exit .alert-type { color: var(--accent); }
.alert-item.type-ignition_on .alert-type, .alert-item.type-ignition_off .alert-type { color: var(--success); }
.alert-item.type-alarm .alert-type, .alert-item.type-sos .alert-type, .alert-item.type-tamper .alert-type, .alert-item.type-power_cut .alert-type { color: var(--danger); }

.alert-item .alert-msg { color: var(--text-primary); margin-bottom: 3px; font-weight: 500; }
.alert-item .alert-time { color: var(--text-faint); font-family: var(--font-mono); font-size: 10px; }

/* ================= Toasts ================= */

.toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column-reverse; gap: 8px; z-index: 1200; }
.toast {
  background: #fff; border: 1px solid var(--warn); color: var(--text-primary); padding: 11px 15px;
  border-radius: 8px; font-size: 12px; max-width: 300px; box-shadow: var(--shadow-lg); animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Map popup mini card (on marker click) */
.map-popup-card {
  background: #fff; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-lg);
  width: 260px; font-size: 12px;
}
.map-popup-card .header { background: var(--danger); color: #fff; padding: 10px 14px; font-weight: 700; font-size: 13px; }
.map-popup-card .header.online { background: var(--success); }
.map-popup-card .body { padding: 12px 14px; }
.map-popup-card .row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 11.5px; }
.map-popup-card .row span:first-child { color: var(--text-dim); }

@media (max-width: 640px) {
  .topbar-left { gap: 12px; }
  .nav-tabs { overflow-x: auto; }
  .cards-row { flex-direction: column; }
  .dash-columns { flex-direction: column; }
  .sidebar { width: 100%; position: absolute; z-index: 900; height: 40%; bottom: 0; top: auto; border-right: none; border-top: 1px solid var(--line); }
  .map-wrap { height: 60%; }
  .panel, .alerts-panel { top: auto; bottom: 16px; right: 10px; left: 10px; width: auto; max-height: 60vh; }
}

.export-btn-group { display: flex; gap: 6px; }
.export-btn-group .btn-primary { padding: 7px 12px; font-size: 11px; }

/* ================= Icon status badges & quick actions ================= */

.icon-badge-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.icon-badge {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px; border-radius: 9px; min-width: 0;
  background: var(--bg-panel-alt); border: 1px solid transparent;
}
.icon-badge-icon { font-size: 15px; line-height: 1; filter: grayscale(1); opacity: 0.45; }
.icon-badge-label { font-size: 9.5px; font-weight: 600; letter-spacing: 0.03em; color: var(--text-faint); }
.icon-badge.on .icon-badge-icon { filter: none; opacity: 1; }
.icon-badge.on .icon-badge-label { color: var(--success); }
.icon-badge.off .icon-badge-icon { filter: none; opacity: 1; }
.icon-badge.off .icon-badge-label { color: var(--danger); }
.icon-badge.unknown { opacity: 0.55; }

.quick-action-row { display: flex; gap: 6px; margin-bottom: 14px; }
.quick-action-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: var(--bg-panel-alt); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 4px; cursor: pointer; font-size: 16px; color: var(--text-primary);
  transition: background 0.15s, border-color 0.15s;
}
.quick-action-btn:hover { background: var(--accent-bg); border-color: var(--accent); }
.quick-action-btn span { font-size: 9px; font-weight: 600; color: var(--text-dim); }
.quick-action-row { flex-wrap: wrap; }

/* ================= Map vertical toolbar ================= */

.map-toolbar {
  position: absolute; top: 12px; right: 12px; z-index: 900;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--bg-panel); border-radius: 10px; padding: 4px;
  box-shadow: var(--shadow);
}
.map-tool-btn {
  width: 38px; height: 38px; border-radius: 8px; border: none;
  background: transparent; color: var(--text-primary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.1s;
}
.map-tool-btn:hover { background: var(--accent-bg); transform: scale(1.05); }
.map-tool-btn.active { background: var(--accent); color: #fff; }

/* ================= Dashboard trend chart (7-day distance) ================= */

.trend-chart { padding: 8px 0; }
.trend-bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding: 0 4px; }
.trend-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.trend-bar-value { font-size: 10px; font-weight: 700; color: var(--text-primary); font-family: var(--font-mono); margin-bottom: 4px; }
.trend-bar { width: 100%; border-radius: 6px 6px 2px 2px; min-height: 4px; transition: height 0.3s; box-shadow: 0 2px 6px rgba(0,0,0,0.12); }
.trend-bar-label { font-size: 10px; color: var(--text-dim); margin-top: 6px; font-weight: 600; }

/* ================= Clickable dashboard cards & filter banner ================= */

.clickable-card { cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.clickable-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.15); }
.donut-legend-item.clickable-card:hover { background: var(--bg-panel-alt); border-radius: 6px; }

.filter-banner {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--accent-bg); color: var(--accent-dark);
  padding: 8px 14px; font-size: 11.5px; font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.filter-banner button {
  background: none; border: 1px solid var(--accent); color: var(--accent-dark);
  border-radius: 5px; padding: 2px 8px; font-size: 10.5px; cursor: pointer; font-weight: 700;
}

/* ================= Clickable data table rows ================= */

tr.report-row-clickable { cursor: pointer; }
tr.report-row-clickable:hover td { background: var(--accent-bg); }

/* ================= Map marker quick popup ================= */

.quick-popup { font-family: var(--font-ui); min-width: 210px; }

.quick-popup-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.quick-popup-title { font-size: 14px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-popup-status { flex-shrink: 0; display: inline-block; font-size: 9.5px; font-weight: 700; color: #fff; padding: 3px 9px; border-radius: 10px; }

.quick-popup-detail-row {
  display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-primary);
  padding: 3px 0;
}
.quick-popup-detail-icon { font-size: 12px; flex-shrink: 0; opacity: 0.8; }

.quick-popup-actions { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.qp-action {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: none; border-radius: 8px; padding: 7px 2px; cursor: pointer;
  transition: transform 0.1s;
}
.qp-action:hover { transform: translateY(-2px); }
.qp-action-icon { font-size: 16px; }
.qp-action-label { font-size: 8px; font-weight: 700; }

.qp-fav { background: #fff4e0; } .qp-fav .qp-action-label { color: #b3760a; }
.qp-history { background: #e3f2fd; } .qp-history .qp-action-label { color: #1565c0; }
.qp-locate { background: #e6f4ea; } .qp-locate .qp-action-label { color: #2e7d32; }
.qp-driver { background: #f3e5f7; } .qp-driver .qp-action-label { color: #7b1fa2; }
.qp-share { background: #fde8ec; } .qp-share .qp-action-label { color: #c2185b; }
.qp-navigate { background: #e0f7f5; } .qp-navigate .qp-action-label { color: #00796b; }

.leaflet-popup.quick-popup-wrap .leaflet-popup-content-wrapper { border-radius: 12px; padding: 4px; }
.leaflet-popup.quick-popup-wrap .leaflet-popup-content { margin: 12px 14px; }

/* ================= Alerts sub-tabs ================= */

.alerts-subtabs { display: flex; gap: 4px; padding: 8px 14px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.alerts-subtab {
  background: none; border: 1px solid var(--line); color: var(--text-dim);
  font-size: 10.5px; font-weight: 600; padding: 5px 10px; border-radius: 12px;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.alerts-subtab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ================= Manage Devices modal ================= */

.manage-device-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.manage-device-row:last-child { border-bottom: none; }

/* ================= Gauge chart (Fleet Utilization) ================= */

.gauge-card { display: flex; flex-direction: column; align-items: center; }
.gauge-wrap { position: relative; width: 200px; margin: 8px auto 0; }
.gauge-svg { width: 100%; }
.gauge-center {
  position: absolute; top: 62%; left: 50%; transform: translate(-50%, -50%);
  text-align: center;
}
.gauge-value { font-size: 26px; font-weight: 800; font-family: var(--font-mono); color: var(--text-primary); }
.gauge-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; margin-top: 2px; }

/* ================= Modal tabs (used in Vehicle add/edit) ================= */

.modal-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.modal-tab-btn {
  background: none; border: none; color: var(--text-dim); font-size: 11px; font-weight: 600;
  padding: 8px 10px; cursor: pointer; border-bottom: 2px solid transparent;
}
.modal-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.modal-tab-panel { min-height: 180px; }

/* ================= App Settings: notification checkboxes & analog speedo ================= */

.checkbox-list { max-height: 320px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 6px; font-size: 11.5px; padding: 4px 0; cursor: pointer; }
.checkbox-row input { cursor: pointer; }

.analog-speedo { display: flex; flex-direction: column; align-items: center; margin-bottom: 10px; }
.analog-speedo-value { font-family: var(--font-mono); font-size: 18px; font-weight: 800; margin-top: -6px; }
.analog-speedo-value small { font-size: 10px; font-weight: 500; color: var(--text-dim); }

/* ================= Login language switcher ================= */

.login-lang-switch {
  margin-top: 14px; width: 100%; padding: 8px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg-panel-alt); color: var(--text-primary);
  font-size: 11.5px; font-family: var(--font-ui);
}

/* ================= Announcement banners & management ================= */

#announcementBannerStack { display: flex; flex-direction: column; }
.announcement-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-left: 4px solid;
  font-size: 12.5px; color: var(--text-primary);
}
.announcement-banner-icon { font-size: 15px; flex-shrink: 0; }
.announcement-banner-text { flex: 1; line-height: 1.4; }
.announcement-banner-close {
  background: none; border: none; font-size: 13px; cursor: pointer;
  color: var(--text-dim); flex-shrink: 0; padding: 2px 6px; border-radius: 4px;
}
.announcement-banner-close:hover { background: rgba(0,0,0,0.08); }

.announcement-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.announcement-row:last-child { border-bottom: none; }

/* ================= Diagnostics & Support Tickets ================= */

.diag-summary {
  display: flex; justify-content: space-between; align-items: center;
  border: 1.5px solid; border-radius: 8px; padding: 10px 12px; margin-bottom: 10px;
  font-size: 12px;
}
.diag-row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.diag-row:last-child { border-bottom: none; }
.diag-row-top { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; }
.diag-row-detail { font-size: 10.5px; color: var(--text-dim); margin-top: 2px; line-height: 1.4; }

.ticket-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.ticket-row:last-child { border-bottom: none; }
.ticket-row-top { display: flex; justify-content: space-between; align-items: center; }
.ticket-status-select { font-size: 10.5px; font-weight: 700; border: none; background: none; cursor: pointer; }

/* ================= Clickable alert items (show location) ================= */

.alert-item-clickable { cursor: pointer; }
.alert-item-clickable:hover { background: var(--accent-bg); }

/* ================= Smooth marker movement ================= */
/* Leaflet positions markers via CSS transform (translate3d). Without a
   transition, every location update makes the marker instantly "teleport"
   to the new spot instead of gliding there - this is what made live
   tracking feel jerky/manual. This animates position changes smoothly. */
.vehicle-marker-icon {
  transition: transform 0.9s linear;
}

/* ================= Dashboard search ================= */

.dash-hero { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; }
.dash-search-wrap { position: relative; min-width: 280px; }
.dash-search-wrap input {
  width: 100%; padding: 9px 14px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 12.5px; font-family: var(--font-ui); background: var(--bg-panel);
}
.dash-search-results {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px;
  background: var(--bg-panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; z-index: 50;
}
.dash-search-result { padding: 9px 14px; font-size: 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.dash-search-result:last-child { border-bottom: none; }
.dash-search-result:hover { background: var(--accent-bg); }


/* ================= Unified tracking design ================= */

:root { --brand: #c94a28; --brand-bg: #faece7; --brand-dark: #993c1d; }
body.dark-theme { --brand: #e05a30; --brand-bg: #3a1c12; --brand-dark: #f0997b; }

.status-pills { display: flex; gap: 6px; padding: 8px 16px 4px; flex-wrap: wrap; }
.sp {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg-panel); border: 1px solid var(--line); border-radius: 11px;
  padding: 3px 10px; font-size: 11px; font-weight: 500; color: var(--text-dim);
  cursor: pointer; font-family: var(--font-ui);
}
.sp i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.sp:hover { border-color: var(--text-faint); }
.sp.active { background: var(--text-primary); border-color: var(--text-primary); color: var(--bg-panel); }

.day-timeline { grid-column: 1 / -1; margin-top: 2px; }
.day-bar { display: flex; height: 9px; border-radius: 5px; overflow: hidden; background: var(--bg-panel-alt); }
.day-bar span { display: block; height: 100%; }
.day-legend { display: flex; gap: 12px; margin-top: 7px; flex-wrap: wrap; }
.day-legend span { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-dim); }
.day-legend i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }
.nav-tab.active { background: var(--brand-bg); color: var(--brand-dark); }

.quick-popup { font-family: var(--font-ui); min-width: 226px; }
.quick-popup-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.qp-icon {
  width: 32px; height: 32px; border-radius: 9px; background: var(--brand-bg);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.qp-icon svg { width: 22px; height: 22px; }
.qp-head-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.quick-popup-title { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qp-sub { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.qp-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.qp-address {
  font-size: 11.5px; color: var(--text-dim); line-height: 1.5;
  border-top: 1px solid var(--line); padding-top: 9px;
}
.quick-popup-actions {
  display: flex; gap: 6px; margin-top: 11px;
  border-top: 1px solid var(--line); padding-top: 11px;
}
.qp-action {
  flex: 1; background: var(--bg-panel-alt); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 4px; cursor: pointer;
  font-family: var(--font-ui); font-size: 11px; font-weight: 500; color: var(--text-primary);
}
.qp-action:hover { border-color: var(--text-faint); }
.qp-action.qp-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.qp-action.qp-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.panel-header h2 { display: grid; grid-template-columns: auto 1fr; gap: 2px 11px; align-items: center; }
.panel-veh-icon {
  grid-row: 1 / 3; width: 36px; height: 36px; border-radius: 10px; background: var(--brand-bg);
  display: flex; align-items: center; justify-content: center;
}
.panel-veh-icon svg { width: 24px; height: 24px; }
.panel-veh-name { font-size: 14px; font-weight: 700; }
.panel-veh-imei { font-family: var(--font-mono); font-size: 11px; font-weight: 400; color: var(--text-faint); }

/* ---- Info tab rebuilt to match the design ---- */

.speed-hero { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 16px; }
.speed-hero-num { font-family: var(--font-mono); font-size: 42px; font-weight: 800; line-height: 1; color: var(--text-primary); }
.speed-hero-num span { font-family: var(--font-ui); font-size: 13px; font-weight: 500; color: var(--text-dim); margin-left: 7px; }
.speed-hero-num.over { color: var(--danger); }
.speed-limit-chip {
  font-size: 11px; color: var(--text-faint); background: var(--bg-panel-alt);
  padding: 5px 11px; border-radius: 7px; white-space: nowrap;
}

.stat-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-bottom: 18px; }
.stat-tile {
  background: var(--bg-panel-alt); border-radius: 11px; padding: 11px 4px 9px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0;
  color: var(--text-faint);
}
.stat-tile svg { width: 20px; height: 20px; }
.stat-tile b { font-size: 11.5px; font-weight: 600; color: var(--text-dim); white-space: nowrap; }
.stat-tile i { font-size: 10.5px; font-style: normal; color: var(--text-faint); }
.stat-tile.ok { color: var(--success); }
.stat-tile.ok b { color: var(--success); }
.stat-tile.bad { color: var(--danger); }
.stat-tile.bad b { color: var(--danger); }

.today-block { margin-bottom: 16px; }
.today-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.today-head span { font-size: 12px; color: var(--text-faint); }
.today-head b { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.today-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 9px; }

.panel-row { padding: 10px 0; font-size: 12.5px; }
.panel-row.addr-row { flex-direction: column; align-items: flex-start; gap: 4px; }
.panel-row.addr-row span:last-child { text-align: left; font-weight: 400; color: var(--text-primary); }

.quick-action-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 18px 0 4px; }
.quick-action-btn {
  flex-direction: row; justify-content: center; padding: 9px 4px;
  background: var(--bg-panel); border: 1px solid var(--line); border-radius: 9px;
  font-family: var(--font-ui); font-size: 11.5px; font-weight: 500; color: var(--text-primary);
}
.quick-action-btn:hover { background: var(--bg-panel-alt); border-color: var(--text-faint); }
.quick-action-btn.qa-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.quick-action-btn.qa-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.form-error {
  background: var(--danger-bg); color: var(--danger);
  border: 1px solid var(--danger); border-radius: 8px;
  padding: 10px 12px; margin: 12px 0 0; font-size: 12.5px; line-height: 1.5;
}

/* LIVE / DELAYED / stale position indicator */
.gps-freshness {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 500; padding: 3px 9px;
  border-radius: 11px; white-space: nowrap; margin-left: 8px;
}
.gps-freshness::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor;
}
.gps-freshness.live { background: var(--success-bg); color: var(--success); }
.gps-freshness.delayed { background: var(--warn-bg, #fff4e0); color: var(--warn, #ffa000); }
.gps-freshness.stale, .gps-freshness.unknown { background: var(--bg-panel-alt); color: var(--text-faint); }

/* Developer diagnostics panel (Ctrl+Shift+D) */
.debug-panel {
  position: fixed; right: 12px; bottom: 12px; z-index: 4000;
  width: 330px; max-height: 78vh; overflow: auto;
  background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  font-family: var(--font-mono); font-size: 11px;
}
.debug-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: var(--bg-panel); border-radius: 12px 12px 0 0;
}
.debug-head strong { font-family: var(--font-ui); font-size: 12px; }
.debug-head span { color: var(--text-faint); flex: 1; overflow: hidden; text-overflow: ellipsis; }
.debug-head button {
  background: none; border: 1px solid var(--line); border-radius: 6px;
  padding: 2px 8px; cursor: pointer; font-size: 10px; color: var(--text-dim);
}
.debug-empty { padding: 16px; color: var(--text-faint); font-family: var(--font-ui); }
.debug-table { width: 100%; border-collapse: collapse; }
.debug-table th {
  text-align: left; font-weight: 400; color: var(--text-faint);
  padding: 4px 12px; font-family: var(--font-ui); white-space: nowrap;
}
.debug-table td { padding: 4px 12px; text-align: right; color: var(--text-primary); }
.debug-table td.ok { color: var(--success); }
.debug-table td.warn { color: var(--danger); }
.debug-log { border-top: 1px solid var(--line); padding: 8px 12px; }
.debug-log div { padding: 3px 0; color: var(--text-dim); line-height: 1.4; }
.debug-log span { color: var(--text-faint); }
.debug-log b { color: var(--text-accent); font-weight: 600; }
