/* license-hub design system — shared by the admin back office and the customer
   portal. Server-rendered, zero framework. Dark is the base palette; light is
   applied via prefers-color-scheme AND an explicit [data-theme] override set
   server-side (no flash). All surfaces use only these tokens. */

:root {
  color-scheme: dark light;

  /* dark palette (default) */
  --bg: #0b0d10;
  --surface: #14171c;
  --surface-raised: #1a1e25;
  --inset: #0e1115;
  --line: #242a32;
  --line-strong: #313945;
  --fg: #e6e9ee;
  --fg-soft: #c2c8d2;
  --muted: #8b94a1;
  --accent: #4f8cff;
  --accent-fg: #ffffff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --ok: #2fbf71;
  --warn: #e9b949;
  --bad: #e05252;
  --ring: #5a9bff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, 0.45);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;

  --maxw: 1180px;
  --header-h: 56px;
}

/* light palette — OS preference, overridable by [data-theme] */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --inset: #eef1f5;
    --line: #e2e7ee;
    --line-strong: #cfd6e0;
    --fg: #161b22;
    --fg-soft: #2f3742;
    --muted: #5b6573;
    --accent: #2f6fe0;
    --accent-fg: #ffffff;
    --accent-soft: rgba(47, 111, 224, 0.10);
    --ok: #1e9e5a;
    --warn: #9a7415;
    --bad: #c43d3d;
    --ring: #2f6fe0;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 6px 24px rgba(16, 24, 40, 0.10);
    --shadow-pop: 0 12px 40px rgba(16, 24, 40, 0.16);
  }
}

/* explicit overrides win over the media query (zero-flash, server-set) */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d10; --surface: #14171c; --surface-raised: #1a1e25; --inset: #0e1115;
  --line: #242a32; --line-strong: #313945; --fg: #e6e9ee; --fg-soft: #c2c8d2;
  --muted: #8b94a1; --accent: #4f8cff; --accent-fg: #fff; --accent-soft: rgba(79,140,255,.14);
  --ok: #2fbf71; --warn: #e9b949; --bad: #e05252; --ring: #5a9bff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3); --shadow-md: 0 6px 24px rgba(0,0,0,.35); --shadow-pop: 0 12px 40px rgba(0,0,0,.45);
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f9; --surface: #fff; --surface-raised: #fff; --inset: #eef1f5;
  --line: #e2e7ee; --line-strong: #cfd6e0; --fg: #161b22; --fg-soft: #2f3742;
  --muted: #5b6573; --accent: #2f6fe0; --accent-fg: #fff; --accent-soft: rgba(47,111,224,.10);
  --ok: #1e9e5a; --warn: #9a7415; --bad: #c43d3d; --ring: #2f6fe0;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06); --shadow-md: 0 6px 24px rgba(16,24,40,.10); --shadow-pop: 0 12px 40px rgba(16,24,40,.16);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 22px; line-height: 1.25; margin: 0 0 var(--space-4); letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: var(--space-5) 0 var(--space-2); }
h3 { font-size: 14px; margin: var(--space-4) 0 var(--space-2); color: var(--fg-soft); }
p { margin: 0 0 var(--space-3); }

/* focus ring — visible only for keyboard users */
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--radius-sm); }
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-fg);
  padding: var(--space-2) var(--space-4); border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* ---- header / nav ---- */
header.app {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--space-5);
  padding: 0 var(--space-5); height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
header.app .brand { font-weight: 700; letter-spacing: 0.2px; display: flex; align-items: center; gap: var(--space-2); }
header.app .brand svg { width: 20px; height: 20px; }
header.app nav { display: flex; gap: var(--space-1); flex-wrap: wrap; }
header.app nav a {
  color: var(--fg-soft); padding: 6px 10px; border-radius: var(--radius-sm);
  font-weight: 500; white-space: nowrap;
}
header.app nav a:hover { background: var(--inset); text-decoration: none; color: var(--fg); }
header.app nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
header.app .spacer { flex: 1; }
header.app .who { color: var(--muted); font-size: 13px; }
.nav-toggle { display: none; }

main { width: 100%; max-width: var(--maxw); margin: var(--space-5) auto; padding: 0 var(--space-5); flex: 1; }

/* ---- cards & layout ---- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--space-4); margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.card.raised { background: var(--surface-raised); box-shadow: var(--shadow-md); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-4); }
.row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

/* Money card. The one tile that is not a count, so it reads differently on
   purpose: accent-tinted, with a left rule and a slightly smaller number (a
   formatted amount is 3–4× longer than a count and would otherwise wrap). */
