/* CertPilot web UI — Knack design tokens (canonical tokens.css).
   Web surfaces only; the PDF template carries its own print CSS.
   Structure follows the phone-first UX pass (main); every colour runs
   through the Knack token set below. */

:root {
  /* Surfaces */
  --bg: #ffffff;
  --bg-subtle: #f7f8fa;
  --bg-muted: #f1f3f6;
  --bg-hover: #f5f6f8;

  /* Borders */
  --border: #ebedf0;
  --border-strong: #dde1e6;
  --border-focus: #c5cdd6;

  /* Text */
  --text: #0f172a;
  --text-secondary: #4b5563;
  --text-tertiary: #6b7280;

  /* Accent */
  --accent: #C43C0A;
  --accent-hover: #9B3008;
  --accent-soft: #FFF4EF;
  --accent-soft-border: #FAD6C6;

  /* Status */
  --good: #047857;
  --good-soft: #ecfdf5;
  --good-soft-border: #c4ecd8;
  --tight: #b45309;
  --tight-soft: #fef7e6;
  --tight-soft-border: #f4e2b3;
  --risk: #b91c1c;
  --risk-soft: #fef2f2;
  --risk-soft-border: #fbd5d5;
  --info: #0369a1;
  --info-soft: #eff6ff;
  --info-soft-border: #c3ddf5;

  /* Notes / provenance */
  --note: #fbbf24;
  --note-bg: #fffbeb;
  --note-border: #f4e0a3;
  --note-text: #78350f;

  /* Aliases for the structural (main) selector vocabulary so nothing
     dangles — same values, second name. */
  --surface: var(--bg);
  --surface-2: var(--bg-hover);
  --fg: var(--text);
  --muted: var(--text-secondary);
  --accent-fg: #ffffff;
  --accent-border: var(--accent-soft-border);
  --success: var(--good);
  --success-soft: var(--good-soft);
  --success-border: var(--good-soft-border);
  --warning-soft: var(--note-bg);
  --warning-border: var(--note-border);
  --danger: var(--risk);

  --radius: 8px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.07), 0 2px 4px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.10);
  --max-form: 28rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-subtle);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  /* The page never scrolls sideways — wide content scrolls inside its
     own container (tables and the section-chip rail already do). */
  overflow-x: clip;
}

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono",
    monospace;
  font-size: 0.9em;
  background: var(--bg-muted);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

.container {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* Page header — title + optional one-line subtitle. */
.page-head { margin-bottom: 1.25rem; }
.page-head h1 { margin: 0 0 0.25rem; font-size: 1.6rem; line-height: 1.15; letter-spacing: -0.01em; }
.page-head .subtitle { margin: 0; color: var(--muted); font-size: 0.95rem; }

/* ---------- top bar (Knack: white bar, quiet links, accent pill) ---------- */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--bg);
  color: var(--text);
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
}

.navbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}
.navbar-brand:hover { color: var(--accent-hover); }
.brand-mark {
  width: 1.35rem;
  height: 1.35rem;
  flex: 0 0 auto;
  display: block;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  /* Phone: the link row scrolls inside itself, never wraps or pushes
     the page wide. */
  overflow-x: auto;
  scrollbar-width: none;
}
.navbar-links::-webkit-scrollbar { display: none; }
.navbar-link {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius);
  white-space: nowrap;
  font-size: 0.95rem;
}
.navbar-link:hover { background: var(--bg-hover); color: var(--text); }
.navbar-link.is-active {
  color: var(--accent-hover);
  background: var(--accent-soft);
  font-weight: 600;
}

