/* NotifyHub web UI
   One accent (signal orange) for actions only; status colors carry meaning. */

/* ------------------------------------------------------------------ tokens */
:root {
  --paper: #F6F7F9;
  --surface: #FFFFFF;
  --surface-2: #F0F2F5;
  --ink: #1B2330;
  --ink-2: #5B6675;
  --ink-3: #8A94A3;
  --line: #E3E6EB;
  --line-strong: #CDD2DA;

  --accent: #F2541B;
  --accent-hover: #D9460F;
  --accent-soft: #FDEBE3;
  --on-accent: #FFFFFF;

  --ok: #1F8A5B;      --ok-soft: #E3F4EC;
  --bad: #C8372D;     --bad-soft: #FBE7E5;
  --wait: #B7791F;    --wait-soft: #FBF1DE;
  --info: #2F6FDE;    --info-soft: #E5EEFC;
  --muted-soft: #EEF0F3;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-pop: 0 12px 32px rgba(27, 35, 48, .16), 0 2px 6px rgba(27, 35, 48, .08);
  --focus: 0 0 0 3px rgba(242, 84, 27, .35);

  --rail-w: 248px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --mono: "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12161D; --surface: #1A1F28; --surface-2: #222833;
    --ink: #E7EAEE; --ink-2: #A4ADBA; --ink-3: #79838F;
    --line: #2B323E; --line-strong: #3A4250;
    --accent: #FF6A33; --accent-hover: #FF8152; --accent-soft: #3A2219;
    --ok: #4CC08A; --ok-soft: #173327; --bad: #FF7A6E; --bad-soft: #3B1E1C;
    --wait: #E8AE4F; --wait-soft: #3A2E17; --info: #79A6FF; --info-soft: #1C2A44; --muted-soft: #262C37;
    --shadow-pop: 0 16px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #12161D; --surface: #1A1F28; --surface-2: #222833;
  --ink: #E7EAEE; --ink-2: #A4ADBA; --ink-3: #79838F;
  --line: #2B323E; --line-strong: #3A4250;
  --accent: #FF6A33; --accent-hover: #FF8152; --accent-soft: #3A2219;
  --ok: #4CC08A; --ok-soft: #173327; --bad: #FF7A6E; --bad-soft: #3B1E1C;
  --wait: #E8AE4F; --wait-soft: #3A2E17; --info: #79A6FF; --info-soft: #1C2A44; --muted-soft: #262C37;
  --shadow-pop: 0 16px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 15px/1.5 var(--font); font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: .86em; }
small, .small { font-size: .85rem; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: none; box-shadow: var(--focus); }
[hidden] { display: none !important; }

