/* ============================================================
   Lakeside Label BOS — Design System (BOS v2.1 port, AA-corrected)
   Tokens: brand-dark #1a1f2e · brand-mid #2c3347 · accent #4a7c6f
           accent-light #6aab9b · gold-text-on-light #8a6d33
           gold-light-on-dark #e8c98a · muted #6b7180
           page #f8f7f4 · card #ffffff · border #e4e0d8
   Display: Georgia · Sans: Inter/system-ui
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --brand-dark: #1a1f2e;
  --brand-mid: #2c3347;
  --accent: #4a7c6f;
  --accent-light: #6aab9b;
  --gold-text: #7a5c24;          /* gold text on light (5.27:1 on the gold tint) */          /* gold used as text on light surfaces */
  --gold-light: #e8c98a;         /* gold used on dark surfaces */
  --muted: #6b7180;
  --page: #f8f7f4;
  --card: #ffffff;
  --border: #e4e0d8;
  --text: #1a1f2e;
  --text-inverse: #eef1f7;
  --nav-text: #c9cfdc;           /* sidebar text on the spine (8.9:1) */
  --nav-text-secondary: #9aa3b5; /* sidebar secondary (6.47:1 on dark) */
  --danger: #a33a34;             /* AA-safe destructive on light */
  --danger-bg: #fbecea;
  --success: #37704f;
  --success-bg: #e9f3ee;
  --warn-text: #b45309;          /* warn text on light (5.02:1 white, 4.58:1 tint) */
  --warning: #c2620a;            /* warn LINES/borders/strokes (3.8:1 on cream, 4.16:1 on white) — a brightness step above gold, not a hue twin */
  --warn-bg: #fdf3e7;            /* cream tint — warn status always pairs word + tint */
  --warn-border: #ecd9ae;
  --gold-bg: #f3ecdc;            /* gold tint — freshness badge, error-code chip */
  --gold-border: #e4d9bc;
  --danger-border: #f0d5d1;
  --chip-bg: #eef0f4;
  --data-table-hover: #faf9f5;   /* row hover (data tables) + section-table zebra */
  --sep: #c2beb4;
  --disabled-bg: #f0efea;
  --muted-strong: #5d6370;      /* muted on cream tints (5.5:1 on --warn-bg) */

  --sidebar-w: 255px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(26, 31, 46, 0.08), 0 6px 20px rgba(26, 31, 46, 0.07);
  --shadow-lg: 0 8px 32px rgba(26, 31, 46, 0.18);

  --font-display: Georgia, "Times New Roman", serif;
  --font-sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --focus-ring: 2px solid var(--accent);
}

/* Instrument face: money, order IDs, SKUs, IOSS/VAT, timestamps.
   System mono is tabular by definition — columns never shimmer. */
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---------- Reset & base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  /* Figures hold width in every Inter tier; Georgia has no tabular figures
     and ignores this, so display counts stay proportional by design. */
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.2;
  margin: 0 0 0.5em;
  color: var(--brand-dark);
}

p {
  margin: 0 0 1em;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--brand-mid);
}

img, svg {
  max-width: 100%;
  height: auto;
}

button {
  font: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

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

/* ---------- Skip link ---------- */
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 10px 16px;
  background: var(--brand-dark);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform 0.15s ease;
}

.skip-link:focus-visible {
  transform: translateY(0);
  outline-color: var(--gold-light);
}

/* ---------- App shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.main-col {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--sidebar-w);
  background: var(--brand-dark);
  color: var(--nav-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar-logo {
  padding: 22px 20px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
}

.sublabel {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-light);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 12px 20px;
}

.nav-group {
  margin-bottom: 6px;
}

.nav-group-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--nav-text-secondary);
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  margin: 2px 0;
  border-radius: var(--radius-sm);
  color: var(--nav-text);
  text-decoration: none;
  font-size: 14px;
  min-height: 36px;
  transition: background-color 130ms ease-out, color 130ms ease-out;
}

.nav-item:hover {
  background: var(--brand-mid);
  color: #fff;
}

.sidebar a:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 2px;
}

.nav-item.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg,
.room-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 14px 20px 18px;
  font-size: 11px;
  color: #8d95a8;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  line-height: 1.6;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 32px;
  background: rgba(248, 247, 244, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}

.breadcrumb {
  font-size: 13px;
  color: var(--muted);
  min-width: 0;
}

.crumb-sep {
  margin: 0 8px;
  color: #c2beb4;
}

.crumb-current {
  color: var(--brand-dark);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

/* Honest freshness — a dated badge, never a pulsing dot */
.freshness-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.px;
  font-weight: 600;
  color: var(--gold-text);
  background: var(--gold-bg);
  border: 1px solid #e4d9bc;
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
}

