/* ==========================================================================
   rps-logistics.io — Fleet Command theme
   Dark-navy sidebar, soft gradient content, indigo/teal accents.
   ========================================================================== */

:root {
  /* surfaces */
  --bg:            #f4f6fb;
  --bg-gradient:   radial-gradient(1200px 600px at 100% -100px, #e6ecff 0%, transparent 60%),
                   linear-gradient(180deg, #f4f6fb 0%, #eef1f8 100%);
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --surface-muted: #eef2f7;
  --sidebar:       #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-text:  #cbd5e1;
  --sidebar-text-muted: #64748b;

  /* text */
  --text:          #0f172a;
  --text-muted:    #64748b;
  --text-faint:    #94a3b8;

  /* lines */
  --border:        #e2e8f0;
  --border-strong: #cbd5e1;

  /* brand */
  --brand:         #6366f1;        /* indigo 500 */
  --brand-700:     #4338ca;
  --brand-50:      #eef2ff;
  --teal:          #0891b2;
  --teal-50:       #ecfeff;

  /* status */
  --success:       #059669;
  --success-50:    #ecfdf5;
  --warning:       #d97706;
  --warning-50:    #fffbeb;
  --info:          #2563eb;
  --info-50:       #eff6ff;
  --danger:        #dc2626;
  --danger-50:     #fef2f2;
  --neutral-50:    #f1f5f9;

  /* misc */
  --radius:        14px;
  --radius-sm:     10px;
  --radius-xs:     7px;
  --shadow:        0 1px 2px rgba(15,23,42,.04), 0 4px 12px rgba(15,23,42,.04);
  --shadow-lg:     0 10px 30px rgba(15,23,42,.08), 0 2px 6px rgba(15,23,42,.04);
  --ring:          0 0 0 3px rgba(99,102,241,.2);

  --font:          "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg:            #0b1220;
  --bg-gradient:   radial-gradient(1000px 600px at 100% -100px, rgba(99,102,241,.18) 0%, transparent 60%),
                   linear-gradient(180deg, #0b1220 0%, #0a0f1e 100%);
  --surface:       #111a2e;
  --surface-2:     #17223a;
  --surface-muted: #1a253e;
  --sidebar:       #060b18;
  --sidebar-hover: #111a2e;
  --sidebar-text:  #cbd5e1;
  --sidebar-text-muted: #64748b;

  --text:          #e2e8f0;
  --text-muted:    #94a3b8;
  --text-faint:    #64748b;

  --border:        #1f2a44;
  --border-strong: #2c3a5a;

  --brand:         #818cf8;
  --brand-700:     #6366f1;
  --brand-50:      #1e1e48;
  --teal:          #22d3ee;
  --teal-50:       #0e3a47;

  --success:       #34d399;
  --success-50:    #0f3a2c;
  --warning:       #fbbf24;
  --warning-50:    #3a2d0a;
  --info:          #60a5fa;
  --info-50:       #0f2847;
  --danger:        #f87171;
  --danger-50:     #3a0f12;
  --neutral-50:    #17223a;

  --shadow:        0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.3);
  --shadow-lg:     0 10px 30px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-gradient);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; color: inherit; }

/* ================================================================
   Login
   ================================================================ */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
  background-image: var(--bg-gradient);
}
.login-wrap > .hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 60%, #6366f1 120%);
  color: #e2e8f0;
  padding: 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-wrap > .hero::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(129,140,248,.25) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(34,211,238,.2) 0%, transparent 50%);
  pointer-events: none;
}
.hero-brand { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; position: relative; }
.hero-headline {
  position: relative;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  max-width: 540px;
}
.hero-headline span { color: #a5b4fc; }
.hero-sub {
  position: relative;
  color: #cbd5e1;
  max-width: 480px;
  margin-top: 16px;
  font-size: 15px;
}
.hero-stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 48px;
}
.hero-stats .stat-mini .n { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.hero-stats .stat-mini .l { font-size: 12px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 4px; }

.login-form-wrap { display: grid; place-items: center; padding: 40px 24px; }
.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}
.login-card h1 {
  font-size: 26px; font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.login-sub { color: var(--text-muted); margin-bottom: 26px; font-size: 14px; }
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  transition: transform .05s, opacity .15s, background .15s, box-shadow .15s;
  box-shadow: 0 1px 2px rgba(15,23,42,.1);
}
.btn:hover { background: var(--brand-700); }
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; padding: 12px; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: none; }
.btn-secondary:hover { background: var(--surface-muted); }
.btn-ghost { background: transparent; color: var(--text-muted); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-muted); color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }

.form-error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }
.login-hint {
  margin-top: 22px;
  padding: 14px;
  background: var(--brand-50);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-muted);
}
.login-hint code {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 11.5px;
  color: var(--text);
}

/* ================================================================
   App shell
   ================================================================ */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(255,255,255,.03);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  color: #fff;
}
.sidebar-logo .mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--teal) 100%);
  display: grid; place-items: center;
  font-weight: 800;
  color: #fff;
  font-size: 14px;
}
.sidebar-logo .name { font-weight: 800; font-size: 15.5px; letter-spacing: -0.01em; }
.sidebar-logo .name small { color: var(--sidebar-text-muted); font-weight: 600; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; display:block; }

.sidebar-user {
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.03);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-user .avatar-sm {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--teal) 100%);
  display: grid; place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.sidebar-user .name { font-weight: 600; font-size: 13px; color: #fff; line-height: 1.2; }
.sidebar-user .role {
  font-size: 10.5px;
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 10.5px;
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 10px 10px 6px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  font-weight: 500;
  font-size: 13.5px;
  color: var(--sidebar-text);
  position: relative;
}
.nav a:hover { background: var(--sidebar-hover); color: #fff; }
.nav a.active {
  background: linear-gradient(90deg, rgba(99,102,241,.18) 0%, rgba(99,102,241,0) 100%);
  color: #fff;
  font-weight: 600;
}
.nav a.active::before {
  content: "";
  position: absolute;
  left: -14px; top: 8px; bottom: 8px;
  width: 3px;
  background: linear-gradient(180deg, var(--brand) 0%, var(--teal) 100%);
  border-radius: 0 4px 4px 0;
}
.nav a .icon { width: 18px; height: 18px; stroke: currentColor; flex-shrink: 0; }
.nav a .badge {
  margin-left: auto;
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.sidebar-footer .btn { font-size: 12px; justify-content: flex-start; gap: 10px; padding: 9px 12px; }

.main { padding: 28px 36px; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}
.topbar .spacer { flex: 1; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}
.page-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.page-actions { display: flex; gap: 10px; }

h2 { font-size: 16px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
h3 { font-size: 14px; font-weight: 700; margin: 0; }

/* Top bar items */
.topbar-search {
  position: relative;
  flex: 0 1 320px;
}
.topbar-search input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  transition: box-shadow .15s, border-color .15s;
}
.topbar-search input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.topbar-search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); width: 16px; height: 16px;
}
.icon-btn {
  position: relative;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: all .15s;
}
.icon-btn:hover { color: var(--text); background: var(--surface-muted); }
.icon-btn .count {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 999px;
  min-width: 18px; height: 18px;
  display: grid; place-items: center;
  padding: 0 5px;
  border: 2px solid var(--bg);
}
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--teal) 100%);
  display: grid; place-items: center;
  font-weight: 700;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