.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------------ app shell */
.shell { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { width: 100%; max-width: 1200px; padding: 24px 28px 64px; }

.rail {
  width: var(--rail-w); flex: none; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 40;
}
.rail-brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px 14px; color: var(--ink); font: 650 1.1rem var(--font-display); }
.rail-brand:hover { text-decoration: none; }
.rail-nav { flex: 1; overflow-y: auto; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.rail-nav a {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px;
  color: var(--ink-2); font-weight: 500;
}
.rail-nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.rail-nav a.active { color: var(--ink); background: var(--surface-2); }
.rail-nav a.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.rail-nav a.active .ico { color: var(--accent); }
.rail-group { padding: 16px 12px 6px; color: var(--ink-3); font-size: .8rem; }
.rail-foot { border-top: 1px solid var(--line); padding: 12px; display: flex; align-items: center; gap: 6px; }
.rail-user { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 8px; color: var(--ink); }
.rail-user:hover, .rail-user.active { background: var(--surface-2); text-decoration: none; }
.rail-user-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.rail-user-text strong { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-user-text small { color: var(--ink-3); font-size: .78rem; }
.avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 650; font-size: .82rem;
}

.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 10px 28px; background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line);
}
.topbar-title { font-size: 1.3rem; font-weight: 650; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-tools { display: flex; align-items: center; gap: 8px; }
.tenant-name { color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.icon-btn.rail-toggle { display: none; }
.theme-dark { display: none; }
:root[data-theme="dark"] .theme-light { display: none; }
:root[data-theme="dark"] .theme-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-light { display: none; }
  :root:not([data-theme="light"]) .theme-dark { display: block; }
}
.scrim { position: fixed; inset: 0; background: rgba(10, 14, 20, .45); z-index: 35; }

/* ------------------------------------------------------------------ buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink);
  font: 550 .92rem var(--font); cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { height: 32px; padding: 0 10px; font-size: .85rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.chip-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 550 .88rem var(--font); cursor: pointer;
  max-width: 260px;
}
.chip-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-btn:hover { border-color: var(--accent); }

label { display: block; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span, .field-label { font-weight: 550; font-size: .9rem; }
.field .hint { color: var(--ink-3); font-size: .82rem; font-weight: 400; }
.field .req::after { content: " *"; color: var(--accent); }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=url],
input[type=search], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: 400 .95rem var(--font);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
textarea.mono { font-family: var(--mono); font-size: .85rem; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input[aria-invalid=true], textarea[aria-invalid=true], select[aria-invalid=true] { border-color: var(--bad); }
.field-error { color: var(--bad); font-size: .82rem; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: .92rem; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 36px; height: 20px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }

/* segmented choice (channel picker, tabs) */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); font-weight: 550; cursor: pointer;
}
.segmented input:checked + span { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.segmented input:focus-visible + span { box-shadow: var(--focus); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button {
  border: 0; background: none; padding: 10px 14px; color: var(--ink-2); font: 550 .95rem var(--font); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); }

/* ------------------------------------------------------------------ panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; }
.panel + .panel { margin-top: 20px; }
.grid-2 > .panel + .panel, .grid-2 > .stack + .stack { margin-top: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head p { margin: 2px 0 0; color: var(--ink-2); font-size: .9rem; }
.panel-flush { padding: 0; overflow: hidden; }
.panel-flush .panel-head { padding: 16px 20px 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }
.toolbar select, .toolbar input { width: auto; min-width: 150px; }

.callout { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; font-size: .9rem; margin-bottom: 14px; }
.callout .ico { margin-top: 2px; }
.callout-error { background: var(--bad-soft); color: var(--bad); }
.callout-info { background: var(--info-soft); color: var(--info); }
.callout-warn { background: var(--wait-soft); color: var(--wait); }
.callout-ok { background: var(--ok-soft); color: var(--ok); }

/* ------------------------------------------------------------------ dashboard */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 20px; }
.kpi { background: var(--surface); padding: 16px 20px; }
.kpi-label { color: var(--ink-2); font-size: .88rem; display: flex; align-items: center; gap: 8px; }
.kpi-label i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.kpi-value { font: 650 1.85rem/1.15 var(--font-display); margin-top: 6px; letter-spacing: -.02em; }
.kpi-sub { color: var(--ink-3); font-size: .82rem; margin-top: 2px; }

.chart { width: 100%; height: auto; display: block; }
.chart .bar-ok { fill: var(--ok); }
.chart .bar-bad { fill: var(--bad); }
.chart .bar-other { fill: var(--line-strong); }
.chart .axis { fill: var(--ink-3); font-size: 11px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--ink-2); font-size: .85rem; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.meter-list { display: flex; flex-direction: column; gap: 12px; }
.meter-row { display: grid; grid-template-columns: 96px 1fr 56px; gap: 10px; align-items: center; font-size: .9rem; }
.meter { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter > b { display: block; height: 100%; background: var(--ink-2); border-radius: 999px; }
.meter-row .num { text-align: right; color: var(--ink-2); }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; font-weight: 550; color: var(--ink-2); font-size: .84rem; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover td { background: var(--surface-2); }
table.data .num { text-align: right; }
table.data .cell-check { width: 44px; padding-right: 0; }
table.data .cell-check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
table.data tbody tr.selected td { background: var(--accent-soft, var(--surface-2)); }
.bulkbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--radius, 12px); background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.bulkbar .grow { flex: 1; }
.cell-main { font-weight: 550; }
.cell-sub { color: var(--ink-3); font-size: .82rem; }
.truncate { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: .88rem; }