.stat.money {
  background: linear-gradient(180deg, var(--accent-soft), transparent 70%);
  border-left: 3px solid var(--accent);
}
.stat.money .n { font-size: 23px; color: var(--fg); }
.stat.money .sub { margin-top: 2px; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; background: var(--inset); }
tbody tr:hover { background: var(--inset); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- forms ---- */
label { display: block; margin: var(--space-3) 0 var(--space-1); color: var(--muted); font-size: 13px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 9px 11px; background: var(--inset); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--radius-sm); font: inherit;
}
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 88px; resize: vertical; font-family: var(--font-mono); font-size: 13px; }
.field-hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* Status inline de consulta remota (auto-preenchimento de CEP). Herda o tamanho
   do .field-hint que o envolve; só a COR muda por estado, e o estado neutro é o
   mesmo cinza da dica para que a linha não pisque de cor ao aparecer. */
.lookup-status { margin-left: 6px; }
.lookup-status[data-state="loading"] { color: var(--muted); }
.lookup-status[data-state="ok"] { color: var(--ok); }
.lookup-status[data-state="error"] { color: var(--bad); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); margin: 0 0 var(--space-4); }
legend { padding: 0 var(--space-2); color: var(--fg-soft); font-weight: 600; }

/* ---- buttons ---- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  margin-top: var(--space-3); padding: 9px 16px; background: var(--accent); color: var(--accent-fg);
  border: 1px solid transparent; border-radius: var(--radius-sm); font: inherit; font-weight: 600;
  cursor: pointer; transition: filter .12s ease, background .12s ease;
}
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
button:active, .btn:active { filter: brightness(0.94); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.small, .btn.small { margin: 0; padding: 4px 10px; font-size: 12px; }
button.ghost, .btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--fg); }
button.ghost:hover, .btn.ghost:hover { background: var(--inset); filter: none; }
button.danger, .btn.danger { background: var(--bad); }
button.link { background: none; border: none; color: var(--accent); padding: 0; margin: 0; font-weight: 500; }
form.inline { display: inline; margin: 0; }

/* ---- badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px;
  border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; line-height: 1.6;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active, .badge.paid, .badge.granted, .badge.authorized { background: rgba(47,191,113,.16); color: var(--ok); }
.badge.suspended, .badge.overdue, .badge.paused, .badge.pending, .badge.awaiting_payment { background: rgba(233,185,73,.18); color: var(--warn); }
.badge.revoked, .badge.canceled, .badge.failed, .badge.refunded { background: rgba(224,82,82,.16); color: var(--bad); }
.badge.neutral, .badge.deactivated { background: rgba(139,148,161,.18); color: var(--muted); }

/* ---- flash / toast ---- */
.flash {
  padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: var(--space-4);
  background: var(--accent-soft); border: 1px solid var(--accent); color: var(--fg);
}
.flash.error { background: rgba(224,82,82,.12); border-color: var(--bad); }
.flash.ok { background: rgba(47,191,113,.12); border-color: var(--ok); }
.flash.warn { background: rgba(233,185,73,.12); border-color: var(--warn); }

.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: var(--space-6) var(--space-4); }

code, .code {
  background: var(--inset); border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px;
  font: 12px var(--font-mono); word-break: break-all;
}
pre {
  background: var(--inset); border: 1px solid var(--line); padding: var(--space-3);
  border-radius: var(--radius-sm); overflow-x: auto; font: 12px var(--font-mono);
}

/* copyable key/value with a copy button */
.copy { display: inline-flex; align-items: center; gap: var(--space-2); }
.copy button { margin: 0; padding: 3px 8px; font-size: 11px; }

/* secret reveal row — shared by every surface that shows a generated/stored
   secret once (Deploy Hub, Stack Library, Portainer manager). The show/hide +
   copy contract is driven globally by app.js via [data-secret]/[data-secret-input]
   /[data-secret-toggle]; no per-page JS. */
.secret-row { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.secret-row .reveal { flex: 1; min-width: 180px; font-family: var(--font-mono); }

/* ---- confirm dialog (native <dialog>) ---- */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  color: var(--fg); padding: var(--space-5); max-width: 420px; box-shadow: var(--shadow-pop);
}
dialog::backdrop { background: rgba(0,0,0,.5); backdrop-filter: blur(2px); }

/* ---- footer (lang + theme switchers) ---- */
footer.app {
  display: flex; align-items: center; justify-content: center; gap: var(--space-4);
  padding: var(--space-5); color: var(--muted); font-size: 12px; flex-wrap: wrap;
}
footer.app .switch { display: inline-flex; gap: 2px; align-items: center; }
footer.app .switch a, footer.app .switch button {
  color: var(--muted); padding: 3px 8px; border-radius: var(--radius-sm); margin: 0;
  background: none; border: 1px solid transparent; font-size: 12px; cursor: pointer;
}
footer.app .switch a[aria-current="true"] { color: var(--fg); background: var(--surface); border-color: var(--line); text-decoration: none; }
footer.app .sep { opacity: .4; }

