/* ===========================================================================
   Security Tools — design system
   Self-hosted, zero third-party CSS. Works under a strict CSP.
   =========================================================================== */

/* --- Tokens -------------------------------------------------------------- */
:root {
  color-scheme: light dark;

  --bg:        #f7f7f8;
  --surface:   #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #e8e8ea;
  --border:    #dddde0;
  --border-sl: #ebebed;

  --text:      #111113;
  --text-dim:  #5c5c63;
  --text-faint:#8b8b93;

  /* Accent is ink, not a hue. Colour is reserved for data. */
  --brand:     #111113;
  --brand-ink: #ffffff;
  --brand-wash:#ececed;

  --ok:        #0f9d6e;
  --ok-wash:   #e4f7f0;
  --bad:       #e11d48;
  --bad-wash:  #fdeaef;
  --warn:      #c2740a;
  --warn-wash: #fdf2e0;
  --info:      #2563eb;
  --info-wash: #e8f0fe;
  --mute-wash: #eef1f6;

  --radius:    14px;
  --radius-sm: 9px;
  --radius-lg: 20px;

  --shadow-1: 0 1px 2px rgba(13,20,36,.05), 0 1px 3px rgba(13,20,36,.04);
  --shadow-2: 0 4px 12px rgba(13,20,36,.07), 0 1px 3px rgba(13,20,36,.05);
  --shadow-3: 0 18px 44px rgba(13,20,36,.13), 0 2px 8px rgba(13,20,36,.06);
  --ring:     0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          "Noto Sans", "Liberation Sans", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo,
          Consolas, "Liberation Mono", monospace;

  --ease: cubic-bezier(.22,.61,.36,1);
  --nav-h: 68px;
}

:root[data-theme="dark"] {
  --bg:        #0a0a0b;
  --surface:   #141416;
  --surface-2: #1b1b1e;
  --surface-3: #252528;
  --border:    #2c2c30;
  --border-sl: #222225;

  --text:      #f2f2f3;
  --text-dim:  #a1a1a8;
  --text-faint:#71717a;

  --brand:     #f2f2f3;
  --brand-ink: #111113;
  --brand-wash:#26262a;

  --ok:        #34d399;
  --ok-wash:   #0e2b23;
  --bad:       #fb7185;
  --bad-wash:  #2e1119;
  --warn:      #fbbf24;
  --warn-wash: #2d2109;
  --info:      #60a5fa;
  --info-wash: #10203c;
  --mute-wash: #1a2232;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 4px 14px rgba(0,0,0,.45);
  --shadow-3: 0 20px 50px rgba(0,0,0,.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#0a0a0b; --surface:#141416; --surface-2:#1b1b1e;
    --surface-3:#252528; --border:#2c2c30; --border-sl:#222225;
    --text:#f2f2f3; --text-dim:#a1a1a8; --text-faint:#71717a;
    --brand:#f2f2f3; --brand-ink:#111113; --brand-wash:#26262a;
    --ok:#34d399; --ok-wash:#0e2b23; --bad:#fb7185; --bad-wash:#2e1119;
    --warn:#fbbf24; --warn-wash:#2d2109; --info:#60a5fa; --info-wash:#10203c;
    --mute-wash:#1a2232;
    --shadow-1:0 1px 2px rgba(0,0,0,.4);
    --shadow-2:0 4px 14px rgba(0,0,0,.45);
    --shadow-3:0 20px 50px rgba(0,0,0,.6);
  }
}

/* --- Reset --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.22; font-weight: 650; letter-spacing: -.021em; }
h1 { font-size: clamp(1.9rem, 1.2rem + 2.6vw, 3.05rem); }
h2 { font-size: clamp(1.35rem, 1.05rem + 1.1vw, 1.9rem); }
h3 { font-size: 1.1rem; }

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

.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;
}

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--brand); color: var(--brand-ink);
  padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 600;
  transition: top .18s var(--ease);
}
.skip-link:focus { top: 12px; text-decoration: none; }

/* --- Layout -------------------------------------------------------------- */
.shell { width: min(1240px, 100% - 48px); margin-inline: auto; }
@media (max-width: 560px) { .shell { width: calc(100% - 32px); } }