/* Notification dropdown */
.dropdown {
  position: absolute;
  top: 46px;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 340px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: none;
  z-index: 50;
}
.dropdown.open { display: block; }
.dropdown-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.dropdown-list { max-height: 380px; overflow-y: auto; }
.notif {
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.notif:last-child { border-bottom: none; }
.notif:hover { background: var(--surface-muted); }
.notif .dot {
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--brand);
  margin-top: 6px;
  flex-shrink: 0;
}
.notif.read .dot { background: transparent; border: 2px solid var(--border-strong); }
.notif .title { font-weight: 600; font-size: 13px; }
.notif .body { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.notif .time { color: var(--text-faint); font-size: 11px; margin-top: 4px; }

/* ================================================================
   Cards + KPIs
   ================================================================ */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--teal) 100%);
  opacity: 0;
  transition: opacity .2s;
}
.kpi:hover::before { opacity: 1; }
.kpi.kpi-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: transform .12s, box-shadow .12s;
}
.kpi.kpi-link:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}
.kpi-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.kpi-head .label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.kpi-head .ico {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--brand-50);
  color: var(--brand);
  display: grid; place-items: center;
}
.kpi.k-teal    .kpi-head .ico { background: var(--teal-50); color: var(--teal); }
.kpi.k-success .kpi-head .ico { background: var(--success-50); color: var(--success); }
.kpi.k-warn    .kpi-head .ico { background: var(--warning-50); color: var(--warning); }
.kpi .value { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; color: var(--text); }
.kpi .delta { font-size: 12px; margin-top: 3px; display: inline-flex; align-items: center; gap: 4px; }
.kpi .delta.up   { color: var(--success); }
.kpi .delta.down { color: var(--danger); }
.kpi .spark { margin-top: 10px; height: 34px; }

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  padding: 16px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.panel-head .actions { display: flex; gap: 8px; }
.panel-body { padding: 0; }
.panel-body.padded { padding: 22px; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.grid-equal-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ================================================================
   Tabs / Filters
   ================================================================ */
.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  white-space: nowrap;
}
.tabs button {
  background: transparent;
  border: 1px solid transparent;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 999px;
  transition: all .15s;
}
.tabs button:hover { color: var(--text); background: var(--surface-muted); }
.tabs button.active {
  color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-700) 100%);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(99,102,241,.3);
}
.tabs button .count {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(0,0,0,.08);
}
.tabs button.active .count { background: rgba(255,255,255,.2); }

.filters {
  display: flex;
  gap: 10px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  flex-wrap: wrap;
}
.filters input, .filters select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
}
.filters input:focus, .filters select:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.filters .search-input { flex: 1; min-width: 180px; padding-left: 34px; background-position: 12px center; background-repeat: no-repeat; background-size: 14px; background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%2394a3b8" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>'); }

/* ================================================================
   Tables
   ================================================================ */
.table-wrap { overflow-x: auto; }
table.tours-table, table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table thead th {
  text-align: left;
  padding: 13px 18px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table tbody tr:last-child td { border-bottom: none; }
table tbody tr { transition: background .12s; }
table tbody tr:hover { background: var(--surface-2); }
table tbody tr.clickable { cursor: pointer; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12.5px; }
.addr-line { line-height: 1.35; }
.addr-line .city { font-weight: 600; font-size: 13.5px; }
.addr-line .street { color: var(--text-muted); font-size: 12.5px; }
.time-block { line-height: 1.4; }
.time-block .date { font-weight: 500; }
.time-block .times { color: var(--text-muted); font-size: 12.5px; }

.route-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.route-dot {
  width: 8px; height: 8px;
  border-radius: 999px;
  background: var(--brand);
  border: 2px solid var(--brand-50);
  flex-shrink: 0;
}
.route-line {
  flex: 1; min-width: 24px;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--border-strong) 0, var(--border-strong) 4px, transparent 4px, transparent 8px);
}
.route-arrow {
  width: 0; height: 0;
  border-left: 6px solid var(--border-strong);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  flex-shrink: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.status-pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 999px;
  background: currentColor;
}
.status-completed { background: var(--success-50); color: var(--success); }
.status-cancelled { background: var(--danger-50);  color: var(--danger); }
.status-booked    { background: var(--info-50);    color: var(--info); }
.status-assigned  { background: var(--warning-50); color: var(--warning); }
.status-available { background: var(--neutral-50); color: var(--text-muted); }

.actions-cell { white-space: nowrap; position: relative; }

/* ---- Action dropdown (row-level) ---- */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .12s;
}
.action-btn:hover { background: var(--surface-muted); border-color: var(--border-strong); }
.action-btn .caret {
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid currentColor;
  margin-left: 2px;
}

