/* ============================================================================
 * Trucking Books — the design system. ONE file. There is no second one.
 *
 * Every page in this product is styled from here. Do not create per-page CSS.
 *
 * Why that rule exists: the JITC Planning app grew 24 separate <page>-2030.css
 * files layered over a shared token set, and they drifted — the same control
 * ended up with different radii, different borders, and two competing token
 * systems (--s30-* and --ops-*) that later had to be reconciled by hand. A new
 * page here gets a class in this file, or it reuses one that already exists.
 *
 * Built on the JITC 2030 tokens so it reads as the same house style:
 * ink #0b1f3a, blue #155eef, page #f3f7fc, the 10/15/20 radius ladder, 44px
 * controls, soft wide shadows, and the frosted-glass panel treatment.
 *
 * GLASS PERFORMANCE RULE (carried over, and it matters):
 * backdrop-filter goes on LARGE, MOSTLY-STATIC surfaces only — the sidebar and
 * page-level cards. Never on table rows, pills, buttons, or anything that
 * repeats dozens of times or animates. Blur is per-element GPU work; a hundred
 * blurred rows will visibly stutter on a laptop.
 * ==========================================================================*/

:root {
  /* ink */
  --tb-ink:          #0b1f3a;
  --tb-ink-soft:     #243b5a;
  --tb-muted:        #64748b;
  --tb-muted-strong: #506581;

  /* ground */
  --tb-page:         #f3f7fc;
  --tb-surface:      rgba(255, 255, 255, 0.92);
  --tb-surface-solid:#ffffff;
  --tb-surface-soft: #f8fbff;
  --tb-glass-border: rgba(96, 140, 210, 0.35);
  --tb-line:         #d8e3f1;
  --tb-line-strong:  #c6d5e8;

  /* accents */
  --tb-blue:         #155eef;
  --tb-blue-dark:    #0f49c7;
  --tb-blue-soft:    #eaf1ff;
  --tb-green:        #079669;
  --tb-green-soft:   #e9f8f2;
  --tb-amber:        #d97706;
  --tb-amber-soft:   #fff5e5;
  --tb-red:          #dc3545;
  --tb-red-soft:     #fff0f1;
  --tb-violet:       #6d4aff;
  --tb-violet-soft:  #f1edff;

  --tb-shadow-sm:    0 8px 24px rgba(32, 60, 96, 0.07);
  --tb-shadow-md:    0 16px 42px rgba(32, 60, 96, 0.10);
  --tb-radius-sm:    10px;
  --tb-radius-md:    15px;
  --tb-radius-lg:    20px;
  --tb-control:      44px;

  --tb-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --tb-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* Single visual world, deliberately: this is a daylight, glass-on-blue-wash
 * product. No dark theme. Colours are therefore stated once and are safe to
 * use directly. */
html { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--tb-ink);
  background-color: var(--tb-page);
  background-image:
    radial-gradient(circle at 82% 0%, rgba(21, 94, 239, 0.07), transparent 29rem),
    radial-gradient(circle at 4% 12%, rgba(109, 74, 255, 0.05), transparent 24rem),
    linear-gradient(180deg, #f8fafe 0%, #f3f7fc 46%, #eef4fb 100%);
  background-attachment: fixed;
  font-family: var(--tb-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--tb-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--tb-blue); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3 { margin: 0; letter-spacing: -.02em; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.7rem; font-weight: 650; }
h2 { font-size: 1.1rem; font-weight: 620; }

.eyebrow {
  font-family: var(--tb-mono);
  font-size: .67rem; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--tb-muted);
}

.num { font-family: var(--tb-mono); font-variant-numeric: tabular-nums; }

/* ---------- glass ---------------------------------------------------------
 * .glass is the ONLY place blur is declared. Anything that wants the frosted
 * treatment adds this class; nothing else sets backdrop-filter. That keeps the
 * performance rule enforceable by reading one selector.
 * ------------------------------------------------------------------------*/

.glass {
  background: var(--tb-surface);
  border: 1px solid var(--tb-glass-border);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--tb-surface-solid); }
}

/* ---------- app shell ---------- */