main { flex: 1; padding-block: 44px 72px; }
.stack  { display: grid; gap: 22px; }
.stack-lg { display: grid; gap: 40px; }
/* Let children shrink below their content width so wide tables scroll
   inside their card rather than stretching the page. */
.stack > *, .stack-lg > * { min-width: 0; }

/* --- Nav ----------------------------------------------------------------- */
.nav {
  position: sticky; top: 0; z-index: 60;
  height: var(--nav-h);
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border-sl);
}
.nav-inner { display: flex; align-items: center; gap: 8px; }

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.02rem; letter-spacing: -.02em;
  color: var(--text); margin-right: auto; padding-block: 4px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 8px; color: var(--brand-ink);
  background: var(--brand);
}
.brand-mark svg { width: 17px; height: 17px; }

.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-link {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px; border-radius: 9px;
  font-size: .89rem; font-weight: 550; color: var(--text-dim);
  transition: background .16s var(--ease), color .16s var(--ease);
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--brand-wash); color: var(--brand); }
.nav-link svg { width: 15px; height: 15px; opacity: .85; }

.nav-user {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border-sl);
  font-size: .83rem; font-weight: 600; color: var(--text-dim);
}
.nav-user svg { width: 15px; height: 15px; }

.nav-toggle { display: none; }

@media (max-width: 760px) {
  .nav-toggle {
    display: grid; place-items: center; width: 36px; height: 36px;
    border: 1px solid var(--border); border-radius: 9px;
    background: var(--surface-2); cursor: pointer; color: var(--text-dim);
  }
  .nav-toggle svg { width: 17px; height: 17px; }
  .nav-links {
    position: absolute; inset: var(--nav-h) 16px auto 16px;
    flex-direction: column; align-items: stretch; gap: 2px; padding: 8px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-3);
    opacity: 0; visibility: hidden; transform: translateY(-8px);
    transition: opacity .18s var(--ease), transform .18s var(--ease), visibility .18s;
  }
  .nav-links[data-open="true"] { opacity: 1; visibility: visible; transform: none; }
  .nav-user { justify-content: center; }
}

/* --- Buttons ------------------------------------------------------------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px;
  font-size: .9rem; font-weight: 600; line-height: 1.2;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: transform .14s var(--ease), box-shadow .18s var(--ease),
              background .18s var(--ease), border-color .18s var(--ease), opacity .18s;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--brand);
  color: var(--brand-ink);
}
.btn-primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--brand) 86%, var(--surface));
  text-decoration: none;
}
.btn-ghost {
  background: var(--surface); color: var(--text-dim); border-color: var(--border);
  box-shadow: var(--shadow-1);
}
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--brand); text-decoration: none; }
.btn-subtle { background: var(--surface-2); color: var(--text-dim); border-color: transparent; }
.btn-subtle:hover:not(:disabled) { background: var(--surface-3); color: var(--text); text-decoration: none; }

.btn-lg { padding: 13px 26px; font-size: .97rem; border-radius: 12px; }
.btn-sm { padding: 6px 11px; font-size: .8rem; border-radius: 8px; gap: 5px; }
.btn-sm svg { width: 14px; height: 14px; }

.icon-btn {
  display: grid; place-items: center; width: 33px; height: 33px;
  border-radius: 9px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-dim); cursor: pointer;
  transition: color .16s var(--ease), border-color .16s var(--ease), background .16s var(--ease);
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand); }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn.is-busy { pointer-events: none; opacity: .65; }

/* --- Cards --------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: 22px; }
.card-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 16px 22px; border-bottom: 1px solid var(--border-sl);
}
.card-head h2, .card-head h3 { font-size: 1rem; font-weight: 650; margin-right: auto; }
.card-foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 13px 22px; border-top: 1px solid var(--border-sl);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: .84rem; color: var(--text-dim);
}

/* --- Forms --------------------------------------------------------------- */
.field { display: grid; gap: 7px; }
.field label { font-size: .85rem; font-weight: 600; color: var(--text-dim); }

