:root {
  --bg: #f3f6fb;
  --bg-top: #f8fbff;
  --bg-bottom: #eef3f9;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --accent: #008ee8;
  --accent-dark: #006db6;
  --warn: #b42318;
  --warn-soft: #fff1f0;
  --ok: #067647;
  --soft: #eef8f8;
  --input: #ffffff;
  --shadow: 0 18px 45px rgba(16, 24, 40, 0.07);
  --shadow-soft: 0 10px 26px rgba(16, 24, 40, 0.05);
}

:root[data-theme="dark"] {
  --bg: #0b1424;
  --bg-top: #101d31;
  --bg-bottom: #050b16;
  --ink: #edf5ff;
  --muted: #a8b5c9;
  --line: #263852;
  --panel: #111d31;
  --panel-soft: #17263d;
  --accent: #38bdf8;
  --accent-dark: #7dd3fc;
  --warn: #f87171;
  --warn-soft: rgba(248, 113, 113, 0.12);
  --ok: #5ee0a7;
  --soft: rgba(56, 189, 248, 0.12);
  --input: #0c1728;
  --sidebar: #07111f;
  --sidebar-ink: #e5f0ff;
  --sidebar-muted: #9fb0c8;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.32);
  --shadow-soft: 0 12px 34px rgba(0, 0, 0, 0.24);
}

:root {
  --sidebar: rgba(255, 255, 255, 0.92);
  --sidebar-ink: var(--ink);
  --sidebar-muted: var(--muted);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(0, 142, 232, 0.10), transparent 34vw),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 38%, var(--bg-bottom) 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.menu-open {
  overflow: hidden;
}

body.operator-mode .admin-only:not(.permission-visible) {
  display: none !important;
}

.registered-access-panel {
  display: none;
}

#customersList {
  display: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  color: white;
  background: var(--accent);
  min-height: 42px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
  box-shadow: 0 10px 22px rgba(0, 142, 232, 0.15);
}

button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

button.ghost {
  color: var(--ink);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  box-shadow: none;
}

button.outline {
  border: 1px solid #98a7bd;
  background: transparent;
}

button.danger {
  background: var(--warn);
  box-shadow: 0 8px 18px rgba(180, 35, 24, 0.15);
}

button.outline-danger {
  color: var(--warn);
  border: 1px solid #f0b8b2;
  background: var(--warn-soft);
  box-shadow: none;
}

button.outline-danger:hover {
  color: #ffffff;
  background: var(--warn);
}

button.compact-button {
  width: auto;
  min-height: 40px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-toggle {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  min-height: 46px;
  overflow: hidden;
  border: 1px solid rgba(245, 158, 11, .22);
  border-radius: 15px;
  padding: 0;
  color: #f59e0b;
  background: linear-gradient(145deg, #fffdf7, #fff7df);
  box-shadow: 0 8px 22px rgba(245, 158, 11, .16), inset 0 1px 0 rgba(255,255,255,.9);
  isolation: isolate;
}

.theme-toggle:hover {
  color: #f59e0b;
  background: linear-gradient(145deg, #fffdf7, #ffefc2);
  transform: translateY(-2px) rotate(-2deg);
  box-shadow: 0 12px 28px rgba(245, 158, 11, .22), inset 0 1px 0 #fff;
}

.theme-toggle-glow {
  content: "";
  position: absolute;
  width: 31px;
  height: 31px;
  border-radius: 50%;
  background: rgba(245, 158, 11, .12);
  transform: scale(.82);
  transition: background 260ms ease, transform 260ms ease;
}

.theme-icon {
  position: absolute;
  z-index: 1;
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 240ms ease, transform 300ms cubic-bezier(.2,.8,.2,1);
}
.theme-icon-sun { opacity: 1; transform: scale(1) rotate(0); }
.theme-icon-moon { opacity: 0; transform: scale(.55) rotate(35deg); }
.theme-icon-moon .moon-star { fill: currentColor; stroke: none; }
.theme-toggle:focus-visible { outline: 3px solid rgba(56, 189, 248, .35); outline-offset: 3px; }
.theme-toggle:active { transform: translateY(0) scale(.94); }
.theme-toggle:hover .theme-toggle-glow { transform: scale(1); }

@media (prefers-reduced-motion: reduce) {
  .theme-toggle,
  .theme-toggle-glow,
  .theme-icon { transition: none; }
}

:root[data-theme="dark"] .theme-toggle {
  color: #bfdbfe;
  border-color: rgba(96, 165, 250, .24);
  background: linear-gradient(145deg, #172a46, #0b172a);
  box-shadow: 0 8px 24px rgba(2, 8, 23, .4), inset 0 1px 0 rgba(191, 219, 254, .12);
}

:root[data-theme="dark"] .theme-toggle:hover {
  color: #dbeafe;
  background: linear-gradient(145deg, #203858, #0e1d33);
  box-shadow: 0 12px 28px rgba(2, 8, 23, .5), 0 0 20px rgba(96, 165, 250, .12);
}

:root[data-theme="dark"] .theme-toggle-glow { background: rgba(96, 165, 250, .12); }
:root[data-theme="dark"] .theme-icon-sun { opacity: 0; transform: scale(.55) rotate(-35deg); }
:root[data-theme="dark"] .theme-icon-moon { opacity: 1; transform: scale(1) rotate(0); }

.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 850;
}

.health-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 16%, transparent);
}

.health-badge.online {
  color: #047857;
  background: #ecfdf5;
  border-color: #bbf7d0;
}

.health-badge.offline {
  color: var(--warn);
  background: #fef3f2;
  border-color: #fecaca;
}

:root[data-theme="dark"] .health-badge.online {
  color: #9ff5c9;
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(94, 224, 167, 0.28);
}

:root[data-theme="dark"] .health-badge.offline {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.25);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 43px;
  border-radius: 7px;
  padding: 11px 15px;
  color: white;
  background: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.button-link:hover {
  background: var(--accent-dark);
}

.button-link.ghost {
  color: var(--ink);
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.button-link.ghost:hover {
  background: var(--soft);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: var(--input);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

select {
  min-height: 43px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 142, 232, 0.13);
}

textarea {
  min-height: 300px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(0, 142, 232, 0.16), transparent 34%),
    linear-gradient(315deg, rgba(0, 177, 117, 0.13), transparent 30%),
    radial-gradient(circle at 50% 0%, rgba(23, 32, 51, 0.12), transparent 42%),
    #eef4f9;
}

.login-box {
  width: min(460px, 100%);
  border: 1px solid color-mix(in srgb, var(--accent) 42%, #ffffff);
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  padding: 34px 34px 0;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    inset 0 -18px 42px rgba(15, 23, 42, 0.045),
    0 26px 76px rgba(18, 28, 45, 0.18),
    0 6px 18px rgba(18, 28, 45, 0.08);
}

.login-logo {
  width: 92px;
  height: 92px;
  margin: 0 auto 20px;
  border-radius: 8px;
}

.login-box h1 {
  font-size: 32px;
  line-height: 1.08;
  text-align: center;
}

.login-box .eyebrow,
.login-subtitle {
  text-align: center;
}

.login-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.brand-logo {
  display: block;
  object-fit: contain;
}

.sidebar-logo {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  flex: 0 0 auto;
}

.login-box h1,
.topbar h1,
.sidebar h2,
.panel h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.form-stack {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.login-box .form-stack {
  margin-top: 26px;
}

.login-box button[type="submit"] {
  margin-top: 4px;
  background: #00a66f;
  box-shadow: 0 10px 24px rgba(0, 166, 111, 0.2);
}

.login-box button[type="submit"]:hover {
  background: #087d59;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

.credit,
.app-footer {
  color: #98a2b3;
  font-size: 12px;
  text-align: center;
}

.credit {
  margin: 24px -34px 0;
  border-top: 1px solid #e4eaf3;
  color: #667085;
  background: #f3f7fb;
  padding: 15px 16px 16px;
  font-size: 12px;
  font-weight: 750;
}

.credit a,
.app-footer a {
  color: inherit;
  text-decoration: none;
}

.credit strong {
  color: #344054;
  font-weight: 900;
}

.credit a:hover,
.app-footer a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

.mobile-header,
.menu-backdrop,
.mobile-nav-group {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  padding: 22px;
  backdrop-filter: blur(18px);
}

.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
}

.sidebar-close {
  display: none;
}

.sidebar nav {
  display: grid;
  align-content: start;
  gap: 7px;
  margin-top: 28px;
}

.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 7px;
  color: var(--sidebar-ink);
  padding: 11px 12px;
  text-decoration: none;
  font-weight: 750;
}

.nav-parent {
  cursor: pointer;
}

.nav-caret {
  display: none;
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  opacity: .7;
  transform: rotate(45deg);
  transition: transform .18s ease, opacity .18s ease;
}

.nav-parent.expanded .nav-caret {
  opacity: 1;
  transform: rotate(-135deg);
}

.nav-icon {
  display: inline-grid;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 8px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.nav-icon::before {
  color: currentColor;
  font-size: 15px;
  line-height: 1;
}

.nav-icon[data-icon="dashboard"]::before { content: "▦"; }
.nav-icon[data-icon="users"]::before { content: "◉"; }
.nav-icon[data-icon="plans"]::before { content: "≡"; }
.nav-icon[data-icon="portal"]::before { content: "◌"; }
.nav-icon[data-icon="diagnostic"]::before { content: "✓"; }
.nav-icon[data-icon="leads"]::before { content: "◇"; }
.nav-icon[data-icon="bank"]::before { content: "▤"; }
.nav-icon[data-icon="payments"]::before { content: "$"; }
.nav-icon[data-icon="sessions"]::before { content: "↗"; }
.nav-icon[data-icon="integration"]::before { content: "⌁"; }
.nav-icon[data-icon="wireguard"]::before { content: "⌁"; }
.nav-icon[data-icon="radius"]::before { content: "R"; font-size: 13px; font-weight: 900; }
.nav-icon[data-icon="logs"]::before { content: "¶"; }
.nav-icon[data-icon="operators"]::before { content: "●"; }
.nav-icon[data-icon="settings"]::before { content: "⚙"; }
.nav-icon[data-icon="ads"]::before { content: "▣"; }

.sidebar a.active,
.sidebar a:hover {
  background: var(--soft);
  color: var(--accent-dark);
}

.sidebar .eyebrow,
.sidebar h2 {
  color: var(--sidebar-ink);
}

:root[data-theme="dark"] .sidebar a.active,
:root[data-theme="dark"] .sidebar a:hover {
  color: #e0f2fe;
  background: rgba(56, 189, 248, 0.18);
}

:root[data-theme="dark"] .nav-icon {
  color: #8bdfff;
  background: rgba(56, 189, 248, 0.12);
}

.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metrics article,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

:root[data-theme="dark"] .metrics article,
:root[data-theme="dark"] .panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)),
    var(--panel);
}

.metrics article {
  display: grid;
  gap: 12px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.metrics article::after {
  content: "";
  position: absolute;
  inset: auto 14px 12px 14px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), rgba(52, 211, 153, 0.9));
  opacity: 0.82;
}