/* status badges */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: var(--muted-soft); color: var(--ink-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.wait { background: var(--wait-soft); color: var(--wait); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.plain::before { display: none; }
.tag { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); font-size: .8rem; font-weight: 550; }

/* ------------------------------------------------------------------ delivery trail (the signature element) */
.trail { display: flex; align-items: flex-start; margin: 6px 0 18px; }
.trail-step { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; min-width: 0; }
.trail-step::before {
  content: ""; position: absolute; top: 9px; left: calc(-50% + 11px); right: calc(50% + 11px); height: 2px; background: var(--line-strong);
}
.trail-step:first-child::before { display: none; }
.trail-dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); position: relative; z-index: 1; }
.trail-step span { font-size: .8rem; color: var(--ink-3); font-weight: 550; }
.trail-step small { font-size: .74rem; color: var(--ink-3); }
.trail-step.done .trail-dot { border-color: var(--ok); background: var(--ok); box-shadow: inset 0 0 0 3px var(--surface); }
.trail-step.done::before { background: var(--ok); }
.trail-step.done span { color: var(--ink); }
.trail-step.current .trail-dot { border-color: var(--wait); background: var(--wait); box-shadow: inset 0 0 0 3px var(--surface); }
.trail-step.current span { color: var(--wait); }
.trail-step.failed .trail-dot { border-color: var(--bad); background: var(--bad); box-shadow: inset 0 0 0 3px var(--surface); }
.trail-step.failed span { color: var(--bad); }
.trail-step.failed::before { background: var(--bad); }
@media (prefers-reduced-motion: no-preference) {
  .trail-step.current .trail-dot { animation: pulse 1.6s ease-in-out infinite; }
  @keyframes pulse { 50% { box-shadow: inset 0 0 0 3px var(--surface), 0 0 0 6px color-mix(in srgb, var(--wait) 25%, transparent); } }
}

/* attempts timeline */
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 18px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); }
.timeline li.ok::before { background: var(--ok); }
.timeline li.bad::before { background: var(--bad); }
.timeline .t-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-weight: 550; font-size: .9rem; }
.timeline .t-body { color: var(--ink-2); font-size: .85rem; word-break: break-word; }

/* key-value list */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: .9rem; margin: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; word-break: break-word; }

/* ------------------------------------------------------------------ providers */
.provider-groups { display: flex; flex-direction: column; gap: 24px; }
.provider-group h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--ink-2); font-size: .95rem; }
.provider-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.provider-item { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); align-items: center; }
.provider-item:last-child { border-bottom: 0; }
.provider-item .p-name { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.provider-item .p-meta { color: var(--ink-3); font-size: .84rem; margin-top: 2px; display: flex; gap: 4px 12px; flex-wrap: wrap; align-items: center; }
.provider-item .p-actions { display: flex; align-items: center; gap: 4px; }
.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.catalog button {
  text-align: left; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer; color: var(--ink); font: inherit;
}
.catalog button:hover { border-color: var(--accent); }
.catalog strong { display: block; font-weight: 600; }
.catalog small { color: var(--ink-3); display: block; margin-top: 2px; line-height: 1.35; }
.catalog .cat-channel { color: var(--ink-3); font-size: .8rem; margin: 6px 0 2px; grid-column: 1 / -1; }

/* ------------------------------------------------------------------ send */
.compose-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--ink-3); font-size: .82rem; margin-top: -8px; margin-bottom: 14px; }
.compose-meta .over { color: var(--bad); font-weight: 600; }
.vars { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.var-row { display: grid; grid-template-columns: 160px 1fr; gap: 8px; align-items: center; }
.var-row code { background: var(--surface-2); padding: 6px 10px; border-radius: 6px; overflow: hidden; text-overflow: ellipsis; }
.preview { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 14px; background: var(--surface-2); white-space: pre-wrap; word-break: break-word; font-size: .92rem; }
.phone-preview { max-width: 320px; }
.phone-preview .bubble { background: var(--surface); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 10px 14px; white-space: pre-wrap; word-break: break-word; font-size: .92rem; }
.phone-preview .from { color: var(--ink-3); font-size: .8rem; margin-bottom: 6px; }
.result-list { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.result-list li { padding: 4px 0; border-bottom: 1px solid var(--line); }

/* ------------------------------------------------------------------ dialogs */
dialog { border: 0; padding: 0; background: transparent; color: var(--ink); max-width: calc(100vw - 24px); }
dialog::backdrop { background: rgba(10, 14, 20, .5); }
.modal-card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 48px); display: flex; flex-direction: column; }
.modal-card.wide { width: min(760px, calc(100vw - 24px)); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px 0; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-title { font-size: 1.15rem; font-weight: 650; }
.modal-text { color: var(--ink-2); padding: 0 20px; margin-top: 8px; }
#confirm-dialog .modal-card { padding-top: 20px; }
#confirm-dialog .modal-title { padding: 0 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.secret-box { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-family: var(--mono); font-size: .85rem; word-break: break-all; }
.secret-box span { flex: 1; }

dialog.drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; max-width: 100vw; }
dialog.drawer .drawer-card { background: var(--surface); width: min(560px, 100vw); height: 100%; display: flex; flex-direction: column; box-shadow: var(--shadow-pop); }
dialog.drawer .modal-body { flex: 1; }
@media (prefers-reduced-motion: no-preference) {
  dialog.drawer[open] .drawer-card { animation: slide-in .22s ease-out; }
  @keyframes slide-in { from { transform: translateX(40px); opacity: .4; } }
}

/* toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--ink); color: var(--surface); box-shadow: var(--shadow-pop); font-size: .92rem; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok .ico { color: var(--ok); }
:root[data-theme="dark"] .toast.ok .ico { color: #1F8A5B; }

/* empty + loading */
.empty { text-align: center; padding: 40px 20px; color: var(--ink-2); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty .btn { margin-top: 8px; }
.skeleton { height: 44px; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; margin: 8px 0; }
@media (prefers-reduced-motion: no-preference) { .skeleton { animation: shimmer 1.2s linear infinite; } @keyframes shimmer { to { background-position: -200% 0; } } }

.gate { max-width: 640px; }
.gate h2 { margin-bottom: 6px; }
.tenant-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.tenant-list button {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; padding: 12px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); cursor: pointer; font: inherit;
}
.tenant-list button:hover { border-color: var(--accent); }

pre.code { background: #141922; color: #E6EAF0; border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; font: .82rem/1.55 var(--mono); margin: 0 0 14px; }
.copy-wrap { position: relative; }
.copy-wrap .icon-btn { position: absolute; top: 6px; right: 6px; color: #A9B2BF; }
.copy-wrap .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

/* ------------------------------------------------------------------ sign-in page */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent 60%), var(--paper); }
.auth { width: 100%; max-width: 420px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font: 650 1.3rem var(--font-display); margin-bottom: 20px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 28px; box-shadow: 0 1px 2px rgba(27,35,48,.04); }
.auth-card h1 { font-size: 1.5rem; font-weight: 600; text-align: center; margin-bottom: 20px; }
.field-icon { position: relative; margin-bottom: 14px; }
.field-icon > .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.field-icon input { padding-left: 40px; height: 44px; }
.field-icon input[data-password] { padding-right: 64px; }
.field-icon .reveal { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--ink-2); font: 550 .85rem var(--font); padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.field-icon .reveal:hover { background: var(--surface-2); }
.auth-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin: 4px 0 16px; }
.forgot summary { color: var(--accent); cursor: pointer; font-size: .9rem; list-style: none; }
.forgot summary::-webkit-details-marker { display: none; }
.forgot p { margin: 8px 0 0; font-size: .84rem; color: var(--ink-2); max-width: 220px; }
.auth-note { font-size: .84rem; color: var(--ink-2); background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.auth-card .btn-primary { height: 44px; font-size: 1rem; margin-top: 4px; }
.auth-foot { text-align: center; color: var(--ink-3); font-size: .85rem; margin-top: 18px; }

/* billing */
.kpis.two { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 640px; }
.grid-2 + .panel, .kpis + .panel { margin-top: 20px; }
.inline.nowrap { flex-wrap: nowrap; }
@media (max-width: 900px) { .inline.nowrap { flex-wrap: wrap; } }
.notice { align-items: center; flex-wrap: wrap; }
.notice .grow { flex: 1; }
.notice .btn { flex: none; }
.kpis.wallet .kpi { position: relative; }
.kpi-value.small-value { font-size: 1.35rem; padding-top: 5px; }
.kpi-sub .badge { margin-right: 4px; }
.kpi-action { margin-top: 10px; }
.kpis.wallet .meter { margin-top: 8px; }
.kpis.wallet .meter.hot > b { background: var(--wait); }
.kpis.wallet .meter > b { background: var(--accent); }
.input-affix { display: flex; align-items: stretch; }
.input-affix > span { display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--line-strong); border-right: 0;
  border-radius: 8px 0 0 8px; background: var(--surface-2); color: var(--ink-2); font-size: .85rem; font-weight: 550; }
