/* Swift RADIUS - staff panel.
   -------------------------------------------------------------------------
   The same token set as the Swift CRM (isp_sales/static/css/app.css), so the
   two tools read as one product. `data-theme` on <html> switches the values;
   nothing below the token blocks hard-codes a colour. */

:root {
  /* Swift's logo: gold on navy. Gold fills carry navy text (--on-brand); gold
     as text on a light page is the deeper --brand-ink, so it stays readable. */
  --brand:            #D7B107;
  --brand-dark:       #B8960A;
  --brand-ink:        #8A6A00;
  --brand-soft:       #FBF3D0;
  --accent:           #EFE432;
  --on-brand:         #111825;
  --navy:             #111825;

  --bg:               #F4F6FA;
  --surface:          #FFFFFF;
  --surface-2:        #FAFBFD;
  --border:           #E3E8EF;
  --border-strong:    #CBD5E1;

  --text:             #1B2333;
  --text-muted:       #64748B;

  --sidebar-bg:       #111825;
  --sidebar-bg-2:     #0C121D;
  --sidebar-text:     #C9D1DD;
  --sidebar-text-dim: #7F8BA0;
  --sidebar-active:   #2A2611;

  --ok:               #16A34A;
  --ok-soft:          #DCFCE7;
  --warn:             #D97706;
  --warn-soft:        #FEF3C7;
  --danger:           #DC2626;
  --danger-soft:      #FEE2E2;
  --muted-soft:       #EEF2F6;

  --code-bg:          #111825;
  --code-text:        #D7E3F4;

  --radius:           12px;
  --radius-sm:        8px;
  --shadow-sm:        0 1px 2px rgba(16, 24, 40, .05);
  --shadow:           0 4px 16px rgba(16, 24, 40, .08);

  --sidebar-w:        236px;
}

html[data-theme="dark"] {
  --bg:            #0F141C;
  --surface:       #171E29;
  --surface-2:     #1D2531;
  --border:        #2A3441;
  --border-strong: #3A4657;
  --text:          #E5EAF2;
  --text-muted:    #93A1B5;
  --brand-soft:    #2E2810;
  --brand-ink:     #E6C83A;
  --sidebar-bg:    #0B1017;
  --sidebar-bg-2:  #080C12;
  --sidebar-active:#2E2810;
  --ok-soft:       #12301F;
  --warn-soft:     #33270D;
  --danger-soft:   #3A1717;
  --muted-soft:    #222B37;
  --code-bg:       #0A0F16;
  --shadow-sm:     0 1px 2px rgba(0, 0, 0, .4);
  --shadow:        0 4px 16px rgba(0, 0, 0, .45);
}

/* ---- Base ---------------------------------------------------------------- */

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: .925rem;
  min-height: 100vh;
}

a { color: var(--brand-ink); text-decoration: none; }
a:hover { color: var(--brand-ink); text-decoration: none; }
h1, h2, h3, h4, h5, h6 { color: var(--text); font-weight: 600; }
.text-muted, .form-text { color: var(--text-muted) !important; }
.mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85em; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---- Shell --------------------------------------------------------------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-text);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sidebar-brand:hover { color: #fff; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  object-fit: cover; background: var(--navy); display: block;
  box-shadow: 0 0 0 1px rgba(215, 177, 7, .35);
}
.brand-name { font-weight: 600; line-height: 1.1; }
.brand-sub { font-size: .72rem; color: var(--sidebar-text-dim); }