.metrics article:hover,
.panel:hover {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line));
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.metrics span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metrics strong {
  font-size: 34px;
  line-height: 1;
}

.panel {
  padding: 18px;
  border-radius: 8px;
  min-width: 0;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.dashboard-visual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 24px 0 16px;
}

.dashboard-status-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  padding: 12px;
  box-shadow: var(--shadow-soft);
}

.dashboard-status-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  min-height: 48px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 10px 14px;
}

.dashboard-status-item i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 5px color-mix(in srgb, currentColor 15%, transparent);
}

.dashboard-status-item span { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.dashboard-status-item strong { font-size: 13px; }
.dashboard-status-item.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 28%, var(--line)); }
.dashboard-status-item.off { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 26%, var(--line)); }

.dashboard-chart-panel {
  min-height: 250px;
}

.dashboard-connections-panel {
  width: 100%;
  min-height: 0;
  margin-bottom: 20px;
}

.dashboard-connections-panel .summary-line-chart svg {
  height: 210px;
  min-height: 0;
}

@media (max-width: 760px) {
  .dashboard-connections-panel .summary-line-chart svg { height: 180px; }
}

.active-connections-total {
  display: grid;
  min-height: 220px;
  place-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
}

.active-connections-icon {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 18px;
  color: #22c55e;
  background: color-mix(in srgb, #22c55e 14%, var(--panel));
}

.active-connections-icon i {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 8px color-mix(in srgb, currentColor 18%, transparent);
}

.active-connections-total strong { color: var(--ink); font-size: clamp(48px, 7vw, 82px); line-height: 1; }
.active-connections-total span { color: var(--muted); font-size: 14px; font-weight: 800; }
.active-connections-line { width: min(440px, 70%); height: 6px; margin-top: 10px; overflow: hidden; border-radius: 99px; background: var(--line); }
.active-connections-line i { display: block; width: 100%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #22c55e, #14b8a6); }

.top-users-panel { min-height: 0; }
.top-users-list { display: grid; }
.top-user-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
}
.top-user-row:last-child { border-bottom: 0; }
.top-user-row > div:last-child { display: grid; gap: 3px; }
.top-user-name-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.top-user-row strong { color: var(--ink); font-size: 16px; }
.top-user-row span { color: var(--muted); font-size: 13px; font-weight: 700; }
.top-user-row .top-user-source {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.top-user-row .top-user-source.lead { color: #be185d; border-color: #f9a8d4; background: #fce7f3; }
.top-user-row .top-user-source.isp { color: #b45309; border-color: #fcd34d; background: #fef3c7; }
:root[data-theme="dark"] .top-user-row .top-user-source.lead { color: #f9a8d4; border-color: #9d174d; background: #500724; }
:root[data-theme="dark"] .top-user-row .top-user-source.isp { color: #fcd34d; border-color: #92400e; background: #451a03; }
.top-user-trophy { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 13px; font-size: 22px; }
.top-user-trophy.gold { background: #fff7bf; }
.top-user-trophy.silver { background: #edf2f7; }
.top-user-trophy.bronze { background: #ffead1; }
.top-user-trophy.green { background: #d1fae5; }
.top-user-trophy.blue { background: #dbeafe; }
:root[data-theme="dark"] .top-user-trophy { filter: saturate(.85) brightness(.8); }

.mini-bar-chart {
  display: grid;
  gap: 14px;
  min-height: 170px;
  align-content: center;
}

.mini-bar-item {
  display: grid;
  gap: 8px;
}

.mini-bar-track {
  position: relative;
  height: 13px;
  border-radius: 999px;
  background: var(--panel-soft);
  overflow: hidden;
}

:root[data-theme="dark"] .mini-bar-track {
  background: rgba(148, 163, 184, 0.16);
}

.mini-bar-track span {
  display: block;
  height: 100%;
  min-width: 8px;
  border-radius: 999px;
}

.mini-bar-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-weight: 850;
}

.mini-bar-row strong {
  color: var(--ink);
}

.health-card-grid {
  display: grid;
  gap: 10px;
}

.health-card-grid article {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 14px;
}

:root[data-theme="dark"] .health-card-grid article {
  background: rgba(23, 38, 61, 0.78);
}

.health-card-grid article.ok strong {
  color: var(--ok);
}

.health-card-grid article.warn strong {
  color: var(--warn);
}

.panel.narrow {
  max-width: 760px;
}

.panel-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.compact-head {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.customer-tools {
  flex: 1 1 420px;
  min-width: min(100%, 280px);
}

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

.cpf-panel .panel-head {
  align-items: flex-start;
  flex-wrap: wrap;
}

.cpf-panel .panel-head > div:first-child {
  flex: 0 0 auto;
}

.cpf-panel .admin-only {
  flex: 0 1 520px;
}

@media (min-width: 1200px) {
  .cpf-panel > .panel-head {
    display: grid;
    grid-template-columns: minmax(300px, .85fr) minmax(560px, 1.15fr);
    grid-template-rows: auto auto;
    align-items: start;
    column-gap: 30px;
    row-gap: 12px;
  }

  .cpf-panel > .panel-head > div:first-child {
    grid-column: 1;
    grid-row: 1 / 3;
    padding-top: 6px;
  }

  .cpf-panel > .panel-head > .customer-tools {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    min-width: 0;
  }

  .cpf-panel > .panel-head > .inline-actions {
    grid-column: 2;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
    gap: 9px;
  }

  .cpf-panel > .panel-head > .inline-actions button {
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
    white-space: nowrap;
  }
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.integration-tabs {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  overflow-x: auto;
}

.integration-tab {
  position: relative;
  min-height: 44px;
  border-radius: 0;
  padding: 0 2px 13px;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
  white-space: nowrap;
  text-decoration: none;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
}

.integration-tab:hover {
  color: var(--accent-dark);
  background: transparent;
  transform: none;
}

.integration-tab.active::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 3px;
  border-radius: 999px 999px 0 0;
  background: var(--accent);
  content: "";
}

.integration-page {
  min-width: 0;
}

.customer-tab-page {
  min-width: 0;
}

.ad-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 720px);
}

.ad-stats-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(170px, 230px)) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.ad-stats-toolbar > div {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  padding: 10px 14px;
  box-shadow: var(--shadow-soft);
}

.ad-stats-toolbar span { color: var(--muted); font-size: 12px; font-weight: 800; }
.ad-stats-toolbar strong { color: var(--ink); font-size: 20px; }
.ad-stats-toolbar button { justify-self: start; }

@media (max-width: 760px) {
  .ad-stats-toolbar { grid-template-columns: 1fr; }
  .ad-stats-toolbar button { width: 100%; }
}

.story-preview {
  position: relative;
  display: grid;
  width: min(100%, 270px);
  aspect-ratio: 9 / 16;
  place-items: center;
  overflow: hidden;
  margin-top: 18px;
  border: 1px dashed var(--line);
  border-radius: 22px;
  color: var(--muted);
  background: var(--panel-soft);
  box-shadow: var(--shadow-soft);
}

.story-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.table-pagination label,
.pagination-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-pagination select {
  width: auto;
  min-height: 38px;
  padding: 7px 30px 7px 10px;
}

.pagination-actions button {
  width: 40px;
  min-height: 38px;
  padding: 6px;
  font-size: 22px;
}

.pagination-actions button:disabled {
  cursor: default;
  opacity: .4;
  transform: none;
}

:root[data-theme="dark"] button.ghost,
:root[data-theme="dark"] .button-link.ghost {
  color: #edf5ff;
  background: #17263d;
  border-color: #314663;
}

:root[data-theme="dark"] button.ghost:hover,
:root[data-theme="dark"] .button-link.ghost:hover {
  color: #ffffff;
  background: #213551;
}

.integration-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.portal-captive-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(420px, 1.05fr);
  gap: 16px;
  align-items: start;
}

.portal-preview-panel {
  position: sticky;
  top: 24px;
}

.portal-preview-panel .portal-preview-shell {
  min-height: calc(100vh - 180px);
}

.portal-editor-panel .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cpf-panel {
  width: 100%;
}

.cpf-panel .form-grid {
  grid-template-columns: 1.2fr 1fr 0.55fr;
}

.cpf-panel .operator-list {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

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

.payment-config-panel {
  grid-column: 1 / -1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid button,
.form-grid .check {
  grid-column: span 2;
}

.form-grid button {
  justify-self: start;
  min-width: 180px;
  width: auto;
}

.form-grid .wide-field,
.form-grid .form-actions {
  grid-column: 1 / -1;
}

.form-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, 0.6fr);
  gap: 12px;
  align-items: center;
}

.form-actions button {
  grid-column: auto;
}

.compact-export-form {
  grid-template-columns: minmax(150px, 220px) minmax(150px, 220px) auto;
  align-items: end;
  margin: 12px 0 14px;
}

.compact-export-form button {
  grid-column: auto;
  width: auto;
  min-height: 42px;
  padding: 0 18px;
  justify-self: start;
  border-radius: 8px;
  white-space: nowrap;
}

.restart-actions {
  margin-top: 16px;
}

.payment-form {
  align-items: start;
}

.payment-form .copy-line,
.payment-form .payment-subsection {
  grid-column: 1 / -1;
}

.payment-provider-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 92%, var(--accent) 8%);
  padding: 16px;
}

.payment-provider-panel[hidden] {
  display: none !important;
}

.payment-test-line {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 2px;
}

.payment-test-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.payment-test-status.ok { color: var(--success); }
.payment-test-status.error { color: var(--danger); }
.payment-test-status.pending { color: var(--accent-dark); }

.payment-subsection {
  border-top: 0;
  padding-top: 0;
}

.payment-subsection h3 {
  margin: 0;
  font-size: 16px;
}

.payment-subsection p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.copy-line {
  display: grid;
  gap: 6px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #f8fafc;
}

.copy-line span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.copy-line code {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  white-space: normal;
}

.compact-textarea {
  min-height: 96px;
}

.brand-preview {
  grid-column: span 2;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.brand-preview img {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  background: #f8fafc;
  flex: 0 0 auto;
}

.check {
  display: flex;
  align-items: center;
  color: var(--ink);
}

.check input {
  width: auto;
}

.startup-toggle {
  justify-content: flex-start;
  gap: 10px;
  margin: 2px 0 8px;
  font-size: 15px;
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
  width: 100%;
}

.access-list {
  display: grid;
  gap: 12px;
}

.access-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
}

.access-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.access-main h3 {
  margin: 0;
  font-size: 18px;
}

.access-main p {
  margin: 4px 0 0;
  color: var(--muted);
}

.access-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.access-meta div {
  min-width: 0;
  border-radius: 7px;
  background: #f8fafc;
  padding: 10px;
}

.access-meta dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.access-meta dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 700;
}

.access-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.access-actions button {
  min-height: 40px;
}

.operator-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.operator-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.operator-card div {
  display: grid;
  gap: 3px;
}

.operator-card span {
  color: var(--muted);
  font-size: 13px;
}

.permissions-editor {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 14px;
}

.erp-test-box {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 14px;
}

.test-result {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 800;
}

.test-result.ok {
  border-color: color-mix(in srgb, var(--ok) 34%, var(--line));
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 10%, var(--panel));
}

.test-result.warn {
  border-color: color-mix(in srgb, var(--warn) 34%, var(--line));
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, var(--panel));
}

.permissions-head {
  display: grid;
  gap: 2px;
}

.permissions-head strong {
  font-size: 14px;
}

.permissions-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.permission-action-grid {
  margin-top: 6px;
}

.permission-subhead {
  grid-column: 1 / -1;
  margin-top: 4px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.permission-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
  cursor: pointer;
}

.permission-chip input {
  width: auto;
  margin: 0;
}

.permission-chip span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.router-health-stack { display:grid; justify-items:end; gap:5px; }
.router-health-stack small { color:var(--muted); font-size:11px; font-weight:750; }
.active-operators-panel { margin-top:22px; padding-top:4px; }
.active-operator-card { border-color:color-mix(in srgb,var(--ok) 28%,var(--line)); }

@media (max-width: 760px) {
  .router-health-stack { justify-items:start; }
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tbody tr {
  transition: background 150ms ease;
}

tbody tr:hover {
  background: #f8fbff;
}

:root[data-theme="dark"] tbody tr {
  background: transparent;
}

:root[data-theme="dark"] tbody tr:hover {
  background: rgba(56, 189, 248, 0.08);
}

:root[data-theme="dark"] th,
:root[data-theme="dark"] td {
  color: var(--ink);
  border-color: rgba(148, 163, 184, 0.22);
}

:root[data-theme="dark"] th,
:root[data-theme="dark"] .muted-cell {
  color: var(--muted);
}

:root[data-theme="dark"] .table-wrap {
  border-color: var(--line);
  background: var(--panel);
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  color: var(--ink);
  border-color: #30435f;
  background: var(--input);
}

:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder {
  color: #7988a2;
}

.muted-cell {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

td.actions {
  width: 1%;
  text-align: right;
  white-space: nowrap;
  min-width: 132px;
}

td.actions button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.status-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.status-actions button,
.row-actions button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.small-action {
  min-width: 64px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.badge.ok {
  color: var(--ok);
  background: #ecfdf3;
}

.badge.blocked {
  color: var(--warn);
  background: #fef3f2;
}

.badge.online {
  color: #175cd3;
  background: #eff8ff;
}

.badge.linked {
  color: #7a2e0e;
  background: #fff4e5;
}

:root[data-theme="dark"] .badge.ok,
:root[data-theme="dark"] .badge.online {
  color: #9ff5c9;
  background: rgba(52, 211, 153, 0.12);
}

:root[data-theme="dark"] .badge.blocked {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.12);
}

:root[data-theme="dark"] .badge.linked {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.14);
}

.audit-list {
  display: grid;
  gap: 10px;
}

.audit-list article {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  color: var(--muted);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.status-grid article {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 14px;
}

.status-grid span,
.status-grid small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.status-grid strong {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.15;
}

#leadsOverview,
#ispOverview,
#radiusOverview,
#wireguardOverview,
#radiusClientForm {
  margin-bottom: 20px;
}

@media (max-width: 760px) {
  #leadsOverview,
  #ispOverview,
  #radiusOverview,
  #wireguardOverview,
  #radiusClientForm {
    margin-bottom: 16px;
  }
}

.script-preview {
  display: grid;
  gap: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--muted);
}

.script-preview code {
  color: var(--accent-dark);
  font-weight: 800;
}

.portal-preview-shell {
  --preview-primary: #0095e8;
  --preview-accent: #22d3ee;
  --preview-bg: #eaf6ff;
  --preview-card: #ffffff;
  --preview-text: #111827;
  display: grid;
  position: relative;
  place-items: center;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--preview-accent) 24%, transparent), transparent 34vw),
    linear-gradient(180deg, #ffffff 0%, var(--preview-bg) 100%);
}