.input-affix > input { border-radius: 0 8px 8px 0; min-width: 0; flex: 1; }
.channel-list { list-style: none; margin: 0; padding: 0; }
.channel-list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.channel-list li:last-child { border-bottom: 0; }
.channel-list .grow { flex: 1; }
.channel-mode { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.channel-mode small { color: var(--ink-3); font-size: .8rem; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.plan-grid.wide { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin: 0; }
.plan-card.static { cursor: default; }
.plan-card.static:hover { border-color: var(--line); }
.plan-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan-card .btn { margin-top: auto; align-self: flex-start; }
.plan-card.static .plan-perks { margin-bottom: 8px; }
td.pos { color: var(--ok); font-weight: 600; white-space: nowrap; }
td.neg { white-space: nowrap; }
.tabs.compact { margin-bottom: 0; border-bottom: 0; }
.panel-flush .panel-head:has(.tabs) { border-bottom: 1px solid var(--line); padding-bottom: 0; margin-bottom: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .chip-btn { height: 32px; }
.method-list { border: 0; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.method-list legend { margin-bottom: 8px; padding: 0; }
.method { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.method:hover { border-color: var(--ink-3); }
.method input { position: absolute; opacity: 0; pointer-events: none; }
.method:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--accent-soft); }
.method:has(input:focus-visible) { box-shadow: var(--focus); }
.method-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.method-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.method-text small { color: var(--ink-2); font-size: .82rem; }
.method-min { color: var(--ink-3); font-size: .8rem; white-space: nowrap; }
.waiting { text-align: center; padding: 18px 8px; }
.waiting p { margin: 10px 0 0; }
.waiting .big-icon { margin-bottom: 4px; }
.spinner { display: inline-block; width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); }
.callout .spinner { width: 16px; height: 16px; border-width: 2px; flex: none; margin-top: 2px; }
@media (prefers-reduced-motion: no-preference) { .spinner { animation: spin .8s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } } }
.money-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.money-grid > div { background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.money-grid > div > span { color: var(--ink-2); font-size: .85rem; }
.money-grid > div > strong { font: 650 1.25rem var(--font-display); }
.money-grid > div > small { color: var(--ink-3); font-size: .78rem; }
.money-grid > .hl { background: var(--accent-soft); }
.money-grid.small-grid { margin-bottom: 16px; }
.money-grid.small-grid > div > strong { font-size: 1.05rem; }
.gateway-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.gateway-grid .panel + .panel { margin-top: 0; }
.gateway .panel-head { align-items: flex-start; }
.gateway .secret-box { font-size: .78rem; }
.kv.compact { grid-template-columns: 110px 1fr; margin-bottom: 12px; font-size: .86rem; }
.inline.wrap { flex-wrap: wrap; margin-top: 12px; }
.check-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.check-list .check { align-items: flex-start; }
.check-list .check input { margin-top: 3px; flex: none; }
tr.muted-row td { opacity: .6; }
.receipt { max-width: 720px; margin: 0 auto; padding: 32px; }
.receipt-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; padding-bottom: 18px; border-bottom: 2px solid var(--ink); }
.receipt-brand { font: 700 1.4rem var(--font-display); color: var(--accent); }
.receipt-title { text-align: right; font: 650 1.2rem var(--font-display); text-transform: uppercase; letter-spacing: .08em; }
.receipt .kv { margin-bottom: 24px; }
.receipt-lines { margin-bottom: 18px; }
.receipt-lines tfoot th { border-top: 2px solid var(--ink); padding-top: 12px; font-size: 1rem; }
@media print {
  .rail, .topbar, .no-print, .toasts, .skip-link { display: none !important; }
  .shell, .main, .content { display: block; padding: 0; margin: 0; }
  body { background: #fff; }
  .receipt { border: 0; box-shadow: none; padding: 0; max-width: none; }
}

/* signup and account pages */
.auth-wide { max-width: 680px; }
.auth-sub { text-align: center; color: var(--ink-2); margin: -12px 0 20px; font-size: .95rem; }
.auth-card.center { text-align: center; }
.auth-card.center .muted { margin: 0 0 20px; }
.big-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; }
.big-icon .ico { width: 28px; height: 28px; }
.big-icon.ok { background: var(--ok-soft); color: var(--ok); }
.big-icon.bad { background: var(--bad-soft); color: var(--bad); }
.forgot-link { font-size: .9rem; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.signup-section { border: 0; padding: 0; margin: 0 0 8px; min-width: 0; }
.signup-section legend { font: 600 .78rem var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; padding: 0; }
.signup-section + .signup-section { border-top: 1px solid var(--line); padding-top: 16px; }
.grid-2.tight { grid-template-columns: 1fr 1fr; gap: 0 14px; }
.signup-section .segmented { margin-bottom: 12px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 14px; }
.plan-card { position: relative; display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; cursor: pointer; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.plan-card[hidden] { display: none; }
.plan-card:hover { border-color: var(--ink-3); }
.plan-card input { position: absolute; opacity: 0; pointer-events: none; }
.plan-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--accent-soft); }
.plan-card:has(input:focus-visible) { box-shadow: var(--focus); }
.plan-name { font-weight: 650; }
.plan-price { font-size: .9rem; color: var(--ink-2); }
.plan-price strong { color: var(--ink); font-size: 1.05rem; }
.plan-desc { font-size: .84rem; color: var(--ink-2); }
.plan-perks { display: flex; flex-direction: column; gap: 2px; font-size: .8rem; color: var(--ink-3); margin-top: 2px; }
.plan-perks span::before { content: "✓ "; color: var(--ok); }
.terms { margin: 4px 0 16px; align-items: flex-start; font-size: .88rem; color: var(--ink-2); }
.terms input { margin-top: 2px; flex: none; }
@media (max-width: 560px) {
  .grid-2.tight { grid-template-columns: 1fr; }
  .auth-card { padding: 22px 18px; }
}

/* error page */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center; }
.error-page .code-big { font: 700 4rem/1 var(--font-display); color: var(--accent); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1080px) {
  .grid-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .rail { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-pop); }
  body.rail-open .rail { transform: none; }
  .icon-btn.rail-toggle { display: inline-grid; }
  .topbar { padding: 10px 16px; }
  .content { padding: 18px 16px 72px; }
  .tenant-name { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .topbar-title { font-size: 1.1rem; }
  .chip-btn { max-width: 150px; }
  .panel { padding: 16px; border-radius: var(--radius); }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 1.5rem; }
  .toolbar select, .toolbar input { min-width: 0; flex: 1 1 140px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; }
  .var-row { grid-template-columns: 1fr; }
  .meter-row { grid-template-columns: 80px 1fr 44px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1; }

  /* tables turn into stacked rows */
  table.data.stack-sm thead { display: none; }
  table.data.stack-sm, table.data.stack-sm tbody, table.data.stack-sm tr, table.data.stack-sm td { display: block; width: 100%; }
  table.data.stack-sm tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.data.stack-sm td { border: 0; padding: 2px 0; }
  table.data.stack-sm td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 92px; color: var(--ink-3); font-size: .8rem; }
  table.data.stack-sm td.cell-lead::before { display: none; }
  table.data.stack-sm td.cell-lead { padding-bottom: 6px; }
  table.data.stack-sm td.num { text-align: left; }
  table.data.stack-sm.selectable tr { position: relative; padding-right: 48px; }
  table.data.stack-sm td.cell-check { position: absolute; top: 12px; right: 14px; width: auto; padding: 0; }
  table.data.stack-sm td.cell-check:empty { display: none; }
  .bulkbar { position: sticky; top: 8px; z-index: 5; }
  .truncate { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
