/* ============================================================
   Megastar CRM — Shared shell for Super Admin / Admin / Logistics
   / Accounts / Management / Transporter personas. Persona is set via
   <body data-persona="sa|ad|lg|ac|mg|tr"> which tints the sidebar.
   ============================================================ */
@import url("./tokens.css");

a { color: var(--primary); }
button { font-family: inherit; }

/* ============================================================
   PERSONA CHROME UNIFICATION
   Chrome unified to Super Admin theme per client direction 2026-07-17.
   Persona identity retained via avatar accent only (see .persona-avatar
   overrides at the foot of this file). The per-persona *-tint tokens are
   deliberately re-pointed at --sa-tint so that every body[data-persona]
   .sidebar rule below resolves to the exact same colour. Do not restore
   the divergent tints — the client wants Super Admin's look everywhere.
   ============================================================ */
:root {
  /* All persona sidebar tints inherit SA's indigo-50 tint. */
  --lg-tint: var(--sa-tint);
  --ac-tint: var(--sa-tint);
  --mg-tint: var(--sa-tint);
  --tr-tint: var(--sa-tint);
}

/* ---- Shell layout ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sa-tint);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
/* Persona rules kept for source-map clarity — all resolve to --sa-tint. */
body[data-persona="lg"] .sidebar { background: var(--lg-tint); }
body[data-persona="ac"] .sidebar { background: var(--ac-tint); }
body[data-persona="mg"] .sidebar { background: var(--mg-tint); }
body[data-persona="tr"] .sidebar { background: var(--tr-tint); }

.sidebar__brand {
  height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--primary);
}
.sidebar__brand-mark {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.sidebar__brand-title {
  font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
  line-height: 18px;
}
.sidebar__brand-sub {
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-secondary); font-weight: 600;
}

.sidebar__group {
  padding: 14px 20px 4px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-secondary);
}
.sidebar__nav { padding: 4px 8px; display: flex; flex-direction: column; gap: 2px; }
.sidebar__link {
  height: 38px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
}
.sidebar__link:hover { background: var(--neutral-100); color: var(--text-primary); }
.sidebar__link--active {
  background: var(--surface);
  color: var(--primary);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--primary);
}
.sidebar__link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.sidebar__link .pill {
  margin-left: auto;
  min-width: 20px; height: 18px; padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--primary); color: #fff;
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

.sidebar__foot {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}
.avatar {
  width: 30px; height: 30px; border-radius: var(--radius-full);
  background: var(--primary-tint); color: var(--primary);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--primary);
  flex-shrink: 0;
}
.avatar-line strong { display: block; color: var(--text-primary); font-size: 12.5px; font-weight: 600; }
.avatar-line span { display: block; color: var(--text-secondary); font-size: 11px; }

/* ---- Main + Topbar ---- */
.main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
}
.topbar__hamburger {
  display: none;
  width: 38px; height: 38px;
  border: none; background: transparent;
  border-radius: var(--radius);
  color: var(--text-primary);
  align-items: center; justify-content: center;
}
.topbar__hamburger:hover { background: var(--neutral-100); }
.topbar__hamburger svg { width: 20px; height: 20px; }
.topbar__crumb { font-size: 13px; color: var(--text-secondary); }
.topbar__crumb strong { color: var(--text-primary); font-weight: 600; }
.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: 10px; }
.persona-switch {
  height: 34px; padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit; font-size: 12.5px;
  color: var(--text-primary);
  cursor: pointer;
}
.role-chip {
  height: 26px; padding: 0 10px;
  border-radius: var(--radius-full);
  background: var(--primary-tint); color: var(--primary);
  font-size: 11.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
}

