:root {
  /* Warm neutrals - paper, not slate. */
  --bg: #fbf9f6;
  --panel: #ffffff;
  --panel-soft: #f7f4ef;
  --text: #1f1b16;
  --text-strong: #0f0c08;
  --muted: #6b6359;
  --muted-soft: #9a9087;
  --line: #e8e1d6;
  --line-soft: #f1ebe0;

  /* Owned colour: amber. Used confidently, not as accent decoration. */
  --brand: #ea580c;
  --brand-soft: #fff1e6;
  --brand-strong: #c2410c;
  --brand-ink: #7c2d12;

  /* Single secondary accent - earns its keep as "safe / success" semantics. */
  --accent: #047857;
  --accent-soft: #ecfdf5;

  /* Status colours kept neutral and restrained. */
  --danger: #b91c1c;
  --warn: #b45309;
  --ok: #047857;
  --info: #1d4ed8;

  --shadow-sm: 0 1px 2px rgba(31, 27, 22, 0.05);
  --shadow-md: 0 4px 16px rgba(31, 27, 22, 0.07);
  --shadow-lg: 0 18px 50px rgba(31, 27, 22, 0.10);

  /* Varied radii - hierarchy, not uniformity. */
  --radius-btn: 6px;
  --radius-input: 8px;
  --radius: 14px;        /* cards (was 12px) */
  --radius-sm: 8px;
  --radius-lg: 20px;     /* hero blocks, large panels */
  --radius-pill: 999px;

  --sidebar-w: 240px;
  --topbar-h: 60px;

  /* Type stacks. */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Fraunces', 'Iowan Old Style', 'Apple Garamond', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { color: var(--text-strong); font-weight: 600; line-height: 1.25; margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

p { margin: 0 0 8px; }

code, kbd, samp {
  background: var(--line-soft);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 5px;
}

.u-mt-1 { margin-top: 8px; }
.u-mt-2 { margin-top: 12px; }
.u-mt-3 { margin-top: 16px; }
.u-mt-4 { margin-top: 18px; }
.u-mb-2 { margin-bottom: 12px; }
.u-mb-1 { margin-bottom: 8px; }
.u-mb-3 { margin-bottom: 16px; }
.u-m-0 { margin: 0; }
.u-ml-1 { margin-left: 8px; }
.u-ml-2 { margin-left: 12px; }
.u-muted-xs { font-size: 11px; }
.u-muted-sm { font-size: 12px; }
.u-muted-md { font-size: 13px; }
.u-kpi-lg { font-size: 22px; }
.u-kpi-md { font-size: 16px; font-weight: 600; }
.u-mono { font-family: var(--font-mono); }
.u-max-sm { max-width: 520px; }
.u-max-md { max-width: 720px; }
.u-max-lg { max-width: 880px; }
.u-mt-5 { margin-top: 24px; }
.u-panel-flush { padding: 0; }
.u-table-flush { border: 0; }
.u-table-rounded { border-radius: var(--radius); }
.u-inline-form { margin: 0; }
.u-inline-actions { display: inline-flex; gap: 6px; }
.u-actions-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.u-text-right { text-align: right; }
.u-danger-text { color: var(--danger); }
.u-danger-border { border-color: #fecaca; }
.u-ok-text { color: var(--ok); font-weight: 600; }
.u-code-block {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: inline-block;
  font-size: 14px;
  padding: 8px 12px;
}
.status-pill-brand {
  background: var(--brand-soft);
  border-color: var(--brand-soft);
  color: var(--brand-strong);
}
.bar-seg { width: var(--seg-width, 0%); }
.bar-compact { max-width: 140px; }
.cell-min-chart { min-width: 140px; }
.content-note-tight { margin: -6px 0 14px; font-size: 12px; }
.content-note-last { margin: -6px 0 18px; font-size: 12px; }
.panel-header-flush { padding: 20px 20px 0; }
.simple-list-spaced { line-height: 1.7; padding-left: 22px; }
.pp-status-min { min-height: 14px; }
.u-heading-gap { margin: 14px 0 8px; }
.u-font-inherit { font-family: inherit; }
.u-max-portal { max-width: 560px; }

/* ================= Login / Guest ================= */
.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(31, 27, 22, 0.04), 0 20px 50px -20px rgba(31, 27, 22, 0.18);
  max-width: 440px;
  padding: 36px;
  width: 100%;
}

.login-brand {
  align-items: center;
  display: flex;
  gap: 14px;
  margin-bottom: 28px;
}

.login-panel h1 {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.login-panel .muted {
  font-size: 14px;
  margin-bottom: 24px;
}

/* ================= Brand mark ================= */
.brand,
.brand-mark {
  align-items: center;
  display: inline-flex;
}

.brand {
  color: var(--text-strong);
  font-weight: 700;
  gap: 10px;
  text-decoration: none;
}

.brand:hover { text-decoration: none; }

.brand-mark {
  background: var(--brand);
  border-radius: var(--radius-btn);
  color: #fff;
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 600;
  height: 30px;
  justify-content: center;
  letter-spacing: 0;
  width: 32px;
}

.login-brand .brand-mark { height: 40px; width: 40px; font-size: 14px; }

.brand small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 500;
  margin-top: 2px;
}

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

.app-content {
  display: flex;
  flex-direction: column;
  grid-column: 2;
  min-width: 0;
}

.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--line);
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 18px;
  inset: 0 auto 0 0;
  padding: 18px 14px;
  position: fixed;
  width: var(--sidebar-w);
}

.sidebar .brand { padding: 6px 8px; }

