/*
 * The whole design system, in one file. To re-theme a product, change the variables in :root (and the dark block).
 * No inline styles anywhere: the Content-Security-Policy is style-src 'self'.
 * Contrast: text/background pairs below meet WCAG AA (4.5:1) in both schemes.
 */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #16181d;
  --text-soft: #4a505c;
  --text-muted: #5f6673;
  --border: #d5d9e0;
  --accent: #1f4fd8;
  --accent-text: #ffffff;
  --accent-soft: #e6ecfd;
  --good: #0f6b3a;
  --good-soft: #e3f4ea;
  --warn: #7a4b00;
  --warn-soft: #fdf0d5;
  --bad: #a4161a;
  --bad-soft: #fde8e8;
  --focus: #b3470f;
  --radius: 8px;
  --gap: 16px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar: 248px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 12px rgb(0 0 0 / 5%);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --surface: #1a1d24;
    --surface-2: #232730;
    --text: #eceef2;
    --text-soft: #c1c6d0;
    --text-muted: #a3a9b6;
    --border: #353a46;
    --accent: #8fb0ff;
    --accent-text: #0c1430;
    --accent-soft: #1f2a4a;
    --good: #7fd6a4;
    --good-soft: #17301f;
    --warn: #f1c26b;
    --warn-soft: #33290f;
    --bad: #ff9a9a;
    --bad-soft: #3a1a1b;
    --focus: #ffb37a;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
h1 { font-size: 1.75rem; line-height: 1.2; }
h2 { font-size: 1.2rem; line-height: 1.3; }
h3 { font-size: 1.05rem; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
img, svg { max-width: 100%; }

/* One focus style everywhere, never removed. */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--surface); color: var(--text); padding: 10px 14px; border: 2px solid var(--focus); border-radius: var(--radius); }
.skip:focus { top: 8px; }

.soft { color: var(--text-soft); }
.muted { color: var(--text-muted); }
.small { font-size: 0.875rem; }
.num { font-variant-numeric: tabular-nums; }
.done { text-decoration: line-through; color: var(--text-muted); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stack { display: flex; flex-direction: column; gap: var(--gap); }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.end { align-items: flex-end; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--gap); }