.input, .select {
  width: 100%; padding: 11px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.input::placeholder { color: var(--text-faint); }
.input:focus, .select:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.input[aria-invalid="true"] { border-color: var(--bad); }

.select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a94a8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 15px;
}

.search-row { display: flex; gap: 10px; flex-wrap: wrap; }
.search-row .input-wrap { flex: 1 1 280px; position: relative; }
.search-row .input-wrap > svg {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-faint); pointer-events: none;
}
.search-row .input-wrap .input { padding-left: 38px; font-family: var(--mono); font-size: .92rem; }

/* --- Badges -------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .745rem; font-weight: 650; letter-spacing: .012em;
  white-space: nowrap; font-family: var(--mono);
  border: 1px solid transparent;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

.badge-ok   { background: var(--ok-wash);   color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 26%, transparent); }
.badge-bad  { background: var(--bad-wash);  color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 26%, transparent); }
.badge-warn { background: var(--warn-wash); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 26%, transparent); }
.badge-info { background: var(--info-wash); color: var(--info); border-color: color-mix(in srgb, var(--info) 26%, transparent); }
.badge-mute { background: var(--mute-wash); color: var(--text-faint); }

/* --- Stats --------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(146px, 1fr)); gap: 12px; }
.stat {
  position: relative; overflow: hidden;
  padding: 15px 17px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1);
}
.stat::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent, var(--border)); opacity: .9;
}
.stat-label {
  display: flex; align-items: center; gap: 6px;
  font-size: .73rem; font-weight: 650; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-faint);
}
.stat-label svg { width: 13px; height: 13px; }
.stat-value {
  font-family: var(--mono); font-size: 1.62rem; font-weight: 680;
  letter-spacing: -.028em; color: var(--text); font-variant-numeric: tabular-nums;
  line-height: 1.25; margin-top: 3px;
}
.stat--ok   { --accent: var(--ok); }
.stat--bad  { --accent: var(--bad); }
.stat--warn { --accent: var(--warn); }
.stat--info { --accent: var(--info); }

/* --- Progress ------------------------------------------------------------ */
.progress {
  height: 5px; border-radius: 999px; overflow: hidden;
  background: var(--surface-3);
}
.progress-bar {
  height: 100%; width: 0;
  background: var(--brand);
  border-radius: 999px;
  transition: width .3s var(--ease);
}

/* --- Table --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; overscroll-behavior-x: contain; }
.tbl { width: 100%; min-width: 780px; border-collapse: collapse; font-size: .875rem; }
.tbl thead th {
  position: sticky; top: 0; z-index: 4;
  padding: 10px 14px; text-align: left;
  font-size: .715rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-faint); white-space: nowrap;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.tbl thead th.sortable { cursor: pointer; user-select: none; }
.tbl thead th.sortable:hover { color: var(--text); }
.tbl thead th .sort-ind { opacity: 0; margin-left: 4px; }
.tbl thead th[aria-sort] .sort-ind { opacity: 1; color: var(--brand); }

.tbl tbody td {
  padding: 9px 14px; border-bottom: 1px solid var(--border-sl);
  vertical-align: middle; white-space: nowrap;
}
.tbl tbody tr { transition: background .12s var(--ease); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: none; }

.col-idx  { width: 56px; color: var(--text-faint); font-family: var(--mono); font-size: .8rem; text-align: right; }
.col-act  { width: 92px; }
.cell-c   { text-align: center; }

.host {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: .855rem; color: var(--text);
  white-space: nowrap;
}
.host-apex { font-weight: 680; color: var(--brand); }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .82rem; color: var(--text-dim); }
.row-actions { display: flex; gap: 5px; justify-content: flex-end; }
.row-actions .icon-btn { width: 28px; height: 28px; border-radius: 7px; }
.row-actions .icon-btn svg { width: 14px; height: 14px; }

.empty { padding: 56px 22px; text-align: center; color: var(--text-dim); }
.empty svg { width: 38px; height: 38px; margin: 0 auto 12px; color: var(--text-faint); opacity: .55; }
.empty p { font-size: .9rem; }

/* --- Hero ---------------------------------------------------------------- */
.hero { padding: clamp(40px, 7vw, 86px) 0 clamp(30px, 5vw, 58px); text-align: center; }
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 14px; margin-bottom: 20px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--border);
  font-size: .78rem; font-weight: 650; letter-spacing: .015em;
}
.hero .eyebrow svg { width: 14px; height: 14px; }
.hero h1 { margin-bottom: 16px; }
.hero h1 .grad {
  color: var(--text);
}
.hero .lede {
  max-width: 62ch; margin: 0 auto 30px;
  font-size: clamp(1rem, .94rem + .3vw, 1.14rem); color: var(--text-dim);
}
.hero-cta { display: flex; gap: 11px; justify-content: center; flex-wrap: wrap; }