.logout-form {
  margin: 0;
}

/* ---------- Content ---------- */
.content {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 32px 80px;
}

.section-block {
  margin-bottom: 28px;
}

.sec-header {
  margin-bottom: 22px;
}

.sec-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-text);
  margin-bottom: 6px;
}

.sec-title {
  font-size: 24px; /* h1 tier 24/30 */
  line-height: 1.25;
  margin-bottom: 6px;
}

.sec-subtitle {
  font-size: 14px;
  color: var(--muted);
  max-width: 64ch;
  margin: 0;
}

.section-head {
  margin-bottom: 14px;
}

.section-title {
  font-size: 17px; /* h2/h3 card-title tier */
  line-height: 1.3;
  margin-bottom: 2px;
}

.section-sub {
  font-size: 13.px;
  color: var(--muted);
  margin: 0;
}

.empty-note {
  padding: 14px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13.px;
  background: var(--card);
}

/* ---------- Stat grid & stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card.stat-good {
  border-top: 3px solid var(--success);
}

.stat-card.stat-warn {
  border-top: 3px solid var(--warning);
}

.stat-card.stat-danger {
  border-top: 3px solid var(--danger);
}

.stat-card.stat-muted {
  border-top: 3px solid var(--border);
  background: #fbfaf7;
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 32px; /* display tier, ledger voice; proportional by design */
  font-weight: 400;
  line-height: 1.1;
  color: var(--brand-dark);
}

.stat-detail {
  font-size: 13px;
  color: var(--muted);
}

.stat-link {
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
}

/* ---------- Needs-you strip (DESIGN.md: phone first viewport, order 2) ----------
   Warn/danger stats only, hidden when empty, max 3 visible + overflow chip.
   Status rides word + tint + 3px rail — never hue alone. */
.needs-you-strip {
  margin-bottom: 20px;
}

.needs-you-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.needs-you-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--warn-text);
}

.needs-you-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.needs-mini {
  flex: 1 1 0;
  min-width: 0;
  display: block;
  border: 1px solid var(--warn-border);
  border-top: 3px solid var(--warning);
  background: var(--warn-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-decoration: none;
  color: var(--text);
}

a.needs-mini:hover {
  border-color: var(--warn-text);
}

a.needs-mini.danger:hover {
  border-color: var(--danger);
}

.needs-mini.danger {
  border-color: #f0d5d1;
  border-top-color: var(--danger);
  background: var(--danger-bg);
}

.needs-mini .l {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-strong);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.needs-mini .v {
  display: block;
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.15;
  color: var(--warn-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.needs-mini.danger .v {
  color: var(--danger);
}

.needs-more {
  flex: 0 0 auto;
  align-self: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--warn-text);
  border: 1px solid var(--warn-border);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 12px;
  text-decoration: none;
}

a.needs-more:hover {
  border-color: var(--warn-text);
}

/* ---------- Room cards ---------- */
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

.room-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

a.room-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.room-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.room-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.room-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 4px;
}

.room-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

/* ---------- Cards & chips ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-mid);
  background: #eef0f4;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

.chip-success { color: var(--success); background: var(--success-bg); border-color: #cfe5d9; }
.chip-warn    { color: var(--warn-text); background: var(--warn-bg); border-color: var(--warn-border); }
.chip-danger  { color: var(--danger); background: var(--danger-bg); border-color: #f0d5d1; }

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.pill {
  font-size: 12px;
  color: var(--muted);
  background: #f0efea;
  border-radius: 999px;
  padding: 3px 10px;
}

/* ---------- Grid helpers ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f5f3ee;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: var(--data-table-hover);
}

/* Roles table — becomes stacked cards below 640px (see media query) */
.roles-table td[data-label]::before {
  content: attr(data-label);
  display: none;
}

/* ---------- Forms ---------- */
.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-dark);
}

