/* css/saas.css
 *
 * Shared styling for the SaaS surface: the public pricing/signup pages and the
 * per-tenant admin screens (onboarding, billing, team, domains, health).
 *
 * One stylesheet rather than a <style> block per page, because these thirteen
 * pages are the same product and drifting apart is what makes a SaaS admin feel
 * assembled from parts. It reuses the variables declared in admin.css where that
 * is loaded, and re-declares them here so the public pages can be styled without
 * pulling in the whole admin sheet.
 */

:root {
  --orange: #f97316;
  --orange-dark: #ea580c;
  --orange-light: #fff7ed;
  --red: #e8380d;
  --red-light: #fef2f2;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --white: #fff;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --blue: #3b82f6;
  --blue-light: #eff6ff;
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body.saas {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--slate-50);
  color: var(--slate-900);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

a { color: var(--orange-dark); }

/* ── Layout ──────────────────────────────────────────────────────────────── */

.saas-wrap { max-width: 1080px; margin: 0 auto; padding: 32px 24px 96px; }
.saas-wrap.narrow { max-width: 620px; }
.saas-wrap.wide { max-width: 1240px; }

.saas-nav {
  display: flex; align-items: center; gap: 20px;
  padding: 16px 24px; background: var(--white);
  border-bottom: 1px solid var(--slate-200);
  position: sticky; top: 0; z-index: 20;
}
.saas-nav .brand {
  font-weight: 900; font-size: 17px; letter-spacing: -0.4px;
  color: var(--slate-900); text-decoration: none;
}
.saas-nav .brand span {
  display: inline-grid; place-items: center; width: 24px; height: 24px;
  margin-right: 8px; border-radius: 7px; background: var(--orange);
  color: #fff; font-size: 14px; vertical-align: -5px;
}
.saas-nav a.nav-link {
  color: var(--slate-700); text-decoration: none; font-size: 14px; font-weight: 600;
}
.saas-nav a.nav-link:hover { color: var(--orange-dark); }
.saas-nav .spacer { margin-left: auto; }

.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.6px; }
.page-head p { color: var(--slate-500); font-size: 14.5px; margin-top: 6px; max-width: 68ch; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { margin-left: auto; }

/* ── Cards ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--white); border: 1px solid var(--slate-200);
  border-radius: var(--radius); padding: 20px;
}
.card + .card { margin-top: 16px; }
.card h2 { font-size: 16px; font-weight: 800; }
.card h3 { font-size: 14.5px; font-weight: 700; }
.card .sub { color: var(--slate-500); font-size: 13.5px; margin-top: 4px; }
.card.tight { padding: 14px 16px; }
.card.accent { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-light); }

.metric { font-size: 24px; font-weight: 800; letter-spacing: -0.6px; }
.metric-label { color: var(--slate-500); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border: none; border-radius: var(--radius-sm);
  background: var(--orange); color: #fff; font-weight: 700; font-size: 14px;
  font-family: inherit; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--orange-dark); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.ghost { background: var(--slate-100); color: var(--slate-700); }
.btn.ghost:hover { background: var(--slate-200); }
.btn.danger { background: var(--red); }
.btn.small { padding: 7px 13px; font-size: 13px; }
.btn.block { width: 100%; }

/* ── Forms ───────────────────────────────────────────────────────────────── */

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--slate-700); }
.field .hint { font-size: 12.5px; color: var(--slate-500); margin-top: 5px; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--slate-200); border-radius: var(--radius-sm);
  background: var(--white); color: var(--slate-900);
}
.input:focus { outline: 2px solid var(--orange); outline-offset: -1px; }
textarea.input { min-height: 120px; resize: vertical; }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }

/* ── Status ──────────────────────────────────────────────────────────────── */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: var(--slate-100); color: var(--slate-700);
}
.pill.ok { background: var(--green-light); color: var(--green); }
.pill.warn { background: var(--amber-light); color: var(--amber); }
.pill.bad { background: var(--red-light); color: var(--red); }
.pill.info { background: var(--blue-light); color: var(--blue); }

