:root {
  --font: "Outfit", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "ui-monospace", monospace;
  --bg: #eef2f7;
  --bg-elev: #f7f9fc;
  --surface: #ffffff;
  --ink: #0c1222;
  --ink-soft: #3d4a63;
  --muted: #6b7890;
  --line: #e3e9f2;
  --line-strong: #cfd8e6;
  --sidebar: #07111c;
  --sidebar-2: #0c1a2b;
  --sidebar-line: rgba(255, 255, 255, 0.07);
  --sidebar-text: #9fb0c6;
  --sidebar-strong: #f4f8ff;
  --ice: #5ad2ff;
  --ice-deep: #1494d2;
  --ice-soft: #e7f7ff;
  --ok: #0f9f6e;
  --ok-bg: #e6f8f0;
  --warn: #b45309;
  --warn-bg: #fff6e5;
  --danger: #d42b3d;
  --danger-bg: #fdecef;
  --issued: #5b6578;
  --issued-bg: #eef1f5;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px -18px rgba(15, 23, 42, 0.28);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }
a { color: var(--ice-deep); }
button, input, select { font: inherit; }

:focus-visible {
  outline: 2px solid var(--ice);
  outline-offset: 2px;
}

/* ── App shell ─────────────────────────────────────────── */

body.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    linear-gradient(180deg, var(--sidebar-2), var(--sidebar)) 0 0 / var(--sidebar-w) 100% no-repeat,
    var(--bg);
}

.sidebar {
  align-self: stretch;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(90, 210, 255, 0.16), transparent 52%),
    linear-gradient(180deg, var(--sidebar-2), var(--sidebar));
  color: var(--sidebar-text);
  z-index: 30;
}

.sidebar-inner {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 22px;
  color: var(--sidebar-strong);
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: none;
  filter: drop-shadow(0 0 12px rgba(90, 210, 255, 0.35));
}

.brand-name {
  display: block;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.03em;
}

.brand-sub {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  font-weight: 500;
  color: var(--sidebar-text);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-section {
  padding: 0 10px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6d8199;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 14.5px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex: none;
  opacity: 0.85;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--sidebar-strong);
}

.nav-link.is-active {
  background: linear-gradient(90deg, rgba(90, 210, 255, 0.16), rgba(90, 210, 255, 0.05));
  color: var(--sidebar-strong);
  box-shadow: inset 0 0 0 1px rgba(90, 210, 255, 0.18);
}

.nav-link.is-active svg { color: var(--ice); opacity: 1; }

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--sidebar-line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(90, 210, 255, 0.14);
  color: var(--ice);
  font-weight: 700;
  font-size: 13px;
}

.user-name {
  display: block;
  color: var(--sidebar-strong);
  font-weight: 600;
  font-size: 13.5px;
}

.user-role {
  display: block;
  font-size: 11px;
  color: var(--sidebar-text);
}

.nav-link.logout {
  color: #8b9cb0;
}

button.nav-link {
  width: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.logout-form {
  margin: 0;
}

.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--sidebar);
  color: #fff;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.nav-backdrop {
  display: none;
}

.canvas {
  min-width: 0;
  padding: 28px 32px 48px;
}

.canvas-inner {
  max-width: 1180px;
  margin: 0 auto;
}

/* ── Type ──────────────────────────────────────────────── */

h1, h2, h3 { margin: 0; letter-spacing: -0.03em; }
h1 { font-size: 28px; font-weight: 700; line-height: 1.15; }
h2 { font-size: 18px; font-weight: 650; margin: 28px 0 12px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
}

.page-head h1 { margin-bottom: 6px; }

.lede, .muted { color: var(--muted); }
.lede { margin: 0; font-size: 14.5px; }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }

.login-code-box { display: flex; flex-direction: column; gap: 2px; min-width: 8rem; }
.login-code-digits {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--ice-deep);
  user-select: all;
}

.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 13px;
}

.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--ink); }

/* ── Surfaces ──────────────────────────────────────────── */

.card, table.accounts, .chat-list, .issuance-form, .form-card, .thread-shell, .faq-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

