/* Hallmark · macrostructure: Workbench · genre: utilitarian · theme: custom-bench
 * pre-emit critique: P5 H4 E5 S4 R5 V4
 * All values come from tokens.css (gate 48). No inline hex below. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: clip;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-style: normal;
  margin: 0;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  min-width: 0;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono, .num { font-family: var(--font-mono); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.ico {
  width: 18px;
  height: 18px;
  flex: none;
  vertical-align: -3px;
}

/* ---------- layout shell ---------- */
.shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100dvh;
}

.main {
  padding: var(--s5) var(--s6);
  max-width: 1440px;
  width: 100%;
}

/* ---------- nav rail (N3 side-rail) ---------- */
.rail {
  background: var(--sidebar);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s4) var(--s3);
  position: sticky;
  top: 0;
  height: 100dvh;
}

.rail-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s2) var(--s2) var(--s4);
  color: var(--sidebar-ink);
}
.rail-brand:hover { text-decoration: none; }

.rail-wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.04em;
}
.rail-wordmark span { color: var(--accent); }

.rail-shop {
  font-size: 12px;
  color: var(--ink-3);
}

.rail-section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  padding: var(--s4) var(--s2) var(--s1);
}

.rail-link {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 8px var(--s2);
  border-radius: var(--r-ctl);
  color: var(--sidebar-ink);
  font-weight: 500;
  transition: background var(--t-fast);
}
.rail-link:hover {
  background: var(--sidebar-line);
  text-decoration: none;
}
.rail-link.is-active {
  background: var(--accent);
  color: var(--accent-ink);
}
.rail-link:focus-visible, .rail-logout:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.rail-foot {
  margin-top: auto;
  border-top: 1px solid var(--sidebar-line);
  padding-top: var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.rail-user-name { display: block; font-weight: 600; font-size: 13px; }
.rail-user-role {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}
.rail-logout {
  display: flex;
  align-items: center;
  gap: var(--s2);
  background: none;
  border: 0;
  color: var(--sidebar-ink);
  font: inherit;
  cursor: pointer;
  padding: 6px var(--s2);
  border-radius: var(--r-ctl);
  width: 100%;
}
.rail-logout:hover { background: var(--sidebar-line); }

/* ---------- page headers ---------- */
.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s5);
  flex-wrap: wrap;
}
.page-title { font-size: 26px; font-weight: 700; }
.page-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.page-narrow { max-width: 640px; margin: 0 auto; padding-top: var(--s6); }
.lede { color: var(--ink-2); margin: var(--s2) 0 var(--s4); }

/* ---------- buttons (8 states) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  padding: 10px 16px;
  border-radius: var(--r-ctl);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled, .btn.is-disabled { opacity: 0.5; cursor: not-allowed; }
.btn[data-state="loading"] { opacity: 0.7; pointer-events: none; }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); color: var(--accent-ink); }

.btn-secondary {
  background: var(--paper-2);
  color: var(--ink);
  border-color: var(--line);
}
.btn-secondary:hover { border-color: var(--ink); }

.btn-teal { background: var(--teal); color: var(--accent-ink); }
.btn-teal:hover { filter: brightness(1.12); }

.btn-danger { background: var(--bad); color: var(--accent-ink); }

.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 10px; font-size: 13px; }

/* ---------- panels & tiles ---------- */
.panel {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: var(--s4);
}
.panel + .panel { margin-top: var(--s4); }
.panel-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: var(--s3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s3);
  margin-bottom: var(--s5);
}
.tile {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: var(--s3) var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}
.tile-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-2);
}
.tile-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.tile-value.is-bad { color: var(--bad); }
.tile-value.is-warn { color: var(--warn); }
.tile-value.is-ok { color: var(--ok); }
.tile-sub { font-size: 12px; color: var(--ink-2); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--paper-2); }
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  font-weight: 600;
  padding: 10px var(--s3);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
}
.table th.num, .table td.num { text-align: right; }
.table td {
  padding: 9px var(--s3);
  border-bottom: 1px solid var(--paper-3);
  vertical-align: middle;
}
.table tbody tr:nth-child(even) { background: var(--paper-3); }
.table tbody tr:hover { background: var(--accent-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.table a { color: var(--ink); font-weight: 500; }
.table td.mono, .table th.mono { white-space: nowrap; }

/* ---------- status chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}
.chip-open { background: var(--paper-3); color: var(--ink); }
.chip-waiting_parts, .chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-ready_pickup, .chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-quote_sent { background: var(--accent-soft); color: var(--accent); }
.chip-closed { background: var(--paper-3); color: var(--ink-2); }
.chip-bad { background: var(--bad-soft); color: var(--bad); }
.chip-teal { background: var(--teal-soft); color: var(--teal); }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: var(--s3); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s3); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}
.field input, .field select, .field textarea {
  font: inherit;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  padding: 9px 10px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.field input::placeholder, .field textarea::placeholder { color: var(--ink-3); }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.field .field-error { color: var(--bad); font-size: 12.5px; }
.field .field-help { color: var(--ink-2); font-size: 12px; }
.field input[aria-invalid="true"] { border-color: var(--bad); }

/* ---------- flash ---------- */
.flash {
  border-radius: var(--r-ctl);
  padding: 10px var(--s3);
  margin-bottom: var(--s4);
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--paper-2);
}
.flash-ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.flash-error { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }

/* ---------- kanban ---------- */
.kanban {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 280px;
  gap: var(--s3);
  overflow-x: auto;
  padding-bottom: var(--s3);
  align-items: start;
}
.kanban-col {
  background: var(--paper-3);
  border-radius: var(--r-card);
  padding: var(--s2);
  min-width: 0;
}
.kanban-col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--s2);
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 13.5px;
}
.kanban-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
}
.kanban-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  padding: var(--s3);
  margin-bottom: var(--s2);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color var(--t-fast);
}
.kanban-card:hover { border-color: var(--ink-3); }
.kanban-card.is-overdue { border-left: 3px solid var(--bad); }
.kanban-card-title { font-weight: 600; }
.kanban-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-2);
}

