/* Freight Desk. Layout: header with brand, tabs and user; one working area; edits happen in a modal sheet. */
:root {
  color-scheme: light;
  --bg: #f2f5f7;
  --surface: #ffffff;
  --surface-2: #e9eef2;
  --line: #d5dde4;
  --fg: #14212c;
  --muted: #5a6b79;
  --accent: #0b6f7a;
  --accent-fg: #ffffff;
  --accent-soft: #d8eef0;
  --ok: #1d6b3a; --ok-bg: #dcf0e3;
  --warn: #8a5a00; --warn-bg: #fbecc8;
  --bad: #a3262a; --bad-bg: #fadcdc;
  --info: #274f8f; --info-bg: #dde8f8;
  --neutral-bg: #e4e9ee;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --radius: 6px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0e171e; --surface: #15212a; --surface-2: #1c2b36; --line: #2b3d4a;
    --fg: #e6edf2; --muted: #93a6b4; --accent: #4cc3cf; --accent-fg: #06252a; --accent-soft: #123b42;
    --ok: #7fd49c; --ok-bg: #163a25; --warn: #f0c36a; --warn-bg: #3d2f0c;
    --bad: #f2928f; --bad-bg: #44191b; --info: #8fb4f0; --info-bg: #182c4c; --neutral-bg: #243541;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font-family: var(--font-body); font-size: 14px; line-height: 1.45;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 16px 48px;
}
.wrap { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.wrap.narrow { max-width: 420px; margin-top: 8vh; }
h1, h2, h3 { margin: 0; text-wrap: balance; font-weight: 600; }
p { margin: 0 0 12px; }
code { font-family: var(--font-mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 14px; }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; justify-content: space-between; }
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand h1 { font-size: 20px; letter-spacing: -0.01em; }
.brand span { color: var(--muted); font-size: 12px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .08em; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { border: 1px solid transparent; background: transparent; padding: 7px 12px; border-radius: var(--radius); cursor: pointer; color: var(--muted); font-weight: 500; }
.tab:hover { background: var(--surface-2); color: var(--fg); }
.tab[aria-current="page"] { background: var(--accent); color: var(--accent-fg); }
.tab .n { font-family: var(--font-mono); font-size: 11px; margin-left: 6px; opacity: .8; }
.who { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; flex-wrap: wrap; }

.banner { padding: 9px 12px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn); font-size: 13px; }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner[hidden] { display: none; }

.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.bar .grow { flex: 1 1 200px; min-width: 0; }
input[type=text], input[type=search], input[type=date], input[type=number], input[type=email], input[type=tel], input[type=password], select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; min-width: 0;
}
textarea { resize: vertical; min-height: 70px; }
.btn { display: inline-block; border: 1px solid var(--line); background: var(--surface); padding: 8px 12px; border-radius: var(--radius); cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; color: var(--fg); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kpi .v { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi .v.sm { font-size: 17px; line-height: 1.5; padding-top: 4px; }
.kpi .s { font-size: 12px; color: var(--muted); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel h2 { font-size: 14px; }
.panel h1 { font-size: 18px; }
.panel .sub { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 6px; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.brow { display: grid; grid-template-columns: 110px 1fr 32px; align-items: center; gap: 10px; font-size: 13px; }
.brow .track { background: var(--surface-2); height: 10px; border-radius: 2px; overflow: hidden; display: block; }
.brow .fill { height: 100%; background: var(--accent); border-radius: 2px; display: block; }
.brow .num { font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }

.list { display: flex; flex-direction: column; }
.item { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); align-items: baseline; flex-wrap: wrap; }
.item:first-child { border-top: 0; padding-top: 0; }
.item .main { min-width: 0; flex: 1 1 180px; }
.item .main b { font-weight: 600; }
.item .meta { color: var(--muted); font-size: 12px; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }

.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; min-width: 760px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 500; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
td .sec { color: var(--muted); font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.act { white-space: nowrap; text-align: right; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--neutral-bg); color: var(--fg); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.due-bad { color: var(--bad); font-weight: 500; }

.empty { padding: 36px 16px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty b { color: var(--fg); font-size: 15px; }
.docs { display: flex; gap: 3px; flex-wrap: wrap; }
.docs i { width: 9px; height: 9px; border-radius: 2px; background: var(--surface-2); border: 1px solid var(--line); display: block; }
.docs i.on { background: var(--ok); border-color: var(--ok); }

.overlay { position: fixed; inset: 0; background: rgba(8, 16, 22, .55); display: flex; align-items: flex-start; justify-content: center; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); overflow-y: auto; z-index: 20; }
.overlay[hidden] { display: none; }
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; width: 100%; max-width: 640px; margin-top: 4vh; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.sheet h2 { font-size: 17px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fields .full { grid-column: 1 / -1; }
.f label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 6px; }
.checks label { display: flex; gap: 8px; align-items: center; color: var(--fg); font-size: 13px; margin: 0; }
.checks input { width: auto; }
.sheet .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.confirm { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: var(--radius); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.err { color: var(--bad); font-size: 13px; margin-top: 8px; }
.err[hidden] { display: none; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 9px 14px; border-radius: var(--radius); z-index: 30; font-size: 13px; max-width: calc(100% - 32px); }
.toast[hidden] { display: none; }

@media (max-width: 560px) {
  .fields { grid-template-columns: 1fr; }
  .brow { grid-template-columns: 90px 1fr 28px; }
}
@media (prefers-reduced-motion: no-preference) { .fill { transition: width .25s ease; } }
