/* ============================================================
   QA responsive & hierarchy fixes — loaded LAST so it overrides.
   Addresses recurring report items:
     • multiple scrollbars / window-in-window / horizontal overflow
       (QA 2d, 3b, 5d, 13b, 14a)
     • weak side-menu hierarchy — SIP/WebRTC read as flat (QA 2g)
     • inconsistent dropdown chevron sizes (QA 2h)
   Defensive constraints only — no layout rewrites.
   ============================================================ */

/* --- Base .btn with no color variant renders white-on-white (base CSS sets
   only color:#fff, no background). Give bare buttons a readable secondary look
   everywhere. Variant buttons (btn-accent/danger/muted/...) are untouched. --- */
button.btn:not([class*="btn-"]) {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
button.btn:not([class*="btn-"]):hover { border-color: var(--accent); }

/* --- Toasts: centered on screen instead of bottom-right corner --- */
.toast-root {
  bottom: auto !important;
  right: auto !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%);
  justify-items: center;
}
.toast {
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5) !important;
  animation: toast-pop 0.16s ease;
}
@keyframes toast-pop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
/* uctv modal's separate toast system — center it too */
#uctv-toast-container {
  bottom: auto !important;
  right: auto !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%);
  align-items: center;
  z-index: 100000 !important;
}
.uctv-toast { font-size: 14px !important; box-shadow: 0 18px 50px rgba(0,0,0,.5) !important; }

/* --- Auth gate: hide the app shell until rbac-ui confirms the session, so an
   unauthenticated visitor never sees the dashboard flash before redirect. --- */
html:not(.uc-auth-ready) .app-shell { visibility: hidden; }
html:not(.uc-auth-ready)::after {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--bg-primary, #0b1120);
  z-index: 9999;
}

/* --- No horizontal page scroll anywhere --- */
html, body { overflow-x: hidden; }
.app-shell { max-width: 100vw; }
.content, .main-shell, .content-section { min-width: 0; max-width: 100%; }

/* --- App-frame layout (desktop): frozen header, scroll INSIDE the panes ---
   The window itself never scrolls; the sidebar and the content pane each
   own their scrollbar. The topbar stays fixed while content scrolls. --- */
@media (min-width: 1025px) {
  html, body { height: 100%; overflow: hidden; }
  .app-shell { height: 100vh; }
  .main-shell { height: 100vh; min-height: 0; }
  .topbar { flex: 0 0 auto; }
  main.content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }
  main.content::-webkit-scrollbar { width: 9px; }
  main.content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
  main.content::-webkit-scrollbar-track { background: transparent; }
}

/* --- Sidebar: never scroll sideways; labels stay on ONE line ---
   (qa-enhance.js shrinks a label's font dynamically if it would overflow) --- */