/* ---- controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.1); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.btn-danger:hover { background: var(--bad); filter: brightness(1.1); }
.btn-small { min-height: 36px; padding: 4px 12px; font-size: 0.9rem; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.field small { font-weight: 400; }
.input { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; font-weight: 400; }
.input[readonly] { background: var(--surface-2); }
.input-small { min-height: 36px; padding: 4px 8px; width: auto; }
textarea.input { resize: vertical; }

.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: 0.82rem; font-weight: 600; text-transform: capitalize; }
.tag-good { background: var(--good-soft); color: var(--good); }
.badge { display: inline-block; min-width: 22px; margin-left: 8px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 0.8rem; font-weight: 700; text-align: center; }

.msg { padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.msg-warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.msg-bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.msg-good { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.msg-info { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.msg a { color: inherit; font-weight: 600; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.panel-danger { border-color: var(--bad); }
.panel > h2 { margin-bottom: 4px; }
.empty { text-align: center; padding: 48px 20px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--text-muted); padding: 24px 0; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } * { scroll-behavior: auto !important; transition: none !important; } }

.list > li { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.list > li.is-unread { border-left: 4px solid var(--accent); padding-left: 12px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 16px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table caption { text-align: left; font-weight: 600; padding-bottom: 8px; }
.table th, .table td { text-align: left; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 0.85rem; color: var(--text-muted); }
.table .num { text-align: right; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn { margin-left: 6px; }

.meter-head { display: flex; justify-content: space-between; gap: 12px; font-size: 0.92rem; }
.meter progress { width: 100%; height: 8px; margin-top: 4px; accent-color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--gap); margin: 12px 0; }
.stats dt { color: var(--text-muted); font-size: 0.85rem; }
.stats dd { font-size: 1.6rem; font-weight: 700; }

/* ---- toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--text); color: var(--bg); box-shadow: var(--shadow); }
.toast-bad { background: var(--bad); color: var(--surface); }
.toast-close { margin-left: auto; min-width: 28px; min-height: 28px; border: 0; background: transparent; color: inherit; font-size: 1.2rem; line-height: 1; cursor: pointer; }

/* ---- brand */
.lockup { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.lockup small { color: var(--text-muted); font-weight: 400; }
.mark { width: 28px; height: 28px; flex: none; }
.mark rect { fill: var(--accent); }
.mark path { fill: none; stroke: var(--accent-text); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---- signed-in shell */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.topbar { display: none; }
.sidebar { display: flex; flex-direction: column; gap: 20px; padding: 20px 16px; background: var(--surface); border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; min-height: 44px; padding: 8px 12px; border-radius: var(--radius); color: var(--text); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current='page'] { background: var(--accent-soft); color: var(--text); font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.content { padding: 32px; display: flex; flex-direction: column; gap: 20px; max-width: 1100px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }
.narrow { max-width: 520px; display: flex; flex-direction: column; gap: var(--gap); }
.plain-page { max-width: 520px; margin: 0 auto; padding: 56px 20px; display: flex; flex-direction: column; gap: var(--gap); }

@media (max-width: 860px) {
  .shell { display: block; }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
  .sidebar { display: none; position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar.is-open { display: flex; }
  .sidebar-brand { display: none; }
  .content { padding: 20px 16px 88px; }
  h1 { font-size: 1.45rem; }
  .table .actions { white-space: normal; }
}

/* ---- plans */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--gap); }
.plan { display: flex; flex-direction: column; gap: 10px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.plan.is-current { border: 2px solid var(--accent); }
.price { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.price small { font-size: 0.95rem; font-weight: 400; color: var(--text-muted); }
.ticks { display: flex; flex-direction: column; gap: 6px; }
.ticks li { padding-left: 22px; position: relative; }
.ticks li::before { content: ''; position: absolute; left: 2px; top: 0.5em; width: 10px; height: 5px; border-left: 2px solid var(--good); border-bottom: 2px solid var(--good); transform: rotate(-45deg); }
.plan-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }

/* ---- public pages */
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
main.container { display: flex; flex-direction: column; gap: 48px; padding-top: 48px; padding-bottom: 72px; }
main.container.prose { max-width: 760px; gap: 16px; }
.prose h2 { margin-top: 16px; }
.prose ul { list-style: disc; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.site-head { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-head-in, .site-foot-in { display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.site-nav { display: flex; align-items: center; gap: 4px 18px; flex-wrap: wrap; }
.site-nav a:not(.btn) { display: inline-flex; align-items: center; min-height: 44px; color: var(--text); }
.site-foot { border-top: 1px solid var(--border); background: var(--surface); color: var(--text-soft); font-size: 0.92rem; }
.hero { display: flex; flex-direction: column; gap: 16px; max-width: 720px; padding: 24px 0; }
.hero h1 { font-size: clamp(1.9rem, 5vw, 3rem); }
.lead { font-size: 1.15rem; color: var(--text-soft); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--gap); }
.faq { display: flex; flex-direction: column; gap: 18px; }
.faq dt { font-weight: 700; }
.faq dd { color: var(--text-soft); }

/* ---- Identity Studio screens */
.row.center { justify-content: center; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.fieldset legend { font-weight: 600; padding: 0 6px; }
.colour-field { flex-direction: row; align-items: center; gap: 10px; }
.colour { width: 48px; height: 44px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.kit-picker { max-width: 360px; }
.kit-card { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.preview { display: block; max-width: 100%; max-height: 78vh; width: auto; height: auto; margin: 0 auto; border: 1px solid var(--border); border-radius: 4px; background: repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%) 0 0 / 20px 20px; }
.preview-thumb { width: 120px; height: 120px; margin: 0; object-fit: contain; }
.preview-missing { padding: 24px; text-align: center; }
.preview-panel { display: flex; align-items: flex-start; justify-content: center; min-height: 240px; }
.graphics { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex: none; border: 1px solid var(--border); }
.avatar-empty { display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-soft); font-weight: 700; }
.steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: step; }
.steps > li { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; counter-increment: step; }
.steps > li::before { content: counter(step); display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); color: var(--text); font-weight: 700; flex: none; }
.steps > li.is-done::before { content: '\2713'; background: var(--good-soft); color: var(--good); }
.steps > li.is-done > span { color: var(--text-muted); }
.next-fixture { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 20px; align-items: start; }
.next-fixture .preview { max-height: 280px; }
.examples { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--gap); list-style: none; padding: 0; align-items: start; }
.examples img { width: 100%; height: auto; border: 1px solid var(--border); border-radius: 4px; }
.examples figcaption { font-size: 0.88rem; color: var(--text-muted); padding-top: 6px; }
.example-note { border-left: 4px solid var(--accent); padding: 8px 14px; background: var(--accent-soft); color: var(--text); border-radius: 0 var(--radius) var(--radius) 0; }
@media (max-width: 860px) {
  .graphics, .next-fixture { grid-template-columns: 1fr; }
}
