/* hub.css - hub.happyhaulexpress.com theme.
   The internal worker hub shares the public site's brand tokens (oklch
   red+gold, Archivo display / Manrope body; see www/assets/site.css) but
   is tuned as a working tool: denser type, compact controls, tabular
   numerals for money columns, a dark-ink sidebar shell. Light-only, like
   the brand. Served at /assets/hub.css; font URLs are relative to this
   file so the same stylesheet renders in the design-system previews. */

/* ---------- Fonts (variable, latin + latin-ext subsets) ---------- */

@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 600 900;
  font-display: swap;
  src: url(fonts/archivo-600-900-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 600 900;
  font-display: swap;
  src: url(fonts/archivo-600-900-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/manrope-400-700-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/manrope-400-700-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Variable weight 200-700; SIL OFL 1.1 (fonts/LICENSE-cascadia-mono.txt). */
@font-face {
  font-family: "Cascadia Mono";
  font-style: normal;
  font-weight: 200 700;
  font-display: swap;
  src: url(fonts/cascadia-mono-vf.woff2) format("woff2");
}

/* ---------- Design tokens ---------- */

:root {
  color-scheme: light;
  --radius: 0.6rem;                            /* tighter than the site's 0.9 */
  --background: oklch(0.985 0.005 60);         /* app canvas, faintly warm */
  --surface: oklch(1 0 0);                     /* cards, table grounds */
  --foreground: oklch(0.18 0.01 40);
  --primary: oklch(0.56 0.235 28.5);           /* brand red  (~#E11B22) */
  --primary-soft: oklch(0.97 0.02 28.5);       /* red-tinted ground */
  --primary-foreground: oklch(0.99 0 0);
  --gold: oklch(0.845 0.166 86);               /* brand gold (~#F5C518) */
  --gold-soft: oklch(0.965 0.05 92);
  --gold-foreground: oklch(0.2 0.03 60);
  --muted: oklch(0.955 0.008 60);
  --muted-foreground: oklch(0.48 0.02 45);
  --ink: oklch(0.17 0.01 40);                  /* sidebar ground */
  --ink-2: oklch(0.24 0.015 40);               /* sidebar hover/raised */
  --ink-foreground: oklch(0.93 0.008 60);
  --ink-muted: oklch(0.66 0.015 50);
  --border: oklch(0.9 0.012 60);
  --border-strong: oklch(0.82 0.015 60);
  --input: oklch(0.86 0.012 60);
  --ring: oklch(0.56 0.235 28.5);
  --ok: oklch(0.55 0.14 150);
  --ok-soft: oklch(0.96 0.035 150);
  --warn: oklch(0.62 0.13 70);
  --warn-soft: oklch(0.97 0.045 85);
  --danger: oklch(0.5 0.19 27);
  --danger-soft: oklch(0.96 0.025 27);
  --info: oklch(0.52 0.11 245);
  --info-soft: oklch(0.96 0.02 245);
  --gradient-brand: linear-gradient(135deg, oklch(0.56 0.235 28.5), oklch(0.63 0.21 38));
  --gradient-gold: linear-gradient(135deg, oklch(0.87 0.16 92), oklch(0.8 0.17 72));
  --shadow-card: 0 4px 16px -8px oklch(0.18 0.01 40 / 0.18);
  --shadow-pop: 0 14px 34px -16px oklch(0.18 0.01 40 / 0.35);
  --font-display: "Archivo", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "Manrope", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Cascadia Mono", ui-monospace, Menlo, Consolas, monospace;
  --sidebar-w: 15.5rem;
}

/* ---------- Base ---------- */

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

html { overflow-x: hidden; overflow-x: clip; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 0.5rem;
  overflow-wrap: break-word;
}
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }

p { margin: 0 0 1rem; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.icon { width: 1.15rem; height: 1.15rem; flex: none; }
.muted { color: var(--muted-foreground); }
.mono { font-family: var(--font-mono); font-size: 0.875em; }
.num { font-variant-numeric: tabular-nums lining-nums; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ---------- App shell: sidebar + topbar + content ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  background: var(--ink);
  color: var(--ink-foreground);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  gap: 0.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.25rem 0.5rem 0.9rem;
  border-bottom: 1px solid oklch(1 0 0 / 0.08);
  margin-bottom: 0.6rem;
}
.sidebar-brand img {
  width: 2.1rem; height: 2.1rem; border-radius: 0.45rem;
  background: #fff; padding: 0.12rem;
}
.sidebar-brand b {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
  line-height: 1.1;
  display: block;
}
.sidebar-brand span { display: block; font-size: 0.72rem; color: var(--ink-muted); }

.nav-section {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-muted);
  padding: 0.85rem 0.6rem 0.3rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 0.45rem;
  color: var(--ink-foreground);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
}
.nav-item:hover { background: var(--ink-2); text-decoration: none; }
.nav-item[aria-current="page"] {
  background: var(--ink-2);
  box-shadow: inset 3px 0 0 var(--gold);
  color: #fff;
}
.nav-item .icon { color: var(--ink-muted); }
.nav-item[aria-current="page"] .icon { color: var(--gold); }
.nav-item .badge { margin-left: auto; }

.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid oklch(1 0 0 / 0.08);
  padding-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 1.1rem; margin: 0; }
.topbar-spacer { flex: 1; }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.user-chip .avatar {
  width: 1.9rem; height: 1.9rem;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: var(--primary-foreground);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 800 0.8rem/1 var(--font-display);
}
.user-chip .role { color: var(--muted-foreground); font-weight: 400; }