.action-menu {
  position: fixed;
  z-index: 90;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 190px;
  padding: 6px;
  display: none;
  animation: slide-up .12s ease-out;
}
.action-menu.open { display: block; }
.action-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: none;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background .1s;
}
.action-menu button:hover { background: var(--surface-muted); }
.action-menu button .m-icon {
  width: 16px; height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.action-menu button:hover .m-icon { color: var(--brand); }
.action-menu button.danger { color: var(--danger); }
.action-menu button.danger .m-icon { color: var(--danger); }
.action-menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ---- Protocol + receipts modal styles ---- */
.proto-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.proto-grid .form-group { margin-bottom: 0; }
.proto-grid .full { grid-column: 1 / -1; }

.proto-existing {
  background: var(--success-50);
  color: var(--success);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 14px;
}
.proto-existing.warn { background: var(--warning-50); color: var(--warning); }

.receipt-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.receipt-row:last-child { border-bottom: none; }
.receipt-row .k {
  background: var(--brand-50);
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.receipt-row .r-note { flex: 1; color: var(--text-muted); font-size: 12.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.receipt-row .amt { font-weight: 700; white-space: nowrap; }

.receipt-totals {
  display: flex;
  justify-content: space-between;
  padding-top: 14px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
  font-weight: 700;
}

/* ---- Driver extras ---- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--surface-muted);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.chip.solid-brand { background: var(--brand-50); color: var(--brand); }
.chip.solid-teal  { background: var(--teal-50);  color: var(--teal); }

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}
.status-dot::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 999px;
}
.status-dot.active::before   { background: var(--success); box-shadow: 0 0 0 3px var(--success-50); }
.status-dot.inactive::before { background: var(--text-faint); }
.status-dot.on-leave::before { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-50); }
.status-dot.active { color: var(--success); }
.status-dot.inactive { color: var(--text-muted); }
.status-dot.on-leave { color: var(--warning); }

.rating {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12.5px;
  font-weight: 600;
}
.rating .star { color: #f59e0b; }

/* Heatmap for driver utilisation */
.heatmap {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
}
.heatmap .cell {
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  background: var(--surface-muted);
  position: relative;
}
.heatmap .cell.l1 { background: var(--brand-50); }
.heatmap .cell.l2 { background: color-mix(in srgb, var(--brand) 40%, var(--surface-muted)); }
.heatmap .cell.l3 { background: color-mix(in srgb, var(--brand) 70%, var(--surface-muted)); }
.heatmap .cell.l4 { background: var(--brand); }
.heatmap .cell:hover::after {
  content: attr(data-t);
  position: absolute;
  bottom: calc(100% + 4px); left: 50%;
  transform: translateX(-50%);
  background: var(--sidebar); color: #fff;
  font-size: 11px; padding: 3px 6px; border-radius: 4px;
  white-space: nowrap; z-index: 10;
}

.progress-bar {
  background: var(--surface-muted);
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--teal));
  border-radius: 999px;
  transition: width .4s ease;
}
.progress-bar .fill.warn  { background: linear-gradient(90deg, var(--warning), #f97316); }
.progress-bar .fill.danger{ background: var(--danger); }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--text);
  background: var(--surface);
}

/* Driver detail section headings */
.sec-h {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  margin: 20px 0 10px;
}
.sec-h::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---- Activity timeline ---- */
.activity-timeline {
  position: relative;
  padding-left: 22px;
}
.activity-timeline::before {
  content: "";
  position: absolute;
  left: 6px; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--border);
}
.activity-item {
  position: relative;
  padding: 6px 0 14px;
}
.activity-item::before {
  content: "";
  position: absolute;
  left: -22px; top: 9px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--brand);
}
.activity-item.completed::before { border-color: var(--success); }
.activity-item.cancelled::before { border-color: var(--danger); }
.activity-item.assigned::before  { border-color: var(--warning); }
.activity-item.proto::before     { border-color: var(--teal); }
.activity-item.receipt::before   { border-color: var(--info); }
.activity-item .a-title { font-weight: 600; font-size: 13.5px; }
.activity-item .a-body  { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.activity-item .a-time  { color: var(--text-faint); font-size: 11.5px; margin-top: 3px; }

.mini-stat {
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.mini-stat .l { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.mini-stat .v { font-weight: 700; font-size: 15px; margin-top: 2px; }

.hero-pickup {
  background: linear-gradient(135deg, var(--sidebar) 0%, #1e293b 60%, var(--brand-700) 140%);
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  gap: 20px;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.hero-pickup::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(400px 200px at 80% -50%, rgba(34,211,238,.25), transparent 70%),
    radial-gradient(300px 150px at 20% 120%, rgba(99,102,241,.25), transparent 70%);
  pointer-events: none;
}
.hero-pickup > div { position: relative; }
.hero-pickup .hp-label { font-size: 11.5px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.hero-pickup .hp-route { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; line-height: 1.15; }
.hero-pickup .hp-sub { color: #cbd5e1; font-size: 13px; margin-top: 6px; }
.hero-pickup .hp-cd {
  background: rgba(255,255,255,.08);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  min-width: 120px;
  text-align: center;
  backdrop-filter: blur(10px);
}
.hero-pickup .hp-cd .big { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.hero-pickup .hp-cd .sm  { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.1em; }
.hero-pickup .hp-actions { margin-left: auto; display: flex; gap: 10px; }
.hero-pickup .btn {
  background: #fff;
  color: var(--sidebar);
}
.hero-pickup .btn:hover { background: #e2e8f0; }

/* ---- Booking modal blocks ---- */
.book-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--surface);
}
.book-block .bl-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 4px;
}
.book-block .bl-value {
  font-weight: 600;
  font-size: 14px;
}
.book-block .bl-value.big { font-size: 15px; font-weight: 700; }
.book-block .bl-sub {
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.4;
  margin-top: 2px;
}
.book-cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.book-cols-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.book-cols-2 > div, .book-cols-3 > div { min-width: 0; }
.book-map-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--brand);
  font-size: 12.5px;
  margin-top: 6px;
  font-weight: 500;
}
.book-map-link:hover { text-decoration: underline; }
.book-disclaimer {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  padding: 12px 14px;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  line-height: 1.5;
}
.book-disclaimer a, .book-disclaimer strong { color: var(--text); font-weight: 700; }
@media (max-width: 600px) {
  .book-cols-2, .book-cols-3 { grid-template-columns: 1fr; }
}
.empty-row {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-row .e-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--surface-muted);
  display: inline-grid; place-items: center;
  margin-bottom: 10px;
  color: var(--text-faint);
}

/* Driver chip */
.driver-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.driver-chip .avatar-xs {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--brand) 0%, var(--teal) 100%);
}