.sidebar {
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar::-webkit-scrollbar { width: 9px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.nav-link, .nav-group-header, .nav-subgroup-header {
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

/* --- Menu hierarchy: clear visual levels (group > item > sub-item) --- */
.nav-group-header { font-weight: 700; }
.nav-group-body > .nav-link { padding-left: 18px; font-size: 13.5px; }
.nav-subgroup { margin: 2px 0; }
.nav-subgroup-header {
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 400; /* same weight as sibling items — was reading as bold */
  font-size: 13.5px; /* same size as sibling items (Pairing Codes, Devices…) */
  /* left-align the label with sibling items like "Pairing Codes" (18px) */
  padding: 8px 10px 8px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-subgroup-body {
  margin-left: 20px;
  padding-left: 6px;
  border-left: 1px solid var(--border);
}
.nav-subgroup-body > .nav-link { padding-left: 8px; font-size: 13.5px; }
.nav-link.active { font-weight: 600; }

/* --- Standardize dropdown chevrons across all menu groups --- */
.nav-chev {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 15px;
  opacity: .75;
  flex: 0 0 auto;
  margin-right: 0;
}

/* --- Uniform sidebar geometry ---
   Top-level rows (Dashboard + group headers) share the search bar's exact
   footprint: full width, 10px side padding, 8px radius — so every dropdown
   arrow lands on the same right-edge column as the search bar. --- */
.sidebar .nav-link.nav-top,
.sidebar .nav-group-header {
  width: 100%;
  box-sizing: border-box;
  border-radius: 8px;
  padding: 10px;
}
.sidebar .nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* nav lists are CSS grids: without minmax(0,1fr) the column sizes itself to
   the widest nowrap label, stretching EVERY row past the sidebar edge and
   clipping the dropdown arrows. Pin the track to the container width. */
.sidebar .nav-list,
.sidebar .nav-group-body,
.sidebar .nav-subgroup-body { grid-template-columns: minmax(0, 1fr); }
.sidebar .nav-group,
.sidebar .nav-subgroup { min-width: 0; }

/* and pin the arrow inside the row so text can never push it out of view */
.sidebar .nav-group-header,
.sidebar .nav-subgroup-header { position: relative; padding-right: 32px; }
.sidebar .nav-group-header .nav-chev,
.sidebar .nav-subgroup-header .nav-chev {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 0.22s ease;
  margin-left: 0;
}
.sidebar .nav-group.open > .nav-group-header .nav-chev,
.sidebar .nav-subgroup.open > .nav-subgroup-header .nav-chev {
  transform: translateY(-50%) rotate(90deg);
}
/* subgroup arrows (e.g. Extensions) match the main heading arrows exactly */
.sidebar .nav-subgroup-header .nav-chev {
  width: 20px;
  height: 20px;
  font-size: 15px;
  color: var(--accent);
  opacity: .75;
}

/* --- Modals: a single (vertical) scroll, never a horizontal one --- */
.modal-card { overflow-x: hidden; overflow-y: auto; }
.modal-body { overflow: visible; }
.modal-grid { min-width: 0; }
.modal-grid label,
.modal-grid input,
.modal-grid select,
.modal-grid textarea {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* --- Tables: horizontal scroll ONLY inside the table area, not the page --- */
.table-wrap, .b-table-wrap, .sx-wrap { overflow-x: auto; max-width: 100%; }

/* --- In-panel list scrolling (2026-07-15, user request): page title, panel
   toolbar (Add/search) and column headers stay frozen; only the rows scroll,
   inside the table wrapper with its own scrollbar. Desktop only — mobile
   keeps natural full-page scrolling. --- */
@media (min-width: 1025px) {
  .content-section .table-wrap,
  .content-section .b-table-wrap,
  .content-section .sx-wrap {
    max-height: calc(100vh - 250px);
    overflow-y: auto;
    /* keep row pills/buttons (own stacking contexts) below the sticky head */
    isolation: isolate;
    /* CRITICAL: a sticky thead pins at the scrollport's padding edge, so any
       top padding here leaves a see-through strip above the stuck header
       where rows scroll past. Zero it and let table cells provide spacing. */
    padding: 0;
  }
  /* Phone Groups + Dialable Numbers: vertical split-window —
     the JS fitter refines max-height live */
  #groups-grid, #dial-table {
    max-height: calc(100vh - 250px);
    overflow-y: auto;
  }
  #dial-table { isolation: isolate; padding: 0; }
  /* SIP / WebRTC: Pairing-Codes-style layout (user request) — cards fill a
     column top-to-bottom, extra cards spill into new columns to the RIGHT,
     horizontal scroll only. Height is set live by the JS fitter. */
  #pjsip-extensions-list, #webrtc-extensions-list {
    display: block;
    height: calc(100vh - 250px);   /* fallback until the fitter runs */
    column-fill: auto;
    columns: 2;                    /* exactly 2 visible columns; extras overflow right */
    column-gap: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
  }
  /* the Total/Online/Offline stat bar spans across all columns on top */
  #pjsip-extensions-list .ext-statbar, #webrtc-extensions-list .ext-statbar {
    column-span: all;
  }
  #pjsip-extensions-list .entity-card, #webrtc-extensions-list .entity-card {
    break-inside: avoid;
    margin: 0 0 12px;
    width: 100%;
  }
  .content-section .table-wrap thead th,
  .content-section .b-table-wrap thead th,
  .content-section .sx-wrap thead th,
  #dial-table thead th {
    position: sticky;
    top: 0;
    /* inside the isolated wrap this only needs to beat row pills/buttons;
       MUST stay below the topbar (z 20) so its popovers (theme picker)
       aren't covered */
    z-index: 5;
    background: var(--bg-card);
    box-shadow: 0 1px 0 var(--border);
  }
  /* the toolbar (Add + search) sits above the scroll area — must be opaque
     so scrolled rows never show through it. The wrap is isolation:isolate,
     so z 2 already paints over ALL of its content; keep well under the
     topbar (z 20) and its dropdowns. */
  .content-section .panel-header {
    position: relative;
    z-index: 2;
    background: var(--bg-card);
  }
}
table { max-width: 100%; }