.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
@media (max-width: 900px) { .shell { grid-template-columns: 1fr; } }

.side {
  border-right: 1px solid var(--tb-glass-border);
  background: var(--tb-surface);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
@media (max-width: 900px) {
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--tb-glass-border); }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .side { background: var(--tb-surface-solid); }
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  background: linear-gradient(145deg, var(--tb-blue), var(--tb-violet));
  box-shadow: 0 4px 12px rgba(21, 94, 239, .25);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: .78rem; letter-spacing: -.03em;
}
.brand-name { font-weight: 640; letter-spacing: -.02em; }
.brand-sub { font-size: .7rem; color: var(--tb-muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--tb-radius-sm);
  color: var(--tb-ink-soft); font-weight: 500; font-size: .9rem;
  text-decoration: none;
  transition: background 150ms ease, color 150ms ease;
}
.nav a:hover { background: rgba(255, 255, 255, .7); color: var(--tb-ink); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--tb-blue-soft); color: var(--tb-blue); font-weight: 600; }
.nav-group { margin-top: 12px; padding: 0 11px 4px; }

.side-foot { margin-top: auto; padding: 0 8px; font-size: .78rem; color: var(--tb-muted); }

.main { padding: 26px clamp(16px, 3vw, 34px) 60px; min-width: 0; }
.head { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }

/* ---------- cards ---------- */

