/* SGA Freight — operations portal. Mobile-first, enterprise: one type scale, a restrained palette, hairline
   borders and soft shadows, GPU-friendly motion, honest empty/loading/error states. Light + dark. */

:root {
  --bg: #eef1f6; --surface: #ffffff; --surface-2: #f6f8fb; --ink: #0f1b2d; --ink-2: #51607a; --ink-3: #8794a9;
  --line: #e2e7f0; --line-2: #eef1f6; --accent: #1f5fd6; --accent-ink: #ffffff; --accent-soft: #e9f0fe;
  --good: #167a4b; --warn: #b26a00; --crit: #c0392b;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .05), 0 6px 20px rgba(15, 27, 45, .05);
  --shadow-lg: 0 10px 40px rgba(15, 27, 45, .12);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  --maxw: 1180px; --topbar-h: 56px; --side-w: 244px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1017; --surface: #141c29; --surface-2: #0f1724; --ink: #eef3fb; --ink-2: #a7b4ca; --ink-3: #6b7a93;
    --line: #243247; --line-2: #1b2636; --accent: #5b94f2; --accent-ink: #0a1017; --accent-soft: #16233b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35); --shadow-lg: 0 12px 44px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --bg: #0a1017; --surface: #141c29; --surface-2: #0f1724; --ink: #eef3fb; --ink-2: #a7b4ca; --ink-3: #6b7a93;
  --line: #243247; --line-2: #1b2636; --accent: #5b94f2; --accent-ink: #0a1017; --accent-soft: #16233b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35); --shadow-lg: 0 12px 44px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }
.muted { color: var(--ink-3); }

/* ---------- buttons / inputs ---------- */
.btn { font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 11px 18px; min-height: 44px; background: var(--accent); color: var(--accent-ink); line-height: 1; transition: transform .12s cubic-bezier(.2, .7, .3, 1), filter .12s, box-shadow .12s; }
.btn:hover { filter: brightness(1.06); } .btn:active { transform: translateY(1px) scale(.995); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 38%, transparent); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; filter: none; }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn--block { width: 100%; }
.link-btn { font: inherit; font-weight: 600; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; }
.link-btn.back { font-size: 13.5px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
input, select { font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; min-width: 0; width: 100%; min-height: 44px; transition: border-color .15s, box-shadow .15s; appearance: none; -webkit-appearance: none; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238794a9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 38px; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input::placeholder { color: var(--ink-3); }

/* ---------- sign in ---------- */
.auth { min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 28px 24px; }
.auth-sub { margin: 4px 0 22px; color: var(--ink-2); font-size: 14.5px; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }
.auth-card .btn { margin-top: 4px; }
.auth-foot { color: var(--ink-3); font-size: 12px; margin: 0; }
.advanced { margin-top: 20px; border-top: 1px solid var(--line-2); padding-top: 14px; }
.advanced > summary, .inline-advanced > summary { cursor: pointer; color: var(--ink-3); font-size: 12.5px; list-style: none; user-select: none; }
.advanced > summary::-webkit-details-marker, .inline-advanced > summary::-webkit-details-marker { display: none; }
.advanced-body { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.02em; color: var(--ink); }
.brand-mark { display: inline-flex; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); align-items: center; justify-content: center; flex: none; }
.brand-mark svg { width: 18px; height: 18px; }
.brand--lg { font-size: 22px; }
.brand--lg .brand-mark { width: 40px; height: 40px; border-radius: 11px; }
.brand--lg .brand-mark svg { width: 24px; height: 24px; }

/* ---------- top bar ---------- */
/* Fixed (not sticky): sticky top bars drop out on several mobile browsers; fixed stays reachable everywhere. */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 30; display: flex; align-items: center; gap: 8px; height: var(--topbar-h); padding: 0 12px; background: color-mix(in srgb, var(--surface) 94%, transparent); -webkit-backdrop-filter: saturate(1.3) blur(10px); backdrop-filter: saturate(1.3) blur(10px); border-bottom: 1px solid var(--line); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--ink-2); cursor: pointer; transition: background .12s, color .12s; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.menu-toggle { display: inline-flex; }