.input,
textarea.input,
select.input {
  font: inherit;
  font-size: 16px; /* form tier — below 16px iOS zooms into the field */
  color: var(--text);
  background: var(--card);
  border: 1px solid #c9c4b8;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-height: 44px;
  width: 100%;
}

textarea.input {
  min-height: 88px;
  resize: vertical;
  line-height: 1.5;
}

.input::placeholder {
  color: #9a948a;
}

.input:focus-visible {
  border-color: var(--accent);
  outline: var(--focus-ring);
  outline-offset: 0;
}

.input:disabled {
  background: #f0efea;
  color: var(--muted);
  cursor: not-allowed;
}

.form-error {
  font-size: 14px;
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #f0d5d1;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand-dark);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-mid);
  color: #fff;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover:not(:disabled) {
  background: #3e6a5f;
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--brand-mid);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: #eef0f4;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #8c312c;
  color: #fff;
}

.btn-sm {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

/* ---------- Modal / bottom sheet ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 31, 46, 0.55);
  padding: 20px;
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 460px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
}

.modal-title {
  font-size: 17px;
  margin-bottom: 6px;
}

.modal-message {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* ---------- Pepper box ---------- */
.pepper-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pepper-input {
  min-height: 64px;
}

.pepper-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pepper-hint {
  font-size: 12.px;
  color: var(--muted);
}

.pepper-hint.htmx-request::after {
  content: " · thinking…";
}

.pepper-answer {
  margin-top: 12px;
}

/* ---------- Auth (login) & error pages ---------- */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page);
  padding: 24px;
}

.auth-wrap {
  width: 100%;
  max-width: 400px;
}

.auth-card,
.error-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}

.auth-brand {
  margin-bottom: 22px;
  text-align: center;
}

.auth-brand .sublabel {
  color: var(--gold-text);
}

.auth-card .form {
  gap: 14px;
}

/* Error envelope */
.error-wrap {
  width: 100%;
  max-width: 560px;
}

.error-card {
  padding: 28px;
}

.error-code {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--gold-text);
  background: var(--gold-bg);
  border: 1px solid #e4d9bc;
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  margin-bottom: 12px;
}

.error-title {
  font-size: 24px;
  margin-bottom: 18px;
}

.error-envelope {
  margin: 0 0 20px;
  border-top: 1px solid var(--border);
}

.error-part {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.error-part dt {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 2px;
}

.error-part dd {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.error-actions {
  display: flex;
  gap: 10px;
}

/* ---------- Offline page ---------- */
.offline-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--page);
}

.offline-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  text-align: center;
}

.offline-card .brand {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  color: var(--brand-dark);
}

.offline-card .sublabel {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-text);
  margin-top: 2px;
}

.offline-card h1 {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 0 0 8px;
}

.offline-card p {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 20px;
}

.offline-pulse {
  width: 34px;
  height: 34px;
  margin: 20px auto 14px;
  border-radius: 50%;
  background: var(--accent);
  position: relative;
}

.offline-pulse::before,
.offline-pulse::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--accent);
  inset: -8px;
  opacity: 0;
  animation: offline-pulse 1.8s ease-out infinite;
}

.offline-pulse::after {
  animation-delay: 0.9s;
}

@keyframes offline-pulse {
  0% { transform: scale(0.7); opacity: 0.8; }
  100% { transform: scale(1.3); opacity: 0; }
}