.portal-preview-card {
  width: 100%;
  border: 1px solid color-mix(in srgb, var(--preview-accent) 55%, #ffffff);
  background: var(--preview-card);
  padding: 24px 18px 20px;
  color: var(--preview-text);
  text-align: center;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    inset 0 -18px 42px rgba(15, 23, 42, 0.045),
    0 22px 48px rgba(10, 24, 60, 0.18),
    0 5px 16px rgba(10, 24, 60, 0.08);
}

.portal-preview-card img {
  display: block;
  max-width: 72%;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  margin: 0 auto 12px;
}

.portal-preview-card .logo-edit {
  display: block;
  width: auto;
  min-height: 0;
  margin: 0 auto;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.portal-preview-card h3 {
  margin: 0;
  color: var(--preview-primary);
  font-size: 28px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.portal-preview-card p {
  max-width: 420px;
  margin: 11px auto 20px;
  color: var(--preview-subtitle, var(--muted));
  font-size: clamp(16px, 1.9vw, 20px);
  font-weight: 850;
  letter-spacing: -0.025em;
  line-height: 1.38;
}

.portal-preview-tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 18px 0 16px;
  border-radius: 8px;
  background: #eef4ff;
  padding: 6px;
}

.portal-preview-tabs::before {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 6px;
  width: calc((100% - 20px) / 2);
  border-radius: 7px;
  background: var(--preview-primary);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--preview-primary) 24%, transparent);
  transform: translateX(0);
  transition: transform 320ms cubic-bezier(.22, 1, .36, 1);
  content: "";
}

.portal-preview-tabs:has(button:nth-child(2).active)::before {
  transform: translateX(calc(100% + 8px));
}

.portal-preview-tabs button {
  position: relative;
  z-index: 1;
  display: grid;
  width: 100%;
  min-height: 44px;
  place-items: center;
  margin: 0;
  border: 0;
  border-radius: 7px;
  color: var(--preview-primary);
  background: transparent;
  font-weight: 850;
  box-shadow: none;
}

.portal-preview-tabs .active {
  color: #ffffff;
  background: transparent;
}

.portal-preview-card label {
  color: #344054;
  text-align: left;
}

.portal-preview-card input {
  background: #ffffff;
}

.portal-preview-card .city-suggestions {
  display: grid;
  gap: 6px;
  margin-top: 3px;
  padding: 7px;
  border: 1px solid #d8e0ec;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 14px 32px rgba(15, 23, 42, .13);
}

.portal-preview-card .city-suggestions.hidden {
  display: none;
}

