/* =====================================================================================
   StaffJunction - flat design system (§12.1, §12.7)
   =====================================================================================

   Rules taken directly from the client's flat-design reference and applied without
   exception:

     box-shadow: none            - surfaces are separated by 1px borders and whitespace
     solid colour backgrounds    - no gradients anywhere
     border-radius: 0-4px        - 8px only for the icon tiles, as in the reference
     hover = colour/opacity shift - no transforms, no depth, ~150ms

   Two deliberate additions to the six-colour reference palette, both driven by
   requirements rather than taste:

   1. A semantic ERROR RED. The reference palette's warm colours are orange and amber, so
      "expiring soon" and "expired/failed" would sit two steps apart on the same hue. On a
      compliance dashboard that ambiguity is a safety problem, not an aesthetic one - an
      expired right-to-work check must never read as merely "expiring" (§12.7 recommendation,
      flagged for design sign-off).

   2. Darkened variants of blue and red for TEXT-BEARING FILLS. White text on the brand blue
      #2196F3 measures ~3.1:1, below the WCAG 2.1 AA threshold of 4.5:1 for normal text
      (§12.5). The brand hues are kept for accents, borders, focus rings and flat areas; the
      700-weight variants carry white text. Where a brand fill must stay exact - green, amber,
      cyan, orange - dark text is used instead, exactly as §12.7 instructs.

   Every status in this system is conveyed by colour AND an icon AND a text label, so it
   survives colour blindness and the greyscale printing of an evidence pack.
   ===================================================================================== */

:root {
  /* --- Brand palette: exact values from the reference (§12.7) --- */
  --blue: #2196f3;
  --orange: #ff5722;
  --green: #4caf50;
  --amber: #ffc107;
  --purple: #9c27b0;
  --cyan: #00bcd4;

  /* --- Accessible text-bearing variants (see header note) --- */
  --blue-700: #1976d2;
  --blue-800: #1565c0;
  --red: #f44336;
  --red-700: #d32f2f;
  --green-700: #388e3c;

  /* --- Neutrals --- */
  --bg: #ffffff;
  --bg-subtle: #f4f5f7;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text-heading: #1f2a37;
  --text-body: #4b5563;
  --text-muted: #9ca3af;

  /* --- Component tokens --- */
  --radius: 4px;
  --radius-tile: 8px;
  --transition: 150ms ease;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", Consolas, "Liberation Mono", monospace;

  --header-height: 56px;
  --content-max: 1280px;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-body);
  background: var(--bg-subtle);
}

h1, h2, h3, h4, h5 {
  margin: 0 0 var(--space-3);
  color: var(--text-heading);
  font-weight: 700;
  line-height: 1.25;
}

h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }

p { margin: 0 0 var(--space-3); }

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

small { font-size: 13px; }

code, pre, .mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-5) 0;
}

/* Focus is always visible and always ≥2px (§12.5, §12.7). */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--blue-700);
  color: #fff;
  padding: var(--space-2) var(--space-4);
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus {
  left: 0;
}

/* =====================================================================================
   App shell - StaffJunction frame with the active company shown inside it (§12.4)
   ===================================================================================== */
.app-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header__inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--space-5);
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  color: var(--text-heading);
  font-size: 17px;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.brand__mark {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  /* --brand-colour is served per portal from companies/<pk>/branding.css. The fallback
     covers a database with no company yet, and the first paint before that file lands. */
  background: var(--brand-colour, var(--blue-700));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
}

/* Uploaded portal logo. Capped in height so an oversized upload cannot push the
   header out of shape; width follows the image's own aspect ratio. */
.brand__logo {
  height: 30px;
  max-width: 200px;
  width: auto;
  object-fit: contain;
  display: block;
}

.header-spacer { flex: 1 1 auto; }

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* --- Primary navigation --- */
.app-nav {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.app-nav__inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--space-5);
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  scrollbar-width: thin;
}

.app-nav__link {
  padding: var(--space-3) var(--space-4);
  color: var(--text-body);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.app-nav__link:hover {
  color: var(--text-heading);
  text-decoration: none;
}
.app-nav__link[aria-current="page"] {
  color: var(--blue-700);
  border-bottom-color: var(--blue-700);
}

.app-main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-5);
}

.app-footer {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-5);
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

/* Environment banner - makes a staging deployment with restored data unmistakable. */
.env-banner {
  background: var(--amber);
  color: var(--text-heading);
  text-align: center;
  padding: var(--space-2) var(--space-4);
  font-weight: 700;
  font-size: 13px;
}

