:root {
  /* ===== Shared design tokens — 2026 light SaaS system =====
   * The exact same palette is reused across the admin console,
   * customer portal, reseller portal and survey app. */

  /* Sidebar — light, subtle-contrast surface */
  --sb-bg: #ffffff;
  --sb-bg-hover: #f1f3fb;
  --sb-fg: #4b5168;
  --sb-fg-muted: #9499ad;
  --sb-fg-active: #1c2236;

  /* Brand accent — friendly indigo */
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-soft: #eef0fe;

  /* Surfaces & text */
  --bg: #f6f7fb;
  --card-bg: #ffffff;
  --surface-2: #fbfbfe;   /* table heads, subtle raised strips */
  --surface-3: #fafbfe;   /* zebra stripes */
  --border: #e7e9f2;
  --border-strong: #d4d7e4;
  --text: #1c2236;
  --text-muted: #6b7185;

  /* Legacy c1 sidebar aliases — reseller markup references --sb-accent etc. */
  --sb-text: var(--sb-fg);
  --sb-text-dim: var(--sb-fg-muted);
  --sb-text-muted: var(--sb-fg-muted);
  --sb-border: var(--border);
  --sb-accent: var(--accent);
  --sb-active-bg: var(--accent-soft);

  /* Semantic colours */
  --ok: #16a34a;
  --warn: #d97706;
  --err: #e11d48;

  /* Soft semantic tints (badges / pills / alerts) */
  --ok-soft: #e8f7ee;   --ok-strong: #166534;
  --warn-soft: #fef3e2; --warn-strong: #9a5b06;
  --err-soft: #fdeaef;  --err-strong: #9f1239;
  --info-soft: #e6f4fd;  --info-strong: #075985;
  --neutral-soft: #f1f3f8; --neutral-strong: #475569;
  --info: #0284c7;
  --neutral: #64748b;

  /* Shape & elevation */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(20, 28, 60, 0.05);
  --shadow: 0 1px 3px rgba(20, 28, 60, 0.06), 0 1px 2px rgba(20, 28, 60, 0.04);
  --shadow-lg: 0 8px 28px rgba(20, 28, 60, 0.10);
  --ring: 0 0 0 3px rgba(99, 102, 241, 0.18);

  /* Layout metrics (preserved) */
  --sb-width: 240px;
  --sb-width-collapsed: 56px;
  --topbar-h: 56px;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas,
               "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

code, pre, kbd, samp, .font-monospace {
  font-family: var(--font-mono);
  font-size: 0.95em;
}

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

/* ==== Sidebar ==== */
.sb {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sb-width);
  height: 100vh;
  background: var(--sb-bg);
  color: var(--sb-fg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1020;
  transition: width 0.15s ease;
  overflow-x: hidden;
}
.sb-collapsed .sb { width: var(--sb-width-collapsed); }

.sb-brand {
  height: var(--topbar-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sb-fg-active);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.sb-brand .bi { color: var(--accent); font-size: 19px; flex: 0 0 auto; }

.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.sb-section {
  padding: 12px 16px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sb-fg-muted);
  white-space: nowrap;
}
.sb-collapsed .sb-section { visibility: hidden; height: 8px; padding: 0; }

/* Collapsible per-section toggle (button styled like the section header).
 * `color: inherit` is required — without it browsers fall back to the
 * <button> UA default (`color: ButtonText`), which renders ~white on the
 * dark sidebar background and looks like a regular nav item. */
.sb-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--sb-fg-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.sb-section-toggle:hover { color: var(--sb-fg-active); }
.sb-section-toggle .sb-chevron {
  font-size: 10px;
  transition: transform 0.15s ease;
  flex: 0 0 auto;
  margin-left: 8px;
}
.sb-section-toggle.sb-collapsed-section .sb-chevron { transform: rotate(-90deg); }
.sb-section-items.sb-hidden { display: none; }

.sb-link {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 1px 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--sb-fg);
  font-size: 13px;
  white-space: nowrap;
  border-left: 3px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
}
.sb-link:hover { background: var(--sb-bg-hover); color: var(--sb-fg-active); text-decoration: none; }
.sb-link.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 600;
  border-left-color: var(--accent);
}
.sb-link.active .bi { color: var(--accent); }
.sb-link .bi { font-size: 15px; width: 20px; text-align: center; flex: 0 0 auto; }
.sb-collapsed .sb-link-label { display: none; }
/* Collapsed icon rail: centre the icons and — since the section headers are
   hidden — force any accordion-collapsed section to still show its icons. */