.notice {
  padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px;
  background: var(--slate-100); color: var(--slate-700); border: 1px solid var(--slate-200);
}
.notice.ok { background: var(--green-light); border-color: #bbf7d0; color: #15803d; }
.notice.warn { background: var(--amber-light); border-color: #fde68a; color: #b45309; }
.notice.bad { background: var(--red-light); border-color: #fecaca; color: #b91c1c; }
.notice.hidden { display: none; }
.notice + .notice, .notice + .card, .card + .notice { margin-top: 14px; }

.muted { color: var(--slate-500); font-size: 13px; }
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; background: var(--slate-100);
  padding: 2px 6px; border-radius: 5px; word-break: break-all;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; padding: 9px 10px; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px; color: var(--slate-500);
  border-bottom: 1px solid var(--slate-200);
}
table.data td { padding: 11px 10px; border-bottom: 1px solid var(--slate-100); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }

/* ── Usage meters ────────────────────────────────────────────────────────── */

.meter { height: 6px; border-radius: 999px; background: var(--slate-200); overflow: hidden; margin-top: 8px; }
.meter > span { display: block; height: 100%; background: var(--green); }
.meter.warn > span { background: var(--amber); }
.meter.bad > span { background: var(--red); }

/* ── Pricing ─────────────────────────────────────────────────────────────── */

.plans { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); align-items: start; }
.plan { background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--radius); padding: 24px; }
.plan.featured { border-color: var(--orange); box-shadow: 0 8px 30px rgba(249, 115, 22, 0.13); }
.plan .name { font-size: 15px; font-weight: 800; }
.plan .price { font-size: 34px; font-weight: 900; letter-spacing: -1.4px; margin: 10px 0 2px; }
.plan .price small { font-size: 14px; font-weight: 600; color: var(--slate-500); letter-spacing: 0; }
.plan ul { list-style: none; margin: 18px 0; display: grid; gap: 9px; }
.plan li { font-size: 13.5px; color: var(--slate-700); padding-left: 22px; position: relative; }
.plan li::before {
  content: '✓'; position: absolute; left: 0; top: -1px;
  color: var(--green); font-weight: 800;
}

/* ── Wizard ──────────────────────────────────────────────────────────────── */

.steps { display: grid; gap: 10px; }
.step {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--white); border: 1px solid var(--slate-200);
  border-radius: var(--radius); padding: 16px 18px; cursor: pointer;
}
.step[aria-current='step'] { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-light); }
.step .dot {
  flex: 0 0 24px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 800;
  background: var(--slate-100); color: var(--slate-500);
}
.step.done .dot { background: var(--green); color: #fff; }
.step .title { font-weight: 700; font-size: 14.5px; }
.step .why { color: var(--slate-500); font-size: 13px; margin-top: 3px; }
.step-body { margin-top: 12px; }
.step-body[hidden] { display: none; }

/* ── Legal / prose ───────────────────────────────────────────────────────── */

.prose { max-width: 76ch; }
.prose h2 { font-size: 18px; font-weight: 800; margin: 30px 0 8px; }
.prose h3 { font-size: 15px; font-weight: 700; margin: 22px 0 6px; }
.prose p, .prose li { font-size: 14.5px; color: var(--slate-700); }
.prose p { margin-bottom: 12px; }
.prose ul, .prose ol { margin: 0 0 14px 22px; display: grid; gap: 6px; }
.prose table.data { margin: 12px 0 20px; }
.prose .updated { color: var(--slate-500); font-size: 13px; }

/* ── Tiles (navigation cards) ────────────────────────────────────────────── */

.tile {
  display: grid; gap: 4px; align-content: start;
  background: var(--white); border: 1px solid var(--slate-200);
  border-radius: var(--radius); padding: 15px 16px;
  text-decoration: none; color: inherit;
}
.tile:hover { border-color: var(--orange); box-shadow: 0 4px 14px rgba(15, 23, 42, 0.07); }
.tile strong { font-size: 14.5px; font-weight: 700; }

/* ── Utility ─────────────────────────────────────────────────────────────── */

[hidden] { display: none !important; }
.loading { color: var(--slate-500); font-size: 13.5px; }
.stack { display: grid; gap: 16px; }
.stack.tight { gap: 10px; }

/* ── Public surface ───────────────────────────────────────────────────────────
 *
 * Everything below styles the pages served by netlify/functions/public-page.mjs:
 * marketing, docs, help centre, legal, the public auth screens, the support form
 * and the status page.
 *
 * It lives in this sheet rather than in a second one because the public surface
 * and the admin are the same product, and the two most visible things a shared
 * sheet buys are the same nav proportions and the same button. A page assembled
 * from a second stylesheet reads as a different site the moment a merchant moves
 * between /pricing and their admin.
 *
 * The renderer emits no <style> blocks and loads no JS to lay anything out, so
 * these rules are the only thing standing between the markup and the reader. They
 * are written to degrade to legible single-column text if any of it fails.
 */

/* Keyboard skip link — visually hidden until focused. The public pages put a
 * fourteen-item nav ahead of the content, which is a long tab journey to repeat
 * on every page. */
.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--slate-900); color: #fff;
  padding: 10px 16px; border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100; text-decoration: none;
}
.skip:focus { left: 0; }

.pub-nav { gap: 4px; flex-wrap: wrap; }
.pub-nav .brand { margin-right: 12px; }
.pub-nav .spacer { flex: 1 1 auto; }