.side-nav { display: grid; gap: 1px; }

.side-nav a {
  align-items: center;
  border-radius: 7px;
  color: var(--text);
  display: flex;
  font-size: 13px;
  font-weight: 500;
  gap: 10px;
  padding: 8px 10px;
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}

.side-nav a:hover {
  background: var(--line-soft);
  color: var(--text-strong);
  text-decoration: none;
}

.side-nav a.is-active {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.side-nav a .nav-icon {
  color: var(--muted);
  display: inline-flex;
  flex-shrink: 0;
  height: 16px;
  width: 16px;
}

.side-nav a:hover .nav-icon,
.side-nav a.is-active .nav-icon { color: var(--brand-strong); }

.nav-section {
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin: 12px 10px 4px;
  text-transform: uppercase;
}

.nav-badge {
  align-items: center;
  background: var(--text-strong);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: 11px;
  font-weight: 500;
  height: 18px;
  justify-content: center;
  margin-left: auto;
  min-width: 18px;
  padding: 0 6px;
}
.nav-badge-warn { background: var(--warn); }

.sidebar-footer {
  border-top: 1px solid var(--line);
  margin-top: auto;
  padding-top: 14px;
}

.sidebar-user {
  align-items: center;
  display: flex;
  gap: 10px;
  padding: 6px 8px;
}

.sidebar-user .avatar {
  align-items: center;
  background: var(--brand-soft);
  border-radius: 999px;
  color: var(--brand-strong);
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.sidebar-user-meta {
  flex: 1;
  min-width: 0;
}

.sidebar-user-meta strong {
  color: var(--text-strong);
  display: block;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-meta span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ================= Top bar ================= */
.topbar {
  align-items: center;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.breadcrumbs {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  font-weight: 500;
  gap: 6px;
}

.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--text); }
.breadcrumbs .sep { color: var(--muted-soft); }
.breadcrumbs strong { color: var(--text-strong); font-weight: 600; }

.topbar-spacer { flex: 1; }

.search {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
  padding: 6px 10px;
  width: 100%;
}

.search input {
  background: transparent;
  border: 0;
  flex: 1;
  font-size: 13px;
  padding: 4px 0;
}

.search input:focus { outline: 0; box-shadow: none; }

.search svg { color: var(--muted); flex-shrink: 0; height: 14px; width: 14px; }

.search-kbd {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 5px;
}

/* ================= Main / content ================= */
.main {
  margin: 0 auto;
  max-width: 1280px;
  opacity: 1;
  padding: 28px 32px 48px;
  transition: opacity 140ms ease;
  width: 100%;
}

.main.is-loading { opacity: 0.55; }

/* Consistent vertical rhythm between top-level sections inside .main.
 * Replaces inline class="u-mt-3" sprinkled across views. */
.main > section + section,
.main > .content-header + section,
.main > section + .panel,
.main > .panel + .panel,
.main > .panel + section { margin-top: 18px; }

.content-header {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 24px;
}

.content-header .eyebrow {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 500;
  gap: 8px;
  margin: 0 0 10px;
}
.content-header .eyebrow::before {
  background: var(--brand);
  content: "";
  height: 1px;
  width: 18px;
}

.content-header h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.content-header p.muted { font-size: 14px; line-height: 1.5; margin: 8px 0 0; max-width: 640px; }

.content-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-panel {
  display: none;
}

/* Generic eyebrow utility - matches the .content-header eyebrow look so any
 * page using <p class="eyebrow"> outside the content-header gets the same
 * small-rule + muted-text treatment. Replaces the old uppercase amber pill. */
.eyebrow {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 500;
  gap: 8px;
  margin: 0 0 10px;
}
.eyebrow::before {
  background: var(--brand);
  content: "";
  height: 1px;
  width: 18px;
}

.hero-status {
  align-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 500;
  gap: 8px;
  padding: 4px 12px;
}

.back-link {
  font-size: 13px;
  margin: 0 0 10px;
}
.back-link a {
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}
.back-link a:hover { color: var(--text-strong); }

.pulse-dot {
  background: var(--accent);
  border-radius: 50%;
  height: 6px;
  width: 6px;
}

/* ================= Panels / cards ================= */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.panel.u-panel-flush { padding: 0; }

.panel-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-header h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

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

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

/* ================= KPI grid ================= */
.kpi-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 20px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  padding: 18px 20px;
}

.kpi-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  margin: 0 0 10px;
}

.kpi-value {
  color: var(--text-strong);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0;
}

/* Sublabel sits at the bottom of the card and wraps to two lines if it
 * needs to - pinned with min-height so all sibling KPIs in a row line
 * their tops up regardless of label length. */
.kpi-sublabel {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin: 10px 0 0;
  min-height: 2.8em;
}

/* ================= Bar chart (risk) ================= */
.risk-distribution {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr auto;
}

.bar-chart {
  background: var(--line-soft);
  border-radius: var(--radius-pill);
  display: flex;
  height: 10px;
  overflow: hidden;
  width: 100%;
}