.nav-heading {
  padding: 18px 20px 6px;
  font-size: .68rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--sidebar-text-dim);
}
.side-link {
  display: flex; align-items: center; gap: 11px;
  margin: 1px 10px; padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-weight: 500;
}
.side-link i { font-size: 1.05rem; opacity: .85; width: 18px; text-align: center; }
.side-link:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.side-link.active { background: var(--sidebar-active); color: #fff; }
.side-link .count {
  margin-left: auto; font-size: .72rem; font-weight: 600;
  background: rgba(22, 163, 74, .2); color: #6EE7A0;
  padding: 1px 8px; border-radius: 999px;
}

.sidebar-foot {
  margin-top: auto; padding: 14px 18px;
  border-top: 1px solid rgba(255, 255, 255, .07);
  font-size: .8rem; color: var(--sidebar-text-dim);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-search { flex: 1; max-width: 460px; position: relative; }
.topbar-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.topbar-search input {
  padding-left: 36px; background: var(--surface-2);
  border-color: var(--border); border-radius: 999px;
}
.suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 1060;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); overflow: hidden; max-height: 70vh; overflow-y: auto;
}
.suggest a {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  color: var(--text); border-bottom: 1px solid var(--border); text-decoration: none;
}
.suggest a:last-child { border-bottom: 0; }
.suggest a:hover, .suggest a.active { background: var(--brand-soft); text-decoration: none; }
.suggest .s-main { flex: 1; min-width: 0; }
.suggest .s-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .s-sub { font-size: .78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .s-more { justify-content: center; font-size: .82rem; color: var(--brand-ink); }
.suggest .s-empty { padding: 12px 14px; color: var(--text-muted); font-size: .88rem; }
.btn-ghost {
  background: transparent; border: 1px solid transparent; color: var(--text-muted);
  border-radius: var(--radius-sm); padding: 6px 10px;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
#menuToggle { display: none; }

.content { padding: 24px 28px 48px; width: 100%; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 20px;
}
.page-head h1 { font-size: 1.45rem; margin: 0; }
.page-head .sub { color: var(--text-muted); margin-top: 3px; }
.crumbs { font-size: .8rem; color: var(--text-muted); margin-bottom: 4px; }
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--brand-ink); }