.sb-collapsed .sb-link { justify-content: center; gap: 0; margin: 1px 6px; }
.sb-collapsed .sb-section-items.sb-hidden { display: block; }

.sb-toggle {
  border: none;
  background: transparent;
  color: var(--sb-fg-muted);
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
  border-top: 1px solid var(--border);
}
.sb-toggle:hover { color: var(--sb-fg-active); }

/* ==== Top bar ==== */
.tb {
  position: fixed;
  top: 0;
  left: var(--sb-width);
  right: 0;
  height: var(--topbar-h);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 1010;
  transition: left 0.15s ease;
}
.sb-collapsed .tb { left: var(--sb-width-collapsed); }
.tb-toggle {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 17px;
  line-height: 1;
  padding: 6px 8px;
  margin: 0 8px 0 -6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.12s ease, color 0.12s ease;
}
.tb-toggle:hover { background: var(--bg); color: var(--text); }
.tb-toggle:focus-visible { box-shadow: var(--ring); outline: none; }
.tb-crumbs { flex: 1; color: var(--text-muted); font-size: 12px; }
.tb-crumbs .bi-chevron-right { font-size: 9px; margin: 0 6px; color: var(--border); }
.tb-crumbs a { color: var(--text-muted); }
.tb-crumbs .tb-crumb-active { color: var(--text); font-weight: 500; }

.tb-search { position: relative; margin-right: 16px; }
.tb-search input {
  width: 260px;
  padding: 6px 10px 6px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: var(--bg);
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.tb-search input:focus { outline: none; border-color: var(--accent); background: var(--card-bg); box-shadow: var(--ring); }
.tb-search .bi-search {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 12px;
}

.tb-health {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  margin-right: 16px;
}
.tb-health .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}
.tb-health.warn .dot { background: var(--warn); }
.tb-health.err  .dot { background: var(--err); }

/* ==== Content frame ==== */
.main {
  margin-left: var(--sb-width);
  padding: calc(var(--topbar-h) + 16px) 24px 24px;
  min-height: 100vh;
  transition: margin-left 0.15s ease;
}
.sb-collapsed .main { margin-left: var(--sb-width-collapsed); }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.page-head h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 2px;
  color: var(--text);
}
.page-head .page-sub { color: var(--text-muted); font-size: 12px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ==== Cards & tables ==== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  background: var(--card-bg);
  color: var(--text);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
.card-body { padding: 14px 16px; }

.table { color: var(--text); }
.table thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  background: var(--surface-2);
  padding-top: 10px;
  padding-bottom: 10px;
}
.table td, .table th { border-color: var(--border); vertical-align: middle; }
.table td { padding-top: 9px; padding-bottom: 9px; }
.table tbody tr { transition: background 0.1s ease; }
.table-hover tbody tr:hover { background: var(--accent-soft); }
.table-striped > tbody > tr:nth-of-type(odd) > * { background: var(--surface-3); }
.table-sortable thead th { cursor: pointer; user-select: none; }
.table-sortable thead th::after {
  content: "";
  display: inline-block;
  width: 0; height: 0;
  margin-left: 4px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  opacity: 0.25;
  border-top: 5px solid currentColor;
}
.table-sortable thead th.sort-asc::after { border-top: none; border-bottom: 5px solid currentColor; opacity: 1; }
.table-sortable thead th.sort-desc::after { opacity: 1; }

/* Filter row inside a table */
.table-filter-row td {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 8px;
}
.table-filter-row input,
.table-filter-row select {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: var(--card-bg);
}

/* Row action menu (trailing dots) */
.row-actions { position: relative; text-align: right; }
.row-actions .row-toggle {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.row-actions .row-toggle:hover {
  border-color: var(--border);
  color: var(--text);
}

/* ==== KPI tiles ==== */
.kpi-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1200px) { .kpi-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px)  { .kpi-row { grid-template-columns: repeat(2, 1fr); } }

