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

/* Rove Dispatch — premium redesign. Every class preserved; only aesthetics changed. */
:root {
  --bg:           #f6f6f5;
  --surface:      #ffffff;
  --sidebar:      #0c0c0c;
  --sidebar-2:    #1a1a1a;
  --accent:       #0891b2;
  --accent-bright:#0ea5e9;
  --accent-soft:  #e0f2fe;
  --text:         #0c0c0c;
  --muted:        #737373;
  --line:         #ebebeb;
  --green:        #16a34a;
  --amber:        #d97706;
  --red:          #dc2626;
  --blue:         #2563eb;
  --radius:       8px;
  --shadow:       0 1px 2px rgba(0,0,0,.04), 0 1px 4px rgba(0,0,0,.04);
  --shadow-md:    0 4px 12px rgba(0,0,0,.07), 0 1px 3px rgba(0,0,0,.04);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 13px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ★ Cross-division platinum badge */
.cross-div-badge {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff; font-size: 9px; font-weight: 800;
  width: 16px; height: 16px; line-height: 16px; text-align: center;
  border-radius: 50%; margin-right: 4px; vertical-align: middle;
}

/* ─── LAYOUT ───────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 224px;
  background: var(--sidebar);
  color: #a1a1a1;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(255,255,255,.04);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.brand .mark {
  width: 30px; height: 30px; flex-shrink: 0;
  background: url('logo.svg') center/contain no-repeat;
  font-size: 0; color: transparent;
}
.brand .name  { color: #f0f0f0; font-weight: 700; font-size: 14px; letter-spacing: -.3px; }
.brand .sub   { color: #404040; font-size: 9px; letter-spacing: 1.2px; font-weight: 700; text-transform: uppercase; }

.nav { padding: 8px 8px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 7.5px 10px;
  border-radius: 6px;
  color: #a8a8a8;
  font-size: 12.5px; font-weight: 500;
  margin-bottom: 1px;
  transition: background 120ms ease, color 120ms ease, padding-left 120ms ease;
  position: relative;
  letter-spacing: -.1px;
}
.nav a:hover  { background: rgba(255,255,255,.07); color: #e8e8e8; }
.nav a.active {
  background: rgba(255,255,255,.1);
  color: #ffffff;
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
  padding-left: 13px;
}
.nav .ico   { width: 15px; text-align: center; flex-shrink: 0; opacity: .85; }
.nav .group {
  color: #525252;
  font-size: 9px; letter-spacing: 1.3px; font-weight: 700;
  padding: 14px 10px 4px; text-transform: uppercase;
}

.sidebar .who {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.05);
  font-size: 11px; color: #686868;
}
.sidebar .who b   { color: #d4d4d4; display: block; font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.sidebar .who a   { color: #686868; font-size: 11px; }

.main   { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 15px; font-weight: 700; letter-spacing: -.3px; flex-shrink: 0; }
.content { padding: 22px 24px 60px; }

/* ─── LOCATION TABS ────────────────────────── */
.tabs {
  display: flex; gap: 2px;
  background: var(--bg);
  padding: 3px;
  border-radius: 7px;
  border: 1px solid var(--line);
}
.tabs button {
  border: 0; background: transparent;
  padding: 5px 12px; border-radius: 5px;
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
  font-family: inherit;
  letter-spacing: -.1px;
}
.tabs button.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

/* ─── STAT CARDS ───────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stats-4 { grid-template-columns: repeat(4, 1fr); }
.stats-6 { grid-template-columns: repeat(6, 1fr); }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  transition: box-shadow 200ms ease, border-color 200ms ease, transform 200ms ease;
  cursor: default;
}
.stat:hover {
  box-shadow: var(--shadow-md);
  border-color: #d9d9d9;
  transform: translateY(-1px);
}
.stat .label {
  font-size: 10px; letter-spacing: .7px;
  color: var(--muted); font-weight: 700; text-transform: uppercase;
}
.stat .num {
  font-size: 28px; font-weight: 800; margin-top: 8px;
  letter-spacing: -.6px; line-height: 1;
}
.stat .num.alert { color: var(--red); }
.stat .foot { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ─── PANELS ───────────────────────────────── */
.grid2  { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.panel  { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.panel-head h2   { font-size: 12.5px; font-weight: 700; letter-spacing: -.2px; }
.panel-head .link { font-size: 11.5px; font-weight: 600; color: var(--accent); }
.panel-body      { padding: 4px 0; }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); font-size: 12px; }

/* ─── LIST ROWS ────────────────────────────── */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid #f3f3f2;
  transition: background 100ms ease;
}
.row:hover      { background: #fafaf9; }
.row:last-child { border-bottom: 0; }
.row .when { font-size: 11.5px; font-weight: 700; width: 56px; flex-shrink: 0; color: var(--muted); }
.row .body { flex: 1; min-width: 0; }
.row .body .t { font-size: 12.5px; font-weight: 600; }
.row .body .s { font-size: 11px; color: var(--muted); margin-top: 1px; }
.row .meta { font-size: 11px; color: var(--muted); text-align: right; }

/* ─── BADGES ───────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px; border-radius: 20px;
  font-size: 10px; font-weight: 700;
  letter-spacing: .2px; text-transform: uppercase;
  border: 1px solid transparent;
}
.b-delivery  { background: #eff6ff;  color: #2563eb;  border-color: #bfdbfe; }
.b-pickup    { background: #f0fdf4;  color: #16a34a;  border-color: #bbf7d0; }
.b-swap      { background: #fffbeb;  color: #d97706;  border-color: #fde68a; }
.b-reorder   { background: #ecfeff;  color: #0891b2;  border-color: #a5f3fc; }
.b-active    { background: #f0fdf4;  color: #16a34a;  border-color: #bbf7d0; }
.b-due       { background: #fffbeb;  color: #d97706;  border-color: #fde68a; }
.b-overdue   { background: #fef2f2;  color: #dc2626;  border-color: #fecaca; }
.b-unassigned{ background: #fef2f2;  color: #dc2626;  border-color: #fecaca; }
.b-assigned  { background: #eef2ff;  color: #4338ca;  border-color: #c7d2fe; }
.b-en_route  { background: #eff6ff;  color: #2563eb;  border-color: #bfdbfe; }
.b-done      { background: #f0fdf4;  color: #16a34a;  border-color: #bbf7d0; }
.b-open      { background: #ecfeff;  color: #0891b2;  border-color: #a5f3fc; }

/* ─── TABLES ───────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 10px; letter-spacing: .7px;
  color: var(--muted); text-transform: uppercase;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  font-weight: 700; background: #fafafa;
}
td { padding: 11px 16px; font-size: 13px; border-bottom: 1px solid #f3f3f2; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fafaf9; }

/* ─── BUTTONS ──────────────────────────────── */
.btn {
  border: 1px solid transparent;
  background: var(--text); color: #fff;
  padding: 7px 13px;
  border-radius: 6px; font-size: 12px; font-weight: 600;
  font-family: inherit;
  display: inline-flex; align-items: center; gap: 5px;
  transition: background 150ms ease, transform 100ms ease, box-shadow 150ms ease;
  letter-spacing: -.1px;
  line-height: 1.4;
}
.btn:hover  { background: #222222; }
.btn:active { transform: scale(.98); }
.btn.ghost {
  background: var(--surface); color: var(--text);
  border-color: var(--line);
}
.btn.ghost:hover { background: var(--bg); border-color: #d4d4d4; }
.btn.sm     { padding: 5px 10px; font-size: 11px; border-radius: 5px; }
.btn.block  { width: 100%; padding: 11px; font-size: 13px; justify-content: center; }

/* ─── FORMS ────────────────────────────────── */
label {
  display: block; font-size: 10.5px; font-weight: 700;
  color: var(--muted); margin-bottom: 4px;
  letter-spacing: .4px; text-transform: uppercase;
}
input, select, textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; font-family: inherit;
  background: #fff; color: var(--text);
  transition: border-color 150ms ease, box-shadow 150ms ease;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: #a3a3a3;
  box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}
input::placeholder, textarea::placeholder { color: #b0b0b0; font-size: 12px; }
.field { margin-bottom: 14px; }

/* ─── MODAL ────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-bg.show { display: flex; }
.modal {
  background: #fff;
  border-radius: 12px;
  width: 440px; max-width: 92vw;
  overflow: visible;
  box-shadow: 0 24px 64px rgba(0,0,0,.16), 0 4px 16px rgba(0,0,0,.08);
  border: 1px solid rgba(0,0,0,.07);
}
.modal h3 {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  font-size: 14px; font-weight: 700; letter-spacing: -.2px;
}
.modal .mbody   { padding: 20px; }
.modal .mfoot   {
  padding: 13px 20px; border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ─── TOAST ────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #0c0c0c; color: #f0f0f0;
  padding: 9px 18px; border-radius: 7px;
  font-size: 12px; font-weight: 600;
  transition: transform 300ms cubic-bezier(0.32,0.72,0,1);
  z-index: 200;
  border: 1px solid rgba(255,255,255,.07);
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  letter-spacing: -.1px;
}
.toast.show { transform: translateX(-50%) translateY(0); }

.proto-tag {
  position: fixed; bottom: 14px; right: 16px;
  background: var(--sidebar); color: #404040;
  font-size: 9px; font-weight: 700; letter-spacing: .8px;
  padding: 5px 9px; border-radius: 5px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ═══════════════════════════════════════════════
   MOBILE  ≤860px
   ═══════════════════════════════════════════════ */
.menu-btn { display: none; }
.scrim    { display: none; }

@media (max-width: 860px) {
  .app { display: block; min-height: 100dvh; }

  .sidebar {
    position: fixed; top: 0; left: 0; height: 100dvh; height: 100vh;
    width: 84%; max-width: 300px; z-index: 90;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(0.32,0.72,0,1);
    overflow-y: auto;
    box-shadow: 0 14px 40px rgba(0,0,0,.4);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .nav a  { padding: 12px 12px; font-size: 14px; }
  .sidebar .nav .group { padding: 16px 12px 6px; }

  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 80; display: none; }
  .scrim.on { display: block; }

  .menu-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 7px; border: 1px solid var(--line);
    background: #fff; color: var(--text); font-size: 16px; flex-shrink: 0; padding: 0;
  }
  .menu-btn:active { background: var(--bg); }

  .main { width: 100%; min-width: 0; }

  .topbar {
    height: auto; min-height: 52px; padding: 9px 14px;
    flex-wrap: wrap; gap: 10px; align-items: center;
    padding-top: calc(9px + env(safe-area-inset-top));
  }
  .topbar h1 { font-size: 15px; flex: 1; min-width: 0; }
  .topbar .btn { padding: 7px 11px; font-size: 12px; }

  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .stat  { padding: 12px 13px; }
  .stat .num { font-size: 22px; }

  .grid2 { grid-template-columns: 1fr; gap: 14px; }
  .grid2 > *, .panel { min-width: 0; max-width: 100%; }
  .stat-row, .summary-grid, .stats.stats-4, .stats { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
  .panel-pair { grid-template-columns: 1fr !important; gap: 14px !important; }
  .pgrid, .pcols { grid-template-columns: 1fr !important; gap: 14px !important; }
  .msg-row { grid-template-columns: 1fr !important; gap: 8px !important; padding: 11px 13px !important; }
  .msg-row .acts { justify-content: flex-start !important; }
  .steps { flex-wrap: wrap; gap: 6px; }
  .steps .step { flex: 1 1 calc(50% - 6px); border-radius: 7px !important; border-left: 1px solid var(--line) !important; }

  html, body { overflow-x: hidden; max-width: 100vw; }

  .schedule-grid, .schedule-board, .dispatch-grid, .truck-columns, .board {
    overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; min-width: 0;
  }
  .board .col { width: 240px !important; }
  .content > * { max-width: 100%; }
  .row .meta  { white-space: normal; text-align: left; font-size: 11px; }
  .row .when  { white-space: nowrap; }
  .content    { padding: 14px 14px 80px; }

  .tabs { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
  .tabs button { white-space: nowrap; flex-shrink: 0; }

  .panel table { min-width: 560px; }
  .panel-body  { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  th, td       { padding: 9px 12px; }
  .row         { padding: 10px 13px; gap: 9px; }
  .row .when   { width: 52px; font-size: 11px; }

  .modal { width: 100%; max-width: 100%; height: 100%; max-height: 100dvh; border-radius: 0; overflow-y: auto; border-radius: 0; }
  .modal .mbody { padding: 16px; }
  .modal h3     { padding: 13px 16px; font-size: 14px; }
  .modal .mfoot { padding: 12px 16px; position: sticky; bottom: 0; background: #fff; }

  input, select, textarea { font-size: 16px; padding: 11px 12px; }

  .toast    { bottom: calc(20px + env(safe-area-inset-bottom)); padding: 10px 16px; }
  .proto-tag { bottom: calc(10px + env(safe-area-inset-bottom)); right: 10px; font-size: 9px; padding: 4px 8px; }
}

@media (max-width: 400px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat .num { font-size: 20px; }
  .topbar h1 { font-size: 14px; }
  .content   { padding: 12px 12px 80px; }
}
