/* ============================================================================
   MTX UI theme — flat, dense, light.
   White header, blue accent,
   sharp 1px borders, no gradients/shadows/rounded corners.
   Dark variant via data-theme="dark".
   ============================================================================ */

:root {
  /* ExtJS Crisp blue accent (buttons, selection, links) */
  --accent: #4a90d9;          /* primary blue button */
  --accent-hover: #5b9fe3;
  --accent-border: #3879c4;
  --link: #2d6cb5;

  /* Selection / highlight */
  --sel: #cbe0f7;             /* selected grid row / tree node */
  --sel-border: #a9cdf0;
  --row-hover: #e6eef7;

  /* Surfaces — Crisp is almost all white & very light grey */
  --bg-page: #ffffff;
  --bg-panel: #ffffff;
  --bg-header: #ffffff;       /* top toolbar is white */
  --bg-toolbar: #f7f7f7;      /* panel toolbars / button strips */
  --tabbar-bg: #e2e5ea;       /* page-tab frame — darker so tabs pop (Chrome-like) */
  --bg-tree: #ffffff;
  --bg-grid-header: #f7f7f7;
  --bg-statusbar: #f7f7f7;
  --bg-input: #ffffff;

  /* Text */
  --text: #000000;
  --text-muted: #717171;
  --text-link: #2d6cb5;

  /* Borders — the defining feature of Crisp: thin, mid-grey, everywhere */
  --border: #cfcfcf;
  --border-light: #e0e0e0;
  --border-input: #b5b5b5;

  /* Status */
  --ok: #129b29;
  --warn: #c98a00;
  --err: #cb2a2a;
  --info: #2d6cb5;

  /* Chart series — pastel tones so dense charts read softly (the saturated
     status palette stays reserved for health states). */
  --viz-in:  #85b4e6;   /* inbound — pastel blue */
  --viz-out: #8ecf9c;   /* outbound — pastel green */
  --viz-int: #b6a1e0;   /* internal — pastel violet */

  /* Metrics — tight & flat */
  --font: "Helvetica Neue", Helvetica, Arial, Verdana, sans-serif;
  --font-size: 12px;
  --row-h: 25px;
  --header-h: 38px;
  --statusbar-h: 24px;
  --sidebar-w: 250px;
}

html[data-theme="dark"] {
  --accent: #3f7fc0;
  --accent-hover: #4f8fd0;
  --accent-border: #34699e;
  --link: #6cb0f0;

  --sel: #2d4a66;
  --sel-border: #3a5e80;
  --row-hover: #2c333c;

  --bg-page: #1e2227;
  --bg-panel: #252a31;
  --bg-header: #2a2f37;
  --bg-toolbar: #2a2f37;
  --tabbar-bg: #15181c;       /* page-tab frame — darker than every surface */
  --bg-tree: #232830;
  --bg-grid-header: #2a2f37;
  --bg-statusbar: #2a2f37;
  --bg-input: #1b1f24;

  --text: #dfe3e8;
  --text-muted: #9aa1ab;
  --text-link: #6cb0f0;

  /* Dark theme: deeper, more saturated series tones — sharper definition against
     the dark panels than washed-out light pastels. */
  --viz-in:  #4a8fd6;
  --viz-out: #3fa45c;
  --viz-int: #8a68ce;

  --border: #3a4049;
  --border-light: #32383f;
  --border-input: #454c56;
}

* { box-sizing: border-box; }

/* Boot loader: full-screen blank cover + centered spinner, shown from first
   paint (static markup in index.html) until app.js completes boot. Theme-aware
   since data-theme is applied before stylesheets load. */
#boot-loader {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg-page);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  transition: opacity .25s ease;
}
#boot-loader.done { opacity: 0; pointer-events: none; }
/* The MTX lattice mark (icon-mark.svg as a mask) with an accent shimmer band
   sweeping across it — the logo silhouette stays visible in a muted tone while
   the highlight passes through. Gradient colors come from theme vars, so it's
   correct in both themes. */
#boot-loader .logo-mark {
  width: 66px; height: 62px;
  background: linear-gradient(110deg,
    var(--border) 38%, var(--accent) 50%, var(--border) 62%);
  background-size: 300% 100%;
  animation: boot-shimmer 1.5s linear infinite;
  -webkit-mask: url('../icon-mark.svg') center / contain no-repeat;
  mask: url('../icon-mark.svg') center / contain no-repeat;
}
@keyframes boot-shimmer {
  from { background-position: 150% 0; }
  to   { background-position: -150% 0; }
}

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-size: var(--font-size);
  color: var(--text);
  background: var(--bg-page);
}

#app {
  display: grid;
  /* header / pinned-tab bar (auto) / body / statusbar */
  grid-template-rows: var(--header-h) auto 1fr var(--statusbar-h);
  /* divide by zoom factor so the app fills the *zoomed* viewport exactly,
     keeping the footer pinned regardless of zoom level (set by applyZoom) */
  height: calc(100vh / var(--zoom, 1));
}

/* ========================================================== PAGE TABS ==== */
/* Browser-style page tabs (always at least one; the active tab tracks wherever
   you navigate). Chrome's blending trick: tabs merge into a full-width SURFACE
   STRIP below the bar (not into the page itself, which splits into sidebar +
   main). The strip and the active tab share --tab-surface (= the page bg), so
   the active tab reads as part of the content area in both themes. */
.mtx-tabbar {
  --tab-surface: var(--bg-page);
  display: flex; align-items: flex-end; gap: 0;
  background: var(--tabbar-bg);
  border-bottom: 5px solid var(--tab-surface);
  padding: 6px 10px 0;
  overflow-x: auto; overflow-y: hidden;
}
.mtx-tab {
  position: relative;
  display: flex; align-items: center; gap: 7px;
  height: 30px;
  padding: 0 8px 0 12px;
  font-size: 11.5px; white-space: nowrap;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 9px 9px 0 0;
  cursor: pointer;
  max-width: 240px; min-width: 120px; flex: 0 1 auto;
}
.mtx-tab .ico { font-size: 11px; flex: none; }
.mtx-tab .lbl { overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; }
/* Thin divider between adjacent tabs, Chrome-style — suppressed next to the
   active or hovered tab so their rounded shapes stay clean. */
.mtx-tab + .mtx-tab::before {
  content: ''; position: absolute; left: 0; top: 9px; bottom: 9px;
  width: 1px; background: var(--border);
}
.mtx-tab.active + .mtx-tab::before,
.mtx-tab:hover + .mtx-tab:not(.active)::before,
.mtx-tab:hover:not(.active)::before { display: none; }
.mtx-tab:hover:not(.active) {
  background: color-mix(in srgb, var(--tab-surface) 45%, var(--tabbar-bg));
  color: var(--text);
}
.mtx-tab.active {
  background: var(--tab-surface);
  color: var(--text);
  font-weight: 600;
}
.mtx-tab.active .ico { color: var(--accent); }
/* Chrome's concave corner flares: small squares either side of the active tab's
   base, cut by a circle so the tab appears to sweep outward into the surface
   strip. (The active tab's ::before is repurposed from divider to flare — the
   rules below override every divider property.) */
.mtx-tab.active::before,
.mtx-tab.active::after {
  content: ''; display: block; position: absolute;
  bottom: 0; top: auto;
  width: 9px; height: 9px;
}
.mtx-tab.active::before {
  left: -9px;
  background: radial-gradient(circle at 0 0, transparent 9px, var(--tab-surface) 9.5px);
}
.mtx-tab.active::after {
  right: -9px;
  background: radial-gradient(circle at 100% 0, transparent 9px, var(--tab-surface) 9.5px);
}
.mtx-tab .x {
  opacity: .45; flex: none;
  width: 16px; height: 16px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px;
}
.mtx-tab .x:hover { opacity: 1; background: rgba(128, 128, 128, .25); }
.mtx-tab-new {
  flex: none; width: 20px; height: 20px;
  margin: 0 4px 5px;
  border: none; border-radius: 50%;
  background: transparent; color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; cursor: pointer;
}
.mtx-tab-new:hover {
  background: color-mix(in srgb, var(--tab-surface) 45%, var(--tabbar-bg));
  color: var(--text);
}

/* ============================================================== HEADER === */

.mtx-header {
  background: var(--bg-header);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.mtx-logo {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
  color: var(--text);
}

/* MTX logo: wordmark inherits currentColor (auto light/dark);
   the geometric glyph (2nd path) uses the theme blue. */
.mtx-logo .mtx-logo {
  height: 24px;
  width: auto;
  display: block;
  color: var(--text);
}
.mtx-logo .mtx-logo path:last-child {
  fill: var(--accent);
}

.mtx-logo .product {
  font-weight: 400;
  font-size: 13px;
  color: var(--text-muted);
  padding-left: 10px;
  margin-left: 4px;
  border-left: 1px solid var(--border);
}

.mtx-header .search {
  position: relative;
  margin-left: 6px;
}
.mtx-header .search input {
  width: 300px;
  height: 23px;
  padding: 2px 26px 2px 28px;       /* room for icon + kbd hint */
  font: inherit;
  border: 1px solid var(--border-input);
  border-radius: 12px;              /* pill (half the rendered height) */
  background: var(--bg-input);
  color: var(--text);
  transition: width 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.mtx-header .search input:focus {
  outline: none;
  width: 360px;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.18);
}
.mtx-header .search .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: none;
}
.mtx-header .search .search-kbd {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  font-family: inherit;
  font-size: 11px;
  line-height: 14px;
  min-width: 15px;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-toolbar);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  pointer-events: none;
}
.mtx-header .search input:focus ~ .search-kbd,
.mtx-header .search.has-text .search-kbd { display: none; }

/* autocomplete dropdown */
.search-results {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  width: 360px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
  z-index: 200;
  display: none;
  padding: 4px 0;
}
.search-results.open { display: block; }

.search-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 7px 12px 3px;
}
.search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
}
.search-item:hover,
.search-item.active { background: var(--sel); }
.search-item .si-icon {
  width: 24px; height: 24px; flex: 0 0 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  background: var(--bg-toolbar);
  color: var(--accent);
  font-size: 12px;
}
.search-item .si-main { flex: 1; min-width: 0; }
.search-item .si-title { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item .si-title b { background: rgba(74,144,217,0.25); font-weight: 600; border-radius: 2px; }
.search-item .si-sub { color: var(--text-muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item .si-meta { color: var(--text-muted); font-size: 11px; flex: 0 0 auto; }
.search-empty { padding: 16px 12px; text-align: center; color: var(--text-muted); font-size: 12px; }

.mtx-header .spacer { flex: 1; }

.mtx-header-tools { display: flex; align-items: center; gap: 5px; }

/* ============================================================== BODY ===== */

.mtx-body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  overflow: hidden;
}

/* -------------------------------------------------------- sidebar tree -- */

.mtx-sidebar {
  position: relative;
  background: var(--bg-tree);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* draggable resize handle sitting on the right border of the sidebar */
.mtx-sidebar-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  right: -3px;
  width: 6px;
  cursor: ew-resize;
  z-index: 6;
}
.mtx-sidebar-resizer:hover,
body.resizing-sidebar .mtx-sidebar-resizer {
  background: var(--accent);
  opacity: 0.5;
}
body.resizing-sidebar { cursor: ew-resize; user-select: none; }

/* View-mode toggle: a segmented two-button control at the top of the sidebar
   (Reseller | Super Admin). Hidden entirely for non-super users. */
.mtx-tree-head {
  display: flex;
  align-items: stretch;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tree);
}
.mtx-tree-head .seg {
  flex: 1; min-width: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 24px;
  font: inherit; font-size: 11px;
  background: var(--bg-toolbar); color: var(--text-muted);
  border: 1px solid var(--border-input); border-right: none;
  cursor: pointer; white-space: nowrap;
}
.mtx-tree-head .seg:first-child { border-radius: 3px 0 0 3px; }
.mtx-tree-head .seg:last-child { border-right: 1px solid var(--border-input); border-radius: 0 3px 3px 0; }
.mtx-tree-head .seg:hover:not(.active) { background: var(--row-hover); color: var(--text); }
.mtx-tree-head .seg.active {
  background: var(--accent); border-color: var(--accent-border);
  color: #fff; font-weight: 600;
}
.mtx-tree-head .seg.active + .seg { border-left-color: var(--accent-border); }

.mtx-tree-list { padding: 2px 0; flex: 1; }

.mtx-tree-group {
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 8px 2px;
  font-weight: 700;
  text-transform: none;
}

/* Manage-as account switcher (top of the reseller nav tree) */
.mtx-acct-switch { padding: 2px 8px 6px; }
.mtx-acct-switch select {
  width: 100%;
  height: 24px;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 4px;
  padding: 0 4px;
  cursor: pointer;
}
.mtx-acct-switch select:focus { outline: none; border-color: var(--accent); }

.mtx-tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--row-h);
  padding: 0 8px 0 14px;
  cursor: pointer;
  font-size: 12px;
  border: 1px solid transparent;
  user-select: none;
  white-space: nowrap;
}

.mtx-tree-item:hover { background: var(--row-hover); }

.mtx-tree-item.active {
  background: var(--sel);
  border-top-color: var(--sel-border);
  border-bottom-color: var(--sel-border);
}

.mtx-tree-item .ico { width: 16px; text-align: center; color: var(--accent); flex: 0 0 16px; }
.mtx-tree-item .badge,
.mtx-subnav-item .badge {
  margin-left: auto; background: var(--text-muted); color: #fff;
  border-radius: 8px; font-size: 10px; padding: 0 6px; font-weight: 600; line-height: 15px;
}

/* ============================================================== MAIN ===== */

.mtx-main { display: flex; flex-direction: column; overflow: hidden; background: var(--bg-page); }

/* breadcrumb / object header strip (e.g. "Container 105 ... on node X") */
.mtx-obj-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--row-h);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-page);
  font-size: 12px;
}
.mtx-obj-header .title { font-weight: 400; }
.mtx-obj-header .title b { font-weight: 700; }
.mtx-obj-header .spacer { flex: 1; }

/* Custom site dropdown trigger (opens openMenu) — looks like a compact control,
   not a native <select>, to match the app chrome. */
.site-select {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 8px;
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border-input); border-radius: 3px;
  font-size: 12px; cursor: pointer; white-space: nowrap;
}
.site-select:hover { border-color: var(--accent); }
.site-select .fa-caret-down { margin-left: 2px; }

/* The split: vertical sub-nav (tabs as a list) on the left + content right.
   --subnav-w is set by the drag handle (JS), defaulting to 150px. position:relative
   so the drag handle can be absolutely positioned on the column boundary. */