/* login / centered single-card pages */
.login-wrap { max-width: 400px; margin: var(--space-7) auto; }

/* utility spacing */
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.gap { height: var(--space-4); }
.stack > * + * { margin-top: var(--space-3); }
.right { margin-left: auto; }
.wrap { flex-wrap: wrap; }

/* ===========================================================================
   F10 management components — toolbar, selection/bulk, sortable, pager, menu,
   tabs, crumbs, tooltip, skeleton, stepper, toast, health, kv. Token-based.
   Contract (used by admin + portal templates):
     - list page: <form data-bulk-form><table>… checkboxes name="ids"
       value=ID data-bulk-item, header checkbox data-bulk-all,
       <div class="bulkbar" data-bulkbar hidden> with <span data-bulk-count>
       and action <button name="action" value="…">. "select all matching" via
       <button class="allmatch" data-bulk-allmatch> toggling hidden input
       name="all" data-bulk-allflag.
     - search: <input data-search> auto-submits its form (debounced).
     - sortable th: <th class="sortable" aria-sort="…"><a href="?sort=…">.
     - dropdown: <details class="menu"><summary>…</summary>
       <div class="menu-pop">…</div></details>.
     - typed confirm: <form data-confirm="…" data-confirm-type="REVOKE">.
     - toast API: window.hubToast(msg, kind) — kind ∈ ok|error|info.
   =========================================================================== */

/* checkbox / radio reset — the global input rule above forces width:100% */
input[type="checkbox"], input[type="radio"] {
  width: auto; height: 16px; margin: 0; padding: 0; accent-color: var(--accent);
  vertical-align: middle; cursor: pointer;
}

/* toggle switch (NB: footer uses .switch; this is .toggle) */
.toggle { position: relative; display: inline-flex; width: 38px; height: 22px; flex: none; }
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle .track { width: 100%; height: 100%; background: var(--line-strong); border-radius: var(--radius-pill); transition: background .15s ease; }
.toggle .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s ease; }
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(16px); }

/* segmented control */
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.segmented a, .segmented button { margin: 0; border: 0; border-radius: 0; background: transparent; color: var(--fg-soft); padding: 6px 12px; font-size: 13px; font-weight: 500; }
.segmented a:hover, .segmented button:hover { background: var(--inset); filter: none; text-decoration: none; }
.segmented a[aria-current="true"], .segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* list toolbar */
.toolbar { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; margin-bottom: var(--space-3); }
.toolbar form.filterbar { display: contents; }
.toolbar .search { flex: 1 1 220px; min-width: 160px; position: relative; margin: 0; }
.toolbar .search input { padding-left: 32px; }
.toolbar .search::before { content: "⌕"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 15px; }
.toolbar select { width: auto; min-width: 120px; }
.toolbar .count { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.toolbar .clear { color: var(--muted); font-size: 13px; }

/* sortable table headers */
th.sortable { padding: 0; }
th.sortable a { display: flex; align-items: center; gap: 4px; padding: 10px 12px; color: var(--muted); }
th.sortable a:hover { color: var(--fg); text-decoration: none; }
th.sortable .arr { opacity: 0; font-size: 9px; transition: transform .1s ease; }
th.sortable[aria-sort="ascending"] .arr, th.sortable[aria-sort="descending"] .arr { opacity: 1; color: var(--accent); }
th.sortable[aria-sort="descending"] .arr { transform: rotate(180deg); }

/* selectable rows */
td.sel-col, th.sel-col { width: 36px; text-align: center; padding-right: 0; }
tbody tr.sel { background: var(--accent-soft); }
tbody tr.sel:hover { background: color-mix(in srgb, var(--accent-soft) 80%, var(--inset)); }

/* bulk action bar */
.bulkbar {
  position: sticky; bottom: var(--space-4); z-index: 20;
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  margin-top: var(--space-3); padding: 10px 14px;
  background: var(--surface-raised); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-pop);
}
.bulkbar[hidden] { display: none; }
.bulkbar .n { font-weight: 700; }
.bulkbar .acts { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-left: auto; }
.bulkbar .acts button { margin: 0; }
.bulkbar .allmatch { color: var(--accent); font-size: 13px; cursor: pointer; background: none; border: none; margin: 0; padding: 0; font-weight: 500; }

