/* ============================================================
   RouteOptima / TSP Dispatch — design system
   Dark-indigo console shell, dotted-route signature motif.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root{
  --ink:#10142c;
  --sidebar-bg:#12152f;
  --sidebar-bg-2:#171b3d;
  --sidebar-active:#2a3378;
  --sidebar-active-2:#3647b8;
  --sidebar-text:#aab0d6;
  --sidebar-text-dim:#6d75a8;

  --primary:#3647c9;
  --primary-600:#2c39ac;
  --primary-700:#232e8c;
  --primary-50:#eef0ff;
  --primary-100:#dde0ff;

  --bg:#f3f5fb;
  --surface:#ffffff;
  --border:#e6e9f5;
  --border-strong:#d4d9ee;

  --text:#171b3d;
  --text-muted:#6a7096;
  --text-faint:#9498b8;

  --success:#16a34a;
  --success-bg:#e9faf0;
  --danger:#e0405a;
  --danger-bg:#fdecef;
  --warning:#d9822b;
  --warning-bg:#fdf3e6;
  --info:#2f7ee0;
  --info-bg:#eaf3fe;

  --radius-sm:8px;
  --radius:14px;
  --radius-lg:20px;
  --shadow-sm:0 1px 2px rgba(16,20,44,.06);
  --shadow:0 6px 20px -4px rgba(16,20,44,.10), 0 2px 6px -2px rgba(16,20,44,.06);
  --shadow-lg:0 18px 40px -12px rgba(16,20,44,.22);

  --sidebar-w:248px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:'Plus Jakarta Sans',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  background:var(--bg);
  color:var(--text);
  font-size:15px;
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4,h5{
  font-family:'Plus Jakarta Sans',sans-serif;
  font-weight:800;
  letter-spacing:-0.02em;
  margin:0 0 4px;
  color:var(--text);
}
a{color:var(--primary);text-decoration:none}
.mono{font-family:'JetBrains Mono',monospace}

/* Prevent unsized inline SVG icons from rendering at the browser's
   default intrinsic size (which caused oversized buttons/icons).
   Specific rules below (sidebar, stat-card, search-box) still win
   via higher specificity. */
svg{width:1em;height:1em;display:inline-block;vertical-align:-0.15em}
/* Leaflet draws its route lines and marker layers through its own
   internal <svg> panes — the blanket rule above must not touch those,
   or the polylines render clipped to almost nothing. */
.leaflet-container svg,
.leaflet-pane svg,
.leaflet-overlay-pane svg,
.leaflet-marker-pane svg,
.custom-pin svg{
  width:auto;height:auto;display:block;vertical-align:baseline;
}

/* ---------- Focus visibility ---------- */
a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,.btn:focus-visible{
  outline:2px solid var(--primary);outline-offset:2px;
}
@media (prefers-reduced-motion: reduce){*{animation:none!important;transition:none!important}}

/* ============================================================
   ROUTE MOTIF — dotted path w/ pin, reused as the signature
   ============================================================ */
.route-motif{position:relative;overflow:hidden}
.route-motif svg{position:absolute;inset:0;width:100%;height:100%}
.dash-path{stroke-dasharray:2 10;stroke-linecap:round}

/* ============================================================
   PUBLIC SHELL (landing + login — no sidebar)
   ============================================================ */