.mtx-split {
  position: relative;
  display: grid;
  grid-template-columns: var(--subnav-w, 150px) 1fr;
  flex: 1;
  overflow: hidden;
}

.mtx-subnav {
  border-right: 1px solid var(--border);
  background: var(--bg-panel);
  overflow-y: auto;
  padding: 2px 0;
}

/* draggable resize handle straddling the subnav/content boundary (mirrors the sidebar).
   Lives in .mtx-split (NOT inside the scrolling subnav) so it's never clipped, and sits
   at the column edge via left:var(--subnav-w). */
.mtx-subnav-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--subnav-w, 150px);
  width: 6px;
  margin-left: -3px;
  cursor: ew-resize;
  z-index: 6;
}
.mtx-subnav-resizer:hover,
body.resizing-subnav .mtx-subnav-resizer {
  background: var(--accent);
  opacity: 0.5;
}
body.resizing-subnav { cursor: ew-resize; user-select: none; }
.mtx-subnav-item {
  display: flex;
  align-items: center;
  gap: 7px;
  height: var(--row-h);
  padding: 0 10px;
  cursor: pointer;
  font-size: 12px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.mtx-subnav-item:hover { background: var(--row-hover); }
.mtx-subnav-item.active {
  background: var(--sel);
  border-top-color: var(--sel-border);
  border-bottom-color: var(--sel-border);
  font-weight: 400;
}
.mtx-subnav-item .ico { width: 16px; text-align: center; color: var(--text-muted); }
.mtx-subnav-item.active .ico { color: var(--accent); }

/* section header within a grouped sub-nav */
.mtx-subnav-group {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 8px 10px 3px;
}
.mtx-subnav-group:first-child { padding-top: 4px; }

.mtx-content { flex: 1; overflow: auto; background: var(--bg-page); }

/* ============================================================= TOOLBAR === */

.toolbar {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: var(--row-h);
  padding: 7px 8px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border);
}
.toolbar .grow { flex: 1; }
.toolbar .sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }
.toolbar .label { font-size: 12px; padding: 0 6px; color: var(--text); }

/* ============================================================= BUTTONS === */

/* Buttons follow the sidebar segmented control's language: 3px radius,
   toolbar-grey fill, row-hover wash on hover, accent fill + bold for primary. */
.btn {
  font: inherit;
  font-size: 12px;
  height: 24px;
  line-height: 1;
  padding: 0 10px;
  border: 1px solid var(--border-input);
  border-radius: 3px;
  background: var(--bg-toolbar);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  margin: 0 2px;
}
.btn:hover { background: var(--row-hover); }
.btn:active { background: var(--sel); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn .fa-solid { font-size: 11px; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent-border);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-border); }

/* Danger variant: solid red fill with white text/icon (mirrors .btn-primary). */
.btn-danger {
  background: var(--err);
  border-color: var(--err);
  color: #fff;
  font-weight: 600;
}
.btn-danger .fa-solid { color: #fff; }
.btn-danger:hover { background: var(--err); border-color: var(--err); filter: brightness(1.12); }

.btn-sm { height: 22px; padding: 0 8px; font-size: 11px; }

/* ============================================================== GRID ===== */

.grid-wrap { overflow: auto; background: var(--bg-panel); }

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

table.grid thead th {
  background: var(--bg-grid-header);
  text-align: left;
  font-weight: 400;
  font-size: 12px;
  padding: 0 8px;
  height: var(--row-h);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  position: sticky;
  top: 0;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
table.grid thead th:last-child { border-right: none; }
table.grid thead th .sort { color: var(--accent); margin-left: 5px; font-size: 10px; }

table.grid tbody td {
  padding: 0 8px;
  height: var(--row-h);
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
  color: var(--text);
}
table.grid tbody td:last-child { border-right: none; }

table.grid tbody tr { cursor: default; }
table.grid tbody tr:hover { background: var(--row-hover); }
table.grid tbody tr.selected { background: var(--sel); }

/* checkbox selection column */
table.grid .grid-check {
  width: 30px;
  text-align: center;
  padding: 0;
  cursor: default;
}
table.grid .grid-check input { cursor: pointer; vertical-align: middle; margin: 0; }

/* ====================================================== STATUS / TAGS ==== */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text);
}
.tag::before {
  content: "";
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
  flex: 0 0 9px;
}
.tag.ok::before   { background: var(--ok); }
.tag.warn::before { background: var(--warn); }
.tag.err::before  { background: var(--err); }
.tag.info::before { background: var(--info); }

/* Semantic colour for standalone icons (e.g. Live DNS match/mismatch marks). */
i.fa-solid.ok   { color: var(--ok); }
i.fa-solid.warn { color: var(--warn); }
i.fa-solid.err  { color: var(--err); }
i.fa-solid.info { color: var(--info); }

/* Task status chip (Super Admin Events): a long-running operation folded into one
   row that shows Running → Finished/Failed. Flat, on-theme — a thin 1px-bordered
   chip with a subtle tinted fill + coloured text (NOT a saturated solid pill), so
   it reads as a state while sitting quietly in the dense grid. The status palette
   stays reserved for the state; neutral grey is the default/idle. */
.task-status {
  --st: var(--text-muted);          /* per-state colour, overridden below */
  --st-bg: rgba(113,113,113,0.10);
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; 
  /* font-weight: 600;  */
  line-height: 12px;
  padding: 1px 7px; border-radius: 3px;
  color: var(--st);
  /* background: var(--st-bg); */
  border: 1px solid var(--st);
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.task-status .fa-solid { font-size: 9px; }
.task-status.running { --st: var(--info); --st-bg: rgba(45,108,181,0.10); }
.task-status.done    { --st: var(--ok);   --st-bg: rgba(18,155,41,0.10); }
.task-status.failed  { --st: var(--err);  --st-bg: rgba(203,42,42,0.10); }
.task-status.warn    { --st: var(--warn); --st-bg: rgba(201,138,0,0.10); }
.task-status .fa-spinner { animation: mtx-spin 0.9s linear infinite; }
@keyframes mtx-spin { to { transform: rotate(360deg); } }

/* Dark theme: the 10%-alpha tints read too faint on dark panels — lift them a touch. */
html[data-theme="dark"] .task-status         { --st-bg: rgba(154,161,171,0.14); }
html[data-theme="dark"] .task-status.running { --st-bg: rgba(108,176,240,0.16); --st: #6cb0f0; }
html[data-theme="dark"] .task-status.done    { --st-bg: rgba(63,164,92,0.16); }
html[data-theme="dark"] .task-status.failed  { --st-bg: rgba(203,42,42,0.18); }
html[data-theme="dark"] .task-status.warn    { --st-bg: rgba(201,138,0,0.18); }

/* A task row that's still in flight gets a subtle left accent so live work stands out. */
tr.task-running td:first-child { box-shadow: inset 2px 0 0 var(--info); }

/* Node Role cell: a left accent bar in a per-role colour (no dot — replaces the old
   .tag::before circle). Same accent idiom as the in-flight task row. */
.role-accent {
  display: inline-flex; align-items: center;
  font-size: 12px; color: var(--text);
  padding-left: 8px;
  border-left: 3px solid var(--text-muted);   /* per-role colour set below */
}
.role-accent.asterisk { border-left-color: #f59e0b; }   /* orange */
.role-accent.kamailio { border-left-color: #84cc16; }   /* lime green */
.role-accent.capture  { border-left-color: #c62317; }   /* red */
.role-accent.socket   { border-left-color: var(--info); }

/* Active provisioning cell: spinning icon + "Provisioning" (no dot, no ellipsis).
   The spinner already signals the in-progress state, so the label stays normal
   body text (not bold, not the amber warning colour). */
.prov-active {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 400; color: var(--text);
}
/* Spinner is green to draw the eye to in-progress work; the label stays normal text. */
.prov-active .fa-spinner { animation: mtx-spin 0.9s linear infinite; font-size: 11px; color: var(--ok); }

/* Status pill with a severity ICON instead of the .tag::before dot — a green check
   for OK/Online/Provisioned, amber triangle for warnings, red cross for errors,
   grey for idle/no-data. The icon carries the colour; the label stays default text. */
.status-ico {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text); white-space: nowrap;
}
.status-ico > .fa-solid { font-size: 12px; }
.status-ico.ok    > .fa-solid { color: var(--ok); }
.status-ico.warn  > .fa-solid { color: var(--warn); }
.status-ico.err   > .fa-solid { color: var(--err); }
.status-ico.muted > .fa-solid { color: var(--text-muted); }
.status-ico.muted { color: var(--text-muted); }

/* ============================================================== CARDS ==== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}
/* Compact metric tile: label + accent glyph on top, value, sparkline footer.
   No hard border — a soft panel with a hairline ring and a faint accent bar down
   the left edge; the sparkline bleeds to the bottom corners. --c = accent. */
.stat-card {
  --c: var(--accent);
  position: relative; overflow: hidden;
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: 7px;
  padding: 9px 11px;
  display: flex; flex-direction: column;
  min-height: 58px;
  transition: border-color .15s, box-shadow .15s;
}
/* when a sparkline footer is present, drop the card's own bottom padding so the
   spark can bleed flush to the bottom edge */
.stat-card:has(.stat-spark) { padding-bottom: 0; }
.stat-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--c); opacity: .45;
}
.stat-card:hover {
  border-color: color-mix(in srgb, var(--c) 26%, var(--border-light));
  box-shadow: 0 1px 5px rgba(0, 0, 0, .05);
}

.stat-head { display: flex; align-items: center; gap: 6px; }
.stat-card .stat-label {
  flex: 1; min-width: 0;
  font-size: 9.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* small flat accent glyph (no badge box) */
.stat-card .stat-ico {
  --c: var(--accent);
  flex: none; font-size: 11px; color: var(--c); opacity: .85;
}

.stat-valrow { display: flex; align-items: baseline; gap: 6px; margin-top: 4px; }
.stat-card .stat-val {
  font-size: 18px; font-weight: 650; line-height: 1.05;
  letter-spacing: -0.3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* trend delta chip */
.stat-trend {
  flex: none; display: inline-flex; align-items: center; gap: 2px;
  font-size: 10px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.stat-trend i { font-size: 9px; }
.stat-trend.up   { color: var(--ok); }
.stat-trend.down { color: var(--err); }
.stat-trend.flat { color: var(--text-muted); }

/* sparkline footer — fills the card width, sits flush at the bottom */
.stat-spark {
  margin: 6px -11px 0;
  height: 18px; flex: none;
}
.stat-spark-svg { width: 100%; height: 100%; display: block; }

/* Floating tooltip (JS-positioned, see attachTooltip in components.js). Fixed-position
   so it's never clipped by an overflow:hidden parent (e.g. the timeline track). */
.app-tooltip {
  position: fixed; z-index: 9999; pointer-events: none;
  background: var(--bg-panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 5px 8px; font-size: 11px; line-height: 1.4;
  box-shadow: 0 4px 14px rgba(0,0,0,.35); max-width: 320px;
  white-space: nowrap;
}
.app-tooltip .tt-title { font-weight: 700; }
.app-tooltip .tt-sub { color: var(--text-muted); }

/* IP cell + hover info panel (see js/ipInfo.js). The info dot is hidden until the
   cell is hovered, then clickable; the panel floats below the cell and AJAX-loads
   the IP's geo/provider details. */
.ip-cell { display: inline-flex; align-items: center; gap: 5px; }
.ip-cell .ip-info-dot {
  font-size: 10px; color: var(--text-muted); opacity: 0;
  transition: opacity .1s; cursor: help;
}
.ip-cell:hover .ip-info-dot { opacity: 1; color: var(--link); }

.ip-info-panel {
  position: fixed; z-index: 10000; display: none;
  min-width: 220px; max-width: 320px;
  background: var(--bg-panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,.30);
  padding: 8px 10px; font-size: 11.5px; line-height: 1.5;
}
.ip-info-head {
  display: flex; align-items: center; gap: 6px;
  font-weight: 600; margin-bottom: 5px;
  padding-bottom: 5px; border-bottom: 1px solid var(--border-light);
}
.ip-info-head .fa-location-dot { color: var(--link); font-size: 11px; }
.ip-info-head .ip-info-flag { font-size: 14px; line-height: 1; }
.ip-info-row { display: flex; gap: 8px; padding: 1px 0; }
.ip-info-row.muted { color: var(--text-muted); }
.ip-info-k { color: var(--text-muted); flex: 0 0 72px; }
.ip-info-v { flex: 1; word-break: break-word; }
.ip-info-retry { display: inline-block; margin-top: 4px; font-size: 11px; cursor: pointer; }
.ip-flag {
  display: inline-block; font-size: 10px; font-weight: 600;
  padding: 0 5px; margin-right: 4px; border-radius: 3px;
  border: 1px solid var(--border); color: var(--text-muted);
}
.ip-flag.warn { color: var(--warn); border-color: var(--warn); }

/* a "Summary" style key/value panel */
.kv-panel { border: 1px solid var(--border); background: var(--bg-panel); }
.kv-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  border-bottom: 1px solid var(--border-light);
}
.kv-row:last-child { border-bottom: none; }
.kv-row .k {
  padding: 4px 8px; background: var(--bg-grid-header);
  border-right: 1px solid var(--border-light); color: var(--text); font-size: 12px;
}
.kv-row .v { padding: 4px 8px; font-size: 12px; }

.section-title {
  font-size: 12px; font-weight: 700; padding: 6px 8px;
  background: var(--bg-toolbar); border-bottom: 1px solid var(--border);
}

/* Super Admin → Overview (superadmin.js). Same flat chrome as .kv-panel /
   .section-title: square corners, 1px borders, toolbar-grey header strips. */
.sa-panel-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 10px; align-items: start;
}
/* Full-width section header strip (title left, action buttons right) — the same
   chrome as .device-list-head, used above the cluster cards. */
.sa-section-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 5px 8px;
  background: var(--bg-toolbar); border: 1px solid var(--border);
  font-size: 12px; font-weight: 700;
}
.sa-cluster-card { border: 1px solid var(--border); background: var(--bg-panel); min-width: 0; }
.sa-cluster-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 5px 8px 5px 10px;
  background: var(--bg-toolbar); border-bottom: 1px solid var(--border);
}
/* Role columns (Edges | Backends | Aux); single column on narrow screens. */
.sa-cluster-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; padding: 10px; align-items: start;
}
@media (max-width: 1100px) { .sa-cluster-grid { grid-template-columns: 1fr; } }
.sa-col { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.sa-col-head {
  display: flex; gap: 6px; align-items: center;
  color: var(--text-muted); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
}
.sa-node-cell {
  border: 1px solid var(--border-light); background: var(--bg-page);
  padding: 8px 10px;
}
.sa-node-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; margin-bottom: 5px;
}
/* Status dot (cluster header, node rows). Background color set inline. */
.sa-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
/* Metric tiles: label / value / 24h peak, in an even 4-up grid so columns line
   up across nodes. .mini-bar = slim capacity bar under % values (mem/disk). */
.sa-metrics-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; margin-top: 8px;
}
.sa-metric { min-width: 0; }
.sa-metric .lbl {
  font-size: 9px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em;
}
.sa-metric .val { font-size: 13px; font-weight: 600; line-height: 1.3; }
.sa-metric .peak { font-size: 10px; color: var(--text-muted); }
.sa-metric .mini-bar { height: 4px; background: var(--border-light); margin: 3px 0 2px; }
.sa-metric .mini-bar > span { display: block; height: 100%; }
/* One uptime-strip segment (a 15-min bucket). Background color set inline;
   hover darkens the segment so the bucket under the themed tooltip is obvious. */