/* pager */
.pager { display: flex; align-items: center; justify-content: center; gap: var(--space-2); margin-top: var(--space-4); flex-wrap: wrap; }
.pager a, .pager span.pg { padding: 5px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--fg-soft); font-size: 13px; }
.pager a:hover { background: var(--inset); text-decoration: none; color: var(--fg); }
.pager [aria-current="page"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.pager .disabled { opacity: .4; pointer-events: none; }
.pager select { width: auto; padding: 4px 8px; margin: 0; }
.pager .info { color: var(--muted); font-size: 12px; }

/* dropdown menu (native details/summary — zero JS) */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; cursor: pointer; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); color: var(--fg); user-select: none; font-size: 12px; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu[open] > summary { background: var(--inset); }
details.menu .menu-pop {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 25; min-width: 184px;
  background: var(--surface-raised); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop); padding: 4px; display: flex; flex-direction: column;
}
.menu-pop a, .menu-pop button { margin: 0; justify-content: flex-start; background: none; border: none; color: var(--fg); padding: 7px 10px; border-radius: var(--radius-sm); font-weight: 500; text-align: left; font-size: 13px; width: 100%; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--inset); text-decoration: none; filter: none; }
.menu-pop .sep { height: 1px; background: var(--line); margin: 4px 0; }
.menu-pop .danger { color: var(--bad); }
.menu-pop form.inline { display: block; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: var(--space-4); flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; border-radius: var(--radius-sm) var(--radius-sm) 0 0; font-weight: 500; }
.tabs a:hover { color: var(--fg); background: var(--inset); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* breadcrumbs */
.crumbs { display: flex; gap: var(--space-2); align-items: center; color: var(--muted); font-size: 13px; margin-bottom: var(--space-3); flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--fg); }
.crumbs .sep { opacity: .5; }

/* tooltip */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 4px 8px; border-radius: var(--radius-sm);
  font-size: 12px; white-space: normal; width: max-content; max-width: min(280px, 80vw);
  line-height: 1.35; text-align: left; z-index: 40; box-shadow: var(--shadow-md);
}