/* ---- Surfaces ------------------------------------------------------------ */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel + .panel { margin-top: 16px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: .98rem; margin: 0; }
.panel-head .hint { font-size: .8rem; color: var(--text-muted); }
.panel-body { padding: 16px 18px; }
.panel-empty { padding: 28px 18px; text-align: center; color: var(--text-muted); }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  height: 100%;
  display: block;
  color: inherit;
}
a.stat:hover { border-color: var(--border-strong); color: inherit; box-shadow: var(--shadow); }
.stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-foot { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.stat.is-live .stat-value { color: var(--ok); }
.stat.is-warn .stat-value { color: var(--warn); }
.stat.is-bad .stat-value { color: var(--danger); }

/* ---- Tables -------------------------------------------------------------- */

.table { --bs-table-bg: transparent; --bs-table-color: var(--text); margin: 0; color: var(--text); }
.table > :not(caption) > * > * { border-bottom-color: var(--border); padding: .62rem .9rem; }
.table thead th {
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); background: var(--surface-2); white-space: nowrap;
}
.table tbody tr:hover > * { background: var(--surface-2); }
.table tbody tr:last-child > * { border-bottom: 0; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { font-size: .78rem; color: var(--text-muted); }

/* ---- Badges & dots ------------------------------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 600; white-space: nowrap;
  background: var(--muted-soft); color: var(--text-muted);
}
.pill-active, .pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-expired, .pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-suspended, .pill-bad { background: var(--danger-soft); color: var(--danger); }
.pill-brand { background: var(--brand-soft); color: var(--brand-ink); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--border-strong); flex-shrink: 0; }
.dot-on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot-warn { background: var(--warn); }
.dot-off { background: var(--border-strong); }

.vendor {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; font-weight: 600; color: var(--text-muted);
}
.vendor::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
.vendor-mikrotik { color: #E5484D; }
.vendor-cisco { color: #049FD9; }
.vendor-juniper { color: #84B135; }
.vendor-huawei { color: #CF0A2C; }
.vendor-other { color: var(--text-muted); }

/* ---- Detail lists -------------------------------------------------------- */

.facts { display: grid; grid-template-columns: 150px 1fr; gap: 9px 16px; margin: 0; }
.facts dt { color: var(--text-muted); font-weight: 500; font-size: .84rem; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.hero {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 18px; border-bottom: 1px solid var(--border);
}
.avatar {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--brand-soft); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 1.15rem;
}
.hero h1 { font-size: 1.3rem; margin: 0; }

.meter { height: 6px; border-radius: 99px; background: var(--muted-soft); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

/* ---- Current session card ----------------------------------------------- */

.dot-warn { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 22%, transparent); }
.session-card .panel-head h2 { display: flex; align-items: center; gap: 8px; }
.session-card.state-online { border-top: 3px solid var(--ok); }
.session-card.state-unreported { border-top: 3px solid var(--warn); }
.session-card.state-offline, .session-card.state-never { border-top: 3px solid var(--border-strong); }
.session-row { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.session-note { padding: 12px 18px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: .88rem; }
.session-note.warn { color: var(--text); background: color-mix(in srgb, var(--warn) 12%, var(--surface)); }
[data-card-refresh].spinning i { display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { [data-card-refresh].spinning i { animation: none; } }

/* ---- Tabs inside a panel ---------------------------------------------- */

.tabs-bar {
  display: flex; gap: 4px; overflow-x: auto;
  padding: 0 12px; border-top: 1px solid var(--border);
  scrollbar-width: none;
}
.tabs-bar::-webkit-scrollbar { display: none; }
.tabs-bar a {
  padding: 11px 12px; white-space: nowrap;
  color: var(--text-muted); font-weight: 500; font-size: .88rem;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs-bar a:hover { color: var(--text); }
.tabs-bar a.active { color: var(--brand-ink); border-bottom-color: var(--brand); }

.geo-map { height: 240px; border-bottom: 1px solid var(--border); }
.geo-map.picker { height: 300px; border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* ---- Code & attributes --------------------------------------------------- */

.snippet { position: relative; }
.snippet pre {
  background: var(--code-bg); color: var(--code-text);
  border-radius: var(--radius-sm);
  padding: 14px 16px; margin: 0;
  font-size: .8rem; line-height: 1.55;
  white-space: pre-wrap; word-break: break-all;
}
.snippet .copy {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255, 255, 255, .08); color: var(--code-text);
  border: 1px solid rgba(255, 255, 255, .12); border-radius: 6px;
  font-size: .74rem; padding: 3px 9px;
}
.snippet .copy:hover { background: rgba(255, 255, 255, .16); }

.attr-op { color: var(--text-muted); }
.attr-value { font-weight: 600; }

/* ---- Forms --------------------------------------------------------------- */

.form-control, .form-select {
  background-color: var(--surface); color: var(--text); border-color: var(--border-strong);
  border-radius: var(--radius-sm);
}
.form-control:focus, .form-select:focus {
  background-color: var(--surface); color: var(--text);
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: 4px; }
.form-section { font-size: .72rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-muted); margin: 6px 0 12px; padding-top: 6px; }
.form-section:not(:first-child) { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 18px; }
.errorlist { list-style: none; padding: 0; margin: 4px 0 0; color: var(--danger); font-size: .8rem; }

.btn { border-radius: var(--radius-sm); font-weight: 500; }
.btn-primary {
  --bs-btn-color: var(--on-brand); --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-color: var(--on-brand); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark);
  --bs-btn-active-color: var(--on-brand); --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark);
  --bs-btn-disabled-color: var(--on-brand); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
  --bs-btn-focus-shadow-rgb: 215, 177, 7; font-weight: 600;
}
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.text-primary { color: var(--brand-ink) !important; }
.btn-light { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-light:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }

.action-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.action-bar > form { display: inline; margin: 0; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters .form-control, .filters .form-select { width: auto; min-width: 160px; }
.chip {
  padding: 5px 12px; border-radius: 999px; font-size: .8rem; font-weight: 500;
  border: 1px solid var(--border-strong); color: var(--text-muted); background: var(--surface);
}
.chip:hover { color: var(--text); border-color: var(--text-muted); }
.chip.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

.alert { border-radius: var(--radius-sm); }

/* ---- Login --------------------------------------------------------------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(11, 95, 255, .18), transparent 60%),
              radial-gradient(900px 500px at 110% 110%, rgba(0, 194, 255, .14), transparent 60%),
              var(--bg); }
.login-card { width: 100%; max-width: 380px; }

/* ---- Small screens ------------------------------------------------------- */

@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 1050; transform: translateX(-100%); transition: transform .2s ease; }
  .shell.menu-open .sidebar { transform: none; }
  .shell.menu-open::after { content: ""; position: fixed; inset: 0; background: rgba(8, 14, 24, .45); z-index: 1040; }
  #menuToggle { display: inline-block; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 10px 16px; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* ---- Global page loader (js/loader.js) ------------------------------------ */

.page-loader-bar {
  position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 2000;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  box-shadow: 0 0 8px color-mix(in srgb, var(--brand) 60%, transparent);
  opacity: 0; transition: opacity .15s ease;
}
.page-loader.bar .page-loader-bar { opacity: 1; animation: loader-crawl 8s cubic-bezier(.1, .7, .2, 1) forwards; }
@keyframes loader-crawl { from { width: 0; } 20% { width: 45%; } to { width: 92%; } }

.page-loader-veil {
  position: fixed; inset: 0; z-index: 1990; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s;
}
.page-loader-veil .spinner-border { color: var(--brand); width: 2.4rem; height: 2.4rem; }
.page-loader.veil .page-loader-veil { opacity: 1; visibility: visible; }

@media (prefers-reduced-motion: reduce) {
  .page-loader.bar .page-loader-bar { animation: none; width: 70%; }
}

/* ---- Pagination ----------------------------------------------------------- */

.pager {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; border-top: 1px solid var(--border); font-size: .82rem; color: var(--text-muted);
}
.pager-links { display: flex; gap: 4px; flex-wrap: wrap; }
.pager-links a, .pager-links span {
  min-width: 32px; height: 32px; padding: 0 8px; display: inline-grid; place-items: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border); color: var(--text);
  background: var(--surface); font-variant-numeric: tabular-nums; text-decoration: none;
}
.pager-links a:hover { border-color: var(--brand); color: var(--brand-ink); text-decoration: none; }
.pager-links .current { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; }
.pager-links .disabled { opacity: .4; }
.pager-links .gap { border-color: transparent; background: transparent; }