.nav-link {
  padding: 7px 11px; border-radius: var(--radius-sm);
  color: var(--slate-700); text-decoration: none;
  font-size: .9rem; font-weight: 500; white-space: nowrap;
}
.nav-link:hover { background: var(--slate-100); color: var(--slate-900); }
/* aria-current carries the same information for a screen reader; this is the
 * visual half of the pair, not a substitute for it. */
.nav-link.is-active { background: var(--orange-light); color: var(--orange-dark); }

/* ── Hero and sections ─── */

.pub-hero { text-align: center; padding: 56px 0 40px; }
.pub-hero h1 { font-size: 2.4rem; line-height: 1.15; letter-spacing: -.02em; }
.pub-hero .lede { margin: 16px auto 0; max-width: 660px; font-size: 1.08rem; color: var(--slate-700); }
.pub-hero .btn { margin-top: 26px; }

.lede { font-size: 1.05rem; color: var(--slate-700); }

.pub-section { padding: 40px 0 0; margin-top: 40px; border-top: 1px solid var(--slate-200); }
.pub-section > h2 { font-size: 1.45rem; letter-spacing: -.01em; }
.pub-section > .sub { margin: 8px 0 22px; max-width: 700px; }
.pub-section > h2 + .card, .pub-section > h2 + .pub-grid { margin-top: 20px; }

.pub-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.pub-card {
  background: var(--white); border: 1px solid var(--slate-200);
  border-radius: var(--radius); padding: 22px;
}
.pub-card h3 { font-size: 1.02rem; margin-bottom: 8px; }
.pub-card p { color: var(--slate-500); font-size: .93rem; }
.pub-card ul { margin: 12px 0 0 18px; color: var(--slate-700); font-size: .92rem; }
.pub-card li { margin-bottom: 6px; }
.pub-card .ico { font-size: 1.5rem; display: block; margin-bottom: 10px; }
/* The featured plan is raised by border and offset only. No scale transform: it
 * would blur the text on the one card we most want read. */
.pub-card.featured { border-color: var(--orange); box-shadow: 0 8px 28px rgba(249, 115, 22, .13); }

.pub-cta {
  margin-top: 48px; padding: 40px 24px; text-align: center;
  background: var(--slate-900); color: var(--white); border-radius: var(--radius);
}
.pub-cta h2 { font-size: 1.5rem; }
.pub-cta p { color: var(--slate-400); margin: 10px auto 22px; max-width: 560px; }
.pub-cta .btn { background: var(--white); color: var(--slate-900); border-color: var(--white); }

/* ── Two-column documentation layout (docs, help, legal) ─── */

.pub-layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 44px; align-items: start; }
.pub-side { position: sticky; top: 78px; font-size: .9rem; }
.pub-side h4 { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--slate-400); margin: 20px 0 8px; }
.pub-side h4:first-child { margin-top: 0; }
.pub-side a { display: block; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--slate-700); text-decoration: none; }
.pub-side a:hover { background: var(--slate-100); }
.pub-side a.is-active { background: var(--orange-light); color: var(--orange-dark); font-weight: 600; }

/* Prose measure is capped at ~72ch. Documentation is read, not scanned, and a
 * full-bleed line on a wide monitor loses the reader's place every wrap. */
.pub-prose { max-width: 72ch; }
.pub-prose h1 { font-size: 1.9rem; letter-spacing: -.02em; margin-bottom: 12px; }
.pub-prose h2 { font-size: 1.25rem; margin: 36px 0 10px; scroll-margin-top: 84px; }
.pub-prose h3 { font-size: 1.02rem; margin: 24px 0 8px; scroll-margin-top: 84px; }
.pub-prose p, .pub-prose li { color: var(--slate-700); }
.pub-prose p { margin: 0 0 14px; }
.pub-prose ul, .pub-prose ol { margin: 0 0 16px 22px; }
.pub-prose li { margin-bottom: 7px; }
.pub-prose code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .87em;
  background: var(--slate-100); padding: 1px 5px; border-radius: 4px;
}
.pub-prose pre {
  background: var(--slate-900); color: #e2e8f0; padding: 16px 18px;
  border-radius: var(--radius-sm); overflow-x: auto; margin: 0 0 18px; font-size: .85rem;
}
.pub-prose pre code { background: none; padding: 0; color: inherit; }
.pub-prose table { width: 100%; border-collapse: collapse; margin: 0 0 18px; font-size: .92rem; }
.pub-prose th, .pub-prose td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--slate-200); }
.pub-prose th { background: var(--slate-50); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--slate-500); }
.pub-prose blockquote {
  margin: 0 0 18px; padding: 14px 18px; background: var(--blue-light);
  border-left: 3px solid var(--blue); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.pub-prose blockquote p:last-child { margin-bottom: 0; }

/* ── Draft banner on legal documents ───
 *
 * Amber, not red, and never dismissible. These documents are real drafts that
 * have not been through legal review, and someone reading them to decide whether
 * to sign needs to know that on every visit — not until they click an x. */
.draft-banner {
  background: var(--amber-light); border: 1px solid #fcd34d;
  border-left: 4px solid var(--amber); border-radius: var(--radius-sm);
  padding: 14px 18px; margin: 0 0 26px; font-size: .92rem; color: #713f12;
}
.draft-banner strong { color: #78350f; }
.draft-banner p { margin: 0; }
.draft-banner p + p { margin-top: 8px; }

/* ── Auth and support forms ─── */

.auth-shell { max-width: 420px; margin: 48px auto 0; }
.auth-shell h1 { font-size: 1.6rem; text-align: center; }
.auth-shell > p { text-align: center; color: var(--slate-500); margin: 8px 0 26px; font-size: .94rem; }
.auth-shell .card { padding: 26px; }
.auth-shell .btn { width: 100%; justify-content: center; margin-top: 4px; }
.auth-shell .foot { text-align: center; margin-top: 18px; font-size: .9rem; color: var(--slate-500); }

.field { margin-bottom: 16px; }
.field > label { display: block; font-size: .84rem; font-weight: 600; margin-bottom: 6px; color: var(--slate-700); }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; font: inherit; font-size: .94rem;
  border: 1px solid var(--slate-200); border-radius: var(--radius-sm);
  background: var(--white); color: var(--slate-900);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(249, 115, 22, .16);
}
.field textarea { resize: vertical; min-height: 132px; }
.field .hint { display: block; margin-top: 5px; font-size: .82rem; color: var(--slate-500); }
.field .hint.bad { color: var(--red); }
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: var(--red); }

