:root {
  --brand: #E31E24;
  --brand-dark: #B8141A;
  --brand-soft: #FDECEC;
  --ink: #15171C;
  --ink-2: #3A3F4A;
  --muted: #6B7280;
  --line: #E6E8EC;
  --bg: #F4F5F7;
  --card: #FFFFFF;
  --ok: #12925B;
  --ok-soft: #E3F6EC;
  --warn: #B86E00;
  --warn-soft: #FFF3DC;
  --info: #2563EB;
  --info-soft: #E7EEFF;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(17, 24, 39, .10);
  --shadow-lg: 0 18px 48px rgba(17, 24, 39, .18);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Hind Siliguri', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 600; cursor: pointer;
  background: var(--brand); color: #fff; transition: transform .08s, background .15s, opacity .15s;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.lg { padding: 15px 20px; font-size: 17px; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn.ghost { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.ghost:hover { background: #F7F7F8; }
.btn.dark { background: var(--ink); }
.btn.dark:hover { background: #000; }
.btn.ok { background: var(--ok); }
.btn.ok:hover { background: #0C7748; }
.btn.soft { background: var(--brand-soft); color: var(--brand-dark); }
.btn.link { background: none; color: var(--brand); padding: 6px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: #fff; box-shadow: var(--shadow);
  display: grid; place-items: center; cursor: pointer; font-size: 18px; flex: none;
}
.field { display: block; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.input, select.input, textarea.input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 11px; padding: 11px 13px; background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ---------- chips, badges, cards ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 13px;
  font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: #EEF0F3; color: var(--ink-2); }
.badge.searching, .badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.accepted, .badge.arrived { background: var(--info-soft); color: var(--info); }
.badge.started { background: #F1E8FF; color: #7C3AED; }
.badge.completed, .badge.active, .badge.on { background: var(--ok-soft); color: var(--ok); }
.badge.cancelled, .badge.expired, .badge.suspended, .badge.blocked { background: var(--brand-soft); color: var(--brand-dark); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(0,0,0,.04); border: 1px solid var(--line); padding: 16px; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.empty .big { font-size: 38px; }

/* ---------- toast ---------- */
#toasts { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 9999; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); animation: tin .2s ease-out; font-size: 14.5px; }
.toast.err { background: var(--brand-dark); }
.toast.ok { background: var(--ok); }
@keyframes tin { from { transform: translateY(-8px); opacity: 0; } }

/* ---------- location gate & auth ---------- */
.gate, .auth {
  position: fixed; inset: 0; z-index: 5000; overflow-y: auto;
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-dark) 55%, #7E0C11 100%);
  display: grid; place-items: center; padding: 22px;
}
.gate .box, .auth .box { width: min(100%, 420px); background: #fff; border-radius: 22px; padding: 26px 22px; box-shadow: var(--shadow-lg); }
.gate .pin { font-size: 54px; text-align: center; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.gate h2 { text-align: center; margin: 8px 0 6px; }
.gate p { text-align: center; color: var(--muted); margin: 0 0 18px; }
.gate .err { color: var(--brand-dark); background: var(--brand-soft); border-radius: 10px; padding: 10px 12px; text-align: left; font-size: 13.5px; }
.brandmark { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 22px; }
.brandmark .logo { width: 40px; height: 40px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 20px; }
.brandmark small { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.auth .tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 12px; padding: 4px; margin: 18px 0; }
.auth .tabs button { border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 600; cursor: pointer; color: var(--muted); }
.auth .tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.demo-hint { margin-top: 14px; font-size: 12.5px; background: var(--bg); border-radius: 10px; padding: 9px 12px; color: var(--ink-2); }

/* ---------- install banner ---------- */
.install-bar {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 4000; background: var(--ink); color: #fff;
  border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow-lg);
  max-width: 460px; margin: 0 auto;
}
.install-bar img { width: 40px; height: 40px; border-radius: 10px; }
.install-bar .x { background: none; border: 0; color: #9CA3AF; font-size: 20px; cursor: pointer; }

/* ---------- map apps (user & rider) ---------- */
.mapapp { position: fixed; inset: 0; }
.mapapp #map { position: absolute; inset: 0; z-index: 1; }
.topbar { position: absolute; z-index: 1000; left: 12px; right: 12px; top: 12px; display: flex; gap: 10px; align-items: center; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.topbar .title { background: #fff; border-radius: 999px; box-shadow: var(--shadow); padding: 8px 16px 8px 8px; display: flex; align-items: center; gap: 8px; font-weight: 700; }
.topbar .title .logo { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 14px; }
.sheet {
  position: absolute; z-index: 1000; left: 0; right: 0; bottom: 0; max-height: 64vh; overflow-y: auto;
  background: #fff; border-radius: 22px 22px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.12); padding: 10px 16px 18px;
}
.sheet::before { content: ''; display: block; width: 42px; height: 5px; border-radius: 9px; background: #D9DCE1; margin: 0 auto 12px; }
.sheet h3 { font-size: 19px; }
@media (min-width: 900px) {
  .sheet { left: 16px; right: auto; top: 76px; bottom: 16px; width: 400px; max-height: none; border-radius: 20px; }
  .sheet::before { display: none; }
  .install-bar { left: auto; right: 16px; margin: 0; }
}
.searchbox { display: flex; align-items: center; gap: 10px; background: var(--bg); border-radius: 14px; padding: 13px 14px; cursor: text; border: 1.5px solid transparent; }
.searchbox:focus-within { border-color: var(--brand); background: #fff; }
.searchbox input { border: 0; background: none; outline: none; flex: 1; min-width: 0; font-size: 16px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.p { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.dot.d { background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); border-radius: 2px; }
.route { position: relative; padding-left: 22px; }
.route .stop { position: relative; padding: 4px 0; }
.route .stop .dot { position: absolute; left: -20px; top: 11px; }
.route::before { content: ''; position: absolute; left: 6px; top: 18px; bottom: 18px; border-left: 2px dashed #CBD0D7; }
.list { display: grid; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list .item:last-child { border-bottom: 0; }
.list .item:hover { background: #FAFAFB; }
.list .ic { width: 38px; height: 38px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; flex: none; font-size: 18px; }
.vopt { display: flex; align-items: center; gap: 12px; border: 1.5px solid var(--line); border-radius: 14px; padding: 11px 13px; cursor: pointer; transition: border-color .15s; }
.vopt + .vopt { margin-top: 9px; }
.vopt.on { border-color: var(--brand); background: #FFF8F8; }
.vopt.off { opacity: .5; }
.vopt .vi { font-size: 30px; width: 46px; text-align: center; }
.vopt .fare { font-weight: 700; font-size: 18px; }
.statusline { display: flex; gap: 6px; margin: 12px 0; }
.statusline i { flex: 1; height: 5px; border-radius: 9px; background: var(--line); }
.statusline i.on { background: var(--brand); }
.person { display: flex; align-items: center; gap: 12px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-weight: 700; font-size: 20px; flex: none; }
.plate { display: inline-block; white-space: nowrap; background: #FFF7D6; border: 1px solid #F0D98A; border-radius: 6px; padding: 1px 8px; font-size: 13px; font-weight: 600; }
.pulse { width: 92px; height: 92px; margin: 10px auto 6px; border-radius: 50%; background: var(--brand-soft); display: grid; place-items: center; font-size: 38px; position: relative; }
.pulse::before, .pulse::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--brand); animation: ring 1.8s ease-out infinite; }
.pulse::after { animation-delay: .9s; }
@keyframes ring { from { transform: scale(1); opacity: .7; } to { transform: scale(1.9); opacity: 0; } }
.stars { display: flex; gap: 6px; justify-content: center; font-size: 34px; }
.stars button { background: none; border: 0; cursor: pointer; filter: grayscale(1) opacity(.4); }
.stars button.on { filter: none; }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--bg); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 12px; color: var(--muted); }
.reqcard { border: 1.5px solid var(--line); border-radius: 16px; padding: 14px; animation: tin .25s ease-out; }
.reqcard + .reqcard { margin-top: 10px; }
.reqcard.new { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.reqcard .fare { font-size: 24px; font-weight: 700; }
.toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; background: #fff; border-radius: 999px; padding: 6px 14px 6px 6px; box-shadow: var(--shadow); cursor: pointer; font-weight: 700; border: 0; }
.toggle .knob { width: 46px; height: 28px; border-radius: 99px; background: #D1D5DB; position: relative; transition: background .2s; }
.toggle .knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle.on .knob { background: var(--ok); }
.toggle.on .knob::after { left: 21px; }

/* drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 3000; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(86vw, 330px); background: #fff; z-index: 3001; padding: 20px 16px; overflow-y: auto; animation: din .2s ease-out; }
@keyframes din { from { transform: translateX(-100%); } }
.drawer .me { background: var(--brand); color: #fff; border-radius: 16px; padding: 16px; margin-bottom: 14px; }
.drawer .me .avatar { background: rgba(255,255,255,.2); color: #fff; }
.drawer nav button { display: flex; width: 100%; gap: 12px; align-items: center; padding: 12px 10px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: left; font-size: 15.5px; }
.drawer nav button:hover { background: var(--bg); }

/* map markers */
.vmark { width: 40px; height: 40px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 21px; box-shadow: 0 3px 10px rgba(0,0,0,.25); border: 2px solid #fff; transition: transform .2s; }
.vmark.sel { border-color: var(--brand); transform: scale(1.15); }
.memark { width: 20px; height: 20px; border-radius: 50%; background: #2563EB; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(37,99,235,.22), 0 2px 6px rgba(0,0,0,.3); }
.pinmark { font-size: 34px; line-height: 1; filter: drop-shadow(0 3px 3px rgba(0,0,0,.3)); }
.leaflet-popup-content { font-family: 'Hind Siliguri', system-ui, sans-serif; font-size: 14px; margin: 12px 14px; }
.leaflet-popup-content-wrapper { border-radius: 14px; }
.banner { border-radius: 12px; padding: 10px 12px; font-size: 13.5px; }
.banner.warn { background: var(--warn-soft); color: #7A4A00; }
.banner.info { background: var(--info-soft); color: #1E40AF; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,17,22,.45); z-index: 4500; display: grid; place-items: center; padding: 16px; }
.modal { background: #fff; border-radius: 18px; width: min(100%, 520px); max-height: 92vh; overflow-y: auto; padding: 20px; box-shadow: var(--shadow-lg); animation: tin .2s; }
.modal h3 { margin-bottom: 14px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ---------- staff panel (admin & agent) ---------- */
.panel { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: #12141A; color: #C9CDD3; padding: 18px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow-y: auto; }
.side .brandmark { color: #fff; font-size: 19px; padding: 4px 6px 18px; }
.side .brandmark small { color: #8B919C; }
.side nav { display: grid; gap: 2px; }
.side nav button { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 0; background: none; color: inherit; border-radius: 10px; cursor: pointer; text-align: left; font-size: 15px; }
.side nav button:hover { background: #1D2028; color: #fff; }
.side nav button.on { background: var(--brand); color: #fff; }
.side nav button .cnt { margin-left: auto; background: var(--brand); color: #fff; font-size: 11.5px; border-radius: 99px; padding: 0 7px; }
.side nav button.on .cnt { background: #fff; color: var(--brand); }
.side .foot { margin-top: auto; padding-top: 16px; border-top: 1px solid #23262D; font-size: 13.5px; }
.pmain { min-width: 0; }
.phead { position: sticky; top: 0; z-index: 20; background: rgba(244,245,247,.92); backdrop-filter: blur(8px); display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); }
.phead h2 { font-size: 21px; }
.phead .live { font-size: 12.5px; color: var(--ok); display: flex; align-items: center; gap: 6px; }
.phead .live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: ring2 1.5s infinite; }
@keyframes ring2 { 50% { opacity: .3; } }
#pview { padding: 22px 24px 40px; }
#mBtn { display: none; }
@media (max-width: 860px) {
  .panel { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 3001; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: var(--shadow-lg); }
  #mBtn { display: grid; box-shadow: none; background: #fff; border: 1px solid var(--line); }
  .phead, #pview { padding-left: 14px; padding-right: 14px; }
}
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.kpi .l { color: var(--muted); font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.kpi .v { font-size: 27px; font-weight: 700; margin-top: 4px; }
.kpi.hl { background: var(--brand); color: #fff; border-color: var(--brand); }
.kpi.hl .l { color: rgba(255,255,255,.8); }
.tbl-wrap { background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 11px 14px; border-bottom: 1px solid var(--line); background: #FAFAFB; white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .acts { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { width: auto; min-width: 220px; padding: 9px 12px; }
.sec-title { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; }
.sec-title h3 { font-size: 17px; }
#livemap { height: calc(100vh - 170px); min-height: 420px; border-radius: 16px; border: 1px solid var(--line); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.vmark.off { filter: grayscale(1); opacity: .65; }
.calc { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.calc .res { display: flex; gap: 8px; flex-wrap: wrap; }
.calc .res span { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px 11px; }
.logo-img { width: 40px; height: 40px; border-radius: 12px; flex: none; display: block; }
.msgs { display: grid; gap: 12px; max-width: 860px; }
.msg.unread { border-left: 4px solid var(--brand); }