/* ---------- Bottom nav (mobile tab bar) ---------- */
.bottom-nav {
  display: none;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Responsive: phone-first reflow ---------- */
@media (max-width: 640px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  body {
    font-size: 14px; /* min body size on phone */
  }

  body.bos-body .sidebar {
    display: none;
  }

  body.bos-body .main-col {
    margin-left: 0;
  }

  body.bos-body .topbar {
    padding: 10px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  body.bos-body .content {
    padding: 20px 16px 96px; /* clearance for the bottom tab bar */
  }

  body.bos-body .sec-title {
    font-size: 24px; /* h1 tier, phone */
  }

  /* Bottom tab bar — scrollable, all 15 sections reachable, no hamburger */
  body.bos-body .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--brand-dark);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .bottom-nav::-webkit-scrollbar {
    display: none;
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 0 0 auto;
    min-width: 72px;
    min-height: 56px; /* ≥44px touch target */
    padding: 8px 10px;
    color: var(--nav-text);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
  }

  .bottom-nav-item .nav-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
  }

  .bottom-nav-item.active {
    color: var(--gold-light);
  }

  .bottom-nav-item.active::after {
    content: "";
    display: block;
    width: 24px;
    height: 3px;
    border-radius: 2px;
    background: var(--accent-light);
  }

  .bottom-nav-label {
    max-width: 68px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* 44px touch targets for interactive elements (DESIGN.md touch floor) */
  .btn,
  .btn-sm,
  .stat-link,
  .nav-item,
  .bottom-nav-item,
  .needs-more,
  a.chip,
  .lang-link,
  .action-link {
    min-height: 44px;
  }

  .btn {
    padding: 10px 16px;
  }

  .freshness-badge {
    font-size: 12px;
  }

  /* All grids collapse to one column */
  .stat-grid,
  .room-grid,
  .grid-2,
  .grid-3,
  .pack-grid {
    grid-template-columns: 1fr;
  }

  /* Roles table → stacked cards */
  .roles-table,
  .roles-table thead,
  .roles-table tbody,
  .roles-table tr,
  .roles-table td {
    display: block;
    width: 100%;
  }

  .roles-table thead {
    display: none;
  }

  .roles-table tbody tr {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    padding: 6px 4px;
  }

  .roles-table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    border: 0;
    padding: 8px 12px;
    font-size: 14px;
  }

  .roles-table td[data-label]::before {
    content: attr(data-label);
    display: inline;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    flex-shrink: 0;
  }

  .table-wrap {
    overflow-x: visible;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  /* Modal → bottom sheet */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    max-width: none;
    border-radius: 16px 16px 0 0;
    max-height: 88vh;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .btn {
    width: 100%;
  }

  .error-part {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

/* ---------- Print ---------- */
@media print {
  .sidebar,
  .topbar,
  .bottom-nav,
  .pepper-section,
  .logout-form,
  .skip-link {
    display: none !important;
  }

  .main-col {
    margin-left: 0;
  }

  .content {
    padding: 0;
    max-width: none;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 12px;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  .card,
  .stat-card,
  .room-card,
  .table-wrap {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  .freshness-badge {
    display: inline-flex;
  }
}


/* ============================================================
   Phase B — entity CRUD + section content views
   (entity.templ / section.templ). Reuses the BOS tokens only.
   ============================================================ */

/* Title row with an inline action button (New / Edit content) */
.sec-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.sec-title-row .btn {
  flex-shrink: 0;
}

/* Entity list table. .table-wrap supplies the card chrome; these rules
   refine the cell layout and the mobile data-label treatment. */
.entity-table td[data-label]::before {
  content: attr(data-label);
  display: none;
}

.entity-table .data-table td {
  vertical-align: middle;
}

.entity-table th.actions-col,
.entity-table td.actions-col {
  text-align: right;
  white-space: nowrap;
}

.entity-table .empty-row td {
  padding: 16px;
}

.action-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.action-link:hover {
  text-decoration: underline;
}

.action-link.action-danger {
  color: var(--danger);
}

.action-sep {
  color: var(--border);
  margin: 0 7px;
  user-select: none;
}

/* Entity form (create / edit) */
.entity-form {
  max-width: 640px;
}

.field-error {
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
  margin: 0;
}

.input.input-error {
  border-color: var(--danger);
  background: #fff8f7;
}

.req-mark {
  color: var(--warn-text);
  margin-left: 3px;
}

.entity-form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* Section content (markdown-rendered, handler-sanitized HTML) */
.section-body {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  overflow-x: auto;
}

.section-body > :first-child {
  margin-top: 0;
}

.section-body > :last-child {
  margin-bottom: 0;
}

.section-body h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
  margin: 26px 0 10px;
}

.section-body h3 {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  margin: 22px 0 8px;
}

.section-body h4 {
  font-size: 14px;
  font-weight: 700;
  margin: 18px 0 6px;
}

.section-body p {
  margin: 0 0 14px;
}

.section-body ul,
.section-body ol {
  margin: 0 0 14px;
  padding-left: 24px;
}

.section-body ol {
  list-style: none;
  padding-left: 0;
  counter-reset: bos-step;
}

.section-body ol li {
  counter-increment: bos-step;
  position: relative;
  padding-left: 30px;
  margin: 6px 0;
}

.section-body ol li::before {
  content: counter(bos-step);
  position: absolute;
  left: 0;
  top: 1px;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--gold-text);
}

.section-body li {
  margin: 4px 0;
}

.section-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.section-body a:hover {
  color: var(--brand-mid);
}

.section-body blockquote {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-left: 3px solid var(--gold-text);
  background: var(--gold-bg);
  color: var(--muted-strong);
}

.section-body blockquote strong {
  color: var(--gold-text);
  font-weight: 600;
}

.section-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: #f0efea;
  border-radius: 4px;
  padding: 2px 5px;
}

.section-body pre {
  background: var(--brand-dark);
  color: var(--text-inverse);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0 0 14px;
}

.section-body pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.section-body hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.section-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 14px;
  font-size: 13px; /* the data-table tier (DESIGN.md) */
}

.section-body th,
.section-body td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.section-body th {
  font-weight: 700;
}

/* Zebra + hover stay desktop-only: stacked mobile cards keep a flat field. */
@media (min-width: 641px) {
  .section-body tbody tr:nth-child(even) {
    background: var(--data-table-hover);
  }
}

.section-body tbody tr:hover {
  background: var(--chip-bg);
}

/* Markdown tables carry no classes, so the stacked treatment scopes by
   column count: 2-column tables use the first cell as its own label;
   3- and 4-column tables (metrics KPI grid, roles table) label every
   following cell with a literal from the CSS. */
@media (max-width: 640px) {
  .section-body table {
    font-size: 13px;
  }
  .section-body thead {
    display: none;
  }
  .section-body tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 0;
    margin-bottom: 10px;
  }
  .section-body td {
    display: block;
    border: 0;
    padding: 5px 12px;
  }
  .section-body td:first-child {
    font-weight: 600;
  }
  .section-body table:has(th:nth-child(3)) td:nth-child(2)::before {
    content: "Target — ";
  }
  .section-body table:has(th:nth-child(3)) td:nth-child(3)::before {
    content: "Benchmark — ";
  }
  .section-body table:has(th:nth-child(4)) td:nth-child(2)::before {
    content: "Task — ";
  }
  .section-body table:has(th:nth-child(4)) td:nth-child(3)::before {
    content: "Owner — ";
  }
  .section-body table:has(th:nth-child(4)) td:nth-child(4)::before {
    content: "Frequency — ";
  }
}