.sa-strip-seg { flex: 1 1 0; min-width: 0; height: 100%; }
.sa-strip-seg:hover { filter: brightness(0.7); }
/* S3 Storage panel: one row per bucket — identity | current figures | 24h chart. */
.sa-storage-row {
  display: grid; grid-template-columns: 230px 150px 1fr;
  gap: 12px; align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
}
.sa-storage-row:last-child { border-bottom: none; }
@media (max-width: 900px) { .sa-storage-row { grid-template-columns: 1fr; } }
/* Storage 24h chart: an SVG step-area sparkline with an invisible column overlay
   on top for per-sample tooltips. Hover veils the column; failed samples show a
   red tick along the top edge. */
.sa-spark { position: relative; height: 36px; width: 100%; min-width: 0; overflow: hidden; }
.sa-spark > .ymax {
  position: absolute; top: 2px; left: 4px; z-index: 2;
  font-size: 9px; color: var(--text-muted); pointer-events: none;
}
.sa-spark-svg, .sa-spark-hits { position: absolute; inset: 0; }
.sa-spark-svg svg { width: 100%; height: 100%; display: block; }
.sa-spark-hits { display: flex; }
.sa-spark-hit { flex: 1 1 0; min-width: 0; position: relative; }
.sa-spark-hit:hover { background: rgba(128, 128, 128, .18); }
.sa-spark-hit .fail-tick {
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px; background: var(--err);
}
/* Customer summary concept dashboard (acctCustomerSummary): panel grids,
   stacked hourly bars, legend swatches, per-site rows. Charts reuse the
   .sa-spark overlay classes above for hover + tooltips. */
.dash-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px; align-items: stretch;
}
.dash-cols { display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; align-items: start; }
@media (max-width: 1000px) { .dash-cols { grid-template-columns: 1fr; } }
.dash-bars {
  position: relative;
  display: flex; gap: 2px; align-items: stretch; width: 100%; min-width: 0;
  /* faint horizontal gridlines at 0/25/50/75% + a solid baseline */
  background: linear-gradient(var(--border-light) 1px, transparent 1px) 0 0 / 100% 25% repeat-y;
  border-bottom: 1px solid var(--border-light);
}
.dash-bars .ymax {
  position: absolute; top: 2px; left: 3px; z-index: 1;
  font-size: 9px; color: var(--text-muted);
}
.dash-bar-col {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 1px;
}
.dash-bar-col:hover { filter: brightness(0.8); }
.dash-bar-col .seg { width: 100%; }
.dash-bar-col .seg.top { border-radius: 3px 3px 0 0; }   /* match button radius */
.dash-legend { display: flex; gap: 14px; align-items: center; font-size: 11px; color: var(--text-muted); }
.dash-legend .sw { width: 9px; height: 9px; display: inline-block; margin-right: 5px; border-radius: 2px; }
.dash-site-row {
  display: grid; grid-template-columns: 200px 110px 130px 1fr;
  gap: 12px; align-items: center;
  padding: 8px 10px; border-bottom: 1px solid var(--border-light);
}
.dash-site-row:last-child { border-bottom: none; }
@media (max-width: 900px) { .dash-site-row { grid-template-columns: 1fr 1fr; } }
/* Fixed-height scrolling panel body (Busiest Extensions / Recent Calls share the
   same height). Grid headers inside stay pinned while the rows scroll. */
.dash-scroll { overflow-y: auto; min-width: 0; }
.dash-scroll table.grid thead th { position: sticky; top: 0; z-index: 1; }
/* Live extension wallboard: one tile per phone, state shown by the left edge +
   pill; the handset icon pulses while ringing. Fixed-height, scrolls vertically
   (sized for ~4 tile rows; the 100-phone pool scrolls within). */
.dash-phone-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  grid-auto-rows: min-content;          /* fixed-height rows — tiles don't stretch */
  gap: 6px; padding: 8px;
  height: 220px; overflow-y: auto;
  align-content: start; align-items: start;
}
/* Wallboard bottom-edge resize handle: a slim grab strip with a center pip. */
.dash-resize {
  height: 8px; cursor: ns-resize;
  border-top: 1px solid var(--border-light);
  background: var(--bg-toolbar);
  display: flex; align-items: center; justify-content: center;
}
.dash-resize::before {
  content: ''; width: 36px; height: 3px; border-radius: 2px;
  background: var(--border);
}
.dash-resize:hover::before { background: var(--text-muted); }
/* 3CX-style contact presence card: a colour-keyed initials avatar with a
   presence dot at its corner, the name + extension, a presence/status line, and
   hover actions. --st = the presence accent colour (set per state below) and
   drives the avatar dot + status emphasis. */
.dash-phone {
  --st: var(--text-muted);
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--border-light);
  border-radius: 5px;
  background: var(--bg-panel);
  padding: 5px 7px; min-width: 0;
  transition: background .2s, border-color .2s, opacity .25s, box-shadow .15s;
}
.dash-phone:hover {
  border-color: var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
}
/* Avatar: round initials chip, hue picked from the contact name in JS. */
.dash-phone-avatar {
  flex: none; position: relative;
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 600; color: #fff;
  background: hsl(var(--av-h, 210) 42% 48%);
  user-select: none;
}
.dash-phone-av-txt { line-height: 1; }
/* presence dot at the avatar's bottom-right corner */
.dash-phone-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--st);
  box-shadow: 0 0 0 2px var(--bg-panel);
}
/* small "Q" queue badge at the avatar's top-left corner */
.dash-phone-q {
  position: absolute; left: -2px; top: -2px;
  min-width: 10px; height: 10px; padding: 0 1px; border-radius: 3px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 7px; font-weight: 700; line-height: 1;
  color: var(--text); background: var(--bg-toolbar);
  box-shadow: inset 0 0 0 1px var(--border);
}
.dash-phone-id { flex: 1; min-width: 0; line-height: 1.2; }
.dash-phone-name {
  font-size: 10px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dash-phone-name b { font-weight: 600; }
.dash-phone-name span { font-weight: 400; }
/* presence / status line (caller + timer / presence word) */
.dash-phone-status {
  margin-top: 1px; font-size: 8px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* per-state presence colour + emphasis */
.dash-phone.st-idle    { --st: var(--ok); }
.dash-phone.st-ringing { --st: var(--warn); }
.dash-phone.st-ringing .dash-phone-dot { animation: dash-pulse .9s infinite; }
.dash-phone.st-call    {
  --st: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-panel));
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border-light));
}
.dash-phone.st-call .dash-phone-status { color: var(--text); font-weight: 600; }
.dash-phone.st-hold    { --st: var(--warn); }
.dash-phone.st-hold .dash-phone-status { color: var(--text); }
.dash-phone.st-dnd     { --st: var(--err); }
.dash-phone.st-offline { --st: var(--text-muted); }
.dash-phone.st-offline .dash-phone-avatar { filter: grayscale(.7); opacity: .6; }
.dash-phone.st-offline .dash-phone-name { color: var(--text-muted); }
@keyframes dash-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
/* Wallboard count badges in the panel header (one per state, colour-coded). */
.dash-count-badges { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.dash-count-badge {
  --c: var(--text-muted);
  display: inline-flex; align-items: center; gap: 4px;
  height: 18px; padding: 0 8px; border-radius: 9px;
  font-size: 10px; font-weight: 400; text-transform: uppercase; letter-spacing: .03em;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, var(--bg-panel));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 26%, transparent);
}
.dash-count-badge b { font-size: 11px; font-weight: 700; }
.dash-count-badge.ok   { --c: var(--ok); }
.dash-count-badge.warn { --c: var(--warn); }
.dash-count-badge.info { --c: var(--accent); }
.dash-count-badge.err  { --c: var(--err); }
.dash-live-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  display: inline-block; background: var(--ok);
  animation: dash-pulse 1.6s infinite;
}

/* Mesh Status tab: summary chip strip + per-edge cards in a 2-up grid. */
.sa-mesh-summary {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  padding: 6px 8px; border-bottom: 1px solid var(--border-light);
}
.sa-mesh-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 10px; align-items: start;
}
@media (max-width: 1100px) { .sa-mesh-grid { grid-template-columns: 1fr; } }

/* Device card header: the toolbar background + divider fills the FULL header row
   (title on the left, status/actions on the right), not just the title text. */
.device-head {
  padding: 6px 8px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border);
}

/* SIP Registrations: device list header strip + per-device cards. */
.device-list-head {
  padding: 6px 8px;
  margin-bottom: 12px;
  background: var(--bg-toolbar);
  border: 1px solid var(--border);
}
.device-card,
.settings-card {
  margin: 0 0 12px;
  border: 1px solid var(--border-input);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* Provisioning function keys laid out 3 per row, each a compact stacked block. */
.prov-fnkey-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 6px 8px;
}
@media (max-width: 700px) { .prov-fnkey-grid { grid-template-columns: repeat(2, 1fr); } }
.prov-fnkey {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--border-light);
  border-radius: 3px;
  background: var(--bg-input);
}
.prov-fnkey-h { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: var(--text-muted); }
.prov-fnkey-h input[type="checkbox"] { margin: 0; cursor: pointer; }

/* Toolbar above the function-key grid: select-all + bulk type-apply. */
.prov-fnkey-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
}
.prov-fnkey-toolbar .grow { flex: 1; }
.prov-fnkey-toolbar .sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 2px; }

/* Lightweight segmented control inside each card (replaces a nested toolbar). */
.device-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px 0;
  border-bottom: 1px solid var(--border-light);
}
.device-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 3px 3px 0 0;
  margin-bottom: -1px;
}
.device-tab .ico { font-size: 11px; }
.device-tab:hover { background: var(--row-hover); }
.device-tab.active {
  color: var(--text);
  background: var(--bg-panel);
  border-color: var(--border-light);
  border-bottom-color: var(--bg-panel);
  font-weight: 600;
}
.device-tab.active .ico { color: var(--accent); }
.device-pane { padding: 8px; }

/* Stats & Status pane: two columns at modal width (status + live edge stats on
   the left, the tall 24h timeline on the right) so an expanded Stats pane isn't
   one long vertical run — keeps things tidy when several are open at once.
   Collapses to a single column on narrow widths. */
.stats-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 10px;
  align-items: start;
}
@media (max-width: 760px) {
  .stats-grid { grid-template-columns: 1fr; }
}
/* Each block framed as a small titled card. */
.stats-sub { border: 1px solid var(--border); background: var(--bg-panel); }
.stats-sub-head {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px;
  font-size: 11px; font-weight: 700;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.stats-sub-head .ico { font-size: 11px; }

/* ============================================================== FORMS ==== */

.form-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  align-items: center;
  padding: 5px 8px;
  gap: 10px;
}
.form-row label { font-size: 12px; color: var(--text); }
/* Base help text (modals, panels): a little padding + a faded tone. */
.field-help { font-size: 11px; color: var(--text-muted); opacity: 0.75; padding: 2px 8px; line-height: 1.4; }
/* In a form row it's grid-placed and snug under the field — keep it tight. */
.form-row .field-help { grid-column: 2; opacity: 0.85; padding: 0; margin-top: -2px; }

input[type="text"], input[type="email"], input[type="number"],
input[type="search"], input[type="tel"], input[type="password"],
input[type="date"], input[type="time"], input[type="datetime-local"],
input[type="month"], input[type="week"], input[type="url"],
select, textarea {
  font: inherit;
  font-size: 12px;
  height: 24px;
  padding: 2px 6px;
  border: 1px solid var(--border-input);
  border-radius: 3px;           /* same small radius as buttons/modals */
  background: var(--bg-input);
  color: var(--text);
  width: 100%;
}
textarea { height: auto; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
}
/* Chrome/Safari paint autofilled fields with a hard-coded light-yellow background that
   ignores our dark theme. Mask it: a large inset box-shadow repaints the field background
   to var(--bg-input) and -webkit-text-fill-color restores the text colour. (We also set
   autocomplete=off on most form inputs so autofill rarely fires in the first place.) */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset !important;
  box-shadow: 0 0 0 1000px var(--bg-input) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;   /* defeat the autofill colour flash */
}

/* checkbox toggle — small switch */
.switch { position: relative; display: inline-block; width: 27.2px; height: 14.4px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border-input); border-radius: 14.4px; transition: 0.12s;
}
.switch .slider::before {
  content: ""; position: absolute; height: 9.6px; width: 9.6px;
  left: 2.4px; top: 2.4px; background: #fff; border-radius: 50%; transition: 0.12s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(12.8px); }
/* Read-only switch: shows state (on/off) but greyed + not clickable. */
.switch.is-disabled { opacity: 0.5; }
.switch.is-disabled .slider { cursor: not-allowed; }

/* ============================================================ STATUSBAR == */

.mtx-statusbar {
  background: var(--bg-statusbar);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 14px;
  font-size: 11px;
  color: var(--text-muted);
}
.mtx-statusbar .spacer { flex: 1; }
.mtx-statusbar .ok { color: var(--ok); }

/* ============================================================== MENU ===== */

.menu {
  min-width: 230px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
  z-index: 5000;   /* above raised modal windows (shared z counter starts at 100) */
  padding: 4px 0;
  font-size: 12px;
}
.menu-userhead {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.menu-userhead .avatar {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 50%;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}
.menu-userhead .uh-name { font-weight: 600; color: var(--text); }
.menu-userhead .uh-sub { color: var(--text-muted); font-size: 11px; }
.menu-header {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); padding: 7px 12px 3px;
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px; cursor: pointer; color: var(--text);
}
.menu-item:hover { background: var(--sel); }
.menu-item .mi { width: 16px; text-align: center; color: var(--text-muted); flex: 0 0 16px; }
.menu-item:hover .mi { color: var(--accent); }
.menu-item.danger { color: var(--err); }
.menu-item.danger .mi { color: var(--err); }
.menu-item .menu-badge {
  margin-left: auto; background: var(--accent); color: #fff;
  border-radius: 9px; font-size: 10px; padding: 0 6px; font-weight: 600;
}
/* Outline variant — border only, no fill (e.g. site country badges). */
.menu-item .menu-badge.outline {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border-input);
}
.menu-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* checkmark for an active/selected menu item */
.menu-item .mi-check { margin-left: auto; color: var(--accent); font-size: 11px; }
.menu-item.checked { color: var(--text); }