.kpi {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.12s ease;
}
.kpi:hover { box-shadow: var(--shadow); }
/* Compact stat number — for inline stat cards (CDR summary etc.) that
   previously leaned on oversized Bootstrap .fs-* utilities. */
.stat-num { font-size: 1.3rem; font-weight: 600; line-height: 1.2; color: var(--text); }
.kpi .kpi-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.kpi .kpi-value {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.2;
}
.kpi .kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.kpi.kpi-good .kpi-value { color: var(--ok); }
.kpi.kpi-warn .kpi-value { color: var(--warn); }
.kpi.kpi-err  .kpi-value { color: var(--err); }

/* ==== Buttons (Bootstrap overrides) ==== */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, transform 0.04s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { box-shadow: var(--ring); outline: none; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-primary:focus-visible { box-shadow: var(--ring); }
.btn-outline-primary {
  color: var(--accent);
  border-color: var(--accent);
}
.btn-outline-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover, .btn-secondary:focus {
  background: var(--bg);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-outline-secondary {
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-outline-secondary:hover, .btn-outline-secondary:focus {
  background: var(--bg);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-danger {
  background: var(--err);
  border-color: var(--err);
}
.btn-danger:hover, .btn-danger:focus {
  background: var(--err-strong);
  border-color: var(--err-strong);
}
.btn-link { color: var(--accent); }
.btn-link:hover { color: var(--accent-hover); }

/* ==== Status dots / badges ==== */
.stat { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; }
.stat .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.stat.ok  .dot { background: var(--ok); }
.stat.warn .dot { background: var(--warn); }
.stat.err  .dot { background: var(--err); }

.badge-soft {
  background: var(--accent-soft);
  color: var(--accent-hover);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 600;
}
.badge-ok   { background: var(--ok-soft);   color: var(--ok-strong); }
.badge-warn { background: var(--warn-soft); color: var(--warn-strong); }
.badge-err  { background: var(--err-soft);  color: var(--err-strong); }

/* ==== Call status badges ====
   Four hues, not nine arbitrary colours: the hue encodes severity, the icon +
   label encode the cause. Rejected / Bad number / Failed all read red because
   they are all "the call did not happen and it wasn't the caller's choice";
   the label says which. Keeps it legible without relying on colour alone. */
.cs {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--radius-pill);
  font-size: 10px; font-weight: 600; white-space: nowrap;
  background: var(--neutral-soft); color: var(--neutral-strong);
}
.cs .bi { font-size: 11px; }
.cs-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.cs-answered  { background: var(--ok-soft);      color: var(--ok-strong); }
.cs-canceled  { background: var(--neutral-soft); color: var(--neutral-strong); }
.cs-busy      { background: var(--warn-soft);    color: var(--warn-strong); }
.cs-no-answer { background: var(--warn-soft);    color: var(--warn-strong); }
.cs-rejected  { background: var(--err-soft);     color: var(--err-strong); }
.cs-invalid   { background: var(--err-soft);     color: var(--err-strong); }
.cs-failed    { background: var(--err-soft);     color: var(--err-strong);
                box-shadow: inset 0 0 0 1px rgba(225, 29, 72, 0.25); }
.cs-unknown   { background: var(--surface-2);    color: var(--text-muted); }

/* Live -- the only animated badge on the site; it earns it by being ephemeral */
.cs-live      { background: var(--info-soft);    color: var(--info-strong); }
.cs-talking   { background: var(--ok-soft);      color: var(--ok-strong); }
.cs-ringing   { background: var(--warn-soft);    color: var(--warn-strong); }
.cs-early     { background: var(--warn-soft);    color: var(--warn-strong); }
.cs-held      { background: var(--neutral-soft); color: var(--neutral-strong); }
.cs-setup     { background: var(--info-soft);    color: var(--info-strong); }
.cs-ending    { background: var(--err-soft);     color: var(--err-strong); }

.cs-pulse {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  animation: cs-pulse 1.6s ease-in-out infinite;
}
@keyframes cs-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .cs-pulse { animation: none; } }

/* Live rows merged on top of a CDR table */
tr.cs-liverow > td { background: var(--info-soft); }
tr.cs-liverow > td:first-child { box-shadow: inset 3px 0 0 var(--info); }
.cs-muted { color: var(--text-muted); }

/* ==== Status chip filter row ==== */
.cs-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.cs-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--card-bg);
  font-size: 12px; color: var(--text-muted); text-decoration: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.cs-chip:hover { border-color: var(--border-strong); color: var(--text); }
.cs-chip b { color: var(--text); font-variant-numeric: tabular-nums; }
.cs-chip.on { border-color: var(--accent); box-shadow: var(--ring); color: var(--text); }
.cs-chip .cs-dot { background: var(--text-muted); }
.cs-chip.cs-answered  .cs-dot { background: var(--ok); }
.cs-chip.cs-canceled  .cs-dot { background: var(--neutral); }
.cs-chip.cs-busy      .cs-dot { background: var(--warn); }
.cs-chip.cs-no-answer .cs-dot { background: var(--warn); }
.cs-chip.cs-rejected  .cs-dot { background: var(--err); }
.cs-chip.cs-invalid   .cs-dot { background: var(--err); }
.cs-chip.cs-failed    .cs-dot { background: var(--err); }
.cs-chip.cs-unknown   .cs-dot { background: var(--text-muted); }

/* ==== Empty states ==== */
.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-muted);
}
.empty .bi {
  font-size: 24px;
  color: var(--accent);
  background: var(--accent-soft);
  width: 56px;
  height: 56px;
  line-height: 56px;
  border-radius: 50%;
  display: inline-block;
  margin-bottom: 10px;
}
.empty .empty-title { font-weight: 600; color: var(--text); margin-bottom: 2px; }