.section-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* Entity tables stack to cards below 640px (mirrors the roles-table
   treatment; the data-label fills in as the row label). */
@media (max-width: 640px) {
  .entity-table,
  .entity-table thead,
  .entity-table tbody,
  .entity-table tr,
  .entity-table td {
    display: block;
    width: 100%;
  }

  .entity-table thead {
    display: none;
  }

  .entity-table tbody tr {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    padding: 6px 4px;
  }

  .entity-table tbody tr:hover {
    background: var(--card);
  }

  .entity-table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    border: 0;
    padding: 8px 12px;
    font-size: 14px;
  }

  .entity-table td[data-label]::before {
    content: attr(data-label);
    display: inline;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    flex-shrink: 0;
  }

  .entity-table .empty-row td {
    display: block;
    padding: 16px;
  }

  .entity-form-actions .btn {
    flex: 1;
    min-height: 48px;
  }
}

/* ---------- Phase C: Pepper ask box (SSE) ---------- */
.ask-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ask-input {
  min-height: 64px;
}

.ask-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.ask-hint {
  font-size: 12.px;
  color: var(--muted);
}

/* Answer panel: the SSE container. Appears below the ask box; hidden until
 * a stream starts (app.js toggles [hidden]). */
.answer-panel {
  margin-top: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.answer-panel[hidden] {
  display: none;
}

/* Thinking state: pulsing dot + label; one state at a time. */
.thinking-state {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}

.thinking-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: thinking-pulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes thinking-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1.15); }
}

/* Answer text: escaped markdown-as-text, pre-wrapped so structure survives
 * without rendering raw HTML. */