/* Wide tables scroll inside their own box instead of pushing the whole
   page sideways on a phone. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 0.75rem; }
.user-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
}
.table-scroll .user-table { margin-top: 0; }
.user-table th,
.user-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
.user-table th {
  font-weight: 600;
  color: var(--text-tertiary);
}
.user-table td a { text-decoration: none; font-weight: 600; white-space: nowrap; }
.user-table td a:hover { text-decoration: underline; }
.user-table tbody tr:hover td { background: var(--bg-hover); }
.user-table tbody tr:last-child td { border-bottom: 0; }
.user-table button[type="submit"] {
  background: transparent;
  color: var(--risk);
  border: 1px solid var(--risk-soft-border);
  padding: 0.2rem 0.6rem;
  min-height: 2rem;
  font-size: 0.85rem;
}
.user-table button[type="submit"]:hover { background: var(--risk-soft); }

/* Log out: the quietest thing in the bar — leaving is never the
   primary action. (Selector doubled so it outweighs the generic
   accent `button[type="submit"]` rule declared later.) */
.navbar-logout { margin: 0; }
.navbar .navbar-logout button,
.navbar-logout button {
  background: transparent;
  color: var(--text-tertiary);
  border: 0;
  border-radius: var(--radius);
  padding: 0.4rem 0.65rem;
  min-height: 2.25rem;
  font: inherit;
  font-size: 0.95rem;
  white-space: nowrap;
  cursor: pointer;
}
.navbar .navbar-logout button:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: transparent;
}

.auth-card {
  max-width: var(--max-form);
  margin: 1.25rem auto 3rem;
  background: var(--bg);
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

/* Product identity above the login card. */
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin: 4rem auto 0;
  text-align: center;
}
.auth-brand .brand-mark { width: 2.4rem; height: 2.4rem; }
.auth-brand-name {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.auth-brand-tagline {
  margin: 0;
  color: var(--text-tertiary);
  font-size: 0.92rem;
}

h1 { margin-top: 0; }

form { display: flex; flex-direction: column; gap: 0.75rem; }

label { font-weight: 500; color: var(--text-secondary); }

input[type="email"],
input[type="password"],
input[type="text"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="date"],
input[type="search"] {
  min-height: 44px;
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  width: 100%;
}

textarea,
select {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  padding: 0.5rem 0.75rem;
}
select { min-height: 44px; }

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft-border);
  outline-offset: 1px;
}

/* Buttons. Shared shape; filled accent for submits + `.primary` (the one
   obvious next step per screen), quiet outline for a bare `.button`
   (links, toggles, low-emphasis actions). */
button[type="submit"],
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
button[type="submit"]:focus-visible,
.button:focus-visible { outline: 3px solid var(--accent-soft-border); outline-offset: 2px; }

/* Quiet outline is the default for a plain `.button`. */
.button,
.button.secondary {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border-strong);
}
.button:hover,
.button.secondary:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); }

/* Filled accent = submit buttons and explicit primary. */
button[type="submit"],
.button.primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
button[type="submit"]:hover,
.button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
}

.form-error {
  color: var(--risk);
  background: var(--risk-soft);
  border: 1px solid var(--risk-soft-border);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  margin: 0 0 1rem;
}

/* Success flash line (post-redirect confirmations). */
.flash {
  color: var(--good);
  background: var(--good-soft);
  border: 1px solid var(--good-soft-border);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  margin: 0 0 1rem;
}

.muted { color: var(--text-tertiary); }

[x-cloak] { display: none !important; }

/* ---------- form rows ---------- */
.form-row { display: block; margin-bottom: 1rem; }
.form-row > label,
.form-row > .label { display: block; font-weight: 600; margin-bottom: 0.25rem; color: var(--text); }
.form-row > input[type="text"],
.form-row > input[type="email"],
.form-row > input[type="tel"],
.form-row > input[type="url"],
.form-row > input[type="number"],
.form-row > input[type="date"],
.form-row > textarea,
.form-row > select {
  width: 100%;
  box-sizing: border-box;
  padding: 0.6rem;
  font-size: 1rem;
}

/* Radio groups render as tappable pills — phone-first, 44px targets,
   selection readable at arm's length on a ladder. The native input
   stays in the DOM (Alpine x-model + form submit untouched) but the
   pill is the visible control. */
