/* =========================================================================
   Atheer v2 · BRIDGE SKIN
   Upgrades ALL existing v1 pages to the Yeastar-grade v2 look WITHOUT
   touching page logic. Maps legacy class names (.btn, .table, .badge,
   .search-input, .form-control, .page, .page-content...) onto v2 tokens.
   Loaded LAST so it wins over refine.css / saas-polish.css.
   Targets BOTH button conventions: btn--primary (BEM) and btn-primary.
   Scope: only legacy classes — never touches .at-* (v2 native) components.
   ========================================================================= */

/* ── Page container rhythm ──────────────────────────────────────────── */
.page, .page-content {
  font-family: var(--at-font-base);
}

/* ── Buttons (both .btn--x and .btn-x conventions) ──────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  font-family: var(--at-font-base);
  font-size: 13px; font-weight: 600; line-height: 1;
  border-radius: 4px;
  border: 1px solid var(--at-border-strong, #cbd5e1);
  background: var(--at-surface-1, #fff);
  color: var(--at-text-primary, #0f172a);
  cursor: pointer;
  transition: background .12s, border-color .12s, box-shadow .12s, transform .06s;
  box-shadow: 0 1px 1px rgba(15,23,42,.03);
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--at-surface-2, #f1f5f9); border-color: var(--at-border-hover, #94a3b8); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(15,98,254,.18); }
.btn .icon, .btn .material-symbols-rounded { font-size: 18px; }

.btn--sm, .btn-sm { height: 32px; padding: 0 11px; font-size: 12px; }
.btn--xs, .btn-xs {
  height: 28px; width: auto; min-width: 28px; padding: 0 8px; font-size: 12px;
  border-radius: 4px;
}
.btn--lg, .btn-lg { height: 40px; padding: 0 18px; font-size: 15px; }

.btn--primary, .btn-primary {
  background: var(--at-accent, #0f62fe); border-color: var(--at-accent, #0f62fe);
  color: #fff; box-shadow: 0 1px 2px rgba(15,98,254,.18);
}
.btn--primary:hover, .btn-primary:hover {
  background: var(--at-accent-hover, #0c54d7); border-color: var(--at-accent-hover, #0c54d7);
  box-shadow: 0 2px 4px rgba(15,98,254,.28);
}
.btn--danger, .btn-danger {
  background: var(--at-danger, #dc2626); border-color: var(--at-danger, #dc2626); color: #fff;
}
.btn--danger:hover, .btn-danger:hover { filter: brightness(.95); }
.btn--danger-ghost, .btn-danger-ghost, .btn-danger-outline {
  background: transparent; border-color: transparent; color: var(--at-danger, #dc2626);
  box-shadow: none;
}
.btn--danger-ghost:hover, .btn-danger-ghost:hover { background: var(--at-danger-bg, #fef2f2); }
.btn--outline, .btn-outline, .btn--secondary, .btn-secondary {
  background: var(--at-surface-1, #fff); border-color: var(--at-border-strong, #cbd5e1);
  color: var(--at-text-primary);
}
.btn--ghost, .btn-ghost {
  background: transparent; border-color: transparent; color: var(--at-text-secondary, #334155);
  box-shadow: none;
}
.btn--ghost:hover, .btn-ghost:hover { background: var(--at-surface-2, #f1f5f9); color: var(--at-text-primary); }
.btn:disabled, .btn[disabled] {
  opacity: 1; background: var(--at-surface-1, #fff) !important;
  border-color: var(--at-border, #e2e8f0) !important;
  color: var(--atheer-gray-400, #94a3b8) !important;
  cursor: not-allowed; box-shadow: none !important;
}

/* ── Inputs / selects / search ──────────────────────────────────────── */
.search-input, .form-control, input.input,
input[type="text"].form-control, input[type="email"].form-control,
input[type="tel"].form-control, input[type="number"].form-control,
input[type="password"].form-control, input[type="search"].form-control,
select.form-control, textarea.form-control {
  height: 36px; padding: 0 12px;
  font-family: var(--at-font-base); font-size: 13px;
  color: var(--at-text-primary, #0f172a);
  background: var(--at-surface-1, #fff);
  border: 1px solid var(--at-border-strong, #cbd5e1);
  border-radius: 4px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
textarea.form-control { height: auto; min-height: 90px; padding: 8px 12px; }
.search-input:focus, .form-control:focus {
  border-color: var(--at-accent, #0f62fe);
  box-shadow: 0 0 0 3px rgba(15,98,254,.15);
}
.search-input::placeholder, .form-control::placeholder { color: var(--at-text-muted, #64748b); }

/* ── Tables ─────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--at-surface-1, #fff);
  border: 1px solid var(--at-border, #e2e8f0);
  border-radius: 12px;
  overflow: hidden;
  overflow-x: auto;
}
.table { width: 100%; border-collapse: collapse; font-size: 13px; font-family: var(--at-font-base); }
.table thead th {
  text-align: start; padding: 11px 14px;
  background: var(--at-surface-2, #f3f5f8);
  border-bottom: 1.5px solid var(--at-border, #e6e9ee);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
  color: var(--at-text-muted, #7d8690);
  white-space: nowrap;
}
.table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--at-border, #e2e8f0);
  color: var(--at-text-primary, #0f172a);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--at-surface-0, #f8fafc); }

/* ── Badges ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-family: var(--at-font-base); font-size: 11.5px; font-weight: 600;
  line-height: 1.4; border: 1px solid transparent; white-space: nowrap;
}
.badge--success, .badge-success, .badge--ok { color: var(--at-success,#10b981); background: var(--at-success-bg,#ecfdf5); border-color: var(--at-success,#10b981); }
.badge--info, .badge-info       { color: var(--at-info,#0284c7);    background: var(--at-info-bg,#eff6ff);    border-color: var(--at-info,#0284c7); }
.badge--warning, .badge-warning { color: var(--at-warning,#f59e0b); background: var(--at-warning-bg,#fffbeb); border-color: var(--at-warning,#f59e0b); }
.badge--error, .badge-error, .badge--danger { color: var(--at-danger,#dc2626); background: var(--at-danger-bg,#fef2f2); border-color: var(--at-danger,#dc2626); }
.badge--neutral, .badge-neutral { color: var(--at-text-secondary,#334155); background: var(--at-surface-2,#f1f5f9); border-color: var(--at-border,#e2e8f0); }

/* ── Cards / surfaces commonly used in v1 ──────────────────────────── */
.card, .panel, .surface-card {
  background: var(--at-surface-1, #fff);
  border: 1px solid var(--at-border, #e2e8f0);
  border-radius: 12px;
}

/* ── Page header (v1 helper output) ────────────────────────────────── */
.page-header, .page__header {
  margin-bottom: 18px; padding-bottom: 14px;
  border-bottom: 1px solid var(--at-border, #e2e8f0);
}
.page-header h1, .page-header .page-title, .page__title {
  font-size: 20px; font-weight: 700; letter-spacing: -.2px;
  color: var(--at-text-primary, #0f172a);
}

/* ── Breadcrumb (v1) ───────────────────────────────────────────────── */
.breadcrumb, .page-breadcrumb { font-size: 12.5px; color: var(--at-text-muted, #64748b); }
.breadcrumb a, .page-breadcrumb a { color: var(--at-text-muted, #64748b); text-decoration: none; }
.breadcrumb a:hover { color: var(--at-text-link, #0c54d7); }

/* ── Empty / loading / error states (v1 helpers) ──────────────────── */
.empty-state, .loading-state, .error-state {
  padding: 48px 24px; text-align: center; color: var(--at-text-secondary, #334155);
  font-family: var(--at-font-base);
}
.empty-state .material-symbols-rounded, .empty-state .icon { color: var(--at-text-muted, #64748b); }

/* ── Tabs (v1) ──────────────────────────────────────────────────────── */
.tabs, .tab-nav { border-bottom: 1px solid var(--at-border, #e2e8f0); }
.tab, .tab-item {
  font-family: var(--at-font-base); font-size: 13.5px; font-weight: 600;
  color: var(--at-text-secondary, #334155);
}
.tab--active, .tab-item.active, .tab[aria-selected="true"] {
  color: var(--at-accent, #0f62fe); border-bottom-color: var(--at-accent, #0f62fe);
}

/* =========================================================================
   v2 Bridge · EXTENDED COVERAGE
   Covers the dominant real conventions found across all 87 pages:
   .input (193×), .select, .data-table + *-table, badge--accent, btn-icon,
   stat-card, kpi-*, form-card, panel. Never touches .at-* (v2 native).
   ========================================================================= */

/* ── Inputs: the dominant .input + .select ─────────────────────────── */
input.input, select.input, textarea.input,
.input:not(.at-input):not(button),
select.select, .select:not(.at-input) {
  height: 36px; padding: 0 12px;
  font-family: var(--at-font-base); font-size: 13px;
  color: var(--at-text-primary, #0f172a);
  background: var(--at-surface-1, #fff);
  border: 1px solid var(--at-border-strong, #cbd5e1);
  border-radius: 4px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; min-height: 90px; padding: 8px 12px; line-height: 1.5; }
input.input:focus, select.input:focus, textarea.input:focus,
.input:focus:not(.at-input), select.select:focus {
  border-color: var(--at-accent, #0f62fe);
  box-shadow: 0 0 0 3px rgba(15,98,254,.15);
}
input.input::placeholder, textarea.input::placeholder, .input::placeholder { color: var(--at-text-muted, #64748b); }

/* ── ALL data tables (data-table, containers-table, backups-table, …) ─ */
.page table:not(.at-grid__table),
.page-content table:not(.at-grid__table),
table.data-table, table.stable {
  width: 100%; border-collapse: collapse;
  font-size: 13px; font-family: var(--at-font-base);
  background: var(--at-surface-1, #fff);
}
.page table:not(.at-grid__table) thead th,
.page-content table:not(.at-grid__table) thead th,
table.data-table thead th {
  text-align: start; padding: 11px 14px;
  background: var(--at-surface-2, #f3f5f8);
  border-bottom: 1.5px solid var(--at-border, #e6e9ee);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
  color: var(--at-text-muted, #7d8690); white-space: nowrap;
}
.page table:not(.at-grid__table) tbody td,
.page-content table:not(.at-grid__table) tbody td,
table.data-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--at-border, #e2e8f0);
  color: var(--at-text-primary, #0f172a); vertical-align: middle;
}
.page table:not(.at-grid__table) tbody tr:last-child td,
table.data-table tbody tr:last-child td { border-bottom: none; }
.page table:not(.at-grid__table) tbody tr:hover td,
.page-content table:not(.at-grid__table) tbody tr:hover td,
table.data-table tbody tr:hover td { background: var(--at-surface-0, #f8fafc); }

/* wrap any standalone data-table in a rounded card border */
table.data-table { border: 1px solid var(--at-border, #e2e8f0); border-radius: 12px; overflow: hidden; }

/* ── Badge variants (single + double dash + extras) ─────────────────── */
.badge--accent, .badge-accent, .badge-primary, .badge--primary { color: var(--at-accent,#0f62fe); background: var(--at-accent-soft-bg,#e0ebff); border-color: var(--at-accent,#0f62fe); }
.badge-secondary, .badge--secondary, .badge-gray, .badge--gray { color: var(--at-text-secondary,#334155); background: var(--at-surface-2,#f1f5f9); border-color: var(--at-border,#e2e8f0); }
.badge-green, .badge--green, .badge--owner { color: var(--at-success,#10b981); background: var(--at-success-bg,#ecfdf5); border-color: var(--at-success,#10b981); }
.badge--xs { padding: 2px 7px; font-size: 11px; }
.badge-dot::before, .badge--dot::before { content:""; width:6px; height:6px; border-radius:50%; background: currentColor; display:inline-block; }

/* ── Button extras: icon-only, close, warning, cancel, accent ───────── */
.btn-icon, .btn--icon {
  width: 32px; min-width: 32px; padding: 0; justify-content: center;
}
.btn-icon.btn-sm, .btn--icon.btn--sm { width: 30px; min-width: 30px; }
.btn-warning, .btn--warning { background: var(--at-warning,#f59e0b); border-color: var(--at-warning,#f59e0b); color: #fff; }
.btn--cancel, .btn-cancel { background: transparent; border-color: var(--at-border-strong,#cbd5e1); color: var(--at-text-secondary,#334155); box-shadow: none; }
.btn--accent, .btn-accent { background: var(--at-accent,#0f62fe); border-color: var(--at-accent,#0f62fe); color: #fff; }
.btn-close, .btn--close {
  width: 32px; min-width: 32px; padding: 0; justify-content: center;
  background: transparent; border-color: transparent; box-shadow: none;
  color: var(--at-text-muted,#64748b);
}
.btn-close:hover, .btn--close:hover { background: var(--at-surface-2,#f1f5f9); color: var(--at-text-primary); }

/* ── Cards: stat-card, form-card, panel, kpi tiles ──────────────────── */
.stat-card, .form-card, .panel, .kpi-tile {
  background: var(--at-surface-1, #fff);
  border: 1px solid var(--at-border, #e2e8f0);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.stat-card:hover, .kpi-tile:hover { border-color: var(--at-border-hover, #94a3b8); }
.kpi-label { font-size: 12px; color: var(--at-text-muted,#64748b); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--at-text-primary,#0f172a); line-height: 1.1; }

/* ── Misc text utilities used in v1 ─────────────────────────────────── */
.text-muted  { color: var(--at-text-muted, #64748b); }
.text-small  { font-size: 12px; }
code, .text-mono { font-family: var(--at-font-mono, monospace); }

/* =========================================================================
   v2 Bridge · FORMS · TABS · SETTINGS · PERMISSIONS (internal pages)
   Makes every edit form / settings page / permission page look Yeastar-grade
   (e.g. "Edit Extension" 9-tab workspace) — CSS only, no logic touched.
   ========================================================================= */

/* ── Tab bar (edit-extension style: horizontal, accent underline) ───── */
.tab-bar, .tabs, .tabs__nav, .tab-nav {
  display: flex; flex-wrap: wrap; gap: 2px;
  border-bottom: 1.5px solid var(--at-border, #e2e8f0);
  margin-bottom: 20px; padding-bottom: 0;
}
.tabs__item, .tab, .tab-item {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 16px;
  background: transparent; border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--at-font-base); font-size: 13.5px; font-weight: 600;
  color: var(--at-text-secondary, #334155);
  cursor: pointer; white-space: nowrap;
  transition: color .12s, border-color .12s;
  margin-bottom: -1.5px;
}
.tabs__item .icon, .tab .icon { font-size: 18px; }
.tabs__item:hover, .tab:hover { color: var(--at-text-primary, #0f172a); }
.tabs__item.is-active, .tab.is-active, .tab--active, .tab[aria-selected="true"],
.tab-item.active {
  color: var(--at-accent, #0f62fe);
  border-bottom-color: var(--at-accent, #0f62fe);
}
.tabs__item.is-active .icon { color: var(--at-accent, #0f62fe); }
.tabs__item--planned, .tabs__item:disabled {
  color: var(--at-text-disabled, #94a3b8); cursor: default;
}
.tabs__item--planned:hover { color: var(--at-text-disabled, #94a3b8); }

/* ── Form sections (cards, like Yeastar grouped settings) ───────────── */
.form-section, .settings-section, .form-card {
  background: var(--at-surface-1, #fff);
  border: 1px solid var(--at-border, #e2e8f0);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.form-section__title, .form-section > h3, .section-title,
.settings-section__title, .form-card__title {
  font-size: 15px; font-weight: 700; margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--at-border, #e2e8f0);
  color: var(--at-text-primary, #0f172a);
}

/* ── Form grid: label + control rows (Yeastar two-column form) ─────── */
.form-grid {
  display: grid; grid-template-columns: minmax(160px, 220px) 1fr;
  gap: 14px 20px; align-items: center;
}
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; gap: 6px 0; } }

.form-field, .form-group, .field {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 14px; min-width: 0;
}
.form-field:last-child, .form-group:last-child { margin-bottom: 0; }
.form-label, .field-label, .form-field > label, .form-group > label {
  font-size: 13px; font-weight: 600;
  color: var(--at-text-primary, #0f172a); line-height: 1.4;
}
.form-hint, .field-hint, .form-help { font-size: 12px; color: var(--at-text-muted, #64748b); line-height: 1.5; }
.form-error, .field-error { font-size: 12px; color: var(--at-danger, #dc2626); font-weight: 500; }
.required::after, label[data-required]::after { content: " *"; color: var(--at-danger, #dc2626); }

/* constrain form inputs to a comfortable width (not full page) */
.form-field input.input, .form-field select.input, .form-field .input,
.form-group input.input, .form-group select.input,
.form-grid input.input, .form-grid select.input, .form-grid .input {
  max-width: 420px;
}
.form-field input[type="number"].input, .form-grid input[type="number"].input { max-width: 160px; }

/* ── Form actions (footer buttons) ─────────────────────────────────── */
.form-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding-top: 16px; margin-top: 8px;
  border-top: 1px solid var(--at-border, #e2e8f0);
}

/* ── Checkbox / radio (accent — settings toggles) ──────────────────── */
input[type="checkbox"].checkbox, input[type="checkbox"], .checkbox input,
input[type="radio"], .radio input {
  width: 16px; height: 16px; accent-color: var(--at-accent, #0f62fe);
  cursor: pointer; vertical-align: middle;
}
.checkbox, .checkbox-label, .radio, .radio-label {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--at-text-primary, #0f172a); cursor: pointer;
}

/* ── Generic sections / key-value rows (permissions, details) ──────── */
.section { margin-bottom: 20px; }
.kv-row, .kvrow, .detail-row, .info-row, .setting-item, .perm-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 11px 0;
  border-bottom: 1px solid var(--at-border, #f1f5f9);
  font-size: 13px;
}
.kv-row:last-child, .detail-row:last-child, .setting-item:last-child { border-bottom: none; }
.kv-row > .label, .detail-row > .label, .setting-item > .label,
.kv-row dt, .detail-row dt { color: var(--at-text-muted, #64748b); }
.kv-row > .value, .detail-row > .value, .kv-row dd, .detail-row dd {
  color: var(--at-text-primary, #0f172a); font-weight: 600; margin: 0;
}

/* ── Toggle-switch look for boolean settings rows (where used) ─────── */
.toggle-switch, .switch {
  position: relative; display: inline-block; width: 40px; height: 22px;
}
.toggle-switch input, .switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch .slider, .switch .slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--at-border-strong, #cbd5e1); border-radius: 999px;
  transition: background .2s;
}
.toggle-switch .slider::before, .switch .slider::before {
  content: ""; position: absolute; height: 16px; width: 16px;
  inset-inline-start: 3px; top: 3px; background: #fff; border-radius: 50%;
  transition: transform .2s;
}
.toggle-switch input:checked + .slider, .switch input:checked + .slider { background: var(--at-accent, #0f62fe); }
.toggle-switch input:checked + .slider::before, .switch input:checked + .slider::before { transform: translateX(18px); }
[dir="rtl"] .toggle-switch input:checked + .slider::before,
[dir="rtl"] .switch input:checked + .slider::before { transform: translateX(-18px); }

/* .form-input (used in CDR filters, queue AI, etc.) */
input.form-input, select.form-input, textarea.form-input, .form-input:not(.at-input) {
  height: 36px; padding: 0 12px; font-family: var(--at-font-base); font-size: 13px;
  color: var(--at-text-primary); background: var(--at-surface-1);
  border: 1px solid var(--at-border-strong); border-radius: 4px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
textarea.form-input { height: auto; min-height: 80px; padding: 8px 12px; }
.form-input:focus { border-color: var(--at-accent); box-shadow: 0 0 0 3px rgba(15,98,254,.15); }
.filters-bar { background: var(--at-surface-1) !important; border-color: var(--at-border) !important; border-radius: 8px !important; }

/* =========================================================================
   v2 Bridge · SHARED COMPONENTS (Modal · Drawer · Field · Tabs · DataTable)
   Restyles the output classes of components.js so EVERY modal, drawer, form
   field, tab, and table across ALL 59 pages adopts the v2 Yeastar look —
   comprehensively, with zero logic change. Loaded last → overrides components.css.
   ========================================================================= */

/* ── Modal (component.js Modal) ─────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--at-z-modal, 3000);
  background: var(--at-overlay, rgba(15,23,42,.45));
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: at-fade-in var(--at-duration-normal, .2s) var(--at-ease-out);
}
.modal {
  background: var(--at-surface-1, #fff);
  border-radius: var(--at-radius-lg, 12px);
  box-shadow: var(--at-shadow-xl, 0 16px 40px rgba(15,23,42,.18));
  width: 100%; max-width: 540px; max-height: calc(100vh - 32px);
  display: flex; flex-direction: column; overflow: hidden;
  font-family: var(--at-font-base);
  animation: at-modal-up 240ms var(--at-ease-out);
}
.modal--sm { max-width: 420px; } .modal--lg { max-width: 760px; } .modal--xl { max-width: 1040px; }
.modal__header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--at-border, #e2e8f0);
}
.modal__title { margin: 0; font-size: var(--at-text-md, 15px); font-weight: 700; color: var(--at-text-primary); }
.modal__body { padding: 18px 20px; overflow-y: auto; color: var(--at-text-secondary); font-size: var(--at-text-base, 13.5px); line-height: 1.55; }
.modal__footer {
  display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px;
  border-top: 1px solid var(--at-border, #e2e8f0); background: var(--at-surface-0, #f8fafc);
}

/* ── Drawer (component.js Drawer) ──────────────────────────────────── */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: var(--at-z-drawer, 2000);
  background: var(--at-overlay, rgba(15,23,42,.45));
  display: flex; justify-content: flex-end;
  animation: at-fade-in var(--at-duration-fast, .12s) var(--at-ease-out);
}
.drawer {
  width: 100%; max-width: 460px; height: 100vh; background: var(--at-surface-1, #fff);
  display: flex; flex-direction: column; font-family: var(--at-font-base);
  box-shadow: var(--at-shadow-xl);
  /* The panel is a SIBLING of .drawer-backdrop (not a child), so it needs a z-index
     ABOVE the backdrop (var(--at-z-drawer,2000)); otherwise the full-screen backdrop
     paints on top and intercepts every click on the panel → each click just closes the
     drawer and nothing inside (Full Guide / Contact support / notifications) is usable. */
  position: fixed;
  z-index: calc(var(--at-z-drawer, 2000) + 1);
}
.drawer__header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--at-border, #e2e8f0);
}
.drawer__title { margin: 0; font-size: var(--at-text-md, 15px); font-weight: 700; color: var(--at-text-primary); }
.drawer__body { flex: 1; padding: 16px 20px; overflow-y: auto; }
.drawer__footer {
  display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px;
  border-top: 1px solid var(--at-border, #e2e8f0); background: var(--at-surface-0, #f8fafc);
}

/* ── icon-btn (used in modals/drawers/rows) ────────────────────────── */
.icon-btn {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; border-radius: var(--at-radius-sm, 6px);
  color: var(--at-text-muted, #64748b); cursor: pointer; transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--at-surface-2, #f1f5f9); color: var(--at-text-primary); }
.icon-btn .icon, .icon-btn .material-symbols-rounded { font-size: 18px; }

/* ── Field (component.js Field) ────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--at-text-primary); }
.field__control { display: flex; align-items: center; }
.field__input {
  width: 100%; height: 36px; padding: 0 12px; font-family: var(--at-font-base); font-size: 13px;
  color: var(--at-text-primary); background: var(--at-surface-1, #fff);
  border: 1px solid var(--at-border-strong, #cbd5e1); border-radius: 4px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
textarea.field__input { height: auto; min-height: 84px; padding: 8px 12px; }
.field__input:focus { border-color: var(--at-accent, #0f62fe); box-shadow: 0 0 0 3px rgba(15,98,254,.15); }
.field__hint { font-size: 12px; color: var(--at-text-muted, #64748b); }

/* ── Tabs component: .tab + .is-active (in addition to .tabs__item) ── */
.tabs .tab, .tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 11px 16px;
  background: transparent; border: none; border-bottom: 2px solid transparent;
  font-family: var(--at-font-base); font-size: 13.5px; font-weight: 600;
  color: var(--at-text-secondary, #334155); cursor: pointer; white-space: nowrap;
  margin-bottom: -1.5px; transition: color .12s, border-color .12s;
}
.tabs .tab:hover { color: var(--at-text-primary); }
.tabs .tab.is-active, .tab.is-active {
  color: var(--at-accent, #0f62fe); border-bottom-color: var(--at-accent, #0f62fe);
}

/* ── DataTable component: .table-wrapper / .table-empty ────────────── */
.table-wrapper {
  background: var(--at-surface-1, #fff); border: 1px solid var(--at-border, #e2e8f0);
  border-radius: 12px; overflow: hidden; overflow-x: auto;
}
.table-empty { padding: 40px 24px; text-align: center; color: var(--at-text-muted, #64748b); font-family: var(--at-font-base); }

/* ── KPICard (component.js) ────────────────────────────────────────── */
.kpi-card, .kpicard {
  background: var(--at-surface-1, #fff); border: 1px solid var(--at-border, #e2e8f0);
  border-radius: 12px; padding: 18px 20px;
}
.kpi-card__value, .kpicard__value { font-size: 26px; font-weight: 700; color: var(--at-text-primary); line-height: 1.1; }
.kpi-card__label, .kpicard__label { font-size: 12px; color: var(--at-text-muted); font-weight: 600; }

/* ── Toast (component.js) — align with v2 ──────────────────────────── */
.toast { font-family: var(--at-font-base); border-radius: 8px; box-shadow: var(--at-shadow-lg); }

/* ── Dashboard Yeastar layout: 2-col main+rail collapses on narrow screens ── */
@media (max-width: 980px) {
  .dash-2col { grid-template-columns: 1fr !important; }
}
/* KPI strip tiles: even widths, consistent with Yeastar top row */
.dash-top-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

/* ── UNIFY ALL TABLES — Yeastar-grade skin for custom *-table classes AND
   bare <table> in page content (covers ~33 legacy pages). AtheerDataGrid
   tables are excluded so they keep their own richer styling. ───────────── */
[class*="-table"]:not(.at-grid__table):not(.at-grid),
.page table:not(.at-grid__table),
.at-card table:not(.at-grid__table),
.dash-card table:not(.at-grid__table) {
  width: 100%; border-collapse: collapse; font-size: 13px; font-family: var(--at-font-base, inherit);
}
[class*="-table"]:not(.at-grid__table) thead th,
.page table:not(.at-grid__table) thead th,
.at-card table:not(.at-grid__table) thead th,
.dash-card table:not(.at-grid__table) thead th {
  padding: 11px 14px; font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: .4px; color: var(--at-text-muted, #7d8690);
  background: var(--at-surface-2, #f3f5f8); border-bottom: 1.5px solid var(--at-border, #e6e9ee);
  text-align: start; white-space: nowrap;
}
[class*="-table"]:not(.at-grid__table) tbody td,
.page table:not(.at-grid__table) tbody td,
.at-card table:not(.at-grid__table) tbody td,
.dash-card table:not(.at-grid__table) tbody td {
  padding: 11px 14px; border-bottom: 1px solid var(--at-border, #eef1f4); vertical-align: middle;
}
[class*="-table"]:not(.at-grid__table) tbody tr:hover td,
.page table:not(.at-grid__table) tbody tr:hover td,
.at-card table:not(.at-grid__table) tbody tr:hover td {
  background: var(--at-surface-0, #f8fafc);
}

/* ════════════════════════════════════════════════════════════════════════
   Route editor widgets (Inbound / Outbound) — Yeastar-grade
   ════════════════════════════════════════════════════════════════════════ */
.at-routeform { display: flex; flex-direction: column; gap: 18px; max-width: 1120px; }

/* ── Titled section ── */
.at-fsec {
  background: var(--at-surface-1, #fff);
  border: 1px solid var(--at-border, #e6e9ee);
  border-radius: 12px; overflow: hidden;
}
.at-fsec__head { padding: 16px 20px 0; }
.at-fsec__title { margin: 0; font-size: 15px; font-weight: 700; color: var(--at-text-primary, #1f2937); }
.at-fsec__sub { margin: 4px 0 0; font-size: 12px; color: var(--at-text-muted, #7d8690); }
.at-fsec__body { padding: 16px 20px 20px; }
.at-fsec__body .form-row { margin: 0; }
.at-fsec__subtitle { font-size: 12px; font-weight: 600; color: var(--at-text-muted, #7d8690);
  text-transform: uppercase; letter-spacing: .3px; margin: 0 0 10px; }

/* ── Dual-list transfer ── */
.at-xfer { display: grid; grid-template-columns: 1fr 48px 1fr auto; gap: 14px; align-items: stretch; }
.at-xfer__panel {
  border: 1px solid var(--at-border, #e6e9ee); border-radius: 10px;
  background: var(--at-surface-0, #fbfcfe); display: flex; flex-direction: column; min-height: 320px; overflow: hidden;
}
.at-xfer__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--at-border, #eef1f4);
  background: var(--at-surface-2, #f3f5f8);
}
.at-xfer__head-left { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--at-text-primary, #1f2937); cursor: pointer; }
.at-xfer__head-right { font-size: 12px; color: var(--at-text-muted, #7d8690); }
.at-xfer__search { position: relative; padding: 10px 12px 8px; }
.at-xfer__search-input {
  width: 100%; height: 34px; padding: 0 32px 0 12px; font-size: 13px;
  border: 1px solid var(--at-border, #e1e5ea); border-radius: 8px;
  background: var(--at-surface-1, #fff); color: var(--at-text-primary, #1f2937);
}
[dir="rtl"] .at-xfer__search-input { padding: 0 12px 0 32px; }
.at-xfer__search-ic { position: absolute; inset-inline-end: 22px; top: 18px; color: var(--at-text-muted, #9aa3ad); font-size: 18px; pointer-events: none; }
.at-xfer__cols {
  display: grid; padding: 6px 14px; gap: 8px; align-items: center;
  border-bottom: 1px solid var(--at-border, #eef1f4); background: var(--at-surface-1, #fff);
}
.at-xfer__col { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--at-text-muted, #7d8690); }
.at-xfer__body { flex: 1; overflow-y: auto; max-height: 300px; }
.at-xfer__row {
  display: grid; gap: 8px; align-items: center; padding: 9px 14px; cursor: pointer;
  border-bottom: 1px solid var(--at-border, #f1f4f7); font-size: 13px; color: var(--at-text-primary, #1f2937);
  transition: background .12s ease;
}
.at-xfer__row:hover { background: var(--at-accent-soft, #eef5fe); }
.at-xfer__cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.at-xfer__cell--cb { overflow: visible; }
.at-xfer__mono { font-family: var(--at-font-mono, monospace); font-size: 12px; }
.at-xfer__empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  height: 100%; min-height: 220px; color: var(--at-text-muted, #aeb6bf); font-size: 13px;
}
.at-xfer__empty .icon { font-size: 40px; opacity: .5; }
.at-xfer__mid, .at-xfer__order { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.at-xfer__order { justify-content: flex-start; padding-top: 56px; }
.at-xfer__arrow {
  width: 36px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--at-border, #d8dde3); border-radius: 8px; cursor: pointer;
  background: var(--at-surface-1, #fff); color: var(--at-text-secondary, #4b5563); transition: all .12s ease;
}
.at-xfer__arrow:hover { background: var(--at-accent, #1278e0); border-color: var(--at-accent, #1278e0); color: #fff; }
.at-xfer__arrow:active { transform: scale(.96); }

/* ── Pattern grid table ── */
.at-pgt { border: 1px solid var(--at-border, #e6e9ee); border-radius: 10px; overflow: hidden; background: var(--at-surface-1, #fff); }
.at-pgt__row { display: grid; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--at-border, #f1f4f7); }
.at-pgt__head { background: var(--at-surface-2, #f3f5f8); }
.at-pgt__head .at-pgt__cell { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--at-text-muted, #7d8690); }
.at-pgt__req { color: var(--at-danger, #e5484d); }
.at-pgt__cell .input { width: 100%; height: 36px; }
.at-pgt__ops { display: flex; align-items: center; }
.at-pgt__del {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--at-danger, #e5484d); transition: all .12s ease;
}
.at-pgt__del:hover { background: var(--at-danger-soft, #fdecec); }
.at-pgt__empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 28px; color: var(--at-text-muted, #aeb6bf); font-size: 13px; border-bottom: 1px solid var(--at-border, #f1f4f7);
}
.at-pgt__empty .icon { font-size: 36px; opacity: .5; }
.at-pgt__add { display: flex; justify-content: center; padding: 10px; }
.at-pgt__addbtn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 16px; font-size: 13px; font-weight: 600;
  border: none; background: transparent; color: var(--at-accent, #1278e0); cursor: pointer; border-radius: 8px;
}
.at-pgt__addbtn:hover { background: var(--at-accent-soft, #eef5fe); }

@media (max-width: 820px) {
  .at-xfer { grid-template-columns: 1fr; }
  .at-xfer__mid { flex-direction: row; justify-content: center; }
  .at-xfer__order { flex-direction: row; justify-content: center; padding-top: 0; }
}

/* ─────────────────────────────────────────────────────────────────────────
   Trunk editor (pages/trunks.js) — clean single-column Yeastar layout.
   The trunk forms append `.form-section` CARDS as direct children of a
   `<form class="form-grid">`. The default `.form-grid` is a 2-column grid
   which mangles those cards into grid cells (the "scattered / misaligned"
   complaint). Inside the trunk tab body we force a single vertical column
   with consistent spacing so every section is a clean full-width block.
   ───────────────────────────────────────────────────────────────────── */
.form-card > form.form-grid {
  display: block;            /* override the 2-col grid → vertical flow      */
  max-width: 960px;
  margin: 0 auto;
}
.form-card > form.form-grid > .form-section {
  display: block;
  margin: 0 0 24px;          /* consistent 24px rhythm between section cards */
  padding: 22px 24px;
}
.form-card > form.form-grid > .form-section:last-of-type { margin-bottom: 0; }

/* Fields inside a trunk section stack as a tidy single column. */
.form-card > form.form-grid .form-fields {
  display: flex; flex-direction: column; gap: 16px;
}
.form-card > form.form-grid .form-fields > .form-field { margin-bottom: 0; }

/* Inputs/selects: comfortable, aligned, not full-bleed. */
.form-card > form.form-grid .form-field input,
.form-card > form.form-grid .form-field select,
.form-card > form.form-grid .form-field textarea {
  max-width: 480px; width: 100%;
}
.form-card > form.form-grid .form-field input[type="number"] { max-width: 200px; }

/* Section heading inside trunk forms. */
.form-card > form.form-grid .form-section-title {
  font-size: 14px; font-weight: 700; margin: 0 0 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--at-border, #e2e8f0);
  color: var(--at-text-primary, #0f172a);
}

/* Checkbox groups: tidy vertical list with breathing room. */
.form-card > form.form-grid .checkbox-group {
  display: flex; flex-direction: column; gap: 12px;
}
.form-card > form.form-grid .checkbox-group .checkbox-label {
  display: flex; align-items: center; gap: 8px;
}

/* Type/info row + action rows. */
.form-card > form.form-grid .form-info-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.form-card > form.form-grid .form-actions-row {
  display: flex; gap: 12px; flex-wrap: wrap;
}

/* The codec dual-list sits flush inside its section card. */
.form-card > form.form-grid .at-xfer { margin-top: 4px; }

/* Footer actions: right-aligned, clear separation. */
.form-card > form.form-grid .form-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  padding-top: 20px; margin-top: 8px;
  border-top: 1px solid var(--at-border, #e2e8f0);
}


/* ── Consistent spacing between stacked form sections (Yeastar gaps) ── */
.at-fsec + .at-fsec { margin-top: 16px; }

/* ── Themed native <select> dropdowns (Yeastar parity) ─────────────────────
 * The OS renders the <option> popup; CSS can theme it via accent-color (the
 * highlight/checkmark, was OS-blue → now the Atheer accent) plus option
 * background/text that follow the active theme (light/dark). Applies to every
 * select across all stages. */
select, select.form-control, select.input, .form-control select {
  accent-color: var(--at-accent, #1278e0);
}
select option, select.form-control option, select.input option {
  background-color: var(--at-surface-1, #ffffff);
  color: var(--at-text-primary, #1f2937);
}
select option:checked, select.form-control option:checked {
  background-color: var(--at-accent-soft-bg, #e7f3fc);
  color: var(--at-accent, #1278e0);
  font-weight: 600;
}

/* Native <select> popup follows the app theme (fixes dark OS dropdown on light theme). */
:root[data-theme="light"] select,
:root[data-dafa-theme="light"] select,
.at-shell select, select.form-control, select.at-input { color-scheme: light; accent-color: var(--at-accent, #1278e0); }
:root[data-theme="dark"] select,
:root[data-dafa-theme="dark"] select { color-scheme: dark; accent-color: var(--at-accent, #1278e0); }
select.form-control option, select.at-input option { background: var(--at-surface, #ffffff); color: var(--at-text, #1f2430); }

/* Animated device-status icons (Online Status column). Connected devices pulse
   gently (live "movement"); .is-ringing shakes the handset during an active call. */
@keyframes at-dev-pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.16); opacity: .72; } }
.at-cell-devices__ic[data-active="true"] {
  color: var(--at-accent, #1278e0);
  animation: at-dev-pulse 2s ease-in-out infinite;
  transition: color .15s ease;
}
@keyframes at-dev-ring {
  0%,100% { transform: rotate(0); } 15% { transform: rotate(-14deg); } 30% { transform: rotate(11deg); }
  45% { transform: rotate(-8deg); } 60% { transform: rotate(6deg); } 75% { transform: rotate(-3deg); }
}
.at-cell-devices__ic.is-ringing,
.at-cell-devices__ic[data-incall="true"] {
  color: var(--at-success, #16a34a);
  animation: at-dev-ring .55s ease-in-out infinite;
  transform-origin: 50% 30%;
}
.at-cell-devices__ic { cursor: default; }
@media (prefers-reduced-motion: reduce) {
  .at-cell-devices__ic[data-active="true"], .at-cell-devices__ic.is-ringing, .at-cell-devices__ic[data-incall="true"] { animation: none; }
}

/* ── Trunk editor (Edit & Add): stack sections full-width single-column, NOT the
   global 2-col .form-grid (which scattered Type/Codecs/Proxy/Account-Mgmt cards).
   Fields INSIDE each section keep their own .form-fields grid. ───────────── */
form.trunk-edit-form,
form.trunk-create-form {
  display: block !important;
  grid-template-columns: none !important;
  max-width: 980px; margin: 0 auto;
}
form.trunk-edit-form > *,
form.trunk-create-form > * { margin-bottom: 24px; }
form.trunk-edit-form > *:last-child,
form.trunk-create-form > *:last-child { margin-bottom: 0; }
/* Type/identity strip: slim full-width row, not a floating left card */
form.trunk-edit-form > .form-section:first-child,
form.trunk-create-form > .form-section:first-child { }
