:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eaf2ff;
  --navy: #0b1f3a;
  --navy-light: #142c4c;
  --ink: #172033;
  --muted: #667085;
  --subtle: #98a2b3;
  --bg: #f6f8fc;
  --surface: #ffffff;
  --border: #e4e9f2;
  --success: #16875a;
  --success-soft: #e8f7f0;
  --warning: #a86708;
  --warning-soft: #fff6df;
  --danger: #c53030;
  --danger-soft: #fff0f0;
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-md: 0 14px 34px rgba(20, 36, 64, .08);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: var(--font); line-height: 1.5; }
body.sidebar-open { overflow: hidden; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-layout { min-height: 100vh; display: grid; grid-template-columns: 264px minmax(0, 1fr); }
.app-frame { min-width: 0; }
.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 26px 18px 20px;
  color: #dce7f7;
  background: linear-gradient(180deg, var(--navy), #08182d 100%);
  border-right: 1px solid rgba(255, 255, 255, .05);
}
.sidebar-brand { padding: 0 12px 24px; border-bottom: 1px solid rgba(255, 255, 255, .09); }
.brand { color: var(--ink); font-size: 23px; font-weight: 850; letter-spacing: -.8px; }
.brand span { color: #4f8cff; }
.sidebar .brand { color: #fff; }
.brand.large { display: inline-block; margin-bottom: 24px; font-size: 31px; }
.product-label { display: block; margin-top: 3px; color: #8fa5c2; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 16px 0; scrollbar-width: thin; }
.nav-section { display: block; margin: 18px 12px 7px; color: #7188a6; font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.nav-section:first-child { margin-top: 4px; }
.nav-link { display: flex; align-items: center; gap: 11px; min-height: 43px; margin: 3px 0; padding: 9px 11px; color: #b9c8dc; border: 1px solid transparent; border-radius: 11px; font-size: 14px; font-weight: 650; transition: background .16s ease, color .16s ease, border-color .16s ease; }
.nav-link:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.nav-link.active { color: #fff; background: rgba(63, 125, 255, .18); border-color: rgba(91, 145, 255, .22); }
.nav-symbol { display: grid; place-items: center; width: 27px; height: 27px; color: #8ca9cd; border: 1px solid rgba(255, 255, 255, .12); border-radius: 8px; font-size: 9px; font-weight: 850; letter-spacing: .03em; }
.nav-link.active .nav-symbol { color: #fff; background: #2d6fee; border-color: #2d6fee; }
.sidebar-footer { padding: 17px 4px 0; border-top: 1px solid rgba(255, 255, 255, .09); }
.user-summary { display: flex; align-items: center; gap: 10px; padding: 0 5px 13px; min-width: 0; color: inherit; }
.user-summary:hover strong { color: #78a7ff; }
.user-summary > span:last-child { min-width: 0; }
.user-summary strong, .user-summary small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-summary strong { color: #fff; font-size: 13px; }
.user-summary small { color: #8197b5; font-size: 11px; text-transform: capitalize; }
.user-avatar, .mobile-avatar { display: grid; flex: 0 0 auto; place-items: center; width: 34px; height: 34px; color: #fff; background: linear-gradient(145deg, #3d7cff, #24a4dd); border-radius: 10px; font-size: 13px; font-weight: 800; }
.sidebar-logout { width: 100%; min-height: 36px; padding: 7px 10px; color: #9cb0ca; background: transparent; border: 1px solid rgba(255, 255, 255, .09); font-size: 12px; }
.sidebar-logout:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.mobile-header { display: none; }
.sidebar-overlay { display: none; }

.shell { width: min(1420px, calc(100% - 64px)); margin: 0 auto; padding: 38px 0 56px; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; width: min(460px, calc(100% - 32px)); padding: 32px 0; }
.auth-card { width: 100%; padding: 38px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(29px, 3vw, 40px); line-height: 1.12; letter-spacing: -1.2px; }
h2 { margin-bottom: 5px; font-size: 18px; letter-spacing: -.25px; }
h3 { font-size: 14px; }
.eyebrow, .panel-kicker { margin-bottom: 7px; color: var(--primary); font-size: 11px; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.page-description { margin-bottom: 0; color: var(--muted); font-size: 15px; }
.muted { color: var(--muted); }
.page-heading, .heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 27px; }
.heading h1 { margin-bottom: 0; }
.heading-actions, .export-actions { display: flex; flex-wrap: wrap; gap: 9px; }

.panel { padding: 23px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.panel-heading h2, .panel-heading p { margin-bottom: 0; }
.panel-kicker { margin-bottom: 3px !important; font-size: 9px; }
.text-link { font-size: 13px; font-weight: 750; }
.text-link:hover { text-decoration: underline; }
.stack { display: grid; gap: 17px; }
.grid { display: grid; grid-template-columns: minmax(270px, 340px) minmax(0, 1fr); gap: 22px; align-items: start; }

label { display: grid; gap: 7px; color: #344054; font-size: 13px; font-weight: 700; }
label small { color: var(--muted); font-weight: 450; }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 12px; color: var(--ink); background: #fff; border: 1px solid #cfd8e6; border-radius: var(--radius-sm); transition: border-color .15s ease, box-shadow .15s ease; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #98a2b3; }
input:hover, select:hover, textarea:hover { border-color: #aebbd0; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, .11); }
button, .button-primary, .button-secondary { min-height: 42px; padding: 10px 17px; border-radius: var(--radius-sm); font-weight: 750; cursor: pointer; transition: background .15s ease, border-color .15s ease, transform .15s ease; }
button, .button-primary { display: inline-grid; place-items: center; color: #fff; background: var(--primary); border: 1px solid var(--primary); }
button:hover, .button-primary:hover { color: #fff; background: var(--primary-hover); border-color: var(--primary-hover); }
button:active, .button-primary:active, .button-secondary:active { transform: translateY(1px); }
.button-secondary { display: inline-grid; place-items: center; color: #344054; background: #fff; border: 1px solid #d5dce8; }
.button-secondary:hover { color: var(--primary); background: var(--primary-soft); border-color: #aac5ff; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(37, 99, 235, .25); outline-offset: 2px; }
button.link { color: var(--muted); background: none; border: 0; }

fieldset { display: grid; gap: 10px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; }
legend { padding: 0 6px; color: #344054; font-size: 12px; font-weight: 800; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; }
.check input { flex: 0 0 auto; width: 17px; min-height: 17px; margin-top: 1px; }

.metrics, .metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 23px; }
.metrics article, .metric-card { min-width: 0; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.metrics span, .metrics small, .metric-card small { display: block; color: var(--muted); }
.metrics strong, .metric-card > strong { display: block; margin: 10px 0 4px; color: var(--ink); font-size: 34px; line-height: 1; letter-spacing: -1px; }
.metrics .plan { margin-top: 10px; font-size: 22px; }
.metric-card > strong em { color: var(--subtle); font-size: 18px; font-style: normal; font-weight: 650; letter-spacing: 0; }
.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-tag { padding: 3px 7px; color: #43618d; background: #f0f4fa; border-radius: 999px; font-size: 9px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.success-tag { color: var(--success); background: var(--success-soft); }
.featured-metric { position: relative; overflow: hidden; color: #fff; background: linear-gradient(140deg, #1c5ee8, #267edb); border-color: transparent; }
.featured-metric::after { content: ""; position: absolute; top: -58px; right: -48px; width: 150px; height: 150px; background: rgba(255, 255, 255, .1); border-radius: 50%; }
.featured-metric .metric-top, .featured-metric small { color: #dceaff; }
.featured-metric > strong { color: #fff; }
.live-dot { position: relative; z-index: 1; width: 8px; height: 8px; background: #65e4ad; border: 2px solid rgba(255, 255, 255, .4); border-radius: 50%; box-shadow: 0 0 0 4px rgba(101, 228, 173, .15); }

.status-banner { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; margin-bottom: 18px; padding: 13px 16px; border-radius: 13px; font-size: 13px; }
.status-banner strong, .status-banner small { display: block; }
.status-banner small { margin-top: 1px; opacity: .8; }
.status-banner a { font-weight: 800; }
.warning-banner { color: #774c08; background: var(--warning-soft); border: 1px solid #f4dfad; }
.warning-banner a { color: #774c08; }
.status-indicator { width: 9px; height: 9px; background: #d79020; border-radius: 50%; box-shadow: 0 0 0 4px rgba(215, 144, 32, .14); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr); gap: 22px; margin-bottom: 22px; }
.dashboard-panel { box-shadow: var(--shadow-sm); }
.gateway-status-list { display: grid; }
.gateway-status-item { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 13px 5px; color: var(--ink); border-top: 1px solid var(--border); }
.gateway-status-item:first-child { border-top: 0; }
.gateway-status-item:hover .gateway-main strong { color: var(--primary); }
.gateway-provider { display: grid; place-items: center; width: 38px; height: 38px; color: #225ab8; background: #e9f1ff; border-radius: 11px; font-size: 10px; font-weight: 850; }
.provider-unifi { color: #087aa8; background: #e5f7ff; }
.gateway-main { min-width: 0; }
.gateway-main strong, .gateway-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gateway-main strong { font-size: 14px; }
.gateway-main small { color: var(--muted); font-size: 11px; }
.gateway-state { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.status-dot { width: 8px; height: 8px; background: #e0a62e; border-radius: 50%; }
.status-dot.status-online { background: #22a06b; box-shadow: 0 0 0 4px rgba(34, 160, 107, .1); }
.status-dot.status-offline { background: #d14343; box-shadow: 0 0 0 4px rgba(209, 67, 67, .1); }
.license-item { margin-top: 17px; }
.license-item > div:first-child { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.license-item strong { color: var(--ink); }
.progress-track { height: 7px; overflow: hidden; background: #edf1f7; border-radius: 999px; }
.progress-track span { display: block; height: 100%; background: linear-gradient(90deg, #2563eb, #38bdf8); border-radius: inherit; }
.plan-summary { display: flex; align-items: center; justify-content: space-between; margin: 20px 0; padding: 12px 13px; color: var(--muted); background: #f7f9fc; border: 1px solid var(--border); border-radius: 11px; font-size: 12px; }
.plan-summary strong { color: var(--primary); font-size: 11px; letter-spacing: .05em; }
.setup-checklist { padding-top: 17px; border-top: 1px solid var(--border); }
.setup-checklist h3 { margin-bottom: 10px; }
.setup-step { display: flex; align-items: center; gap: 10px; margin-top: 7px; padding: 8px; color: var(--ink); border-radius: 10px; }
.setup-step:hover { background: #f7f9fc; }
.setup-step > span { display: grid; flex: 0 0 auto; place-items: center; width: 27px; height: 27px; color: #75839a; background: #edf1f7; border-radius: 8px; font-size: 10px; font-weight: 850; }
.setup-step.complete > span { color: var(--success); background: var(--success-soft); }
.setup-step strong, .setup-step small { display: block; }
.setup-step strong { font-size: 12px; }
.setup-step small { color: var(--muted); font-size: 10px; }
.recent-panel { margin-bottom: 24px; }

.account-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); gap: 22px; align-items: start; }
.account-summary { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; }
.account-summary span, .account-summary strong, .account-summary small { display: block; }
.account-summary span { color: var(--muted); font-size: 11px; font-weight: 700; }
.account-summary strong { margin: 2px 0; font-size: 17px; }
.account-summary small { color: var(--muted); }
.account-avatar { width: 46px; height: 46px; border-radius: 13px; font-size: 16px; }
.password-panel button { justify-self: start; }
.security-note p { font-size: 13px; }

.data-panel { padding-top: 20px; }
.data-panel-heading { margin-bottom: 15px; }
.filter-bar { display: grid; align-items: end; gap: 10px; margin-bottom: 17px; padding: 14px; background: #f7f9fc; border: 1px solid var(--border); border-radius: 12px; }
.filter-bar label { margin: 0; }
.filter-bar label > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.filter-bar button, .filter-bar .button-secondary { min-height: 46px; }
.single-filter { grid-template-columns: minmax(220px, 1fr) auto auto; }
.session-filter { grid-template-columns: 160px 160px minmax(240px, 1fr) auto; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 15px; padding-top: 15px; color: var(--muted); border-top: 1px solid var(--border); font-size: 12px; }
.pagination div { display: flex; gap: 8px; }
.presence-note { margin: 13px 0 25px; font-size: 11px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 13px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: #7a879b; font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.clean-table td:first-child, .clean-table th:first-child { padding-left: 2px; }
.clean-table td:last-child, .clean-table th:last-child { padding-right: 2px; }
.table-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.badge { display: inline-flex; align-items: center; padding: 4px 9px; color: var(--success); background: var(--success-soft); border-radius: 999px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.badge.status-offline { color: var(--danger); background: var(--danger-soft); }
.badge.status-unknown, .badge.status-planned { color: var(--warning); background: var(--warning-soft); }
.empty, .empty-state { text-align: center; color: var(--muted); padding: 32px; }
.empty-state strong { display: block; color: var(--ink); }
.empty-state p { margin: 4px 0 14px; font-size: 12px; }
.compact-empty { padding: 26px 12px; }

.alert, .notice { padding: 12px 14px; border-radius: 11px; margin-bottom: 16px; font-size: 13px; }
.alert { color: var(--danger); background: var(--danger-soft); border: 1px solid #f5cccc; }
.success-notice { color: var(--success); background: var(--success-soft); }
.warning-notice { color: var(--warning); background: var(--warning-soft); }
.portal-list { display: grid; gap: 10px; }
.portal-item { display: flex; justify-content: space-between; align-items: center; padding: 16px; color: var(--ink); border: 1px solid var(--border); border-radius: 11px; }
.portal-item:hover { border-color: #aac5ff; background: var(--primary-soft); }
.portal-item small { display: block; color: var(--muted); }
.portal-item b { color: var(--primary); }

.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 24px; align-items: start; }
.color-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.color-fields input[type=color] { padding: 5px; }
.field-builder { display: grid; gap: 10px; }
.field-row { display: grid; grid-template-columns: 85px 1fr 105px; gap: 10px; align-items: center; }
.preview-wrap { position: sticky; top: 22px; }
.phone-preview { position: relative; overflow: hidden; padding: 28px 18px; min-height: 650px; background: linear-gradient(145deg, var(--preview-primary), var(--preview-secondary)); border: 9px solid #263044; border-radius: 34px; box-shadow: 0 20px 50px rgba(52, 63, 90, .2); }
.preview-glow { position: absolute; top: -100px; right: -100px; width: 260px; height: 260px; background: rgba(255, 255, 255, .24); border-radius: 50%; }
.preview-card { position: relative; width: min(100%, 320px); margin: 35px auto 0; padding: 25px; background: rgba(255, 255, 255, .97); border-radius: 18px; box-shadow: 0 12px 30px rgba(0, 0, 0, .13); }
.preview-card h2 { margin-bottom: 5px; font-size: 22px; }
.preview-card > p { color: #667085; font-size: 13px; }
.preview-card label { margin-top: 10px; font-size: 12px; }
.fake-input { height: 34px; background: #fff; border: 1px solid #d6dce7; border-radius: 7px; }
.preview-mark { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 14px; color: #fff; background: var(--preview-primary); border-radius: 15px; font-weight: 800; }
.preview-logo { display: block; max-width: 150px; max-height: 72px; object-fit: contain; margin-bottom: 15px; }
.preview-consent { display: flex !important; align-items: flex-start; gap: 7px; }
.preview-consent small { color: #667085; font-size: 8px; line-height: 1.3; }
.preview-button { display: grid; place-items: center; height: 39px; margin-top: 15px; color: #fff; background: var(--preview-primary); border-radius: 8px; font-weight: 750; }
.terms-version { display: block; margin-top: 8px; color: #98a2b3; text-align: center; }
.font-rounded { font-family: "Arial Rounded MT Bold", ui-rounded, system-ui, sans-serif; }
.font-serif { font-family: Georgia, "Times New Roman", serif; }
.font-mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.preview-note { margin-top: 10px; text-align: center; font-size: 12px; }

@media (max-width: 1100px) {
  .metric-grid, .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .account-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .app-layout { display: block; }
  .sidebar { position: fixed; left: 0; width: min(288px, 86vw); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 20px 0 50px rgba(7, 20, 40, .25); }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-overlay { position: fixed; inset: 0; z-index: 20; display: block; visibility: hidden; opacity: 0; background: rgba(5, 18, 35, .48); border: 0; border-radius: 0; transition: opacity .2s ease, visibility .2s ease; }
  .sidebar-open .sidebar-overlay { visibility: visible; opacity: 1; }
  .mobile-header { position: sticky; top: 0; z-index: 15; display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; min-height: 64px; padding: 0 20px; background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--border); backdrop-filter: blur(12px); }
  .mobile-header .brand { justify-self: center; }
  .mobile-avatar { justify-self: end; width: 32px; height: 32px; }
  .menu-toggle { display: grid; align-content: center; gap: 4px; width: 38px; min-height: 38px; padding: 9px; background: #fff; border: 1px solid var(--border); }
  .menu-toggle:hover { background: var(--primary-soft); border-color: #aac5ff; }
  .menu-toggle span { display: block; width: 17px; height: 2px; background: var(--ink); border-radius: 2px; }
  .shell { width: min(100% - 36px, 760px); padding-top: 28px; }
  .grid, .editor-layout { grid-template-columns: 1fr; }
  .preview-wrap { position: static; }
  .phone-preview { width: min(390px, 100%); margin: auto; }
  .session-filter { grid-template-columns: 1fr 1fr; }
  .session-filter .search-filter { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .shell { width: min(100% - 28px, 560px); padding: 23px 0 40px; }
  .page-heading, .heading { align-items: flex-start; flex-direction: column; gap: 15px; }
  .heading-actions, .export-actions { width: 100%; }
  .heading-actions > *, .export-actions > * { flex: 1; }
  .metric-grid, .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card, .metrics article { padding: 16px; }
  .metric-card > strong, .metrics strong { font-size: 29px; }
  .status-banner { grid-template-columns: auto 1fr; }
  .status-banner a { grid-column: 2; }
  .gateway-status-item { grid-template-columns: 38px minmax(0, 1fr); }
  .gateway-state { grid-column: 2; }
  .panel { padding: 18px; }
  .field-row { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 23px; }
  .single-filter, .session-filter { grid-template-columns: 1fr; }
  .session-filter .search-filter { grid-column: auto; }
}

@media (max-width: 420px) {
  .metric-grid, .metrics { grid-template-columns: 1fr; }
  .heading-actions { display: grid; }
}
