/* Haulbook design tokens and shared components.
   Identity: highway-sign green chrome, kraft-box accents, Overpass type (from the Highway Gothic family). */

@font-face { font-family: 'Overpass'; src: url('/assets/fonts/overpass-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Overpass'; src: url('/assets/fonts/overpass-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Overpass'; src: url('/assets/fonts/overpass-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Overpass'; src: url('/assets/fonts/overpass-latin-800-normal.woff2') format('woff2'); font-weight: 800; font-display: swap; }

:root {
  --green-950: #08291D;
  --green-900: #0D3B2A;
  --green-800: #0F5A3D;
  --green-700: #147A50;
  --green-600: #1A8D5D;
  --green-200: #BFE0CD;
  --green-100: #E2F1E8;
  --green-50: #F2F8F4;
  --kraft-700: #9A6332;
  --kraft-500: #C98E52;
  --kraft-300: #DFAE76;
  --kraft-100: #F5E7D5;
  --kraft-50: #FBF5EC;
  --ink-900: #17201C;
  --ink-800: #26302B;
  --ink-700: #38433E;
  --ink-500: #5A6560;
  --ink-400: #7E8984;
  --ink-300: #B3BCB8;
  --ink-200: #D5DCD8;
  --ink-150: #E2E7E4;
  --ink-100: #EBEFED;
  --ink-50: #F4F6F5;
  --amber-700: #835B00;
  --amber-500: #D79A0A;
  --amber-100: #FBF0CF;
  --red-700: #9C2F25;
  --red-600: #BC3A2D;
  --red-100: #FAE6E2;
  --slate-700: #34508A;
  --slate-100: #E5EBF6;

  --bg: var(--ink-50);
  --surface: #FFFFFF;
  --surface-2: #FAFBFA;
  --text: var(--ink-900);
  --text-2: var(--ink-500);
  --text-3: var(--ink-400);
  --line: var(--ink-200);
  --line-soft: var(--ink-100);
  --accent: var(--green-700);
  --accent-ink: #FFFFFF;
  --chrome: var(--green-900);
  --focus: 0 0 0 3px rgba(20, 122, 80, .28);
  --on-green: var(--green-700);   /* text on tinted chips and notes; lighter in dark mode */
  --on-green-strong: var(--green-800);
  --on-kraft: var(--kraft-700);
  --on-red: var(--red-700);
  --on-amber: var(--amber-700);
  --on-slate: var(--slate-700);
  --on-ink: var(--ink-700);

  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --shadow-pop: 0 12px 32px rgba(10, 30, 22, .16), 0 2px 6px rgba(10, 30, 22, .08);

  --font: 'Overpass', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 26px;
  --fs-3xl: 34px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1513; --surface: #161E1A; --surface-2: #1B2420; --text: #E7ECE9; --text-2: #A8B3AE; --text-3: #7E8A85;
    --line: #2C3732; --line-soft: #232D29; --chrome: #0A2A1E; --accent: #2FA672;
    --green-50: #13221B; --green-100: #173126; --green-200: #1F4433; --kraft-50: #221C14; --kraft-100: #2E2418;
    --amber-100: #2D2512; --red-100: #301A17; --slate-100: #1A2234; --ink-50: #141B18; --ink-100: #1D2622; --ink-150: #232D29; --on-green: #5FD39B; --on-green-strong: #8FE3B9; --on-kraft: #E6B886; --on-red: #F2948A; --on-amber: #F0C35A; --on-slate: #A9BDEB; --on-ink: #C9D2CD;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1513; --surface: #161E1A; --surface-2: #1B2420; --text: #E7ECE9; --text-2: #A8B3AE; --text-3: #7E8A85;
  --line: #2C3732; --line-soft: #232D29; --chrome: #0A2A1E; --accent: #2FA672;
  --green-50: #13221B; --green-100: #173126; --green-200: #1F4433; --kraft-50: #221C14; --kraft-100: #2E2418;
  --amber-100: #2D2512; --red-100: #301A17; --slate-100: #1A2234; --ink-50: #141B18; --ink-100: #1D2622; --ink-150: #232D29; --on-green: #5FD39B; --on-green-strong: #8FE3B9; --on-kraft: #E6B886; --on-red: #F2948A; --on-amber: #F0C35A; --on-slate: #A9BDEB; --on-ink: #C9D2CD;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: var(--fs-md); line-height: 1.45; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.005em; }
h1 { font-size: var(--fs-2xl); font-weight: 800; }
h2 { font-size: var(--fs-xl); font-weight: 700; }
h3 { font-size: var(--fs-lg); font-weight: 700; }
h4 { font-size: var(--fs-md); font-weight: 700; }
p { margin: 0 0 10px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
.num, .money { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); border-color: var(--ink-300); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--green-600); border-color: var(--green-600); }
.btn.kraft { background: var(--kraft-500); border-color: var(--kraft-500); color: #fff; }
.btn.kraft:hover { background: var(--kraft-700); border-color: var(--kraft-700); }
.btn.danger { color: var(--red-600); }
.btn.danger:hover { background: var(--red-100); border-color: var(--red-600); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--ink-100); }
.btn.sm { height: 28px; padding: 0 10px; font-size: var(--fs-xs); }
.btn.lg { height: 44px; padding: 0 20px; font-size: var(--fs-md); }
.btn.icon { width: 34px; padding: 0; }
.btn.sm.icon { width: 28px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* forms */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.field .hint { font-size: var(--fs-xs); color: var(--text-3); font-weight: 400; }
.input, select.input, textarea.input { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font-size: var(--fs-md); }
textarea.input { height: auto; min-height: 84px; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.input:hover { border-color: var(--ink-300); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input.money-input { text-align: right; font-variant-numeric: tabular-nums; }
.input-group { display: flex; align-items: stretch; }
.input-group > .addon { display: flex; align-items: center; white-space: nowrap; flex: none; padding: 0 9px; border: 1px solid var(--line); background: var(--ink-50); color: var(--text-2); font-size: var(--fs-sm); }
.input-group > .addon:first-child { border-right: 0; border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group > .addon:last-child { border-left: 0; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.input-group > .input:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group > .input:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.check { display: inline-flex; gap: 8px; align-items: flex-start; cursor: pointer; font-size: var(--fs-sm); }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-error { color: var(--red-600); font-size: var(--fs-sm); font-weight: 600; }
.form-error a { color: inherit; }
.form-note { margin: 0; padding: 10px 12px; border-radius: var(--r-md); background: var(--slate-100); color: var(--on-slate); font-size: var(--fs-sm); line-height: 1.45; }
.form-note a { color: inherit; font-weight: 700; }

/* status pills */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; background: var(--ink-100); color: var(--on-ink); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.plain::before { display: none; }
.pill.s-new_lead { background: var(--kraft-100); color: var(--on-kraft); }
.pill.s-estimate_sent { background: var(--slate-100); color: var(--on-slate); }
.pill.s-booked { background: var(--green-100); color: var(--on-green); }
.pill.s-confirmed { background: var(--green-200); color: var(--on-green-strong); }
.pill.s-in_progress { background: var(--amber-100); color: var(--on-amber); }
.pill.s-completed { background: var(--ink-100); color: var(--on-ink); }
.pill.s-closed { background: var(--ink-50); color: var(--ink-500); border: 1px solid var(--line); }
.pill.s-lost, .pill.s-cancelled { background: var(--red-100); color: var(--on-red); }
.pill.warn { background: var(--amber-100); color: var(--on-amber); }
.pill.good { background: var(--green-100); color: var(--on-green); }
.pill.bad { background: var(--red-100); color: var(--on-red); }
.pill.hot { background: var(--red-100); color: var(--on-red); }

/* surfaces */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel-pad { padding: 18px 20px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-title h3 { font-size: var(--fs-md); }
.divider { height: 1px; background: var(--line-soft); margin: 14px 0; border: 0; }

/* ledger tables */
.ledger { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.ledger th { text-align: left; font-weight: 600; color: var(--text-2); font-size: var(--fs-xs); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.ledger td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.ledger tr.click { cursor: pointer; }
.ledger tr.click:hover td { background: var(--green-50); }
.ledger td.r, .ledger th.r { text-align: right; font-variant-numeric: tabular-nums; }
.ledger tr.total td { font-weight: 800; border-top: 2px solid var(--text); border-bottom: 0; }
.ledger .sub { color: var(--text-3); font-size: var(--fs-xs); }

/* toasts */
.toasts { position: fixed; left: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 300; }
.toast { background: var(--ink-900); color: #fff; padding: 10px 14px; border-radius: var(--r-md); box-shadow: var(--shadow-pop); font-size: var(--fs-sm); font-weight: 600; max-width: 380px; animation: toast-in .18s ease-out; }
.toast.error { background: var(--red-700); }
@keyframes toast-in { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* drawers and modals */
.scrim { position: fixed; inset: 0; background: rgba(8, 20, 15, .38); z-index: 200; display: flex; justify-content: flex-end; animation: fade .15s ease-out; }
.scrim.center { justify-content: center; align-items: flex-start; padding: 8vh 16px 16px; }
.drawer { width: min(520px, 100vw); height: 100%; background: var(--surface); box-shadow: var(--shadow-pop); display: flex; flex-direction: column; animation: slide-in .18s ease-out; }
.modal { width: min(560px, 100%); max-height: 84vh; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); display: flex; flex-direction: column; overflow: hidden; }
.modal.wide { width: min(880px, 100%); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.sheet-body { padding: 18px 20px; overflow: auto; flex: 1; }
.sheet-foot { padding: 12px 20px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-in { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }

/* route strip: the road between stops */
.route { display: flex; align-items: center; gap: 0; min-width: 0; }
.route .stop { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 auto; }
.route .marker { width: 26px; height: 26px; border-radius: 50%; background: var(--ink-800); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; flex: none; }
.route .stop.origin .marker { background: var(--green-700); }
.route .stop.destination .marker { background: var(--kraft-700); }
.route .place { min-width: 0; }
.route .place b { display: block; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.route .place small { display: block; color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.route .road { flex: 1 1 60px; min-width: 56px; height: 8px; margin: 0 10px; border-radius: 4px; background: var(--ink-700); position: relative; }
.route .road::after { content: ''; position: absolute; left: 6px; right: 6px; top: 3.5px; height: 1px; background: repeating-linear-gradient(90deg, var(--kraft-300) 0 7px, transparent 7px 13px); }
.route .road .leg { position: absolute; left: 50%; top: -19px; transform: translateX(-50%); font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); white-space: nowrap; }

/* misc */
.empty { padding: 28px 20px; text-align: center; color: var(--text-2); }
.empty h4 { color: var(--text); margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: 128px 1fr; gap: 8px 12px; font-size: var(--fs-sm); align-items: center; }
.kv > dt { color: var(--text-2); }
.kv > dd { margin: 0; min-width: 0; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 60px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; background: var(--kraft-500); flex: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--ink-300); }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--r-sm); background: var(--ink-100); color: var(--on-ink); font-size: var(--fs-xs); font-weight: 600; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