/* =====================================================================================
   Page header
   ===================================================================================== */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.page-header__title { margin: 0; }

.page-header__meta {
  color: var(--text-muted);
  font-size: 14px;
  margin: var(--space-1) 0 0;
}

.page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.breadcrumb a { color: var(--text-muted); }

/* =====================================================================================
   Cards - separation by 1px border, never elevation (§12.1)
   ===================================================================================== */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: none;
}

.card + .card { margin-top: var(--space-4); }

.card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: calc(var(--space-5) * -1) calc(var(--space-5) * -1) var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.card__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-heading);
}

.card__subtitle {
  margin: var(--space-1) 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.card--flush { padding: 0; }
.card--flush .card__header { margin: 0; }

.card-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.two-column {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 2fr 1fr;
  align-items: start;
}

/* =====================================================================================
   Icon tiles - 8px radius, solid palette fills, as in the reference
   ===================================================================================== */
.icon-tile {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-tile);
  display: grid;
  place-items: center;
  font-size: 17px;
  line-height: 1;
  flex: none;
  color: #fff;
}
.icon-tile--blue { background: var(--blue-700); }
.icon-tile--orange { background: var(--orange); color: var(--text-heading); }
.icon-tile--green { background: var(--green); color: var(--text-heading); }
.icon-tile--amber { background: var(--amber); color: var(--text-heading); }
.icon-tile--purple { background: var(--purple); }
.icon-tile--cyan { background: var(--cyan); color: var(--text-heading); }
.icon-tile--red { background: var(--red-700); }

/* =====================================================================================
   Stat tiles
   ===================================================================================== */
.stat-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: var(--space-5);
}

.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}
a.stat:hover {
  border-color: var(--border-strong);
  text-decoration: none;
}

.stat__value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.1;
}

.stat__label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.stat--alert { border-left: 3px solid var(--red-700); }
.stat--warn { border-left: 3px solid var(--amber); }
.stat--ok { border-left: 3px solid var(--green); }

/* =====================================================================================
   Buttons - solid fills, hover darkens, no shadow, no transform
   ===================================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--transition), border-color var(--transition),
    color var(--transition);
  box-shadow: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--blue-700);
  color: #fff;
}
.btn--primary:hover { background: var(--blue-800); }

.btn--secondary {
  background: var(--bg-subtle);
  border-color: var(--border);
  color: var(--text-heading);
}
.btn--secondary:hover { background: #e8eaed; }

.btn--danger {
  background: var(--red-700);
  color: #fff;
}
.btn--danger:hover { background: #b71c1c; }

.btn--success {
  background: var(--green-700);
  color: #fff;
}
.btn--success:hover { background: #2e7d32; }

/* On a coloured band: white fill with coloured text, as in the reference's CTA. */
.btn--on-fill {
  background: #fff;
  color: var(--blue-700);
}
.btn--on-fill:hover { background: #f0f0f0; }

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-body);
}
.btn--ghost:hover {
  background: var(--bg-subtle);
  color: var(--text-heading);
}

.btn--small {
  min-height: 30px;
  padding: var(--space-1) var(--space-3);
  font-size: 13px;
}

.btn--block { width: 100%; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* =====================================================================================
   Badges - colour + icon + label, never colour alone (§12.5)
   ===================================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge__icon {
  font-size: 11px;
  line-height: 1;
}

/* Dark text on green/amber/cyan/orange: white text fails AA on these hues (§12.7). */
.badge--success { background: var(--green); color: var(--text-heading); }
.badge--warning { background: var(--amber); color: var(--text-heading); }
.badge--danger { background: var(--red-700); color: #fff; }
.badge--info { background: var(--blue-700); color: #fff; }
.badge--neutral {
  background: var(--bg-subtle);
  color: var(--text-body);
  border-color: var(--border);
}
.badge--accent { background: var(--purple); color: #fff; }
.badge--cyan { background: var(--cyan); color: var(--text-heading); }
.badge--orange { background: var(--orange); color: var(--text-heading); }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-3);
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-body);
  font-size: 12px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* =====================================================================================
   Alerts / messages
   ===================================================================================== */
.alert {
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--bg);
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.alert__icon { flex: none; font-weight: 700; }
.alert__body { flex: 1; }
.alert p:last-child { margin-bottom: 0; }

.alert--success { border-left-color: var(--green); }
.alert--info { border-left-color: var(--blue); }
.alert--warning { border-left-color: var(--amber); }
.alert--error { border-left-color: var(--red-700); }

/* The standing compliance notice: this system never submits to the Home Office (§2). */
.notice-compliance {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cyan);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  font-size: 13px;
  color: var(--text-body);
  margin-bottom: var(--space-4);
}

/* =====================================================================================
   Tables - degrade to stacked cards on small screens (§12.2)
   ===================================================================================== */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

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

table.data th,
table.data td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data thead th {
  background: var(--bg-subtle);
  color: var(--text-heading);
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--bg-subtle); }