.card {
  background: var(--tb-surface);
  border: 1px solid var(--tb-glass-border);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  border-radius: var(--tb-radius-md);
  box-shadow: var(--tb-shadow-sm);
  padding: 18px 20px;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card { background: var(--tb-surface-solid); }
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* ---------- stat tiles ---------- */

.stat { display: flex; flex-direction: column; gap: 3px; }
.stat-label { font-size: .78rem; color: var(--tb-muted); font-weight: 500; }
.stat-value { font-family: var(--tb-mono); font-variant-numeric: tabular-nums; font-size: 1.55rem; font-weight: 600; letter-spacing: -.02em; }
.stat-note { font-size: .75rem; color: var(--tb-muted); }
.stat-value.good { color: var(--tb-green); }
.stat-value.bad  { color: var(--tb-red); }

/* ---------- pills — no blur, these repeat ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .73rem; font-weight: 600;
  border: 1px solid transparent; white-space: nowrap;
}
.pill-ok    { background: var(--tb-green-soft);  color: var(--tb-green);  border-color: rgba(7, 150, 105, .28); }
.pill-warn  { background: var(--tb-amber-soft);  color: var(--tb-amber);  border-color: rgba(217, 119, 6, .28); }
.pill-bad   { background: var(--tb-red-soft);    color: var(--tb-red);    border-color: rgba(220, 53, 69, .28); }
.pill-info  { background: var(--tb-blue-soft);   color: var(--tb-blue);   border-color: rgba(21, 94, 239, .28); }
.pill-quiet { background: var(--tb-surface-soft); color: var(--tb-muted); border-color: var(--tb-line); }

/* ---------- tables — no blur, rows repeat ---------- */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--tb-radius-sm);
  border: 1px solid var(--tb-line);
  background: var(--tb-surface-solid);
}
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
thead th {
  background: var(--tb-surface-soft);
  text-align: left; font-weight: 600; font-size: .71rem;
  letter-spacing: .07em; text-transform: uppercase; color: var(--tb-muted);
  padding: 9px 12px; white-space: nowrap;
  border-bottom: 1px solid var(--tb-line);
  position: sticky; top: 0; z-index: 1;
}
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--tb-line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--tb-surface-soft); }
td.r, th.r { text-align: right; font-family: var(--tb-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.flagged { background: rgba(217, 119, 6, .07); }
tr.flagged:hover { background: rgba(217, 119, 6, .11); }

/* ---------- forms & buttons ---------- */

label { display: block; font-size: .82rem; font-weight: 550; color: var(--tb-ink-soft); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=file], select, textarea {
  width: 100%; min-height: var(--tb-control);
  padding: 9px 12px;
  background: var(--tb-surface-solid);
  border: 1px solid var(--tb-line-strong);
  border-radius: var(--tb-radius-sm);
  color: var(--tb-ink); font: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--tb-blue); outline: none; box-shadow: 0 0 0 3px var(--tb-blue-soft);
}
.field + .field { margin-top: 14px; }
.hint { font-size: .76rem; color: var(--tb-muted); margin-top: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tb-control); padding: 0 18px;
  border-radius: var(--tb-radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 80ms ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--tb-blue); color: #fff; box-shadow: 0 4px 12px rgba(21, 94, 239, .22); }
.btn-primary:hover { background: var(--tb-blue-dark); }
.btn-primary:disabled { background: #9fb0c7; box-shadow: none; cursor: not-allowed; }
.btn-quiet { background: var(--tb-surface-solid); color: var(--tb-ink); border-color: var(--tb-line-strong); }
.btn-quiet:hover { background: var(--tb-surface-soft); }
.btn-full { width: 100%; }

/* ---------- notices ---------- */

.notice { padding: 11px 14px; border-radius: var(--tb-radius-sm); border: 1px solid; font-size: .86rem; margin-bottom: 16px; }
.notice-bad  { background: var(--tb-red-soft);   border-color: rgba(220, 53, 69, .3);  }
.notice-warn { background: var(--tb-amber-soft); border-color: rgba(217, 119, 6, .3);  }
.notice-ok   { background: var(--tb-green-soft); border-color: rgba(7, 150, 105, .3);  }
.notice-info { background: var(--tb-blue-soft);  border-color: rgba(21, 94, 239, .3);  }

/* ---------- centred auth pages ---------- */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: min(415px, 100%);
  background: var(--tb-surface);
  border: 1px solid var(--tb-glass-border);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  border-radius: var(--tb-radius-lg);
  box-shadow: var(--tb-shadow-md);
  padding: 32px;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .auth-card { background: var(--tb-surface-solid); }
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth-title { font-size: 1.28rem; font-weight: 640; letter-spacing: -.02em; }
.auth-sub { color: var(--tb-muted); font-size: .88rem; margin: 4px 0 22px; }
.auth-foot { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--tb-line); font-size: .78rem; color: var(--tb-muted); }

.code-input { font-family: var(--tb-mono); font-size: 1.5rem; letter-spacing: .5em; text-align: center; padding-left: .5em; }

/* ---------- misc ---------- */

.muted { color: var(--tb-muted); }
.small { font-size: .8rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 3px; }
hr.sep { border: 0; border-top: 1px solid var(--tb-line); margin: 18px 0; }

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

/* ---------- MFA enrolment ----------
 * Matches the JITC Planning enrolment layout: numbered steps, QR panel beside a
 * manual setup key. The QR is inline SVG rendered on the server rather than
 * drawn by a vendored script, so script-src can stay 'none'.
 */

.auth-card-wide { width: min(560px, 100%); }

.steps-list {
  margin: 0 0 20px;
  padding-left: 20px;
  font-size: .85rem;
  color: var(--tb-muted);
  display: flex; flex-direction: column; gap: 5px;
}

.mfa-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding: 16px;
  background: var(--tb-surface-soft);
  border: 1px solid var(--tb-line);
  border-radius: var(--tb-radius-md);
  margin-bottom: 18px;
}
@media (max-width: 520px) { .mfa-grid { grid-template-columns: 1fr; justify-items: center; text-align: center; } }

.mfa-qr { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.mfa-qr svg {
  display: block; width: 168px; height: 168px;
  background: #fff; padding: 8px;
  border: 1px solid var(--tb-line); border-radius: var(--tb-radius-sm);
}
.mfa-qr figcaption { font-size: .72rem; color: var(--tb-muted); }

.mfa-key { display: flex; flex-direction: column; }
.mfa-key-value {
  display: block;
  font-family: var(--tb-mono); font-size: .82rem; line-height: 1.5;
  word-break: break-all; user-select: all;
  padding: 10px 12px;
  background: var(--tb-surface-solid);
  border: 1px solid var(--tb-line-strong);
  border-radius: var(--tb-radius-sm);
}