/* ==== Forms ==== */
.form-label { font-size: 12px; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.form-control, .form-select {
  font-size: 12px;
  border-color: var(--border);
  border-radius: var(--radius-sm);
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}
.form-check-input:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.form-help { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Form overview header (used above tabs on detail forms) */
.form-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px 18px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.form-overview .ov-label { font-size: 10px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.06em; }
.form-overview .ov-value { font-size: 15px; font-weight: 600; color: var(--text); }
@media (max-width: 800px) { .form-overview { grid-template-columns: repeat(2, 1fr); } }

/* Tabs */
.nav-tabs { border-bottom-color: var(--border); }
.nav-tabs .nav-link {
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  font-size: 12px;
}
.nav-tabs .nav-link:hover { color: var(--text); border-color: transparent; }
.nav-tabs .nav-link.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: transparent;
}

/* Toasts */
.toast-stack {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  right: 20px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast { border-radius: var(--radius); box-shadow: var(--shadow-lg); }

/* Alerts — soft, rounded, token-driven */
.alert { border-radius: var(--radius-sm); border: 1px solid transparent; }
.alert-info    { background: var(--accent-soft); color: var(--accent-hover); border-color: #dcdffb; }
.alert-success { background: var(--ok-soft);   color: var(--ok-strong);   border-color: #c9ecd6; }
.alert-warning { background: var(--warn-soft); color: var(--warn-strong); border-color: #f7e3c2; }
.alert-danger  { background: var(--err-soft);  color: var(--err-strong);  border-color: #f7cdd8; }

/* Mobile */
@media (max-width: 768px) {
  .sb { width: var(--sb-width-collapsed); }
  .sb-link-label, .sb-section { display: none; }
  .tb { left: var(--sb-width-collapsed); padding: 0 12px; }
  .tb-search input { width: 140px; }
  .main { margin-left: var(--sb-width-collapsed); padding: calc(var(--topbar-h) + 12px) 12px 12px; }
  .page-head { flex-direction: column; align-items: stretch; }
}

/* FlySIP-style collapsible filter panel */
.filter-panel { margin-bottom: 12px; }
.filter-panel > summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}
.filter-panel > summary::-webkit-details-marker { display: none; }
.filter-panel > summary::after {
  content: "\F282"; /* bi-chevron-up */
  font-family: "bootstrap-icons";
  font-weight: 400;
  transition: transform .15s ease;
}
.filter-panel:not([open]) > summary::after { transform: rotate(180deg); }
.filter-panel > .card-body { padding-top: 14px; }

/* Pagination strip */
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 10px 14px; }
.pager .pager-info { color: var(--text-muted); font-size: 11px; margin-right: 8px; }
.pager a, .pager span.current {
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  font-size: 12px;
  line-height: 1.8;
}
.pager a:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); }
.pager span.current { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager span.disabled { color: var(--text-muted); padding: 2px 10px; font-size: 12px; }

/* Per-customer tab strip — FlySIP-style account drilldown nav */
.customer-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 16px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.customer-tab {
  padding: 8px 14px;
  color: var(--text-muted);
  font-size: 12px;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.customer-tab:hover { color: var(--text); text-decoration: none; }
.customer-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 500;
}

/* Customer-form summary strip + action bar — uses shared tokens instead of
   hardcoded hex so it matches the rest of the console. */
.stat-strip {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin: 8px 0 18px;
}
.stat-card {
  flex: 1;
  min-width: 160px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
}
.stat-card .stat-value {
  font-size: 22px;
  font-weight: 600;
}
.action-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  align-items: end;
}

/* ==== Dropdown menus (Bootstrap harmonisation) ==== */
.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  padding: 6px;
}
.dropdown-item { border-radius: 6px; padding: 6px 10px; color: var(--text); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--accent-soft); color: var(--accent-hover); }
.dropdown-item.active { background: var(--accent); color: #fff; }
.dropdown-divider { border-color: var(--border); opacity: 1; }

/* ==== Modals (Bootstrap harmonisation) ==== */
.modal-content {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.modal-header { border-bottom: 1px solid var(--border); padding: 14px 18px; }
.modal-footer { border-top: 1px solid var(--border); padding: 12px 18px; }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-backdrop { background: rgba(20, 28, 60, 0.45); }

/* ==== Focus & scrollbars ==== */
a:focus-visible, .sb-link:focus-visible { box-shadow: var(--ring); outline: none; border-radius: var(--radius-sm); }
.sb-nav::-webkit-scrollbar { width: 6px; }
.sb-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ==== Small utilities ==== */
.text-primary { color: var(--accent) !important; }
.text-ok  { color: var(--ok) !important; }
.text-err { color: var(--err) !important; }
.nowrap { white-space: nowrap; }
.num { font-family: var(--font-mono); font-size: 0.95em; font-variant-numeric: tabular-nums; }
.field-xs { width: 128px !important; }
.field-sm { width: 160px !important; }
.field-md { width: 176px !important; }
.field-lg { width: 224px !important; }
.scroll-box { max-height: 224px; overflow-y: auto; }
.mini-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.mini-value { font-size: 13px; font-weight: 600; color: var(--text); }

/* ==================================================================
   Customer-portal shell (migrated from portal/base.html inline CSS).
   rem sizes converted to their previous computed px values — the
   portal used a 16px root before adopting this 13px-root stylesheet.
   ================================================================== */
#portal-wrapper { display: flex; min-height: 100vh; flex-direction: column; }
#portal-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
#portal-header .brand { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
#portal-header .header-right { display: flex; align-items: center; gap: 20px; font-size: 13px; }
#portal-header .header-left { display: flex; align-items: center; gap: 8px; }
#portal-body { display: flex; flex: 1; }
#portal-sidebar {
  width: 220px; min-width: 220px; background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  transition: width 0.15s ease, min-width 0.15s ease;
  overflow-x: hidden;
}
#portal-content { flex: 1; padding: 24px; min-width: 0; }

.sidebar-section-header {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--text-muted); text-transform: uppercase;
  padding: 12px 16px 4px;
}
.sidebar-section-header:not(:first-child) { margin-top: 8px; }
.sidebar-nav { list-style: none; padding: 0; margin: 0; }
.sidebar-nav li a {
  display: block; margin: 1px 8px; padding: 6px 12px;
  color: var(--text); text-decoration: none; font-size: 13px;
  border-left: 3px solid transparent; border-radius: var(--radius-sm);
  transition: background 0.12s ease, color 0.12s ease;
}
.sidebar-nav li a:hover { background: var(--bg); color: var(--accent-hover); }
.sidebar-nav li a.active {
  border-left-color: var(--accent); color: var(--accent-hover);
  background: var(--accent-soft); font-weight: 600;
}
.sidebar-sub { list-style: none; padding: 0; margin: 0; }
.sidebar-sub li a {
  display: block; margin: 1px 8px; padding: 6px 12px 6px 24px;
  color: var(--text); text-decoration: none; font-size: 12px;
  border-left: 3px solid transparent; border-radius: var(--radius-sm);
  transition: background 0.12s ease, color 0.12s ease;
}
.sidebar-sub li a:hover { background: var(--bg); color: var(--accent-hover); }
.sidebar-sub li a.active {
  border-left-color: var(--accent); color: var(--accent-hover);
  background: var(--accent-soft); font-weight: 600;
}
.sidebar-group-label {
  padding: 6px 16px 2px 20px;
  font-size: 12px; color: var(--text-muted); font-weight: 600;
}

