/* Rayo dashboard — matches /var/www/dashboards (navy/amber, Inter, 12px cards). Light + dark. */
:root {
  --navy: #1f3550; --amber: #f5a623;
  --bg: #f4f6f9; --card: #ffffff; --text: #1f3550; --muted: #5b6b7d; --border: #e2e8f0;
  --sub: #eef2f7; --hover: #f8fafc;
  --ok: #2e7d4f; --ok-bg: #e6f4ec; --warn: #a3660e; --warn-bg: #fdf1dc; --bad: #b3261e; --bad-bg: #fbe9e7;
  --chip: #e8edf3; --chip-text: #3c4d62;
  --shadow: 0 1px 2px rgba(31,53,80,.04);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101a26; --card: #182432; --text: #e6ecf3; --muted: #9aa9ba; --border: #2a3a4d;
    --sub: #1f2d3d; --hover: #1d2a39; --navy: #14243a;
    --ok: #7fd3a1; --ok-bg: #163524; --warn: #f2c26b; --warn-bg: #3a2c12; --bad: #f2a29b; --bad-bg: #421b18;
    --chip: #263547; --chip-text: #c5d0dc; --shadow: none;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif; font-size: 14px; line-height: 1.45; }
a { color: var(--text); }
h1, h2, h3, h4 { margin: 0; }
button { font: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.sp { flex: 1; }
.inline { display: inline; margin: 0; }
.w1 { width: 1%; white-space: nowrap; }
.center { text-align: center; padding: 22px !important; }
.mono { font-family: var(--mono); }
.dim { color: var(--muted); }

header.site { background: var(--navy); color: #fff; padding: 18px 20px; border-bottom: 4px solid var(--amber); }
.site-inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 14px; }
.site .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--amber); }
.site h1 { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.01em; }
.site .crumb { color: rgba(255,255,255,.7); font-weight: 500; text-decoration: none; }
.site .crumb::after { content: "/"; margin: 0 10px; color: rgba(255,255,255,.4); }
.who-top { color: rgba(255,255,255,.75); font-size: 13px; }
.btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }

main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 56px; display: flex; flex-direction: column; gap: 16px; }
main.narrow { max-width: 440px; padding-top: 48px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 22px; box-shadow: var(--shadow); }
.login { display: flex; flex-direction: column; gap: 12px; }
.login h2 { font-size: 1.1rem; }
.login label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.login .input { font-size: 14px; }

.gbanner { display: flex; align-items: center; gap: 10px; background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad); border-radius: 10px; padding: 10px 14px; text-decoration: none; font-size: 13px; }
.gbanner .go { font-weight: 600; white-space: nowrap; }
.flashes { display: flex; flex-direction: column; gap: 6px; }
.flash { border-radius: 8px; padding: 9px 13px; font-size: 13px; font-weight: 500; border: 1px solid var(--border); background: var(--sub); }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.flash.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.flash.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