/* ---- Content ---- */
.content { padding: 20px 24px 40px; max-width: 1360px; width: 100%; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
.page-title {
  font-weight: 700;
  font-size: 22px;
  line-height: 28px;
  color: var(--text-primary);
  margin: 0;
}
.page-sub { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }
.page-actions { display: flex; align-items: center; gap: 8px; }

/* ---- Buttons ---- */
.btn {
  height: 36px; padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font: inherit; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; }
.btn--primary { background: var(--primary); color: var(--text-inverse); }
.btn--primary:hover { background: var(--primary-hover); }
.btn--secondary { background: var(--surface); color: var(--text-primary); border-color: var(--border-strong); }
.btn--secondary:hover { background: var(--neutral-100); }
.btn--ghost { background: transparent; color: var(--primary); }
.btn--ghost:hover { background: var(--primary-tint); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn--lg { height: 42px; padding: 0 18px; font-size: 14px; }

/* ---- KPI cards ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-grid--5 { grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); }
.kpi-grid--6 { grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.kpi__label {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-secondary);
  overflow-wrap: break-word;
}
.kpi__value {
  font-weight: 700; font-size: 24px; line-height: 30px;
  color: var(--text-primary); margin-top: 4px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: break-word;
  word-break: break-word;
}
.kpi__trend { font-size: 12px; margin-top: 4px; color: var(--text-secondary); }
.kpi__trend--up { color: var(--success); }
.kpi__trend--down { color: var(--danger); }

/* ---- Card generic ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.card__head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card__title {
  font-weight: 600;
  font-size: 15px; margin: 0; color: var(--text-primary);
}
.card__body { padding: 18px; }
.card__body--flush { padding: 0; }

/* ---- Two-column layout ---- */
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
table.data thead th {
  height: 38px;
  text-align: left;
  padding: 0 14px;
  background: var(--neutral-100);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-weight: 600; font-size: 11px;
  letter-spacing: 0.06em; text-transform: uppercase;
  white-space: nowrap;
}
table.data tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:hover { background: var(--neutral-50); }
table.data tbody tr.row--l1 {
  background: var(--success-bg);
  box-shadow: inset 3px 0 0 var(--success);
}
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.mono { font-family: var(--font-mono); font-size: 12px; }
table.data td .btn--sm { font-size: 11.5px; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 10px;
  border-radius: var(--radius-full);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.02em; line-height: 1;
  gap: 4px;
}
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--warning { background: var(--warning-bg); color: var(--warning); }
.badge--danger  { background: var(--danger-bg);  color: var(--danger); }
.badge--info    { background: var(--info-bg);    color: var(--info); }
.badge--neutral { background: var(--neutral-100); color: var(--text-secondary); }
.badge--dot::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; display: inline-block;
}

/* ---- Forms ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-grid--3 { grid-template-columns: repeat(3, 1fr); }
.form-grid--1 { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field--wide { grid-column: 1 / -1; }
.field__label {
  font-size: 12.5px; font-weight: 500; color: var(--text-primary);
}
.field__label .req { color: var(--danger); margin-left: 2px; }
.field__hint { font-size: 11.5px; color: var(--text-secondary); }
input[type="text"], input[type="number"], input[type="date"], input[type="time"],
input[type="tel"], input[type="email"], input[type="password"], select, textarea {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit; font-size: 13.5px;
  color: var(--text-primary);
  width: 100%;
}
textarea { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}
.checkbox-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-primary);
}
.checkbox-row input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--primary); }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  padding: 10px 16px;
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  background: transparent; border: none;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text-primary); }
.tab--active {
  color: var(--primary);
  font-weight: 600;
  border-bottom-color: var(--primary);
}
.tab .pill {
  margin-left: 6px;
  min-width: 20px; height: 18px; padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--neutral-100); color: var(--text-secondary);
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.tab--active .pill { background: var(--primary-tint); color: var(--primary); }

/* ---- Filter chips (scoped so state chips below can share the .chip class) ---- */
.filter-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter-row .chip {
  height: 30px; padding: 0 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12.5px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer;
  line-height: 1;
}
.filter-row .chip:hover { background: var(--neutral-100); }
.filter-row .chip--active {
  background: var(--primary-tint);
  color: var(--primary);
  border-color: var(--primary);
}

/* ---- Kanban ---- */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kanban__col {
  background: var(--neutral-100);
  border-radius: var(--radius-md);
  padding: 10px;
  min-height: 400px;
}
.kanban__col-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 6px 10px;
  font-size: 12px; font-weight: 600;
  color: var(--text-primary);
}
.kanban__col-count {
  font-size: 10.5px; padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--surface); color: var(--text-secondary);
  font-weight: 700;
}
.kanban__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 8px;
  cursor: pointer;
}
.kanban__card:hover { box-shadow: var(--shadow-md); }
.kanban__card-ref {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-secondary);
}
.kanban__card-route {
  font-size: 13px; font-weight: 600; margin: 3px 0;
  color: var(--text-primary);
}
.kanban__card-meta {
  font-size: 11.5px; color: var(--text-secondary);
  display: flex; justify-content: space-between; margin-top: 6px;
}

