/* Freight Broker Demo — light theme, one accent, status colors green/amber/red only. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;

  --accent: #2554d8;
  --accent-hover: #1e45b8;
  --accent-soft: #eaf0fd;
  --accent-soft-2: #d6e2fb;

  --green: #15803d;
  --green-soft: #e7f6ec;
  --amber: #b45309;
  --amber-soft: #fdf2df;
  --red: #c42b2b;
  --red-soft: #fdeaea;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .05);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .18);
  --sidebar-w: 236px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.ico { width: 16px; height: 16px; fill: currentColor; flex: none; }
.hide { display: none !important; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 16px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); display: flex; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; }
.brand-text small { color: var(--muted); font-size: 12px; }

.nav { padding: 8px 10px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; margin-bottom: 2px;
}
.nav a .ico { width: 18px; height: 18px; color: var(--muted); }
.nav a:hover { background: var(--surface-3); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a.active .ico { color: var(--accent); }
.nav .count { margin-left: auto; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); }
.nav .count.red { background: var(--red-soft); color: var(--red); }
.nav .count.amber { background: var(--amber-soft); color: var(--amber); }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); display: grid; gap: 6px; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 60px; display: flex; align-items: center; gap: 14px;
  padding: 0 24px; background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.menu-btn { display: none; }
.search { position: relative; display: flex; align-items: center; gap: 8px; flex: 1; max-width: 460px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; height: 36px; color: var(--muted); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: #fff; }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; height: 100%; color: var(--text); }
.search kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; color: var(--faint); background: #fff; }
.search-results { position: absolute; top: 42px; left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 380px; overflow-y: auto; padding: 6px; }
.search-results .sr-group { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--faint); padding: 8px 8px 4px; letter-spacing: .05em; }
.search-results a { display: flex; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 6px; color: var(--text); }
.search-results a:hover, .search-results a.hl { background: var(--accent-soft); text-decoration: none; }
.search-results .empty { padding: 14px; color: var(--muted); }

.sim-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--amber); background: var(--amber-soft); border: 1px solid #f6ddb0; padding: 4px 10px; border-radius: 999px; white-space: nowrap; margin-left: auto; }
.sim-short { display: none; }
.sim-tag .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.user { display: flex; align-items: center; gap: 9px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar.alt { background: var(--surface-3); color: var(--text-2); }
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta small { color: var(--muted); font-size: 12px; }

.view { padding: 24px; flex: 1; outline: none; max-width: 1480px; width: 100%; }
.footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 24px; font-size: 12.5px; border-top: 1px solid var(--border); color: var(--text-2); background: var(--surface); }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 700; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.crumbs a { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 13px;
  border-radius: 8px; border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible, .icon-btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-accent-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn-accent-soft:hover { background: var(--accent-soft-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { color: var(--red); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: 14px; }
.btn-block { width: 100%; justify-content: flex-start; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-3); }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; font-weight: 600; font-size: 12.5px; color: var(--muted); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.seg button.on { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 14.5px; font-weight: 650; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.g-side { grid-template-columns: minmax(0, 1fr) 360px; }
.g-quote { grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.25fr); }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 24px; }

/* KPI */
.kpi { padding: 16px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; color: var(--text); position: relative; }
.kpi:hover { border-color: var(--accent-soft-2); box-shadow: var(--shadow); text-decoration: none; transform: translateY(-1px); }
.kpi-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.kpi-icon { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.kpi-icon.red { background: var(--red-soft); color: var(--red); }
.kpi-icon.amber { background: var(--amber-soft); color: var(--amber); }
.kpi-icon.green { background: var(--green-soft); color: var(--green); }
.kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kpi-go { position: absolute; right: 14px; top: 16px; color: var(--faint); font-size: 12px; font-weight: 600; }
.kpi:hover .kpi-go { color: var(--accent); }
.trend-up { color: var(--green); font-weight: 600; }
.trend-down { color: var(--red); font-weight: 600; }

/* ---------- Chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); border: 1px solid transparent; }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.blue { background: var(--accent-soft); color: var(--accent); }
.chip.solid-blue { background: var(--accent); color: #fff; }
.chip.outline { background: #fff; border-color: var(--border); color: var(--text-2); }
.stage-Quoted { background: var(--surface-3); color: var(--text-2); }
.stage-Booked { background: var(--accent-soft); color: var(--accent); }
.stage-Dispatched { background: var(--accent-soft-2); color: #1b3f9e; }
.stage-InTransit { background: var(--accent); color: #fff; }
.stage-Delivered { background: var(--green-soft); color: var(--green); }
.stage-Invoiced { background: #e2e8f0; color: #1e293b; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: #f6f9ff; }
.tbl tbody tr.flash { animation: rowflash 2.2s ease; }
@keyframes rowflash { 0%, 40% { background: var(--accent-soft-2); } 100% { background: transparent; } }
.tbl .id { font-weight: 650; color: var(--accent); white-space: nowrap; }
.tbl .lane { white-space: nowrap; }
.tbl .lane .arrow { color: var(--faint); margin: 0 4px; }
.tbl td.num, .tbl th.num { text-align: right; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--muted); }
.empty-state { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--text); margin-bottom: 4px; }

/* ---------- Toolbar & form controls ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.input, .select, .textarea {
  height: 34px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 10px; background: #fff; outline: none; min-width: 0;
  transition: border-color .12s, box-shadow .12s, background .3s;
}
.textarea { height: auto; padding: 10px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.sm, .select.sm { height: 30px; font-size: 13px; }
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon .ico { position: absolute; left: 9px; color: var(--faint); }
.input-icon .input { padding-left: 30px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label, .label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--muted); }
.field .input, .field .select { width: 100%; }
.prefix { position: relative; }
.prefix > span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }
.prefix .input { padding-left: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.filled { animation: fillflash 1.2s ease; }
@keyframes fillflash { 0% { background: var(--accent-soft-2); border-color: var(--accent); } 100% { background: #fff; } }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 4px 0 10px; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---------- Dashboard ---------- */
.greet h1 { font-size: 22px; }
.pipeline { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
.pipeline span { display: block; height: 100%; }
.pipe-legend { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 16px; margin-top: 14px; }
.pipe-legend a { display: flex; align-items: center; gap: 8px; color: var(--text-2); padding: 6px 8px; border-radius: 6px; }
.pipe-legend a:hover { background: var(--surface-2); text-decoration: none; }
.pipe-legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.pipe-legend .n { margin-left: auto; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.alert-list li:last-child { border-bottom: 0; }
.alert-list li:hover { background: var(--surface-2); }
.alert-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.alert-ico.red { background: var(--red-soft); color: var(--red); }
.alert-ico.amber { background: var(--amber-soft); color: var(--amber); }
.alert-ico.blue { background: var(--accent-soft); color: var(--accent); }
.alert-title { font-weight: 600; }
.alert-text { font-size: 12.5px; color: var(--muted); }
.feed { list-style: none; margin: 0; padding: 4px 16px; }
.feed li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.feed li:last-child { border-bottom: 0; }
.feed .when { margin-left: auto; color: var(--faint); font-size: 12px; white-space: nowrap; padding-left: 8px; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(6, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.kcol { background: var(--surface-3); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 360px; transition: background .15s, box-shadow .15s; }
.kcol.over { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 650; font-size: 13px; }
.kcol-head .n { font-size: 11.5px; color: var(--muted); background: #fff; border-radius: 999px; padding: 0 7px; }
.kcol-head .sum { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 500; }
.kcol-body { padding: 0 8px 8px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.kcard { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 11px; box-shadow: var(--shadow-sm); cursor: grab; transition: box-shadow .12s, border-color .12s; }
.kcard:hover { border-color: var(--accent-soft-2); box-shadow: var(--shadow); }
.kcard.dragging { opacity: .45; }
.kcard-top { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.kcard-top .id { font-weight: 700; color: var(--accent); font-size: 12.5px; }
.kcard .lane { font-weight: 600; font-size: 13px; }
.kcard .meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.kcard-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; }
.kcard-foot .move { margin-left: auto; }

/* ---------- Load detail ---------- */
.stepper { display: flex; padding: 18px 16px 16px; gap: 0; overflow-x: auto; }
.step { flex: 1; min-width: 92px; display: flex; flex-direction: column; align-items: center; position: relative; font-size: 12px; color: var(--muted); font-weight: 600; text-align: center; }
.step::before { content: ""; position: absolute; top: 12px; left: -50%; right: 50%; height: 2px; background: var(--border); z-index: 0; }
.step:first-child::before { display: none; }
.step .b { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border-strong); background: #fff; display: grid; place-items: center; z-index: 1; margin-bottom: 6px; font-size: 11.5px; color: var(--muted); }
.step.done .b { background: var(--accent); border-color: var(--accent); color: #fff; }
.step.done::before, .step.cur::before { background: var(--accent); }
.step.cur .b { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.step.done, .step.cur { color: var(--text); }
.dl { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 9px 12px; font-size: 13px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.money-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.money-row > div { padding: 14px 16px; border-right: 1px solid var(--border); }
.money-row > div:last-child { border-right: 0; }
.money-row .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.money-row .val { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 3px; }
.timeline { list-style: none; margin: 0; padding: 14px 16px 6px; position: relative; }
.timeline li { position: relative; padding: 0 0 14px 28px; }
.timeline li::before { content: ""; position: absolute; left: 8px; top: 18px; bottom: -2px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .tdot { position: absolute; left: 0; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface-3); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong); display: grid; place-items: center; }
.timeline .tdot svg { width: 10px; height: 10px; fill: var(--muted); }
.timeline .t-msg .tdot { background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.timeline .t-msg .tdot svg { fill: var(--accent); }
.timeline .t-alert .tdot { background: var(--red-soft); box-shadow: 0 0 0 1px var(--red); }
.timeline .t-alert .tdot svg { fill: var(--red); }
.timeline .t-delivered .tdot, .timeline .t-invoice .tdot { background: var(--green-soft); box-shadow: 0 0 0 1px var(--green); }
.timeline .t-delivered .tdot svg, .timeline .t-invoice .tdot svg { fill: var(--green); }
.timeline .ttext { font-size: 13px; }
.timeline .twhen { font-size: 11.5px; color: var(--faint); }
.timeline .tquote { margin-top: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: 8px 10px; font-size: 12.5px; color: var(--text-2); white-space: pre-line; }
.timeline li.new { animation: rowflash 2.4s ease; border-radius: 6px; }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 9px; font-size: 13px; border: 1px solid transparent; }
.banner.red { background: var(--red-soft); color: #8f1f1f; border-color: #f6c9c9; }
.banner.amber { background: var(--amber-soft); color: #7c3d0a; border-color: #f4d9a8; }
.banner.blue { background: var(--accent-soft); color: #1b3f9e; border-color: var(--accent-soft-2); }
.banner.green { background: var(--green-soft); color: #0f5a2b; border-color: #bfe5cc; }
.banner .ico { margin-top: 1px; }

/* ---------- Quote builder ---------- */
.email-card .email-meta { font-size: 12.5px; color: var(--muted); padding: 12px 16px 0; display: grid; gap: 2px; }
.email-card .email-meta b { color: var(--text-2); font-weight: 600; }
.email-card textarea { width: 100%; border: 0; border-top: 1px solid var(--border); border-radius: 0; min-height: 300px; padding: 14px 16px; font-size: 13px; resize: vertical; outline: none; background: #fff; margin-top: 10px; }
.email-card .ext-bar { display: flex; gap: 8px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.ai-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; letter-spacing: .03em; color: var(--accent); background: var(--accent-soft); padding: 3px 8px; border-radius: 999px; text-transform: uppercase; }
.extract-log { font-size: 12px; color: var(--muted); }
.extract-log .ok { color: var(--green); font-weight: 600; }
mark.hl { background: #fff1c7; color: inherit; border-radius: 3px; padding: 0 2px; transition: background .4s; }
.margin-panel { border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); padding: 16px; }
.margin-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.margin-grid .lbl { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.margin-grid .val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.margin-grid .val.green { color: var(--green); }
.margin-grid .val.amber { color: var(--amber); }
.margin-grid .val.red { color: var(--red); }
.meter { height: 8px; border-radius: 999px; background: var(--border); margin-top: 14px; position: relative; overflow: visible; }
.meter .fill { height: 100%; border-radius: 999px; transition: width .35s ease, background .35s; }
.meter .tick { position: absolute; top: -4px; width: 2px; height: 16px; background: var(--text-2); opacity: .35; }
.meter-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 6px; }
.mkt { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); background: #fff; border: 1px dashed var(--border-strong); border-radius: 8px; padding: 8px 10px; flex-wrap: wrap; }
.mkt b { color: var(--text); }

/* ---------- Matching ---------- */
.match-row td { vertical-align: middle; }
.score { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.score .n { font-weight: 700; font-size: 15px; width: 30px; font-variant-numeric: tabular-nums; }
.score-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-3); display: flex; overflow: hidden; }
.score-bar span { height: 100%; }
.rank { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-weight: 700; font-size: 12px; background: var(--surface-3); color: var(--text-2); }
.rank.top { background: var(--accent); color: #fff; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
tr.ineligible td { color: var(--faint); }
tr.ineligible .cell-main { color: var(--muted); }
tr.best { background: #f7faff; }

/* ---------- Carriers ---------- */
.profile-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.logo-tile { width: 52px; height: 52px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: none; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-grid > div { padding: 14px 16px; border-right: 1px solid var(--border); }
.stat-grid > div:last-child { border-right: 0; }
.stat-grid .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat-grid .val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.doc-list li:last-child { border-bottom: 0; }
.doc-ico { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--muted); }
.doc-ico.ok { background: var(--green-soft); color: var(--green); }
.doc-ico.warn { background: var(--amber-soft); color: var(--amber); }
.doc-ico.bad { background: var(--red-soft); color: var(--red); }
.doc-list .doc-name { font-weight: 600; }
.doc-list .doc-meta { font-size: 12px; color: var(--muted); }
.doc-list .doc-act { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.badge-preview { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); transition: background .3s, border-color .3s; }
.badge-preview.green { background: var(--green-soft); border-color: #bfe5cc; }
.badge-preview.amber { background: var(--amber-soft); border-color: #f4d9a8; }
.badge-preview.red { background: var(--red-soft); border-color: #f6c9c9; }
.badge-preview .big { font-size: 15px; font-weight: 700; }
.lane-hist { display: grid; gap: 8px; }
.lane-hist .lh { display: grid; grid-template-columns: minmax(0, 1fr) 120px 30px; gap: 10px; align-items: center; font-size: 13px; }
.lane-hist .bar { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.lane-hist .bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* ---------- Tracking (customer view) ---------- */
body.public .sidebar, body.public .topbar, body.public .scrim { display: none; }
body.public .main { margin-left: 0; }
body.public .view { max-width: 920px; margin: 0 auto; padding-top: 0; }
.track-top { display: flex; align-items: center; gap: 12px; padding: 18px 0; border-bottom: 1px solid var(--border); margin-bottom: 22px; flex-wrap: wrap; }
.track-top .brand-mark { color: var(--accent); }
.track-hero { padding: 22px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; }
.track-hero h1 { font-size: 24px; }
.eta-box { text-align: right; }
.eta-box .lbl { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.eta-box .val { font-size: 22px; font-weight: 750; }
.route-viz { padding: 8px 22px 22px; }
.route-line { position: relative; height: 54px; }
.route-line .track { position: absolute; left: 10px; right: 10px; top: 20px; height: 4px; border-radius: 4px; background: var(--surface-3); }
.route-line .done { position: absolute; left: 10px; top: 20px; height: 4px; border-radius: 4px; background: var(--accent); transition: width .6s ease; }
.route-line .pin { position: absolute; top: 13px; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); transform: translateX(-50%); }
.route-line .pin.end { border-color: var(--border-strong); }
.route-line .truck { position: absolute; top: 4px; transform: translateX(-50%); width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 0 0 6px var(--accent-soft); transition: left .6s ease; }
.route-ends { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; }
.route-ends small { display: block; font-weight: 500; color: var(--muted); }
.vtl { list-style: none; padding: 6px 22px 10px; margin: 0; }
.vtl li { display: flex; gap: 14px; padding-bottom: 18px; position: relative; }
.vtl li::before { content: ""; position: absolute; left: 11px; top: 26px; bottom: 0; width: 2px; background: var(--border); }
.vtl li:last-child::before { display: none; }
.vtl .vd { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); background: #fff; flex: none; display: grid; place-items: center; }
.vtl li.done .vd { background: var(--accent); border-color: var(--accent); }
.vtl li.done .vd::after { content: ""; width: 8px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(1px, -1px); }
.vtl li.done::before { background: var(--accent); }
.vtl li.cur .vd { border-color: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.vtl li.cur .vd::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.vtl .vt { font-weight: 600; }
.vtl .vs { font-size: 12.5px; color: var(--muted); }
.operator-bar { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--text); color: #e2e8f0; border-radius: 10px; padding: 9px 14px; font-size: 12.5px; margin: 16px 0 0; }
.operator-bar a { color: #fff; font-weight: 600; }

/* ---------- Documents ---------- */
.doc-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.paper { background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 6px; max-width: 860px; margin: 0 auto; padding: 44px 48px; color: #111827; font-size: 13px; }
.paper h2 { font-size: 20px; letter-spacing: .02em; }
.paper .ph { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid #111827; padding-bottom: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.paper .co { font-weight: 800; font-size: 16px; }
.paper .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.paper .box { border: 1px solid #d1d5db; border-radius: 4px; padding: 10px 12px; }
.paper .box h4 { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #6b7280; margin-bottom: 6px; }
.paper table { width: 100%; border-collapse: collapse; margin: 6px 0 16px; }
.paper th, .paper td { border: 1px solid #d1d5db; padding: 7px 9px; text-align: left; font-size: 12.5px; }
.paper th { background: #f3f4f6; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.paper .terms { font-size: 11.5px; color: #4b5563; line-height: 1.55; }
.paper .sigs { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 26px; }
.paper .sig { border-top: 1px solid #111827; padding-top: 6px; font-size: 11.5px; color: #4b5563; position: relative; min-height: 64px; }
.paper .sig svg { position: absolute; bottom: 24px; left: 4px; width: 180px; height: 52px; }
.paper .stamp { display: inline-block; border: 2px solid var(--green); color: var(--green); font-weight: 800; letter-spacing: .1em; padding: 4px 10px; border-radius: 4px; transform: rotate(-4deg); font-size: 12px; }
.paper .watermark { font-size: 10.5px; color: #9ca3af; text-align: center; margin-top: 22px; }

/* ---------- Billing ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 16px; }
.tabs button { border: 0; background: none; padding: 12px 12px 10px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; margin-bottom: -1px; display: inline-flex; gap: 6px; align-items: center; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.aging { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.aging > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.aging .lbl { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.aging .val { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Charts ---------- */
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); }
.chart .axis { stroke: var(--border); }
.chart .grid-l { stroke: var(--border); stroke-dasharray: 3 4; }
.chart .lbl { fill: var(--text-2); font-size: 12px; }
.chart .val { fill: var(--text); font-size: 12px; font-weight: 600; }
.chart .sub { fill: var(--muted); font-size: 11px; }
.chart rect.bar { fill: var(--accent); transition: opacity .15s; }
.chart rect.bar.alt { fill: var(--accent-soft-2); }
.chart rect.bar.low { fill: var(--amber); }
.chart g.b:hover rect.bar { opacity: .82; }
.chart-tip { position: fixed; pointer-events: none; background: var(--text); color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 6px; z-index: 90; white-space: nowrap; box-shadow: var(--shadow-lg); }

/* ---------- Modal ---------- */
.modal-root:empty { display: none; }
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 70; display: grid; place-items: center; padding: 16px; animation: fade .15s ease; }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 720px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: pop .18s ease; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; flex-wrap: wrap; }
.tpl-grid { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 16px; }
.tpl-list { display: grid; gap: 6px; align-content: start; }
.tpl-list button { text-align: left; border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 9px 11px; cursor: pointer; font-weight: 600; font-size: 13px; }
.tpl-list button small { display: block; font-weight: 500; color: var(--muted); font-size: 11.5px; }
.tpl-list button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.msg-preview { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.msg-preview .mh { background: var(--surface-2); padding: 10px 12px; font-size: 12.5px; border-bottom: 1px solid var(--border); display: grid; gap: 3px; }
.msg-preview .mh b { display: inline-block; width: 56px; color: var(--muted); font-weight: 600; }
.msg-preview .mb { padding: 14px; white-space: pre-line; font-size: 13px; line-height: 1.55; min-height: 180px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 95; display: grid; gap: 8px; }
.toast { display: flex; gap: 10px; align-items: center; background: var(--text); color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13px; max-width: 380px; animation: pop .2s ease; }
.toast .ico { color: #86efac; }
.toast.warn .ico { color: #fcd34d; }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .25s ease; }

/* ---------- Tour ---------- */
.tour { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.tour-spot { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(15, 23, 42, .58), 0 0 0 3px var(--accent); transition: all .35s cubic-bezier(.4, 0, .2, 1); pointer-events: none; }
.tour-card { position: fixed; width: 340px; max-width: calc(100vw - 24px); background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); padding: 16px 16px 12px; pointer-events: auto; transition: top .35s ease, left .35s ease; }
.tour-card .tstep { display: flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.tour-card .tnum { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 12px; }
.tour-card h4 { font-size: 16px; margin: 8px 0 4px; }
.tour-card p { color: var(--text-2); font-size: 13.5px; }
.tour-card .tfoot { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.tour-card .tprog { flex: 1; height: 4px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.tour-card .tprog span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.tour-card .tkeys { font-size: 11px; color: var(--faint); margin-top: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-side { grid-template-columns: minmax(0, 1fr); }
  .g-quote { grid-template-columns: minmax(0, 1fr); }
  .email-card textarea { min-height: 220px; }
}
@media (max-width: 980px) {
  .g-main, .g-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 35; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 12px; gap: 8px; }
  .user-meta, .search kbd { display: none; }
  .view { padding: 16px; }
  .footer { padding: 12px 16px; }
}
@media (max-width: 640px) {
  .g-4, .g-2, .form-grid, .form-grid.g3 { grid-template-columns: minmax(0, 1fr); }
  .sim-full { display: none; }
  .sim-short { display: inline; }
  .sim-tag { padding: 4px 8px; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .money-row, .stat-grid, .margin-grid, .aging { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .money-row > div:nth-child(2), .stat-grid > div:nth-child(2) { border-right: 0; }
  .money-row > div:nth-child(-n+2), .stat-grid > div:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .pipe-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tpl-grid { grid-template-columns: minmax(0, 1fr); }
  .tpl-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .track-hero { grid-template-columns: minmax(0, 1fr); }
  .eta-box { text-align: left; }
  .paper { padding: 22px 18px; }
  .paper .grid2, .paper .sigs { grid-template-columns: 1fr; }
  .paper table { display: block; overflow-x: auto; }
  .dl { grid-template-columns: 110px minmax(0, 1fr); }
  .kpi-value { font-size: 24px; }
  .lane-hist .lh { grid-template-columns: minmax(0, 1fr) 70px 24px; }
}

/* ---------- Print (documents) ---------- */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .footer, .no-print, .toasts, .tour, .scrim { display: none !important; }
  .main { margin: 0 !important; }
  .view { padding: 0 !important; max-width: none; }
  .paper { box-shadow: none; border: 0; padding: 0; max-width: none; }
}

/* ---------- Chart pieces (added) ---------- */
.hbars { display: grid; gap: 12px; }
.hb { display: grid; grid-template-columns: minmax(0, 170px) minmax(0, 1fr) 92px; gap: 12px; align-items: center; padding: 2px 0; }
.hb:hover .hb-bar { opacity: .82; }
.hb-l { min-width: 0; }
.hb-l .cell-main { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.hb-svg { display: block; }
.hb-track { fill: var(--surface-3); }
.hb-bar { fill: var(--accent); transition: opacity .15s; }
.hb-bar.low { fill: var(--amber); }
.hb-v { text-align: right; font-weight: 650; font-size: 13px; }
.hb-v small { display: block; font-weight: 500; color: var(--muted); font-size: 11.5px; }
.chart .vbar { fill: var(--accent); transition: opacity .15s; }
.chart .vbar.partial { fill: var(--accent-soft-2); }
.chart g.b:hover .vbar { opacity: .82; }
.chart.scroll { overflow-x: auto; }
.chart.scroll svg { min-width: 440px; }
@media (max-width: 640px) {
  .hb { grid-template-columns: minmax(0, 1fr) 80px; }
  .hb-svg { grid-column: 1 / -1; grid-row: 2; }
}