.acct-wrap { position: relative; }
.acct { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px 0 7px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); cursor: pointer; max-width: 40vw; transition: background .12s; }
.acct:hover { background: var(--surface-2); }
.acct:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.acct-avatar { width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; text-transform: uppercase; }
.acct-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-caret { width: 16px; height: 16px; color: var(--ink-3); flex: none; }
.menu { position: absolute; top: 48px; right: 0; min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; animation: pop .14s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 6px; }
.menu-name { font-weight: 600; font-size: 14px; } .menu-sub { color: var(--ink-3); font-size: 12px; margin-top: 2px; word-break: break-word; }
.menu-item { display: block; width: 100%; text-align: left; font: inherit; font-size: 14px; color: var(--ink); background: transparent; border: 0; border-radius: 8px; padding: 10px; cursor: pointer; }
.menu-item:hover { background: var(--surface-2); }

/* ---------- body: sidebar + content ---------- */
.body { position: relative; padding-top: var(--topbar-h); }
.scrim { position: fixed; top: var(--topbar-h); left: 0; right: 0; bottom: 0; background: rgba(10, 16, 23, .45); z-index: 35; animation: fade .18s ease; }
.sidebar { position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: 272px; max-width: 82vw; background: var(--surface); border-right: 1px solid var(--line); z-index: 40; transform: translateX(-100%); transition: transform .22s cubic-bezier(.2, .7, .3, 1); display: flex; flex-direction: column; padding: 14px 12px; overflow-y: auto; }
.sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; font-size: 15px; font-weight: 550; color: var(--ink-2); background: transparent; border: 0; border-radius: var(--radius-sm); padding: 12px 13px; cursor: pointer; transition: background .12s, color .12s; }
.nav-item svg { width: 20px; height: 20px; flex: none; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item[aria-current="true"] { background: var(--accent-soft); color: var(--accent); }
.nav-item:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.sidebar-foot { margin: auto 0 4px; padding: 10px 13px 0; color: var(--ink-3); font-size: 12px; }

.content { max-width: var(--maxw); margin: 0 auto; padding: 18px 16px 72px; }
.view { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.panel-head h1 { font-size: 21px; }
.updated { color: var(--ink-3); font-size: 12px; }
.lead { color: var(--ink-2); font-size: 14.5px; margin: 6px 0 18px; }
.group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; margin: 24px 0 12px; }
.banner { margin: 14px 0 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); color: var(--ink-2); font-size: 13.5px; }

/* ---------- cards / KPI ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
.stat { padding: 15px 16px; position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--ink-3); opacity: .5; }
.stat.accent::before { background: var(--accent); opacity: 1; } .stat.good::before { background: var(--good); opacity: 1; }
.stat.warn::before { background: var(--warn); opacity: 1; } .stat.crit::before { background: var(--crit); opacity: 1; }
.stat .label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.stat .value { font-size: 27px; font-weight: 700; margin-top: 7px; letter-spacing: -.02em; line-height: 1.1; }
.stat .sub { font-size: 12px; color: var(--ink-3); margin-top: 4px; min-height: 1em; }

/* ---------- badges ---------- */
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, var(--line)); background: color-mix(in srgb, var(--good) 10%, transparent); }
.badge.go { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--accent-soft); }
.badge.bad { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 40%, var(--line)); background: color-mix(in srgb, var(--crit) 10%, transparent); }

