:root {
  --nav: #282436; --nav-2: #33304A; --nav-text: #B9B6C9; --accent: #F02938; --accent-2: #C81E2C;
  --bg: #F4F4F7; --card: #ffffff; --text: #1C1A26; --muted: #5A5770; --line: #DCDBE4; --head: #282436;
  --all: #3b82f6; --moving: #22c55e; --stoppage: #eab308; --idle: #f97316; --offline: #dc2626; --inactive: #6b7280;
  --radius: 10px; --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(15,27,61,.06);
}
body.dark { --bg: #1E1B29; --card: #282436; --text: #EEEDF2; --muted: #B9B6C9; --line: #4A4663; --head: #33304A; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--text); background: var(--bg); font-size: 14px; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent-2); }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; background: radial-gradient(circle at 20% 20%, #33304A, #1E1B29); padding: 20px; }
.login form { background: #fff; color: #111827; width: 100%; max-width: 380px; padding: 32px; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login h1 { margin: 0 0 4px; font-size: 26px; color: var(--nav); }
.login p { margin: 0 0 24px; color: #6b7280; }
.brand-mark { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark svg { width: 34px; height: 34px; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; height: 100vh; height: 100dvh; }
.shell.collapsed { grid-template-columns: 68px 1fr; }
.side { background: var(--nav); color: var(--nav-text); display: flex; flex-direction: column; overflow: hidden; }
.side .logo { display: flex; align-items: center; gap: 10px; padding: 18px 18px 22px; font-size: 22px; font-weight: 800; color: #fff; white-space: nowrap; letter-spacing: .3px; }
.side .logo small { display: block; font-size: 10px; font-weight: 500; color: var(--accent); letter-spacing: 1.5px; }
.side nav { flex: 1; overflow-y: auto; padding: 0 10px; }
.side nav button { display: flex; align-items: center; gap: 14px; width: 100%; background: none; border: 0; color: var(--nav-text); padding: 12px 14px; border-radius: 10px; cursor: pointer; font-size: 15px; text-align: left; white-space: nowrap; margin-bottom: 2px; }
.side nav button:hover { background: var(--nav-2); color: #fff; }
.side nav button.active { background: var(--nav-2); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.side nav svg { width: 20px; height: 20px; flex: none; }
.side .foot { padding: 12px 18px; font-size: 11px; color: #64748b; white-space: nowrap; }
.shell.collapsed .side .label, .shell.collapsed .side .logo span, .shell.collapsed .side .foot { display: none; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { height: 60px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar h2 { margin: 0; font-size: 18px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { position: relative; background: none; border: 0; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; color: var(--text); }
.icon-btn:hover { background: var(--bg); }
.icon-btn svg { width: 22px; height: 22px; }
.badge { position: absolute; top: 4px; right: 4px; background: var(--offline); color: #fff; border-radius: 9px; font-size: 10px; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 4px; font-weight: 700; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 20px; cursor: pointer; border: 0; background: none; }
.user-chip .av { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; }
.user-chip .nm { color: var(--accent-2); font-weight: 600; }
.content { flex: 1; min-height: 0; overflow: auto; padding: 14px; }
.content.flush { padding: 0; overflow: hidden; display: flex; flex-direction: column; }

/* ---------- controls ---------- */
.btn { border: 0; background: var(--nav); color: #fff; padding: 9px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { filter: brightness(1.15); }
.btn.accent { background: var(--accent-2); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--offline); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.sq { width: 42px; height: 42px; justify-content: center; padding: 0; }
.btn svg { width: 18px; height: 18px; }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
input, select { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 9px 11px; outline: none; min-width: 0; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240,41,56,.15); }
.login input { background: #fff; color: #111827; border-color: #d1d5db; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.err { color: var(--offline); font-size: 13px; min-height: 18px; }
.muted { color: var(--muted); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card h3 { margin: 0 0 12px; font-size: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }

/* ---------- live dashboard ---------- */
.live-bar { display: flex; gap: 8px; padding: 12px 14px; align-items: center; flex-wrap: wrap; background: var(--card); border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab { border: 0; color: #fff; font-weight: 700; padding: 10px 16px; border-radius: 8px; cursor: pointer; font-size: 14px; opacity: .78; min-width: 104px; }
.tab.on { opacity: 1; box-shadow: 0 0 0 3px rgba(15,27,61,.25) inset, 0 2px 8px rgba(0,0,0,.15); transform: translateY(-1px); }
.tab.all { background: var(--all); } .tab.moving { background: var(--moving); } .tab.stoppage { background: var(--stoppage); }
.tab.idle { background: var(--idle); } .tab.offline { background: var(--offline); } .tab.inactive { background: var(--inactive); }
.search { position: relative; margin-left: auto; }
.search input { width: 230px; padding-right: 34px; height: 42px; }
.search svg { position: absolute; right: 10px; top: 11px; width: 20px; height: 20px; color: var(--muted); }
.split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(380px, 46%) 1fr; }
.split.list-hidden { grid-template-columns: 0 1fr; }
.list-pane { min-width: 0; display: flex; flex-direction: column; border-right: 4px solid var(--nav); background: var(--card); position: relative; overflow: hidden; }
.table-wrap { flex: 1; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; background: var(--head); color: #fff; text-align: left; padding: 12px 10px; font-weight: 600; white-space: nowrap; cursor: pointer; user-select: none; z-index: 1; }
th .s { opacity: .55; font-size: 11px; margin-left: 4px; }
td { padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: rgba(240,41,56,.07); }
tbody tr.sel { background: rgba(240,41,56,.14); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; color: #fff; text-transform: capitalize; }
.pill.moving { background: var(--moving); } .pill.stoppage { background: var(--stoppage); } .pill.idle { background: var(--idle); }
.pill.offline { background: var(--offline); } .pill.inactive { background: var(--inactive); }
.vname { font-weight: 700; } .vsub { color: var(--muted); font-size: 12px; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.pager input { width: 60px; text-align: center; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.collapse-btn { position: absolute; right: -4px; top: 50%; transform: translateY(-50%); width: 22px; height: 54px; background: var(--nav); color: #fff; border: 0; border-radius: 6px 0 0 6px; cursor: pointer; z-index: 5; }
.split.list-hidden .collapse-btn.show { display: block; }
.map-pane { position: relative; min-width: 0; }
.map { position: absolute; inset: 0; }
.map-switch { position: absolute; top: 12px; left: 56px; z-index: 500; display: flex; background: #fff; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.3); overflow: hidden; }
.map-switch button { border: 0; background: #fff; color: #444; padding: 9px 16px; cursor: pointer; font-size: 15px; }
.map-switch button.on { color: #000; font-weight: 700; }
.map-tools { position: absolute; top: 12px; right: 12px; z-index: 500; display: flex; flex-direction: column; gap: 8px; }
.map-tools button { width: 40px; height: 40px; border: 0; border-radius: 6px; background: #fff; color: #333; box-shadow: 0 1px 4px rgba(0,0,0,.3); cursor: pointer; display: grid; place-items: center; }
.map-tools svg { width: 20px; height: 20px; }
.show-list { position: absolute; left: 0; top: 50%; transform: translateY(-50%); z-index: 600; width: 24px; height: 60px; border: 0; border-radius: 0 6px 6px 0; background: var(--nav); color: #fff; cursor: pointer; }

/* vehicle marker */
.vm { position: relative; }
.vm .arrow { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.vm .arrow svg { width: 16px; height: 16px; color: #fff; }
.vm .lbl { position: absolute; top: 33px; left: 50%; transform: translateX(-50%); background: rgba(15,27,61,.88); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.leaflet-popup-content { margin: 12px 14px; min-width: 230px; font-size: 13px; }
.pop h4 { margin: 0 0 6px; font-size: 15px; }
.pop .kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 8px 0; }
.pop .kv span:nth-child(odd) { color: #6b7280; }
.pop .acts { display: flex; gap: 6px; flex-wrap: wrap; }

/* history */
.hist { display: grid; grid-template-columns: 340px 1fr; flex: 1; min-height: 0; }
.hist-side { overflow: auto; padding: 14px; background: var(--card); border-right: 1px solid var(--line); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.stat { background: var(--bg); border-radius: 8px; padding: 10px; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 12px; color: var(--muted); }
.player { position: absolute; left: 12px; right: 12px; bottom: 22px; z-index: 600; background: var(--card); border-radius: 10px; box-shadow: var(--shadow); padding: 10px 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.player input[type=range] { flex: 1; min-width: 120px; padding: 0; }
.player .now { font-size: 12px; min-width: 190px; }
canvas.chart { width: 100%; height: 120px; display: block; background: var(--bg); border-radius: 8px; }
.trip { padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); margin-bottom: 6px; cursor: pointer; font-size: 13px; }
.trip:hover { border-color: var(--accent); }

/* alerts */
.ev { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-bottom: 1px solid var(--line); }
.ev .dot { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; font-size: 17px; }
.ev.unread { background: rgba(240,41,56,.06); }
.ev .t { font-weight: 600; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 2000; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal h3 { margin: 0 0 16px; }
.modal .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.modal .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--nav); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 340px; animation: slide .25s ease-out; border-left: 4px solid var(--accent); }
.toast.bad { border-left-color: var(--offline); }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }

.geo-tools { position: absolute; top: 12px; left: 56px; z-index: 600; background: var(--card); border-radius: 10px; box-shadow: var(--shadow); padding: 10px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; max-width: calc(100% - 120px); }

/* ---------- mobile ---------- */
.mob-nav { display: none; }
@media (max-width: 860px) {
  .shell, .shell.collapsed { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .side { display: none; }
  .mob-nav { display: flex; background: var(--nav); padding-bottom: env(safe-area-inset-bottom); }
  .mob-nav button { flex: 1; background: none; border: 0; color: var(--nav-text); padding: 8px 2px; font-size: 10px; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; }
  .mob-nav button.active { color: var(--accent); }
  .mob-nav svg { width: 22px; height: 22px; }
  .user-chip .nm { display: none; }
  .split { grid-template-columns: 1fr; grid-template-rows: 46% 54%; }
  .split.list-hidden { grid-template-rows: 0 1fr; grid-template-columns: 1fr; }
  .list-pane { border-right: 0; border-bottom: 4px solid var(--nav); order: 2; }
  .map-pane { order: 1; }
  .collapse-btn { display: none; }
  .tab { min-width: 0; padding: 7px 10px; font-size: 12px; }
  .search { margin-left: 0; width: 100%; }
  .search input { width: 100%; }
  .hist { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow: auto; }
  .hist-side { max-height: 45vh; }
  .hist .map-pane { min-height: 50vh; }
  .modal .grid { grid-template-columns: 1fr; }
  .player .now { min-width: 0; width: 100%; }
  .map-switch { left: 52px; } .map-switch button { padding: 7px 10px; font-size: 13px; }
}

/* ---------- v2: groups, fuel, cards ---------- */
textarea { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 9px 11px; width: 100%; resize: vertical; font-size: 13px; }
.topbar select { height: 38px; }
.health { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; padding: 8px 14px; background: var(--bg); border-bottom: 1px solid var(--line); font-size: 13px; }
.health b { margin-left: 3px; }
.health .ok { color: #16a34a; } .health .warn { color: #ea580c; } .health .bad { color: var(--offline); }
.health .sep { width: 1px; height: 16px; background: var(--line); }
.fuelbar { display: inline-block; width: 46px; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.fuelbar i { display: block; height: 100%; }
.cards { display: none; padding: 10px; }
.vcard { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: var(--card); cursor: pointer; }
.vcard.sel { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(240,41,56,.2); }
.vcard b { font-size: 16px; }
.vmeta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 20px; padding: 6px 12px; font-size: 13px; background: var(--card); }
.linkbtn { background: none; border: 0; color: var(--accent-2); cursor: pointer; padding: 0 2px; font-size: 12px; }
details summary { margin: 6px 0; }
@media (max-width: 860px) {
  .list-pane table { display: none; }
  .cards { display: block; }
  .topbar select { max-width: 120px !important; }
  .health { gap: 10px; font-size: 12px; }
}
@media print {
  .side, .topbar, .mob-nav, #toasts, .btn, .live-bar, .map-tools, .map-switch { display: none !important; }
  .shell { display: block; height: auto; } .content { overflow: visible; padding: 0; }
  body { background: #fff; } .card { box-shadow: none; border: 1px solid #ddd; }
  th { background: #0f1b3d !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media (max-width: 860px) {
  .live-bar { padding: 8px 10px; gap: 6px; }
  .live-bar #export { display: none; }
  .live-bar .search { width: calc(100% - 50px); }
  .live-bar #refresh { width: 42px; }
}
/* ---------- brand fixes ---------- */
#app { min-height: 100%; }
.login { min-height: 100vh; min-height: 100dvh; }
.login-brand { text-align: center; margin-bottom: 22px; }
.login-logo svg { width: 84px; height: 84px; filter: drop-shadow(0 6px 14px rgba(240,41,56,.35)); }
.login-brand h1 { margin: 8px 0 2px; font-size: 30px; color: var(--nav); letter-spacing: .3px; }
.login-brand p { margin: 0; }
.side .logo svg { width: 46px; height: 46px; flex: none; }
.mob-brand { display: none; }
.mob-brand svg { width: 30px; height: 30px; }
@media (max-width: 860px) {
  .mob-brand { display: inline-flex; }
  #collapse { display: none; }
}

/* ---------- We Trace brand logo ---------- */
.side .logo { flex-direction: column; align-items: flex-start; gap: 6px; padding: 18px 16px 20px; }
.side .logo .brand-full { width: 200px; height: auto; border-radius: 8px; display: block; }
.side .logo .brand-mark { display: none; width: 40px; height: 40px; border-radius: 10px; }
.side .logo small { font-size: 11px; color: var(--nav-text); letter-spacing: .3px; font-weight: 500; }
.shell.collapsed .side .logo { align-items: center; padding: 16px 0; }
.shell.collapsed .side .logo .brand-full, .shell.collapsed .side .logo small { display: none; }
.shell.collapsed .side .logo .brand-mark { display: block; }
.login-logo { width: 280px; max-width: 100%; height: auto; border-radius: 12px; display: block; margin: 0 auto 10px; box-shadow: 0 8px 22px rgba(240,41,56,.3); }
img.mob-brand { height: 30px; width: auto; border-radius: 6px; }
.tab.on { box-shadow: 0 0 0 3px rgba(40,36,54,.35) inset, 0 2px 8px rgba(0,0,0,.15); }
.toast { border-left-color: var(--accent); }
@media (max-width: 860px) {
  .topbar { gap: 4px; padding: 0 10px; }
  .topbar h2, #fs { display: none; }
  .topbar #proj { flex: 1; max-width: none !important; min-width: 0; }
}

/* ---------- AI assistant & health ---------- */
.ai-fab { position: fixed; right: 18px; bottom: 18px; z-index: 1500; display: flex; align-items: center; gap: 8px; background: var(--accent); color: #fff; border: 0; border-radius: 28px;
  padding: 12px 18px; font-weight: 700; box-shadow: 0 8px 24px rgba(240,41,56,.4); cursor: pointer; }
.ai-fab svg { width: 20px; height: 20px; }
.ai-panel { position: fixed; right: 18px; bottom: 18px; width: 420px; max-width: calc(100vw - 24px); height: min(640px, calc(100vh - 36px)); z-index: 1600; background: var(--card);
  border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.35); display: none; flex-direction: column; overflow: hidden; border: 1px solid var(--line); }
.ai-panel.open { display: flex; }
.ai-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: var(--nav); color: #fff; }
.ai-head svg { width: 20px; height: 20px; color: var(--accent); } .ai-head .icon-btn { color: #fff; width: 32px; height: 32px; } .ai-head .muted { color: var(--nav-text); font-size: 11px; }
.ai-ctx { padding: 8px 12px; border-bottom: 1px solid var(--line); } .ai-ctx select { width: 100%; }
.ai-msgs { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { border-radius: 12px; padding: 10px 12px; font-size: 13.5px; line-height: 1.45; max-width: 92%; }
.ai-msg.bot { background: var(--bg); align-self: flex-start; } .ai-msg.me { background: var(--accent); color: #fff; align-self: flex-end; }
.ai-msg h4, .ai-text h4 { margin: 8px 0 4px; font-size: 14px; } .ai-msg p, .ai-text p { margin: 4px 0; } .ai-msg ul, .ai-text ul { margin: 4px 0; padding-left: 18px; }
.ai-chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; border-top: 1px solid var(--line); }
.ai-chips .chip { white-space: nowrap; cursor: pointer; font-size: 12px; padding: 5px 10px; }
.ai-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); } .ai-input input { flex: 1; }
.ring { border-radius: 50%; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--line) 0); display: grid; place-items: center; flex: none; }
.ring span { width: 76%; height: 76%; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-weight: 800; font-size: 17px; }
.hgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.hcard { border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.hcard:hover { border-color: var(--accent); }
.hstats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--muted); }
.hissue { font-size: 12.5px; padding: 6px 8px; border-radius: 8px; background: var(--bg); margin-bottom: 4px; }
.hissue.high { background: #fee2e2; color: #991b1b; } .hissue.medium { background: #ffedd5; color: #9a3412; } .hissue.ok { color: #166534; }
body.dark .hissue.high { background: #4c1d1d; color: #fecaca; } body.dark .hissue.medium { background: #4a2a12; color: #fed7aa; }
.kv2 { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: 13px; } .kv2 span { color: var(--muted); }
@media (max-width: 860px) { .ai-fab { bottom: 78px; right: 12px; padding: 12px; } .ai-fab span { display: none; } .ai-panel { right: 6px; bottom: 6px; height: calc(100vh - 12px); } }
@media print { .ai-fab, .ai-panel { display: none !important; } }
.thread { display: flex; flex-direction: column; gap: 8px; max-height: 45vh; overflow: auto; }
.sn-row .grid { margin-top: 6px; }

/* construction sensors on the live dashboard */
.schip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; margin: 1px 4px 1px 0; border-radius: 6px; font-size: 12px; font-weight: 650; white-space: nowrap; background: #eef0f5; color: #374151; }
td.sens { white-space: nowrap; }
.schip.load { background: #eef2ff; color: #3730a3; }
.schip.work { background: #dcfce7; color: #166534; }
.schip.idle { background: #ffedd5; color: #9a3412; }
.schip.warn { background: #fee2e2; color: #b91c1c; }
.drum-ico { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; flex: none; }
.drum-mixing { background: #dbeafe; color: #1d4ed8; } .drum-mixing .drum-ico { animation: drumspin 1.6s linear infinite; }
.drum-discharging { background: #d9f99d; color: #3f6212; } .drum-discharging .drum-ico { animation: drumspin .7s linear infinite reverse; }
.drum-stopped { background: #e5e7eb; color: #6b7280; }
.drum-txt-mixing b { color: #1d4ed8; } .drum-txt-discharging b { color: #4d7c0f; }
.vm-drum { position: absolute; top: -7px; right: -9px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.vm-drum .drum-ico { width: 8px; height: 8px; border-width: 2px; }
@keyframes drumspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .drum-ico { animation: none !important; } }
body.dark .schip:not([class*="drum-"]):not(.load):not(.work):not(.idle):not(.warn) { background: #33304A; color: #EEEDF2; }

/* drum sensor screen */
.mixgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-top: 12px; }
.mixcard { all: unset; cursor: pointer; display: block; padding: 12px 14px; border: 1px solid var(--line); border-left: 4px solid #9ca3af; border-radius: 10px; background: var(--card); }
.mixcard.st-mixing { border-left-color: #3b82f6; } .mixcard.st-discharging { border-left-color: #84cc16; }
.mixcard:hover, .mixcard:focus-visible { box-shadow: 0 2px 10px rgba(0,0,0,.12); outline: none; }
.mixcard .vmeta { margin-top: 6px; }
.stat.bad b { color: #dc2626; }
.legend { font-size: 12px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.dtl { position: relative; height: 34px; margin-top: 14px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.dtl i { position: absolute; top: 0; bottom: 0; }
.dtl-ticks { position: relative; height: 18px; margin-top: 4px; font-size: 11px; color: var(--muted); }
.dtl-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
tr.bad-row td { background: #fef2f2; } body.dark tr.bad-row td { background: #3b1d1d; }

/* drum sensor v2 */
.stat.warn b { color: #d97706; }
.stat b small { font-size: 12px; font-weight: 600; color: var(--muted); }
.dchart-wrap { position: relative; margin-top: 12px; }
.dchart { width: 100%; height: 240px; display: block; }
.dchart .grid { stroke: var(--line); stroke-width: 1; }
.dchart .zero { stroke: #94a3b8; stroke-dasharray: 4 4; }
.dchart .ax { font-size: 11px; fill: var(--muted); }
.dchart .ax.wt { fill: #f97316; }
.dchart .spd { fill: none; stroke: #cbd5e1; stroke-width: 1.5; }
.dchart .wgt { fill: none; stroke: #f97316; stroke-width: 1.6; opacity: .85; }
.dchart .rpm { fill: none; stroke: #2563eb; stroke-width: 1.6; }
.dchart .hov { stroke: var(--text); stroke-width: 1; opacity: .5; }
.dtip { position: absolute; top: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.12); pointer-events: none; width: 160px; }
.dsplit { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin-top: 14px; background: var(--bg); }
.dsplit i { display: block; height: 100%; }
.dsplit-l { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.dsplit-l i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.dsplit-l b { color: var(--text); }
.ai-drum .findings { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.ai-drum .findings li { display: flex; gap: 10px; padding: 10px 12px; border-radius: 8px; background: var(--bg); line-height: 1.45; }
.ai-drum .findings li.bad { background: #fef2f2; } .ai-drum .findings li.warn { background: #fffbeb; } .ai-drum .findings li.good { background: #f0fdf4; }
body.dark .ai-drum .findings li.bad { background: #3b1d1d; } body.dark .ai-drum .findings li.warn { background: #3a2c12; } body.dark .ai-drum .findings li.good { background: #14301f; }
.ai-drum .todo { margin: 0 0 0 20px; display: grid; gap: 4px; }
table.loads td.bad { color: #dc2626; font-weight: 700; } table.loads td.warn { color: #d97706; font-weight: 700; }
table.loads tr.flag-row td { background: #fffbeb; } body.dark table.loads tr.flag-row td { background: #2f2512; }
table.loads td { vertical-align: top; }
@media print { .dtip { display: none; } }