.portal-hamburger {
  background: transparent; border: 0; font-size: 17px; line-height: 1;
  color: var(--text-muted); cursor: pointer; padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.portal-hamburger:hover { background: var(--bg); color: var(--text); }

/* Icon-rail collapse — shrinks the sidebar to centred icons, persisted in JS. */
body.portal-collapsed #portal-sidebar { width: 64px; min-width: 64px; }
body.portal-collapsed #portal-sidebar .sidebar-section-header { font-size: 0; padding: 8px 0 4px; }
body.portal-collapsed #portal-sidebar .sidebar-nav li a,
body.portal-collapsed #portal-sidebar .sidebar-sub li a,
body.portal-collapsed #portal-sidebar .sidebar-group-label {
  text-align: center; padding-left: 0; padding-right: 0; font-size: 0;
}
body.portal-collapsed #portal-sidebar .sidebar-nav li a .bi,
body.portal-collapsed #portal-sidebar .sidebar-sub li a .bi,
body.portal-collapsed #portal-sidebar .sidebar-group-label .bi {
  font-size: 15px; margin: 0 !important;
}

/* Identity strip (rendered when an authenticated account is in context) */
#portal-ident {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 4px 16px;
}
#portal-ident .ident-primary { color: var(--text); font-weight: 600; }
#portal-ident .sep { color: #c3c7d6; }
#portal-ident .status-badge {
  font-size: 10px; padding: 3px 10px;
  border-radius: var(--radius-pill); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