.side-link .count-bad { background: var(--danger); color: #fff; }
.dot-bad { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }

/* ---- Network: pool meters, customer map ----------------------------------- */

.meter-ok > span { background: var(--ok); }
.meter-warn > span { background: var(--warn); }
.meter-bad > span { background: var(--danger); }

.customer-map { height: calc(100vh - 260px); min-height: 420px; border-radius: 0 0 var(--radius) var(--radius); }
.chip-check {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px;
  border: 1px solid var(--border); font-size: .82rem; cursor: pointer; user-select: none; background: var(--surface);
}
.chip-check input { margin: 0; }
.olt-pin {
  display: grid; place-items: center; border-radius: 6px; color: #fff; font-size: 14px;
  background: var(--text-muted); border: 2px solid #fff; box-shadow: var(--shadow);
}
.olt-pin.olt-up { background: var(--ok); }
.olt-pin.olt-down { background: var(--danger); }

/* Optical power values (network.Onu thresholds) */
.power { font-weight: 600; font-variant-numeric: tabular-nums; }
.power-ok { color: var(--ok); }
.power-warn { color: var(--warn); }
.power-bad { color: var(--danger); }
.onu-badge { display: inline-flex; gap: 8px; align-items: center; padding: 2px 10px; border-radius: 99px;
             background: var(--surface-2); border: 1px solid var(--border); font-size: .8rem; }

.chip-warn { border-color: var(--warn); color: var(--text); }
.chip-warn.active { background: var(--warn); border-color: var(--warn); color: #fff; }
.dot-approx { background: transparent; border: 2px dashed var(--text-muted); }
.pill-held { background: color-mix(in srgb, var(--warn) 18%, var(--surface)); color: var(--text); }

.chart-box { position: relative; height: 240px; }
.sev { font-size: .75em; text-transform: uppercase; letter-spacing: .02em; color: var(--text-muted); }
.sev-0, .sev-1, .sev-2, .sev-3 { color: var(--danger); font-weight: 600; }
.sev-4 { color: var(--warn); font-weight: 600; }

/* -- subscriber overview: HMS-style cards with coloured headers ----------------- */
.xcard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm);
         overflow: hidden; display: flex; flex-direction: column; }
.xcard + .xcard { margin-top: 16px; }
.xcard-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; color: #fff; }
.xcard-head h2 { margin: 0; font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 8px; color: #fff; }
.xcard-head .btn-head { background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35); color: #fff;
                        font-size: .78rem; padding: 3px 10px; border-radius: 6px; }