/* Server-rendered result of a form post. Both variants are announced through
 * role, so colour is never the only carrier. */
.form-note {
  padding: 13px 16px; border-radius: var(--radius-sm); margin: 0 0 20px;
  font-size: .93rem; border: 1px solid var(--slate-200); background: var(--slate-50);
}
.form-note.ok { background: var(--green-light); border-color: #bbf7d0; color: #14532d; }
.form-note.bad { background: var(--red-light); border-color: #fecaca; color: #7f1d1d; }
.form-note p { margin: 0; }
.form-note p + p { margin-top: 8px; }

/* ── Status page ─── */

.status-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--slate-100);
}
.status-row:last-child { border-bottom: none; }
.status-row .name { flex: 1 1 auto; font-weight: 600; font-size: .95rem; }

/* Status colours. The shapes are identical, so the dot alone is not the signal —
 * every row also carries a text label ("Operational", "No data") for the same
 * reason the history bars carry a title. */
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; flex: none; background: var(--slate-400); }
.dot.up { background: var(--green); }
.dot.degraded { background: var(--amber); }
.dot.down { background: var(--red); }
.dot.unknown { background: var(--slate-400); }

/* Ninety one-day bars. min-width rather than a fixed width so the strip fits a
 * phone by getting thinner instead of scrolling sideways. */
.spark { display: flex; gap: 2px; align-items: flex-end; margin-top: 8px; }
.spark i { flex: 1 1 0; min-width: 2px; height: 30px; border-radius: 2px; background: var(--slate-200); }
.spark i.up { background: #86efac; }
.spark i.degraded { background: #fcd34d; }
.spark i.down { background: #fca5a5; }
.spark i.unknown { background: var(--slate-200); }

/* ── Footer ─── */

.pub-foot { margin-top: 72px; border-top: 1px solid var(--slate-200); background: var(--white); }
.pub-foot-inner {
  max-width: 1080px; margin: 0 auto; padding: 40px 24px;
  display: grid; gap: 28px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.pub-foot-col h5 { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--slate-400); margin-bottom: 10px; }
.pub-foot-col a { display: block; padding: 4px 0; color: var(--slate-700); text-decoration: none; font-size: .9rem; }
.pub-foot-col a:hover { color: var(--orange-dark); }
.pub-foot-col.brandcol p { color: var(--slate-500); font-size: .88rem; max-width: 260px; }
.pub-foot-legal {
  border-top: 1px solid var(--slate-100); padding: 18px 24px 32px;
  max-width: 1080px; margin: 0 auto; color: var(--slate-400); font-size: .84rem;
}

/* ── Narrow viewports ───
 *
 * The sidebar becomes a normal block above the content rather than a drawer. A
 * drawer needs JavaScript, and the documentation has to work without it. */
@media (max-width: 860px) {
  .pub-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .pub-side { position: static; border-bottom: 1px solid var(--slate-200); padding-bottom: 18px; }
  .pub-hero { padding: 36px 0 28px; }
  .pub-hero h1 { font-size: 1.85rem; }
  .pub-nav { gap: 2px; }
  .nav-link { padding: 6px 8px; font-size: .85rem; }
}
