:root {
  --bg: #f9fafb;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --muted: #6b7280;
  --accent: #059669;
  --accent-strong: #047857;
  --accent-soft: #d1fae5;
  --accent-text: #065f46;
  --on-accent: #ffffff;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --crit: #b91c1c;
  --crit-soft: #fee2e2;
  --focus: #10b981;
  --grid: #e5e7eb;
  --shadow: 0 1px 2px rgba(17, 24, 39, .06);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14;
    --surface: #111827;
    --surface-2: #1f2937;
    --border: #1f2937;
    --border-strong: #374151;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --accent: #10b981;
    --accent-strong: #34d399;
    --accent-soft: #064e3b;
    --accent-text: #a7f3d0;
    --on-accent: #022c22;
    --warn: #fbbf24;
    --warn-soft: #451a03;
    --crit: #f87171;
    --crit-soft: #450a0a;
    --focus: #34d399;
    --grid: #1f2937;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}

a { color: var(--accent-strong); }
a:hover { color: var(--accent); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75em; }

.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 16px; top: 8px; z-index: 50; background: var(--surface); padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.sticky { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }

.topbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 10px 16px; max-width: 1120px; margin: 0 auto; }
.logo { font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; color: var(--text); text-decoration: none; margin-right: auto; }
.logo:hover { color: var(--accent); }

#nav { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
#nav a, #nav button { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font: inherit; font-size: .9rem; background: none; border: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
#nav a:hover, #nav button:hover { color: var(--text); background: var(--surface-2); }
#nav a[aria-current="page"] { color: var(--accent-text); background: var(--accent-soft); font-weight: 600; }

.actionbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px; max-width: 1120px; margin: 0 auto; border-top: 1px solid var(--border); }
.actionbar h1 { margin: 0; margin-right: auto; font-size: 1.15rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions:empty { display: none; }
.actions label { font-size: .9rem; color: var(--muted); }
.actions .contents { display: contents; }

main { display: block; max-width: 1120px; margin: 0 auto; padding: 20px 16px 48px; }
main:focus { outline: none; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 20px 16px; }
.narrow { max-width: 560px; }
.medium { max-width: 820px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card > :last-child { margin-bottom: 0; }
.card.center { text-align: center; }
.panel-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 12px; }
.panel-bar h2 { margin: 0 auto 0 0; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid { margin-bottom: 16px; }
.grid > .card { margin-bottom: 0; }
.cols { display: grid; gap: 16px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 760px) { .cols { grid-template-columns: minmax(0, 1fr); } }
.stack > * + * { margin-top: 16px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.code { font-size: 2.5rem; font-weight: 800; color: var(--accent); margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 14px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { color: var(--crit); border-color: var(--crit); }
.btn.danger:hover { background: var(--crit-soft); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn[aria-current="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.icon { width: 1.1em; height: 1.1em; flex: none; vertical-align: -.15em; }
.seg { display: inline-flex; gap: 0; }
.seg .btn { border-radius: 0; margin-left: -1px; }
.seg .btn:first-child { border-radius: 9px 0 0 9px; margin-left: 0; }
.seg .btn:last-child { border-radius: 0 9px 9px 0; }

form { margin: 0; }
fieldset { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
legend { font-weight: 700; font-size: 1rem; margin-bottom: 10px; padding: 0; }
.fields { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-weight: 600; font-size: .9rem; }
.req { color: var(--crit); }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="url"], select {
  width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit;
}
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--crit); }
input[readonly] { background: var(--surface-2); }
.hint { font-size: .82rem; color: var(--muted); margin: 0; }
.field-err { font-size: .82rem; color: var(--crit); margin: 0; font-weight: 600; }
.field-err:empty { display: none; }
.field-err:not(:empty)::before { content: "! "; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; margin-bottom: 10px; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.choice .grow { flex: 1; min-width: 0; }
.price { font-weight: 700; white-space: nowrap; }
ul.features { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: .9rem; }

.alert { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 16px; display: flex; gap: 8px; align-items: flex-start; }
.alert.error { border-color: var(--crit); background: var(--crit-soft); color: var(--text); }
.alert.warn { border-color: var(--warn); background: var(--warn-soft); color: var(--text); }
.alert.ok { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.alert .icon { margin-top: 3px; }

.live { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 40; max-width: calc(100% - 32px); }
.live:empty { display: none; }
.live > div { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.live > div.error { background: var(--crit); color: #fff; }

dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
@media (max-width: 420px) { dl.kv { grid-template-columns: minmax(0, 1fr); gap: 2px; } dl.kv dd { margin-bottom: 8px; } }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: .82rem; font-weight: 700; border: 1px solid transparent; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--accent-soft); color: var(--accent-text); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.badge.crit { background: var(--crit-soft); color: var(--crit); border-color: var(--crit); }
.badge .icon { width: .95em; height: .95em; }

.usage .value { font-size: 1.5rem; font-weight: 800; margin: 2px 0; }
.usage .of { color: var(--muted); font-size: .9rem; }
.bar { height: 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin: 10px 0 8px; }
.bar > span { display: block; height: 100%; background: var(--accent); width: 0; }
.bar.warn > span { background: var(--warn); }
.bar.crit > span { background: var(--crit); }
.usage.warn { border-color: var(--warn); }
.usage.crit { border-color: var(--crit); border-width: 2px; }

.graph { width: 100%; height: auto; display: block; }
.graph .gridline { stroke: var(--grid); stroke-width: 1; }
.graph .axis { fill: var(--muted); font-size: 11px; font-family: inherit; }
.graph .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.graph .area { fill: var(--accent); opacity: .12; stroke: none; }
.graph .limit { stroke: var(--crit); stroke-width: 1.5; stroke-dasharray: 6 4; fill: none; }
.graph .limit-label { fill: var(--crit); font-size: 11px; font-weight: 700; font-family: inherit; }
.graph .empty { fill: var(--muted); font-size: 14px; font-family: inherit; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-top: 6px; }
.legend .sw { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--accent); vertical-align: middle; margin-right: 6px; }
.legend .sw.limit { border-top: 2px dashed var(--crit); }

.steps { display: flex; gap: 6px; flex-wrap: wrap; list-style: none; margin: 0 0 16px; padding: 0; font-size: .85rem; }
.steps li { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); background: var(--surface); }
.steps li.done { color: var(--accent-text); border-color: var(--accent); }
.steps li[aria-current="step"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }

.doc { overflow-wrap: anywhere; }
.doc h2 { font-size: 1.25rem; margin-top: 1em; }
.doc h3 { font-size: 1.05rem; margin-top: 1.2em; }
.doc h4, .doc h5, .doc h6 { font-size: .95rem; margin-top: 1em; }
.doc ul, .doc ol { padding-left: 22px; margin: 0 0 .75em; }
.doc.scroll { max-height: 60vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; padding: 16px; background: var(--surface-2); }

.srv { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; cursor: pointer; flex-wrap: wrap; }
.srv:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.srv input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.srv .grow { flex: 1; font-weight: 600; min-width: 0; }

pre.logs { margin: 0; padding: 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font: 12.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 70vh; overflow: auto; tab-size: 4; }

.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; list-style: none; margin: 0 0 12px; padding: 0; font-size: .92rem; }
.crumbs li + li::before { content: "/"; color: var(--muted); margin-right: 4px; }
.crumbs [aria-current="page"] { font-weight: 700; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; }
td.name a { display: inline-flex; gap: 8px; align-items: center; text-decoration: none; color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
td.name a:hover { color: var(--accent); }
td.num { white-space: nowrap; color: var(--muted); }
td.row-actions { white-space: nowrap; text-align: right; }
@media (max-width: 560px) { .hide-sm { display: none; } }

progress { width: 100%; height: 10px; accent-color: var(--accent); }
.uploads:empty { display: none; }
.uploads > div { margin-bottom: 10px; font-size: .88rem; }

.copyrow { display: flex; gap: 8px; }
.copyrow input { flex: 1; min-width: 0; font-family: var(--mono); font-size: .85rem; }

.stripe-note { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: .85rem; }

@media (max-width: 480px) {
  .card { padding: 16px; }
  .actionbar { gap: 8px; }
  .actionbar h1 { width: 100%; }
}