/* --- Feature grid -------------------------------------------------------- */
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }

.feature {
  position: relative; overflow: hidden;
  padding: 24px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1);
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s var(--ease);
}
.feature:hover { border-color: var(--text-faint); }
.feature-ico {
  width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: 15px;
  border-radius: 10px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border);
}
.feature-ico svg { width: 20px; height: 20px; }
.feature h3 { margin-bottom: 7px; font-size: 1.02rem; }
.feature p { font-size: .9rem; color: var(--text-dim); }
.feature .badge { margin-top: 13px; }

.section-head { text-align: center; max-width: 60ch; margin: 0 auto 30px; }
.section-head p { color: var(--text-dim); margin-top: 9px; }

/* --- Detail panel -------------------------------------------------------- */
.drawer-scrim {
  position: fixed; inset: 0; z-index: 90;
  background: rgb(0 0 0 / .45); backdrop-filter: blur(2px);
  opacity: 0; visibility: hidden; transition: opacity .2s var(--ease), visibility .2s;
}
.drawer-scrim[data-open="true"] { opacity: 1; visibility: visible; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 91;
  width: min(560px, 100%);
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-3);
  transform: translateX(100%); transition: transform .26s var(--ease);
}
.drawer[data-open="true"] { transform: none; }
.drawer-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border-sl);
}
.drawer-head h2 { font-size: .98rem; margin-right: auto; font-family: var(--mono); word-break: break-all; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; display: grid; gap: 20px; }

.kv { display: grid; gap: 1px; background: var(--border-sl); border: 1px solid var(--border-sl); border-radius: var(--radius-sm); overflow: hidden; }
.kv > div { display: grid; grid-template-columns: 136px 1fr; gap: 12px; padding: 9px 13px; background: var(--surface); }
.kv dt { font-size: .79rem; font-weight: 600; color: var(--text-faint); }
.kv dd {
  font-size: .845rem; font-family: var(--mono); word-break: break-word;
  color: var(--text); white-space: pre-line;
}
@media (max-width: 480px) { .kv > div { grid-template-columns: 1fr; gap: 2px; } }

.panel-title {
  display: flex; align-items: center; gap: 7px; margin-bottom: 10px;
  font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-faint);
}
.panel-title svg { width: 14px; height: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.port-list { display: grid; gap: 6px; }
.port-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border-sl);
  font-size: .83rem;
}
.port-row .pnum { font-family: var(--mono); font-weight: 680; color: var(--brand); min-width: 48px; }
.port-row .psvc { font-weight: 600; }
.port-row .pban {
  flex: 1; font-family: var(--mono); font-size: .76rem; color: var(--text-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right;
}

/* --- Toasts -------------------------------------------------------------- */
.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 120;
  display: grid; gap: 9px; width: min(348px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-3); font-size: .865rem;
  animation: toast-in .24s var(--ease);
}
.toast[data-leaving="true"] { animation: toast-out .2s var(--ease) forwards; }
.toast svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.toast-ok   svg { color: var(--ok); }
.toast-bad  svg { color: var(--bad); }
.toast-info svg { color: var(--info); }
.toast p { flex: 1; color: var(--text-dim); }
.toast strong { display: block; color: var(--text); font-weight: 640; }

