:root {
  --bg: #f4f5f7; --panel: #ffffff; --ink: #14171f; --muted: #6b7280; --line: #e5e7eb;
  --accent: #1d4ed8; --accent-soft: #e8eefc; --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --idle: #9ca3af;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.06);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.btn { white-space: nowrap; border: 1px solid var(--line); background: var(--panel); padding: 7px 12px; border-radius: 8px; font-weight: 500; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1e40af; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.icon { padding: 6px; width: 34px; height: 34px; justify-content: center; }
input[type=text], input[type=password], input[type=datetime-local], input[type=search], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { font-size: 13px; color: var(--muted); display: block; margin: 10px 0 4px; }

/* Layout */
.app { display: grid; grid-template-rows: 54px 1fr; grid-template-columns: 330px 1fr; height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 1001; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand svg { width: 26px; height: 26px; }
.topbar .spacer { flex: 1; }
.live { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); }
.live.on .dot { background: #22c55e; box-shadow: 0 0 0 3px #dcfce7; }
.bell { position: relative; }
.bell .count { position: absolute; top: -4px; right: -4px; background: var(--bad); color: #fff; border-radius: 9px; font-size: 11px; min-width: 18px; height: 18px; display: none; align-items: center; justify-content: center; padding: 0 4px; font-weight: 600; }
.bell.has .count { display: flex; }

.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { padding: 12px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; }
.summary { display: flex; gap: 14px; padding: 10px 14px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.summary b { color: var(--ink); font-size: 14px; }
.devices { overflow-y: auto; flex: 1; }
.dev { display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; padding: 11px 14px; border-bottom: 1px solid #f1f2f4; cursor: pointer; align-items: center; }
.dev:hover { background: #fafbfc; }
.dev.sel { background: var(--accent-soft); }
.dev .sw { width: 12px; height: 12px; border-radius: 50%; }
.dev .nm { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.dev .right { text-align: right; font-size: 12px; color: var(--muted); }
.pill { display: inline-block; padding: 2px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.pill.moving { background: #dcfce7; color: var(--ok); }
.pill.online { background: #dbeafe; color: var(--accent); }
.pill.offline { background: #f3f4f6; color: var(--muted); }
.pill.never { background: #fef3c7; color: var(--warn); }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.5; }

.mapwrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; }
.map-tools { position: absolute; top: 12px; right: 12px; z-index: 600; display: flex; flex-direction: column; gap: 6px; }
.map-tools .btn { box-shadow: var(--shadow); }

/* Detail drawer */
.drawer { position: absolute; top: 12px; left: 12px; bottom: 12px; width: 360px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 700; display: none; flex-direction: column; overflow: hidden; }
.drawer.open { display: flex; }
.drawer-head { padding: 14px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 10px; }
.drawer-head h2 { margin: 0; font-size: 17px; }
.drawer-head .sub { font-size: 12px; color: var(--muted); margin-top: 3px; word-break: break-all; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; background: none; padding: 10px 0; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.drawer-body { overflow-y: auto; padding: 14px; flex: 1; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: #f8f9fb; border-radius: 8px; padding: 9px 10px; }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 16px; font-weight: 600; margin-top: 2px; }
.kv { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px; }
.kv td { padding: 6px 0; border-bottom: 1px solid #f1f2f4; vertical-align: top; }
.kv td:first-child { color: var(--muted); width: 45%; }
.section-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 18px 0 6px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.hist-summary { margin-top: 12px; font-size: 13px; background: #f8f9fb; border-radius: 8px; padding: 10px; display: none; }
.player { display: none; margin-top: 10px; }
.player input[type=range] { width: 100%; }
.player .t { font-size: 12px; color: var(--muted); }
.cmdlog { margin-top: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.cmdlog div { padding: 6px 8px; border-radius: 6px; margin-bottom: 4px; background: #f8f9fb; word-break: break-all; }
.cmdlog .out { background: var(--accent-soft); }
.cmdlog .ts { color: var(--muted); font-size: 11px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.note { font-size: 12px; color: var(--muted); line-height: 1.5; }
.warn-box { background: #fef3c7; color: #78350f; border-radius: 8px; padding: 9px 10px; font-size: 12px; margin-top: 10px; }

/* Alarms panel */
.alarms { position: absolute; top: 12px; right: 60px; width: 360px; max-height: calc(100% - 24px); background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 800; display: none; flex-direction: column; }
.alarms.open { display: flex; }
.alarms-head { display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); gap: 8px; }
.alarms-head h3 { margin: 0; font-size: 15px; flex: 1; }
.alarm-list { overflow-y: auto; }
.alarm { padding: 10px 14px; border-bottom: 1px solid #f1f2f4; display: grid; grid-template-columns: 1fr auto; gap: 4px; font-size: 13px; cursor: pointer; }
.alarm.new { background: #fef2f2; }
.alarm .an { font-weight: 600; }
.alarm.sos .an { color: var(--bad); }
.alarm .ad { color: var(--muted); font-size: 12px; }

/* Toasts */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #111827; color: #fff; padding: 11px 14px; border-radius: 9px; font-size: 14px; box-shadow: var(--shadow); max-width: 360px; animation: in .2s ease-out; }
.toast.alarm { background: var(--bad); }
@keyframes in { from { transform: translateY(8px); opacity: 0; } }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 2000; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-bg.open { display: flex; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; padding: 20px 22px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal h2 { margin: 0 0 4px; font-size: 19px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; }
.colors button.on { border-color: var(--ink); box-shadow: inset 0 0 0 2px #fff; }
.guide h3 { font-size: 15px; margin: 18px 0 6px; }
.guide p, .guide li { font-size: 14px; line-height: 1.55; }
.guide code { background: #f3f4f6; padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.guide pre { background: #f3f4f6; padding: 10px; border-radius: 8px; overflow-x: auto; font-size: 12.5px; }
.err { color: var(--bad); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* Map markers */
.mk { width: 34px; height: 34px; position: relative; }
.mk .core { position: absolute; left: 7px; top: 7px; width: 20px; height: 20px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.mk .arrow { position: absolute; left: 12px; top: -1px; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 9px solid; transform-origin: 5px 18px; }
.mk.stale .core { opacity: .55; }
.mk.alarm .core { animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(220,38,38,.35); } }
.mk-label { background: #fff; border: 0; border-radius: 6px; padding: 2px 7px; font-weight: 600; font-size: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.leaflet-tooltip.mk-label::before { display: none; }

/* Login / phone tracker pages */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.card { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); padding: 28px; width: 100%; max-width: 380px; }
.card h1 { font-size: 21px; margin: 12px 0 4px; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 54px 40vh 1fr; }
  .sidebar { grid-row: 3; border-right: 0; border-top: 1px solid var(--line); }
  .mapwrap { grid-row: 2; }
  .drawer { position: fixed; inset: auto 0 0 0; top: 30vh; width: auto; border-radius: 14px 14px 0 0; z-index: 1500; }
  .alarms { position: fixed; right: 8px; left: 8px; width: auto; top: 62px; }
  .live span { display: none; }
}

/* Battery card */
.battery { background: #f8f9fb; border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.battery .top { display: flex; align-items: center; gap: 10px; }
.battery .pct { font-size: 24px; font-weight: 700; }
.battery .cell { width: 46px; height: 22px; border: 2px solid #9ca3af; border-radius: 5px; position: relative; padding: 2px; flex: none; }
.battery .cell::after { content: ''; position: absolute; right: -6px; top: 6px; width: 3px; height: 8px; background: #9ca3af; border-radius: 0 2px 2px 0; }
.battery .fill { height: 100%; border-radius: 2px; }
.battery .est { font-size: 13px; color: var(--muted); margin-left: auto; text-align: right; line-height: 1.35; }
.battery .est b { color: var(--ink); }
.battery svg { width: 100%; height: 70px; display: block; margin-top: 8px; }
.battery .axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
/* Trips */
.btn.on-range { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.trip-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.trip-list { margin-top: 12px; }
.trip { border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; margin-bottom: 8px; cursor: pointer; }
.trip:hover { border-color: #c7d2fe; background: #fafbff; }
.trip.sel { border-color: var(--accent); background: var(--accent-soft); }
.trip .when { font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; gap: 8px; }
.trip .meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 12px; flex-wrap: wrap; }
.trip .live { color: var(--ok); font-size: 11px; font-weight: 700; }
.trip-day { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 14px 0 6px; }

/* ===== Black & gray theme ===== */
:root {
  --bg: #F4F4F5; --panel: #FFFFFF; --ink: #18181B; --muted: #52525B; --line: #E4E4E7;
  --accent: #18181B; --accent-soft: #F4F4F5; --idle: #A1A1AA;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); margin: 0; }
.btn.primary { background: #0A0A0B; border-color: #0A0A0B; color: #FAFAFA; }
.btn.primary:hover { background: #27272A; }
input:focus, select:focus, textarea:focus { outline: 2px solid #D4D4D8; border-color: #18181B; }
a { color: #18181B; }

.app { grid-template-rows: 64px 1fr; grid-template-columns: 1fr 400px; }
.topbar { background: #0A0A0B; border-bottom: 0; gap: 22px; padding: 0 18px; color: #FAFAFA; }
.brand { font-family: "Space Grotesk", Inter, sans-serif; font-size: 20px; color: #FAFAFA; gap: 10px; }
.brand .logo { width: 32px; height: 32px; border-radius: 8px; background: #FAFAFA; display: inline-flex; align-items: center; justify-content: center; }
.nav { display: flex; gap: 4px; }
.nav a, .nav button { color: #A1A1AA; background: none; border: 0; text-decoration: none; font-size: 14px; font-weight: 500; padding: 9px 14px; border-radius: 8px; }
.nav a:hover, .nav button:hover { color: #FAFAFA; background: #18181B; }
.nav a.on { color: #0A0A0B; background: #FAFAFA; font-weight: 600; }
.live { color: #A1A1AA; }
.live.on .dot { box-shadow: 0 0 0 3px #14532D; }
.topbar .btn { background: #18181B; border-color: #27272A; color: #FAFAFA; height: 40px; }
.topbar .btn:hover { background: #27272A; }
.topbar .btn.icon { width: 40px; }

.sidebar { grid-column: 2; grid-row: 2; border-right: 0; border-left: 1px solid var(--line); }
.mapwrap { grid-column: 1; grid-row: 2; background: #1C1C1F; }
.side-title { display: flex; align-items: center; gap: 12px; padding: 18px 20px 0; }
.side-title h1 { margin: 0; font-family: "Space Grotesk", Inter, sans-serif; font-size: 26px; letter-spacing: -.02em; flex: 1; }
.chips { display: flex; gap: 8px; padding: 14px 20px 0; flex-wrap: wrap; }
.chip { font-size: 12px; font-weight: 600; padding: 7px 11px; border-radius: 999px; background: #F4F4F5; color: #3F3F46; border: 0; }
.chip.on { background: #18181B; color: #FAFAFA; }
.side-search { padding: 14px 20px; border-bottom: 1px solid var(--line); }
.side-search input { height: 44px; border-radius: 12px; background: #FAFAFA; padding: 0 14px; }
.dev { display: block; width: 100%; text-align: left; font: inherit; color: inherit; background: #FFFFFF; border: 0; border-bottom: 1px solid var(--line); border-left: 4px solid transparent; padding: 15px 20px; }
.dev:hover { background: #FAFAFA; }
.dev.sel { background: #F4F4F5; border-left-color: #0A0A0B; }
.dev .r1 { display: flex; align-items: center; gap: 8px; }
.dev .sdot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dev .nm { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev .upd { margin-left: auto; font-size: 12px; color: #52525B; white-space: nowrap; }
.dev .st { font-size: 15px; font-weight: 600; margin-top: 6px; }
.st-moving { color: #15803D; } .st-online { color: #3F3F46; } .st-offline { color: #52525B; } .st-never { color: #B45309; }
.dev .where { font-size: 13px; color: #3F3F46; margin-top: 4px; font-variant-numeric: tabular-nums; }
.dev .r3 { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 12px; color: #52525B; }
.dev .batt { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; color: #3F3F46; font-size: 13px; }
.dev-alert { margin-top: 8px; padding: 7px 10px; border-radius: 8px; background: #FEF2F2; color: #991B1B; font-size: 13px; font-weight: 600; }

/* dark map tiles */
.tiles-dark { filter: grayscale(1) invert(1) brightness(.88) contrast(.92); }
.tiles-gray { filter: grayscale(1) contrast(.95); }
.leaflet-container { background: #1C1C1F; font-family: inherit; }
.leaflet-bar a, .leaflet-control-layers { background: #0A0A0B; color: #FAFAFA; border-color: #3F3F46; }
.leaflet-control-layers-expanded { color: #FAFAFA; }
.leaflet-control-attribution { background: rgba(10,10,11,.7) !important; color: #A1A1AA; }
.leaflet-control-attribution a { color: #E4E4E7; }
.map-tools .btn { background: #0A0A0B; border-color: #3F3F46; color: #FAFAFA; width: 40px; height: 40px; }
.mk .core { border: 3px solid #0A0A0B; box-shadow: 0 0 0 2px rgba(250,250,250,.85); }
.mk.sel .core { border-color: #FAFAFA; box-shadow: 0 0 0 6px rgba(250,250,250,.2); }
.mk-label { background: #0A0A0B; color: #F4F4F5; border: 1px solid #3F3F46; box-shadow: none; }

/* drawer + panels keep white, black accents */
.tabs button.on { color: #0A0A0B; border-bottom-color: #0A0A0B; }
.btn.on-range { background: #18181B; border-color: #18181B; color: #FAFAFA; }
.trip.sel { border-color: #0A0A0B; background: #F4F4F5; }
.trip:hover { border-color: #A1A1AA; background: #FAFAFA; }
.pill.online { background: #F4F4F5; color: #3F3F46; }
.cmdlog .out { background: #F4F4F5; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 45vh 1fr; }
  .topbar { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .sidebar { grid-column: 1; grid-row: 3; border-left: 0; border-top: 1px solid var(--line); }
  .mapwrap { grid-column: 1; grid-row: 2; }
}

/* ===== Layout matched to reference (black & gray) ===== */
.app { grid-template-rows: 76px 1fr; grid-template-columns: 1fr 440px; }
.topbar { background: #0A0A0B; align-items: flex-end; padding: 0 22px; gap: 26px; }
.topbar > .brand, .topbar > .live, .topbar > .btn { align-self: center; }
.brand { font-size: 30px; font-style: italic; font-weight: 700; letter-spacing: -.02em; }
.brand .logo { width: 40px; height: 40px; border-radius: 10px; }
.tabsnav { display: flex; gap: 6px; margin-left: 40px; }
.tabsnav a, .tabsnav button { font: inherit; font-size: 15px; font-weight: 500; color: #18181B; background: #A1A1AA; border: 0; border-radius: 8px 8px 0 0; padding: 11px 18px 10px; text-decoration: none; cursor: pointer; }
.tabsnav a:hover, .tabsnav button:hover { background: #D4D4D8; }
.tabsnav a.on { background: #FFFFFF; color: #0A0A0B; font-weight: 600; }
.topbar .bell { background: transparent; border: 0; width: 44px; height: 44px; color: #FAFAFA; }
.topbar .userbtn { background: transparent; border: 1.5px solid #FAFAFA; color: #FAFAFA; height: 44px; padding: 0 18px; border-radius: 10px; font-size: 15px; }
.topbar .userbtn:hover { background: #18181B; }

.mapwrap { background: #E4E4E7; }
.map-tools { left: 14px; right: auto; top: 14px; gap: 10px; }
.map-tools .btn { background: #FFFFFF; color: #18181B; border: 1px solid #D4D4D8; width: 44px; height: 44px; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.map-tools .btn:hover { background: #F4F4F5; }
.layer-menu { position: absolute; left: 54px; top: 108px; background: #FFFFFF; border: 1px solid #D4D4D8; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.15); padding: 6px; display: flex; flex-direction: column; min-width: 150px; }
.layer-menu[hidden] { display: none; }
.layer-menu button { text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 6px; font-size: 14px; }
.layer-menu button:hover { background: #F4F4F5; }
.layer-menu button.on { font-weight: 700; }
.addr-search { position: absolute; top: 14px; right: 14px; z-index: 650; display: flex; align-items: center; width: 400px; max-width: calc(100% - 90px); height: 48px; background: #FFFFFF; border-radius: 10px; box-shadow: 0 1px 6px rgba(0,0,0,.18); padding: 0 6px 0 16px; }
.addr-search input { border: 0 !important; outline: none !important; background: transparent !important; padding: 0 !important; font-size: 15px; height: 100%; }
.addr-search button { border: 0; background: none; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
.drawer { left: 72px; }
.tiles-gray { filter: grayscale(1) contrast(.95) brightness(1.02); }

/* markers: colored ring with white center, bold label underneath */
.mk { width: 30px; height: 30px; }
.mk .core { left: 3px; top: 3px; width: 24px; height: 24px; border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.mk .core::after { content: ''; position: absolute; left: 7px; top: 7px; width: 10px; height: 10px; border-radius: 50%; background: #FFFFFF; }
.mk.sel .core { box-shadow: 0 0 0 4px #0A0A0B, 0 1px 4px rgba(0,0,0,.35); }
.mk .arrow { left: 10px; top: -6px; border-bottom-color: #16A34A !important; }
.mk-label { background: transparent; border: 0; box-shadow: none; padding: 0; color: #0A0A0B; font-weight: 700; font-size: 13px; text-shadow: 0 0 3px #FFF, 0 0 3px #FFF, 0 0 3px #FFF, 0 0 3px #FFF; }
.leaflet-tooltip-bottom.mk-label::before { display: none; }
.leaflet-control-attribution { background: rgba(255,255,255,.8) !important; color: #3F3F46; }
.leaflet-control-attribution a { color: #18181B; }

/* asset panel */
.sidebar { background: #FFFFFF; }
.side-title { padding: 20px 22px 0; }
.side-title h1 { font-family: Inter, sans-serif; font-size: 32px; font-weight: 500; letter-spacing: -.01em; }
.btn.addlink { background: #0A0A0B; color: #FAFAFA; border: 0; height: 40px; padding: 0 14px; }
.side-search { position: relative; border-bottom: 0; padding: 16px 22px 0; }
.side-search input { height: 56px; border-radius: 12px; background: #FFFFFF; border: 1px solid #D4D4D8; padding: 0 48px 0 18px; font-size: 16px; }
.side-search svg { position: absolute; right: 38px; top: 34px; }
.chips { padding: 14px 22px 12px; border-bottom: 1px solid var(--line); }
.devices { background: #F4F4F5; }
.dev { display: block; background: #F4F4F5; border: 0; border-bottom: 1px solid #D4D4D8; border-left: 4px solid transparent; padding: 18px 22px; cursor: pointer; }
.dev:hover { background: #ECECEE; }
.dev.sel { background: #FFFFFF; border-left-color: #0A0A0B; }
.dev:focus-visible { outline: 2px solid #0A0A0B; outline-offset: -2px; }
.dev .r1 { display: flex; align-items: center; gap: 10px; }
.dev .sdot { width: 13px; height: 13px; }
.dev .nm { font-size: 21px; font-weight: 500; color: #18181B; }
.dev .route { margin-left: auto; border: 0; background: none; color: #52525B; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.dev .route:hover { background: #E4E4E7; color: #0A0A0B; }
.dev .r2 { display: flex; align-items: baseline; gap: 10px; margin-top: 6px; }
.dev .st { font-size: 19px; font-weight: 700; margin: 0; }
.st-moving { color: #15803D; } .st-online { color: #B91C1C; } .st-offline { color: #52525B; } .st-never { color: #B45309; }
.dev .upd { margin-left: auto; font-size: 15px; color: #3F3F46; }
.dev .where { font-size: 17px; color: #18181B; margin-top: 6px; }
.dev .approx { color: #52525B; font-size: 14px; }
.dev .r3 { margin-top: 8px; font-size: 15px; color: #3F3F46; }
.dev .idtag { font-variant-numeric: tabular-nums; }
.dev .batt { font-size: 16px; color: #18181B; gap: 6px; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 45vh 1fr; }
  .topbar { align-items: center; padding: 10px 14px; }
  .brand { font-size: 22px; }
  .tabsnav { margin-left: 0; order: 3; width: 100%; overflow-x: auto; }
  .addr-search { width: auto; left: 68px; }
  .drawer { left: 0; }
}
.leaflet-container { background: #E4E4E7; }

/* stops, odometer, report */
.trip .addr { font-size: 13px; color: #3F3F46; margin-top: 4px; line-height: 1.35; }
.trip .addr b { color: #18181B; font-weight: 600; }
.stop-num { width: 22px; height: 22px; border-radius: 50%; background: #0A0A0B; color: #FAFAFA; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.stop-now { color: #B91C1C; font-size: 11px; font-weight: 700; }
.odo-row { display: flex; align-items: center; gap: 8px; }
.odo-edit { display: flex; gap: 6px; margin-top: 6px; }
.odo-edit input { width: 140px; }
.dev .odo { display: inline-flex; align-items: center; gap: 5px; }
.modal.report { max-width: 1100px; }
.rep-head { display: flex; align-items: center; }
.rep-head h2 { flex: 1; font-family: "Space Grotesk", Inter, sans-serif; font-size: 24px; }
.rep-controls { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin-top: 8px; }
.rep-controls select { width: auto; min-width: 160px; }
.rep-btns { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.rep-body { margin-top: 16px; overflow-x: auto; }
.rep-table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
.rep-table th, .rep-table td { padding: 9px 10px; border-bottom: 1px solid #E4E4E7; text-align: right; white-space: nowrap; }
.rep-table th { font-size: 12px; color: #52525B; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.rep-table th:first-child, .rep-table td:first-child { text-align: left; position: sticky; left: 0; background: #FFFFFF; }
.rep-table tfoot td { font-weight: 700; border-top: 2px solid #18181B; }
.rep-table td.zero { color: #A1A1AA; }
.rep-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.rep-body { max-height: 60vh; overflow: auto; }
.rep-table thead th { position: sticky; top: 0; background: #FFFFFF; z-index: 1; }
.rep-table tfoot tr:not(:first-child) td { font-weight: 500; border-top: 0; }

/* tabs scroll when there are many */
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs button { flex: 1 0 auto; padding: 10px 9px; }
/* device settings */
.set-sec { border: 1px solid #E4E4E7; border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.set-sec > summary { list-style: none; cursor: pointer; padding: 12px 14px; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.set-sec > summary::-webkit-details-marker { display: none; }
.set-sec > summary::after { content: '+'; margin-left: auto; color: #52525B; font-size: 18px; }
.set-sec[open] > summary::after { content: '–'; }
.set-sec[open] > summary { border-bottom: 1px solid #E4E4E7; background: #FAFAFA; }
.set-body { padding: 4px 14px 14px; }
.set-body label { margin-top: 10px; }
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.set-body .hint { font-size: 12px; color: #52525B; margin-top: 4px; line-height: 1.45; }
.set-body .cmdprev { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: #3F3F46; background: #F4F4F5; padding: 6px 8px; border-radius: 6px; margin-top: 10px; word-break: break-all; }
.set-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.set-body input[type=checkbox] { width: auto; margin-right: 6px; }
.set-body .chk { display: flex; align-items: center; font-size: 14px; color: #18181B; margin-top: 10px; }
.set-body input[type=color] { width: 54px; height: 38px; padding: 2px; border: 1px solid #E4E4E7; border-radius: 8px; }
.pending { background: #FEF3C7; color: #78350F; border-radius: 8px; padding: 8px 10px; font-size: 12px; margin-top: 10px; }
.pending code { background: rgba(255,255,255,.6); }
.danger-btn { color: #B91C1C !important; border-color: #FCA5A5 !important; }
.pending { word-break: break-all; }

/* Ask AI */
.aibtn { display: inline-flex; align-items: center; gap: 6px; background: #27272A; color: #FAFAFA; border: 1px solid #3F3F46; margin-right: 10px; }
.aibtn:hover { background: #3F3F46; }
.aipanel { position: fixed; top: 76px; right: 0; bottom: 0; width: min(440px, 100vw); background: #fff; border-left: 1px solid #E4E4E7; box-shadow: -8px 0 30px rgba(0,0,0,.12); z-index: 1200; display: flex; flex-direction: column; }
.aipanel[hidden] { display: none; }
.ai-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid #E4E4E7; }
.ai-head b { font-size: 16px; } .ai-head .note { margin: 0; flex: 1; }
.ai-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.ai-empty p { color: #52525B; font-size: 14px; margin: 0 0 10px; }
.ai-sug { display: block; width: 100%; text-align: left; background: #F4F4F5; border: 1px solid #E4E4E7; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font: inherit; font-size: 14px; cursor: pointer; color: #18181B; }
.ai-sug:hover { background: #E4E4E7; }
.ai-msg { max-width: 92%; padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.ai-msg.user { align-self: flex-end; background: #18181B; color: #FAFAFA; border-bottom-right-radius: 4px; }
.ai-msg.bot { align-self: flex-start; background: #F4F4F5; color: #18181B; border-bottom-left-radius: 4px; }
.ai-msg.err { background: #FEE2E2; color: #7F1D1D; }
.ai-msg.wait { color: #71717A; font-style: italic; }
.ai-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid #E4E4E7; }
.ai-form textarea { flex: 1; resize: none; max-height: 140px; border: 1px solid #D4D4D8; border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 14px; }
@media (max-width: 760px) { .aibtn { padding: 8px 10px; } }

/* Zones */
.z-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.z-item { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid #E4E4E7; border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.z-item:hover { background: #FAFAFA; }
.z-item .zdot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #18181B; background: rgba(24,24,27,.15); flex: none; }
.z-item .zn { font-weight: 600; font-size: 14px; } .z-item .zm { font-size: 12px; color: #52525B; }
.z-hint { background: #F4F4F5; border-radius: 10px; padding: 10px 12px; font-size: 13px; color: #3F3F46; margin-bottom: 10px; }
.z-hint.need { background: #FEF3C7; color: #78350F; }
.z-body label { display: block; margin-top: 12px; font-size: 13px; color: #3F3F46; font-weight: 500; }
.z-body input[type=text] { width: 100%; }
.z-body input[type=range] { width: 100%; }
.z-size { font-weight: 600; font-size: 14px; }
.z-checks { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; max-height: 180px; overflow-y: auto; }
.z-checks label, .n-checks label { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 400; color: #18181B; font-size: 14px; }
.z-checks input, .n-checks input { width: auto; }
.z-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.zone-label { background: rgba(24,24,27,.85); color: #fff; border: 0; border-radius: 6px; padding: 2px 8px; font-weight: 600; font-size: 12px; box-shadow: none; }
.zone-label::before { display: none; }
/* Alert settings */
.modal.notify { max-width: 620px; }
.modal.notify h3 { margin: 18px 0 4px; font-size: 15px; }
.n-switch { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-weight: 600; font-size: 14px; }
.n-switch input { width: auto; }
.n-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.n-checks { display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }
.n-err { background: #FEE2E2; color: #7F1D1D; border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-top: 10px; }
@media (max-width: 600px) { .n-grid { grid-template-columns: 1fr; } }

/* playback */
.ptime { display: flex; justify-content: space-between; font-size: 13px; color: #3F3F46; margin-top: 8px; font-variant-numeric: tabular-nums; }
.pfollow { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 0 0 0 auto; }
.pfollow input { width: auto; }
.sub-h { margin: 20px 0 8px; font-size: 13px; color: #3F3F46; }
.trip .replay { margin-top: 8px; }
.trip .tlinks { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.trip .tlinks a, .trip .tlinks button { font-size: 12px; }
/* action rows */
.act-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.theft-on { background: #B91C1C !important; color: #fff !important; border-color: #B91C1C !important; }
.theft-badge { display: inline-block; background: #B91C1C; color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; margin-left: 6px; letter-spacing: .02em; }
.card-box { border: 1px solid #E4E4E7; border-radius: 10px; padding: 12px; margin-top: 14px; }
.card-box h4 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.card-box h4 .btn { margin-left: auto; }
.mt-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid #F4F4F5; font-size: 14px; }
.mt-item:first-of-type { border-top: 0; }
.mt-item .mn { flex: 1; } .mt-item .ml { font-size: 12px; color: #52525B; }
.mt-item .due { color: #B91C1C; font-weight: 600; } .mt-item .soon { color: #B45309; font-weight: 600; }
.mini-form { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 6px; margin-top: 8px; align-items: end; }
.mini-form label { margin: 0; font-size: 11px; }
/* share / users / misc */
.share-url { display: flex; gap: 6px; margin-top: 8px; } .share-url input { flex: 1; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.list-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid #F4F4F5; font-size: 14px; }
.list-row .grow { flex: 1; min-width: 0; } .list-row .sub { font-size: 12px; color: #52525B; }
.score { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; font-weight: 700; color: #fff; }
.cf-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 6px; align-items: center; margin-top: 6px; }
.cf-days { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 10px; }
.cf-days label { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; margin: 0; }
.cf-days input { width: auto; }
body.viewer .admin-only { display: none !important; }
@media (max-width: 600px) { .mini-form, .cf-row { grid-template-columns: 1fr 1fr; } }

.play-dot { width: 20px; height: 20px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.45); }
.odo-edit[hidden] { display: none !important; }