.radio-group {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.radio-group > label {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 1rem;
  min-height: 44px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
}
.radio-group > label:hover { background: var(--bg-hover); }
.radio-group input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}
.radio-group > label:has(input[type="radio"]:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
  font-weight: 650;
  box-shadow: inset 0 0 0 1px var(--accent);
}
.radio-group > label:has(input[type="radio"]:focus-visible) {
  outline: 3px solid var(--accent-soft-border);
  outline-offset: 1px;
}

input[type="checkbox"] {
  accent-color: var(--accent);
  width: 1.25rem;
  height: 1.25rem;
  flex: 0 0 auto;
}

/* Yes/No 2-option groups share the pill row. */
.radio-group.inline { flex-direction: row; gap: 0.5rem; }

/* Inline checkboxes */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  min-height: 44px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

/* Identify/Link details subordinate to their reliance checkbox —
   revealed only when ticked (declutter), indented under it so the
   pair reads as one unit. */
.reliance-detail,
.sub-fields {
  margin: 0.55rem 0 0.1rem;
  padding: 0.1rem 0 0.1rem 0.9rem;
  border-left: 3px solid var(--accent-soft-border);
}
.reliance-detail > label,
.sub-fields > label {
  display: block;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0 0 0.25rem;
}
.reliance-detail > label:not(:first-child),
.sub-fields > label:not(:first-child) { margin-top: 0.6rem; }

fieldset {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1.1rem 1.1rem 1.15rem;
  margin: 0 0 1.5rem 0;
  border-radius: var(--radius);
}
/* Legends live INSIDE the card as a section header, not straddling
   the border (the default legend placement reads as a glitch). */
fieldset > legend {
  float: left;
  width: 100%;
  padding: 0 0 0.6rem;
  margin: 0 0 0.9rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
fieldset > legend + * { clear: both; }

.cert-form h1 {
  margin-bottom: 0.25rem;
  font-size: 1.6rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.cert-form-hero {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.85rem;
}

/* Collapsible legal / retention note — available but out of the way so
   the form itself is what the electrician sees first. */
.legal-note {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.legal-note > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0;
}
.legal-note > summary::-webkit-details-marker { display: none; }
.legal-note > summary::before {
  content: "";
  width: 0; height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s ease;
}
.legal-note[open] > summary::before { transform: rotate(90deg); }
.legal-note > p { margin: 0.5rem 0 0; line-height: 1.4; }

.cert-section-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 0.35rem;
  margin: 0 -1rem 1rem;
  padding: 0.5rem 1rem;
  overflow-x: auto;
  background: rgba(247, 248, 250, 0.94);
  border-bottom: 1px solid var(--border-strong);
  backdrop-filter: blur(8px);
}

.cert-section-nav a {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0.42rem 0.72rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
}

.cert-section-nav a:focus,
.cert-section-nav a:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-hover);
  outline: none;
}