.answer-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Citation chips: "{title} · {date}" per cited document. */
.answer-citations {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.answer-citations-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.citation-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.citation-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-mid);
  background: #eef0f4;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Refusal note: "no citation → no answer" onboarding grammar (AI-404-NO-HIT,
 * AI-403-RESTRICTED). Distinct warn tone from the error state. */
.refusal-note {
  font-size: 14px;
  line-height: 1.55;
  color: var(--warn-text);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

/* Error state: "AI-<code>" + message (DX error envelope). */
.answer-error {
  font-size: 14px;
  line-height: 1.55;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #f0d5d1;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.answer-error-code {
  font-weight: 700;
}

/* ---------- Phase C: search page ---------- */
.search-form {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.search-input {
  flex: 1;
  min-width: 0;
}

.search-note {
  font-size: 12.px;
  color: var(--muted);
  margin: 10px 0 0;
}

.search-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.result-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--brand-dark);
  margin: 0;
  text-decoration: none;
}

a.result-title:hover {
  color: var(--accent);
  text-decoration: underline;
}

.result-snippet {
  font-size: 13.px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: auto;
  padding-top: 4px;
}

.result-meta-item {
  font-size: 12px;
  color: var(--muted);
}

.result-meta-item strong {
  color: var(--brand-mid);
  font-weight: 600;
}

/* ---------- Phase C: settings (AI providers) ---------- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.settings-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.settings-card-title {
  font-size: 17px;
  margin: 0;
}

.settings-dl {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 13.px;
}

.settings-row dt {
  color: var(--muted);
  flex-shrink: 0;
}

.settings-row dd {
  margin: 0;
  text-align: right;
  color: var(--text);
  word-break: break-all;
}

.settings-card-actions {
  margin-top: 2px;
}

.test-result {
  font-size: 13px;
  min-height: 18px;
}

.test-ok {
  color: var(--success);
  font-weight: 600;
}

.test-fail {
  color: var(--danger);
  font-weight: 600;
}

/* ---------- Phase C: upload form ---------- */
.field-hint {
  font-size: 12.px;
  color: var(--muted);
  margin: 4px 0 0;
}

.radio-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.45;
  padding: 6px 0;
}

.radio-row input[type="radio"] {
  margin-top: 3px;
  flex-shrink: 0;
}

.radio-row input[type="radio"]:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

/* Confidentiality warning: visible only when AI-restricted is selected
 * (CSS :has — no JS required). */
.confidentiality-warning {
  display: none;
  font-size: 13.px;
  line-height: 1.5;
  color: var(--warn-text);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 4px 0 0;
}

.upload-form:has(input[name="confidentiality"][value="ai_restricted"]:checked) .confidentiality-warning {
  display: block;
}

/* ---------- Phase C: reduced motion & responsive ---------- */
@media (prefers-reduced-motion: reduce) {
  .thinking-dot {
    animation: none;
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .search-form {
    flex-direction: column;
  }

  .search-form .btn {
    width: 100%;
  }

  .settings-row {
    flex-direction: column;
    gap: 2px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
  }

  .settings-row dd {
    text-align: left;
  }

  .radio-row {
    min-height: 44px;
    align-items: center;
  }
}

@media print {
  .ask-box,
  .answer-panel {
    display: none !important;
  }
}

/* ============================================================
   Phase D: generation (job detail), launch packs, export
   Reuses the design tokens above; job/pack status chips reuse
   .chip + .chip-success/.chip-warn/.chip-danger modifiers.
   ============================================================ */

/* ---------- Language switcher (layout header) ---------- */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.px;
  white-space: nowrap;
}

.lang-link {
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

.lang-link:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.lang-link.active {
  color: var(--brand-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.lang-sep {
  color: #c2beb4;
}

/* ---------- Phase D: generation job detail ---------- */
.job-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.job-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.job-kind {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.job-stage-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stage-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.stage-item .stage-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d8d4ca;
  border: 1px solid var(--border);
}

.stage-item.done {
  color: var(--success);
}

.stage-item.done .stage-dot {
  background: var(--success);
  border-color: var(--success);
}

.stage-item.active {
  color: var(--brand-dark);
}

.stage-item.active .stage-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74, 124, 111, 0.18);
}

.stage-sep {
  color: #c2beb4;
}

.job-progress {
  height: 8px;
  background: #eceae3;
  border-radius: 999px;
  overflow: hidden;
}

.job-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.job-error-label {
  font-weight: 700;
}

.job-result {
  display: flex;
}

.job-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- Phase D: launch packs ---------- */
.pack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.pack-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pack-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pack-card-title {
  font-size: 17px;
  margin: 0;
}

.pack-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12.px;
  color: var(--muted);
}