table.data .numeric { text-align: right; font-variant-numeric: tabular-nums; }

.table-empty {
  padding: var(--space-6);
  text-align: center;
  color: var(--text-muted);
}

/* --- Definition lists for detail pages --- */
.detail-list {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  gap: var(--space-2) var(--space-4);
  margin: 0;
  font-size: 14px;
}
.detail-list dt {
  color: var(--text-muted);
  font-weight: 600;
}
.detail-list dd {
  margin: 0;
  color: var(--text-heading);
}

/* =====================================================================================
   Forms
   ===================================================================================== */
.form-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.field { margin-bottom: var(--space-4); }

.field__label {
  display: block;
  margin-bottom: var(--space-1);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-heading);
}

.field__required { color: var(--red-700); }

.field__help {
  margin-top: var(--space-1);
  font-size: 12px;
  color: var(--text-muted);
}

.field__error {
  margin-top: var(--space-1);
  font-size: 12px;
  color: var(--red-700);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  min-height: 38px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-heading);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color var(--transition);
}

input[type="color"] {
  width: 56px;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
}

textarea { min-height: 80px; resize: vertical; }

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  outline: 2px solid var(--blue);
  outline-offset: 0;
}

.field--error input,
.field--error select,
.field--error textarea {
  border-color: var(--red-700);
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: 14px;
  color: var(--text-heading);
  margin-bottom: var(--space-3);
}

.checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--green-700);
  flex: none;
}

/* Confirmation checkboxes on the right-to-work form: these are decisions, not paperwork. */
.confirmation-box {
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filter-bar .field { margin-bottom: 0; }
.filter-bar .field--grow { flex: 1 1 220px; }

/* =====================================================================================
   Progress
   ===================================================================================== */
.progress {
  height: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  background: var(--green);
  width: 0;
}

/* Progress is driven by a data attribute rather than an inline style. The
   Content-Security-Policy has no 'unsafe-inline' in style-src, so style="width: 60%"
   was being dropped by the browser and every bar rendered empty regardless of progress.
   Rounded to the nearest 5% by the template filter, which is finer than an 8px-tall bar
   can show anyway. */
.progress__bar[data-progress="0"]   { width: 0; }
.progress__bar[data-progress="5"]   { width: 5%; }
.progress__bar[data-progress="10"]  { width: 10%; }
.progress__bar[data-progress="15"]  { width: 15%; }
.progress__bar[data-progress="20"]  { width: 20%; }
.progress__bar[data-progress="25"]  { width: 25%; }
.progress__bar[data-progress="30"]  { width: 30%; }
.progress__bar[data-progress="35"]  { width: 35%; }
.progress__bar[data-progress="40"]  { width: 40%; }
.progress__bar[data-progress="45"]  { width: 45%; }
.progress__bar[data-progress="50"]  { width: 50%; }
.progress__bar[data-progress="55"]  { width: 55%; }
.progress__bar[data-progress="60"]  { width: 60%; }
.progress__bar[data-progress="65"]  { width: 65%; }
.progress__bar[data-progress="70"]  { width: 70%; }
.progress__bar[data-progress="75"]  { width: 75%; }
.progress__bar[data-progress="80"]  { width: 80%; }
.progress__bar[data-progress="85"]  { width: 85%; }
.progress__bar[data-progress="90"]  { width: 90%; }
.progress__bar[data-progress="95"]  { width: 95%; }
.progress__bar[data-progress="100"] { width: 100%; }

/* =====================================================================================
   Layout utilities

   These replace inline style attributes, which the Content-Security-Policy discards.
   ===================================================================================== */
.text-20 { font-size: 20px; }
.text-16 { font-size: 16px; }
.text-15 { font-size: 15px; }
.text-14 { font-size: 14px; }
.text-12 { font-size: 12px; }

.w-narrow  { max-width: 560px; }
.w-form    { max-width: 640px; }
.w-content { max-width: 680px; }
.w-wide    { max-width: 720px; }
.w-page    { max-width: 820px; }
.centred   { margin-left: auto; margin-right: auto; }

.flex-1 { flex: 1; }
.mb-0 { margin-bottom: 0; }
.progress--inline { min-width: 120px; }
.code-fragment {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  word-break: break-all;
}

/* =====================================================================================
   Pagination
   ===================================================================================== */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  flex-wrap: wrap;
}
.pagination__info {
  color: var(--text-muted);
  font-size: 13px;
  margin-right: auto;
}