.cert-form-coc fieldset,
.cert-form-esc fieldset {
  scroll-margin-top: 4.75rem;
  background: var(--bg);
  border-color: var(--border);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.cert-form-coc fieldset > legend,
.cert-form-esc fieldset > legend {
  color: var(--text);
  font-size: 0.98rem;
}

.cert-form-coc .form-row:last-child,
.cert-form-esc .form-row:last-child { margin-bottom: 0; }

.form-grid {
  display: grid;
  gap: 1rem;
}

.cert-issuer-line {
  margin: 0;
  color: var(--text-secondary);
}

.cert-issuer-line strong { color: var(--text); }

/* side-by-side date pair on wide screens */
.date-pair { display: grid; gap: 1rem; }
@media (min-width: 640px) {
  .cert-form h1 { font-size: 2.35rem; }
  .date-pair { grid-template-columns: 1fr 1fr; }
  .form-grid.two { grid-template-columns: 1fr 1fr; }
  .radio-group.wide { flex-direction: row; flex-wrap: wrap; gap: 1rem; }
}

/* preamble / preview banner */
.preamble {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 1rem;
  line-height: 1.4;
}
.cert-number-preview {
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 0 0 1.25rem;
  font-weight: 600;
  color: var(--accent-hover);
}
.cert-number-preview small { display: block; font-weight: 400; color: var(--text-tertiary); }

/* Knack handoff provenance band — amber note above a prefilled form. */
.handoff-banner {
  background: var(--note-bg);
  border: 1px solid var(--note-border);
  border-left: 4px solid var(--note);
  border-radius: var(--radius);
  color: var(--note-text);
  padding: 0.75rem 1rem;
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
}

/* Freshly-minted API token panel (shown once). */
.minted-token-panel {
  background: var(--bg);
  border: 1px solid var(--accent-soft-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 0 0 1.5rem;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}
.minted-token-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
}
.minted-token-panel textarea[readonly],
.minted-token-panel input[readonly] {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono",
    monospace;
  font-size: 0.9rem;
  width: 100%;
  padding: 0.6rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  border-radius: var(--radius);
  color: var(--text);
  word-break: break-all;
}
.minted-token-panel .button { margin-top: 0.5rem; }
.minted-token-manual { margin-top: 0.75rem; }
.minted-token-manual summary {
  cursor: pointer;
  color: var(--text-secondary);
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* ---------- dashboard ---------- */
.dash-greeting { margin: 0 0 0.15rem; font-size: 1.55rem; letter-spacing: -0.01em; }
.dash-sub { margin: 0 0 1.5rem; color: var(--text-secondary); }
.dash-sub .dash-email { color: var(--text-secondary); }

.action-cards { display: grid; gap: 1rem; }
@media (min-width: 640px) { .action-cards { grid-template-columns: 1fr 1fr; } }

.action-card {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.15rem;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}
.action-card:hover {
  border-color: var(--accent-soft-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  color: var(--text);
}
.action-card .ac-icon {
  flex: 0 0 auto;
  width: 2.6rem; height: 2.6rem;
  display: grid; place-items: center;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
}
.action-card .ac-icon svg { width: 1.4rem; height: 1.4rem; }
.action-card .ac-body { min-width: 0; }
.action-card .ac-title {
  margin: 0.1rem 0 0.2rem;
  font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 0.4rem;
}
.action-card .ac-desc { margin: 0; color: var(--text-tertiary); font-size: 0.9rem; line-height: 1.35; }
.action-card .ac-arrow { color: var(--text-tertiary); margin-left: auto; align-self: center; flex: 0 0 auto; }
.action-card:hover .ac-arrow { color: var(--accent); }

/* Big CTA form of the grid (handoff choose page). */
.dashboard-actions {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}
.dashboard-actions a.button {
  padding: 1.25rem;
  font-size: 1.1rem;
  text-align: center;
  min-height: 64px;
}
@media (min-width: 640px) {
  .dashboard-actions { grid-template-columns: 1fr 1fr; gap: 1.5rem; }
}

/* field-level error */
.field-error {
  color: var(--risk);
  font-size: 0.85rem;
  margin: 0.25rem 0 0;
}

/* ---------- address + customer autocomplete ---------- */
.address-field,
.customer-field {
  position: relative;
}

.address-autocomplete-list,
.customer-autocomplete-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.25rem);
  z-index: 30;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
  overflow-y: auto;
  max-height: 16rem;
}

.address-autocomplete-list[hidden],
.customer-autocomplete-list[hidden] { display: none; }

.address-autocomplete-list button,
.customer-autocomplete-list button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  color: var(--text);
  border: 0;
  border-bottom: 1px solid var(--border);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.address-autocomplete-list button:last-child,
.customer-autocomplete-list button:last-child { border-bottom: 0; }

.address-autocomplete-list button:hover,
.address-autocomplete-list button.is-active,
.customer-autocomplete-list button:hover,
.customer-autocomplete-list button.is-active {
  background: var(--accent-soft);
}

.address-autocomplete-list .ac-pin,
.customer-autocomplete-list .ac-pin {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  fill: var(--text-tertiary);
}

.address-autocomplete-list button:hover .ac-pin,
.address-autocomplete-list button.is-active .ac-pin,
.customer-autocomplete-list button:hover .ac-pin,
.customer-autocomplete-list button.is-active .ac-pin {
  fill: var(--accent);
}

.address-autocomplete-list .ac-text {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text-secondary);
}