/* zoom stepper row inside a menu */
/* Light/Dark segmented toggle — two pill buttons in a track, active = filled. */
.menu-seg {
  display: flex; gap: 3px; margin: 4px 12px 2px;
  padding: 3px; border-radius: 8px;
  background: var(--bg-toolbar);
  box-shadow: inset 0 0 0 1px var(--border-light);
}
.menu-seg .seg-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 26px; border: 0; border-radius: 6px; cursor: pointer;
  font-size: 12px; font-weight: 500;
  color: var(--text-muted); background: transparent;
  transition: background .12s, color .12s, box-shadow .12s;
}
.menu-seg .seg-btn i { font-size: 11px; }
.menu-seg .seg-btn:hover { color: var(--text); }
.menu-seg .seg-btn.active {
  color: var(--text); background: var(--bg-panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}
.menu-seg .seg-btn.active i { color: var(--accent); }

.menu-zoom {
  display: flex; flex-direction: column; gap: 7px;
  padding: 6px 12px 8px; color: var(--text);
}
.menu-zoom .zoom-head { display: flex; align-items: center; gap: 10px; }
.menu-zoom .mi { width: 16px; text-align: center; color: var(--text-muted); flex: 0 0 16px; }
.menu-zoom .zoom-val {
  margin-left: auto; min-width: 38px; text-align: right;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--accent);
}
/* small inline reset-to-100% button beside the readout */
.menu-zoom .zoom-reset {
  flex: none; width: 22px; height: 22px; border: 0; border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; cursor: pointer;
  color: var(--text-muted); background: transparent;
}
.menu-zoom .zoom-reset:hover { background: var(--sel); color: var(--accent); }
.menu-zoom .zoom-track { display: flex; align-items: center; gap: 8px; }
.menu-zoom .zoom-end {
  font-size: 9.5px; color: var(--text-muted); flex: none;
  font-variant-numeric: tabular-nums;
}
/* range slider — themed track + thumb, cross-browser */
.menu-zoom .zoom-slider {
  flex: 1; min-width: 110px; height: 16px; margin: 0; cursor: pointer;
  -webkit-appearance: none; appearance: none; background: transparent;
}
.menu-zoom .zoom-slider:focus { outline: none; }
.menu-zoom .zoom-slider::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: var(--border);
}
.menu-zoom .zoom-slider::-moz-range-track {
  height: 4px; border-radius: 2px;
  background: var(--border);
}
.menu-zoom .zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; margin-top: -4.5px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg-panel);
  box-shadow: 0 0 0 1px var(--accent);
}
.menu-zoom .zoom-slider::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg-panel);
  box-shadow: 0 0 0 1px var(--accent);
}

/* presence dot in the header chip */
.mtx-header-tools .presence { margin-right: 5px; }

/* ============================================================= FEATURES === */

.feat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.feat-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
  position: relative;
}
.feat-card:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(0,0,0,0.08); }
.feat-card.on {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-panel));
}

.feat-ico {
  width: 42px; height: 42px; flex: 0 0 42px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; font-size: 18px;
  background: var(--bg-toolbar); color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
}
.feat-card.on .feat-ico {
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-panel));
  color: var(--accent);
}

.feat-main { flex: 1; min-width: 0; }
.feat-name { font-weight: 600; font-size: 13px; }
.feat-desc { font-size: 11.5px; color: var(--text-muted); margin: 3px 0 8px; line-height: 1.45; }
.feat-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.feat-plan {
  font-size: 10px; font-weight: 600; letter-spacing: 0.3px;
  padding: 2px 8px; border-radius: 10px;
  background: var(--bg-toolbar); color: var(--text-muted);
  border: 1px solid var(--border);
}
.feat-status {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600; color: var(--ok);
}
.feat-toggle { flex: 0 0 auto; padding-top: 2px; }

/* ============================================================ SOFTPHONE === */

.sp-wrap { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; }

.sp {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 16px;
  flex: 1; min-height: 0;
}
@media (max-width: 900px) { .sp { grid-template-columns: 1fr; } }
.sp-col { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.sp-left { overflow: auto; padding-right: 2px; }
.sp-pane { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }

/* header status strip */
.sp-status {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--bg-toolbar);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.sp-reg { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 12.5px; }
.sp-reg .dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent);
}
.sp-reg.off .dot { background: var(--err); box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 22%, transparent); }
.sp-idn { color: var(--text-muted); font-size: 11.5px; }
.sp-chip {
  font-size: 10px; font-weight: 700; letter-spacing: 0.4px;
  padding: 2px 7px; border-radius: 10px;
  background: var(--bg-panel); border: 1px solid var(--border); color: var(--text-muted);
}
.sp-gap { flex: 1; }
.sp-quality { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-muted); cursor: default; }
.sp-quality .bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.sp-quality .bars i { width: 3px; background: var(--border-strong); border-radius: 1px; }
.sp-quality .bars i:nth-child(1) { height: 4px; }
.sp-quality .bars i:nth-child(2) { height: 7px; }
.sp-quality .bars i:nth-child(3) { height: 10px; }
.sp-quality .bars i:nth-child(4) { height: 14px; }
.sp-quality.excellent .bars i { background: var(--ok); }
.sp-quality.good .bars i:nth-child(-n+3) { background: var(--ok); }
.sp-quality.fair .bars i:nth-child(-n+2) { background: var(--warn); }
.sp-quality.poor .bars i:nth-child(1) { background: var(--err); }
/* the app's base select is width:100% — pin this one to its content so the
   status strip stays a single row with presence + DND on the right */
.sp-status select.sp-pres { width: auto; flex: 0 0 auto; font-size: 12px; padding: 3px 6px; }
.sp-dndbtn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; padding: 5px 10px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-panel); color: var(--text-muted);
}
.sp-dndbtn:hover { border-color: var(--accent); color: var(--text); }
.sp-dndbtn.on { background: var(--err); border-color: var(--err); color: #fff; }

/* incoming-call banner */
.sp-banner {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--ok) 45%, var(--border));
  background: color-mix(in srgb, var(--ok) 9%, var(--bg-panel));
  border-radius: 8px;
  animation: sp-banner-in 0.18s ease-out;
}
@keyframes sp-banner-in { from { opacity: 0; transform: translateY(-6px); } }
.sp-banner .rings {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--ok); color: #fff; font-size: 15px;
  animation: sp-ring-pulse 1.1s ease-in-out infinite;
}
@keyframes sp-ring-pulse {
  0%, 100% { transform: rotate(0); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 45%, transparent); }
  20% { transform: rotate(-12deg); }
  40% { transform: rotate(10deg); }
  60% { box-shadow: 0 0 0 9px transparent; }
}
.sp-banner .who { min-width: 0; }
.sp-banner .who .p { font-weight: 700; font-size: 14px; }
.sp-banner .who .n { font-size: 11.5px; color: var(--text-muted); }
.sp-banner .acts { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.sp-banner .acts button {
  border: none; border-radius: 7px; padding: 8px 14px; cursor: pointer;
  font-size: 12.5px; font-weight: 600; color: #fff;
  display: inline-flex; align-items: center; gap: 7px;
}
.sp-banner .acts button:hover { filter: brightness(1.08); }
.sp-btn-answer { background: var(--ok); }
.sp-btn-decline { background: var(--err); }
.sp-banner .acts .sp-btn-vm { background: var(--bg-panel); color: var(--text); border: 1px solid var(--border); }

/* the 4 line keys */
.sp-lines { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; flex: 0 0 auto; }
.sp-line {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 8px; cursor: pointer; min-height: 46px;
  display: flex; flex-direction: column; gap: 3px;
  background: var(--bg-panel);
  transition: border-color 0.12s, background 0.12s;
}
.sp-line:hover { border-color: var(--accent); }
.sp-line .ln {
  display: flex; align-items: center; gap: 5px;
  font-size: 9px; font-weight: 700; letter-spacing: 0.5px; color: var(--text-muted);
}
.sp-line .led { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); flex: 0 0 auto; }
.sp-line.live .led { background: var(--ok); box-shadow: 0 0 4px var(--ok); }
.sp-line.hold .led { background: var(--warn); animation: sp-led-blink 1.2s steps(1) infinite; }
@keyframes sp-led-blink { 50% { opacity: 0.25; } }
.sp-line .lp-party { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-line .lp-meta { font-size: 10px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.sp-line .lp-free { font-size: 11px; color: var(--text-muted); }
.sp-line.live { border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); background: color-mix(in srgb, var(--ok) 7%, var(--bg-panel)); }
.sp-line.hold { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); background: color-mix(in srgb, var(--warn) 6%, var(--bg-panel)); }
.sp-line.sel { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent); }

/* dial display + keypad */
.sp-display {
  width: 100%; text-align: center; font-size: 24px; letter-spacing: 1px;
  height: 48px; border: 1px solid var(--border-input); border-radius: 8px;
  background: var(--bg-input); color: var(--text);
  font-variant-numeric: tabular-nums; box-sizing: border-box;
}
.sp-display::placeholder { font-size: 14px; letter-spacing: 0; }
.sp-hint {
  min-height: 16px; font-size: 12px; color: var(--text-muted); text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.sp-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sp-key {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-panel); color: var(--text);
  height: 52px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1; transition: background 0.1s, transform 0.05s;
}
.sp-key:hover { background: var(--row-hover); border-color: var(--accent); }
.sp-key:active { background: var(--sel); transform: scale(0.96); }
.sp-key .d { font-size: 19px; font-weight: 600; }
.sp-key .l { font-size: 8px; color: var(--text-muted); letter-spacing: 1.5px; margin-top: 3px; height: 8px; }

.sp-dialrow { display: flex; gap: 8px; }
.sp-callbtn {
  flex: 1; height: 44px; border: none; border-radius: 8px;
  background: var(--ok); color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.sp-callbtn:hover { filter: brightness(1.08); }
.sp-callbtn.hang { background: var(--err); width: 100%; flex: 0 0 auto; margin-top: 6px; }
.sp-bs {
  width: 52px; height: 44px; flex: 0 0 auto; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-panel); color: var(--text-muted); font-size: 15px;
}
.sp-bs:hover { background: var(--row-hover); color: var(--text); }
.sp-btn-ghost {
  border: 1px solid var(--border); border-radius: 8px; height: 44px; padding: 0 14px;
  background: var(--bg-panel); color: var(--text); cursor: pointer;
  font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.sp-btn-ghost:hover { background: var(--row-hover); }

/* favourites (speed dials) under the keypad */
.sp-favs { display: flex; flex-direction: column; gap: 6px; }
.sp-favs-t { font-size: 10px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-muted); }
.sp-favs-row { display: flex; flex-wrap: wrap; gap: 6px; }
.sp-fav {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  border: 1px solid var(--border); border-radius: 14px; padding: 4px 10px 4px 8px;
  background: var(--bg-panel); cursor: pointer; font-size: 11.5px; color: var(--text);
}
.sp-fav:hover { border-color: var(--accent); background: var(--row-hover); }
.sp-fav .led { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); flex: 0 0 auto; }
.sp-fav.idle .led { background: var(--ok); }
.sp-fav.on-call .led, .sp-fav.dnd .led { background: var(--err); }
.sp-fav.ringing .led { background: var(--warn); }
.sp-fav .fx { font-weight: 700; font-variant-numeric: tabular-nums; }
.sp-fav .fn { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* active call card */
.sp-callcard {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 18px 16px;
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--accent) 15%, transparent), transparent 60%),
    var(--bg-panel);
  border: 1px solid var(--border); border-radius: 10px;
}
.sp-callcard.held {
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--warn) 14%, transparent), transparent 60%),
    var(--bg-panel);
}
.sp-callcard .avatar-lg {
  width: 68px; height: 68px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 25px; font-weight: 600; margin-bottom: 4px;
}
.sp-callcard .avatar-lg.conf { font-size: 22px; }
.sp-callcard .party { font-size: 17px; font-weight: 700; text-align: center; }
.sp-callcard .sub { color: var(--text-muted); font-size: 12px; text-align: center; max-width: 100%; overflow-wrap: break-word; }
.sp-flags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 2px; }
.sp-flag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
  padding: 2px 8px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-panel); color: var(--text-muted);
}
.sp-flag.rec { color: var(--err); border-color: color-mix(in srgb, var(--err) 50%, var(--border)); }
.sp-flag.rec i { animation: sp-led-blink 1.2s steps(1) infinite; }
.sp-flag.hold { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, var(--border)); }
.sp-flag.consult { color: var(--info); border-color: color-mix(in srgb, var(--info) 50%, var(--border)); }
.sp-callcard .timer { font-size: 24px; font-variant-numeric: tabular-nums; margin: 4px 0 6px; }
.sp-ctrls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.sp-ctrl {
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg-panel);
  color: var(--text); padding: 9px 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 10.5px;
}
.sp-ctrl i { font-size: 15px; color: var(--text-muted); }
.sp-ctrl:hover { background: var(--row-hover); border-color: var(--accent); }
.sp-ctrl.on { background: color-mix(in srgb, var(--accent) 12%, var(--bg-panel)); border-color: var(--accent); }
.sp-ctrl.on i { color: var(--accent); }
.sp-ctrl.on.recing { border-color: var(--err); background: color-mix(in srgb, var(--err) 10%, var(--bg-panel)); }
.sp-ctrl.on.recing i { color: var(--err); animation: sp-led-blink 1.2s steps(1) infinite; }
.sp-txrow { display: flex; gap: 8px; width: 100%; margin-top: 6px; }
.sp-txrow .sp-callbtn { margin: 0; }