/* ================================================================
   Modals
   ================================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fade-in .15s ease-out;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slide-up .2s ease-out;
}
.modal.lg { max-width: 860px; }
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px;
}
.modal-head .title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.modal-head .subtitle { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.modal-close {
  background: var(--surface-muted); border: none;
  width: 32px; height: 32px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 18px;
  display: grid; place-items: center;
  line-height: 1;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body { padding: 22px; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  background: var(--surface-2);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* Info grid inside modals */
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 24px;
  margin-bottom: 18px;
}
.info-grid > div { min-width: 0; }
.info-grid .l { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.info-grid .v { margin-top: 2px; font-weight: 500; }

/* Route viz */
.route-timeline {
  position: relative;
  padding: 10px 0 10px 20px;
  margin: 14px 0;
}
.route-timeline::before {
  content: "";
  position: absolute;
  left: 6px; top: 14px; bottom: 14px;
  width: 2px;
  background: repeating-linear-gradient(180deg, var(--brand) 0 4px, transparent 4px 8px);
}
.route-stop {
  position: relative;
  margin-bottom: 14px;
}
.route-stop:last-child { margin-bottom: 0; }
.route-stop::before {
  content: "";
  position: absolute;
  left: -20px; top: 4px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--brand);
}
.route-stop.goal::before { border-color: var(--teal); }
.route-stop .city { font-weight: 600; font-size: 14px; }
.route-stop .street { color: var(--text-muted); font-size: 12.5px; }
.route-stop .time { color: var(--brand); font-size: 12.5px; font-weight: 600; margin-top: 2px; }

#routeMap {
  width: 100%;
  height: 260px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-top: 4px;
}

/* ================================================================
   Toasts
   ================================================================ */