/* ── Stats ─────────────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px 16px 20px;
  box-shadow: var(--shadow);
}

.stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--ice);
}

.stat-ok::before, .stat-likes::before { background: var(--ok); }
.stat-danger::before, .stat-dislikes::before, .stat-dislikes-in::before { background: var(--danger); }
.stat-pool::before, .stat-mutual::before, .stat-rate::before { background: #6f86ff; }
.stat-info::before, .stat-dialogs::before { background: var(--ice); }
.stat-unsub::before { background: var(--warn); }
.stat-crm::before { background: var(--ok); }

.stat-ok, .stat-likes, .stat-crm {
  background: linear-gradient(180deg, var(--ok-bg), var(--surface) 46%);
}
.stat-danger, .stat-dislikes, .stat-dislikes-in {
  background: linear-gradient(180deg, var(--danger-bg), var(--surface) 46%);
}
.stat-pool, .stat-mutual, .stat-rate {
  background: linear-gradient(180deg, #eef1ff, var(--surface) 46%);
}
.stat-info, .stat-dialogs {
  background: linear-gradient(180deg, var(--ice-soft), var(--surface) 46%);
}
.stat-unsub {
  background: linear-gradient(180deg, var(--warn-bg), var(--surface) 46%);
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-hint {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: none;
}

.stat-value {
  margin-top: 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.stat-ok .stat-value,
.stat-likes .stat-value,
.stat-crm .stat-value { color: var(--ok); }
.stat-danger .stat-value,
.stat-dislikes .stat-value,
.stat-dislikes-in .stat-value { color: var(--danger); }
.stat-pool .stat-value,
.stat-mutual .stat-value,
.stat-rate .stat-value { color: #4f67ee; }
.stat-info .stat-value,
.stat-dialogs .stat-value { color: var(--ice-deep); }
.stat-unsub .stat-value { color: var(--warn); }

.live-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
}

/* ── Tables ────────────────────────────────────────────── */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.accounts {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  min-width: 740px;
}

table.accounts.props { min-width: 0; }

table.accounts th,
table.accounts td {
  padding: 13px 16px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  word-break: break-word;
}

table.accounts th {
  background: var(--bg-elev);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

table.accounts tbody tr:hover { background: #f8fbff; }
table.accounts tbody tr:last-child td { border-bottom: 0; }

.account-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.account-cell a {
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
}

.account-cell a:hover { color: var(--ice-deep); }

.cell-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.reaction-likes, .reaction-crm { color: var(--ok); }
.reaction-dislikes, .reaction-drain { color: var(--danger); }
.reaction-mutual { color: #4f67ee; }
.reaction-dialogs { color: var(--ice-deep); }
.reaction-unsub { color: var(--warn); }
.reaction.is-zero { color: var(--muted); font-weight: 550; }

/* ── Status / tags ─────────────────────────────────────── */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-active { background: var(--ok-bg); color: var(--ok); }
.status-error { background: var(--danger-bg); color: var(--danger); }
.status-issued { background: var(--issued-bg); color: var(--issued); }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--ice-soft);
  color: #0b6d99;
  font-size: 11px;
  font-weight: 650;
}

.tag-issued {
  background: #eef0ff;
  color: #4c57a8;
}

.tag-idle-fail {
  background: #ffe4c7;
  color: #9a3b00;
}

tr.idle-return-fail {
  background: #fff4ea;
  box-shadow: inset 4px 0 0 #e07020;
}

tr.idle-return-fail td {
  background: transparent;
}

.idle-return-banner {
  max-width: none;
}

/* ── Buttons ───────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset;
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover { background: #1b2538; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(180deg, #3ec4f5, #168fc9);
  color: #042433;
}

.btn-primary:hover { background: linear-gradient(180deg, #58d0ff, #1a9ad6); }

.btn-ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.btn-ghost:hover { background: var(--bg-elev); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b71f31; }

.btn-sm { padding: 6px 10px; font-size: 12.5px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn-row form { margin: 0; }

/* ── Forms ─────────────────────────────────────────────── */

.issuance-form, .form-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 440px;
  padding: 20px;
}

.issuance-form label, .form-card label, .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.issuance-form input, .form-card input, .field input, .login-form input, input[type="file"] {
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}

.issuance-form input:focus, .form-card input:focus, .login-form input:focus {
  outline: none;
  border-color: var(--ice);
  box-shadow: 0 0 0 4px rgba(90, 210, 255, 0.2);
}

.issuance-form button, .form-card button { align-self: flex-start; }
.form-card h2 { margin: 0; }

.crm-key-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.crm-key-form input {
  flex: 1 1 160px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
}

.proxy-field-card {
  margin-bottom: 16px;
  max-width: none;
}