/* transfer target picker */
.sp-transfer {
  border: 1px solid color-mix(in srgb, var(--info) 40%, var(--border));
  border-radius: 10px; padding: 16px;
  display: flex; flex-direction: column; gap: 12px; align-items: stretch;
  background: color-mix(in srgb, var(--info) 6%, var(--bg-panel));
}
.sp-transfer .tx-head { display: flex; gap: 8px; align-items: center; font-weight: 700; }
.sp-transfer .tx-head i { color: var(--info); }
.sp-transfer p { margin: 0; font-size: 12.5px; line-height: 1.5; }
.sp-transfer a.link { align-self: center; }

/* right-hand tabs */
.sp-tabs { display: flex; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.sp-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; font-size: 12px; cursor: pointer;
  border-bottom: 2px solid transparent; color: var(--text-muted);
}
.sp-tab:hover { color: var(--text); }
.sp-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.sp-tab .badge {
  font-size: 10px; font-weight: 700; min-width: 16px; text-align: center;
  padding: 1px 5px; border-radius: 9px; background: var(--accent); color: #fff;
}
.sp-panel { flex: 1; overflow: auto; min-height: 0; }
.sp-panel.cols { display: flex; flex-direction: column; overflow: hidden; }
.sp-scroll { flex: 1; min-height: 0; overflow: auto; }

/* Modal tabs (node resources etc.) — conservative: quiet text, thin underline. */
.mtx-tab {
  padding: 6px 12px; font-size: 12px; cursor: pointer; user-select: none;
  color: var(--text-muted); border-bottom: 1px solid transparent;
  margin-bottom: -1px; /* sit on the tabBar's bottom border */
}
.mtx-tab:hover { color: var(--text); }
.mtx-tab.active { color: var(--text); border-bottom-color: var(--text); }
.mtx-tab i { font-size: 11px; opacity: 0.7; }

/* panel tool rows: search + filter chips */
.sp-toolrow { display: flex; gap: 8px; align-items: center; padding: 8px 2px 6px; flex: 0 0 auto; }
.sp-search {
  flex: 1; height: 30px; padding: 0 10px; box-sizing: border-box;
  border: 1px solid var(--border-input); border-radius: 6px;
  background: var(--bg-input); color: var(--text); font-size: 12px;
}
.sp-chip-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 5px 10px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--bg-panel); color: var(--text-muted);
}
.sp-chip-btn:hover { border-color: var(--accent); color: var(--text); }
.sp-chip-btn.active { background: color-mix(in srgb, var(--accent) 14%, var(--bg-panel)); border-color: var(--accent); color: var(--text); }
.sp-chips { display: flex; gap: 6px; align-items: center; padding: 0 2px 8px; flex: 0 0 auto; }
.sp-txhint {
  display: flex; align-items: center; gap: 8px; flex: 0 0 auto;
  margin: 8px 2px 0; padding: 7px 10px; font-size: 12px; font-weight: 600;
  border: 1px solid color-mix(in srgb, var(--info) 40%, var(--border));
  background: color-mix(in srgb, var(--info) 8%, var(--bg-panel));
  border-radius: 6px;
}
.sp-txhint i { color: var(--info); }

/* contacts (BLF) grid */
.sp-blf { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; padding: 4px 2px; align-content: start; }
.sp-blf-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; flex: 0 0 auto;
  padding: 4px 2px 8px; font-size: 11px; color: var(--text-muted);
}
.sp-blf-bar b { color: var(--text); }
.sp-blf-bar .lg { display: inline-flex; align-items: center; gap: 5px; }
.sp-blf-bar .lg .sw { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.sp-blf-bar .lg .sw.idle { background: var(--ok); }
.sp-blf-bar .lg .sw.busy { background: var(--err); }
.sp-blf-bar .lg .sw.ringing { background: var(--warn); }
.sp-blf-bar .lg .sw.offline { background: var(--border-strong); }
.sp-blf-key {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-left-width: 4px; border-radius: 6px;
  padding: 7px 9px; cursor: pointer; background: var(--bg-panel);
}
.sp-blf-key:hover { background: var(--row-hover); }
.sp-blf-key .k-ext { font-weight: 600; font-variant-numeric: tabular-nums; }
.sp-blf-key .k-name { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-blf-key.idle    { border-left-color: var(--ok); }
.sp-blf-key.on-call { border-left-color: var(--err); }
.sp-blf-key.ringing { border-left-color: var(--warn); animation: blf-blink 0.9s steps(1) infinite; }
.sp-blf-key.dnd     { border-left-color: var(--err); }
.sp-blf-key.offline { border-left-color: var(--border-strong); opacity: 0.6; }
.sp-blf-key .k-state { font-size: 9px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); flex: 0 0 auto; }
.sp-blf-key .k-star { flex: 0 0 auto; padding: 2px 3px; font-size: 12px; color: var(--border-strong); visibility: hidden; }
.sp-blf-key:hover .k-star { visibility: visible; }
.sp-blf-key .k-star:hover { color: var(--warn); }
.sp-blf-key .k-star.on { visibility: visible; color: var(--warn); }
@keyframes blf-blink { 50% { background: color-mix(in srgb, var(--warn) 22%, var(--bg-panel)); } }

/* contacts view switcher (segmented icon control) + sort select */
.sp-viewbtns { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; flex: 0 0 auto; }
.sp-viewbtn {
  width: 32px; height: 28px; border: none; cursor: pointer;
  background: var(--bg-panel); color: var(--text-muted); font-size: 12px;
}
.sp-viewbtn + .sp-viewbtn { border-left: 1px solid var(--border); }
.sp-viewbtn:hover { background: var(--row-hover); color: var(--text); }
.sp-viewbtn.active { background: color-mix(in srgb, var(--accent) 14%, var(--bg-panel)); color: var(--accent); }
.sp-toolrow select.sp-sortsel { width: auto; flex: 0 0 auto; height: 28px; font-size: 12px; padding: 3px 6px; }

/* contacts — list view: one row per extension */
.sp-blf-rows { padding: 4px 2px; }
.sp-blf-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; cursor: pointer;
  border-bottom: 1px solid var(--border-light); border-left: 3px solid transparent;
}
.sp-blf-row:hover { background: var(--row-hover); }
.sp-blf-row .k-ext { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 42px; }
.sp-blf-row .k-name { flex: 1; min-width: 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-blf-row .k-state { font-size: 9px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); flex: 0 0 auto; }
.sp-blf-row .k-star { flex: 0 0 auto; padding: 2px 3px; font-size: 12px; color: var(--border-strong); visibility: hidden; }
.sp-blf-row:hover .k-star { visibility: visible; }
.sp-blf-row .k-star:hover { color: var(--warn); }
.sp-blf-row .k-star.on { visibility: visible; color: var(--warn); }
.sp-blf-row.idle    { border-left-color: var(--ok); }
.sp-blf-row.on-call { border-left-color: var(--err); }
.sp-blf-row.ringing { border-left-color: var(--warn); animation: blf-blink 0.9s steps(1) infinite; }
.sp-blf-row.dnd     { border-left-color: var(--err); }
.sp-blf-row.offline { border-left-color: var(--border-strong); opacity: 0.6; }

/* contacts — lamp wall: dense ext-only tiles, like a hardware attendant console */
.sp-blf-minis { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 5px; padding: 4px 2px; align-content: start; }
.sp-blf-cell {
  position: relative; text-align: center; cursor: pointer;
  border: 1px solid var(--border); border-top: 3px solid var(--border-strong); border-radius: 5px;
  padding: 7px 2px 6px; background: var(--bg-panel);
}
.sp-blf-cell .m-ext { font-weight: 600; font-size: 12px; font-variant-numeric: tabular-nums; }
.sp-blf-cell:hover { background: var(--row-hover); }
.sp-blf-cell .m-fav { position: absolute; top: 3px; right: 3px; font-size: 7px; color: var(--warn); }
.sp-blf-cell.idle    { border-top-color: var(--ok); background: color-mix(in srgb, var(--ok) 5%, var(--bg-panel)); }
.sp-blf-cell.on-call { border-top-color: var(--err); background: color-mix(in srgb, var(--err) 7%, var(--bg-panel)); }
.sp-blf-cell.ringing { border-top-color: var(--warn); animation: blf-blink 0.9s steps(1) infinite; }
.sp-blf-cell.dnd     { border-top-color: var(--err); background: color-mix(in srgb, var(--err) 7%, var(--bg-panel)); }
.sp-blf-cell.offline { border-top-color: var(--border-strong); opacity: 0.55; }

/* recents list */
.sp-recent { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-bottom: 1px solid var(--border-light); cursor: pointer; }
.sp-recent:hover { background: var(--row-hover); }
.sp-recent .r-ico { width: 16px; text-align: center; }
.sp-recent .r-main { flex: 1; min-width: 0; }
.sp-recent .r-party { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-recent .r-num { font-size: 11px; color: var(--text-muted); }
.sp-recent .r-meta { font-size: 11px; color: var(--text-muted); text-align: right; }
.sp-recent.missed .r-party, .sp-recent.missed .r-ico { color: var(--err); }
.sp-recent .r-call { color: var(--text-muted); visibility: hidden; padding: 0 4px; }
.sp-recent:hover .r-call { visibility: visible; color: var(--ok); }

/* voicemail list */
.sp-vm-head { display: flex; align-items: center; gap: 5px; padding: 10px 2px 8px; font-size: 12px; }
.sp-vm { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border-light); position: relative; }
.sp-vm .v-dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; flex: 0 0 auto; }
.sp-vm.new .v-dot { background: var(--accent); }
.sp-vm.new .v-from { font-weight: 700; }
.sp-vm .v-main { flex: 1; min-width: 0; }
.sp-vm .v-from { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-vm .v-num { font-size: 11px; color: var(--text-muted); }
.sp-vm .v-meta { font-size: 11px; color: var(--text-muted); text-align: right; flex: 0 0 auto; }
.sp-icobtn {
  width: 28px; height: 28px; flex: 0 0 auto; cursor: pointer;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-panel); color: var(--text-muted); font-size: 11px;
}
.sp-icobtn:hover { color: var(--text); border-color: var(--accent); }
.sp-icobtn.danger:hover { color: var(--err); border-color: var(--err); }
.sp-vm-prog { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: color-mix(in srgb, var(--accent) 18%, transparent); }
.sp-vm-prog span { display: block; height: 100%; width: 0; background: var(--accent); animation: sp-vm-play linear forwards; }
@keyframes sp-vm-play { from { width: 0; } to { width: 100%; } }

/* in-call DTMF panel */
.sp-dtmf { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 10px; }
.sp-dtmf p { margin: 0; font-size: 12px; }
.sp-dtmf-out {
  min-height: 34px; width: 100%; max-width: 280px; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; letter-spacing: 3px; font-variant-numeric: tabular-nums;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-input);
}

/* settings */
.sp-settings { padding: 4px 2px; }
.sp-settings .section-title { margin: 10px -2px 8px; }
.sp-settings .section-title:first-child { margin-top: 4px; }
.sp-settings .flex select { flex: 1; min-width: 0; }
.sp-micbar {
  flex: 1; height: 10px; min-width: 120px; overflow: hidden;
  border: 1px solid var(--border); border-radius: 5px; background: var(--bg-input);
}
.sp-micbar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), var(--warn)); transition: width 0.06s; }

/* ============================================================== MISC ===== */

.muted { color: var(--text-muted); }
/* .mono kept as a hook but no longer monospace — uses the UI font app-wide.
   tabular-nums keeps figures aligned in data columns. */
.mono { font-family: inherit; font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.flex { display: flex; align-items: center; gap: 7px; }
.empty { text-align: center; color: var(--text-muted); padding: 30px; }

.bar { background: var(--border); height: 9px; overflow: hidden; min-width: 90px; border: 1px solid var(--border); }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.warn > span { background: var(--warn); }
.bar.err > span  { background: var(--err); }

a.link { color: var(--text-link); text-decoration: none; cursor: pointer; }
a.link:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 14px; height: 14px; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border: 3px solid var(--bg-page); border-radius: 7px; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #4a525c; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================== MODAL ==== */

.modal-backdrop {
  position: fixed;
  /* body is zoom-scaled, so fixed/vw/vh map to the *unzoomed* viewport;
     divide by --zoom so the overlay covers the actual visible screen */
  top: 0; left: 0;
  width: calc(100vw / var(--zoom, 1));
  height: calc(100vh / var(--zoom, 1));
  background: rgba(0,0,0,0.35);
  /* Top-anchored (not centered): a modal whose content loads/grows dynamically
     keeps its header at a fixed position and only its bottom edge moves. */
  display: flex; align-items: flex-start; justify-content: center; z-index: 100;
  padding-top: calc(6vh / var(--zoom, 1));
}
.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 3px;          /* same small radius as buttons */
  overflow: hidden;            /* clip the accent head + toolbar foot to the corners */
  box-shadow: 0 3px 14px rgba(0,0,0,0.3);
  /* sizes are zoom-corrected (see .modal-backdrop) */
  width: calc(70vw / var(--zoom, 1));
  max-width: calc(70vw / var(--zoom, 1));
  max-height: calc(88vh / var(--zoom, 1));
  display: flex; flex-direction: column;
}
/* fixed-size softphone modal: capped width (a phone shouldn't sprawl on a big
   monitor), 90% tall; the columns scroll internally */
.modal.modal-softphone {
  width: calc(min(1100px, 88vw) / var(--zoom, 1));
  max-width: calc(min(1100px, 88vw) / var(--zoom, 1));
  height: calc(90vh / var(--zoom, 1));
  max-height: calc(90vh / var(--zoom, 1));
}
.modal.modal-softphone .modal-body { flex: 1; overflow: auto; display: flex; flex-direction: column; }

/* Cross-site dialing matrix */
.modal.modal-wide { width: calc(80vw / var(--zoom, 1)); max-width: calc(80vw / var(--zoom, 1)); }
/* Compact confirmation dialog (confirmModal) — sized to its short message, not the 70vw default. */
.modal.modal-confirm { width: calc(440px / var(--zoom, 1)); max-width: calc(92vw / var(--zoom, 1)); }
/* Single-column account form (e.g. Voice Menu add/edit): a contained width so the section cards
   fill the modal instead of bunching into a narrow column inside the 70vw default. */
.modal.modal-account-form { width: calc(720px / var(--zoom, 1)); max-width: calc(94vw / var(--zoom, 1)); }
.modal-account-form .modal-body > div { min-width: 0; max-width: none; }