.frame { background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); display: grid; grid-template-columns: 188px minmax(0, 1fr); min-height: 520px; overflow: hidden; }
.nav { background: var(--sub); border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 4px 8px 14px; }
.nav .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--amber); }
.nav a { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 8px; text-decoration: none; font-weight: 500; color: var(--text); }
.nav a.on { background: var(--card); box-shadow: inset 0 0 0 1px var(--border); }
.nav .cnt { background: var(--amber); color: #1f3550; border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 700; }
.nav .cnt.bad { background: var(--bad); color: #fff; }
.nav .who { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; line-height: 1.5; word-break: break-all; }
.nav .who b { color: var(--text); font-weight: 600; display: block; }
.nav .who a { text-decoration: none; }

.pane { padding: 20px 22px 24px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.pane-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pane-head h3 { font-size: 1.05rem; font-weight: 600; }
.hint { font-size: 12px; color: var(--muted); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); font-weight: 500; font-size: 13px; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--amber); border-color: var(--amber); color: #1f3550; font-weight: 600; }
.btn.quiet { color: var(--muted); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg a { padding: 6px 11px; font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none; display: inline-flex; gap: 6px; align-items: center; }
.seg a.on { background: var(--sub); color: var(--text); }
.seg .cnt { background: var(--chip); border-radius: 999px; padding: 0 6px; font-size: 11px; }

.two { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.two.tight { gap: 14px; }
.block { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.block > .bh { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--sub); border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; }
.block > .bh small { color: var(--muted); font-weight: 500; }
.scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.pick { cursor: pointer; }
.tbl tr.pick:hover td { background: var(--hover); }
.tbl tr.sel td { background: var(--hover); box-shadow: inset 0 0 0 1px var(--amber); }
.tbl tr.attn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.tbl .num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.stack { display: flex; flex-direction: column; gap: 3px; }
.stack small { color: var(--muted); font-size: 11.5px; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.off { background: var(--chip); color: var(--chip-text); }
.chip { display: inline-block; padding: 1px 6px; border-radius: 5px; background: var(--chip); color: var(--chip-text); font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.role { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--chip-text); font-size: 11.5px; font-weight: 600; }
.role.owner { background: var(--amber); color: #1f3550; }

.drawer { border: 1px solid var(--border); border-radius: 10px; background: var(--card); box-shadow: 0 8px 24px rgba(31,53,80,.10); overflow: hidden; margin: 0; }
.drawer.narrowform { max-width: 520px; }
.drawer .dh { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.drawer .dh h4 { font-size: 14px; font-weight: 600; }
.drawer .db { padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.drawer .df { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; background: var(--sub); flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.input { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--card); color: var(--text); font: inherit; font-size: 13px; min-height: 36px; width: 100%; }
.input.sm { min-height: 32px; padding: 4px 8px; width: auto; }
textarea.input { resize: vertical; min-height: 54px; }
.pinbox { font-family: var(--mono); letter-spacing: .3em; max-width: 160px; }
.pinbox.sm { max-width: 90px; min-height: 30px; padding: 3px 8px; display: inline-block; width: auto; margin-right: 6px; }
.row-end { display: flex; gap: 8px; justify-content: flex-end; }
.steps { display: flex; gap: 6px; font-size: 12px; }
.steps span { padding: 3px 9px; border-radius: 999px; background: var(--chip); color: var(--chip-text); font-weight: 600; }
.steps span.on { background: var(--amber); color: #1f3550; }
.checks { display: flex; flex-direction: column; gap: 6px; }
.check { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 7px; border: 1px solid var(--border); font-size: 13px; cursor: pointer; background: var(--card); }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box { width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--muted); flex-shrink: 0; position: relative; }
.check:has(input:checked) .box { background: var(--navy); border-color: var(--navy); }
.check:has(input:checked) .box::after { content: ""; position: absolute; left: 4.5px; top: 1.5px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.check small { color: var(--muted); margin-left: auto; }

.pinwrap { position: relative; }
.modal { position: absolute; right: 0; top: 44px; width: 340px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 16px 40px rgba(31,53,80,.18); padding: 16px; display: flex; flex-direction: column; gap: 12px; z-index: 5; margin: 0; }
.modal h4 { font-size: 14px; }
.hist { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; padding: 12px 14px; }
.hist > div { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 10px; }
.hist .t { font-family: var(--mono); color: var(--muted); font-size: 11.5px; padding-top: 2px; }
.temp-pw { font-size: 20px; background: var(--sub); border-radius: 8px; padding: 10px 14px; display: inline-block; user-select: all; }

.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.tile .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.tile .l { font-size: 12px; color: var(--muted); }
.tile.bad { border-color: var(--bad); background: var(--bad-bg); }
.tile.bad .v { color: var(--bad); }
.tile.ok .v { color: var(--ok); }

.hgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.hrows { display: flex; flex-direction: column; }
.hrow { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.hrow:last-child { border-bottom: 0; }
.hrow .st { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); margin-left: 4px; }
.hrow .st.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
.hrow .st.warn { background: var(--warn); }
.hrow .d { color: var(--muted); font-size: 12px; font-family: var(--mono); white-space: nowrap; }
.hrow.bad { background: var(--bad-bg); }
.hrow.bad .d { color: var(--bad); }
.hrow .n small { display: block; color: var(--muted); font-size: 11.5px; font-family: var(--mono); }
.alert { border: 1px solid var(--bad); background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 12px 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; font-size: 13px; }
.alert b { display: block; font-weight: 600; }
.alert code { font-family: var(--mono); font-size: 12px; }
.log { background: var(--navy); color: #cfe0f2; border-radius: 10px; padding: 12px 14px; font-family: var(--mono); font-size: 12px; line-height: 1.6; overflow-x: auto; white-space: pre; margin: 0; max-height: 420px; overflow-y: auto; }

.distform { display: grid; grid-template-columns: 1fr 1.6fr 1.4fr auto; gap: 10px; padding: 12px 14px; align-items: end; }
.distout { margin: 0 14px 12px; padding: 10px 12px; border-radius: 8px; background: var(--sub); font-size: 13px; }
.distout .big { font-size: 18px; font-weight: 700; }
.distout.bad { background: var(--bad-bg); color: var(--bad); }
.distout.warn { background: var(--warn-bg); }
@media (max-width: 860px) { .distform { grid-template-columns: 1fr; } }
.livemap { height: 520px; border-radius: 10px; border: 1px solid var(--border); background: var(--sub); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); align-items: center; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.legend .l-finished { background: #2e7d4f; } .legend .l-open { background: #f5a623; } .legend .l-incomplete { background: #b3261e; } .legend .l-never { background: #5b6b7d; }

.ov { position: fixed; inset: 0; background: rgba(16,26,38,.45); display: none; align-items: center; justify-content: center; z-index: 20; padding: 20px; }
.ov.on { display: flex; }
.ov .box { background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 12px; width: min(520px, 100%); box-shadow: 0 24px 60px rgba(16,26,38,.35); overflow: hidden; max-height: 80vh; display: flex; flex-direction: column; }
.ov .bh2 { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 10px; }
.ov form { overflow-y: auto; }
.ov .opt { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 11px 16px; border: 0; border-bottom: 1px solid var(--border); background: var(--card); color: var(--text); cursor: pointer; font-size: 13px; }
.ov .opt:hover { background: var(--hover); }
.ov .opt small { color: var(--muted); display: block; }

.toast { position: fixed; right: 18px; bottom: 18px; background: var(--navy); color: #fff; border-left: 4px solid var(--amber); border-radius: 10px; padding: 11px 16px; font-size: 13px; max-width: 46ch; box-shadow: 0 12px 32px rgba(16,26,38,.35); opacity: 0; transform: translateY(8px); transition: opacity .18s ease, transform .18s ease; pointer-events: none; z-index: 30; }
.toast.on { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media (max-width: 860px) {
  .frame { grid-template-columns: 1fr; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav .who { display: none; }
  .two, .hgrid { grid-template-columns: 1fr; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal { position: static; width: auto; }
  .who-top { display: none; }
}

/* ---------- Vehicles (Zonar) ---------- */
.seg a.locked { opacity: .55; }
.layers { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.layers .check { padding: 5px 9px; }
.layers .check small { margin-left: 4px; color: var(--muted); }
.two.wide { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.livemap.tall { height: 620px; }
.trk-panel { max-height: 620px; overflow-y: auto; }
.trk-row { cursor: pointer; }
.trk-row:hover { background: var(--hover); }
.trk-row.dim .n b { color: var(--muted); font-weight: 500; }
.trk { position: relative; }
.trk-dot { position: absolute; left: -8px; top: -8px; width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(16,26,38,.45); }
.trk-dot.grey { opacity: .75; }
.trk-dot.moving { box-shadow: 0 0 0 4px rgba(245,166,35,.35), 0 1px 4px rgba(16,26,38,.45); }
.trk-arrow { position: absolute; left: -6px; top: -22px; width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 12px solid #1f3550; transform-origin: 50% 200%; }
.trk-label { position: absolute; left: 11px; top: -9px; white-space: nowrap; font: 600 11.5px 'Inter', sans-serif; color: #1f3550; background: rgba(255,255,255,.88); padding: 1px 6px; border-radius: 6px; box-shadow: 0 1px 2px rgba(16,26,38,.25); }
.trk-label.grey { color: #5b6b7d; font-weight: 500; }
.trk-actions { margin-top: 6px; display: flex; gap: 6px; }
.leaflet-popup-content { font: 13px 'Inter', sans-serif; line-height: 1.4; }
.locked-pane { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; padding: 30px 0; }
.locked-pane .tile { max-width: 360px; }
.ybh { cursor: pointer; user-select: none; }
.ybh .caret { color: var(--muted); width: 12px; }
.ybh small { color: var(--muted); font-weight: 500; }
.ybody { display: grid; grid-template-columns: minmax(0, 2.6fr) minmax(220px, 1fr); }
.markNote { min-width: 140px; }
.markSel { min-width: 96px; }
.ybody .scroll { min-width: 0; }
.ymap { min-height: 260px; border-left: 1px solid var(--border); background: var(--sub); }
.tbl tr.marked td { background: var(--ok-bg); }
.tbl.fleet tr.parked td { color: var(--muted); }
.tbl.fleet tr.parked td b { color: var(--muted); font-weight: 500; }
.bad-text { color: var(--bad); }
.tbl tr.noint td { color: var(--muted); }
.map-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
@media (max-width: 860px) { .two.wide, .ybody { grid-template-columns: 1fr; } .ymap { border-left: 0; border-top: 1px solid var(--border); } }

/* ---------- Fit to width (site-wide toggle in the header) ---------- */
html.wide main, html.wide .site-inner { max-width: none; }
html.wide main { padding-left: 28px; padding-right: 28px; }
html.wide .two.wide { grid-template-columns: minmax(0, 3fr) minmax(300px, 1fr); }
html.wide .livemap.tall { height: 720px; }
html.wide .ybody { grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); }