#portal-ident .status-active     { background: var(--ok-soft);   color: var(--ok-strong); }
#portal-ident .status-pending    { background: var(--warn-soft); color: var(--warn-strong); }
#portal-ident .status-suspended,
#portal-ident .status-closed     { background: var(--err-soft);  color: var(--err-strong); }

/* ==================================================================
   Reseller (c1) shell (migrated from c1/base.html inline CSS).
   Scoped under #c1-* ids so its .sb-* names can't collide with the
   admin sidebar classes above.
   ================================================================== */
#c1-wrapper { display: flex; min-height: 100vh; }
#c1-sidebar {
  width: 240px; min-width: 240px;
  background: var(--sb-bg);
  color: var(--sb-fg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-x: hidden;
  transition: width 0.15s ease, min-width 0.15s ease;
}
#c1-sidebar .sb-brand {
  height: auto;
  padding: 16px 18px 14px;
  display: block;
  border-bottom: 1px solid var(--border);
}
#c1-sidebar .sb-brand-name {
  font-weight: 700; font-size: 14px; color: var(--text);
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px;
}
#c1-sidebar .sb-brand-meta { font-size: 10px; color: var(--sb-fg-muted); margin-top: 4px; }

#c1-sidebar .sb-menu { flex: 1; overflow-y: auto; padding: 8px 0; }
#c1-sidebar .sb-menu::-webkit-scrollbar { width: 6px; }
#c1-sidebar .sb-menu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