/* --- Panels/cards can't push the page wider than the viewport --- */
.panel, .card, .entity-card, .b-modal { max-width: 100%; min-width: 0; }

/* --- SIP/WebRTC extension status summary bar (QA 5e) ---
   Restyled 2026-07-15 to match the Softphone stat boxes: one compact
   content-sized card per stat, number on top / label below, both centered,
   Online number green, and the whole row centered in the panel. */
.ext-statbar {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 0;
  background: transparent;
  border: none;
}
.ext-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 104px;
  padding: 10px 22px;
  /* theme variables only — themes.css defines these per theme
     (midnight / graphite / daylight / violet); no hardcoded surfaces.
     bg-primary = same surface as the page/title background (user request) */
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  text-align: center;
}
.ext-stat b { color: var(--text-primary); font-size: 26px; font-weight: 700; margin-right: 0; line-height: 1.2; }
.ext-stat-online b { color: #34d399; }
.ext-stat-offline b { color: var(--text-muted); }
/* emerald reads too pale on the light theme — darken it there */
:root[data-theme="daylight"] .ext-stat-online b { color: #059669; }

/* --- Panel headers (QA 3c, global) ---
   The compact theme styled every .panel-header h2 as a blue uppercase pill
   that duplicated the topbar page title. De-pill them everywhere; qa-enhance.js
   additionally hides any h2 whose text merely repeats the topbar title. --- */
.panel-header h2 {
  background: transparent;
  box-shadow: none;
  padding: 0;
  color: var(--text-primary);
  text-transform: none;
  letter-spacing: 0;
  font-size: 16px;
  font-weight: 700;
}

/* --- Unified list toolbar: Add-button left, search right (qa-enhance.js) --- */
.qa-search {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  width: 200px;
  outline: none;
  margin-left: auto;
}
.qa-search:focus { border-color: var(--accent); }
/* Pairing toolbar: pack the whole cluster (bulk pill, Select, Filters) tight
   against the search bar on the RIGHT — the Generate button's margin-right:auto
   is the only flexible gap; the search must not carry its own auto margin. */
#code-search.qa-search { margin-left: 0; }
/* same packing on SIP / WebRTC / Softphone: their Select cluster must sit
   tight against the search bar — the Add button's margin-right:auto (set by
   toolbarEnhance) is the only flexible gap */
#pjsip-extensions-section .qa-search,
#webrtc-extensions-section .qa-search,
#softphone-extensions-section .qa-search,
#devices-section .qa-search { margin-left: 0; }
/* SIP header: uctv-patch injects its own visible Add button while the hidden
   original consumed toolbarEnhance's margin-right:auto slot — give the
   visible one the flexible gap (!important beats the inline 12px) */
#uctv-sip-add-btn { margin-right: auto !important; }

/* pairing-code filters: pill button + small popover panel */
#code-filters, #sipf-filters, #webf-filters, #spf-filters, #devf-filters { position: relative; display: inline-flex; align-items: center; }

/* Softphone refresh: icon-only circular button */
#sx-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
}
#sx-refresh:hover { border-color: var(--accent); color: var(--text-primary); }
.cf-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.cf-btn:hover { border-color: var(--accent); }
.cf-btn svg circle { fill: var(--bg-primary); }
.cf-btn.cf-active { border-color: var(--accent); color: var(--text-primary); }
.cf-count {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
.cf-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 80;
  background: var(--bg-card, #0d1526);
  border: 1px solid var(--border, #22304d);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  padding: 14px;
  display: grid;
  gap: 10px;
  min-width: 230px;
}
.cf-panel label { display: grid; gap: 4px; }
.cf-panel label span { font-size: 11px; color: var(--text-secondary); }
.cf-panel .cf-sel { width: 100%; }
.cf-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2px;
}
.cf-panel-head > span { font-size: 12px; font-weight: 700; color: var(--text-primary); }
.cf-clear {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
.cf-clear:hover:not(:disabled) { text-decoration: underline; }
.cf-clear:disabled { color: var(--text-muted, #5b6b85); opacity: 0.55; cursor: default; }

/* multi-select + bulk delete for pairing codes — one pill container,
   options as real buttons (matches the Cancel/Filters pill styling) */
#code-bulk, #sipb-bulk, #webb-bulk, #spb-bulk {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin-right: 2px;
  padding: 5px 6px 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
}
.cb-count { font-size: 12.5px; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
#code-bulk .cf-clear, #sipb-bulk .cf-clear, #webb-bulk .cf-clear, #spb-bulk .cf-clear {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
#code-bulk .cf-clear:hover, #sipb-bulk .cf-clear:hover, #webb-bulk .cf-clear:hover, #spb-bulk .cf-clear:hover { border-color: var(--accent); color: var(--text-primary); text-decoration: none; }
#cb-delete, #sipb-delete, #webb-delete, #spb-delete { border-radius: 999px; }
.cb-box {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  width: 16px !important;      /* hard-lock: base input rules squashed it */
  height: 16px !important;
  min-width: 16px;
  max-width: 16px;
  min-height: 16px;
  max-height: 16px;
  padding: 0 !important;
  border-radius: 50%;          /* circular select boxes */
  border: 1.5px solid var(--border);
  background: var(--bg-primary);
  cursor: pointer;
  flex: 0 0 16px;
  margin: 0;
  position: relative;
  display: inline-block;
}
.cb-box:hover { border-color: var(--accent); }
/* !important: theme input rules (e.g. Daylight's white input background)
   otherwise out-specificity the checked fill and the circle looks empty */
.cb-box:checked { background: var(--accent) !important; border-color: var(--accent) !important; }
/* CSS-drawn checkmark — geometrically centered, no font-baseline drift */
.cb-box:checked::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 4px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: translate(-50%, -68%) rotate(-45deg);
}
#code-accordion .accordion-item.cb-sel {
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.14), rgba(59, 130, 246, 0.04));
  border-color: rgba(96, 165, 250, 0.4);
}
/* same selected look for SIP/WebRTC cards and Softphone rows */
.entity-card.cb-sel {
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.14), rgba(59, 130, 246, 0.04));
  border-color: rgba(96, 165, 250, 0.4);
}
#sx-tbody tr.cb-sel td, #devices-table-body tr.cb-sel td { background: rgba(59, 130, 246, 0.10); }
.entity-head .cb-box { margin-right: 4px; }
#sx-tbody .cb-box, #devices-table-body .cb-box { margin-right: 8px; vertical-align: middle; }