.public-nav{
  display:flex;align-items:center;justify-content:space-between;
  padding:18px 40px;background:var(--ink);color:#fff;
}
.public-nav .brand{display:flex;align-items:center;gap:10px;font-weight:800;font-size:17px}
.public-nav .brand .dot{width:9px;height:9px;border-radius:50%;background:linear-gradient(135deg,#5d6cff,#8b5cff)}
.public-nav a{color:#c7cbef;font-weight:600;font-size:14px;margin-left:26px}
.public-nav a:hover{color:#fff}
.public-nav .cta{background:var(--primary);color:#fff;padding:9px 18px;border-radius:999px}
.public-nav .cta:hover{background:var(--primary-600);color:#fff}

/* ---------- Login ---------- */
.auth-wrap{
  min-height:100vh;
  display:flex;align-items:center;justify-content:center;
  background:
    radial-gradient(600px 400px at 15% 15%, rgba(93,108,255,.35), transparent 60%),
    radial-gradient(500px 380px at 90% 85%, rgba(139,92,255,.28), transparent 60%),
    linear-gradient(160deg,#0c0e26 0%,#141a45 55%,#1c2264 100%);
  padding:24px;position:relative;
}
.auth-wrap .path-decor{position:absolute;inset:0;opacity:.5;pointer-events:none}
.auth-card{
  width:100%;max-width:380px;background:rgba(18,21,55,.72);
  border:1px solid rgba(255,255,255,.09);
  border-radius:var(--radius-lg);
  padding:36px 34px 30px;
  backdrop-filter:blur(18px);
  box-shadow:var(--shadow-lg);
  position:relative;z-index:1;
  color:#e7e9ff;
}
.auth-card .brand-row{display:flex;align-items:center;gap:10px;margin-bottom:22px}
.auth-card .brand-row .mark{
  width:34px;height:34px;border-radius:10px;
  background:linear-gradient(135deg,#5d6cff,#8b5cff);
  display:flex;align-items:center;justify-content:center;color:#fff;font-weight:800;font-size:15px;
}
.auth-card .brand-row span{font-weight:800;font-size:16px;color:#fff}
.auth-card h1{font-size:22px;color:#fff;margin-bottom:2px}
.auth-card p.sub{color:#a9addb;font-size:13.5px;margin-bottom:24px}
.field{margin-bottom:16px}
.field label{display:block;font-size:12.5px;font-weight:600;color:#b7bbe8;margin-bottom:6px;letter-spacing:.02em;text-transform:uppercase}
.field input{
  width:100%;padding:11px 13px;border-radius:10px;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.06);color:#fff;font-size:14.5px;
}
.field input::placeholder{color:#767bb0}
.field input:focus{outline:none;border-color:#7f8bff;background:rgba(255,255,255,.09)}
.btn-auth{
  width:100%;padding:12px;border:0;border-radius:10px;
  background:linear-gradient(135deg,#4c5aff,#7a52f4);color:#fff;font-weight:700;font-size:14.5px;
  cursor:pointer;margin-top:4px;box-shadow:0 10px 22px -8px rgba(90,90,255,.55);
}
.btn-auth:hover{filter:brightness(1.07)}
.auth-foot{margin-top:20px;text-align:center;font-size:12px;color:#787cb0}
.demo-chip{
  margin-top:16px;padding:9px 12px;border-radius:9px;background:rgba(255,255,255,.05);
  border:1px dashed rgba(255,255,255,.16);font-size:12px;color:#b7bbe8;text-align:center;
}

/* ============================================================
   APP SHELL (authenticated — sidebar + topbar)
   ============================================================ */
.app-shell{display:flex;min-height:100vh}

.sidebar{
  width:var(--sidebar-w);flex:none;
  background:linear-gradient(180deg,var(--sidebar-bg),var(--sidebar-bg-2));
  color:var(--sidebar-text);
  display:flex;flex-direction:column;
  position:sticky;top:0;height:100vh;
}
.sidebar .brand{
  display:flex;align-items:center;gap:10px;
  padding:22px 22px 18px;
}
.sidebar .brand .mark{
  width:32px;height:32px;border-radius:9px;
  background:linear-gradient(135deg,#5d6cff,#8b5cff);
  display:flex;align-items:center;justify-content:center;color:#fff;font-weight:800;font-size:14px;
}
.sidebar .brand span{color:#fff;font-weight:800;font-size:15.5px;letter-spacing:-.01em}

.sidebar nav{flex:1;padding:10px 14px;display:flex;flex-direction:column;gap:2px}
.sidebar nav a{
  display:flex;align-items:center;gap:11px;
  padding:10px 12px;border-radius:10px;
  color:var(--sidebar-text);font-weight:600;font-size:13.8px;
  transition:background .15s,color .15s;
}
.sidebar nav a svg{width:17px;height:17px;flex:none;opacity:.85}
.sidebar nav a:hover{background:rgba(255,255,255,.06);color:#fff}
.sidebar nav a.active{
  background:linear-gradient(135deg,var(--sidebar-active-2),var(--sidebar-active));
  color:#fff;box-shadow:0 4px 14px -4px rgba(54,71,201,.6);
}
.sidebar .foot{padding:14px;border-top:1px solid rgba(255,255,255,.08)}
.sidebar .foot a{
  display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:10px;
  color:var(--sidebar-text-dim);font-weight:600;font-size:13.5px;
}
.sidebar .foot a:hover{background:rgba(255,255,255,.06);color:#fff}

.main{flex:1;min-width:0;display:flex;flex-direction:column}
.topbar{
  display:flex;align-items:center;justify-content:space-between;
  padding:18px 30px;background:var(--surface);border-bottom:1px solid var(--border);
  position:sticky;top:0;z-index:5;
}
.topbar .title h1{font-size:19px}
.topbar .title p{margin:0;color:var(--text-muted);font-size:13px}
.topbar .user{display:flex;align-items:center;gap:10px}
.topbar .avatar{
  width:34px;height:34px;border-radius:50%;
  background:var(--primary-50);color:var(--primary-700);
  display:flex;align-items:center;justify-content:center;font-weight:800;font-size:13px;
}
.page{padding:26px 30px 50px}

/* ---------- flash messages ---------- */
.flash{
  padding:12px 16px;border-radius:10px;margin-bottom:18px;font-size:13.8px;font-weight:600;
  border:1px solid transparent;
}
.flash-success{background:var(--success-bg);color:#0f7a37;border-color:#c7f0d6}
.flash-danger{background:var(--danger-bg);color:#b21f3a;border-color:#f6c6d0}
.flash-info{background:var(--info-bg);color:#1c5aa6;border-color:#c7dffb}

/* ============================================================
   Cards / grid / stats
   ============================================================ */
.card{
  background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);
  box-shadow:var(--shadow-sm);
}
.card-pad{padding:22px}
.grid{display:grid;gap:16px}
.grid-4{grid-template-columns:repeat(4,1fr)}
.grid-2{grid-template-columns:repeat(2,1fr)}
.grid-split{grid-template-columns:1.5fr 1fr}
@media (max-width:1080px){.grid-4{grid-template-columns:repeat(2,1fr)}.grid-split{grid-template-columns:1fr}}
@media (max-width:620px){.grid-4,.grid-2{grid-template-columns:1fr}}

.stat-card{
  background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);
  padding:18px 20px;box-shadow:var(--shadow-sm);
  display:flex;flex-direction:column;gap:10px;
}
.stat-card .icon{
  width:38px;height:38px;border-radius:10px;display:flex;align-items:center;justify-content:center;
}
.stat-card .icon svg{width:19px;height:19px}
.stat-card .label{font-size:12.5px;color:var(--text-muted);font-weight:600}
.stat-card .value{font-size:26px;font-weight:800;letter-spacing:-.02em}
.icon-indigo{background:var(--primary-50);color:var(--primary-700)}
.icon-green{background:var(--success-bg);color:var(--success)}
.icon-blue{background:var(--info-bg);color:var(--info)}
.icon-amber{background:var(--warning-bg);color:var(--warning)}

.section-title{display:flex;align-items:baseline;justify-content:space-between;margin-bottom:14px}
.section-title h2{font-size:15.5px}
.section-title p{margin:2px 0 0;color:var(--text-muted);font-size:12.8px}

/* ---------- mini bar chart (deliveries per day) ---------- */
.bars{display:flex;align-items:flex-end;gap:10px;height:120px;padding-top:10px}
.bars .bar-col{flex:1;display:flex;flex-direction:column;align-items:center;gap:8px;height:100%;justify-content:flex-end}
.bars .bar{
  width:100%;max-width:30px;border-radius:6px 6px 3px 3px;
  background:linear-gradient(180deg,var(--primary-600),var(--primary));
  min-height:4px;
}
.bars .bar-label{font-size:11px;color:var(--text-faint);font-weight:600}

/* ---------- top riders list ---------- */
.rank-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}
.rank-list li{display:flex;align-items:center;gap:12px;padding:9px 4px;border-bottom:1px solid var(--border)}
.rank-list li:last-child{border-bottom:0}
.rank-num{
  width:22px;height:22px;border-radius:6px;background:var(--primary-50);color:var(--primary-700);
  font-size:11.5px;font-weight:800;display:flex;align-items:center;justify-content:center;flex:none;
}
.rank-name{font-weight:700;font-size:13.6px;flex:1}
.rank-count{font-size:12.6px;color:var(--text-muted);font-weight:600}

/* ============================================================
   Forms
   ============================================================ */
label.f-label{display:block;font-size:12.3px;font-weight:700;color:var(--text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.02em}
input.f-input,select.f-input{
  width:100%;padding:10px 12px;border-radius:9px;border:1px solid var(--border-strong);
  background:var(--surface);font-size:14px;color:var(--text);font-family:inherit;
}
input.f-input:focus,select.f-input:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 3px var(--primary-50)}
.form-row{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:14px;margin-bottom:16px}

/* ---------- buttons ---------- */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:7px;
  padding:10px 18px;border-radius:9px;font-weight:700;font-size:13.8px;
  border:1px solid transparent;cursor:pointer;font-family:inherit;text-decoration:none;
  transition:filter .12s, background .12s;
}
.btn-primary{background:var(--primary);color:#fff;box-shadow:0 6px 16px -6px rgba(54,71,201,.55)}
.btn-primary:hover{background:var(--primary-600);color:#fff}
.btn-success{background:var(--success);color:#fff}
.btn-success:hover{filter:brightness(1.05);color:#fff}
.btn-outline{background:var(--surface);border-color:var(--border-strong);color:var(--text)}
.btn-outline:hover{background:var(--bg)}
.btn-danger-ghost{background:var(--danger-bg);color:#b21f3a;border-color:#f6c6d0}
.btn-danger-ghost:hover{background:#fbd7de}
.btn-link-ghost{background:var(--primary-50);color:var(--primary-700)}
.btn-link-ghost:hover{background:var(--primary-100)}
.btn-block{width:100%}
.btn-sm{padding:6px 12px;font-size:12.5px;border-radius:7px}

/* ============================================================
   Tables
   ============================================================ */
.table-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;box-shadow:var(--shadow-sm)}
.table-toolbar{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:16px 20px;border-bottom:1px solid var(--border);flex-wrap:wrap}
.search-box{
  display:flex;align-items:center;gap:8px;background:var(--bg);border:1px solid var(--border-strong);
  border-radius:9px;padding:8px 12px;min-width:220px;flex:1;max-width:320px;
}
.search-box svg{width:15px;height:15px;color:var(--text-faint);flex:none}
.search-box input{border:0;background:transparent;outline:0;font-size:13.5px;width:100%;color:var(--text)}
table.data{width:100%;border-collapse:collapse}
table.data th{
  text-align:left;font-size:11.5px;text-transform:uppercase;letter-spacing:.04em;color:var(--text-faint);
  font-weight:700;padding:11px 20px;border-bottom:1px solid var(--border);background:var(--bg);
}
table.data td{padding:13px 20px;border-bottom:1px solid var(--border);font-size:13.8px;vertical-align:middle}
table.data tr:last-child td{border-bottom:0}
table.data tr:hover td{background:#fbfbfe}

.badge{
  display:inline-flex;align-items:center;gap:5px;padding:4px 10px;border-radius:999px;
  font-size:11.8px;font-weight:700;
}
.badge::before{content:'';width:6px;height:6px;border-radius:50%;background:currentColor}
.badge-green{background:var(--success-bg);color:var(--success)}
.badge-amber{background:var(--warning-bg);color:var(--warning)}
.badge-grey{background:#eef0f6;color:#6a7096}
.badge-blue{background:var(--info-bg);color:var(--info)}

.empty-row td{text-align:center;padding:40px 20px;color:var(--text-faint);font-size:13.5px}

.action-link{
  color:var(--primary);font-weight:700;font-size:12.8px;
  background:none;border:0;padding:0;cursor:pointer;font-family:inherit;
}
.action-link:hover{text-decoration:underline}
.action-link.danger{color:var(--danger)}

/* ============================================================
   Optimize page
   ============================================================ */
.stop-check{
  display:flex;align-items:flex-start;gap:11px;border:1px solid var(--border-strong);
  border-radius:10px;padding:11px 13px;margin-bottom:9px;cursor:pointer;transition:border-color .12s,background .12s;
}
.stop-check:hover{border-color:var(--primary);background:var(--primary-50)}
.stop-check input{margin-top:3px;accent-color:var(--primary)}
.stop-check .t{font-weight:700;font-size:13.6px}
.stop-check .s{color:var(--text-muted);font-size:12.4px}
#map{
  height:100%;min-height:440px;border-radius:var(--radius);overflow:hidden;
  border:1px solid var(--border);background:var(--bg);
}
.map-col{display:flex;flex-direction:column}
.metric-box{
  background:var(--bg);border:1px solid var(--border);border-radius:10px;padding:12px 14px;text-align:left;
}
.metric-box small{display:block;color:var(--text-muted);font-size:11.3px;font-weight:700;text-transform:uppercase;letter-spacing:.03em;margin-bottom:3px}
.metric-box strong{font-size:16.5px}
#route-list{list-style:none;padding:0;margin:14px 0 0;display:flex;flex-direction:column;gap:8px}
#route-list li{
  display:flex;align-items:center;gap:11px;background:var(--bg);border:1px solid var(--border);
  border-radius:9px;padding:9px 13px;font-size:13.5px;
}
#route-list li .n{
  width:22px;height:22px;border-radius:50%;background:var(--primary);color:#fff;font-size:11px;font-weight:800;
  display:flex;align-items:center;justify-content:center;flex:none;
}
#route-list li .x-remove,.stop-row .x-remove{
  margin-left:auto;background:none;border:0;color:var(--text-faint);cursor:pointer;
  font-size:15px;line-height:1;padding:2px 4px;border-radius:5px;
}
#route-list li .x-remove:hover,.stop-row .x-remove:hover{background:var(--danger-bg);color:var(--danger)}

.stop-row{
  display:flex;align-items:center;gap:10px;background:var(--bg);border:1px solid var(--border);
  border-radius:9px;padding:9px 12px;margin-bottom:8px;font-size:13.4px;
}
.stop-row .n{
  width:20px;height:20px;border-radius:50%;background:var(--primary-50);color:var(--primary-700);
  font-size:10.5px;font-weight:800;display:flex;align-items:center;justify-content:center;flex:none;
}
.stop-row .txt{flex:1;min-width:0}
.stop-row .txt b{display:block;font-size:13.4px}
.stop-row .txt span{display:block;font-size:11.6px;color:var(--text-muted)}
.add-location-row{display:flex;gap:8px;margin-top:4px}
.add-location-row select{flex:1}

.map-toggle{
  position:absolute;top:12px;left:12px;z-index:400;background:var(--surface);
  border-radius:9px;padding:3px;display:flex;gap:2px;box-shadow:var(--shadow);border:1px solid var(--border);
}
.map-toggle button{
  border:0;background:transparent;padding:6px 12px;font-size:12px;font-weight:700;border-radius:7px;
  color:var(--text-muted);cursor:pointer;font-family:inherit;
}
.map-toggle button.active{background:var(--primary);color:#fff}
.map-col{position:relative}

/* ============================================================
   Backend / architecture page
   ============================================================ */
.layer-card{padding:20px;border-radius:var(--radius)}
.layer-card .tag{
  display:inline-block;font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:.05em;
  padding:4px 9px;border-radius:6px;margin-bottom:10px;
}

/* ============================================================
   Landing (public index) — optional, matches Figure 4.1
   ============================================================ */

.hero-wrap {
  background: var(--surface);
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3rem;
  max-width: 1120px;
  margin: 0 auto;
  padding: 64px 32px 40px;
}

.hero-content {
  flex: 1;
  max-width: 520px;
}

.hero h1 {
  font-size: 38px;
  line-height: 1.08;
  max-width: 520px;
  font-weight: 800;
  color: var(--text);
}

.hero p.lead {
  color: var(--text-muted);
  font-size: 15.5px;
  max-width: 460px;
  margin: 14px 0 26px;
  line-height: 1.6;
}

.hero .cta-row,
.hero-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-image {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.hero-image img,
.scooter-img {
  max-width: 100%;
  height: auto;
  max-height: 420px;
}

/* Stats section */
.landing-stats,
.stats {
  max-width: 1120px;
  margin: 10px auto 60px;
  padding: 0 32px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-card .stat-icon {
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.stat-card .stat-label,
.stat-card .label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-card .stat-value,
.stat-card .value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.stat-card .stat-sub {
  font-size: 12px;
  color: var(--text-faint);
}

/* How it works */
.how,
.how-it-works {
  max-width: 1120px;
  margin: 0 auto 70px;
  padding: 0 32px;
  text-align: center;
}

.how h2,
.how-it-works h2 {
  font-size: 22px;
  margin-bottom: 28px;
}

.how-grid,
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 20px;
}

.how-step,
.step {
  padding: 22px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.how-step .n,
.step-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary-50);
  color: var(--primary-700);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 1.3rem;
}

.step h3 {
  font-size: 16px;
  margin-bottom: 6px;
}

.step p {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0;
}

/* Responsive */
@media (max-width: 900px) {
  .hero {
    flex-direction: column;
    text-align: center;
    padding: 40px 24px;
  }
  .hero-content {
    max-width: 100%;
  }
  .hero-buttons {
    justify-content: center;
  }
}

@media (max-width: 800px) {
  .landing-stats,
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .how-grid,
  .steps {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 500px) {
  .landing-stats,
  .stats {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Dashboard v2 — match 4.3.7 Admin Dashboard design
   ============================================================ */
.dash-user-row {
  display: flex;
  justify-content: flex-end;
  padding: 18px 30px 0;
}

.welcome-header {
  margin-bottom: 24px;
}
.welcome-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 4px;
}
.welcome-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

.stat-card-v2 {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  min-height: 96px;
}
.stat-card-v2 .stat-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
}
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.stat-icon svg {
  width: 22px;
  height: 22px;
}
.stat-icon-purple {
  background: #f3efff;
  color: #7c3aed;
}
.stat-icon-green {
  background: var(--success-bg);
  color: var(--success);
}
.stat-icon-blue {
  background: var(--primary-50);
  color: var(--primary-700);
}
.stat-icon-cyan {
  background: #ecfeff;
  color: #0891b2;
}
.stat-card-v2 .stat-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.stat-card-v2 .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}
.stat-card-v2 .stat-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
}

/* ---------- Line chart ---------- */
.line-chart-wrap {
  width: 100%;
  margin-top: 8px;
}
.line-chart {
  width: 100%;
  height: 240px;
  display: block;
}

/* ---------- Top riders v2 ---------- */
.rank-list-v2 {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rank-list-v2 li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--border);
}
.rank-list-v2 li:last-child {
  border-bottom: 0;
}
.rank-num-v2 {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  color: var(--text);
  background: var(--bg);
}
.rank-num-v2.rank-1 {
  background: #fff7ed;
  color: #c2410c;
}
.rank-num-v2.rank-2 {
  background: #f1f5f9;
  color: #475569;
}
.rank-num-v2.rank-3 {
  background: #fef3c7;
  color: #92400e;
}
.rank-name-v2 {
  font-weight: 700;
  font-size: 14.5px;
  flex: 1;
  color: var(--text);
}
.rank-count-v2 {
  font-size: 14.5px;
  color: var(--text-muted);
  font-weight: 700;
}

@media (max-width: 1080px) {
  .stat-card-v2 .stat-value {
    font-size: 24px;
  }
}

/* ============================================================
   Optimize Route v2 — match 4.4/4.5 figures
   ============================================================ */
.map-wrap {
  position: relative;
  height: 100%;
  min-height: 480px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
}
.map-wrap #map,
.map-wrap #map2 {
  height: 100%;
  min-height: 480px;
  width: 100%;
}
.leaflet-container {
  background: #e6ecf2;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.custom-pin { background: transparent !important; border: none !important; }
.custom-pin svg { display:block; }

.opt-field-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.opt-field-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.opt-depot-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  font-size: 14.5px;
  color: var(--text);
  font-family: inherit;
  font-weight: 500;
}
.opt-algo-select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--text);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}
.opt-add-select {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 13.5px;
  color: var(--text);
  font-family: inherit;
}
.opt-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.opt-add-btn:hover { background: var(--bg); }
.opt-add-btn svg { width: 15px; height: 15px; }

.btn-optimize-primary {
  width: 100%;
  margin-top: 22px;
  padding: 14px 18px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #3647c9, #4c5aff);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 10px 24px -8px rgba(54,71,201,.6);
  letter-spacing: -.01em;
}
.btn-optimize-primary:hover { filter: brightness(1.06); }

.opt-loc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 11px 13px;
  margin-bottom: 8px;
  font-size: 13.8px;
}
.opt-loc-num {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.opt-loc-txt {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.opt-loc-txt b {
  font-size: 13.8px;
  font-weight: 700;
}
.opt-loc-txt span {
  font-size: 11.8px;
  color: var(--text-muted);
  font-weight: 500;
}
.opt-loc-row .x-remove {
  margin-left: auto;
  background: none;
  border: 0;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 5px;
}
.opt-loc-row .x-remove:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ---------- Result metric cards (5 cards in row) ---------- */
.metrics-grid {
  grid-template-columns: repeat(5, 1fr);
}
@media (max-width: 1180px){ .metrics-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px){ .metrics-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px){ .metrics-grid { grid-template-columns: 1fr; } }

.res-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 84px;
  justify-content: center;
}
.res-card-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.res-card-val {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
  line-height: 1.15;
}
.res-card-blue .res-card-val {
  color: var(--primary-700);
}

/* ---------- Print / Download buttons ---------- */
.btn-print, .btn-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: filter .12s, background .12s;
}
.btn-print svg, .btn-download svg {
  width: 16px;
  height: 16px;
}
.btn-print {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(54,71,201,.55);
}
.btn-print:hover { background: var(--primary-600); color: #fff; }
.btn-download {
  background: var(--success);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(22,163,74,.5);
}
.btn-download:hover { filter: brightness(1.05); color: #fff; }