#c1-sidebar .sb-group { padding: 4px 0; }
#c1-sidebar .sb-group-head {
  width: 100%; background: transparent; border: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 18px;
  color: var(--sb-fg-muted);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  cursor: pointer;
}
#c1-sidebar .sb-group-head:hover { color: var(--text); }
#c1-sidebar .sb-group-head .sb-group-icon { font-size: 13px; width: 16px; text-align: center; }
#c1-sidebar .sb-group-head .sb-group-label { flex: 1; text-align: left; }
#c1-sidebar .sb-group-head .sb-chevron { transition: transform 0.15s ease; font-size: 11px; }
#c1-sidebar .sb-group.open .sb-chevron { transform: rotate(90deg); }

#c1-sidebar .sb-items { list-style: none; padding: 0; margin: 0 0 4px; display: none; }
#c1-sidebar .sb-group.open .sb-items { display: block; }
#c1-sidebar .sb-items li a {
  display: flex; align-items: center; gap: 8px;
  margin: 1px 8px;
  padding: 7px 12px 7px 34px;
  color: var(--sb-fg);
  text-decoration: none; font-size: 13px;
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  transition: background 0.12s ease, color 0.12s ease;
}
#c1-sidebar .sb-items li a:hover { background: var(--sb-bg-hover); color: var(--accent-hover); }
#c1-sidebar .sb-items li a.active {
  background: var(--accent-soft);
  color: var(--accent-hover); border-left-color: var(--accent);
  font-weight: 600;
}

#c1-sidebar .sb-footer {
  border-top: 1px solid var(--border);
  padding: 12px 16px; font-size: 12px;
}
#c1-sidebar .sb-footer .sb-user {
  display: flex; align-items: center; gap: 10px;
  color: var(--sb-fg);
}
#c1-sidebar .sb-footer .sb-user .bi { font-size: 17px; color: var(--sb-fg-muted); }
#c1-sidebar .sb-footer .sb-user .sb-uname {
  flex: 1; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
#c1-sidebar .sb-footer .sb-balance { color: var(--sb-fg-muted); font-size: 10px; margin-top: 4px; }
#c1-sidebar .sb-footer .sb-logout {
  background: transparent; border: 0; color: var(--sb-fg-muted); cursor: pointer;
}
#c1-sidebar .sb-footer .sb-logout:hover { color: var(--accent-hover); }

/* Desktop icon-rail collapse — toggled by the top-bar hamburger.
   Scoped to desktop so mobile always uses the slide-in drawer below. */
@media (min-width: 901px) {
  body.c1-collapsed #c1-sidebar { width: 64px; min-width: 64px; }
  body.c1-collapsed #c1-sidebar .sb-brand { padding: 16px 0 14px; }
  body.c1-collapsed #c1-sidebar .sb-brand-name { justify-content: center; gap: 0; font-size: 0; }
  body.c1-collapsed #c1-sidebar .sb-brand-name .bi { font-size: 17px; }
  body.c1-collapsed #c1-sidebar .sb-brand-meta { display: none; }
  body.c1-collapsed #c1-sidebar .sb-group-head { display: none; }
  body.c1-collapsed #c1-sidebar .sb-items { display: block; }
  body.c1-collapsed #c1-sidebar .sb-items li a {
    justify-content: center; gap: 0; padding: 8px 0; font-size: 0;
  }
  body.c1-collapsed #c1-sidebar .sb-items li a .bi { font-size: 15px; }
  body.c1-collapsed #c1-sidebar .sb-footer { padding: 12px 0; }
  body.c1-collapsed #c1-sidebar .sb-footer .sb-user { justify-content: center; gap: 0; }
  body.c1-collapsed #c1-sidebar .sb-footer .sb-uname,
  body.c1-collapsed #c1-sidebar .sb-footer .sb-balance { display: none; }
}