/* ---------- auth page ---------- */
.auth-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: var(--s4);
}
.auth-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: var(--s6);
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}
.auth-brand { display: flex; flex-direction: column; gap: 4px; }
.auth-brand .rail-wordmark { color: var(--ink); font-size: 24px; }
.auth-sub { color: var(--ink-2); font-size: 13px; }

/* ---------- 2FA ---------- */
.twofa-panel { display: flex; flex-direction: column; gap: var(--s4); }
.twofa-qr { border: 1px solid var(--line); border-radius: var(--r-ctl); }
.twofa-manual { display: flex; flex-direction: column; gap: 4px; }
.twofa-manual code {
  background: var(--paper-3);
  padding: 6px 10px;
  border-radius: var(--r-ctl);
  font-size: 13px;
  user-select: all;
}

/* ---------- error page ---------- */
.error-page { text-align: left; }
.error-code {
  font-family: var(--font-display);
  font-size: 64px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

/* ---------- misc ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--s4); }
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.hr { border: 0; border-top: 1px solid var(--line); margin: var(--s4) 0; }
.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--r-card);
  padding: var(--s6);
  text-align: center;
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  align-items: center;
}
.freshness-strip {
  display: flex;
  gap: var(--s4);
  font-size: 12px;
  color: var(--ink-2);
  border-top: 1px solid var(--line);
  padding-top: var(--s2);
  margin-top: var(--s5);
  flex-wrap: wrap;
}
.badge-count {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  font-family: var(--font-mono);
}

/* ---------- public customer pages (calm variant, density ~4) ---------- */
.public-page {
  display: grid;
  place-items: start center;
  min-height: 100dvh;
  padding: var(--s6) var(--s4);
}
.public-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: var(--s6);
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: var(--s3);
  padding: var(--s2) 0;
  border-bottom: 1px solid var(--paper-3);
}
.timeline li:last-child { border-bottom: 0; }
.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--r-pill);
  background: var(--line);
  margin-top: 5px;
}
.timeline li.is-current .timeline-dot { background: var(--accent); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .shell { grid-template-columns: 64px minmax(0, 1fr); }
  .rail { padding: var(--s3) var(--s2); }
  .rail-shop, .rail-section, .rail-user, .rail-brand .rail-wordmark, .rail-label { display: none; }
  .rail-link { justify-content: center; padding: 10px; }
  .rail-logout { justify-content: center; }
  .main { padding: var(--s4); }
}
@media (max-width: 640px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: static;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    align-items: center;
  }
  .rail-foot { display: none; }
  .tile-value { font-size: 24px; }
}