#cb-delete:disabled { opacity: 0.5; }
.cf-sel {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 8px;
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}
.cf-sel:focus { border-color: var(--accent); }
/* sidebar menu search (above Dashboard) */
.nav-search {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 12px;
}

/* --- Entity lists (SIP/WebRTC/trunks/ring groups/IVR/routes…): sleek bars ---
   Same language as the pairing-code bars: ● dot | name | inline meta | actions. */
.entity-card {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding: 8px 14px;
}
.entity-head { display: flex; align-items: center; gap: 9px; margin: 0; min-width: 0; flex: 0 0 auto; }
.entity-title { font-size: 13.5px; }
.entity-title.mono { font-size: 13px; font-weight: 700; }
.entity-sub { font-size: 12px; }
/* status badge -> round filled dot, docked to the left of the title */
.entity-head .badge {
  display: inline-block;
  font-size: 0;
  line-height: 0;
  width: 10px;
  height: 10px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  flex: 0 0 auto;
}
.entity-head > span:has(> .badge) { order: -1; display: inline-flex; align-items: center; }
/* select-mode checkbox comes before the status dot */
.entity-head .cb-box { order: -2; }
/* bulk Delete reads as disabled until something is selected */
#cb-delete:disabled, #sipb-delete:disabled, #webb-delete:disabled, #spb-delete:disabled, #devb-delete:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.entity-head .badge-success { background: #22c55e; box-shadow: 0 0 6px rgba(34, 197, 94, 0.65); }
.entity-head .badge-danger,
.entity-head .badge-muted,
.entity-head .badge-warning { background: #ef4444; opacity: 0.75; box-shadow: none; }
.entity-meta {
  flex: 1 1 240px;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.entity-actions { margin-left: auto; margin-top: 0; flex: 0 0 auto; flex-wrap: nowrap; gap: 6px; }
.entity-actions .btn { padding: 4px 10px; font-size: 12px; }

/* --- Pairing codes: sleek status bars ---
   Each code renders as a slim bar: ● status dot | CODE | SP/GW pill | chevron. */
.code-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.code-dot-on  { background: #22c55e; box-shadow: 0 0 6px rgba(34, 197, 94, 0.65); }
.code-dot-off { background: #ef4444; opacity: 0.75; }
#code-accordion .accordion-head { padding: 7px 12px; min-height: 34px; }
#code-accordion .accordion-title { gap: 9px; font-size: 12.5px; font-weight: 600; flex-wrap: nowrap; min-width: 0; }
.code-bar-info {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* --- Pairing Codes: masonry flow (no inner scroll box) ---
   CSS columns instead of grid: bars pack top-to-bottom and reflow
   dynamically around an expanded code's details. Kills both the fixed-height
   inner scrollbar and the stretched-row effect. --- */
#code-accordion {
  /* Sequential column fill: the 1st column fills the visible window height
     completely, THEN the 2nd starts, and so on. Column count and height both
     derive from the device/window size. Overflow scrolls sideways in strips. */
  display: block;
  height: calc(100vh - 250px);
  column-fill: auto;
  columns: 300px;
  column-gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  max-height: none;
}
/* phones / stacked layout: single natural column, page scrolls */
@media (max-width: 1024px) {
  #code-accordion {
    height: auto;
    column-fill: balance;
    columns: 1;
    overflow: visible;
  }
}
#code-accordion .accordion-item {
  break-inside: avoid;
  margin: 0 0 -1px;      /* joined bars — borders overlap into divider lines */
  border-radius: 0;
}
#code-accordion .accordion-item:first-child { border-radius: 8px 8px 0 0; }
/* the expanded code stands out — same gradient language as the selected
   sidebar item (e.g. "Pairing Codes" when active) */
#code-accordion .accordion-item.open {
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.18), rgba(59, 130, 246, 0.03));
  border: 1px solid rgba(96, 165, 250, 0.45);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.12);
  position: relative;
  z-index: 1;
}
#code-accordion .accordion-item.open .accordion-title { color: var(--text-primary); }

/* --- Panels hug their content ---
   In the locked app-frame the content pane is full-height; without this the
   last panel stretches to fill it, leaving a big empty block after the rows. */
main.content { align-content: start; }
.content-section { align-content: start; }

/* --- Analog Gateways (FXS/FXO) --- */
.ag-card { border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card); padding: 14px; display: grid; gap: 12px; }
.ag-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ag-name { font-weight: 700; font-size: 15px; }
.ag-ports { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 700px) { .ag-ports { grid-template-columns: 1fr; } }
.ag-col h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); }
.ag-port { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.ag-plabel { flex: 0 0 130px; font-size: 13px; }
.ag-plabel small { color: var(--text-muted); }
.ag-port select { flex: 1; background: var(--bg-primary); border: 1px solid var(--border); color: var(--text-primary); border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 13px; }
.ag-good { color: #4ade80; font-size: 13px; }
.ag-bad { color: #f87171; font-size: 13px; }
.ag-detected { display: flex; flex-wrap: wrap; gap: 16px; margin: 8px 0; font-size: 13px; color: var(--text-secondary); }
.ag-detected b { color: var(--text-primary); }