/* ---------- forms ---------- */
.card.form { padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; }
.form-section { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; margin-top: 4px; }
.form-section:first-child { margin-top: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inline-advanced { border-top: 1px solid var(--line-2); padding-top: 12px; }
.inline-advanced .form-row { margin-top: 12px; }
.card.form .btn { align-self: flex-start; }

/* ---------- quote result ---------- */
.quote-result { margin-top: 16px; }
.quote-card { padding: 20px 18px; }
.quote-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.quote-lane { font-weight: 600; color: var(--ink-2); font-size: 14px; }
.quote-price { margin: 14px 0 18px; }
.quote-total { font-size: 40px; font-weight: 750; letter-spacing: -.03em; line-height: 1; }
.quote-total-label { color: var(--ink-3); font-size: 13px; margin-top: 6px; }
.quote-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 14px 0; border-top: 1px solid var(--line-2); }
.quote-lines { border-top: 1px solid var(--line-2); padding-top: 12px; display: flex; flex-direction: column; gap: 7px; }
.quote-line { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--ink-2); }
.quote-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; }

/* ---------- shipments ---------- */
.ship-row { display: block; width: 100%; text-align: left; cursor: pointer; padding: 15px 16px; margin-bottom: 10px; transition: border-color .12s, transform .1s; }
.ship-row:hover { border-color: var(--accent); } .ship-row:active { transform: scale(.995); }
.ship-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ship-lane { font-weight: 600; font-size: 15px; }
.ship-price { font-weight: 700; }
.ship-sub { color: var(--ink-3); font-size: 12.5px; margin-top: 4px; }
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 14px; }
.detail-head h2 { font-size: 18px; }
.detail-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.card.mini { padding: 12px 14px; } .card.mini-pad { padding: 14px 16px; }
.mini .rk, .result-rows .rk, .quote-meta .rk { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .03em; }
.mini .rv { font-size: 15px; margin-top: 2px; font-weight: 550; }
.detail-sub { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin: 20px 0 10px; }
.stop-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.stop-row:last-child { border-bottom: 0; }
.stop-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; } .stop-dot.pu { background: var(--accent); } .stop-dot.do { background: var(--good); }
.stop-kind { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .03em; } .stop-label { font-weight: 550; }
.issue-row { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--line-2); font-size: 14px; } .issue-row:last-child { border-bottom: 0; }

/* ---------- results (find trucks / my trucks) ---------- */
.board-result { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
#myTrucks { display: flex; flex-direction: column; gap: 10px; }
.result { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.result-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.result-equip { font-weight: 650; font-size: 15px; }
.result-dh { font-size: 12.5px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.result-rows { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px 16px; }
.result-rows .rv, .quote-meta .rv { font-size: 14px; margin-top: 1px; }
.result-count { color: var(--ink-3); font-size: 12.5px; padding: 2px; }

/* ---------- assistant ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { font: inherit; font-size: 13px; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.chip:hover { background: var(--surface-2); color: var(--ink); border-color: var(--ink-3); }
.ask { display: flex; gap: 10px; } .ask input { flex: 1; } .ask .btn { flex: none; }
.answer-wrap { margin-top: 16px; }
.answer { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); white-space: pre-wrap; line-height: 1.6; }

/* ---------- states ---------- */
.empty, .error { padding: 26px 18px; text-align: center; color: var(--ink-3); border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface); }
.error { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 40%, var(--line)); }
.skeleton { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-height: 92px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ink) 6%, transparent), transparent); animation: shimmer 1.25s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(12px); opacity: 0; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 70; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--crit); color: #fff; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 420px) { .grid { grid-template-columns: 1fr; } .stat .value { font-size: 24px; } .quote-meta { grid-template-columns: 1fr; gap: 8px; } .result-rows { grid-template-columns: 1fr 1fr; } }

/* ---------- desktop: fixed sidebar, wider grid ---------- */
@media (min-width: 900px) {
  .menu-toggle { display: none; }
  .scrim { display: none !important; }
  .body { display: flex; align-items: flex-start; max-width: var(--maxw); margin: 0 auto; }
  .sidebar { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); transform: none; width: var(--side-w); max-width: none; z-index: 1; box-shadow: none; flex: none; background: transparent; border-right: 1px solid var(--line); }
  .content { flex: 1; min-width: 0; max-width: none; margin: 0; padding: 24px 28px 64px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
  .detail-meta { grid-template-columns: repeat(4, 1fr); }
  .card.form, .ask, .answer, .quote-card { max-width: 680px; }
}