@keyframes toast-in  { from { opacity: 0; transform: translateX(14px) scale(.97); } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(14px) scale(.97); } }

/* --- Flash messages ------------------------------------------------------ */
.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm); font-size: .88rem;
  border: 1px solid transparent;
}
.flash svg { width: 17px; height: 17px; flex: none; }
.flash-success { background: var(--ok-wash);  color: var(--ok);  border-color: color-mix(in srgb, var(--ok) 26%, transparent); }
.flash-error   { background: var(--bad-wash); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 26%, transparent); }

/* --- Spinner ------------------------------------------------------------- */
.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: var(--surface-2);
  animation: pulse-fade 1.2s ease-in-out infinite;
  border-radius: 6px; color: transparent;
}
@keyframes pulse-fade { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* --- Auth ---------------------------------------------------------------- */
.auth-wrap { max-width: 410px; margin: clamp(24px, 6vh, 64px) auto; }
.auth-head { text-align: center; margin-bottom: 26px; }
.auth-head .brand-mark { width: 44px; height: 44px; margin: 0 auto 15px; border-radius: 13px; }
.auth-head .brand-mark svg { width: 23px; height: 23px; }
.auth-head h1 { font-size: 1.52rem; margin-bottom: 6px; }
.auth-head p { color: var(--text-dim); font-size: .9rem; }

/* --- Footer -------------------------------------------------------------- */
.foot {
  border-top: 1px solid var(--border-sl);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  padding: 26px 0;
}
.foot-inner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-size: .845rem; color: var(--text-dim);
}
.foot-inner .brand { margin-right: auto; font-size: .93rem; }

/* --- Error page ---------------------------------------------------------- */
.errpage { text-align: center; padding: clamp(50px, 12vh, 120px) 0; }
.errpage .code {
  font-family: var(--mono); font-size: clamp(3.6rem, 10vw, 6.2rem); font-weight: 700;
  letter-spacing: -.04em; line-height: 1;
  color: var(--text-faint);
}
.errpage p { color: var(--text-dim); margin: 12px 0 26px; }

/* --- Utilities ----------------------------------------------------------- */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-end { margin-left: auto; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.ml-1 { margin-left: 8px; }
.hidden { display: none !important; }
.fs-sm { font-size: .85rem; }
.fs-xs { font-size: .78rem; }

@media (max-width: 680px) {
  .col-idx, .hide-sm { display: none; }
  .card-pad { padding: 17px; }
  .card-head, .card-foot { padding-inline: 17px; }
  .tbl tbody td, .tbl thead th { padding-inline: 11px; }
}

/* --- Layout helpers (classes, not inline styles: the CSP forbids those) --- */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ico-inline {
  display: inline-block;          /* overrides the global `svg { display: block }` */
  width: 16px; height: 16px;
  vertical-align: -3px; margin-right: 7px;
  flex: none;
}

.w-full { width: 100%; }
.m-0 { margin: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 18px; }
.mt-2 { margin-top: 12px; }
.grow { flex: 1 1 320px; }
.pad-tight { padding-bottom: 14px; }
.select-compact { flex: 0 1 190px; }
.text-left { text-align: left; }

/* A nav link rendered as a form submit button. */
.nav-link-button {
  background: none; border: none; cursor: pointer;
  width: 100%; font: inherit; text-align: left;
}

/* The results table scrolls inside this box; the header sticks to its top. */
.table-scroll { max-height: min(68vh, 720px); overflow-y: auto; }
.spacer-cell {
  padding: 0 !important; border: none !important;
  height: 0 !important; white-space: normal;
}

/* --- API documentation --------------------------------------------------- */
.doc-nav {
  position: sticky; top: calc(var(--nav-h) + 18px);
  align-self: start; display: grid; gap: 2px;
}
.doc-nav a {
  padding: 7px 12px; border-radius: 8px; border-left: 2px solid transparent;
  font-size: .86rem; color: var(--text-dim); text-decoration: none;
}
.doc-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.doc-nav .doc-nav-title {
  padding: 7px 12px; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint);
}

