* { margin:0; padding:0; box-sizing:border-box; font-family:'Segoe UI', system-ui, -apple-system, sans-serif; }
:root {
  --bg:#0b0f14; --panel:#111820; --panel2:#0e141c; --line:#1e2a36;
  --txt:#e8eef4; --dim:#7d8ea0; --accent:#10b981; --accent2:#0ea5e9;
  --amber:#f59e0b; --red:#ef4444; --green:#22c55e;
}
html,body { height:100%; background:var(--bg); color:var(--txt); overflow:hidden; }
.hidden { display:none !important; }
button { cursor:pointer; border:none; background:none; color:inherit; font:inherit; }
input { background:#0a0f15; border:1px solid var(--line); border-radius:10px; padding:10px 12px; color:var(--txt); outline:none; width:100%; font-size:14px; }
input:focus { border-color:var(--accent2); }

/* ---------- LOGIN ---------- */
#login-screen { position:fixed; inset:0; display:flex; align-items:center; justify-content:center; background:radial-gradient(1200px 700px at 70% 20%, #0f1b26, var(--bg)); z-index:50; }
.login-glow { position:absolute; border-radius:50%; filter:blur(120px); opacity:.25; }
.login-glow.g1 { width:420px; height:420px; background:var(--accent); top:-80px; left:-80px; }
.login-glow.g2 { width:380px; height:380px; background:var(--accent2); bottom:-60px; right:-60px; }
.login-card { position:relative; width:min(400px, 92vw); background:rgba(17,24,32,.9); border:1px solid var(--line); border-radius:20px; padding:34px 30px; backdrop-filter:blur(14px); box-shadow:0 30px 80px rgba(0,0,0,.5); display:flex; flex-direction:column; gap:10px; }
.brand-mark { display:flex; align-items:center; gap:9px; font-weight:800; font-size:22px; letter-spacing:2px; }
.brand-mark.small { font-size:15px; }
.brand-dot { width:12px; height:12px; border-radius:50%; background:linear-gradient(135deg, var(--accent), var(--accent2)); box-shadow:0 0 14px var(--accent); }
.brand-thin { font-weight:300; color:var(--dim); letter-spacing:4px; }
.login-logo { width:150px; margin:0 auto 6px; display:block; }
.demo-badge { font-size:10px; font-weight:800; letter-spacing:1.5px; color:#04121a; background:linear-gradient(135deg,var(--amber),#fbbf24); border-radius:6px; padding:3px 7px; }
.login-tag { color:var(--dim); font-size:13px; margin-bottom:12px; }
.login-card label { font-size:12px; color:var(--dim); margin-top:6px; }
.btn-primary { margin-top:14px; background:linear-gradient(135deg, var(--accent), var(--accent2)); color:#04121a; font-weight:700; padding:12px; border-radius:12px; font-size:15px; }
.btn-primary:hover { filter:brightness(1.1); }
#login-error { color:var(--red); font-size:13px; min-height:16px; }
.login-demo-row { display:flex; gap:10px; margin-top:6px; }
.btn-demo { flex:1; border:1px dashed var(--line); border-radius:10px; padding:9px; color:var(--dim); font-size:13px; }
.btn-demo:hover { border-color:var(--accent); color:var(--txt); }
.login-foot { text-align:center; color:#54647a; font-size:11px; margin-top:12px; }

/* ---------- TOPBAR ---------- */
#app { display:flex; flex-direction:column; height:100%; }
#topbar { height:58px; display:flex; align-items:center; gap:18px; padding:0 16px; background:rgba(14,20,28,.92); border-bottom:1px solid var(--line); backdrop-filter:blur(10px); z-index:20; }
.topbar-stats { display:flex; gap:10px; flex:1; justify-content:center; }
.stat-chip { display:flex; flex-direction:column; align-items:center; background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:4px 14px; min-width:84px; }
.stat-num { font-weight:800; font-size:15px; }
.stat-num.green { color:var(--green); } .stat-num.amber { color:var(--amber); }
.stat-lbl { font-size:10px; color:var(--dim); text-transform:uppercase; letter-spacing:.6px; }
.topbar-right { display:flex; align-items:center; gap:10px; }
.clock { font-variant-numeric:tabular-nums; color:var(--dim); font-size:13px; }
.role-badge { font-size:11px; font-weight:700; padding:4px 10px; border-radius:20px; background:rgba(16,185,129,.14); color:var(--accent); border:1px solid rgba(16,185,129,.4); text-transform:uppercase; letter-spacing:.5px; }
.role-badge.supervisor { background:rgba(14,165,233,.12); color:var(--accent2); border-color:rgba(14,165,233,.4); }
.btn-ghost { border:1px solid var(--line); border-radius:10px; padding:7px 12px; font-size:12px; color:var(--dim); }
.btn-ghost:hover { color:var(--txt); border-color:var(--accent2); }

/* ---------- LAYOUT ---------- */
#layout { flex:1; display:grid; grid-template-columns:340px 1fr 300px; min-height:0; }
.panel { background:var(--panel2); border-right:1px solid var(--line); display:flex; flex-direction:column; min-height:0; }
#drivers-panel { border-right:none; border-left:1px solid var(--line); }
.panel-head { display:flex; align-items:center; justify-content:space-between; padding:14px 14px 8px; }
.panel-head h2 { font-size:15px; font-weight:700; }
.btn-mini { background:rgba(14,165,233,.15); color:var(--accent2); border:1px solid rgba(14,165,233,.4); padding:5px 10px; border-radius:8px; font-size:12px; font-weight:600; }
.switch { display:flex; align-items:center; gap:6px; font-size:11px; color:var(--dim); cursor:pointer; }
.switch input { display:none; }
.switch span { width:30px; height:16px; border-radius:10px; background:#26313e; position:relative; transition:.2s; }
.switch span::after { content:''; position:absolute; width:12px; height:12px; border-radius:50%; background:#8fa2b5; top:2px; left:2px; transition:.2s; }
.switch input:checked + span { background:rgba(16,185,129,.4); }
.switch input:checked + span::after { background:var(--accent); left:16px; }
.tabs { display:flex; gap:6px; padding:4px 14px 8px; flex-wrap:wrap; }
.tab { font-size:11.5px; color:var(--dim); padding:6px 9px; border-radius:9px; border:1px solid transparent; display:flex; gap:5px; align-items:center; }
.tab b { background:#1b2632; border-radius:6px; padding:1px 6px; font-size:11px; }
.tab.active { color:var(--txt); background:var(--panel); border-color:var(--line); }
.search { width:calc(100% - 28px); margin:0 14px 10px; padding:8px 12px; font-size:13px; }
.scroll-list { flex:1; overflow-y:auto; padding:0 10px 12px; display:flex; flex-direction:column; gap:10px; }
.scroll-list::-webkit-scrollbar { width:6px; } .scroll-list::-webkit-scrollbar-thumb { background:#223041; border-radius:3px; }

/* task card */
.task-card { background:var(--panel); border:1px solid var(--line); border-radius:14px; padding:12px; transition:.15s; }
.task-card:hover { border-color:#2c3e50; }
.task-card.selected { border-color:var(--accent2); box-shadow:0 0 0 1px var(--accent2); }
.task-top { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.task-id { font-weight:800; font-size:13.5px; letter-spacing:.4px; }
.status-pill { font-size:10.5px; font-weight:700; padding:3px 9px; border-radius:20px; text-transform:capitalize; }
.st-unassigned { background:rgba(245,158,11,.15); color:var(--amber); }
.st-assigned { background:rgba(14,165,233,.15); color:var(--accent2); }
.st-accepted { background:rgba(14,165,233,.15); color:var(--accent2); }
.st-picked_up { background:rgba(168,85,247,.15); color:#c084fc; }
.st-completed { background:rgba(34,197,94,.15); color:var(--green); }
.task-client { font-size:12.5px; font-weight:600; }
.task-sub { font-size:11.5px; color:var(--dim); margin-bottom:8px; }
.task-times { display:flex; flex-direction:column; gap:3px; font-size:11.5px; color:var(--dim); margin-bottom:8px; }
.task-times b { color:var(--txt); font-weight:600; }
.late { color:var(--amber); font-weight:600; }
.prio-urgent { color:var(--red); font-size:10px; font-weight:800; text-transform:uppercase; letter-spacing:.5px; }
.prio-high { color:var(--amber); font-size:10px; font-weight:800; text-transform:uppercase; letter-spacing:.5px; }
.task-driver { display:flex; align-items:center; justify-content:space-between; gap:8px; border-top:1px dashed var(--line); padding-top:8px; font-size:12px; }
.avatar { width:26px; height:26px; border-radius:50%; background:linear-gradient(135deg,#1e3a4c,#0e5c46); display:flex; align-items:center; justify-content:center; font-size:10px; font-weight:700; flex-shrink:0; }
.assign-select { background:#0a0f15; border:1px solid var(--line); color:var(--txt); border-radius:8px; padding:5px 6px; font-size:11.5px; max-width:130px; }
.mini-actions { display:flex; gap:6px; }
.mini-btn { font-size:10.5px; padding:4px 8px; border-radius:7px; border:1px solid var(--line); color:var(--dim); }
.mini-btn:hover { color:var(--txt); border-color:var(--accent); }
.empty-state { text-align:center; color:#54647a; font-size:12.5px; padding:30px 10px; }

/* driver card */
.driver-card { display:flex; align-items:center; gap:10px; background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:10px 12px; }
.driver-card .avatar { width:32px; height:32px; font-size:12px; }
.driver-info { flex:1; min-width:0; }
.driver-name { font-size:13px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.driver-meta { font-size:11px; color:var(--dim); }
.dstatus { width:9px; height:9px; border-radius:50%; flex-shrink:0; }
.ds-free { background:var(--green); box-shadow:0 0 8px var(--green); }
.ds-busy { background:var(--amber); box-shadow:0 0 8px var(--amber); }
.ds-offline { background:#54647a; }

/* ---------- MAP ---------- */
#map-wrap { position:relative; min-width:0; }
#map { position:absolute; inset:0; background:#0a0e13; }
.leaflet-container { font:inherit; }
.leaflet-tile-pane { filter:saturate(.8); }
.dpin { border-radius:50% 50% 50% 4px; transform:rotate(-45deg); border:2px solid #fff2; display:flex; align-items:center; justify-content:center; box-shadow:0 4px 12px rgba(0,0,0,.5); }
.dpin b { transform:rotate(45deg); font-size:9px; color:#04121a; }
.dpin.free { background:var(--green); } .dpin.busy { background:var(--amber); } .dpin.offline { background:#54647a; opacity:.6; }
.tpin { border-radius:50%; border:2px solid #fff3; box-shadow:0 3px 10px rgba(0,0,0,.5); }
.tpin.pickup { background:var(--amber); } .tpin.drop { background:var(--accent2); }
.tpin.done { background:var(--green); opacity:.55; }
#map-overlay { position:absolute; right:14px; bottom:16px; z-index:1000; display:flex; flex-direction:column; gap:10px; align-items:flex-end; }
#ai-fab { display:flex; align-items:center; gap:8px; background:linear-gradient(135deg,var(--accent),var(--accent2)); color:#04121a; font-weight:800; border-radius:30px; padding:12px 18px; font-size:14px; box-shadow:0 8px 24px rgba(16,185,129,.35); }
.ai-pulse { width:9px; height:9px; border-radius:50%; background:#04121a; animation:pulse 1.6s infinite; }
@keyframes pulse { 0%,100%{opacity:.4} 50%{opacity:1} }
#watermark { position:absolute; left:12px; bottom:10px; z-index:1000; font-size:10px; color:#5b6b7d; letter-spacing:.5px; }
#activity-feed { position:absolute; left:12px; top:12px; z-index:1000; display:flex; flex-direction:column; gap:6px; max-width:300px; }
.feed-item { background:rgba(10,15,21,.85); border:1px solid var(--line); border-left:3px solid var(--accent); border-radius:8px; padding:6px 10px; font-size:11px; color:var(--dim); backdrop-filter:blur(6px); animation:slidein .3s; }
.feed-item b { color:var(--txt); font-weight:600; }
@keyframes slidein { from{transform:translateX(-12px);opacity:0} to{transform:none;opacity:1} }

/* ---------- AI PANEL ---------- */
#ai-panel { position:fixed; right:16px; bottom:16px; width:min(360px, calc(100vw - 32px)); height:min(480px, 70vh); background:rgba(13,19,27,.97); border:1px solid var(--line); border-radius:18px; z-index:2000; display:flex; flex-direction:column; box-shadow:0 24px 60px rgba(0,0,0,.6); overflow:hidden; }
.ai-head { display:flex; justify-content:space-between; align-items:center; padding:12px 14px; border-bottom:1px solid var(--line); }
.ai-sub { display:block; font-size:10.5px; color:var(--dim); font-weight:400; }
#ai-messages { flex:1; overflow-y:auto; padding:12px; display:flex; flex-direction:column; gap:8px; }
.ai-msg { max-width:85%; padding:9px 12px; border-radius:12px; font-size:12.5px; line-height:1.5; white-space:pre-line; }
.ai-msg.bot { background:#152030; border:1px solid var(--line); align-self:flex-start; }
.ai-msg.me { background:linear-gradient(135deg,rgba(16,185,129,.25),rgba(14,165,233,.25)); align-self:flex-end; }
.ai-suggest { display:flex; gap:6px; padding:0 12px 8px; flex-wrap:wrap; }
.ai-suggest button { font-size:11px; border:1px solid var(--line); border-radius:16px; padding:5px 10px; color:var(--dim); }
.ai-suggest button:hover { color:var(--accent); border-color:var(--accent); }
.ai-input-row { display:flex; gap:8px; padding:10px 12px; border-top:1px solid var(--line); }
.ai-input-row input { flex:1; }
#ai-send { background:linear-gradient(135deg,var(--accent),var(--accent2)); color:#04121a; border-radius:10px; padding:0 14px; font-weight:700; }

/* ---------- MODAL / TOAST ---------- */
.modal { position:fixed; inset:0; background:rgba(4,8,12,.7); display:flex; align-items:center; justify-content:center; z-index:3000; backdrop-filter:blur(4px); }
.modal-card { width:min(460px, 92vw); max-height:80vh; overflow-y:auto; background:var(--panel2); border:1px solid var(--line); border-radius:18px; padding:20px; }
.modal-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:14px; font-size:15px; }
.report-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.report-cell { background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:12px; }
.report-cell b { display:block; font-size:19px; }
.report-cell span { font-size:11px; color:var(--dim); }
.report-row { display:flex; justify-content:space-between; font-size:12.5px; padding:7px 2px; border-bottom:1px dashed var(--line); color:var(--dim); }
.report-row b { color:var(--txt); }
#toast { position:fixed; bottom:22px; left:50%; transform:translateX(-50%); background:#12202b; border:1px solid var(--accent); color:var(--txt); border-radius:12px; padding:10px 18px; font-size:13px; z-index:4000; box-shadow:0 10px 30px rgba(0,0,0,.5); }
#toast.err { border-color:var(--red); }

#phone-nav { display:none; }

/* ---------- HINTS ---------- */
.panel-hint { margin:0 14px 8px; font-size:11px; color:var(--dim); background:rgba(14,165,233,.08); border:1px dashed rgba(14,165,233,.35); border-radius:8px; padding:6px 9px; line-height:1.4; }
.panel-hint b { color:var(--accent2); font-weight:600; }
html.light .panel-hint { background:rgba(14,165,233,.07); }

/* ---------- TASK DRAWER ---------- */
#task-drawer { position:fixed; top:58px; right:0; bottom:0; width:min(360px, 94vw); background:var(--panel2); border-left:1px solid var(--line); z-index:2500; box-shadow:-16px 0 40px rgba(0,0,0,.35); display:flex; flex-direction:column; animation:drawerin .22s; }
@keyframes drawerin { from{transform:translateX(40px);opacity:0} to{transform:none;opacity:1} }
.drawer-head { display:flex; justify-content:space-between; align-items:center; padding:14px 16px; border-bottom:1px solid var(--line); font-size:14px; }
#drawer-body { padding:14px 16px; overflow-y:auto; display:flex; flex-direction:column; gap:12px; }
.drawer-kv { display:flex; justify-content:space-between; font-size:12.5px; color:var(--dim); padding:5px 0; border-bottom:1px dashed var(--line); }
.drawer-kv b { color:var(--txt); font-weight:600; text-align:right; }
.timeline { display:flex; flex-direction:column; gap:0; margin-top:4px; }
.tl-step { display:flex; gap:10px; align-items:flex-start; padding:6px 0; }
.tl-dot { width:14px; height:14px; border-radius:50%; border:2px solid #3a4a5c; margin-top:1px; flex-shrink:0; }
.tl-step.done .tl-dot { background:var(--green); border-color:var(--green); box-shadow:0 0 8px rgba(34,197,94,.5); }
.tl-step.now .tl-dot { border-color:var(--accent2); box-shadow:0 0 8px rgba(14,165,233,.5); }
.tl-lbl { font-size:12.5px; color:var(--dim); }
.tl-step.done .tl-lbl, .tl-step.now .tl-lbl { color:var(--txt); font-weight:600; }
.sla-chip { font-size:11px; font-weight:700; padding:3px 8px; border-radius:14px; }
.sla-ok { background:rgba(34,197,94,.15); color:var(--green); }
.sla-soon { background:rgba(245,158,11,.15); color:var(--amber); }
.sla-late { background:rgba(239,68,68,.15); color:var(--red); }
.drawer-actions { display:flex; flex-direction:column; gap:8px; margin-top:6px; }

/* ---------- TOUR ---------- */
#tour-overlay { position:fixed; inset:0; z-index:5000; }
#tour-hole { position:absolute; border-radius:14px; box-shadow:0 0 0 9999px rgba(3,6,10,.72); transition:all .3s; }
#tour-card { position:absolute; width:min(320px, 86vw); background:var(--panel2); border:1px solid var(--line); border-radius:16px; padding:16px; box-shadow:0 20px 50px rgba(0,0,0,.5); transition:all .3s; }
#tour-step-lbl { font-size:10px; color:var(--accent2); font-weight:700; letter-spacing:1px; text-transform:uppercase; margin-bottom:4px; }
#tour-title { font-size:14px; display:block; margin-bottom:4px; }
#tour-text { font-size:12.5px; color:var(--dim); line-height:1.55; margin-bottom:12px; }
.tour-btns { display:flex; justify-content:space-between; align-items:center; }
.tour-btns .btn-primary { margin-top:0; padding:8px 18px; font-size:13px; }

/* ---------- THEME ---------- */
.logo-b { display:none; }
html.light .logo-b { display:block; margin:0 auto 6px; width:150px; }
html.light .logo-w { display:none; }
.theme-btn { position:absolute; top:14px; right:14px; border:1px solid var(--line); border-radius:10px; padding:6px 10px; color:var(--dim); font-size:14px; }
.theme-btn:hover { color:var(--txt); border-color:var(--accent2); }
.login-card { position:relative; }
.select { background:#0a0f15; border:1px solid var(--line); border-radius:10px; padding:10px; color:var(--txt); width:100%; }

html.light {
  --bg:#eef2f6; --panel:#ffffff; --panel2:#f5f7fa; --line:#d8e1ea;
  --txt:#17222e; --dim:#5b6d80;
}
html.light body { background:var(--bg); color:var(--txt); }
html.light #login-screen { background:radial-gradient(1200px 700px at 70% 20%, #dde8f0, var(--bg)); }
html.light .login-glow { opacity:.18; }
html.light .login-card { background:rgba(255,255,255,.94); box-shadow:0 24px 60px rgba(90,110,130,.25); }
html.light input, html.light .select { background:#fff; border-color:#c9d5e0; color:var(--txt); }
html.light input:focus { border-color:var(--accent2); }
html.light .assign-select { background:#fff; border-color:#c9d5e0; color:var(--txt); }
html.light .login-foot { color:#8a99a9; }
html.light #topbar { background:rgba(255,255,255,.94); }
html.light .tab b { background:#e4ebf2; }
html.light .leaflet-tile-pane { filter:none; }
html.light #map { background:#dde3e9; }
html.light .feed-item { background:rgba(255,255,255,.88); }
html.light #toast { background:#fff; }
html.light #ai-panel { background:rgba(255,255,255,.97); }
html.light .ai-msg.bot { background:#eef2f7; }
html.light #watermark { color:#8a99a9; }
html.light .task-card, html.light .driver-card { box-shadow:0 1px 3px rgba(90,110,130,.08); }
html.light .task-card.selected { box-shadow:0 0 0 1px var(--accent2); }
html.light .modal-card { box-shadow:0 24px 60px rgba(90,110,130,.3); }
html.light #phone-nav { background:rgba(255,255,255,.97); }
html.light .login-glow.g1 { background:var(--accent); }
html.light .login-glow.g2 { background:var(--accent2); }

/* ---------- PHONE ---------- */
@media (max-width: 820px) {
  #layout { grid-template-columns:1fr; }
  .panel, #map-wrap { display:none; }
  #layout.view-map #map-wrap { display:block; position:absolute; inset:58px 0 56px 0; }
  #layout.view-tasks #tasks-panel { display:flex; position:absolute; inset:58px 0 56px 0; }
  #layout.view-drivers #drivers-panel { display:flex; position:absolute; inset:58px 0 56px 0; border-left:none; }
  #topbar { gap:8px; padding:0 10px; }
  .brand-mark.small { font-size:12px; letter-spacing:1px; }
  .brand-mark.small .brand-thin { display:none; }
  .brand-mark.small .demo-badge { font-size:8px; padding:2px 5px; }
  .role-badge { font-size:9px; padding:3px 7px; }
  .topbar-stats { display:none; }
  .clock { display:none; }
  #watermark { display:none; }
  .btn-ghost { padding:6px 9px; font-size:11px; }
  #phone-nav { display:flex; position:fixed; bottom:0; left:0; right:0; height:56px; background:rgba(14,20,28,.97); border-top:1px solid var(--line); z-index:1500; }
  .pnav { flex:1; color:var(--dim); font-size:12.5px; font-weight:600; }
  .pnav.active { color:var(--accent); }
  #activity-feed { max-width:220px; }
  #map-overlay { bottom:70px; }
  #watermark { bottom:60px; }
}