/* Add/Edit Customer modal — matches the Add/Edit Extension modal's width (the base .modal 70vw)
   so the .ext-gen-grid cards (Company, Address, Account & Access, User Invite) sit comfortably
   TWO across, exactly like the Extension modal's General Settings pane. Inputs fill their column
   so nothing spills past a narrow card edge (same guard the queue modal uses for its cards). */
.modal.modal-customer-form { width: calc(70vw / var(--zoom, 1)); max-width: calc(70vw / var(--zoom, 1)); }
.modal-customer-form .modal-body > div { min-width: 0; max-width: none; }
.modal-customer-form .ext-gen-grid .form-row > select,
.modal-customer-form .ext-gen-grid .form-row > input[type="text"],
.modal-customer-form .ext-gen-grid .form-row > input[type="email"],
.modal-customer-form .ext-gen-grid .form-row > input[type="tel"],
.modal-customer-form .ext-gen-grid .form-row > input[type="password"] { width: 100%; box-sizing: border-box; }
/* Itemised list inside a confirm (e.g. the extensions being removed). */
.confirm-list {
  list-style: none; margin: 0; padding: 6px 0; max-height: 240px; overflow: auto;
  border-top: 1px solid var(--border-light); border-bottom: 1px solid var(--border-light);
}
.confirm-list li { padding: 2px 4px; font-size: 13px; }
.cs-matrix th, .cs-matrix td { border: 1px solid var(--border); padding: 6px 8px; }
.cs-matrix thead th { background: var(--bg-2, rgba(0,0,0,0.15)); font-weight: 600; white-space: nowrap; }
.cs-matrix tbody th { background: var(--bg-2, rgba(0,0,0,0.08)); white-space: nowrap; }
.cs-matrix td.cs-self { text-align: center; opacity: 0.5; }
.cs-matrix input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
/* Cross-site dialing — flat, square panels matching the platform theme (.kv-panel /
   .section-title). No rounded corners; toolbar-grey header strips; 1px borders. */
.cs-panel { border: 1px solid var(--border); background: var(--bg-panel); }
.cs-panel + .cs-panel { margin-top: 10px; }
/* explainer above the matrix */
.cs-intro { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text); line-height: 1.5; }
.cs-intro > p { margin: 0 0 10px; }
.cs-intro-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cs-intro-h { font-size: 12px; font-weight: 700; margin-bottom: 5px; display: flex; align-items: center; gap: 6px; }
.cs-intro-h i { color: var(--text-muted); }
.cs-intro ul { margin: 0; padding-left: 16px; }
.cs-intro li { margin: 0 0 5px; color: var(--text-muted); }
.cs-intro li b { color: var(--text); font-weight: 600; }
.cs-intro code { font-family: var(--mono, ui-monospace, Menlo, monospace); font-size: 11px;
  background: var(--bg-toolbar); border: 1px solid var(--border); border-radius: 3px; padding: 0 3px; color: var(--text); }
@media (max-width: 720px) { .cs-intro-cols { grid-template-columns: 1fr; } }
/* the matrix table */
.cs-gridwrap { overflow: auto; }
.cs-grid { border-collapse: collapse; width: 100%; }
.cs-grid th, .cs-grid td { border-bottom: 1px solid var(--border-light); border-right: 1px solid var(--border-light); }
.cs-grid tr:last-child th, .cs-grid tr:last-child td { border-bottom: none; }
.cs-grid th:last-child, .cs-grid td:last-child { border-right: none; }
/* column headers (the "to" sites) — toolbar-grey strip, like .section-title */
.cs-grid thead th {
  background: var(--bg-toolbar); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 2; padding: 7px 10px;
  font-size: 11px; font-weight: 700;
}
.cs-corner {
  text-align: left; white-space: nowrap; position: sticky; left: 0; z-index: 3;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px;
  background: var(--bg-toolbar);
}
.cs-colhead { white-space: nowrap; text-align: center; }
/* row header (the "from" site) — uses the kv-row key strip look, sticky left */
.cs-rowhead {
  text-align: left; padding: 7px 10px; vertical-align: middle; white-space: nowrap;
  background: var(--bg-grid-header); position: sticky; left: 0; z-index: 1; min-width: 200px;
}
.cs-grid tbody tr:hover .cs-rowhead { background: var(--bg-toolbar); }
.cs-site-line { display: flex; align-items: center; gap: 7px; min-width: 0; }
/* country-code chip (UK / IE) — flat, square-ish, matches .tag/.feat-plan chips */
.cs-cc {
  flex: 0 0 auto; display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.3px;
  padding: 1px 5px; border-radius: 3px; background: var(--bg-toolbar); border: 1px solid var(--border);
  color: var(--text-muted);
}
.cs-site-name { font-size: 13px; font-weight: 600; }
.cs-rowhead .tag { margin-top: 5px; }
/* toggle cells */
.cs-grid td.cs-cell { text-align: center; padding: 7px; cursor: pointer; transition: background 0.12s; }
.cs-grid td.cs-cell:hover { background: var(--bg-toolbar); }
.cs-grid td.cs-cell.on { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.cs-grid td.cs-self { text-align: center; color: var(--text-muted); background: var(--bg-grid-header); }
/* live relationship map (SVG topology) — flat panel, .section-title header */
.cs-mapwrap { padding: 0; }
.cs-map-svg { display: flex; justify-content: center; padding: 12px 14px 16px; }
.cs-map-svg svg text { pointer-events: none; user-select: none; }
.cs-map-svg .cs-node { cursor: default; transition: opacity .14s; }
.cs-map-svg .cs-link { transition: stroke-opacity .14s, stroke-width .14s; }
/* let the softphone layout fill the tall body; each column scrolls internally */
.modal.modal-softphone .modal-body > .sp-wrap { flex: 1; min-height: 0; }
.modal-head {
  background: var(--accent);
  color: #fff;
  padding: 6px 10px;
  font-weight: 600;
  font-size: 12px;
  display: flex; align-items: center;
  cursor: move; user-select: none;   /* draggable (see openModal) */
}
.modal-head .x { cursor: pointer; opacity: 0.9; padding: 0 4px; }
.modal-head .x:hover { opacity: 1; }
/* Maximize / restore toggle (always present), sits left of the close button. */
.modal-head .modal-max { margin-left: auto; cursor: pointer; opacity: 0.8; padding: 0 5px; font-size: 11px; }
.modal-head .modal-max:hover { opacity: 1; }
.modal-head .modal-max ~ .x { margin-left: 0; }
/* Pin toggle (opts.pinnable): tilted when unpinned, upright when pinned. */
.modal-head .pin { margin-left: auto; cursor: pointer; opacity: 0.7; padding: 0 5px; }
.modal-head .pin:hover { opacity: 1; }
.modal-head .pin .fa-thumbtack { transform: rotate(45deg); transition: transform .15s; }
.modal-head .pin.on { opacity: 1; }
.modal-head .pin.on .fa-thumbtack { transform: none; }
/* When a pin is present, it owns the margin-left:auto; the max button follows it. */
.modal-head .pin ~ .modal-max { margin-left: 4px; }

/* Maximized window: fills the ENTIRE page body — full viewport, no margins, no
   radius. Sizes are zoom-corrected like the other modal widths (see
   .modal-backdrop). Overrides the per-variant width/height via specificity +
   !important; the backdrop's top padding is zeroed so it sits flush at 0,0. */
.modal-backdrop:has(.modal.maximized) { padding-top: 0; }
.modal.maximized {
  width: calc(100vw / var(--zoom, 1)) !important;
  max-width: calc(100vw / var(--zoom, 1)) !important;
  height: calc(100vh / var(--zoom, 1)) !important;
  max-height: calc(100vh / var(--zoom, 1)) !important;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.modal.maximized .modal-body { flex: 1; }
/* Pinned + shown: the backdrop stops dimming/blocking — the page behind stays
   interactive while the modal floats above it (stronger shadow sells the float). */
/* Destructive confirm (confirmModal danger): a near-opaque dark overlay to weight the decision. */
.modal-backdrop.modal-backdrop-danger { background: rgb(5 5 5 / 93%); }
.modal-backdrop.pinned { background: transparent; pointer-events: none; }
.modal-backdrop.pinned .modal { pointer-events: auto; box-shadow: 0 8px 30px rgba(0,0,0,.45); }

/* Pin Bar: docked mini cards for pinned modals, right edge of the page. Click a
   card to show/hide its window; × closes it. The bar exists only while it has
   items (created/removed by openModal). */
#pin-bar {
  position: fixed; right: 0; top: 50%; transform: translateY(-50%);
  z-index: 99;
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 6px;
  background: var(--bg-toolbar);
  border: 1px solid var(--border); border-right: none;
  border-radius: 6px 0 0 6px;
  box-shadow: -2px 2px 10px rgba(0,0,0,.18);
  max-width: 190px;
}
.pin-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px;
  font-size: 11px;
  background: var(--bg-panel); color: var(--text);
  border: 1px solid var(--border-input); border-radius: 3px;
  cursor: pointer; min-width: 150px; max-width: 100%;
}
.pin-item .ti { color: var(--accent); font-size: 11px; flex: none; }
.pin-item .tt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pin-item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-item .sub { font-size: 10px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-item:hover { background: var(--row-hover); }
.pin-item.shown { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.pin-item .x {
  opacity: .5; flex: none;
  width: 15px; height: 15px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px;
}
.pin-item .x:hover { opacity: 1; background: rgba(128, 128, 128, .25); }
/* Optional band between the head and body (e.g. a tab toolbar). A .toolbar child
   already brings its own background + bottom border, so the slot stays unstyled. */
.modal-subhead { flex: none; }
.modal-body { padding: 10px; overflow: auto; }
.modal-foot {
  padding: 8px 10px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; background: var(--bg-toolbar);
}

/* Edit Extension modal: fixed height so switching tabs doesn't resize the modal
   (which would make it re-center and jump vertically). The body fills the modal
   and the pane scrolls internally. */
.modal.modal-ext-edit {
  height: calc(72vh / var(--zoom, 1));
  max-height: calc(88vh / var(--zoom, 1));
}
.modal.modal-ext-edit .modal-body { flex: 1; overflow: hidden; }

/* Edit Extension modal: left sub-nav + right pane. The -10px
   margins pull the split flush to the modal-body edges so the nav meets the
   modal chrome; the pane keeps the original body padding. */
.ext-modal-split {
  display: grid;
  grid-template-columns: 170px 1fr;
  margin: -10px;
  height: calc(100% + 20px);
  min-height: 320px;
}
.ext-modal-split .mtx-subnav { padding: 4px 0; }
.ext-modal-pane { padding: 12px 14px; overflow: auto; }

/* Edit Extension → General Settings: the preview sections flow in two columns
   (CSS columns = masonry, cards never split) so the wide modal isn't one long
   single-column scroll. Identity sits full-width above this grid. */
.ext-gen-grid { columns: 2; column-gap: 12px; }
.ext-gen-grid .settings-card { break-inside: avoid; margin: 0 0 12px; }
.ext-gen-grid .form-row { grid-template-columns: 130px 1fr; }
@media (max-width: 1100px) { .ext-gen-grid { columns: 1; } }

/* Call Queue edit modal: same left-nav + content-pane layout as the Extension modal
   (reuses .ext-modal-split / .ext-modal-pane), but a touch wider + taller because the
   queue has many more option fields per section. */
.modal.modal-queue-edit {
  /* Width inherits the base .modal 70vw (same as the Extension edit modal); only the height
     is fixed so switching tabs doesn't resize/re-center the modal. */
  height: calc(74vh / var(--zoom, 1));
  max-height: calc(90vh / var(--zoom, 1));
}
.modal.modal-queue-edit .modal-body { flex: 1; overflow: hidden; }
.modal-queue-edit .ext-modal-pane .settings-card { margin: 0 0 12px; }
.modal-queue-edit .ext-modal-pane .settings-card:last-child { margin-bottom: 0; }
.modal-queue-edit .form-row { grid-template-columns: 200px 1fr; }
/* Form controls fill their column so fixed pixel widths (e.g. width:200px selects) never spill
   past a card edge — especially in the narrow side-by-side card tracks below. Bare number inputs
   and the "n sec" wrappers keep their natural compact width. */
.modal-queue-edit .form-row > select,
.modal-queue-edit .form-row > input[type="text"],
.modal-queue-edit .form-row > input[type="password"] { width: 100%; box-sizing: border-box; }
/* Two cards side by side within a wide section (Timing/Capacity/Announcements/Advanced). At 70vw
   each half-track is roomy, so the label column matches the single-card panes (180px). */
.cq-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.cq-card-grid .settings-card { margin: 0; min-width: 0; }
.cq-card-grid .form-row { grid-template-columns: 180px 1fr; }
.cq-card-grid .form-row > select { width: 100%; box-sizing: border-box; }
@media (max-width: 980px) { .cq-card-grid { grid-template-columns: 1fr; } }

/* Customer SIP Trunk edit modal: identical layout to the Extension edit modal — left sub-nav +
   content pane, 70vw (inherited from base .modal), fixed height, and the 2-column card masonry
   (reuses .ext-modal-split / .ext-modal-pane / .ext-gen-grid). */
.modal.modal-trunk-edit {
  height: calc(74vh / var(--zoom, 1));
  max-height: calc(90vh / var(--zoom, 1));
}
.modal.modal-trunk-edit .modal-body { flex: 1; overflow: hidden; }
.modal-trunk-edit .form-row > select,
.modal-trunk-edit .form-row > input[type="text"],
.modal-trunk-edit .form-row > input[type="password"],
.modal-trunk-edit .form-row > textarea { width: 100%; box-sizing: border-box; }
/* The card body is inset 12px (set inline in the section() helper). Form rows carry their own
   8px side padding, which would double the inset — zero it so they align with the other content. */
.modal-trunk-edit .settings-card .form-row { padding-left: 0; padding-right: 0; }

/* ====================================================== BOTTOM TASK LOG == */

.mtx-tasklog {
  height: 150px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  /* slightly darker than the content panels so the log reads as a distinct,
     separated band in both themes */
  background: color-mix(in srgb, var(--bg-panel) 92%, #000);
  position: relative;
  flex: 0 0 auto;
}
/* draggable resize handle sitting on the top border */
.mtx-tasklog-resizer {
  position: absolute;
  top: -3px;
  left: 0;
  right: 0;
  height: 6px;
  cursor: ns-resize;
  z-index: 5;
}
.mtx-tasklog-resizer:hover,
body.resizing-tasklog .mtx-tasklog-resizer {
  background: var(--accent);
  opacity: 0.5;
}
body.resizing-tasklog { cursor: ns-resize; user-select: none; }

/* collapsed = only the tabs bar is visible */
.mtx-tasklog.collapsed {
  height: auto !important;
}
.mtx-tasklog.collapsed .grid-wrap { display: none; }

.mtx-tasklog-tabs {
  display: flex; align-items: stretch;
  background: var(--bg-toolbar); border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  cursor: pointer;            /* whole bar toggles collapse */
}
.mtx-tasklog.collapsed .mtx-tasklog-tabs { border-bottom: none; }
.mtx-tasklog-tab {
  padding: 4px 14px; font-size: 12px; cursor: pointer; border-right: 1px solid var(--border);
  display: flex; align-items: center; gap: 7px;
}
.mtx-tasklog-tab.active { background: var(--accent); color: #fff; }

/* count pill inside a task-log tab */
.count-pill {
  font-size: 8.5px;
  font-weight: 600;
  line-height: 12px;
  padding: 0 5px;
  border-radius: 7px;
  background: var(--border);
  color: var(--text);
}
.mtx-tasklog-tab.active .count-pill {
  background: #fff;
  color: var(--accent);
}
.mtx-tasklog .grid-wrap { flex: 1; }

/* slightly smaller, denser text for the task/event grids */
.mtx-tasklog table.grid { font-size: 11px; }
.mtx-tasklog table.grid thead th { font-size: 11px; }
.mtx-tasklog table.grid tbody td,
.mtx-tasklog table.grid thead th { height: 22px; }
.mtx-tasklog .tag { font-size: 11px; }

/* collapse/expand chevron on the right of the tabs bar */
.mtx-tasklog-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 30px;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
  font-size: 11px;
}
.mtx-tasklog-toggle:hover { color: var(--accent); background: var(--row-hover); }

/* ---- Toast notifications ------------------------------------------------ */
#toast-root {
  position: fixed;
  top: calc(var(--header-h, 38px) + 12px);
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 220px;
  max-width: 360px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border-radius: 5px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  animation: toast-in 0.18s ease-out;
}
.toast.leaving { animation: toast-out 0.18s ease-in forwards; }
.toast .toast-ico { margin-top: 1px; color: #fff; }
/* Solid colour fills so success/error stand out clearly. */
.toast.ok   { background: var(--ok); }
.toast.err  { background: var(--err); }
.toast.info { background: var(--info); }
.toast .toast-msg { flex: 1; line-height: 1.35; }
.toast .toast-x { cursor: pointer; color: rgba(255, 255, 255, 0.75); margin-left: 4px; }
.toast .toast-x:hover { color: #fff; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-8px); } }

/* Wide modal — used by the template/playbook editor. */
.modal.wide { width: min(820px, 92vw); max-width: 92vw; }
.modal.wide textarea { box-sizing: border-box; }

/* Email-template editor: a roomy two-column (editor | live preview) modal. Width
   matches the default modal (e.g. "Add Node") — 70vw — with a taller fixed height. */
.modal.modal-email-tpl {
  width: calc(70vw / var(--zoom, 1));
  max-width: calc(70vw / var(--zoom, 1));
  height: calc(86vh / var(--zoom, 1));
  max-height: calc(90vh / var(--zoom, 1));
}
.modal.modal-email-tpl .modal-body { padding: 0; flex: 1; overflow: hidden; }

/* Two equal columns, each scrolls on its own; a divider between them. */
.et-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 100%;
  min-height: 0;
}
.et-col { min-height: 0; overflow: auto; padding: 16px 18px; }
.et-col + .et-col { border-left: 1px solid var(--border); background: var(--bg-toolbar); }

/* Section heading inside the editor — small caps label with a hairline under it. */
.et-label {
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 8px;
}
.et-col .et-label:not(:first-child) { margin-top: 18px; }

/* Field rows: stacked label + control, comfortable spacing. */
.et-field { margin-bottom: 12px; }
.et-field > label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 4px;
}
.et-field input[type=text],
.et-field textarea {
  width: 100%; box-sizing: border-box;
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font-size: 13px;
}
.et-field textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.5; resize: vertical; }
.et-field input[type=text]:focus,
.et-field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(74,144,217,.18); }
.et-help { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Inline name + key + enabled on one row to save vertical space. */
.et-row { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 12px; align-items: end; }
.et-row .et-field { margin-bottom: 0; }

/* Preview panel: a framed "card" so the rendered email reads as a real message. */
.et-preview-subject {
  font-size: 14px; font-weight: 600; color: var(--text);
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px;
  padding: 9px 11px; word-break: break-word; min-height: 18px;
}
.et-preview-frame {
  width: 100%; height: 320px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.et-preview-text {
  white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; line-height: 1.5; color: var(--muted);
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px;
  padding: 9px 11px; margin: 0; max-height: 160px; overflow: auto;
}

/* ---- Audit action badges (audit log table + modal banner) -----------------
   Outlined uppercase chips, matching the .task-status idiom: a crisp full-colour
   border + bold small-caps text, no fill. Each tone sets --c (the state colour). */
.audit-badge {
  --c: var(--text-muted);
  display: inline-flex; align-items: center;
  font-size: 10.5px; font-weight: 600; line-height: 12px;
  padding: 1px 7px; border-radius: 3px;
  color: var(--c);
  border: 1px solid var(--c);
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.audit-badge--ok      { --c: var(--ok); }
.audit-badge--err     { --c: var(--err); }
.audit-badge--info    { --c: var(--info); }
.audit-badge--accent  { --c: var(--accent); }
.audit-badge--warn    { --c: var(--warn); }
.audit-badge--neutral { --c: var(--text-muted); }

/* Dark theme: the info blue is a touch dark on dark panels — lift it (mirrors task-status). */
html[data-theme="dark"] .audit-badge--info { --c: #6cb0f0; }

/* Failed audit events (success=0): tint the row light red so they stand out.
   Deepen slightly on hover so the hover affordance survives the tint. */
table.grid tbody tr.audit-row-fail { background: rgba(203,42,42,0.08); }
table.grid tbody tr.audit-row-fail:hover { background: rgba(203,42,42,0.15); }
html[data-theme="dark"] table.grid tbody tr.audit-row-fail { background: rgba(203,42,42,0.16); }
html[data-theme="dark"] table.grid tbody tr.audit-row-fail:hover { background: rgba(203,42,42,0.24); }

/* ---- Audit event detail modal (openAuditModal) ----------------------------
   A banner headlining the action/outcome, a key/value metadata panel, then the
   before/after JSON snapshots (side-by-side when both exist). */
/* Size the card to the content instead of the default 70vw. */
.modal.modal-audit { width: calc(760px / var(--zoom, 1)); max-width: calc(94vw / var(--zoom, 1)); }
.audit-modal {
  display: flex; flex-direction: column; gap: 14px;
  min-width: 0;
}
/* Banner: the at-a-glance summary line. A left accent + tinted background keys
   off the outcome (green for success, red for failure). */
.audit-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); border-left: 3px solid var(--text-muted);
  background: var(--bg-toolbar);
}
.audit-banner.ok   { border-left-color: var(--ok); }
.audit-banner.fail { border-left-color: var(--err); }
.audit-banner-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.audit-entity { font-weight: 600; font-size: 13px; color: var(--text); }

/* Metadata panel: narrower key column than the default kv-panel since the
   labels here are short. */
.audit-meta { border-radius: 8px; overflow: hidden; }
.audit-meta .kv-row { grid-template-columns: 120px 1fr; }

/* Snapshots */
.audit-snaps { display: grid; grid-template-columns: 1fr; gap: 12px; }
.audit-snaps.dual { grid-template-columns: 1fr 1fr; }
.audit-snap { display: flex; flex-direction: column; min-width: 0; }
.audit-snap-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px;
}
.audit-json { max-height: 280px; }
.audit-empty {
  display: flex; align-items: center; gap: 8px;
  padding: 14px; border: 1px dashed var(--border); border-radius: 8px;
  color: var(--text-muted); font-size: 12px;
}
@media (max-width: 680px) {
  .audit-snaps.dual { grid-template-columns: 1fr; }
}

/* ---- CodeMirror theme bridge ----------------------------------------------
   The email-template editor swaps its HTML/text/JSON textareas for CodeMirror.
   Frame each instance like the app's other inputs and map colours to the theme
   vars so it tracks light/dark. Sizing is per-instance via .CodeMirror inline
   height set in the cmEditor() helper. */
.CodeMirror {
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-input); color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; line-height: 1.5;
}
.CodeMirror.cm-focused, .CodeMirror-focused { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(74,144,217,.18); }
/* Resizable editor: square the bottom corners so the native resize grip isn't clipped,
   and nudge the cursor hint at the very bottom edge. */