/* skeleton */
.skeleton { background: linear-gradient(90deg, var(--inset) 25%, var(--line) 37%, var(--inset) 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: var(--radius-sm); min-height: 14px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* stat enhancements */
.stat .delta { font-size: 12px; font-weight: 600; }
.stat .delta.up { color: var(--ok); } .stat .delta.down { color: var(--bad); }
.stat .ico { width: 18px; height: 18px; color: var(--muted); }
.stat .sub { color: var(--muted); font-size: 12px; }

/* ---- money totals strip (billing list) ----
   One row per CURRENCY, never merged: a single figure over mixed currencies is
   a number that matches no real money. */
.totals { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-3); }
.totals-row {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--space-3);
}
.totals-head {
  display: flex; align-items: baseline; gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.totals-head .cur {
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  padding: 2px 7px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.totals-head .muted { font-size: 12px; }
/* auto-fit so it degrades to 2 columns then 1 on narrow screens without a query */
.totals-figs {
  display: grid; gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
}
.fig { display: flex; flex-direction: column; gap: 1px; }
.fig .v { font-size: 19px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.fig .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.fig .k .muted { text-transform: none; letter-spacing: 0; }
.fig.received .v { color: var(--ok); }
.fig.pending  .v { color: var(--warn); }
.fig.refunded .v { color: var(--bad); }

/* empty state with icon + CTA */
.empty .ico { display: block; font-size: 28px; opacity: .5; margin-bottom: var(--space-2); }
.empty .cta { margin-top: var(--space-3); }

/* stepper / wizard */
.steps { display: flex; gap: var(--space-2); list-style: none; padding: 0; margin: 0 0 var(--space-5); flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: var(--space-2); color: var(--muted); font-size: 13px; }
.steps li .num { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-strong); font-size: 12px; font-weight: 700; }
.steps li.active { color: var(--fg); }
.steps li.active .num { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.steps li.done .num { background: var(--ok); color: #fff; border-color: var(--ok); }
.steps li:not(:last-child)::after { content: "→"; color: var(--muted); margin-left: var(--space-1); }

/* toast */
.toasts { position: fixed; top: calc(var(--header-h) + var(--space-3)); right: var(--space-4); z-index: 60; display: flex; flex-direction: column; gap: var(--space-2); max-width: 340px; }
.toast { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-raised); border: 1px solid var(--line-strong); box-shadow: var(--shadow-pop); color: var(--fg); animation: toastin .2s ease; }
.toast.ok { border-color: var(--ok); } .toast.error { border-color: var(--bad); } .toast.info { border-color: var(--accent); }
@keyframes toastin { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* integration health pills */
.health { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.health::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.health.on::before { background: var(--ok); } .health.off::before { background: var(--bad); } .health.warn::before { background: var(--warn); }

/* key/value detail rows */
.kv { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: var(--space-2) var(--space-4); margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; word-break: break-word; }

/* qr block (TOTP enrollment) */
.qr { display: inline-block; padding: var(--space-3); background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.qr img { display: block; width: 180px; height: 180px; image-rendering: pixelated; }

/* ---- responsive ---- */
@media (max-width: 720px) {
  header.app { gap: var(--space-3); padding: 0 var(--space-3); }
  header.app nav { display: none; position: absolute; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; background: var(--surface); border-bottom: 1px solid var(--line); padding: var(--space-2); gap: 0; }
  header.app nav.open { display: flex; }
  header.app nav a { padding: 10px 12px; border-radius: 0; }
  .nav-toggle { display: inline-flex; margin: 0; padding: 6px 10px; }
  main { padding: 0 var(--space-3); margin: var(--space-4) auto; }
  h1 { font-size: 19px; }
  /* tables collapse to stacked cards */
  table.responsive thead { position: absolute; left: -9999px; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: var(--space-3); padding: var(--space-2); }
  table.responsive td { border: none; padding: 6px 8px; display: flex; justify-content: space-between; gap: var(--space-3); }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 600; }
}

/* responsive — F10 management components */
@media (max-width: 720px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .search { flex: 1 1 auto; }
  .toolbar select { width: 100%; }
  .toolbar .count { margin-left: 0; }
  .bulkbar { flex-direction: column; align-items: stretch; }
  .bulkbar .acts { margin-left: 0; }
  .kv { grid-template-columns: 1fr; gap: 2px var(--space-2); }
  .kv dd { margin-bottom: var(--space-2); }
  details.menu .menu-pop { right: auto; left: 0; }
  .toasts { left: var(--space-3); right: var(--space-3); max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Entitlement editor — friendly grouped fields replacing raw params JSON
   (admin plan/addon forms). Tokens only; inherits inputs/grid from above. */
.ent-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4) var(--space-4);
  margin: var(--space-3) 0;
}
.ent-group > legend {
  font-weight: 600;
  font-size: .85rem;
  color: var(--muted);
  padding: 0 var(--space-2);
}
.ent-group details { margin-top: var(--space-3); }
.ent-group summary { cursor: pointer; color: var(--muted); font-size: .9rem; }

/* ── Integrations / billing activation (F11) ──────────────────────────── */
.readiness { margin: var(--space-4) 0 var(--space-5); }
.readiness-banner {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line); border-radius: var(--radius);
  font-weight: 500; margin-bottom: var(--space-4);
}
.readiness-banner.ok   { background: rgba(47,191,113,.10); border-color: var(--ok); }
.readiness-banner.warn { background: rgba(233,185,73,.10); border-color: var(--warn); }
.readiness-banner .ico { font-size: 20px; line-height: 1; flex: none; }
.readiness-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-3);
}
.readiness-item {
  display: flex; flex-direction: column; gap: 3px;
  padding: var(--space-3); background: var(--surface);
  border: 1px solid var(--line); border-left: 3px solid var(--line-strong);
  border-radius: var(--radius-sm);
}
.readiness-item.on   { border-left-color: var(--ok); }
.readiness-item.warn { border-left-color: var(--warn); }
.readiness-item.off  { border-left-color: var(--bad); }
.readiness-item .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.readiness-item .v { display: flex; align-items: center; gap: var(--space-2); font-weight: 600; }
.readiness-item .v .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.readiness-item.on   .v .dot { background: var(--ok); }
.readiness-item.warn .v .dot { background: var(--warn); }
.readiness-item.off  .v .dot { background: var(--bad); }
.readiness-item a { font-size: 12px; margin-top: 2px; }

.gw-card { transition: box-shadow .15s ease; }
.gw-card:hover { box-shadow: var(--shadow-pop); }
.gw-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.gw-statuses { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-3) 0; }
.gw-url { display: flex; flex-direction: column; gap: 4px; margin: var(--space-3) 0; }
.gw-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); align-items: end; }
.gw-field { display: flex; flex-direction: column; gap: 4px; }
.gw-field small { color: var(--muted); font-size: 12px; }
.gw-field-narrow { max-width: 360px; margin-top: var(--space-3); }
.gw-check { display: inline-flex; align-items: center; gap: var(--space-2); }
.gw-check input { width: auto; }
.gw-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
.gw-meta { color: var(--muted); font-size: 13px; margin-top: var(--space-3); }