.proxy-check-row {
  margin-top: 10px;
}

.proxy-check-result {
  margin-top: 8px;
}

.proxy-check-result:empty {
  margin: 0;
}

.proxy-check-result .error,
.proxy-check-result .alert {
  margin-bottom: 0;
}

.proxy-mass-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.proxy-mass-form .btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.add-methods {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.add-methods .form-card {
  max-width: none;
}

.add-steps {
  margin: 0 0 16px;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 14px;
}

.add-phone-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.phone-status { margin-top: 14px; }

input[type="file"] {
  padding: 14px;
  background: var(--bg-elev);
  border-style: dashed;
  cursor: pointer;
}

/* ── Alerts ────────────────────────────────────────────── */

.error, .alert {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
}

.error, .alert-error {
  color: #8f1d2c;
  background: var(--danger-bg);
  border: 1px solid #f5c4cb;
}

.alert-ok {
  color: #0b6b4a;
  background: var(--ok-bg);
  border: 1px solid #b7ead4;
}

.warning-box {
  background: var(--warn-bg);
  border: 1px solid #f1d7a4;
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 8px 0 20px;
  max-width: 760px;
  color: #6b3f08;
}

.warning-box p { margin: 0 0 10px; }
.warning-box p:last-child { margin: 0; }

.notice-box {
  background: var(--ice-soft);
  border: 1px solid #b7dff3;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 0 0 18px;
  max-width: 760px;
  color: var(--ink-soft);
  font-size: 14px;
}

.notice-box p { margin: 0 0 8px; }
.notice-box p:last-child { margin: 0; }

.faq-lead { max-width: none; }

.faq-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 20px;
}

.faq-toc a {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.faq-toc a:hover { border-color: var(--ice); color: var(--ink); }

.faq-card {
  padding: 22px;
  margin-bottom: 16px;
}

.faq-card h2 { margin: 0 0 10px; font-size: 18px; }
.faq-card h3 { margin: 18px 0 8px; font-size: 14px; font-weight: 700; }
.faq-card p { margin: 0 0 10px; color: var(--ink-soft); }
.faq-card p:last-child { margin-bottom: 0; }

.faq-list {
  margin: 0 0 12px;
  padding-left: 1.15rem;
  color: var(--ink-soft);
}

.faq-list li { margin: 0 0 6px; }

.faq-mark {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--ink);
}

.faq-formula {
  padding: 10px 12px;
  background: var(--bg-elev);
  border-radius: 10px;
  border: 1px solid var(--line);
  overflow-x: auto;
}

.faq-table { margin: 8px 0 4px; }
.faq-missing { color: var(--warn); font-weight: 650; }

/* ── Empty ─────────────────────────────────────────────── */

.empty {
  text-align: center;
  padding: 48px 24px;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.empty-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--ice-soft);
  color: var(--ice-deep);
}

.empty p { margin: 0; color: var(--muted); }
.empty a { font-weight: 650; }

/* ── Tabs ──────────────────────────────────────────────── */

.tabs {
  display: inline-flex;
  gap: 4px;
  margin: 22px 0 14px;
  padding: 4px;
  background: #e7edf5;
  border-radius: 12px;
}

.tab {
  padding: 7px 14px;
  border-radius: 9px;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 600;
}

.tab-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

/* ── Chats ─────────────────────────────────────────────── */

.chat-list {
  list-style: none;
  padding: 6px;
  margin: 0;
}

.chat-list li { border: 0; }

.chat-list a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
}

.chat-list a:hover { background: #f3f7fc; }

.avatar {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #d7ecff, #b9d8f5);
  color: #165f8a;
  font-weight: 700;
}

.chat-copy { min-width: 0; }
.chat-title { display: block; font-weight: 650; }
.chat-preview {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-shell {
  padding: 8px;
  background: #0e1621;
  border-color: #0e1621;
}

.thread {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  max-width: none;
  min-height: 62vh;
  padding: 18px 16px 22px;
  border-radius: 12px;
  background:
    radial-gradient(ellipse at 12% 0%, rgba(90, 210, 255, 0.12), transparent 42%),
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.035) 1px, transparent 0),
    #0e1621;
  background-size: auto, 18px 18px, auto;
}

.msg { display: flex; }
.msg-in { justify-content: flex-start; }
.msg-out { justify-content: flex-end; }