.portal-preview-card .city-suggestions .city-option {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid #e4eaf3;
  border-radius: 8px;
  color: #18243c;
  background: #f8fbff;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.portal-preview-card .city-suggestions .city-option:hover,
.portal-preview-card .city-suggestions .city-option:focus-within {
  border-color: color-mix(in srgb, var(--preview-primary) 42%, #ffffff);
  color: var(--preview-primary);
  background: color-mix(in srgb, var(--preview-primary) 8%, #ffffff);
}

.portal-preview-card .city-suggestions .city-option input {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  min-height: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin: 0;
  padding: 0;
  border: 2px solid #9bb6d3;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: none;
}

.portal-preview-card .city-suggestions .city-option input:checked {
  border-color: var(--preview-primary);
  background: radial-gradient(circle, var(--preview-primary) 0 43%, #ffffff 47% 58%, var(--preview-primary) 62% 100%);
}

.portal-preview-card .city-suggestions .city-option span {
  flex: 1;
}

.portal-preview-card .city-suggestions .empty {
  padding: 8px 10px;
  color: #667085;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.portal-preview-main-button,
.portal-preview-buy {
  display: grid;
  width: 100%;
  min-height: 46px;
  place-items: center;
  margin-top: 12px;
  border: 0;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 850;
  text-decoration: none;
  box-shadow: none;
}

.portal-preview-main-button {
  color: #ffffff;
  background: var(--preview-primary);
}
.portal-preview-main-button:disabled { cursor: not-allowed; opacity: .48; filter: saturate(.45); }
.portal-preview-privacy-consent { position: relative; display: flex; align-items: center; gap: 7px; min-height: 44px; margin-top: 12px; padding: 9px 11px 9px 15px; border: 1px solid var(--line); border-radius: 9px; color: #475467; background: #f8fafc; font-size: 11px; font-weight: 750; text-align: left; }
.portal-preview-privacy-consent input { appearance: none; -webkit-appearance: none; width: 20px; min-height: 20px; height: 20px; flex: 0 0 20px; margin: 0; padding: 0; border: 2px solid color-mix(in srgb, var(--preview-primary) 76%, #64748b); border-radius: 50%; background: #fff; box-shadow: 0 0 0 0 color-mix(in srgb, var(--preview-primary) 62%, transparent); animation: previewPrivacyPulse 1.35s ease-out infinite; cursor: pointer; }
.portal-preview-privacy-consent input:focus { border-color: var(--preview-primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--preview-primary) 20%, transparent); outline: none; }
.portal-preview-privacy-consent input:checked { border-color: var(--preview-primary); background: radial-gradient(circle, var(--preview-primary) 0 43%, #fff 47% 58%, var(--preview-primary) 62% 100%); }
.portal-preview-privacy-consent label { display: inline; color: #475467; font-size: 11px; cursor: pointer; }
.portal-preview-privacy-consent button { display: inline; width: auto; min-height: 0; margin: 0; padding: 0; border: 0; color: var(--preview-primary); background: transparent; box-shadow: none; font-size: 11px; font-weight: 850; text-decoration: underline; user-select: none; -webkit-user-select: none; }
.portal-preview-privacy-consent.accepted { border-color: #86efac; background: #f0fdf4; }
.portal-preview-privacy-pulse { display: none; }
.portal-preview-privacy-consent.accepted input { animation: none; transform: none; box-shadow: none; }
.portal-preview-privacy-modal { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; padding: 18px; border-radius: inherit; overflow: hidden; }
.portal-preview-privacy-backdrop { position: absolute; inset: 0; background: rgba(5,15,30,.68); backdrop-filter: blur(4px); }
.portal-preview-privacy-dialog { position: relative; width: min(100%,480px); max-height: 80%; display: flex; flex-direction: column; overflow: hidden; border-radius: 18px; color: #101828; background: #fff; box-shadow: 0 24px 70px rgba(0,0,0,.3); text-align: left; }
.portal-preview-privacy-dialog header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 18px 12px; border-bottom: 1px solid #eaecf0; }
.portal-preview-privacy-dialog header small { color: var(--preview-primary); font-size: 9px; font-weight: 900; letter-spacing: .08em; }
.portal-preview-privacy-dialog h3 { margin: 3px 0 0; color: #101828; font-size: 20px; }
.portal-preview-privacy-dialog header button { width: 34px; min-height: 34px; padding: 0; border-radius: 9px; color: #475467; background: #f2f4f7; font-size: 22px; }
.portal-preview-privacy-dialog > div { overflow: auto; padding: 16px 18px; }
.portal-preview-privacy-dialog p { margin: 0 0 10px; color: #475467; font-size: 12px; text-align: left; }
.portal-preview-privacy-dialog h4 { margin: 14px 0 4px; font-size: 13px; }
.portal-preview-privacy-dialog .portal-preview-policy-ok { width: auto; min-height: 42px; margin: 0 18px 18px; color: #fff; background: var(--preview-primary); }
@keyframes previewPrivacyPulse { 0% { transform: scale(1); box-shadow: 0 0 0 0 color-mix(in srgb, var(--preview-primary) 62%, transparent); } 55% { transform: scale(1.12); box-shadow: 0 0 0 9px color-mix(in srgb, var(--preview-primary) 0%, transparent); } 100% { transform: scale(1); box-shadow: 0 0 0 0 color-mix(in srgb, var(--preview-primary) 0%, transparent); } }
@media (prefers-reduced-motion: reduce) { .portal-preview-privacy-consent input { animation: none; } }

.portal-preview-buy {
  border: 1px solid color-mix(in srgb, var(--preview-primary) 32%, #ffffff);
  color: var(--preview-primary);
  background: color-mix(in srgb, var(--preview-primary) 9%, #ffffff);
}

.portal-preview-plan-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.portal-preview-plan-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  border: 1px solid color-mix(in srgb, var(--preview-primary) 24%, #ffffff);
  border-radius: 8px;
  color: var(--preview-text);
  background: #ffffff;
  padding: 10px 12px;
  box-shadow: none;
  text-align: left;
}

.portal-preview-plan-list button:hover {
  color: #ffffff;
  background: var(--preview-primary);
}

.portal-preview-feedback {
  margin-top: 12px;
  border: 1px solid color-mix(in srgb, var(--preview-primary) 28%, #ffffff);
  border-radius: 8px;
  color: var(--preview-primary);
  background: color-mix(in srgb, var(--preview-primary) 8%, #ffffff);
  padding: 10px;
  font-size: 13px;
  font-weight: 800;
}

.portal-preview-feedback[data-type="error"] {
  border-color: color-mix(in srgb, #ef4444 42%, #ffffff);
  color: #b91c1c;
  background: color-mix(in srgb, #ef4444 10%, #ffffff);
}

.portal-preview-feedback[data-type="success"] {
  border-color: color-mix(in srgb, #22c55e 42%, #ffffff);
  color: #047857;
  background: color-mix(in srgb, #22c55e 10%, #ffffff);
}

.field-highlight {
  color: var(--accent-dark);
}

.portal-preview-card footer {
  margin: 18px -18px -20px;
  border-top: 1px solid #e4eaf3;
  color: #667085;
  background: #f3f7fb;
  padding: 14px 16px;
  font-size: 12px;
  font-weight: 750;
}

.portal-preview-card footer strong {
  color: #344054;
  font-weight: 900;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(4px);
}

.script-modal {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  width: min(980px, 100%);
  max-height: min(90vh, 820px);
  overflow: hidden;
  border: 1px solid rgba(216, 226, 237, 0.9);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(16, 24, 40, 0.24);
}

.credential-modal {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(430px, 100%);
  max-height: min(90vh, 760px);
  overflow: hidden;
  border: 1px solid rgba(216, 226, 237, 0.9);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(16, 24, 40, 0.22);
}

.credential-card {
  display: grid;
  gap: 18px;
  align-content: start;
  padding: 18px 36px;
  text-align: center;
}

.fake-qr {
  display: grid;
  width: 156px;
  height: 156px;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 auto;
  border: 10px solid #ffffff;
  background: #f2f4f7;
  box-shadow: 0 0 0 1px var(--line);
}

.fake-qr span {
  background: #111827;
}

.fake-qr span:nth-child(2n),
.fake-qr span:nth-child(7),
.fake-qr span:nth-child(11),
.fake-qr span:nth-child(14) {
  background: #ffffff;
}

.credential-card dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

.credential-card div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.credential-card dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.credential-card dd {
  margin: 4px 0 0;
  font-size: 22px;
  font-weight: 850;
}

.history-list {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow-y: auto;
  padding: 18px 36px;
}

.history-list article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.history-list strong,
.history-list time,
.history-list p {
  display: block;
}

.history-list time {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.history-list p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.script-modal.script-ready {
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(1120px, 100%);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px;
}

.modal-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.08;
}

.icon-btn {
  width: 38px;
  height: 38px;
  color: #8794a8;
  background: #f1f5f9;
  font-size: 25px;
  line-height: 1;
  padding: 0;
  box-shadow: none;
}

.script-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-content: start;
  overflow-y: auto;
  padding: 18px 22px 22px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.script-modal.script-ready .script-form {
  display: none;
}

.script-form label {
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.script-form input,
.script-form select {
  min-height: 44px;
  color: #667085;
  background: #f8fafc;
  font-size: 15px;
  font-weight: 750;
}

.generated-script {
  overflow: auto;
  border-top: 1px solid var(--line);
  padding: 18px 22px;
}

.generated-script h3 {
  margin: 0;
}

.inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.search-input {
  min-width: min(240px, 100%);
}

.modal-actions {
  border-top: 1px solid var(--line);
  background: #f8fafc;
  justify-content: flex-end;
}

.modal-actions button {
  min-width: 120px;
  border-radius: 8px;
  font-size: 15px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 420px;
  border-radius: 8px;
  color: white;
  background: #101828;
  padding: 13px 15px;
  box-shadow: 0 16px 45px rgba(16, 24, 40, 0.22);
}

.app-footer {
  margin-top: auto;
  padding: 28px 0 8px;
}

.app-footer a {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
  min-width: 0;
  min-height: 34px;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, rgba(255, 255, 255, 0.58));
  border-radius: 14px;
  color: color-mix(in srgb, var(--muted) 88%, var(--ink));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.18)),
    color-mix(in srgb, var(--panel) 54%, transparent);
  padding: 7px 18px 8px;
  overflow: hidden;
  font-weight: 760;
  line-height: 1.15;
  letter-spacing: .01em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.62),
    inset 0 -10px 20px color-mix(in srgb, var(--accent) 6%, transparent),
    0 14px 30px rgba(10, 24, 60, 0.10),
    0 3px 8px rgba(10, 24, 60, 0.06);
  backdrop-filter: blur(16px) saturate(1.08);
  -webkit-backdrop-filter: blur(16px) saturate(1.08);
  transition: transform 180ms ease, box-shadow 180ms ease, color 180ms ease, border-color 180ms ease;
}

.app-footer a::before {
  position: absolute;
  inset: 1px 12px auto;
  z-index: -1;
  height: 44%;
  border-radius: 12px 12px 70% 70%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.38), transparent);
  opacity: .62;
  content: "";
}

.app-footer a::after {
  position: absolute;
  right: 18px;
  bottom: 6px;
  z-index: -1;
  width: 46px;
  height: 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  filter: blur(12px);
  opacity: .42;
  content: "";
}

.app-footer a:hover {
  border-color: color-mix(in srgb, var(--accent) 28%, rgba(255, 255, 255, 0.62));
  color: var(--accent-dark);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.68),
    inset 0 -10px 22px color-mix(in srgb, var(--accent) 8%, transparent),
    0 16px 34px rgba(10, 24, 60, 0.12),
    0 4px 10px rgba(10, 24, 60, 0.07);
}

.menu-btn {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  gap: 4px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.08);
}

.menu-btn span {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: var(--ink);
}

@media (max-width: 920px) {
  .app-shell {
    display: block;
    padding-top: 72px;
  }

  .mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 16;
    display: flex;
    width: 100%;
    min-height: 72px;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    padding: 12px 16px;
    backdrop-filter: blur(16px);
  }

  :root[data-theme="dark"] .mobile-header {
    background: rgba(7, 17, 31, 0.96);
  }

  :root[data-theme="dark"] .menu-btn {
    color: var(--ink);
    background: var(--panel);
    border: 1px solid var(--line);
  }

  .mobile-header strong {
    display: block;
    font-size: 17px;
  }

  .mobile-header .eyebrow {
    margin-bottom: 2px;
  }

  .menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 17;
    display: block;
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
    background: rgba(15, 23, 42, 0);
    transition: background 180ms ease, opacity 180ms ease, visibility 0s linear 180ms;
  }

  body.menu-open .menu-backdrop {
    pointer-events: auto;
    visibility: visible;
    opacity: 1;
    background: rgba(15, 23, 42, 0.42);
    transition-delay: 0s;
  }

  .split,
  .config-grid,
  .portal-captive-layout,
  .metrics,
  .status-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .cpf-panel .form-grid {
    grid-template-columns: 1fr;
  }

  .compact-export-form {
    grid-template-columns: 1fr;
  }

  .compact-export-form button {
    width: 100%;
    justify-self: stretch;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 18;
    width: min(84vw, 320px);
    height: 100vh;
    grid-template-rows: auto 1fr auto;
    gap: 18px;
    border-right: 0;
    border-radius: 0 14px 14px 0;
    box-shadow: 20px 0 45px rgba(16, 24, 40, 0.18);
    transform: translateX(-105%);
    transition: transform 200ms ease;
  }

  body.menu-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-close {
    display: inline-grid;
    width: 38px;
    height: 38px;
    font-size: 30px;
  }

  .sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
  }

  .nav-caret {
    display: block;
  }

  .mobile-nav-group {
    display: none;
    gap: 4px;
    margin: -3px 0 5px 48px;
    padding-left: 10px;
    border-left: 1px solid rgba(113, 205, 249, .25);
  }

  .mobile-nav-group.open {
    display: grid;
  }

  .mobile-nav-group a {
    display: flex;
    min-height: 38px;
    align-items: center;
    gap: 8px;
    padding: 8px 11px;
    border-radius: 9px;
    color: var(--sidebar-muted);
    font-size: 13px;
  }

  .mobile-nav-group a::before {
    width: 5px;
    height: 5px;
    flex: 0 0 5px;
    border-radius: 50%;
    background: currentColor;
    content: "";
  }

  .mobile-nav-group a.active { color: #fff; background: rgba(255,255,255,.08); }

  .sidebar a {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    padding: 13px 12px;
  }

  .form-grid button,
  .form-grid .check {
    grid-column: auto;
  }

  .content {
    min-height: calc(100vh - 72px);
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .topbar button:not(.theme-toggle),
  .panel-head button,
  .panel-head .button-link,
  td.actions button {
    min-height: 42px;
  }

  .panel {
    padding: 16px;
  }

  .portal-preview-panel {
    position: static;
  }

  .portal-preview-panel .portal-preview-shell {
    min-height: 520px;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .metrics {
    gap: 10px;
  }

  .metrics article {
    padding: 16px;
  }

  .metrics strong {
    font-size: 30px;
  }

  td.actions {
    min-width: 180px;
  }

  .access-meta {
    grid-template-columns: 1fr;
  }

  .access-actions button {
    flex: 1 1 150px;
  }

  .script-modal {
    width: 100%;
    max-height: calc(100vh - 24px);
  }

  .credential-modal {
    width: 100%;
    max-height: calc(100vh - 24px);
  }

  .modal-head,
  .modal-actions,
  .script-form,
  .generated-script,
  .credential-card,
  .history-list {
    padding-left: 22px;
    padding-right: 22px;
  }

  .modal-head,
  .modal-actions {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .modal-head h2 {
    font-size: 24px;
  }

  .modal-actions {
    gap: 10px;
  }

  .modal-actions button {
    min-width: 0;
    flex: 1;
  }
}

@media (max-width: 520px) {
  .login-shell {
    align-items: start;
    padding: 18px 14px;
  }

  .login-box {
    padding: 24px 18px 0;
  }

  .credit {
    margin-right: -18px;
    margin-left: -18px;
    padding: 13px 14px 14px;
  }

  .topbar button,
  .panel-head button,
  .panel-head .button-link,
  .form-grid button,
  #openScriptModalBtn {
    width: 100%;
  }

  .topbar .theme-toggle {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 14px;
  }

  .inline-actions {
    width: 100%;
  }

  .inline-actions button {
    flex: 1;
  }

  .search-input {
    width: 100%;
  }

  .script-form label {
    font-size: 13px;
  }

  .script-form input,
  .script-form select {
    min-height: 46px;
    font-size: 15px;
  }
}

@media (max-width: 980px) {
  .dashboard-visual-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .topbar-actions {
    justify-content: flex-start;
  }

  .metrics article {
    padding: 16px;
  }

  .mini-bar-chart {
    min-height: 0;
  }

  .permission-grid {
    grid-template-columns: 1fr;
  }

  .erp-test-box {
    grid-template-columns: 1fr;
  }

  .dashboard-status-bar { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  body {
    background: var(--bg);
  }

  button,
  .button-link {
    min-height: 44px;
    border-radius: 8px;
  }

  input,
  select,
  textarea {
    min-height: 46px;
    border-radius: 8px;
    font-size: 16px;
  }

  .app-shell {
    padding-top: 76px;
  }

  .mobile-header {
    min-height: 76px;
    padding: 12px 14px;
  }

  .menu-btn {
    width: 50px;
    height: 50px;
    border-radius: 8px;
  }

  .sidebar {
    width: min(88vw, 330px);
    padding: 18px;
  }

  .sidebar-head {
    align-items: center;
  }

  .sidebar-logo {
    width: 50px;
    height: 50px;
  }

  .sidebar h2 {
    font-size: 22px;
    line-height: 1.08;
  }

  .sidebar a {
    border-radius: 8px;
    padding: 14px;
    font-size: 16px;
  }

  .content {
    padding: 14px;
  }

  .app-footer {
    padding: 24px 0 10px;
  }

  .app-footer a {
    min-width: 0;
    min-height: 34px;
    padding: 7px 14px 8px;
    font-size: 11px;
    border-radius: 13px;
  }

  .topbar {
    border-bottom: 1px solid var(--line);
    margin: -14px -14px 14px;
    padding: 18px 14px 20px;
    background:
      linear-gradient(135deg, rgba(0, 142, 232, 0.10), rgba(255, 255, 255, 0)),
      #f8fbff;
  }

  :root[data-theme="dark"] .topbar {
    background:
      linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(15, 23, 42, 0)),
      #0b1424;
  }

  .topbar h1 {
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: clamp(28px, 9vw, 38px);
    line-height: 1.02;
  }

  .topbar p {
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: 18px;
    line-height: 1.25;
  }

  .health-badge {
    min-height: 42px;
    padding: 10px 14px;
    font-size: 14px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics article {
    border-radius: 8px;
    padding: 15px;
  }

  .metrics strong {
    font-size: 32px;
  }

  .panel {
    border-radius: 8px;
    padding: 16px;
    overflow: hidden;
  }

  .modal {
    padding: 0;
    place-items: stretch;
  }

  .script-modal {
    width: 100%;
    max-height: none;
    height: 100vh;
    border-radius: 0;
  }

  .credential-modal {
    width: 100%;
    max-height: none;
    height: 100vh;
    border-radius: 0;
  }

  .script-form {
    grid-template-columns: 1fr;
  }

  .panel + .panel {
    margin-top: 2px;
  }

  .panel-head {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 14px;
  }

  .panel-head h2 {
    overflow-wrap: anywhere;
    font-size: clamp(26px, 8vw, 34px);
    line-height: 1.04;
  }

  .panel-note {
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: 15px;
    line-height: 1.35;
  }

  .customer-tools,
  .inline-actions,
  .cpf-panel .admin-only {
    width: 100%;
    min-width: 0;
    flex-basis: auto;
  }

  .inline-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .form-grid,
  .cpf-panel .form-grid,
  .config-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .form-grid button,
  .form-grid .check,
  .form-grid .wide-field,
  .form-grid .form-actions,
  .brand-preview {
    grid-column: auto;
  }

  .form-actions {
    grid-template-columns: 1fr;
  }

  .brand-preview {
    align-items: flex-start;
  }

  .connections-panel .panel-head {
    grid-template-columns: 1fr;
  }

  .connections-panel .panel-head button {
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
  }

  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap th,
  .table-wrap td {
    display: block;
    width: 100%;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tbody {
    display: grid;
    gap: 12px;
  }

  .table-wrap tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 12px;
    box-shadow: 0 10px 28px rgba(16, 24, 40, 0.05);
  }

  .table-wrap tr:hover {
    background: var(--panel);
  }

  .table-wrap td {
    display: grid;
    grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .table-wrap td:first-child {
    padding-top: 0;
    font-size: 20px;
    font-weight: 850;
  }

  .table-wrap td:first-child::before {
    align-self: center;
  }

  .table-wrap td:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .table-wrap td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: .02em;
    text-transform: uppercase;
  }

  .table-wrap td.actions {
    min-width: 0;
    width: 100%;
    text-align: left;
  }

  .table-wrap td.actions .row-actions {
    justify-content: stretch;
    width: 100%;
  }

  .table-wrap td.actions button {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 40px;
    padding: 8px 10px;
  }

  .badge {
    justify-self: start;
    padding: 7px 10px;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    left: 12px;
    max-width: none;
    border-radius: 8px;
  }

  .integration-tabs {
    gap: 8px;
    margin-right: -14px;
    margin-left: -14px;
    padding: 0 14px;
    scrollbar-width: none;
  }

  .integration-tab {
    min-height: 46px;
    padding-right: 10px;
    padding-left: 10px;
  }

  .table-pagination {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .table-pagination > span {
    text-align: right;
  }

  .pagination-actions {
    grid-column: 1 / -1;
    justify-content: space-between;
  }

  .pagination-actions button {
    width: 48px;
  }

  .health-card-grid,
  .dashboard-visual-grid {
    min-width: 0;
  }

  .mini-bar-row {
    gap: 8px;
  }

  .mini-bar-row span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  :root[data-theme="dark"] input[type="date"] {
    color-scheme: dark;
  }
}

/* Modern icons and action controls */
.nav-icon::before { display: none; }
.nav-icon {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
  border-radius: 10px;
  transition: transform .18s ease, background .18s ease;
}
.nav-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sidebar a:hover .nav-icon { transform: scale(1.08) rotate(-2deg); }
.nav-icon[data-icon="dashboard"] { color:#67d4ff; background:rgba(14,165,233,.16); }
.nav-icon[data-icon="users"] { color:#79e6b3; background:rgba(16,185,129,.15); }
.nav-icon[data-icon="sessions"] { color:#c4a7ff; background:rgba(139,92,246,.16); }
.nav-icon[data-icon="ads"] { color:#ffbd71; background:rgba(245,158,11,.16); }
.nav-icon[data-icon="portal"] { color:#63e6dc; background:rgba(20,184,166,.16); }
.nav-icon[data-icon="diagnostic"] { color:#7dd3fc; background:rgba(14,165,233,.16); }
.nav-icon[data-icon="payments"] { color:#8be5a5; background:rgba(34,197,94,.16); }
.nav-icon[data-icon="integration"] { color:#ff91b8; background:rgba(236,72,153,.15); }
.nav-icon[data-icon="settings"] { color:#a9bfff; background:rgba(99,102,241,.17); }
.sidebar a.active .nav-icon { color:inherit; background:rgba(255,255,255,.18); box-shadow:inset 0 0 0 1px rgba(255,255,255,.1); }

.diagnostic-grid,
.payment-monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.diagnostic-card,
.payment-monitor-card {
  display: grid;
  gap: 7px;
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel) 88%, #f8fbff);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65), 0 12px 28px rgba(15,23,42,.05);
}

.diagnostic-card span,
.payment-monitor-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.diagnostic-card strong,
.payment-monitor-card strong {
  color: var(--ink);
  font-size: 22px;
  line-height: 1.1;
}

.diagnostic-card small,
.payment-monitor-card small,
.diagnostic-log-list small {
  color: var(--muted);
  font-weight: 750;
  line-height: 1.35;
}

.diagnostic-card.ok,
.payment-monitor-card.ok {
  border-color: color-mix(in srgb, #10b981 42%, var(--line));
  background: linear-gradient(135deg, rgba(16,185,129,.08), rgba(255,255,255,.72));
}

.diagnostic-card.warn,
.payment-monitor-card.warn {
  border-color: color-mix(in srgb, #f59e0b 46%, var(--line));
  background: linear-gradient(135deg, rgba(245,158,11,.11), rgba(255,255,255,.72));
}

.payment-monitor-card.error {
  border-color: color-mix(in srgb, #ef4444 52%, var(--line));
  background: linear-gradient(135deg, rgba(239,68,68,.1), rgba(255,255,255,.72));
}

.payment-monitor-card.active {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--primary) 46%, transparent), 0 14px 34px rgba(14,165,233,.12);
}

.diagnostic-layout {
  display: grid;
  gap: 28px;
  margin: 18px 0;
}

.payment-monitor-inline {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.diagnostic-log-list {
  display: grid;
  gap: 10px;
}

.diagnostic-log-list article {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 88%, #eef7ff);
}

.diagnostic-log-list strong {
  color: var(--ink);
  font-size: 14px;
}

.muted-empty {
  margin: 0;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.panel button,
.form-actions button,
.inline-actions button,
.access-actions button,
.pagination-actions button {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  border-radius:12px;
  border:1px solid transparent;
  background:linear-gradient(135deg,var(--accent),#2374d8);
  box-shadow:0 8px 18px rgba(22,137,232,.16);
}
.panel button:hover,
.form-actions button:hover,
.inline-actions button:hover,
.access-actions button:hover {
  box-shadow:0 11px 24px rgba(22,137,232,.23);
  transform:translateY(-2px);
}
.panel button:active,
.form-actions button:active,
.inline-actions button:active,
.access-actions button:active { transform:translateY(0) scale(.98); }
.panel button.ghost,
.form-actions button.ghost,
.inline-actions button.ghost,
.access-actions button.ghost {
  color:var(--ink);
  border-color:var(--line);
  background:linear-gradient(180deg,var(--panel),var(--panel-soft));
  box-shadow:0 5px 14px rgba(31,55,90,.06);
}
.panel button.ghost:hover,
.form-actions button.ghost:hover,
.inline-actions button.ghost:hover,
.access-actions button.ghost:hover {
  color:var(--accent-dark);
  border-color:color-mix(in srgb,var(--accent) 40%,var(--line));
  background:color-mix(in srgb,var(--accent) 6%,var(--panel));
}
.panel button.danger,
.panel button.outline-danger,
.inline-actions button.outline-danger {
  color:#c32922;
  border-color:#ffc5c0;
  background:linear-gradient(180deg,#fff8f7,#fff0ee);
  box-shadow:0 5px 14px rgba(220,38,38,.07);
}
.panel button.danger:hover,
.panel button.outline-danger:hover,
.inline-actions button.outline-danger:hover { color:#fff; border-color:#dc2626; background:linear-gradient(135deg,#ef4444,#c81e1e); }

#importCustomersBtn::before,
#importUsersBtn::before { content:"↥"; font-size:17px; line-height:1; }
#exportUsersBtn::before { content:"↧"; font-size:17px; line-height:1; }
#backupBtn::before { content:"◫"; font-size:16px; line-height:1; }
#restoreUsersBtn::before { content:"↻"; font-size:18px; line-height:1; }
#syncUsersBtn::before,
#inlineOnlineBtn::before,
#sessionsRefreshBtn::before { content:"⟳"; font-size:18px; line-height:1; }
#clearCpfBtn::before,
#clearIspBtn::before,
#clearLeadsBtn::before { content:"×"; width:17px; height:17px; display:grid; place-items:center; border:1.5px solid currentColor; border-radius:5px; font-size:14px; line-height:1; }
#customerForm button[type="submit"]::before { content:"+"; width:19px; height:19px; display:grid; place-items:center; border-radius:6px; color:var(--accent); background:#fff; font-size:17px; line-height:1; }

:root[data-theme="dark"] .panel button.ghost,
:root[data-theme="dark"] .form-actions button.ghost,
:root[data-theme="dark"] .inline-actions button.ghost,
:root[data-theme="dark"] .access-actions button.ghost { color:var(--ink); border-color:var(--line); background:linear-gradient(180deg,#17263d,#111d31); }

.panel .portal-preview-tabs button:not(.active),
.panel .portal-preview-tabs button:not(.active):hover,
.panel .portal-preview-tabs button:not(.active):focus {
  color: var(--muted);
  border-color: var(--line);
  background: transparent !important;
  box-shadow: none;
  transform: none;
}

@media (max-width: 380px) {
  .content {
    padding: 10px;
  }

  .topbar {
    margin: -10px -10px 12px;
    padding: 16px 10px 18px;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

  .table-wrap td {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* Visual refresh 2026 */
:root {
  --bg: #f4f7fc;
  --bg-top: #f9fbff;
  --bg-bottom: #eef3fb;
  --ink: #14213d;
  --muted: #718096;
  --line: #e3e9f2;
  --panel-soft: #f7f9fc;
  --accent: #1689e8;
  --accent-dark: #086bc1;
  --shadow: 0 22px 55px rgba(31, 55, 90, .11);
  --shadow-soft: 0 8px 28px rgba(31, 55, 90, .07);
}

body {
  background:
    radial-gradient(circle at 88% -5%, rgba(22, 137, 232, .14), transparent 28vw),
    radial-gradient(circle at 42% 105%, rgba(20, 184, 166, .08), transparent 32vw),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.app-shell { grid-template-columns: 248px minmax(0, 1fr); }

.sidebar {
  border: 0;
  color: #e9f4ff;
  background:
    radial-gradient(circle at 15% 0%, rgba(56, 189, 248, .22), transparent 28%),
    linear-gradient(180deg, #0b2342 0%, #07182f 58%, #061327 100%);
  padding: 24px 18px;
  box-shadow: 12px 0 40px rgba(9, 30, 60, .12);
}

.sidebar-head { align-items: center; padding: 0 8px; }
.sidebar .eyebrow { color: #71cdf9; letter-spacing: .12em; }
.sidebar h2 { color: #fff; font-size: 19px; }
.sidebar-logo { width: 52px; height: 52px; border-radius: 15px; background: #fff; padding: 4px; }
.sidebar nav { gap: 5px; margin-top: 32px; }
.sidebar a {
  position: relative;
  min-height: 48px;
  border-radius: 13px;
  color: #b8cae0;
  padding: 11px 13px;
  transition: color .18s ease, background .18s ease, transform .18s ease;
}
.sidebar a:hover { color: #fff; background: rgba(255,255,255,.08); transform: translateX(2px); }
.sidebar a.active { color: #fff; background: linear-gradient(135deg, rgba(22,137,232,.9), rgba(39,112,218,.82)); box-shadow: 0 10px 24px rgba(0,111,218,.28); }
.sidebar a.active::after { position:absolute; right:-18px; width:4px; height:24px; border-radius:8px 0 0 8px; background:#65d4ff; content:""; }
.nav-icon { color: #8ddcff; background: rgba(82,194,244,.12); }
.sidebar a.active .nav-icon { color: #fff; background: rgba(255,255,255,.17); }
.sidebar > .ghost { color:#dbeafe; border-color:rgba(255,255,255,.12); background:rgba(255,255,255,.06); }

.content { padding: 30px clamp(20px, 3vw, 44px); }
.topbar { margin-bottom: 26px; }
.topbar h1 { font-size: clamp(27px, 2.5vw, 38px); letter-spacing: -.035em; }
.topbar p { font-size: 13px; }

button, .button-link { border-radius: 11px; }
input, select, textarea { border-radius: 11px; min-height: 44px; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }

.metrics { gap: 16px; margin-bottom: 20px; }
.metrics article, .panel { border-color: rgba(221,229,240,.9); border-radius: 18px; }
.metrics article { min-height: 136px; align-content: space-between; gap: 16px; padding: 21px 22px; }
.metrics article::before { content:""; position:absolute; top:18px; right:18px; width:38px; height:38px; border-radius:12px; background:linear-gradient(135deg,rgba(22,137,232,.16),rgba(99,102,241,.08)); }
.metrics article:nth-child(2)::before { background:linear-gradient(135deg,rgba(99,102,241,.18),rgba(168,85,247,.08)); }
.metrics article:nth-child(3)::before { background:linear-gradient(135deg,rgba(16,185,129,.18),rgba(20,184,166,.08)); }
.metrics article:nth-child(4)::before { background:linear-gradient(135deg,rgba(245,158,11,.18),rgba(239,68,68,.08)); }
.metrics article:nth-child(5)::before { background:linear-gradient(135deg,rgba(14,165,233,.18),rgba(20,184,166,.08)); }
.metrics article:nth-child(6)::before { background:linear-gradient(135deg,rgba(236,72,153,.18),rgba(168,85,247,.08)); }
.metrics article:nth-child(7)::before { background:linear-gradient(135deg,rgba(245,158,11,.2),rgba(249,115,22,.08)); }
.metrics article:nth-child(8)::before { background:linear-gradient(135deg,rgba(20,184,166,.2),rgba(14,165,233,.08)); }
.metrics article:has(#metricIsp)::before { background:linear-gradient(135deg,rgba(245,158,11,.2),rgba(249,115,22,.08)); }
.metrics article::after { inset:auto 22px 0; height:3px; opacity:.7; }
.metrics span { max-width:calc(100% - 46px); font-size:12px; letter-spacing:.025em; text-transform:uppercase; }
.metrics strong { font-size:clamp(31px,3vw,42px); letter-spacing:-.045em; }

.panel { padding: 22px; }
.panel-head { margin-bottom: 20px; }
.panel h2 { font-size: 19px; letter-spacing: -.02em; }
.dashboard-visual-grid { gap: 18px; margin-bottom: 20px; }
.dashboard-chart-panel { min-height: 310px; overflow: hidden; }

.mini-bar-chart { min-height: 220px; }
.movement-chart-wrap { display:grid; gap:12px; min-width:0; }
.movement-chart { display:block; width:100%; height:auto; min-height:190px; overflow:visible; }
.chart-grid line { stroke:var(--line); stroke-width:1; stroke-dasharray:5 7; }
.chart-area { fill:url(#movementArea); }
.chart-line { fill:none; stroke:url(#movementLine); stroke-width:5; stroke-linecap:round; stroke-linejoin:round; filter:drop-shadow(0 5px 5px rgba(22,137,232,.17)); }
.chart-point-halo { fill:var(--panel); stroke:var(--line); stroke-width:1; }
.chart-point-dot { fill:var(--point-color); stroke:var(--panel); stroke-width:3; }
.chart-value { fill:var(--ink); font-size:13px; font-weight:850; }
.movement-legend { display:grid; grid-template-columns:repeat(auto-fit,minmax(105px,1fr)); gap:8px; }
.movement-legend-item { display:grid; grid-template-columns:8px 1fr auto; align-items:center; gap:7px; border:1px solid var(--line); border-radius:11px; padding:9px 10px; background:var(--panel-soft); font-size:11px; }
.movement-legend-item i { width:8px; height:8px; border-radius:50%; background:var(--legend-color); box-shadow:0 0 0 4px color-mix(in srgb,var(--legend-color) 15%,transparent); }
.movement-legend-item span { color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.movement-legend-item strong { color:var(--ink); font-size:13px; }
.individual-chart-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(125px,1fr)); gap:12px; align-items:stretch; }
.individual-chart { display:grid; justify-items:center; gap:10px; min-width:0; border:1px solid var(--line); border-radius:15px; padding:15px 12px; background:var(--panel-soft); }
.individual-chart-ring { display:grid; width:72px; height:72px; place-items:center; border-radius:50%; background:conic-gradient(var(--chart-color) var(--chart-progress),color-mix(in srgb,var(--line) 65%,transparent) 0); position:relative; }
.individual-chart-ring::after { position:absolute; inset:7px; border-radius:50%; background:var(--panel); content:""; }
.individual-chart-ring strong { position:relative; z-index:1; color:var(--ink); font-size:20px; }
.individual-chart > span { color:var(--muted); font-size:11px; font-weight:850; letter-spacing:.035em; text-align:center; text-transform:uppercase; }
.individual-chart-track { width:100%; height:4px; overflow:hidden; border-radius:99px; background:var(--line); }
.individual-chart-track i { display:block; width:var(--chart-progress); height:100%; border-radius:inherit; background:var(--chart-color); }
.summary-line-chart { width:100%; min-width:0; }
.summary-line-chart svg { display:block; width:100%; height:auto; min-height:230px; overflow:visible; }
.summary-chart-grid line { stroke:var(--line); stroke-width:1; stroke-dasharray:6 7; }
.summary-chart-area { pointer-events:none; }
.summary-chart-line { fill:none; stroke:#38bdf8; stroke-width:5; stroke-linecap:round; stroke-linejoin:round; filter:drop-shadow(0 5px 6px rgba(14,165,233,.2)); }
.summary-chart-point circle { stroke:var(--panel); stroke-width:4; }
.summary-chart-point text { fill:var(--ink); font-size:15px; font-weight:900; }
.summary-chart-point .summary-chart-label { fill:var(--muted); font-size:12px; font-weight:800; text-transform:uppercase; }

.health-card-grid { gap:12px; }
.health-card-grid article { min-height:52px; border-radius:13px; padding:13px 15px; }
.health-card-grid article strong { display:inline-flex; align-items:center; gap:7px; }
.health-card-grid article strong::before { content:""; width:7px; height:7px; border-radius:50%; background:currentColor; box-shadow:0 0 0 4px color-mix(in srgb,currentColor 13%,transparent); }

.table-wrap { border:1px solid var(--line); border-radius:15px; overflow:hidden; background:var(--panel); }
table { border-collapse:separate; border-spacing:0; }
th { background:var(--panel-soft); color:var(--muted); font-size:11px; letter-spacing:.05em; text-transform:uppercase; }
tbody tr { transition:background .15s ease; }
tbody tr:hover { background:color-mix(in srgb,var(--accent) 4%,var(--panel)); }
.modal > section, .script-modal, .credential-modal { border-radius:20px; box-shadow:0 28px 90px rgba(15,31,55,.24); }
.toast { border-radius:14px; backdrop-filter:blur(14px); }

:root[data-theme="dark"] .sidebar { background:linear-gradient(180deg,#06162b,#030b17); }
:root[data-theme="dark"] .metrics article,
:root[data-theme="dark"] .panel { border-color:rgba(87,111,144,.3); }
:root[data-theme="dark"] .table-wrap { border-color:var(--line); background:var(--panel); }

@media (max-width: 920px) {
  .app-shell { display:block; }
  .content { padding:20px; }
  .sidebar { border-radius:0 22px 22px 0; }
  .sidebar a.active::after { display:none; }
}

@media (max-width: 760px) {
  .content { padding:14px; }
  .topbar { border-radius:0 0 18px 18px; }
  .metrics { gap:10px; }
  .metrics article { min-height:122px; border-radius:15px; padding:17px; }
  .metrics article::before { top:14px; right:14px; width:32px; height:32px; }
  .panel { border-radius:16px; }
  .dashboard-chart-panel { min-height:0; }
  .movement-chart { min-height:150px; }
  .movement-legend { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .individual-chart-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .summary-line-chart svg { min-height:190px; }
}

/* Dark-mode contrast and destructive actions */
:root[data-theme="dark"] .copy-line {
  border-color: #3a5272;
  background: #0c1728;
}

:root[data-theme="dark"] .copy-line span { color: #9fb0c8; }
:root[data-theme="dark"] .copy-line code { color: #dbeafe; }

button.danger,
button.outline-danger,
button[data-delete],
button[data-delete-customer],
button[data-delete-operator],
button[data-delete-radius-client],
button[data-delete-voucher],
button[data-delete-voucher-plan],
button[data-kick-operator],
#clearCpfBtn,
#clearIspBtn,
#clearLeadsBtn,
#resetAdStatsBtn {
  color: #ffffff !important;
  border-color: #ef4444 !important;
  background: linear-gradient(135deg, #ef4444, #c81e1e) !important;
  box-shadow: 0 8px 20px rgba(220, 38, 38, .22) !important;
}

button.danger:hover,
button.outline-danger:hover,
button[data-delete]:hover,
button[data-delete-customer]:hover,
button[data-delete-operator]:hover,
button[data-delete-radius-client]:hover,
button[data-delete-voucher]:hover,
button[data-delete-voucher-plan]:hover,
button[data-kick-operator]:hover,
#clearCpfBtn:hover,
#clearIspBtn:hover,
#clearLeadsBtn:hover,
#resetAdStatsBtn:hover {
  border-color: #f87171 !important;
  background: linear-gradient(135deg, #f05252, #b91c1c) !important;
  box-shadow: 0 11px 26px rgba(220, 38, 38, .32) !important;
}

/* Modern login and captive-portal editor */
.login-shell {
  place-items: stretch;
  padding: 0;
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 255, 255, .42), transparent 20vw),
    linear-gradient(115deg, #17253a 0 62%, #e9f2ff 62% 100%);
}

.login-stage {
  display: grid;
  grid-template-columns: 1fr minmax(360px, 38vw);
  min-height: 100vh;
}

.login-panel {
  order: 2;
  align-self: center;
  justify-self: center;
  width: min(430px, calc(100% - 48px));
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 22px;
  padding: 28px 28px 0;
  overflow: hidden;
  background: rgba(255,255,255,.96);
  box-shadow: 0 28px 90px rgba(4, 12, 24, .34);
}

.login-brand-mark {
  display: grid;
  gap: 18px;
  justify-items: center;
  text-align: center;
}

.login-brand-mark .login-logo {
  width: 104px;
  height: 104px;
  margin: 0;
  border-radius: 22px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .14);
}

.login-panel h1 {
  margin: 0;
  font-size: clamp(34px, 4vw, 48px);
  letter-spacing: -0.045em;
}

.login-panel .form-stack input {
  min-height: 54px;
  border-radius: 14px;
  background: #f8fbff;
}

.login-panel button[type="submit"] {
  min-height: 58px;
  border-radius: 16px;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  box-shadow: 0 16px 34px rgba(37, 99, 235, .28);
}

.login-panel button[type="submit"]:hover {
  background: linear-gradient(135deg, #0284c7, #1d4ed8);
}

.login-art {
  order: 1;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 20%, var(--login-spot-one, rgba(255, 199, 116, .96)), transparent 18vw),
    radial-gradient(circle at 55% 40%, var(--login-spot-two, rgba(236, 72, 153, .76)), transparent 28vw),
    radial-gradient(circle at 42% 76%, var(--login-spot-three, rgba(6, 182, 212, .96)), transparent 30vw),
    linear-gradient(135deg, var(--login-bg-one, #2563eb), var(--login-bg-two, #581c87));
}

.login-art::before,
.login-art::after {
  content: "";
  position: absolute;
  inset: auto -8% -12% 0;
  height: 58%;
  border-radius: 58% 42% 0 0;
  background: var(--login-shape-one, rgba(34, 211, 238, .82));
  filter: blur(.2px);
  transform: rotate(-7deg);
}

.login-art::after {
  inset: 8% -10% auto 18%;
  height: 48%;
  background: var(--login-shape-two, rgba(168, 85, 247, .78));
  transform: rotate(10deg);
}

.login-art-card {
  position: relative;
  z-index: 1;
  width: min(520px, 66%);
  margin: 12vh auto 0;
  border: 1px solid rgba(255,255,255,.32);
  border-radius: 28px;
  padding: 28px;
  color: #fff;
  background: rgba(15, 23, 42, .22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.24), 0 30px 80px rgba(15,23,42,.24);
  backdrop-filter: blur(18px);
}

.login-art-card span {
  display: block;
  margin-bottom: 12px;
  color: var(--login-kicker, #a7f3d0);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.login-art-card strong {
  display: block;
  max-width: 420px;
  font-size: clamp(34px, 4.6vw, 68px);
  line-height: .95;
  letter-spacing: -.06em;
}

.login-art-card p {
  max-width: 360px;
  color: rgba(255,255,255,.84);
  font-weight: 700;
}

.portal-captive-layout {
  grid-template-columns: minmax(360px, 440px) minmax(520px, 1fr);
  align-items: start;
  gap: 22px;
}

.portal-editor-panel {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.portal-editor-panel::-webkit-scrollbar {
  width: 8px;
}

.portal-editor-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 28%, transparent);
}

.portal-editor-panel::-webkit-scrollbar-track {
  background: transparent;
}

.portal-editor-panel .panel-head {
  margin-bottom: 14px;
}

.portal-editor-form {
  display: grid;
  gap: 14px;
}

.portal-config-menu {
  display: grid;
  gap: 10px;
}

.portal-config-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  min-height: 74px;
  justify-items: start;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 18px;
  color: #12213a !important;
  background: linear-gradient(180deg, #ffffff, #f8fbff) !important;
  box-shadow: var(--shadow-soft);
  text-align: left;
}

.portal-config-card::after {
  content: "›";
  grid-row: 1 / span 2;
  grid-column: 2;
  color: #52627a;
  font-size: 34px;
  line-height: 1;
  transition: transform .18s ease, color .18s ease;
}

.portal-config-card strong {
  color: #12213a;
  font-size: 18px;
}

.portal-config-card span {
  color: #52627a;
  font-size: 13px;
  font-weight: 750;
}

.portal-config-card:hover {
  color: #0f2748 !important;
  border-color: rgba(37, 99, 235, .28);
  background: linear-gradient(180deg, #f8fbff, #edf6ff) !important;
  transform: translateY(-1px);
}

.portal-config-card.active {
  color: #fff !important;
  border-color: color-mix(in srgb, var(--accent) 52%, transparent);
  background: linear-gradient(135deg, #0284c7, #2563eb) !important;
  transform: translateY(-1px);
}

.portal-config-card:hover strong,
.portal-config-card:hover span {
  color: #0f2748;
}

.portal-config-card.active strong,
.portal-config-card.active span,
.portal-config-card.active::after {
  color: #ffffff;
}

.portal-config-card.active::after {
  transform: rotate(90deg);
}

.portal-config-section {
  display: none;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: color-mix(in srgb, var(--panel-soft) 76%, var(--panel));
}

.portal-config-menu .portal-config-section {
  margin: -2px 0 8px;
}

.portal-config-section.active {
  display: grid;
  gap: 14px;
  animation: portalSectionIn .18s ease;
}

@keyframes portalSectionIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.portal-section-title h3 {
  margin: 0;
  font-size: 20px;
}

.portal-section-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.portal-config-section .compact-grid {
  grid-template-columns: 1fr;
  gap: 12px;
}

.portal-apply-grid {
  display: grid;
  gap: 10px;
}

.portal-preview-panel {
  position: sticky;
  top: 24px;
  height: calc(100vh - 48px);
  min-height: 0;
  overflow: hidden;
}

.portal-preview-panel .panel-head {
  align-items: flex-start;
  margin-bottom: 14px;
}

.portal-preview-save {
  min-width: 156px;
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  padding: 12px 24px;
  color: #fff;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  box-shadow: 0 14px 34px rgba(37, 99, 235, .24);
  font-size: 15px;
  font-weight: 900;
}

.portal-preview-save:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.portal-preview-save:active {
  transform: translateY(1px) scale(.99);
}

.portal-preview-panel .portal-preview-shell {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  height: calc(100vh - 150px);
  min-height: 0;
  overflow: hidden;
  border-radius: 20px;
  padding: 64px 28px 28px;
  background:
    linear-gradient(#edf3fb, #edf3fb) top 0 left 0 / 100% 46px no-repeat,
    radial-gradient(circle at top right, color-mix(in srgb, var(--preview-accent) 24%, transparent), transparent 34vw),
    linear-gradient(135deg, color-mix(in srgb, var(--preview-primary) 88%, #111827), #123a66);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65), 0 22px 70px rgba(15,23,42,.12);
}

.portal-preview-shell::before {
  content: "";
  position: absolute;
  top: 18px;
  left: 24px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fb7185;
  box-shadow: 20px 0 #f59e0b, 40px 0 #22c55e;
}

.portal-preview-shell::after {
  content: "portalconnect.local";
  position: absolute;
  top: 12px;
  left: 90px;
  right: 24px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid #d9e0ea;
  border-radius: 8px;
  color: #667085;
  background: #f8fafc;
  font-size: 11px;
  font-weight: 800;
}

.portal-preview-card {
  flex: 0 0 auto;
  max-height: none;
  transform: scale(var(--portal-preview-scale, 1));
  transform-origin: top center;
  transition: transform .18s ease;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.86),
    0 28px 76px rgba(2,8,23,.22),
    0 10px 22px rgba(2,8,23,.12);
}

:root[data-theme="dark"] .portal-config-card,
:root[data-theme="dark"] .portal-config-section {
  background: rgba(17, 29, 49, .82) !important;
}

:root[data-theme="dark"] .portal-config-card strong {
  color: #f8fbff;
}

:root[data-theme="dark"] .portal-config-card span,
:root[data-theme="dark"] .portal-config-card::after {
  color: #b7c7dd;
}

:root[data-theme="dark"] .portal-config-card:hover {
  background: rgba(31, 48, 76, .92) !important;
}

:root[data-theme="dark"] .portal-config-card:hover strong,
:root[data-theme="dark"] .portal-config-card:hover span {
  color: #ffffff;
}

:root[data-theme="dark"] .portal-config-card.active {
  background: linear-gradient(135deg, #0284c7, #2563eb) !important;
}

:root[data-theme="dark"] .portal-config-card.active strong,
:root[data-theme="dark"] .portal-config-card.active span,
:root[data-theme="dark"] .portal-config-card.active::after {
  color: #ffffff;
}

@media (max-width: 1180px) {
  .portal-captive-layout {
    grid-template-columns: 1fr;
  }

  .portal-editor-panel,
  .portal-preview-panel {
    position: static;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .portal-preview-panel .portal-preview-shell {
    height: auto;
    min-height: calc(100vh - 150px);
    overflow: hidden;
  }
}

@media (max-width: 900px) {
  .login-stage {
    grid-template-columns: 1fr;
    background:
      radial-gradient(circle at 72% 18%, rgba(14,165,233,.26), transparent 42vw),
      linear-gradient(180deg, #17253a 0 34%, #edf5ff 34% 100%);
  }

  .login-panel {
    margin: 42px auto;
  }

  .login-art {
    display: none;
  }
}