/* ---- Toast ---- */
.toast-wrap {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  min-width: 260px; max-width: 380px;
  background: var(--surface); color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius); padding: 12px 14px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
}
.toast strong { display: block; margin-bottom: 2px; font-size: 13px; color: var(--text-primary); }
.toast small { color: var(--text-secondary); font-size: 11.5px; }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.5);
  z-index: 60;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 720px; width: 100%;
  max-height: 90vh; overflow-y: auto;
}
.modal--sm { max-width: 480px; }
.modal__head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal__title { font-size: 16px; font-weight: 600; }
.modal__body { padding: 20px; }
.modal__foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}
.modal__close {
  border: none; background: transparent;
  width: 30px; height: 30px; border-radius: var(--radius);
  color: var(--text-secondary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.modal__close:hover { background: var(--neutral-100); color: var(--text-primary); }

/* ---- Section headings inside pages ---- */
.section-title {
  font-size: 15px; font-weight: 600;
  color: var(--text-primary);
  margin: 20px 0 10px;
}
.muted { color: var(--text-secondary); }
.mono { font-family: var(--font-mono); font-size: 12.5px; }

/* ---- Doc thumbnail ---- */
.doc-tile {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex; gap: 10px; align-items: center;
  background: var(--surface);
}
.doc-tile__icon {
  width: 36px; height: 42px;
  border-radius: var(--radius-sm);
  background: var(--info-bg); color: var(--info);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 11px; font-weight: 700;
}
.doc-tile__name { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.doc-tile__meta { font-size: 11.5px; color: var(--text-secondary); }
.doc-tile__action { margin-left: auto; }

/* ---- Upload tile (KYC docs, receiving copies, etc.) ---- */
.upload-tile {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; gap: 12px; align-items: center;
  background: var(--neutral-50);
  cursor: pointer;
}
.upload-tile:hover { background: var(--neutral-100); border-color: var(--primary); }
.upload-tile--done {
  border-style: solid;
  border-color: var(--success);
  background: var(--success-bg);
}
.upload-tile__icon {
  width: 36px; height: 36px; border-radius: var(--radius);
  background: var(--surface); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 10px; font-weight: 700;
}
.upload-tile__label { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.upload-tile__meta { font-size: 11.5px; color: var(--text-secondary); }
.upload-tile__status { margin-left: auto; font-size: 11.5px; color: var(--text-secondary); }

/* ---- Progress bar ---- */
.progress {
  height: 8px;
  background: var(--neutral-100);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 10px;
}
.progress__bar { height: 100%; background: var(--primary); }
.progress-meta {
  display: flex; justify-content: space-between;
  font-size: 11.5px; color: var(--text-secondary);
  margin-top: 6px;
}

/* ---- Timeline ---- */
.timeline { position: relative; padding-left: 24px; margin: 8px 0; }
.timeline::before {
  content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px;
  width: 2px; background: var(--border);
}
.timeline__step { position: relative; padding-bottom: 16px; }
.timeline__step::before {
  content: ''; position: absolute; left: -22px; top: 4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--neutral-200); border: 2px solid var(--surface);
}
.timeline__step--done::before { background: var(--success); }
.timeline__step--active::before { background: var(--primary); box-shadow: 0 0 0 4px var(--primary-tint); }
.timeline__title { font-weight: 600; font-size: 13.5px; }
.timeline__meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ---- Empty state ---- */
.empty {
  padding: 40px 20px; text-align: center;
  color: var(--text-secondary); font-size: 13px;
}

/* ---- Sidebar off-canvas backdrop ---- */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.4); z-index: 39; }
.sidebar-backdrop.is-open { display: block; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 40;
    height: 100vh; transform: translateX(-100%);
    transition: transform 180ms ease;
  }
  .sidebar.is-open { transform: translateX(0); }
  .topbar__hamburger { display: inline-flex; }
  .kpi-grid, .kpi-grid--5, .kpi-grid--6 { grid-template-columns: repeat(2, 1fr); }
  .two-col, .three-col { grid-template-columns: 1fr; }
  .form-grid, .form-grid--3 { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: 1fr; }
  .content { padding: 16px 14px 32px; }
  .page-head { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 600px) {
  .kpi-grid, .kpi-grid--5, .kpi-grid--6 { grid-template-columns: 1fr; }
  .topbar__crumb { display: none; }
}

/* ============================================================
   Shared additions — approval state chips, 12-stage trip
   timeline, trip-detail drawer, filter bar. Used by LG, SA,
   AC, MG, TR pages. Keep class names stable.
   ============================================================ */

/* ---- Approval-state chips (row state pills, shared vocab) ---- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
/* When a table cell holds multiple chips, wrap them cleanly so labels never collide */
.chip-stack {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.chip-pending      { background: #fef3c7; color: #92400e; }
.chip-approved     { background: #dcfce7; color: #166534; }
.chip-rejected     { background: #fee2e2; color: #991b1b; }
.chip-awaiting-sa  { background: #dbeafe; color: #1e40af; }
.chip-live         { background: #fef3c7; color: #92400e; }
.chip-closed       { background: #e5e7eb; color: #374151; }
.chip-draft        { background: #f3f4f6; color: #4b5563; }

/* ---- 12-stage trip timeline (horizontal desktop / vertical mobile) ---- */
.trip-timeline {
  display: flex;
  gap: 0;
  padding: 12px 0 4px;
  overflow-x: auto;
}
.trip-timeline__step {
  position: relative;
  flex: 1 1 0;
  min-width: 88px;
  padding: 0 6px;
  text-align: center;
}
.trip-timeline__step::before {
  content: '';
  position: absolute;
  top: 8px;
  left: calc(50% + 12px);
  right: calc(-50% + 12px);
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.trip-timeline__step:last-child::before { display: none; }
.trip-timeline__step--done::before,
.trip-timeline__step--current::before { background: var(--success); }
.trip-timeline__dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--neutral-200);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
  margin: 0 auto 6px;
  position: relative;
  z-index: 1;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 10px; font-weight: 700;
}
.trip-timeline__step--done .trip-timeline__dot {
  background: var(--success); box-shadow: 0 0 0 1px var(--success);
}
.trip-timeline__step--current .trip-timeline__dot {
  background: var(--primary); box-shadow: 0 0 0 4px var(--primary-tint);
}
.trip-timeline__label {
  font-size: 11px; font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
  word-break: break-word;
  overflow-wrap: break-word;
}
.trip-timeline__step--pending .trip-timeline__label {
  color: var(--text-secondary); font-weight: 500;
}
.trip-timeline__time {
  font-size: 10.5px; color: var(--text-secondary);
  margin-top: 3px; line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
/* Switch to vertical layout below 1100px (was 900px) — 12 nodes on a
   narrow-but-desktop viewport was causing label collisions. */
@media (max-width: 1100px) {
  .trip-timeline {
    flex-direction: column;
    gap: 4px;
    padding: 4px 0;
  }
  .trip-timeline__step {
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 10px;
    align-items: center;
    text-align: left;
    padding: 4px 0;
    min-width: 0;
  }
  .trip-timeline__dot { margin: 0; }
  .trip-timeline__step::before {
    top: 22px;
    bottom: -8px;
    left: 10px;
    right: auto;
    width: 2px;
    height: auto;
  }
}

/* ---- Trip Detail drawer (right-side slide-in, 640px) ---- */
.trip-drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.5);
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}
.trip-drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}
.trip-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 640px;
  max-width: 100%;
  height: 100vh;
  background: var(--surface);
  z-index: 71;
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 220ms ease;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.trip-drawer.is-open { transform: translateX(0); }
.trip-drawer__head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}
.trip-drawer__title {
  font-size: 16px; font-weight: 600;
  color: var(--text-primary);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.trip-drawer__sub {
  font-size: 12.5px; color: var(--text-secondary);
  margin-top: 4px;
}
.trip-drawer__body { padding: 18px 20px 40px; }
.trip-drawer__section { margin-top: 22px; }
.trip-drawer__section:first-child { margin-top: 0; }
.trip-drawer__section-title {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.trip-drawer__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 16px;
  font-size: 12.5px;
}
.trip-drawer__grid > div span { color: var(--text-secondary); display:block; font-size: 11px; }
.trip-drawer__grid > div strong { color: var(--text-primary); font-size: 13px; }
.trip-drawer__close {
  border: none; background: transparent;
  width: 30px; height: 30px; border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.trip-drawer__close:hover { background: var(--neutral-100); color: var(--text-primary); }
@media (max-width: 900px) {
  .trip-drawer { width: 100%; }
  .trip-drawer__grid { grid-template-columns: 1fr; }
}

/* ---- Filter bar (bids, contracts, trips, own-fleet) ---- */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 12px;
  align-items: end;
}
.filter-bar .field { margin: 0; gap: 4px; min-width: 0; }
.filter-bar .field__label {
  font-size: 10.5px;
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.filter-bar input, .filter-bar select { height: 34px; font-size: 12.5px; min-width: 0; width: 100%; }
.filter-bar__actions {
  display: flex; gap: 6px; align-items: center;
  padding-bottom: 1px;
  align-self: end;
}
@media (max-width: 600px) {
  .filter-bar { grid-template-columns: 1fr; }
  .filter-bar__actions { justify-content: flex-end; }
}

/* ---- Banner (state notice on top of forms/screens) ---- */
.state-banner {
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  background: var(--info-bg);
  color: var(--text-primary);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.state-banner--warning { border-left-color: var(--warning); background: var(--warning-bg); }
.state-banner--success { border-left-color: var(--success); background: var(--success-bg); }

/* ============================================================
   Overlap polish v2 — sidebar ellipsis, table truncation,
   drawer word-break, Admin persona tint.
   ============================================================ */

/* Sidebar labels: hide overflow so long text with a pill never wraps icons */
.sidebar__link { overflow: hidden; min-width: 0; }
.sidebar__link > span:not(.pill) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Table cell safety — long UTRs/route names truncate with title tooltip pattern */
table.data td { min-width: 0; }
.cell-truncate {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.cell-mono-wrap {
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-wrap: anywhere;
  word-break: break-all;
}

/* Trip drawer — long strings wrap gracefully instead of overflowing */
.trip-drawer__grid strong,
.trip-drawer__grid span { word-break: break-word; overflow-wrap: break-word; }
.trip-drawer__section { min-width: 0; }
.trip-drawer__body { overflow-wrap: break-word; }

/* Form-grid label alignment — label lives in the same row baseline as input */
.form-grid .field__label { align-self: start; }

/* KPI trend row — stat chips inside .kpi__trend line up neatly */
.kpi__trend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Toolbar wrap helper — 3+ btn toolbars stack cleanly at narrow widths */
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ============================================================
   Persona chrome — sidebar tints unified to Super Admin (2026-07-17).
   --ad-tint now equals --sa-tint. Persona identity is retained
   ONLY through the avatar accent colours defined below.
   ============================================================ */
:root { --ad-tint: var(--sa-tint); }
body[data-persona="ad"] .sidebar { background: var(--ad-tint); }

/* Per-persona AVATAR accent — the single remaining visual differentiator
   between personas. Chrome (sidebar, topbar, KPI, cards) is identical
   across all 6 roles; the avatar tells the user which role they are in. */
body[data-persona="sa"] .persona-avatar,
body[data-persona="sa"] .avatar { background: #7c3aed; color: #ffffff; border-color: #7c3aed; }
body[data-persona="ad"] .persona-avatar,
body[data-persona="ad"] .avatar { background: #4f46e5; color: #ffffff; border-color: #4f46e5; }
body[data-persona="lg"] .persona-avatar,
body[data-persona="lg"] .avatar { background: #ea580c; color: #ffffff; border-color: #ea580c; }
body[data-persona="ac"] .persona-avatar,
body[data-persona="ac"] .avatar { background: #0d9488; color: #ffffff; border-color: #0d9488; }
body[data-persona="mg"] .persona-avatar,
body[data-persona="mg"] .avatar { background: #db2777; color: #ffffff; border-color: #db2777; }
body[data-persona="tr"] .persona-avatar,
body[data-persona="tr"] .avatar { background: #b45309; color: #ffffff; border-color: #b45309; }

/* ============================================================
   Fruxinfo branding — Megastar Foods logo + agency footer.
   Added 2026-07-17. Do NOT remove: client-facing branding.
   ============================================================ */
.brand-logo {
  height: 32px;
  width: auto;
  display: block;
  object-fit: contain;
}
.brand-logo--auth {
  height: 56px;
  margin: 0 auto 12px;
}
/* Fit inside the sidebar__brand row: replaces the old MSF square. */
.sidebar__brand .brand-logo { height: 34px; }
/* Fit inside the public-topbar brand row (register / approval-pending). */
.public-topbar .brand-logo { height: 30px; }

.site-footer {
  padding: 14px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary, #6b7280);
  border-top: 1px solid var(--border, #e5e7eb);
  margin-top: 32px;
  background: var(--surface, #fff);
}
.site-footer strong { color: var(--text-primary, #111827); font-weight: 600; }