.bubble {
  max-width: min(75%, 560px);
  padding: 9px 12px 7px;
  border-radius: 16px;
  box-shadow: 0 8px 18px -14px rgba(0, 0, 0, 0.7);
}

.msg-in .bubble {
  background: #182533;
  color: #e7eef5;
  border-bottom-left-radius: 5px;
}

.msg-out .bubble {
  background: linear-gradient(180deg, #3d8ecc, #2b6fa8);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.msg-text { white-space: pre-wrap; word-break: break-word; }

.msg-date {
  display: block;
  text-align: right;
  font-size: 11px;
  opacity: 0.72;
  margin-top: 4px;
}

.msg-media {
  display: inline-block;
  margin-bottom: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 11px;
}

#load-older { text-align: center; margin-bottom: 10px; }
#load-older .btn { background: rgba(255, 255, 255, 0.1); color: #d5e6f5; }

.thread .muted { color: #8ea0b3; text-align: center; }

/* ── Snapshots / details ───────────────────────────────── */

.snapshots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.snapshot-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.snapshot-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.snapshot-card .snap-body { padding: 12px; }

.snapshot-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.snapshot-hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.snapshot-hero img {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  display: block;
}

.snapshot-hero .snap-body { padding: 16px 18px; }
.snapshot-hero h2 { margin: 0 0 8px; font-size: 16px; }

.stats-six {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.stats-metrics {
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
}

.metric-board {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 20px;
}

.metric-group-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.metric-group .stat-grid { margin-bottom: 0; }

.metric-lower {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(17rem, 0.85fr);
  gap: 16px;
  align-items: stretch;
}

.metric-pair {
  grid-template-columns: minmax(8.5rem, 1fr) minmax(16rem, 2fr);
}

.metric-pair .stat-split,
.metric-crm .stat-split { grid-column: auto; }

.metric-pair .stat,
.metric-crm .stat { height: 100%; }

.metric-crm { grid-template-columns: 1fr; }

.stat-split {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  padding-bottom: 14px;
}

.stat-split-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex: 1 1 auto;
}

.stat-split .stat-value { margin-top: 4px; }

.stat-badge {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  white-space: nowrap;
}

.stat-split-bar {
  display: flex;
  height: 8px;
  margin-top: 12px;
  background: #e7edf5;
  border-radius: 999px;
  overflow: hidden;
}

.stat-split-bar.is-empty { opacity: 0.55; }

.stat-split-fill { min-width: 0; height: 100%; }
.stat-unsub .stat-split-fill.is-left { background: var(--warn); }
.stat-unsub .stat-split-fill.is-right { background: var(--danger); }
.stat-crm .stat-split-fill.is-left { background: var(--ok); }
.stat-crm .stat-split-fill.is-right { background: var(--warn); }

.stat-split-legend {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  flex-wrap: wrap;
}

.stat-split-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stat-split-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.stat-split-legend b {
  font-weight: 700;
  color: inherit;
}

.stat-unsub .stat-split-legend .is-left { color: var(--warn); }
.stat-unsub .stat-split-legend .is-left i { background: var(--warn); }
.stat-unsub .stat-split-legend .is-right { color: var(--danger); }
.stat-unsub .stat-split-legend .is-right i { background: var(--danger); }
.stat-crm .stat-split-legend .is-left { color: var(--ok); }
.stat-crm .stat-split-legend .is-left i { background: var(--ok); }
.stat-crm .stat-split-legend .is-right { color: var(--warn); }
.stat-crm .stat-split-legend .is-right i { background: var(--warn); }

.section-title {
  margin: 8px 0 12px;
  font-size: 15px;
  font-weight: 700;
}

.account-group {
  margin-bottom: 28px;
}

.props {
  width: 100%;
  max-width: 720px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.steps {
  display: grid;
  gap: 10px;
  max-width: 560px;
  margin: 0 0 20px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.step {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
  font-size: 14px;
  color: var(--ink-soft);
}

.step-n {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--ice-soft);
  color: var(--ice-deep);
  font-size: 12px;
  font-weight: 700;
}

.qr-wrap {
  display: inline-block;
  margin-top: 18px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  text-align: center;
}

.qr-wrap img {
  display: block;
  width: 260px;
  height: 260px;
  background: #fff;
}

/* ── Login ─────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 42%) 1fr;
  background: var(--bg);
}

.login-hero {
  position: relative;
  overflow: hidden;
  padding: 48px 44px;
  color: #eef7ff;
  background:
    radial-gradient(ellipse at 20% 15%, rgba(90, 210, 255, 0.22), transparent 46%),
    radial-gradient(ellipse at 90% 90%, rgba(36, 99, 180, 0.35), transparent 42%),
    linear-gradient(165deg, #07111c 0%, #0c1a2b 55%, #071018 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-hero h1 {
  font-size: 40px;
  max-width: 12ch;
  margin: 18px 0 12px;
}

.login-hero p { margin: 0; color: #9fb0c6; max-width: 36ch; }

.hero-points {
  display: grid;
  gap: 10px;
  margin-top: 36px;
}

.hero-point {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: #c5d4e4;
  font-size: 14px;
}

.hero-point span {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(90, 210, 255, 0.15);
  color: var(--ice);
  font-size: 12px;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.login-form {
  width: min(100%, 380px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #fff;
  padding: 32px;
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-form h1 { font-size: 26px; }
.login-form .lede { margin-bottom: 6px; }
.login-password {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-form button {
  margin-top: 6px;
  padding: 12px;
  background: linear-gradient(180deg, #3ec4f5, #168fc9);
  color: #042433;
  border: 0;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

.login-form button:hover { filter: brightness(1.05); }

.login-sso {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.login-sso:hover { background: #1b2538; color: #fff; }

.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ── Charts ────────────────────────────────────────────── */

.charts {
  margin: 8px 0 28px;
  padding: 16px 18px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.chart-legend {
  display: flex;
  gap: 14px;
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.legend::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: 1px;
}
.legend.likes::before { background: var(--ok); }
.legend.dislikes::before { background: var(--danger); }
.legend.mutual::before { background: #6f86ff; }
.legend.in::before { background: var(--ice); }

.chart-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.chart-row {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr) 7rem;
  gap: 10px;
  align-items: center;
}
.chart-label { font-size: 13px; font-weight: 600; }
.chart-n { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.bar-track {
  display: flex;
  height: 12px;
  background: #e7edf5;
  border-radius: 999px;
  overflow: hidden;
}
.bar-track.grouped {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: transparent;
  overflow: visible;
}
.bar-slot {
  height: 100%;
  background: #e7edf5;
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill { height: 100%; min-width: 0; }
.bar-fill.likes { background: var(--ok); }
.bar-fill.dislikes { background: var(--danger); }
.bar-fill.mutual { background: #6f86ff; }
.bar-fill.in { background: var(--ice); }

.hist {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  height: 120px;
  margin: 8px 0 16px;
}
.hist-col { display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 4px; }
.hist-bar {
  width: 70%;
  background: var(--ice);
  border-radius: 6px 6px 0 0;
  min-height: 4px;
}
.hist-bar.is-empty {
  min-height: 0;
  height: 0 !important;
  background: transparent;
}
.hist-n { font-size: 12px; font-weight: 700; }
.hist-label { font-size: 11px; color: var(--muted); }
.source-table { margin-top: 8px; }

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 960px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-six { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-pair { grid-template-columns: 1fr; }
  .metric-lower { grid-template-columns: 1fr; }
  .metric-crm { grid-template-columns: 1fr; }
  .metric-pair .stat,
  .metric-crm .stat { height: auto; min-height: 0; }
  .stat-split-legend { flex-direction: column; align-items: flex-start; }
  .page-head { flex-direction: column; align-items: stretch; }
  .split { grid-template-columns: 1fr; }
  .add-methods { grid-template-columns: 1fr; }
  .chart-row { grid-template-columns: 1fr; }
  .chart-n { text-align: left; }
}

@media (max-width: 860px) {
  body.app {
    grid-template-columns: 1fr;
    background: var(--bg);
  }
  .topbar { display: flex; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, var(--sidebar-w));
    transform: translateX(-104%);
    transition: transform 0.22s ease;
    box-shadow: 20px 0 40px rgba(0, 0, 0, 0.25);
  }
  .sidebar-inner { height: 100%; }
  body.nav-open .sidebar { transform: none; }
  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(4, 10, 18, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 20;
  }
  body.nav-open .nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  .canvas { padding: 18px 16px 36px; }
  .login-page { grid-template-columns: 1fr; }
  .login-hero { min-height: 220px; padding: 28px 24px; }
  .hero-points { display: none; }
}

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