.bar-chart .seg { display: block; height: 100%; }
.bar-chart .seg.low      { background: #10b981; }
.bar-chart .seg.medium   { background: #f59e0b; }
.bar-chart .seg.high     { background: #ef4444; }
.bar-chart .seg.critical { background: #b91c1c; }

.legend {
  display: grid;
  gap: 6px;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
}

.legend-item {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 6px;
}

.legend-dot {
  border-radius: 999px;
  display: inline-block;
  height: 8px;
  width: 8px;
}

.legend-dot.low      { background: #10b981; }
.legend-dot.medium   { background: #f59e0b; }
.legend-dot.high     { background: #ef4444; }
.legend-dot.critical { background: #b91c1c; }

/* ================= Plans grid ================= */
.plans-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-top: 8px;
}

.plan-card {
  background: var(--panel);
  border: 1px solid transparent;
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(31, 27, 22, 0.04), 0 8px 24px -12px rgba(31, 27, 22, 0.12);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 26px 26px 24px;
  position: relative;
  transition: box-shadow 160ms ease, transform 160ms ease;
}
.plan-card:hover {
  box-shadow: 0 1px 2px rgba(31, 27, 22, 0.04), 0 16px 40px -16px rgba(31, 27, 22, 0.18);
  transform: translateY(-2px);
}
.plan-card.is-highlighted {
  border-color: var(--brand);
  box-shadow: 0 1px 2px rgba(234, 88, 12, 0.08), 0 16px 40px -12px rgba(234, 88, 12, 0.28);
}
.plan-card.is-inactive {
  opacity: 0.55;
}

/* "Most popular" ribbon - embedded into the top of the highlighted card. */
.plan-card-ribbon {
  background: var(--brand);
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 12px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -14px;
}

.plan-card-head { display: grid; gap: 4px; }
.plan-card-eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  margin: 0;
}
.plan-card-name {
  font-family: var(--font-serif);
  color: var(--text-strong);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.15;
  margin: 0;
}
.plan-card-description {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 4px 0 0;
}

.plan-card-price {
  align-items: baseline;
  display: flex;
  gap: 4px;
  margin: 2px 0;
}
.plan-card-price-amount {
  color: var(--text-strong);
  font-family: var(--font-serif);
  font-size: 40px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
}
.plan-card-price-suffix {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.plan-card-meta {
  border-bottom: 1px solid var(--line-soft);
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 14px;
  list-style: none;
  margin: 0;
  padding: 10px 0;
}

/* Admin-only yearly status line on /billing/plans cards. Lets the
 * operator see at a glance whether a plan has yearly billing wired
 * up without opening the editor. */
.plan-card-admin-yearly {
  margin: 0;
  font-size: 12px;
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
}
.plan-card-admin-yearly em { color: var(--muted-soft); font-style: italic; }
.plan-card-admin-yearly .muted { color: var(--muted); font-weight: 400; }

.plan-card-features {
  color: var(--text);
  display: grid;
  font-size: 13px;
  gap: 7px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.plan-card-features li {
  padding-left: 22px;
  position: relative;
}
.plan-card-features li::before {
  color: var(--brand);
  content: '✓';
  font-size: 14px;
  font-weight: 500;
  left: 2px;
  line-height: 1;
  position: absolute;
  top: 4px;
}

.plan-card-inactive-pill {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  left: 18px;
  padding: 3px 10px;
  position: absolute;
  top: -14px;
}

/* "Just saved" green flash also applies to plan cards. */
.plan-card.row-just-saved {
  background: #ecfdf5;
  transition: background 900ms ease;
}

/* Slide-over: two-column inputs row + nicer checkbox rows */
.slideover-body .form-grid-2 {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}
.slideover-body .form-grid-2 label { margin: 0; }
.slideover-body .checkbox-row {
  align-items: center;
  cursor: pointer;
  display: flex;
  font-weight: 500;
  gap: 10px;
}
.slideover-body .checkbox-row input { width: auto; }
.slideover-body textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  padding: 9px 11px;
  width: 100%;
  resize: vertical;
}

/* ================= Grid layouts ================= */
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

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

.split-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(280px, 380px) 1fr;
}

.stack { display: grid; gap: 16px; }

/* ================= Tabs ================= */
.tabs {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
}

.tabs a,
.tabs button,
.tabs button.is-active {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: -1px;
  padding: 10px 14px;
  text-decoration: none;
}

.tabs a:hover,
.tabs button:hover {
  background: transparent;
  color: var(--text-strong);
}

.tabs a.is-active,
.tabs button.is-active {
  background: transparent;
  border-bottom-color: var(--brand);
  color: var(--text-strong);
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* Inline count next to a tab label - replaces the parenthetical "(13)"
 * pattern with a small mono pill that reads as data, not punctuation. */
.tab-count {
  background: var(--panel-soft);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  margin-left: 6px;
  padding: 1px 7px;
}
.tabs .is-active .tab-count {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

/* ================= Forms ================= */
label {
  color: var(--text);
  display: grid;
  font-size: 13px;
  font-weight: 500;
  gap: 8px;
  margin: 0 0 16px;
}

input, select, textarea {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-input);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 9px 11px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.16);
  outline: 0;
}

/* App primary action - dark, like Stripe.  Marketing pages opt into the
 * amber primary explicitly via .marketing-cta-button. */
button, .button, .button-primary {
  background: var(--text-strong);
  border: 0;
  border-radius: var(--radius-btn);
  color: #fff;
  cursor: pointer;
  display: inline-block;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  text-decoration: none;
  transition: background 120ms ease;
}

button:hover, .button:hover, .button-primary:hover {
  background: var(--text);
  color: #fff;
  text-decoration: none;
}

button:disabled { cursor: wait; opacity: 0.6; }

.button-secondary {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
}

.button-secondary:hover { background: var(--panel-soft); border-color: var(--muted-soft); color: var(--text-strong); }

.button-muted {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--text);
}
.button-muted:hover { background: var(--line-soft); color: var(--text-strong); }

.button-ghost {
  background: transparent;
  color: var(--muted);
  padding: 6px 8px;
}
.button-ghost:hover { background: var(--panel-soft); color: var(--text-strong); }

.button-sm { font-size: 12px; padding: 6px 10px; }

/* Amber accent button - for one-off highlighted CTAs inside the app
 * (e.g. "Upgrade", "Buy now"). Use sparingly. */
.button-accent {
  background: var(--brand);
  color: #fff;
}
.button-accent:hover { background: var(--brand-strong); color: #fff; }

.full-width { width: 100%; }

/* ----- Inline form rows (label-on-top inputs + a button on the right) -----
   The button needs to sit on the input's baseline, not on the label-stack's
   centre. We do this by aligning the row to the bottom and adding a fake-label
   spacer height to the button so it visually descends to the input row. */
.customer-inline-form {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 18px;
}

.customer-inline-form .customer-inline-field {
  display: grid;
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  gap: 6px;
  margin: 0;
  min-width: 220px;
}

.customer-inline-form .customer-inline-field input {
  margin: 0;
}

.customer-inline-form > button {
  /* Match the input's height (9px+11px+9px ≈ 36px) so the button aligns */
  align-self: flex-end;
  height: 36px;
  padding-bottom: 0;
  padding-top: 0;
}

/* ================= Notices / toast ================= */
.notice {
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.notice-error   { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); }
.notice-success { background: #ecfdf5; border: 1px solid #a7f3d0; color: var(--ok); }
.notice-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: var(--info); }
.notice-warn    { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; }

.toast {
  background: var(--text-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  padding: 10px 14px;
  pointer-events: none;
  position: fixed;
  right: 24px;
  top: calc(var(--topbar-h) + 16px);
  transform: translateY(-6px);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 50;
}

.toast-visible { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--ok); }
.toast-error   { background: var(--danger); }

/* ================= Tables ================= */
table {
  border-collapse: collapse;
  font-size: 13px;
  width: 100%;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

tr:hover td { background: var(--panel-soft); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.table-wrap.u-table-flush { border: 0; }
.table-wrap.u-table-rounded { border-radius: var(--radius); }
.table-wrap table { border-radius: var(--radius-sm); }

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover { color: var(--text-strong); }

th.sortable .sort-arrow {
  color: var(--muted-soft);
  font-size: 9px;
  margin-left: 4px;
}

th.sortable.is-asc .sort-arrow,
th.sortable.is-desc .sort-arrow { color: var(--brand); }

/* ================= Pills / status ================= */
.status-pill {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--text);
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  text-transform: capitalize;
}

.status-pill.active    { background: #ecfdf5; border-color: #a7f3d0; color: var(--ok); }
.status-pill.trialing  { background: #eff6ff; border-color: #bfdbfe; color: var(--info); }
.status-pill.past_due  { background: #fefce8; border-color: #fde68a; color: #a16207; }
.status-pill.cancelled { background: var(--panel-soft); border-color: var(--line); color: var(--muted); }
.status-pill.received  { background: #eff6ff; border-color: #bfdbfe; color: var(--info); }
.status-pill.failed    { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.status-pill.connected { background: #ecfdf5; border-color: #a7f3d0; color: var(--ok); }
.status-pill.stale     { background: #fefce8; border-color: #fde68a; color: #a16207; }
.status-pill.success   { background: #ecfdf5; border-color: #a7f3d0; color: var(--ok); }
.status-pill.error     { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.status-pill.pending   { background: #fefce8; border-color: #fde68a; color: #a16207; }

.risk-pill {
  border-radius: var(--radius-pill);
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  text-transform: capitalize;
}

.risk-low      { background: #ecfdf5; color: #047857; }
.risk-medium   { background: #fffbeb; color: #b45309; }
.risk-high     { background: #fef2f2; color: #b91c1c; }
.risk-critical { background: #fee2e2; color: #7f1d1d; }

/* ================= Filter chips ================= */
.filter-bar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.chip:hover {
  background: var(--panel-soft);
  border-color: var(--muted-soft);
  color: var(--text-strong);
}

.chip.is-active {
  background: var(--text-strong);
  border-color: var(--text-strong);
  color: #fff;
}
.chip.is-active:hover {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

.local-search {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  margin-left: auto;
  max-width: 280px;
  padding: 6px 10px;
  width: 100%;
}

/* ================= Reasons (per-plugin reasoning) ================= */
.reasons {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.reason {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.reason-critical { border-left-color: var(--danger); }
.reason-warn     { border-left-color: var(--warn); }
.reason-notice   { border-left-color: #f59e0b; }
.reason-info     { border-left-color: var(--info); }

.reason-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.severity-pill {
  border-radius: var(--radius-pill);
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  text-transform: uppercase;
}

.severity-pill.critical { background: #fee2e2; color: #7f1d1d; }
.severity-pill.warn     { background: #fef3c7; color: #92400e; }
.severity-pill.notice   { background: #fff7ed; color: #c2410c; }
.severity-pill.info     { background: #dbeafe; color: #1e3a8a; }

.reason-title {
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 600;
}

.reason-evidence {
  background: var(--panel);
  border-left: 3px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  margin: 8px 0 6px;
  padding: 8px 10px;
}

.reason-action {
  color: var(--text);
  font-size: 12px;
  margin: 6px 0 0;
}

.reason-action strong { color: var(--text-strong); }

/* ================= Capabilities table ================= */
.capabilities-dl {
  display: grid;
  gap: 6px 16px;
  grid-template-columns: minmax(160px, max-content) 1fr;
  margin: 0;
}

.capabilities-dl dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  margin: 0;
}

.capabilities-dl dd { margin: 0; }

.capabilities-dl dd code { margin-right: 4px; }

/* ================= Plugin / scan detail ================= */
.changelog-pre {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-input);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  max-height: 380px;
  overflow: auto;
  padding: 12px 14px;
  white-space: pre-wrap;
}

.expandable summary {
  color: var(--text-strong);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 0;
}

.expandable summary:hover { color: var(--brand-strong); }

.expand-row {
  background: var(--panel-soft);
}

.expand-row td {
  padding: 14px 16px;
}

.row-toggle {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  width: 18px;
}

.row-toggle:hover { color: var(--text-strong); background: transparent; }

/* ================= Timeline ================= */
.timeline {
  display: grid;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline-item {
  border-bottom: 1px solid var(--line-soft);
  padding: 0;
}
.timeline-item:last-child { border-bottom: 0; }

/* Non-expandable row layout (no <details> wrapper): 3-column grid sits
 * directly on the <li>. */
.timeline-item:not(.is-expandable) {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: max-content 1fr max-content;
  padding: 12px 4px;
}
.timeline-item:last-child:not(.is-expandable) { padding-bottom: 8px; }

/* Expandable row: the <details>/<summary> takes over the 3-column grid.
 * Clicking anywhere on the summary toggles open, revealing the formatted
 * JSON context underneath. */
.timeline-item-details { width: 100%; }
.timeline-item-details > summary {
  align-items: center;
  cursor: pointer;
  display: grid;
  gap: 12px;
  grid-template-columns: max-content 1fr max-content;
  list-style: none;
  padding: 12px 4px;
  transition: background 100ms ease;
}
.timeline-item-details > summary::-webkit-details-marker { display: none; }
.timeline-item-details > summary::marker { content: ""; }
.timeline-item-details > summary:hover { background: var(--panel-soft); }
.timeline-item-details[open] > summary { background: var(--panel-soft); }

.timeline-item .when { color: var(--muted); font-size: 12px; }
.timeline-item .what strong { color: var(--text-strong); display: block; font-size: 13px; }
.timeline-item .what small { color: var(--muted); display: block; font-size: 12px; }

.timeline-context {
  background: var(--panel-soft);
  border-top: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
  max-height: 320px;
  overflow: auto;
  padding: 14px 18px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ================= Empty state ================= */
.empty-state {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 48px 24px;
  text-align: center;
}

.empty-state svg {
  color: var(--muted-soft);
  height: 40px;
  width: 40px;
}

.empty-state h3 { color: var(--text-strong); }

/* "No matches" - shown by JS when client-side filters hide every row.
 * Quieter than the server-rendered empty-state because the data exists,
 * the user just over-filtered. */
.empty-filtered-cell { padding: 0; background: var(--panel); }
.empty-filtered {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 40px 24px;
  text-align: center;
}
.empty-filtered p { margin: 0; }
.empty-filtered p:first-child {
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 500;
}
.empty-filtered p.muted { font-size: 13px; }
.empty-filtered-li { list-style: none; }

/* ================= Quick grid (dashboard sub-nav) ================= */
.quick-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.quick-grid a {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-strong);
  display: block;
  font-size: 13px;
  font-weight: 500;
  padding: 14px;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease;
}

.quick-grid a:hover {
  background: var(--panel-soft);
  border-color: var(--muted-soft);
  color: var(--text-strong);
  text-decoration: none;
}

/* ================= Actions / utilities ================= */
.actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.inline-actions {
  align-items: center;
  display: flex;
  gap: 6px;
}

.inline-actions form { margin: 0; }

.compact-select { min-width: 130px; padding: 6px 10px; }

.metric { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.05; margin: 0; color: var(--text-strong); }
.metric-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.metric-card .muted { font-size: 12px; font-weight: 500; margin-bottom: 6px; }

.relative-time { color: var(--muted); font-size: 12px; }

.dot-sep { color: var(--muted-soft); margin: 0 6px; }

.kbd {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 5px;
}

.code-block {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-input);
  font-family: var(--font-mono);
  font-size: 11px;
  max-height: 280px;
  overflow: auto;
  padding: 10px 12px;
  white-space: pre-wrap;
}

.attention-list {
  display: grid;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}

.attention-list li {
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr max-content max-content max-content;
  padding: 14px 0;
}
.attention-list li:first-child { padding-top: 4px; }
.attention-list li:last-child { border-bottom: 0; padding-bottom: 4px; }

.attention-list .site-name {
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
}
.attention-list .site-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

/* ================= Diff list (scan detail) ================= */
.diff-list {
  display: grid;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.diff-list li {
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: grid;
  gap: 10px;
  grid-template-columns: max-content 1fr max-content;
  padding: 8px 12px;
}

.diff-list li.added { border-left: 3px solid var(--ok); }
.diff-list li.removed { border-left: 3px solid var(--danger); }
.diff-list li.upgraded { border-left: 3px solid var(--info); }
.diff-list li.downgraded { border-left: 3px solid var(--warn); }

.diff-tag {
  background: var(--panel);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
}

.diff-tag.added { color: var(--ok); }
.diff-tag.removed { color: var(--danger); }
.diff-tag.upgraded { color: var(--info); }
.diff-tag.downgraded { color: var(--warn); }

/* ================= Responsive ================= */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .split-layout { grid-template-columns: 1fr; }
  .risk-distribution { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    flex-wrap: wrap;
    min-height: auto;
    padding: 12px 16px;
    position: static;
    width: auto;
  }
  .side-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
  }
  .sidebar-footer { border-top: 0; margin: 0; padding: 0; }
  .nav-section { display: none; }
  .app-content { grid-column: auto; }
  .main { padding: 16px; }
  .topbar { padding: 0 16px; }
  .search { max-width: 200px; }
}

/* ===== Slide-over panel ===== */

.slideover-open { overflow: hidden; }

.slideover-overlay {
  inset: 0;
  position: fixed;
  z-index: 10000;
  pointer-events: none;
}

.slideover-backdrop {
  background: rgba(15, 12, 8, 0.42);
  inset: 0;
  opacity: 0;
  position: absolute;
  pointer-events: auto;
  transition: opacity 220ms ease;
}

.slideover-overlay.is-open .slideover-backdrop {
  opacity: 1;
}

.slideover-panel {
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px -20px rgba(31, 27, 22, 0.30);
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 480px;
  pointer-events: auto;
  position: absolute;
  right: 0;
  top: 0;
  transform: translateX(100%);
  transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
}

.slideover-overlay.is-open .slideover-panel {
  transform: translateX(0);
}

.slideover-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-shrink: 0;
  gap: 12px;
  justify-content: space-between;
  padding: 20px 24px;
}

.slideover-head h2 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  margin: 0;
}

.slideover-close {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 22px;
  height: 32px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: background 140ms ease, color 140ms ease;
  width: 32px;
}

.slideover-close:hover {
  background: var(--panel-soft);
  color: var(--text-strong);
}

.slideover-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding: 24px;
}

.slideover-body form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
}

.slideover-body label {
  color: var(--text);
  display: grid;
  font-size: 13px;
  font-weight: 500;
  gap: 8px;
  margin: 0;
}

.slideover-body input,
.slideover-body select,
.slideover-body textarea {
  font-size: 14px;
  padding: 10px 12px;
}

.slideover-body .form-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin: -8px 0 0;
}

.slideover-footer {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 16px;
}

.slideover-footer button {
  font-size: 13px;
  padding: 9px 16px;
}

/* Inside the slideover, ghost buttons get a clear outlined treatment
 * so they're visually distinct from the dark primary submit button. */
.slideover-footer .button-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-strong);
}
.slideover-footer .button-ghost:hover {
  background: var(--panel-soft);
  border-color: var(--muted-soft);
  color: var(--text-strong);
}

/* ===== Generic clickable-row affordance ===== */

.table-clickable tbody tr {
  cursor: pointer;
  transition: background 140ms ease;
}

.table-clickable tbody tr:hover {
  background: var(--line-soft);
}

.table-clickable tbody tr td:last-child::after {
  color: var(--muted);
  content: '›';
  display: inline-block;
  font-weight: 600;
  margin-left: 8px;
  opacity: 0;
  transition: opacity 140ms ease, transform 140ms ease;
}

.table-clickable tbody tr:hover td:last-child::after {
  opacity: 0.9;
  transform: translateX(2px);
}

/* ===== Customer show page ===== */

.customer-show-header {
  margin-bottom: 18px;
}

.customer-show-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1.4fr;
  margin-bottom: 16px;
}

@media (max-width: 720px) {
  .customer-show-grid { grid-template-columns: 1fr; }
}

.customer-show-sub {
  align-items: center;
  display: flex;
  gap: 6px;
  font-size: 14px;
  margin: 0;
}

.customer-show-sites {
  display: grid;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}
.customer-show-sites li {
  align-items: center;
  border-top: 1px solid var(--line-soft);
  display: flex;
  font-size: 13px;
  gap: 12px;
  justify-content: space-between;
  padding: 10px 0;
}
.customer-show-sites li:first-child { border-top: 0; }
.customer-show-site-url {
  font-family: var(--font-mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-pre {
  border-radius: var(--radius-input);
  font-family: var(--font-mono);
  font-size: 13px;
  margin: 8px 0 0;
  overflow: auto;
  padding: 14px 18px;
  user-select: all;
  word-break: break-all;
}
.code-pre-dark {
  background: #1f1b16;
  color: #fde68a;
}
.code-pre-brand {
  background: #1f1b16;
  color: #fed7aa;
}

.panel-callout {
  border-radius: 14px;
  margin-bottom: 16px;
}
.panel-callout-brand {
  background: var(--brand-soft);
  border: 1px solid var(--brand);
  border-width: 0 0 0 3px;
  border-radius: 0 14px 14px 0;
}

.panel-deprecated {
  background: var(--panel-soft);
  border-color: var(--line);
  opacity: 0.7;
}

/* Consistent panel rhythm: all panels in the show page sit at the same width
   and share vertical spacing. */
.customer-show-header + .panel,
.panel + .panel,
.customer-show-grid + .panel,
.panel + .panel-deprecated {
  margin-top: 16px;
}

/* Row "just saved" flash after a slide-over save patches it. */
.table-clickable tbody tr.row-just-saved {
  background: #ecfdf5;
  transition: background 900ms ease;
}

/* ===== Inbox / pills shared between admin + marketing =====
 * These were originally defined in marketing.css but are used by
 * operator pages (e.g. /pilot-deck/inbox) so they live here. */
.pill {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  text-transform: capitalize;
}
.pill-new      { background: var(--brand-soft); color: var(--brand-strong); border-color: var(--brand); }
.pill-read     { background: var(--panel-soft); color: var(--muted); }
.pill-archived { background: var(--panel-soft); color: var(--muted-soft); }
.pill-ok       { background: #ecfdf5; color: var(--ok); border-color: #a7f3d0; }
.pill-warn     { background: #fef3c7; color: var(--warn); border-color: #fde68a; }

.row-new td { background: var(--brand-soft); }
.row-new td:first-child { border-left: 3px solid var(--brand); }
.cell-preview details summary { cursor: pointer; color: var(--text); }
.cell-preview details summary::-webkit-details-marker { display: none; }
.cell-preview .message-body {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-input);
  font-size: 13px;
  margin-top: 8px;
  padding: 10px 12px;
  white-space: pre-wrap;
}
.cell-actions { white-space: nowrap; }

/* Section heading inside a form/panel - replaces uppercase eyebrow pattern. */
.form-section-heading {
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 600;
  margin: 22px 0 10px;
}
.form-section-heading:first-child { margin-top: 4px; }

/* ===== AJAX page-transition fade ===== */

#app-main {
  transition: opacity 140ms ease, transform 140ms ease;
}

#app-main.is-navigating {
  opacity: 0.3;
  transform: translateY(4px);
}

/* ================= Site-content editor =================
 * Two-column layout: section nav on the left, the editor for the
 * active section on the right. Each section is a fresh GET so the
 * operator can deep-link to a specific page (Home, Pricing, etc.).
 */
.pp-content-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: start;
  margin-top: 8px;
}

/* Sidebar nav */
.pp-content-nav {
  position: sticky;
  top: 76px;        /* clear of the fixed app topbar */
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.pp-content-nav-group {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 8px 8px 4px;
}
.pp-content-nav-group:first-child { margin-top: 2px; }
.pp-content-nav-link {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}
.pp-content-nav-link:hover {
  background: var(--panel-soft);
  color: var(--text-strong);
  text-decoration: none;
}
.pp-content-nav-link.is-active {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

/* Right-side editor */
.pp-content-main {
  min-width: 0;
}
.pp-content-section-head {
  margin-bottom: 18px;
}
.pp-content-section-head h2 {
  font-size: 22px;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.pp-content-section-head .muted { margin: 0; font-size: 14px; }
.pp-content-section-head .muted a { color: var(--brand-strong); font-weight: 600; }

/* One fieldset per block (scalar or JSON). Visually separates the
 * blocks within a section without making the whole thing feel like
 * a forest of cards. */
.pp-content-form .pp-content-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 0 0 14px;
  background: var(--panel);
}
.pp-content-form .pp-content-block legend {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-strong);
}
.pp-content-block-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--panel-soft);
  padding: 1px 6px;
  border-radius: 4px;
}
.pp-content-block-hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

/* Fields: label + input pair (.pp-field is the wrapper) */
.pp-field {
  display: block;
  margin: 10px 0 0;
}
.pp-field:first-of-type { margin-top: 4px; }
.pp-field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.pp-field input[type="text"],
.pp-field input[type="email"],
.pp-field textarea {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font: inherit;
  font-weight: 400;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.pp-field textarea { resize: vertical; min-height: 64px; font-family: inherit; }
.pp-field-hint {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

/* Image-block field: preview + file input + optional clear checkbox. */
.pp-image-field { display: grid; gap: 12px; margin-top: 4px; }
.pp-image-preview {
  margin: 0;
  padding: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  max-width: 360px;
}
.pp-image-preview img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}
.pp-image-clear {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.pp-image-field input[type="file"] {
  display: block;
  font: inherit;
  font-size: 13px;
  padding: 6px 0;
}

/* Object-block fields stack tightly */
.pp-content-fields { display: grid; gap: 8px; }

/* List-block rows (add/remove) */
.pp-content-rows { display: grid; gap: 10px; margin: 4px 0 8px; }
.pp-content-row {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}
.pp-content-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.pp-content-actions {
  margin: 18px 0 40px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.pp-content-preview {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}
.pp-content-preview:hover { color: var(--brand-strong); }

@media (max-width: 880px) {
  .pp-content-shell { grid-template-columns: 1fr; }
  .pp-content-nav { position: static; }
}

/* ===== Generic confirm modal =====
 *
 * Used by pp.confirm() in app.js to replace native window.confirm().
 * Available on every layout (operator + portal) because app.css is
 * loaded everywhere.
 *
 * Markup the JS builds:
 *   .pp-modal-overlay
 *     .pp-modal[role=dialog]
 *       .pp-modal-head      <h3> + close ×
 *       .pp-modal-body      <p>message</p>
 *       .pp-modal-foot      cancel + confirm buttons
 */
.pp-modal-overlay {
  align-items: center;
  background: rgba(15, 12, 8, 0.5);
  display: flex;
  inset: 0;
  justify-content: center;
  opacity: 0;
  padding: 24px;
  position: fixed;
  transition: opacity 200ms ease;
  z-index: 10000;
}
.pp-modal-overlay.is-open { opacity: 1; }
.pp-modal-overlay.is-open .pp-modal {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.pp-modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(31, 27, 22, 0.06), 0 24px 64px -16px rgba(31, 27, 22, 0.30);
  display: flex;
  flex-direction: column;
  max-width: 460px;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 220ms ease, transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
}

.pp-modal-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 20px 24px;
}
.pp-modal-head h3 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.2;
  margin: 0;
}
.pp-modal-close {
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 22px;
  height: 32px;
  line-height: 1;
  padding: 0;
  width: 32px;
}
.pp-modal-close:hover {
  background: var(--panel-soft);
  color: var(--text-strong);
}

.pp-modal-body {
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  padding: 20px 24px;
}
.pp-modal-body p { margin: 0 0 10px; }
.pp-modal-body p:last-child { margin-bottom: 0; }
.pp-modal-body strong { color: var(--text-strong); }

.pp-modal-foot {
  align-items: center;
  background: var(--panel-soft);
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 24px;
}
/* Confirm button defaults to the app's dark primary; pass intent:'danger'
 * to pp.confirm() to get the red destructive variant. */
.pp-modal-foot .pp-modal-confirm {
  background: var(--text-strong);
  color: #fff;
}
.pp-modal-foot .pp-modal-confirm:hover { background: var(--text); color: #fff; }
.pp-modal-foot .pp-modal-confirm-danger {
  background: var(--danger);
}
.pp-modal-foot .pp-modal-confirm-danger:hover { background: #991b1b; }
.pp-modal-foot .pp-modal-cancel {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-strong);
}
.pp-modal-foot .pp-modal-cancel:hover {
  background: var(--panel);
  border-color: var(--muted-soft);
}

/* Lock body scroll while a confirm is open. */
.pp-modal-open { overflow: hidden; }

/* ===== Perimeter glow primitive =====
 *
 * Makes a rounded card grow a glowing ring around its full border while
 * an action is in flight, then briefly tint the ring green when done.
 *
 * Apply one of these state classes to any element that has
 * position:relative and a solid background (the rules below set both):
 *
 *   .pp-busy        amber light sweeps around the border (looping)
 *   .pp-busy-done   green chase sweeps once, then a solid green ring
 *                   fades in on a second layer and holds
 *   .pp-busy-error  same chase-then-fill pattern in red, plays once
 *
 * Implementation: an absolutely-positioned ::before sits BEHIND the
 * element, slightly larger on every side, painting a rotating conic
 * gradient. A mask blanks out the inside so only the rim is visible.
 *
 *   .pp-busy-done also adds an ::after layer carrying the solid ring
 *   that fades in as the ::before chase fades out - two layers + opacity
 *   is the only reliable way to cross-fade from a moving gradient to a
 *   static one across browsers.
 *
 * @property is used so the gradient angle can interpolate smoothly via
 * CSS animation. Browsers without @property fall back to a static ring
 * (the visual is still recognisable, just less alive).
 */
@property --pp-glow-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

@keyframes pp-perimeter-spin {
  to { --pp-glow-angle: 360deg; }
}

/* Drives one full rotation of the chase layer for the done/error states. */
@keyframes pp-perimeter-success-spin {
  to { --pp-glow-angle: 360deg; }
}

/* Lockstep cross-fade between the chase layer and the solid ring. */
@keyframes pp-perimeter-success-chase-out {
  0%, 60% { opacity: 1; }
  100%    { opacity: 0; }
}
@keyframes pp-perimeter-success-fill {
  0%, 60% { opacity: 0; }
  100%    { opacity: 1; }
}

.pp-busy::before,
.pp-busy-done::before,
.pp-busy-done::after,
.pp-busy-error::before,
.pp-busy-error::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  padding: 3px;
  pointer-events: none;
  z-index: -1;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
          mask-composite: exclude;
}

.pp-busy,
.pp-busy-done,
.pp-busy-error {
  position: relative;
  isolation: isolate;
}

.pp-busy::before {
  background: conic-gradient(
    from var(--pp-glow-angle, 0deg),
    transparent 0%,
    rgba(234, 88, 12, 0.0) 5%,
    rgba(234, 88, 12, 0.6) 18%,
    var(--brand) 28%,
    var(--brand-strong) 32%,
    var(--brand) 36%,
    rgba(234, 88, 12, 0.55) 46%,
    transparent 60%,
    transparent 100%
  );
  opacity: 1;
  animation: pp-perimeter-spin 1.8s linear infinite;
  filter: drop-shadow(0 0 4px rgba(234, 88, 12, 0.45));
}

.pp-busy-done::before {
  background: conic-gradient(
    from var(--pp-glow-angle, 0deg),
    transparent 0%,
    rgba(16, 185, 129, 0.6) 18%,
    #059669 28%,
    #10b981 35%,
    rgba(16, 185, 129, 0.55) 46%,
    transparent 60%,
    transparent 100%
  );
  animation:
    pp-perimeter-success-spin       900ms linear forwards,
    pp-perimeter-success-chase-out 1400ms ease-out forwards;
  filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.5));
}
.pp-busy-done::after {
  background: #10b981;
  opacity: 0;
  animation: pp-perimeter-success-fill 1400ms ease-out forwards;
  filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.4));
}

.pp-busy-error::before {
  background: conic-gradient(
    from var(--pp-glow-angle, 0deg),
    transparent 0%,
    rgba(220, 38, 38, 0.6) 18%,
    #b91c1c 28%,
    #dc2626 35%,
    rgba(220, 38, 38, 0.55) 46%,
    transparent 60%,
    transparent 100%
  );
  animation:
    pp-perimeter-success-spin       900ms linear forwards,
    pp-perimeter-success-chase-out 1400ms ease-out forwards;
  filter: drop-shadow(0 0 4px rgba(220, 38, 38, 0.5));
}
.pp-busy-error::after {
  background: #dc2626;
  opacity: 0;
  animation: pp-perimeter-success-fill 1400ms ease-out forwards;
  filter: drop-shadow(0 0 4px rgba(220, 38, 38, 0.4));
}

@media (prefers-reduced-motion: reduce) {
  .pp-busy::before {
    animation: none;
    background: var(--brand);
    opacity: 0.6;
  }
  .pp-busy-done::before,
  .pp-busy-error::before { display: none; }
  .pp-busy-done::after { animation: none; opacity: 0.85; background: #10b981; }
  .pp-busy-error::after { animation: none; opacity: 0.85; background: #dc2626; }
}