/* =====================================================================================
   Queue lists (compliance dashboard)
   ===================================================================================== */
.queue {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}

.queue__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.queue__title {
  font-weight: 700;
  color: var(--text-heading);
  font-size: 14px;
  margin: 0;
}

.queue__count {
  margin-left: auto;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-heading);
}

.queue__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.queue__item:last-child { border-bottom: 0; }
.queue__item:hover { background: var(--bg-subtle); }
.queue__meta {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

.queue__empty {
  padding: var(--space-4);
  color: var(--text-muted);
  font-size: 13px;
}

/* =====================================================================================
   Timeline (audit + history)
   ===================================================================================== */
.timeline { list-style: none; margin: 0; padding: 0; }
/* Inset variant, used where the timeline sits directly inside a card rather than a
   page section that already provides the gutter. */
.timeline--padded { padding: 0 24px; }

.timeline__item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  /* The header and nav are sticky, so an anchored item would otherwise land underneath them. */
  scroll-margin-top: 120px;
}
.timeline__item:last-child { border-bottom: 0; }

.timeline__time {
  flex: none;
  width: 140px;
  color: var(--text-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.value-change {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.value-old {
  text-decoration: line-through;
  color: var(--text-muted);
}
.value-new {
  color: var(--text-heading);
  font-weight: 600;
}

/* =====================================================================================
   Auth pages
   ===================================================================================== */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background: var(--bg-subtle);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-6);
}

.auth-card__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-heading);
}

.qr-code {
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
}
.qr-code svg { width: 190px; height: 190px; }

.recovery-codes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

/* =====================================================================================
   Utilities
   ===================================================================================== */
.muted { color: var(--text-muted); }
.strong { font-weight: 700; color: var(--text-heading); }
.small { font-size: 13px; }
.tabular { font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }

.stack > * + * { margin-top: var(--space-3); }
.inline-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }

.divider {
  border-top: 1px solid var(--border);
  margin: var(--space-4) 0;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-heading);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}

.person {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.person__name {
  font-weight: 600;
  color: var(--text-heading);
}
.person__meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* Masked sensitive values are rendered in mono so it is obvious they are redacted. */
.masked {
  font-family: var(--font-mono);
  letter-spacing: 1px;
  color: var(--text-muted);
}

/* =====================================================================================
   Responsive - mobile first breakpoints (§12.2)
   ===================================================================================== */
@media (max-width: 1024px) {
  .two-column { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .app-header__inner,
  .app-nav__inner,
  .app-main,
  .app-footer {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .detail-list { grid-template-columns: 1fr; gap: var(--space-1); }
  .detail-list dd { margin-bottom: var(--space-3); }


  /* Tables become stacked cards: each cell carries its column name via data-label. */
  table.data.responsive thead { display: none; }
  table.data.responsive,
  table.data.responsive tbody,
  table.data.responsive tr,
  table.data.responsive td {
    display: block;
    width: 100%;
  }
  table.data.responsive tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--space-3);
    padding: var(--space-2);
    background: var(--bg);
  }
  table.data.responsive td {
    border-bottom: 0;
    padding: var(--space-2);
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    align-items: center;
  }
  table.data.responsive td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex: none;
  }
  table.data.responsive td:empty { display: none; }
  .table-wrap { border: 0; background: transparent; }
}

@media (max-width: 480px) {
  body { font-size: 14px; }
  h1 { font-size: 22px; }
  .app-main { padding: var(--space-4) var(--space-3); }
  .card { padding: var(--space-4); }
  .card__header {
    margin: calc(var(--space-4) * -1) calc(var(--space-4) * -1) var(--space-3);
    padding: var(--space-3) var(--space-4);
  }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page-header__actions { width: 100%; }
  .page-header__actions .btn { flex: 1 1 auto; }
  .recovery-codes { grid-template-columns: 1fr; }
  /* Touch targets stay comfortable on phones (§12.5). */
  .btn { min-height: 44px; }
}

@media print {
  .app-nav,
  .app-header,
  .app-footer,
  .page-header__actions,
  .btn { display: none !important; }
  body { background: #fff; }
  .card { border: 1px solid #999; }
}