/* c1 topbar + content */
#c1-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#c1-topbar {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 8px 18px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 50;
}
#c1-topbar .c1-hamburger {
  background: transparent; border: 0; font-size: 17px;
  color: var(--text-muted); cursor: pointer; padding: 4px 6px;
  border-radius: var(--radius-sm);
  display: inline-block;
}
#c1-topbar .c1-hamburger:hover { background: var(--bg); color: var(--text); }
#c1-topbar .c1-page-title { font-size: 13px; color: var(--text-muted); }
#c1-topbar .c1-spacer { flex: 1; }
#c1-topbar .c1-bal-pill {
  background: var(--accent-soft); color: var(--accent-hover);
  padding: 4px 12px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600;
}
#c1-content { padding: 18px 24px 32px; flex: 1; }

/* c1 mobile drawer */
@media (max-width: 900px) {
  #c1-topbar .c1-hamburger { display: inline-block; }
  #c1-sidebar {
    position: fixed; top: 0; left: 0; z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  body.c1-sb-open #c1-sidebar { transform: translateX(0); }
  body.c1-sb-open::after {
    content: ''; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4);
    z-index: 150;
  }
}

/* ==================================================================
   Selectable option cards (customer portal).
   Promoted out of unified_login.html, which had the only card-style
   radio in the codebase inlined in a <style> block. The portal's
   location picker is the second user, so it belongs here.
   The input is visually hidden rather than display:none so it stays
   keyboard-reachable; .selected is toggled by JS on change.
   ================================================================== */
.opt-cards { display: flex; flex-wrap: wrap; gap: 8px; }
.opt-card {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  min-width: 150px; flex: 1 1 150px; padding: 10px 12px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-bg); transition: border-color .12s, box-shadow .12s;
}
.opt-card input { position: absolute; opacity: 0; pointer-events: none; }
.opt-card:hover { border-color: var(--accent); }
.opt-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt-card .opt-title { font-weight: 600; font-size: 13px; }
.opt-card .opt-sub { font-size: 11px; color: var(--text-muted); }
.opt-card.selected .opt-title { color: var(--accent); }
.opt-card:has(input:focus-visible) { box-shadow: 0 0 0 3px rgba(99, 102, 241, .3); }

/* ==================================================================
   Dedicated Servers — ordering flow
   Step 1 is a row of product cards; step 2 pins a summary bar to the
   bottom of the viewport so the price, the resulting balance and the
   button stay together however far the size list scrolls.
   ================================================================== */
.product-card {
  border: 1px solid var(--border); background: var(--card-bg);
  color: inherit; transition: border-color .12s, box-shadow .12s, transform .12s;
}
.product-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .06);
  transform: translateY(-1px);
}
.order-summary {
  position: sticky; bottom: 12px; z-index: 5;
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .10);
}

/* ---------------------------------------------------------------------------
   Support button — persistent, on every authenticated page.
   Telegram is the only customer contact route, so it gets an affordance that
   survives scrolling rather than living in a menu. Mirrors the marketing
   site's .tg-fab so the two read as one product.
   --------------------------------------------------------------------------- */
.tg-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1030;            /* over content, under Bootstrap modals (1055) */
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 13px 19px;
  border-radius: 999px;
  background: #229ED9;
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  box-shadow: 0 12px 30px -10px rgba(34, 158, 217, 0.75);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.tg-fab:hover,
.tg-fab:focus {
  color: #fff;
  transform: translateY(-3px);
  box-shadow: 0 18px 40px -10px rgba(34, 158, 217, 0.9);
}
.tg-fab i { font-size: 1.15rem; line-height: 1; }

@media (max-width: 768px) {
  /* Shrink to a disc so it never covers the content it exists to support. */
  .tg-fab { right: 16px; bottom: 16px; padding: 13px; }
  .tg-fab-label { display: none; }
}

/* The server-order page has a sticky bottom summary bar; without this the
   support button lands on top of its confirm control. :has() is the whole fix
   and needs no template change -- browsers without it simply keep the default
   position, which is the pre-existing behaviour rather than a regression. */
body:has(.order-summary) .tg-fab { bottom: 96px; }

/* lead email: cap long addresses so the row's action buttons stay in frame */
.lead-email { max-width: 180px; }

/* CRM leads table: fits a laptop screen without sideways scrolling */
.crm-leads .lead-cell { max-width: 280px; }
.crm-leads td { padding-top: .35rem; padding-bottom: .35rem; }