.pack-meta-blocked {
  color: var(--danger);
  font-weight: 600;
}

.pack-meta-verify {
  color: var(--warn-text);
  font-weight: 600;
}

.pack-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.pack-card-updated {
  font-size: 12px;
  color: var(--muted);
}

.pack-card-link {
  font-size: 13px;
  font-weight: 600;
}

.pack-snapshot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--warn-text);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 18px;
}

.pack-blocked-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #f0d5d1;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 18px;
}

.pack-phase {
  margin: 22px 0 10px;
}

.pack-phase-title {
  font-size: 16px;
  margin: 0 0 8px;
  color: var(--brand-dark);
}

.pack-phase-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-text);
  margin-bottom: 2px;
}

.pack-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pack-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.pack-step.blocked {
  border-color: #f0d5d1;
  background: #fffafa;
}

.pack-step-no {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #eef0f4;
  color: var(--brand-mid);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pack-step-body {
  flex: 1;
  min-width: 0;
}

.pack-step-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pack-step-title {
  font-weight: 600;
  font-size: 14px;
}

.pack-step-detail {
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 0;
}

.pack-step-flags {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.verify-flag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warn-text);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 6px;
  padding: 2px 8px;
}

.verify-flag.blocked {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #f0d5d1;
}

.pack-approve {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.pack-approve-hint {
  font-size: 12.px;
  color: var(--muted);
}

/* ---------- Phase D: export panel ---------- */
.export-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 720px;
}

.export-explainer p {
  font-size: 14px;
  color: var(--muted);
}

.export-admin-note {
  font-size: 12.px;
  font-weight: 600;
  color: var(--gold-text);
}

.export-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.export-status {
  min-height: 20px;
  font-size: 13px;
}

@media (max-width: 640px) {
  .job-card,
  .export-panel {
    padding: 16px;
  }

  .pack-step-top {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
}

/* ============================================================
   Phase E: supervised harness (plan §4.6 / §5.1)
   Approval inbox · verification queue · compliance deadlines ·
   Monday brief. Reuses the BOS tokens (--card, --border, --shadow,
   --danger, --success, --gold-text, --muted, --accent) and the
   .chip / .btn / .data-table / .form primitives above.
   ============================================================ */

/* ---------- Top-level alert banner (error / success) ---------- */
.page-alert {
  font-size: 14px;
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #f0d5d1;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 22px;
}

.page-alert.success {
  color: var(--success);
  background: var(--success-bg);
  border-color: #cfe5d9;
}

/* ---------- Approval inbox ---------- */
.approval-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.approval-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.approval-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.approval-card-title {
  font-size: 17px;
  margin: 0;
}

.approval-freshness {
  font-size: 12.px;
  color: var(--muted);
}

.approval-preview {
  font-size: 14px;
  color: var(--text);
  border-left: 3px solid var(--border);
  padding-left: 12px;
}

.approval-preview p:last-child {
  margin-bottom: 0;
}

.approval-evidence .card-label {
  margin-bottom: 6px;
}

.evidence-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.evidence-line {
  font-size: 13px;
  color: var(--brand-mid);
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.evidence-title {
  font-weight: 600;
}

.evidence-date {
  color: var(--muted);
}

.evidence-sep {
  color: var(--muted);
}

.approval-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--muted);
}

.approval-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.approval-card.approval-handled {
  background: #fbfaf7;
}

.approval-reason {
  font-size: 13.px;
  color: var(--brand-mid);
  margin: 0;
}

/* ---------- Verification queue ---------- */
.verify-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.verify-doc {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.verify-doc-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  min-height: 44px; /* touch target */
}

.verify-check {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.verify-doc-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.verify-doc-title {
  font-weight: 600;
  font-size: 14.px;
}

.verify-doc-meta {
  font-size: 12.px;
  color: var(--muted);
}

.meta-sep {
  margin: 0 4px;
  color: var(--border);
}

.verify-batch-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.verify-batch-bar {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.verify-reason-field {
  flex: 1;
  min-width: 240px;
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 0;
}

.verify-result {
  margin-top: 14px;
  min-height: 0;
}

/* ---------- Compliance deadlines ---------- */
.deadline-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.deadline-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.deadline-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.deadline-row-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-dark);
}