.CodeMirror[style*="resize"] { border-bottom-right-radius: 0; border-bottom-left-radius: 0; }
.CodeMirror-gutters { background: var(--bg-toolbar); border-right: 1px solid var(--border); }
.CodeMirror-linenumber { color: var(--muted); }
.CodeMirror-cursor { border-left: 1px solid var(--text); }
.CodeMirror-selected { background: rgba(74,144,217,.20) !important; }
.CodeMirror-matchingbracket { color: var(--accent) !important; font-weight: 700; border-bottom: 1px solid var(--accent); }
/* Fold marker (the “…” for a collapsed div/tag) + the gutter fold arrows. */
.CodeMirror-foldmarker { color: var(--accent); background: rgba(74,144,217,.14); border-radius: 3px; padding: 0 4px; cursor: pointer; }
.CodeMirror-foldgutter { width: 14px; }
.CodeMirror-foldgutter-open, .CodeMirror-foldgutter-folded { color: var(--muted); cursor: pointer; }
.CodeMirror-foldgutter-open:hover, .CodeMirror-foldgutter-folded:hover { color: var(--accent); }

/* Syntax token colours — light theme defaults; dark overrides below. */
.cm-s-default .cm-tag { color: #22863a; }
.cm-s-default .cm-attribute { color: #6f42c1; }
.cm-s-default .cm-string { color: #032f62; }
.cm-s-default .cm-bracket { color: #6a737d; }
.cm-s-default .cm-comment { color: #6a737d; font-style: italic; }
.cm-s-default .cm-property, .cm-s-default .cm-keyword { color: #d73a49; }
.cm-s-default .cm-number { color: #005cc5; }
[data-theme="dark"] .cm-s-default .cm-tag { color: #7ee787; }
[data-theme="dark"] .cm-s-default .cm-attribute { color: #d2a8ff; }
[data-theme="dark"] .cm-s-default .cm-string { color: #a5d6ff; }
[data-theme="dark"] .cm-s-default .cm-bracket { color: #8b949e; }
[data-theme="dark"] .cm-s-default .cm-comment { color: #8b949e; }
[data-theme="dark"] .cm-s-default .cm-property,
[data-theme="dark"] .cm-s-default .cm-keyword { color: #ff7b72; }
[data-theme="dark"] .cm-s-default .cm-number { color: #79c0ff; }

/* ---- Cluster "alerts disabled" warning banner -----------------------------
   Amber strip across the top of the cluster page when Email Alerts are off. */
.cluster-alert-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 8px; font-size: 13px; line-height: 1.4;
  background: color-mix(in srgb, var(--warn, #d29922) 14%, var(--bg-panel));
  border-bottom: 1px solid color-mix(in srgb, var(--warn, #d29922) 45%, var(--border));
  color: var(--text);
}
.cluster-alert-banner .cab-ico { color: var(--warn, #d29922); font-size: 15px; }

/* ---- Status filter chips (Email Queue, reusable) --------------------------
   A pill that holds a label + a small count badge, vertically centred with even
   padding. Active state fills with the accent. */
.chip-bar { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; padding: 4px 4px 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 5px 0 10px;
  border: 1px solid var(--border); border-radius: 999px;
  background: transparent; color: var(--text);
  font-size: 10px; cursor: pointer;
  user-select: none; transition: background .12s, border-color .12s, color .12s;
}
.chip:hover { border-color: var(--accent); }
/* Label: own line-height + flex box so its text centres on the chip's mid-line
   exactly like the count badge (no baseline drift between the two). */
.chip > span:first-child { display: inline-flex; align-items: center; line-height: 1; }
.chip .chip-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 15px; height: 15px; padding: 0 5px; box-sizing: border-box;
  border-radius: 999px; background: var(--bg-toolbar); color: var(--muted);
  font-size: 9px; font-weight: 600; line-height: 1;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.active .chip-count { background: rgba(255,255,255,.22); color: #fff; }

/* ---- Select2 theme bridge -------------------------------------------------
   Map Select2's default chrome onto the app's CSS vars so the lock-exception
   multi-select matches the (light/dark) theme + input sizing. Only used there. */
.select2-container { width: 100% !important; }
.select2-container--default .select2-selection--multiple {
  background: var(--bg-input); border: 1px solid var(--border-input);
  border-radius: 3px; min-height: 28px; font-size: 12px;
}
.select2-container--default.select2-container--focus .select2-selection--multiple {
  border-color: var(--accent);
}
/* Lay the chips + search field out as a centered, wrapping flex row so there's even
   top/bottom spacing regardless of how many chips wrap to a new line. */
.select2-container--default .select2-selection--multiple .select2-selection__rendered {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  padding: 3px 5px; margin: 0; min-height: 26px; box-sizing: border-box;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
  background: var(--sel); border: 1px solid var(--border-input); color: var(--text);
  border-radius: 3px; font-size: 12px; margin: 0;   /* spacing comes from the flex gap */
  line-height: 18px;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
  color: var(--text-muted);
}
.select2-container--default .select2-search--inline .select2-search__field {
  color: var(--text); margin: 0;   /* flex-aligned with the chips */
}
/* dropdown panel */
.select2-dropdown {
  background: var(--bg-panel); border: 1px solid var(--border); color: var(--text); font-size: 12px;
}
.select2-container--default .select2-results__option {
  color: var(--text);
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background: var(--accent); color: #fff;
}
.select2-container--default .select2-results__option[aria-selected=true] {
  background: var(--row-hover);
}
.select2-search--dropdown .select2-search__field {
  background: var(--bg-input); border: 1px solid var(--border-input); color: var(--text);
}
.select2-container--default .select2-selection--multiple .select2-selection__clear { color: var(--text-muted); }

/* ---- Order DDIs modal: browse (left) + cart (right) ---------------------- */
.order-ddi-split {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 12px;
  min-height: 360px;
}
.order-ddi-browse { display: flex; flex-direction: column; min-width: 0; }
/* a tickable available-number row */
/* Available-numbers results: scrollable 3-column grid of tickable numbers. */
.ddi-results {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px 8px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px;
  align-content: start;
}
.ddi-results .empty { grid-column: 1 / -1; }   /* placeholder/message spans all columns */
.ddi-num {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 6px; border-radius: 3px;
  cursor: pointer; font-size: 12px; min-width: 0;
}
.ddi-num .mono { overflow: hidden; text-overflow: ellipsis; }
.ddi-num:hover { background: var(--row-hover); }
/* cart column */
.order-ddi-cart {
  display: flex; flex-direction: column;
  border: 1px solid var(--border-input); border-radius: 4px;
  background: var(--bg-panel); overflow: hidden;
}
.order-ddi-cart-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px; font-weight: 700; font-size: 12px;
  background: var(--bg-toolbar); border-bottom: 1px solid var(--border);
}
.ddi-cart-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px; border-bottom: 1px solid var(--border); font-size: 12px;
}
.order-ddi-cart-foot {
  padding: 8px; border-top: 1px solid var(--border); margin-top: auto;
}
.order-ddi-cart-foot .btn { width: 100%; justify-content: center; }

/* ---- Audio recorder modal (openAudioRecorder) — flat panels matching the theme ---- */
/* Size the modal to the recorder content instead of the default 70vw (which leaves the
   narrow recorder floating in a too-wide shell). */
.modal.modal-rec { width: calc(600px / var(--zoom, 1)); max-width: calc(94vw / var(--zoom, 1)); }
/* When editing, the modal widens to fit the studio's right column. */
.modal.modal-rec.modal-rec-wide { width: calc(80vw / var(--zoom, 1)); max-width: calc(80vw / var(--zoom, 1)); }
/* Two-column body: left = details + player, right = edit studio. The right column is hidden
   until the body has .editing (toggled by the Edit button), at which point it takes ~half. */
.rec-cols { display: flex; gap: 12px; align-items: flex-start; }
.rec-col-left { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.rec-col-right { flex: 0 0 0; width: 0; overflow: hidden; }
.rec-modal.editing .rec-col-right { flex: 1 1 0; width: auto; overflow: visible; }
.rec-col-right .rec-studio { margin: 0; }
.rec-modal { display: flex; flex-direction: column; gap: 12px; }

/* The capture hero: big timer + a pulsing dot while live, centred in a panel. */
.rec-stage {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 20px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-toolbar);
}
.rec-timer { font-size: 30px; font-weight: 700; letter-spacing: 1px; color: var(--text); font-variant-numeric: tabular-nums; }
.rec-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--text-muted);
  display: inline-block; flex: none;
}
.rec-dot.live { background: var(--err); animation: rec-pulse 1.1s ease-in-out infinite; }
@keyframes rec-pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.8); } }
.rec-status { font-size: 12px; color: var(--text-muted); min-height: 16px; text-align: center; }
.rec-controls { display: flex; gap: 8px; align-items: center; justify-content: center; }

/* Section panel — same chrome as .kv-panel + .section-title used by the other modals. */
.rec-panel { border: 1px solid var(--border); border-radius: 4px; background: var(--bg-panel); overflow: hidden; }
.rec-panel > .section-title { display: flex; align-items: center; gap: 6px; }
.rec-panel-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; }

/* Waveform + trim handles. */
.rec-wave {
  position: relative; user-select: none; touch-action: none;
  border: 1px solid var(--border); border-radius: 4px; background: var(--bg-input);
}
.rec-wave canvas { display: block; width: 100%; height: 88px; border-radius: 4px; }
.rec-shade { position: absolute; top: 0; bottom: 0; background: rgba(0,0,0,0.42); pointer-events: none; border-radius: 4px; }
/* A wider hit area (18px) than the visual line/tab so the handles are easy to grab, including at
   the very edges (no overflow:hidden clipping them, no negative margin pushing them out). */
.rec-handle {
  position: absolute; top: 0; bottom: 0; width: 18px; transform: translateX(-50%); cursor: ew-resize;
  display: none; z-index: 3;
}
.rec-handle::before {                       /* the thin vertical line, centred in the 18px hit area */
  content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: currentColor;
}
.rec-handle::after {                        /* the grab tab, centred on the line */
  content: ''; position: absolute; left: 4px; top: 50%; width: 10px; height: 24px; margin-top: -12px;
  background: currentColor; border-radius: 3px; box-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.rec-handle.start { color: var(--ok); }
.rec-handle.end { color: var(--err); }
.rec-selbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.rec-selbar .rec-sel { color: var(--text); font-variant-numeric: tabular-nums; }
.rec-selbar .rec-hint { color: var(--text-muted); }
/* Native <audio controls> bar — themed to blend with the studio panels. The built-in control
   chrome can't be fully restyled cross-browser, but `color-scheme` flips Chromium/WebKit to its
   matching light/dark control set, and the wrapper bg/border/radius make it sit in the panel. */
.rec-wave-audio {
  width: 100%; height: 38px; outline: none; display: block;
  border-radius: 6px; background: var(--bg-input);
  color-scheme: light;
}
html[data-theme="dark"] .rec-wave-audio {
  color-scheme: dark;                 /* Chrome/Edge/Safari render the DARK native audio UI */
  background: var(--bg-input);
}
/* Chromium: nudge the control bar to the panel colour so it isn't a flat light-grey block. */
html[data-theme="dark"] .rec-wave-audio::-webkit-media-controls-panel { background: var(--bg-input); }
html[data-theme="dark"] .rec-wave-audio::-webkit-media-controls-enclosure { background: var(--bg-input); border-radius: 6px; }

/* Player waveform: the click-to-seek track shows a playhead line + a shaded played region. */
.rec-wave-player { cursor: pointer; }
.rec-played {
  position: absolute; top: 0; bottom: 0; left: 0; width: 0;
  background: rgba(74, 144, 217, 0.16); pointer-events: none;
}
.rec-playhead {
  position: absolute; top: 0; bottom: 0; left: 0; width: 2px; margin-left: -1px;
  background: var(--accent); pointer-events: none; z-index: 2;
}
.rec-wave.editing { cursor: default; }

/* ---- Edit Studio ---- */
.modal.modal-rec-studio { width: calc(680px / var(--zoom, 1)); max-width: calc(96vw / var(--zoom, 1)); }
.rec-studio .section-title { display: flex; align-items: center; gap: 6px; }
.rec-studio-tools { margin-left: auto; display: flex; gap: 6px; }
.rec-fx-hint { font-size: 11px; color: var(--text-muted); line-height: 1.4; }

/* Effect controls: a two-up grid of slider rows. */
/* One effect per row so each slider gets the full column width (the studio is a narrower right
   column now). The slider (1fr) sits between a fixed label and the value/reset. */
.rec-fx { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.rec-fx-row { display: grid; grid-template-columns: 150px 1fr 56px 22px; align-items: center; gap: 10px; }
@media (max-width: 560px) { .rec-fx-row { grid-template-columns: 110px 1fr 50px 22px; gap: 6px; } }
.rec-fx-label { font-size: 12px; color: var(--text); }
.rec-fx-range { width: 100%; min-width: 90px; accent-color: var(--accent); }
.rec-fx-val { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; text-align: right; }
.rec-fx-reset {
  border: none; background: none; cursor: pointer; color: var(--text-muted);
  padding: 2px; line-height: 1; border-radius: 3px;
}
.rec-fx-reset:hover { color: var(--text); background: var(--row-hover); }
.rec-fx-reset .fa-solid { font-size: 10px; }
.rec-fx-check {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text); padding: 2px 0;
}
.rec-fx-check input { accent-color: var(--accent); }

/* ============================================================================
   CDR call-detail modal (mock drill-down): Time-column link, tabbed modal,
   RTCP quality section, recordings player, PCAP SIP ladder + packet inspector.
   ============================================================================ */
a.cdr-time { color: var(--text-link); text-decoration: none; }
a.cdr-time:hover { text-decoration: underline; }

.modal.modal-cdr {
  width: calc(1280px / var(--zoom, 1));
  max-width: calc(96vw / var(--zoom, 1));
  height: calc(88vh / var(--zoom, 1));
}
.modal.modal-cdr .modal-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; padding: 0; }
.modal.modal-cdr .modal-foot .grow { flex: 1; }
.modal.modal-cdr .modal-foot { gap: 8px; align-items: center; }

/* tab strip (also reused for the packet inspector's Message/SIP/SDP tabs) */
.cdrm-tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--bg-toolbar); flex: 0 0 auto; }
.cdrm-tab {
  display: flex; align-items: center; gap: 6px; padding: 8px 14px;
  font-size: 12px; color: var(--text-muted); cursor: pointer; user-select: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.cdrm-tab:hover { color: var(--text); }
.cdrm-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.cdrm-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.cdrm-pane.details { display: block; overflow: auto; padding: 12px; }

/* details tab */
.cdrm-sec { margin-bottom: 18px; }
.cdrm-sec-h {
  display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 12px;
  padding: 5px 0; border-bottom: 1px solid var(--border-light); margin-bottom: 8px;
}
.cdrm-sec-h .ico { color: var(--accent); }
.cdrm-sec-h .grow { flex: 1; }
.cdrm-kv { display: grid; grid-template-columns: 150px minmax(0, 1fr) 150px minmax(0, 1fr); gap: 2px 14px; font-size: 12px; }
.cdrm-kv .k { color: var(--text-muted); padding: 3px 0; }
.cdrm-kv .v { padding: 3px 0; min-width: 0; overflow-wrap: anywhere; }
.cdrm-copy { cursor: copy; }
.cdrm-copy:hover { text-decoration: underline; }
.cdrm-path { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 2px 0; }
.cdrm-path .chip { border: 1px solid var(--border); background: var(--bg-toolbar); border-radius: 3px; padding: 3px 10px; font-size: 11px; font-weight: 600; }
.cdrm-path .chip .sub { color: var(--text-muted); font-size: 10px; font-weight: 400; }
.cdrm-stats { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 10px; margin-bottom: 10px; }

/* recordings rows */
.cdrm-rec {
  display: flex; align-items: center; gap: 12px; padding: 7px 10px;
  border: 1px solid var(--border-light); border-radius: 3px; margin-bottom: 6px;
}
.cdrm-rec > .ico { color: var(--accent); font-size: 16px; }
.cdrm-rec .nm { font-weight: 600; font-size: 12px; }
.cdrm-rec .meta { color: var(--text-muted); font-size: 10px; }
.cdrm-prog { flex: 1; max-width: 300px; height: 6px; border-radius: 3px; background: var(--border-light); overflow: hidden; }
.cdrm-prog span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }

/* PCAP tab: ladder on the left, packet inspector on the right */
.cdrp-split { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.cdrp-left { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.cdrp-bar {
  display: flex; align-items: center; gap: 12px; padding: 6px 10px;
  border-bottom: 1px solid var(--border); background: var(--bg-toolbar); font-size: 11px;
}
.cdrp-bar .grow { flex: 1; }
.cdrp-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.cdrp-scroll { flex: 1; overflow: auto; background: #f2f9f8; }
.cdrp-canvas { position: relative; }
.cdrp-hosts {
  position: sticky; top: 0; z-index: 4; height: 62px;
  background: var(--bg-panel); border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
.cdrp-host {
  position: absolute; top: 8px; width: 160px; text-align: center;
  border: 1px solid var(--border); border-radius: 3px; background: var(--bg-toolbar); padding: 5px 6px;
}
.cdrp-host .hn { font-weight: 600; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cdrp-host .hip { color: var(--text-muted); font-size: 10px; }
.cdrp-rows { position: relative; padding: 6px 0 14px; }
.cdrp-life { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px dashed #b3c8c5; }
.cdrp-row { position: relative; cursor: pointer; }
.cdrp-row:hover { background: rgba(74, 144, 217, .07); }
.cdrp-row.sel { background: var(--sel); }
.cdrp-box { position: absolute; top: 5px; bottom: 5px; }
.cdrp-m { text-align: center; font-weight: 700; font-size: 12px; }
.cdrp-m.m-inv { color: #1d5fbf; }
.cdrp-m.m-ok { color: var(--ok); }
.cdrp-m.m-err { color: var(--err); }
.cdrp-m.m-prov { color: #4c4c4c; }
.cdrp-m.m-req { color: #1c1c1c; }
.cdrp-prev, .cdrp-meta {
  text-align: center; font-size: 10px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 12px;
}
.cdrp-line { position: absolute; left: 0; right: 0; bottom: 9px; border-top: 2px solid #2aa79b; }
.cdrp-line::after { content: ''; position: absolute; top: -5px; border: 4px solid transparent; }
.cdrp-line.r::after { right: -1px; border-left: 7px solid #2aa79b; border-right: 0; }
.cdrp-line.l::after { left: -1px; border-right: 7px solid #2aa79b; border-left: 0; }
.cdrp-row.sel .cdrp-line { border-top-color: #0e7c72; }
.cdrp-row.sel .cdrp-line.r::after { border-left-color: #0e7c72; }
.cdrp-row.sel .cdrp-line.l::after { border-right-color: #0e7c72; }
.cdrp-port { position: absolute; bottom: 1px; font-size: 10px; color: var(--text-muted); }
.cdrp-port.pl { left: -36px; width: 32px; text-align: right; }
.cdrp-port.pr { right: -36px; width: 32px; text-align: left; }

/* packet inspector panel */
.cdrp-detail {
  flex: 0 0 440px; max-width: 46%; border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden; background: var(--bg-panel);
}
.cdrp-d-head { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 12px; }
.cdrp-d-body { flex: 1; overflow: auto; padding: 10px; }
.cdrp-hint {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 12px; padding: 24px; text-align: center;
}
.cdrp-raw {
  margin: 0; font-size: 11px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, 'Cascadia Mono', Consolas, Menlo, monospace;
}
.cdrp-reqline {
  font-weight: 700; font-size: 11px; padding: 5px 6px; margin-bottom: 6px;
  background: var(--bg-toolbar); border: 1px solid var(--border-light); border-radius: 3px;
  word-break: break-all;
}
table.cdrp-hdrs { width: 100%; border-collapse: collapse; font-size: 11px; }
.cdrp-hdrs td { padding: 3px 6px; border-bottom: 1px solid var(--border-light); vertical-align: top; }
.cdrp-hdrs td.hn { color: var(--text-muted); white-space: nowrap; }
.cdrp-hdrs td.hv { word-break: break-all; }