.content { padding: 1.5rem; display: grid; gap: 1.25rem; align-content: start; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.page-head h2 { margin: 0; }
.page-head .btn-row { margin-left: auto; }

/* Narrow screens: the hub is desktop-first; collapse the sidebar to a
   top strip rather than hiding navigation entirely. */
@media (max-width: 56rem) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar-brand { border: 0; margin: 0; padding: 0.25rem 0.5rem; }
  .nav-section { display: none; }
  .sidebar-foot { display: none; }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 0;
  border-radius: calc(var(--radius) - 0.15rem);
  padding: 0.45rem 0.9rem;
  min-height: 2.25rem;
  font: 700 0.875rem/1.2 var(--font-sans);
  color: var(--foreground);
  background: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.15s ease, background 0.15s ease, color 0.15s ease;
  text-align: center;
  max-width: 100%;
}
.btn:hover { filter: brightness(0.97); text-decoration: none; }
.btn:active { filter: brightness(0.93); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-brand { background: var(--gradient-brand); color: var(--primary-foreground); }
.btn-gold { background: var(--gradient-gold); color: var(--gold-foreground); }
.btn-outline {
  background: var(--surface);
  color: var(--foreground);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.btn-outline:hover { box-shadow: inset 0 0 0 1px var(--foreground); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { min-height: 1.85rem; padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn-block { display: flex; width: 100%; }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }

/* ---------- Forms ---------- */

.field { display: grid; gap: 0.3rem; margin-bottom: 0.9rem; }
.field > label { font-weight: 700; font-size: 0.85rem; }
.field .hint { font-size: 0.78rem; color: var(--muted-foreground); }

.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 0.15rem);
  background: var(--surface);
  color: var(--foreground);
  font: 400 0.9rem/1.4 var(--font-sans);
  padding: 0.5rem 0.7rem;
  min-height: 2.4rem;
}
.textarea { min-height: 6rem; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: 2px solid var(--ring);
  outline-offset: 0;
  border-color: transparent;
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.field-error { font-size: 0.8rem; font-weight: 600; color: var(--danger); }

.checkbox { display: flex; gap: 0.55rem; align-items: flex-start; font-size: 0.875rem; }
.checkbox input { width: 1.05rem; height: 1.05rem; margin-top: 0.15rem; accent-color: var(--primary); }

.form-grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.form-grid .field-wide { grid-column: 1 / -1; }

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 0.4rem;
  margin: 0 0 1rem;
}
legend { font-weight: 800; font-family: var(--font-display); font-size: 0.9rem; padding-inline: 0.4rem; }

/* ---------- Tables ---------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow-card);
}
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th, .table td {
  text-align: left;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table thead th {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted-foreground);
  background: var(--muted);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--primary-soft); }
.table .num { text-align: right; white-space: nowrap; }
.table tfoot td {
  font-weight: 700;
  background: var(--muted);
  border-top: 2px solid var(--border-strong);
}
.table .row-link { font-weight: 700; }

/* ---------- Cards & stat tiles ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.1rem 1.25rem;
}
.card-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  margin: 0 0 0.75rem;
}
.card-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }

.stat { display: grid; gap: 0.1rem; }
.stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted-foreground);
}
.stat-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.01em;
}
.stat-note { font-size: 0.8rem; color: var(--muted-foreground); }
.stat-up { color: var(--ok); font-weight: 700; }
.stat-down { color: var(--danger); font-weight: 700; }

/* ---------- Badges & alerts ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  padding: 0.12rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--muted);
  color: var(--muted-foreground);
  white-space: nowrap;
}
.badge::before { content: ""; width: 0.42rem; height: 0.42rem; border-radius: 50%; background: currentColor; }
.badge-plain::before { display: none; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-gold { background: var(--gold-soft); color: oklch(0.5 0.11 80); }
.badge-brand { background: var(--primary-soft); color: var(--primary); }

.alert {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 0.7rem 0.9rem;
  font-size: 0.875rem;
  background: var(--muted);
}
.alert b { font-weight: 800; }
.alert-ok { background: var(--ok-soft); border-color: oklch(0.85 0.06 150); }
.alert-warn { background: var(--warn-soft); border-color: oklch(0.86 0.07 85); }
.alert-danger { background: var(--danger-soft); border-color: oklch(0.86 0.05 27); }
.alert-info { background: var(--info-soft); border-color: oklch(0.86 0.04 245); }

/* ---------- Login screen ---------- */

.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(50rem 30rem at 115% -15%, oklch(0.87 0.16 92 / 0.35), transparent 60%),
    radial-gradient(55rem 35rem at -20% 115%, oklch(0.56 0.235 28.5 / 0.16), transparent 55%),
    var(--ink);
}
.login-card {
  width: 100%;
  max-width: 24rem;
  background: var(--surface);
  border-radius: calc(var(--radius) + 0.3rem);
  box-shadow: var(--shadow-pop);
  padding: 2rem 1.9rem 1.6rem;
}
.login-logo { display: flex; justify-content: center; margin-bottom: 1rem; }
.login-logo img { width: 4.2rem; height: 4.2rem; }
.login-card h1 { font-size: 1.25rem; text-align: center; margin-bottom: 0.15rem; }
.login-sub { text-align: center; font-size: 0.85rem; color: var(--muted-foreground); margin-bottom: 1.4rem; }
.login-card .btn-block { margin-top: 0.4rem; }
.login-foot {
  margin-top: 1.4rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted-foreground);
}
.login-badge {
  display: block;
  text-align: center;
  margin-top: 1.1rem;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

/* ---------- Empty states ---------- */

.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted-foreground);
  font-size: 0.9rem;
}
.empty b { display: block; font-family: var(--font-display); font-size: 1rem; color: var(--foreground); margin-bottom: 0.25rem; }