.doc-layout { display: grid; grid-template-columns: 208px minmax(0, 1fr); gap: 34px; }
/* Grid and flex children default to min-width:auto, so a wide code block would
   stretch the page instead of scrolling inside its own box. */
.doc-layout > *, .doc-section, .endpoint, .tab-panel { min-width: 0; }
@media (max-width: 900px) {
  .doc-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .doc-nav {
    position: static; grid-auto-flow: column; grid-auto-columns: max-content;
    overflow-x: auto; max-width: 100%; padding-bottom: 6px;
  }
  .doc-nav .doc-nav-title { display: none; }
  .doc-nav a { white-space: nowrap; border: 1px solid var(--border); }
}

.doc-section { scroll-margin-top: calc(var(--nav-h) + 20px); }
/* One rhythm for every child, so a paragraph after a code block is spaced the
   same as one after a heading. The global `* { margin: 0 }` reset means
   nothing here has spacing of its own. */
.doc-section > * + * { margin-top: 16px; }
.doc-section > h2 + p { margin-top: 10px; }
.doc-section > p { color: var(--text-dim); }

/* Code blocks */
.code {
  position: relative; max-width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); overflow: hidden;
}
.code-head {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-bottom: 1px solid var(--border-sl);
  background: var(--surface-3);
  font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-faint);
}
.code-head .row-end { margin-left: auto; }
.code pre {
  margin: 0; padding: 13px 14px; max-width: 100%; overflow-x: auto;
  font-family: var(--mono); font-size: .825rem; line-height: 1.65;
  color: var(--text); tab-size: 2;
}
.code pre .c { color: var(--text-faint); font-style: italic; }   /* comment */
.code pre .s { color: var(--text-dim); }                          /* string  */
.code pre .k { color: var(--text); font-weight: 650; }            /* keyword */

.copy-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-dim); font-size: .7rem; font-weight: 650;
  text-transform: none; letter-spacing: 0;
}
.copy-btn:hover { color: var(--brand); border-color: var(--brand); }
.copy-btn svg { width: 12px; height: 12px; }

/* Endpoint rows */
.endpoint {
  display: grid; gap: 10px; padding: 16px 18px; min-width: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface);
}
.endpoint + .endpoint { margin-top: 10px; }
.endpoint-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.method {
  padding: 2px 8px; border-radius: 5px;
  font-family: var(--mono); font-size: .7rem; font-weight: 700; letter-spacing: .04em;
}
.method-get  { background: var(--surface-3); color: var(--text); }
.method-post { background: var(--text); color: var(--surface); }
.endpoint-path {
  font-family: var(--mono); font-size: .86rem; font-weight: 600;
  color: var(--text); word-break: break-all;
}
.endpoint p { font-size: .87rem; color: var(--text-dim); margin: 0; }

/* Parameter / field tables */
.doc-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.doc-table-wrap { overflow-x: auto; }
.doc-table th {
  text-align: left; padding: 8px 12px;
  font-size: .71rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-faint);
  border-bottom: 1px solid var(--border);
}
.doc-table td {
  padding: 9px 12px; border-bottom: 1px solid var(--border-sl);
  vertical-align: top; color: var(--text-dim);
}
.doc-table td:first-child {
  font-family: var(--mono); font-size: .82rem; color: var(--text); white-space: nowrap;
}
.doc-table tr:last-child td { border-bottom: none; }
.doc-table code { font-family: var(--mono); font-size: .8rem; color: var(--brand); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.tab {
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; background: none;
  font-size: .83rem; font-weight: 600; color: var(--text-dim);
}
.tab[aria-selected="true"] {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px;
}
.tab-panel { display: grid; gap: 16px; }
.tab-panel[hidden] { display: none; }
