:root {
  --bg: #f6f7fb; --surface: #ffffff; --surface-2: #f1f3f9; --text: #151a2d; --muted: #5b6477; --border: #e2e6ef;
  --brand: #3b5bdb; --brand-ink: #ffffff; --brand-soft: #e8edff;
  --up: #1a7f4e; --up-soft: #e3f5ec; --down: #c92a2a; --down-soft: #fdecec; --warn: #b35c00; --warn-soft: #fff3e0;
  --restricted: #6741d9; --restricted-soft: #efe9ff; --stale: #5b6477; --stale-soft: #eceff4;
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1320; --surface: #171c2c; --surface-2: #1e2438; --text: #e8ebf4; --muted: #9aa3b8; --border: #2a3148;
    --brand: #748ffc; --brand-ink: #0f1320; --brand-soft: #232b4a;
    --up: #51cf8a; --up-soft: #16372a; --down: #ff8787; --down-soft: #3d1d22; --warn: #ffb45a; --warn-soft: #3b2a14;
    --restricted: #b197fc; --restricted-soft: #2c2448; --stale: #9aa3b8; --stale-soft: #262c3f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); letter-spacing: -.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 1em; }
code, .mono { font-family: var(--mono); font-size: .9em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 6px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
.break { word-break: break-all; }
.truncate { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-danger { color: var(--down); }
.text-warn { color: var(--warn); }
.sr-only, .skip { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip:focus { position: static; width: auto; height: auto; padding: .5rem; }
.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 760px; }

.staging-banner { background: #ffd43b; color: #3d2c00; text-align: center; font-size: .82rem; padding: 6px 12px; }
.placeholder { display: inline-block; background: var(--warn-soft); color: var(--warn); border: 1px dashed var(--warn); border-radius: 6px; padding: 0 .4em; font-size: .9em; }
.placeholder-card { border-style: dashed; }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink);
  font: 600 .92rem var(--font); padding: .6em 1.1em; border-radius: 10px; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-danger { background: var(--down); border-color: var(--down); color: #fff; }
.btn-small { padding: .35em .75em; font-size: .82rem; }
.btn-large { padding: .8em 1.4em; font-size: 1rem; }
.btn-block { width: 100%; }
.link-button { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }
.form { display: grid; gap: 14px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: 1 / -1; }
label { display: grid; gap: 6px; font-weight: 500; font-size: .9rem; }
label.check, label.radio { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: .6em .75em; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; display: grid; gap: 6px; }
legend { font-weight: 600; font-size: .88rem; padding: 0 4px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 8px; }
.inline-form input[type=text], .inline-form input[type=search], .inline-form input[type=number] { width: auto; flex: 1 1 180px; }
details.subtle { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
details summary { cursor: pointer; font-weight: 600; }

/* Flash & banners */
.flashes { display: grid; gap: 8px; margin: 12px 0; }
.flash, .banner { border-radius: 10px; padding: 10px 14px; border: 1px solid var(--border); background: var(--surface); }
.flash-success { border-color: var(--up); background: var(--up-soft); }
.flash-error, .banner-danger { border-color: var(--down); background: var(--down-soft); }
.flash-info, .banner-info { border-color: var(--brand); background: var(--brand-soft); }
.banner-warn { border-color: var(--warn); background: var(--warn-soft); }
.banner { margin-bottom: 16px; }

/* Badges */
.badge { display: inline-block; font-size: .76rem; font-weight: 600; padding: .18em .6em; border-radius: 999px; background: var(--stale-soft); color: var(--stale); white-space: nowrap; margin: 1px 2px 1px 0; }
.badge-up, .badge-valid, .badge-service-active, .badge-approval-approved, .badge-billing-paid, .badge-inv-paid { background: var(--up-soft); color: var(--up); }
.badge-down, .badge-expired, .badge-invalid, .badge-error, .badge-service-suspended, .badge-approval-rejected, .badge-billing-past_due, .badge-billing-unpaid, .badge-inv-failed, .badge-closed, .badge-service-canceled { background: var(--down-soft); color: var(--down); }
.badge-expiring, .badge-approval-pending, .badge-billing-checkout_open, .badge-inv-refunded, .badge-inv-open { background: var(--warn-soft); color: var(--warn); }
.badge-restricted { background: var(--restricted-soft); color: var(--restricted); }
.badge-unexpected { background: var(--down-soft); color: var(--down); }

/* Public site */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.header-row { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); font-weight: 800; }
.site-nav { display: flex; align-items: center; gap: 22px; }
.site-nav a:not(.btn) { color: var(--text); font-weight: 500; }
.nav-toggle { display: none; }
.nav-toggle-label { display: none; }
.hero { padding: 72px 0 56px; background: linear-gradient(180deg, var(--brand-soft), transparent); }
.hero-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 48px; align-items: center; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .76rem; font-weight: 700; color: var(--brand); margin-bottom: .6em; }
.lead { font-size: 1.1rem; color: var(--muted); }
.note { font-size: .9rem; color: var(--muted); border-left: 3px solid var(--brand); padding-left: 10px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 24px 0; }
.hero-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); display: grid; gap: 10px; }
.demo-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px; border-radius: 10px; background: var(--surface-2); }
.demo-host { font-weight: 600; flex: 1; min-width: 140px; }
.demo-meta { font-size: .8rem; color: var(--muted); }
.demo-caption { font-size: .78rem; color: var(--muted); margin: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--stale); }
.dot-up { background: var(--up); } .dot-down { background: var(--down); } .dot-warn { background: var(--warn); }
.section { padding: 56px 0; }
.section.alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-title { font-size: 1.5rem; margin-bottom: 24px; }
.cards { display: grid; gap: 18px; }
.cards-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cards-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.link-card { color: var(--text); display: block; transition: transform .12s ease; }
.link-card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--brand); }
.link-card p { color: var(--muted); margin: 0; }
.plan-card { display: flex; flex-direction: column; gap: 8px; }
.plan-card .btn { margin-top: auto; }
.price { font-size: 1.8rem; font-weight: 700; margin: 0; }
.price small { font-size: .9rem; color: var(--muted); font-weight: 500; }
.checklist { list-style: none; padding: 0; margin: 0 0 1em; display: grid; gap: 6px; }
.checklist li::before { content: "✓"; color: var(--up); font-weight: 700; margin-right: 8px; }
.plain { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 4px; font-size: .9rem; }
.steps { list-style: none; counter-reset: step; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.steps li { counter-increment: step; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: grid; gap: 4px; }
.steps li::before { content: counter(step); display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.steps span { color: var(--muted); font-size: .88rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.service-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 40px; }
.side-nav { display: grid; gap: 8px; align-content: start; position: sticky; top: 90px; }
.side-nav a[aria-current] { font-weight: 700; }
.prose { max-width: 760px; }
.prose h2 { margin-top: 1.6em; }
.prose details { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; }
.prose details p { margin: .6em 0 0; }
.defs { display: grid; grid-template-columns: max-content 1fr; gap: 10px 18px; }
.defs dt { font-weight: 600; } .defs dd { margin: 0; }
.cta-row { margin-top: 2em; display: flex; gap: 10px; flex-wrap: wrap; }
.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding: 40px 0 20px; margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 24px; }
.footer-grid a:not(.brand) { display: block; color: var(--muted); padding: 2px 0; }
.footer-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.footer-bottom { margin-top: 24px; font-size: .82rem; }

/* Auth pages */
.auth-main { min-height: 90vh; display: grid; place-content: center; justify-items: center; gap: 18px; padding: 32px 16px; }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-card.wide { width: min(620px, 100%); }
.auth-links { text-align: center; margin-top: 16px; font-size: .9rem; }
.auth-foot { text-align: center; }
.qr-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin: 16px 0; }
.qr-wrap img { border-radius: 10px; border: 1px solid var(--border); background: #fff; width: 220px; height: 220px; image-rendering: pixelated; }
.secret { display: block; font-size: 1rem; letter-spacing: .08em; padding: 8px; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.codes code { display: block; text-align: center; font-size: 1.05rem; padding: 8px; }
.setup-steps { padding-left: 1.2em; color: var(--muted); }
.test-mode-flag { background: #ffd43b; color: #3d2c00; font-weight: 700; font-size: .78rem; text-align: center; padding: 6px; border-radius: 8px; margin-bottom: 14px; }

/* App shell */
.app-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.app-side { background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.app-nav { display: grid; gap: 2px; margin-top: 24px; }
.app-nav a { color: var(--text); padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.app-nav a:hover { background: var(--surface-2); text-decoration: none; }
.app-nav a[aria-current] { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.app-user { margin-top: 24px; padding: 12px; border-top: 1px solid var(--border); display: grid; gap: 6px; word-break: break-all; }
.app-main { padding: 28px clamp(16px, 3vw, 40px) 60px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin-bottom: .2em; }
.page-head .eyebrow a { color: inherit; }
.head-actions { display: flex; gap: 8px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-head h2 { margin: 0; }
.small-title { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-2 > .panel { margin-bottom: 0; }
.grid-2 { margin-bottom: 18px; }
.metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 4px; border-top: 3px solid var(--border); }
.metric span { font-size: .8rem; color: var(--muted); }
.metric strong { font-size: 1.7rem; }
.metric-up { border-top-color: var(--up); } .metric-down { border-top-color: var(--down); }
.metric-restricted { border-top-color: var(--restricted); } .metric-stale { border-top-color: var(--stale); } .metric-warn { border-top-color: var(--warn); }
.quota { display: grid; grid-template-columns: 80px 1fr auto; gap: 10px; align-items: center; font-size: .88rem; margin-bottom: 6px; }
progress { width: 100%; height: 8px; accent-color: var(--brand); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table.compact td { padding: 6px 10px; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.data-table .actions form { margin: 0; }
.empty-row td { text-align: center; color: var(--muted); padding: 24px; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0 0 12px; }
.kv dt { color: var(--muted); font-size: .88rem; } .kv dd { margin: 0; }
.list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.tags { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.tags li { background: var(--surface-2); border-radius: 6px; padding: 1px 6px; font-size: .8rem; font-family: var(--mono); }
.records { list-style: none; margin: 0; padding: 0; }
.chain { padding-left: 1.2em; }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.timeline li { border-left: 3px solid var(--up); padding-left: 10px; }
.timeline li.open { border-left-color: var(--down); }
.uptime-bar { display: flex; gap: 2px; height: 28px; margin: 8px 0 4px; }
.uptime-bar span { flex: 1; border-radius: 3px; }
.bar-up { background: var(--up); } .bar-warn { background: var(--warn); } .bar-down { background: var(--down); }
.danger-zone { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.plain-steps { display: grid; gap: 12px; }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.tabs a[aria-current] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.actions-panel .inline-form { border-bottom: 1px dashed var(--border); padding-bottom: 8px; }
.live-status { margin: 8px 0 0; }

@media (max-width: 1000px) {
  .cards-4, .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .hero-grid, .two-col, .service-layout, .grid-2, .cards-2, .cards-3, .form-grid { grid-template-columns: 1fr; }
  .side-nav { position: static; }
  .nav-toggle-label { display: block; width: 32px; height: 32px; cursor: pointer; position: relative; }
  .nav-toggle-label span, .nav-toggle-label span::before, .nav-toggle-label span::after { position: absolute; left: 4px; right: 4px; height: 2px; background: var(--text); content: ""; }
  .nav-toggle-label span { top: 15px; } .nav-toggle-label span::before { top: -8px; } .nav-toggle-label span::after { top: 8px; }
  .site-nav { display: none; position: absolute; top: 64px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); flex-direction: column; align-items: stretch; padding: 16px 20px; gap: 12px; }
  .nav-toggle:checked ~ .site-nav { display: flex; }
  .app-shell { grid-template-columns: 1fr; }
  .app-side { position: relative; height: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 12px 16px; }
  .app-nav { display: none; width: 100%; margin-top: 12px; }
  .nav-toggle:checked ~ .app-nav { display: grid; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .truncate { max-width: 180px; }
}
@media (max-width: 520px) {
  .cards-4, .steps, .footer-grid { grid-template-columns: 1fr; }
  .codes { grid-template-columns: 1fr; }
  .auth-card { padding: 20px; }
}
@media print {
  .app-side, .staging-banner, .page-head .eyebrow, .flashes { display: none; }
  .app-shell { display: block; }
  .panel { box-shadow: none; border: 0; }
}