.address-autocomplete-list .ac-text strong {
  color: var(--text);
  font-weight: 600;
}

/* customer rows are two lines: name + muted contact details */
.customer-autocomplete-list .ac-lines {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.customer-autocomplete-list .ac-name {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.customer-autocomplete-list .ac-name strong {
  font-weight: 600;
}

.customer-autocomplete-list .ac-sub {
  color: var(--text-secondary);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* warning banner (CoC-only confirmation and other alerts) */
.warning {
  background: var(--note-bg);
  border: 1px solid var(--note-border);
  border-radius: var(--radius);
  color: var(--note-text);
  padding: 1rem;
  margin-bottom: 1.25rem;
}
.warning p { margin: 0 0 0.75rem; }

/* signature pad wrapper */
.signature-pad { margin-top: 0.5rem; }
.signature-pad canvas {
  background: var(--bg);
  border: 1.5px dashed var(--border-focus);
  border-radius: var(--radius);
}
.signature-pad button { margin-top: 0.5rem; }
.signature-hint {
  margin: 0 0 0.35rem;
  color: var(--text-tertiary);
  font-size: 0.85rem;
}

/* sticky submit */
.sticky-submit {
  position: sticky;
  bottom: 0;
  background: var(--bg-subtle);
  padding: 0.75rem 0;
  box-shadow: 0 -4px 10px -5px rgba(0, 0, 0, 0.15);
}
.sticky-submit button { width: 100%; min-height: 56px; font-size: 1.1rem; }

/* Email status banners on the cert detail page. */
.banner {
  padding: 1rem;
  border-radius: var(--radius);
  margin: 1rem 0;
}
.banner.success {
  background: var(--good-soft);
  border: 1px solid var(--good-soft-border);
  color: var(--good);
}
.banner.warning {
  background: var(--tight-soft);
  border: 1px solid var(--tight-soft-border);
  color: var(--tight);
}
.banner.muted {
  background: var(--bg-muted);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
}
.recipient-list {
  margin: 0.5rem 0 0.75rem 1rem;
  padding: 0;
}
.recipient-list li {
  list-style: disc;
  margin-left: 1rem;
}

.email-panel {
  padding: 1.25rem;
  border-radius: var(--radius);
  margin: 1rem 0;
}
.email-panel.pending {
  background: var(--tight-soft);
  border: 1px solid var(--tight-soft-border);
}
.email-panel.sent {
  background: var(--good-soft);
  border: 1px solid var(--good-soft-border);
}
.email-panel.muted {
  background: var(--bg-muted);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
}
.email-panel h3 { margin: 0 0 0.5rem 0; }
.email-panel.sent h3 { color: var(--good); }
.email-panel ul {
  margin: 0.5rem 0 0.75rem 1rem;
  padding: 0;
}
.email-panel li { list-style: disc; margin-left: 1rem; }
.recipient-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0;
}
.recipient-row .checkbox-row { margin: 0; }
.recipient-row input[type="email"] {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 0.95rem;
}

/* Quiet cloud-backup provenance line on the cert detail page. */
.backup-link {
  color: var(--text-tertiary);
  font-size: 0.9rem;
  margin: 0.5rem 0;
}
.backup-link a { color: var(--info); text-decoration-color: var(--info-soft-border); }
.backup-link a:hover { color: var(--info); text-decoration-color: var(--info); }

/* ---------- cert detail: the facts card ---------- */
.fact-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin: 1rem 0;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}
dl.fact-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.15rem 1.25rem;
  margin: 0;
}
dl.fact-grid dt {
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-top: 0.7rem;
}
dl.fact-grid dt:first-of-type { margin-top: 0; }
dl.fact-grid dd { margin: 0; color: var(--text); }
@media (min-width: 640px) {
  dl.fact-grid { grid-template-columns: auto 1fr; align-items: baseline; }
  dl.fact-grid dt,
  dl.fact-grid dd { margin-top: 0.7rem; }
  dl.fact-grid dt:first-of-type,
  dl.fact-grid dt:first-of-type + dd { margin-top: 0; }
  dl.fact-grid .span-2 { grid-column: 1 / -1; }
  dl.fact-grid dd.span-2 { margin-top: 0.15rem; }
}