.toast-wrap {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200;
}
.toast {
  background: var(--sidebar);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  display: flex; gap: 10px; align-items: center;
  animation: slide-in .2s ease-out;
  min-width: 240px;
}
.toast .emoji { font-size: 16px; }
.toast.err { background: var(--danger); }
.toast.ok  { background: var(--success); }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ================================================================
   Charts
   ================================================================ */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  height: 220px;
  padding: 20px 24px 12px;
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bar-wrap { width: 100%; flex: 1; display: flex; align-items: flex-end; }
.bar {
  width: 100%;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-700) 100%);
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  transition: height .4s ease;
  position: relative;
}
.bar:hover::after {
  content: attr(data-v);
  position: absolute;
  top: -22px; left: 50%;
  transform: translateX(-50%);
  background: var(--sidebar); color: #fff;
  font-size: 11px; padding: 3px 7px; border-radius: 5px;
  white-space: nowrap;
}
.bar-label { font-size: 11.5px; color: var(--text-muted); }
.bar-value { font-size: 11.5px; font-weight: 700; }

.donut-wrap { display: flex; align-items: center; gap: 20px; padding: 20px 24px; }
.donut { width: 150px; height: 150px; flex-shrink: 0; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.legend-item { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.legend-item .sw { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-item .lbl { flex: 1; color: var(--text-muted); }
.legend-item .v { font-weight: 700; }

.sparkline { width: 100%; height: 30px; display: block; }

/* ================================================================
   Calendar
   ================================================================ */
.cal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}
.cal-head .month { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.cal-nav { display: flex; gap: 6px; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
}
.cal-dow {
  background: var(--surface-2);
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.cal-day {
  background: var(--surface);
  min-height: 104px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cal-day .num { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.cal-day.today .num { color: var(--brand); font-weight: 800; }
.cal-day.today { background: var(--brand-50); }
.cal-day.out-of-month { background: var(--surface-2); }
.cal-day.out-of-month .num { color: var(--text-faint); }
.cal-event {
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  font-weight: 500;
}
.cal-event.e-completed { background: var(--success); }
.cal-event.e-cancelled { background: var(--danger); }
.cal-event.e-available { background: var(--text-faint); }
.cal-event.e-assigned  { background: var(--warning); }
.cal-event.e-booked    { background: var(--info); }

/* ================================================================
   Fleet / vehicle cards
   ================================================================ */
.fleet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.vehicle-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
  position: relative;
  overflow: hidden;
}
.vehicle-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.vehicle-card .v-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.vehicle-card .v-ico {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--brand-50);
  color: var(--brand);
  display: grid; place-items: center;
}
.vehicle-card .v-ico.transporter { background: var(--teal-50); color: var(--teal); }
.vehicle-card .plate { font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: 14px; }
.vehicle-card .model { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.vehicle-card .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-top: 10px; }
.vehicle-card .meta strong { color: var(--text); font-weight: 700; font-size: 13px; }

/* ================================================================
   Dispatchers
   ================================================================ */
.dispatcher-card {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}
.dispatcher-card .avatar { width: 48px; height: 48px; font-size: 16px; cursor: default; }
.dispatcher-card .name { font-weight: 700; }
.dispatcher-card .role { font-size: 12px; color: var(--text-muted); }
.dispatcher-card .meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.dispatcher-card .actions { margin-left: auto; display: flex; gap: 6px; }

/* ================================================================
   Responsive
   ================================================================ */
/* Stack the 2-column grid earlier so the tours table doesn't get squeezed
   next to the status donut. Also give the table horizontal scroll room. */
@media (max-width: 1400px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 1280px) {
  .app { grid-template-columns: 220px 1fr; }
  .main { padding: 24px 26px; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-wrap > .hero { display: none; }
}

/* Tables should never squeeze content — scroll horizontally instead. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tours-table, table.data-table { min-width: 720px; }
.time-block .date { white-space: nowrap; }
.time-block .times { white-space: nowrap; }
.route-cell { white-space: nowrap; }
@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: column; }
  .main { padding: 20px; }
  .kpis { grid-template-columns: 1fr; }
  .grid-equal-2 { grid-template-columns: 1fr; }
  .page-title { font-size: 22px; }
  .topbar-search { flex: 1; }
  .cal-day { min-height: 56px; }
  .cal-day .num { font-size: 11px; }
}