.deadline-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin: 0;
}

.deadline-meta-item {
  display: flex;
  gap: 6px;
  align-items: baseline;
  font-size: 13px;
}

.deadline-meta-item dt {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.deadline-meta-item dd {
  margin: 0;
  color: var(--brand-mid);
}

.deadline-meta-item dd.deadline-next-due {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--warn-text);
}

.deadline-row-notes {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.deadline-row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.deadline-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.deadline-form-actions {
  display: flex;
  gap: 10px;
}

/* ---------- Monday brief ---------- */
.brief-heartbeat {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--warn-text);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
}

.brief-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

a.chip {
  text-decoration: none;
}

a.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.brief-body {
  margin-bottom: 18px;
}

.brief-section {
  margin: 0 0 18px;
}

.brief-section-title {
  font-size: 16px;
  margin: 0 0 8px;
  color: var(--brand-dark);
}

.brief-sections {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
  color: var(--brand-mid);
}

.brief-sections li {
  margin-bottom: 4px;
}

.weekly-refresh {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.weekly-refresh-result {
  width: 100%;
  min-height: 0;
}

/* ---------- Phase E phone-first reflow ---------- */
@media (max-width: 640px) {
  .approval-actions {
    flex-direction: column;
  }

  .approval-actions .btn {
    width: 100%;
  }

  .verify-batch-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .deadline-form .grid-2 {
    grid-template-columns: 1fr;
  }

  .deadline-row-meta {
    flex-direction: column;
    gap: 6px;
  }
}

/* ---------- Pepper chat drawer (plan 2.5/2.6 — tokens only) ---------- */
.chat-trigger {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 110; /* above the bottom nav (100) and the topbar (50) */
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  background: var(--brand-dark);
  color: var(--nav-text);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease-out, color 150ms ease-out;
}

.chat-trigger .nav-icon {
  color: var(--gold-light);
}

.chat-trigger:hover {
  background: var(--brand-mid);
  color: #fff;
}

.chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 104;
  background: rgba(26, 31, 46, 0.45);
  transition: opacity 120ms ease-out;
}

.chat-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 105; /* above the backdrop (104) and every chrome layer */
  width: 420px;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transition: transform 150ms ease-out;
}

.chat-drawer[hidden] {
  display: none;
}

.chat-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.chat-drawer-title {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--text);
}

.chat-close {
  min-width: 44px;
  min-height: 44px;
  font-size: 18px;
  line-height: 1;
}

.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-empty {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-empty-note {
  font-size: 13px;
  color: var(--muted-strong);
  line-height: 1.6;
}

.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-suggestion {
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 150ms ease-out, background 150ms ease-out;
}

.chat-suggestion:hover {
  border-color: var(--gold-border);
  background: var(--gold-bg);
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-msg-caption {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-strong);
}

.chat-msg-plain {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg-card {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}

.chat-msg-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--font-sans);
  color: var(--muted-strong);
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  text-decoration: none;
}

a.chip:hover {
  border-color: var(--gold-border);
  color: var(--gold-text);
}

.chip-tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold-text);
}

.searching-state {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted-strong);
}

.answer-error {
  font-size: 13px;
  line-height: 1.6;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.answer-error-code {
  font-family: var(--font-mono);
  font-size: 12px;
}

.chat-drawer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}

.chat-foot-note {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted-strong);
}

.chat-clear {
  white-space: nowrap;
}

.chat-form {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.chat-input {
  width: 100%;
  resize: vertical;
  min-height: 56px;
}

.chat-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.chat-hint {
  font-size: 11px;
  color: var(--muted-strong);
}

/* Phone: full-screen sheet with safe-area clearance (D15/D18). */
@media (max-width: 640px) {
  .chat-trigger {
    right: 14px;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    padding: 12px 14px;
  }
  .chat-drawer {
    width: 100vw;
    max-width: 100vw;
    border-left: 0;
  }
  .chat-form {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .chat-drawer-foot {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
}