/* ============================================================
   Cards, badges, pills, lists
   ============================================================ */

/* Generic surface card. */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem 1.15rem;
}

/* ---- Badges (cert type) + status pills ----
   One badge system everywhere: CoC = info, ESC = good, combined = accent. */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.coc { background: var(--info-soft); color: var(--info); border-color: var(--info-soft-border); }
.badge.esc { background: var(--good-soft); color: var(--good); border-color: var(--good-soft-border); }
.badge.combined { background: var(--accent-soft); color: var(--accent-hover); border-color: var(--accent-soft-border); }

.pill {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem; font-weight: 600;
}
.pill.sent { background: var(--good-soft); color: var(--good); border: 1px solid var(--good-soft-border); }
.pill.draft { background: var(--bg-hover); color: var(--text-secondary); border: 1px solid var(--border-strong); }

/* ---- Certificate list (card rows, phone-first) ---- */
.cert-list { display: flex; flex-direction: column; gap: 0.75rem; margin: 0.5rem 0 0; padding: 0; list-style: none; }
.cert-list-item {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.14s ease, border-color 0.14s ease;
}
.cert-list-item:hover { border-color: var(--accent-soft-border); box-shadow: var(--shadow-md); color: var(--text); }
.cli-top { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.3rem; }
.cli-number { font-weight: 700; letter-spacing: -0.01em; }
.cli-meta { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.cli-date { color: var(--text-tertiary); font-size: 0.85rem; }
.cli-customer { font-weight: 600; }
.cli-site { color: var(--text-tertiary); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- customer + user card rows ----------
   Both lists reuse .cert-list-item, but neither row is a link (there
   is no customer detail page, and a user row's only action is the
   button inside it), so they opt out of the anchor hover lift. */
.cert-list-item.customer-row:hover,
.cert-list-item.user-row:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

/* Contact details wrap instead of widening the row — this is what the
   old <table> could not do, and why it grew a horizontal scrollbar. */
.customer-contact,
.user-row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1rem;
  margin-top: 0.15rem;
}
.customer-contact-item {
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-decoration: none;
  /* Long addresses break rather than push the row wide. */
  overflow-wrap: anywhere;
}
a.customer-contact-item:hover { color: var(--text); text-decoration: underline; }

/* The destructive action sits IN the row, below the identity line, so
   it is reachable at every width. */
.user-row-actions { margin-top: 0.7rem; }
.user-row-actions .button {
  background: transparent;
  color: var(--risk);
  border: 1px solid var(--risk-soft-border);
  padding: 0.25rem 0.7rem;
  min-height: 2rem;
  font-size: 0.85rem;
}
.user-row-actions .button:hover { background: var(--risk-soft); }
.cert-list-item.user-row.is-inactive { opacity: 0.72; }

/* Search above a long list. */
.list-search { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0 0 1rem; }
.list-search input[type="search"] { flex: 1 1 16rem; min-width: 0; margin: 0; }
.list-search-clear { color: var(--text-tertiary); font-size: 0.9rem; text-decoration: none; }
.list-search-clear:hover { text-decoration: underline; }

.pagination { display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem; }

/* Row of actions with sensible wrapping. */
.action-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1rem 0; }

/* ---------- bottom action rows ---------- */
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

/* ---------- dashboard recents ---------- */
.recents-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 2rem 0 0.25rem;
}
.recents-header h2 { margin: 0; font-size: 1.15rem; }
.recents-header a { font-size: 0.92rem; }
.recent-empty {
  color: var(--text-tertiary);
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 0.5rem;
}