.xcard-head .btn-head:hover { background: rgba(255,255,255,.3); color: #fff; }
.xcard-head.blue { background: linear-gradient(135deg, #0C121D, #1E2A40); border-bottom: 2px solid var(--brand); }
.xcard-head.purple { background: linear-gradient(135deg, #2A2611, #5C4B0E); }
.xcard-head.green { background: linear-gradient(135deg, #15803d, #22c55e); }
.xcard-head.slate { background: linear-gradient(135deg, #334155, #64748b); }
.xcard-body { padding: 4px 16px 12px; flex: 1; }
.kv { display: grid; grid-template-columns: minmax(118px, 42%) 1fr; align-items: center; gap: 8px;
      padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .86rem; }
.kv:last-child { border-bottom: 0; }
.kv > .k { color: var(--text-muted); display: flex; align-items: center; gap: 8px; font-weight: 500; }
.kv > .k i { width: 16px; text-align: center; color: var(--text); opacity: .75; }
.kv > .v { min-width: 0; word-break: break-word; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 0 6px; }
.chip-btn { border: 0; border-radius: 6px; padding: 4px 10px; font-size: .78rem; font-weight: 600; color: #fff; text-decoration: none;
            display: inline-flex; align-items: center; gap: 5px; }
.chip-btn:hover { filter: brightness(1.08); color: #fff; }
.chip-btn.c-green { background: #16a34a; } .chip-btn.c-blue { background: #2563eb; } .chip-btn.c-purple { background: #7c3aed; }
.chip-btn.c-amber { background: #d97706; } .chip-btn.c-slate { background: #64748b; } .chip-btn.c-teal { background: #0d9488; }
.ip-badge { background: #f59e0b; color: #fff; font-family: var(--bs-font-monospace, monospace); font-weight: 600; font-size: .82rem;
            padding: 3px 10px; border-radius: 6px; }
.ip-badge.green { background: #16a34a; }
a.ip-badge { color: #fff; text-decoration: none; } a.ip-badge:hover { filter: brightness(.9); color: #fff; }
a.ip-badge .bi { font-size: .7rem; opacity: .85; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; padding: 2px 7px;
            font-size: .8rem; line-height: 1.4; text-decoration: none; }
.icon-btn:hover { border-color: var(--brand); color: var(--brand-ink); }
.qa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; padding: 12px 0; }
.qa-grid form { margin: 0; display: contents; }
.qa { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 14px 8px; text-align: center;
      text-decoration: none; color: var(--text); font-size: .8rem; font-weight: 500; display: flex; flex-direction: column;
      align-items: center; gap: 8px; width: 100%; transition: transform .12s ease, box-shadow .12s ease; }
.qa i { font-size: 1.45rem; }
.qa:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); color: var(--text); border-color: var(--brand); }
.usage-bar { height: 8px; border-radius: 4px; background: var(--muted-soft, rgba(127,127,127,.15)); overflow: hidden; }
.usage-bar > span { display: block; height: 100%; border-radius: 4px; }


/* -- layouts: side (default), compact (icon rail), top (menu bar) -------------- */
.brand-text { display: block; }
@media (min-width: 992px) {
  body.layout-compact { --rail-w: 68px; }
  body.layout-compact .sidebar { width: var(--rail-w); position: fixed; left: 0; top: 0; z-index: 1035;
                                 transition: width .16s ease, box-shadow .16s ease; overflow-x: hidden; }
  body.layout-compact .main { margin-left: var(--rail-w); }
  body.layout-compact .sidebar:not(:hover) .side-label,
  body.layout-compact .sidebar:not(:hover) .brand-text,
  body.layout-compact .sidebar:not(:hover) .count,
  body.layout-compact .sidebar:not(:hover) .sidebar-foot { display: none; }
  body.layout-compact .sidebar:not(:hover) .nav-heading { font-size: 0; padding: 10px 0 4px; margin: 0 16px;
                                                          border-top: 1px solid rgba(255,255,255,.07); }
  body.layout-compact .sidebar:not(:hover) .side-link { justify-content: center; margin: 1px 8px; padding: 9px 0; }
  body.layout-compact .sidebar:not(:hover) .sidebar-brand { justify-content: center; padding: 18px 0 16px; }
  body.layout-compact .sidebar:hover { width: var(--sidebar-w); box-shadow: 0 0 40px rgba(8, 14, 24, .35); }

  body.layout-top .sidebar { display: none; }
}
.topnav { display: none; }
@media (min-width: 992px) {
  body.layout-top .topnav { display: flex; align-items: center; gap: 4px; padding: 8px 24px;
    background: linear-gradient(90deg, var(--sidebar-bg), var(--sidebar-bg-2)); position: sticky; top: 0; z-index: 30; }
  body.layout-top .topbar { top: 52px; }
}
.topnav-brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; margin-right: 18px; text-decoration: none; }
.topnav-brand:hover { color: #fff; }
.topnav-brand .brand-mark { width: 30px; height: 30px; }
.topnav-link { background: transparent; border: 0; color: var(--sidebar-text); font-weight: 500; padding: 7px 12px; border-radius: var(--radius-sm); }
.topnav-link:hover, .topnav-link.show { background: rgba(255,255,255,.07); color: #fff; }
.topnav-link.active { background: var(--sidebar-active); color: #fff; }
.topnav-alert { margin-left: auto; color: #fecaca; font-weight: 600; font-size: .85rem; text-decoration: none; }
.topnav .dropdown-item.active { background: var(--brand); color: var(--on-brand); }

.layout-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.layout-pick label { border: 2px solid var(--border); border-radius: 12px; padding: 10px; cursor: pointer; display: block; }
.layout-pick input { position: absolute; opacity: 0; pointer-events: none; }
.layout-pick input:checked + label { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.layout-pick input:focus-visible + label { outline: 2px solid var(--brand); outline-offset: 2px; }
.mini { height: 78px; border-radius: 8px; background: var(--surface-2); display: flex; overflow: hidden; margin-bottom: 8px;
        border: 1px solid var(--border); }
.mini .m-side { width: 30%; background: #13203a; }
.mini .m-rail { width: 12%; background: #13203a; }
.mini .m-col { flex: 1; display: flex; flex-direction: column; }
.mini .m-side { background: var(--navy); } .mini .m-rail { background: var(--navy); }
.mini .m-top { height: 16px; background: var(--navy); }
.mini .m-tabs { height: 12px; background: var(--surface); border-top: 2px solid var(--brand); }
.mini .m-bar { height: 10px; background: var(--border); margin: 6px; border-radius: 3px; }
.mini .m-card { flex: 1; margin: 0 6px 6px; border-radius: 4px; background: var(--surface); border: 1px solid var(--border); }
.mini.light { background: #f4f6fb; } .mini.dark { background: #0f1729; }
.mini.light .m-card { background: #fff; } .mini.dark .m-card { background: #1b2540; border-color: #26324f; }
.mini.auto { background: linear-gradient(135deg, #f4f6fb 50%, #0f1729 50%); }


/* -- HMS-style forms: label on the left, input on the right ------------------ */
.hform-section { margin-bottom: 16px; }
.hform-section .panel-head h2 { font-size: 1rem; text-transform: none; letter-spacing: 0; }
.hfield { display: grid; grid-template-columns: 36% 1fr; gap: 12px; align-items: start; }
.hfield-label { text-align: right; color: var(--text-muted); font-size: .85rem; padding-top: 7px; margin: 0; }
.hfield-input .form-control, .hfield-input .form-select { font-size: .88rem; }
.hfield-input .form-check { padding-top: 7px; }
.hfield.has-error .hfield-label { color: var(--danger); }
@media (max-width: 575.98px) { .hfield { grid-template-columns: 1fr; gap: 4px; } .hfield-label { text-align: left; padding-top: 0; } }
.form-actions { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 8px; padding: 12px 0;
                background: linear-gradient(transparent, var(--bg) 35%); }
.modal-head-purple { background: linear-gradient(135deg, #6d28d9, #a855f7); color: #fff; }
.modal-head-purple .modal-title { color: #fff; }
.modal-head-purple .btn-close { filter: invert(1) grayscale(1) brightness(2); }
.kv .row-edit { border: 0; background: none; color: var(--text-muted); padding: 0 2px; opacity: 0; transition: opacity .12s; }
.kv:hover .row-edit, .kv .row-edit:focus { opacity: 1; }
.kv .row-edit:hover { color: var(--brand-ink); }
.hform-section .hfield-label, .hform-section .form-text, .hform-section .hint { text-transform: none; letter-spacing: 0; }
@media (min-width: 992px) { .hfield.wide { grid-template-columns: calc(18% - 9px) 1fr; } }

/* The fibre line behind a login (login log, Who had this IP) */
.onu-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.onu-line .cell-sub { flex-basis: 100%; }

/* FTTH network tree */
.view-toggle .btn { white-space: nowrap; }
.ftth-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; min-height: 60vh; }
.ftth-canvas { overflow: auto; max-height: 72vh; background: var(--bg); border-right: 1px solid var(--border); }
.ftth-side { padding: 14px 16px; max-height: 72vh; overflow: auto; }
.ftth-kind { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.ftth-list { border-top: 1px solid var(--border); }
.ftth-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--border); font-size: .85rem; }
.ftth-legend { font-size: .78rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.ft-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; margin-left: 4px; }
.ft-dot.up { background: var(--ok); } .ft-dot.partial { background: var(--warn); }
.ft-dot.down { background: var(--danger); } .ft-dot.unknown, .ft-dot.empty { background: var(--border-strong); }
#ftthSvg { display: block; font: 13px Inter, system-ui, sans-serif; }
#ftthSvg .ft-links path { fill: none; stroke: var(--border-strong); stroke-width: 1.4; }
#ftthSvg .ft-node { cursor: pointer; }
#ftthSvg .ft-node text { fill: var(--text); paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; }
#ftthSvg .ft-node.olt text, #ftthSvg .ft-node.root text { font-weight: 600; }
#ftthSvg .ft-node.onu text { font-size: 12px; fill: var(--text-muted); }
#ftthSvg .ft-node.focus text { fill: var(--brand-ink); font-weight: 600; }
#ftthSvg .ft-dot-svg { stroke: var(--surface); stroke-width: 2; }
#ftthSvg .ft-dot-svg.up { fill: var(--ok); } #ftthSvg .ft-dot-svg.partial { fill: var(--warn); }
#ftthSvg .ft-dot-svg.down { fill: var(--danger); } #ftthSvg .ft-dot-svg.unknown, #ftthSvg .ft-dot-svg.empty { fill: var(--border-strong); }
@media (max-width: 991px) {
  .ftth-wrap { grid-template-columns: 1fr; }
  .ftth-canvas { border-right: 0; border-bottom: 1px solid var(--border); max-height: 60vh; }
}

/* Roles: one row per page, a level picker on the right */
.role-group { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 12px; }
.role-group-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
                   padding: 8px 12px; background: var(--muted-soft); font-weight: 600; font-size: .8rem;
                   text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.role-all { text-transform: none; letter-spacing: 0; font-weight: 400; }
.role-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
            padding: 8px 12px; border-top: 1px solid var(--border); }
.role-pages .pill { margin: 1px 0; }
.pill.lvl-change { background: var(--brand-soft); color: var(--brand-ink); }
.pill.lvl-admin { background: var(--danger-soft); color: var(--danger); }

/* Usage graph on a customer's page */
.usage-canvas { position: relative; height: 190px; }
.usage-graph .btn.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

/* ONU list: the "what counts as weak" bar */
.weak-bar { padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--muted-soft); }
.dbm-input { width: 84px; }

/* Credit */
.credit-note { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius-sm); padding: 8px 12px; font-size: .88rem; }

/* Finance */
.fin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.fin-chart { position: relative; height: 280px; }
.fin-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: baseline;
           padding: 6px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.fin-row:last-child { border-bottom: 0; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 3px 0 8px; }

/* Branch picker in the top bar */
.branch-pick { display: inline-flex; align-items: center; gap: 6px; margin-right: 6px; color: var(--text-muted); }
.branch-pick select { width: auto; min-width: 150px; }
.branch-pick.locked { font-size: .88rem; font-weight: 500; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; }
@media (max-width: 575.98px) { .branch-pick select { min-width: 0; max-width: 130px; } }
/* A region being refetched by a live filter (form[data-ajax-target]). */
.is-loading { opacity: .55; transition: opacity .15s; }

/* ---- Mobile app layout (layout-mobile) ------------------------------------
   A phone gets the shape of an app instead of a shrunk desktop panel: no side
   menu, a fixed bottom tab bar with the main pages and "More" for the rest,
   soft rounded cards, and every table stacked into one card per row on narrow
   screens (app.js labels each cell from the table's header). Ideas from the
   hotel system's Mobile App theme. */
.topbar-brand { display: none; }
body.layout-mobile { scroll-padding-bottom: 90px; }
body.layout-mobile .sidebar, body.layout-mobile #menuToggle, body.layout-mobile .topnav { display: none !important; }
body.layout-mobile .main { margin-left: 0 !important; }
body.layout-mobile .topbar { position: sticky; top: 0; z-index: 1020; gap: 8px; padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top)); }
body.layout-mobile .topbar-brand { display: block; flex-shrink: 0; }
body.layout-mobile .topbar-brand .brand-mark { width: 32px; height: 32px; }
body.layout-mobile .topbar-search { flex: 1; min-width: 0; max-width: none; }
body.layout-mobile .topbar .branch-pick, body.layout-mobile #themeToggle { display: none !important; }
.more-branch { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); }
.more-branch i { color: var(--brand-ink); font-size: 1.2rem; }
.more-branch select { flex: 1; }
body.layout-mobile .topbar .dropdown-toggle::after { display: none; }
body.layout-mobile .content { padding: 14px 12px calc(96px + env(safe-area-inset-bottom)); }
body.layout-mobile .page-head { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 14px; }
body.layout-mobile .page-head h1 { font-size: 1.3rem; }
body.layout-mobile .page-head .action-bar, body.layout-mobile .page-head > .btn,
body.layout-mobile .page-head > a.btn { width: 100%; }
body.layout-mobile .action-bar > .btn, body.layout-mobile .action-bar > a, body.layout-mobile .action-bar > form { flex: 1 1 auto; }
body.layout-mobile .panel { border-radius: 16px; border-color: transparent; box-shadow: var(--shadow-sm); }
body.layout-mobile .panel-head { flex-wrap: wrap; gap: 6px; padding: 12px 14px; }
body.layout-mobile .btn, body.layout-mobile .form-control, body.layout-mobile .form-select { border-radius: 12px; }
body.layout-mobile .btn:not(.btn-sm), body.layout-mobile .form-control:not(.form-control-sm),
body.layout-mobile .form-select:not(.form-select-sm) { min-height: 42px; }
body.layout-mobile .filters { width: 100%; }
body.layout-mobile .filters > * { flex: 1 1 140px; min-width: 0; }
body.layout-mobile .chip { border-radius: 999px; }
body.layout-mobile .tabs-bar { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
body.layout-mobile .tabs-bar a { white-space: nowrap; }
body.layout-mobile .modal-dialog { margin: auto 0 0; max-width: 100%; }
body.layout-mobile .modal-content { border-radius: 18px 18px 0 0; }

@media (max-width: 767.98px) {
  body.layout-mobile .table-responsive { overflow: visible; }
  body.layout-mobile table.table:not(.keep-grid) thead { display: none; }
  body.layout-mobile table.table:not(.keep-grid), body.layout-mobile table.table:not(.keep-grid) tbody,
  body.layout-mobile table.table:not(.keep-grid) tr, body.layout-mobile table.table:not(.keep-grid) td { display: block; width: 100%; }
  body.layout-mobile table.table:not(.keep-grid) > :not(caption) > * > * { background-color: transparent; box-shadow: none; }
  body.layout-mobile table.table:not(.keep-grid) tr { background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 14px; margin: 0 0 10px; padding: 10px 12px; }
  body.layout-mobile .panel table.table:not(.keep-grid) { padding: 4px 10px 0; }
  body.layout-mobile table.table:not(.keep-grid) td { border: none; padding: 3px 0; text-align: left !important; }
  body.layout-mobile table.table:not(.keep-grid) td[data-label] { display: flex; justify-content: space-between;
    align-items: flex-start; gap: 12px; }
  body.layout-mobile table.table:not(.keep-grid) td[data-label] > .cell-v { text-align: right; min-width: 0;
    overflow-wrap: anywhere; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
  body.layout-mobile table.table:not(.keep-grid) td[data-label] > .cell-v > .d-flex { justify-content: flex-end; }
  body.layout-mobile table.table:not(.keep-grid) td[data-label]::before { content: attr(data-label); font-weight: 600;
    font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); flex-shrink: 0; padding-top: 2px; }
  body.layout-mobile table.table:not(.keep-grid) td.cell-first { padding-bottom: 6px; margin-bottom: 4px;
    border-bottom: 1px solid var(--border); }
  body.layout-mobile table.table:not(.keep-grid) td:empty { display: none; }
}

.mobile-tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex;
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(16, 24, 40, .08);
  padding-bottom: env(safe-area-inset-bottom, 0); }
.mobile-tab { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 8px 4px 7px; color: var(--text-muted); font-size: .68rem; font-weight: 600;
  background: none; border: 0; border-top: 2px solid transparent; text-decoration: none; }
.mobile-tab i { font-size: 1.3rem; line-height: 1; }
.mobile-tab:hover { color: var(--text); }
.mobile-tab.active { color: var(--brand-ink); border-top-color: var(--brand); }
.tab-count { position: absolute; top: 3px; left: calc(50% + 6px); min-width: 18px; padding: 1px 5px; border-radius: 99px;
  background: var(--ok); color: #fff; font-size: .62rem; font-weight: 700; line-height: 1.3; }
.tab-count.bad { background: var(--danger); }
.offcanvas.offcanvas-bottom.mobile-more { height: 88vh; max-height: 88vh; border-radius: 20px 20px 0 0;
  background: var(--bg); color: var(--text); }
.mobile-more .offcanvas-header { border-bottom: 1px solid var(--border); }
.mobile-more .offcanvas-body { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.more-heading { text-transform: uppercase; font-size: .68rem; letter-spacing: .08em; color: var(--text-muted);
  font-weight: 700; padding: 14px 2px 6px; }
.more-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.more-link { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 76px; padding: 10px 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: .76rem; font-weight: 500; text-align: center; text-decoration: none; width: 100%; }
.more-link i { font-size: 1.35rem; color: var(--brand-ink); }
.more-link.active { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.more-link .tab-count { top: 6px; left: auto; right: 8px; }
body.layout-mobile .stat-value { font-size: 1.6rem; }
body.layout-mobile .stat { padding: 14px; }
