/* ============================================================
   NIR PBX — Main Stylesheet
   design.gov.ua + PBX industry best practices (3CX/FreePBX)
   ============================================================ */

/* === Reset === */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
*:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--color-text);
  background: var(--color-bg-secondary);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-link); text-decoration: underline; }
a:hover { color: var(--color-link-hover); }
a:visited { color: var(--color-link-visited); }
a:focus-visible { outline: 3px solid var(--color-focus); outline-offset: var(--focus-offset); }
/* Prevent visited-link color from bleeding into nav, buttons, badges */
.nav-item, .nav-item:visited, .nav-item:hover { color: var(--sidebar-text); text-decoration: none; }
.nav-item.active, .nav-item.active:visited { color: var(--sidebar-text); }
.btn:visited, .btn-outline:visited { color: inherit; }
.ext-badge:visited, .dept-badge:visited, .cdr-rec a:visited { color: inherit; }

/* === App Layout === */
#app { display: flex; height: 100vh; overflow: hidden; }
#main-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
#content {
  flex: 1; overflow-y: auto; padding: var(--space-lg) var(--space-xl);
  scroll-behavior: smooth;
}
/* Custom scrollbar */
#content::-webkit-scrollbar { width: 6px; }
#content::-webkit-scrollbar-track { background: transparent; }
#content::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
#content::-webkit-scrollbar-thumb:hover { background: var(--color-text-secondary); }

/* ============================================================
   SIDEBAR — gov.ua dark blue gradient (per design system)
   Design code lives in css/variables.css → --sidebar-bg
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column; height: 100vh; flex-shrink: 0;
  transition: width 0.25s ease;
}
.sidebar-logo {
  padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.15);
  display: flex; align-items: center; gap: 12px;
}
.logo-icon {
  width: 44px; height: 44px; background: var(--color-accent);
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 22px; font-weight: 700;
  color: var(--color-text); flex-shrink: 0;
}
.sidebar-brand { flex: 1; min-width: 0; overflow: hidden; }
.logo-title { font-size: 16px; font-weight: 700; color: var(--sidebar-text); white-space: nowrap; }
.logo-sub { font-size: var(--font-size-caption); color: var(--sidebar-text-dim); white-space: nowrap; }

.sidebar-toggle {
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--sidebar-text);
  width: 32px; height: 32px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.2s;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.20); }

.sidebar-nav { flex: 1; padding: var(--space-sm); overflow-y: auto; overflow-x: hidden; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }
.nav-section {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
  color: rgba(255,255,255,0.50); padding: var(--space-md) 12px var(--space-xs);
  white-space: nowrap;
}
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: 4px; color: rgba(255,255,255,0.92);
  text-decoration: none;
  /* Larger font for readability per user request */
  font-size: 16px; font-weight: 500;
  transition: all 0.15s ease; cursor: pointer; margin: 1px 0;
  white-space: nowrap; overflow: hidden;
}
.nav-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; font-size: 16px; flex-shrink: 0;
  text-align: center;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item:focus-visible { outline: 2px solid var(--color-accent); outline-offset: -2px; }
.nav-item.active {
  background: var(--sidebar-active); color: #fff; font-weight: 600;
  border-left: 3px solid var(--color-accent); padding-left: 11px;
}
.nav-item .badge {
  margin-left: auto; background: var(--color-error); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600;
}
.nav-item .count { margin-left: auto; font-size: var(--font-size-caption); color: var(--sidebar-text-dim); }

.sidebar-presence { padding: var(--space-md); border-top: 1px solid rgba(255,255,255,0.15); }
.presence-select {
  width: 100%; height: var(--input-height); padding: 12px 16px;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--border-radius); color: var(--sidebar-text);
  font-size: var(--font-size-small); cursor: pointer;
}
.presence-select option { background: var(--sidebar-bg); color: #fff; }

.sidebar-user {
  padding: var(--space-md); border-top: 1px solid rgba(255,255,255,0.15);
  display: flex; align-items: center; gap: 12px;
}
.user-name { font-size: var(--font-size-small); font-weight: 600; color: var(--sidebar-text); }
.user-role { font-size: var(--font-size-caption); color: rgba(255,255,255,0.80); }
.user-ext { font-size: var(--font-size-caption); color: var(--sidebar-text-dim); }

/* ────── Collapsed sidebar (icon-only mode) ────── */
body.sidebar-collapsed .sidebar { width: 64px; }
body.sidebar-collapsed .sidebar-brand,
body.sidebar-collapsed .nav-section,
body.sidebar-collapsed .sidebar-presence,
body.sidebar-collapsed .user-name,
body.sidebar-collapsed .user-role,
body.sidebar-collapsed .user-ext { display: none; }
body.sidebar-collapsed .sidebar-logo {
  padding: 20px 10px;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}
body.sidebar-collapsed .sidebar-toggle { width: 100%; }
body.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 14px 0;
  gap: 0;
  font-size: 22px; /* bigger icon when text is hidden */
  position: relative;
}
body.sidebar-collapsed .nav-item .badge,
body.sidebar-collapsed .nav-item .count,
body.sidebar-collapsed .nav-item .nav-label { display: none; }
body.sidebar-collapsed .nav-icon { font-size: 22px; }
body.sidebar-collapsed .sidebar-user { justify-content: center; padding: var(--space-md) 0; }
/* Tooltip showing full label on hover when collapsed */
body.sidebar-collapsed .nav-item:hover::after {
  content: attr(title);
  position: absolute; left: 70px; top: 50%; transform: translateY(-50%);
  background: var(--color-text); color: #fff;
  padding: 6px 12px; border-radius: 4px;
  font-size: 13px; white-space: nowrap;
  pointer-events: none; z-index: 1100;
  box-shadow: var(--shadow-md);
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
  height: 64px; border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; padding: 0 var(--space-xl);
  gap: var(--space-md); background: var(--color-bg-primary); flex-shrink: 0;
}
.header h2 { font-size: var(--font-size-h3); font-weight: var(--font-weight-semibold); color: var(--color-text); }
.header .spacer { flex: 1; }

/* ============================================================
   BUTTONS — design.gov.ua spec: square corners, min 48px, 16px font
   ============================================================ */
.btn {
  min-height: var(--button-height); padding: 12px 24px;
  font-size: var(--font-size-base); font-weight: 600; line-height: var(--line-height);
  border-radius: var(--border-radius); cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-sm);
  text-decoration: none;
  background: var(--color-accent); color: var(--color-text); border: none;
}
.btn:hover { background: var(--color-accent-hover); }
.btn:focus-visible { outline: 3px solid var(--color-focus); outline-offset: var(--focus-offset); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--color-link); color: #FFFFFF; }
.btn-primary:hover { background: var(--color-link-hover); }

.btn-outline {
  background: transparent; color: var(--color-link);
  border: 2px solid var(--color-link);
}
.btn-outline:hover { color: var(--color-link-hover); border-color: var(--color-link-hover); }

.btn-sm { min-height: var(--button-height-sm); padding: var(--space-sm) var(--space-md); font-size: var(--font-size-small); }

.btn-danger { background: var(--color-error); color: #fff; }
.btn-success { background: var(--color-success); color: #fff; }

/* ============================================================
   INPUTS — design.gov.ua: 48px height, square corners, 16px font
   ============================================================ */
.search-input, input[type="text"], input[type="number"],
input[type="email"], input[type="tel"], input[type="password"],
select, textarea {
  height: var(--input-height); padding: 12px 16px;
  border: 1px solid var(--color-border); border-radius: var(--border-radius);
  font-size: var(--font-size-base); line-height: var(--line-height);
  color: var(--color-text); background: var(--color-bg-primary);
  font-family: var(--font-family);
  transition: border-color 0.15s;
  max-width: 100%;
}
.search-input:focus, input:focus, select:focus, textarea:focus {
  border: 2px solid var(--color-focus); padding: 11px 15px;
}
.search-input::placeholder, input::placeholder { color: var(--color-text-secondary); }
.search-input { width: 280px; max-width: 100%; box-sizing: border-box; }

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--font-size-small); font-weight: 700; color: #fff;
  flex-shrink: 0; background: var(--color-link);
}
.avatar.sm { width: 32px; height: 32px; font-size: var(--font-size-caption); }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--color-bg-primary); border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md); margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-sm); overflow-x: auto;
  transition: box-shadow var(--transition-normal);
}
.card-header {
  padding: var(--space-md) 20px; border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; background: var(--color-bg-primary); z-index: 2;
}
.card-header h3 { font-size: var(--font-size-h4); font-weight: var(--font-weight-semibold); color: var(--color-text); }
.card-body { padding: var(--space-md) 20px; }
.card-actions { display: flex; gap: var(--space-sm); align-items: center; }

/* ============================================================
   STATS CARDS — accent left border (3CX pattern)
   ============================================================ */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-md); margin-bottom: var(--space-lg);
}
.stat-card {
  background: var(--color-bg-primary); border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-link);
  border-radius: var(--border-radius-md); padding: var(--space-lg); box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
}
.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-4px); }
.stat-card .label { font-size: var(--font-size-small); color: var(--color-text-secondary); margin-bottom: var(--space-xs); }
.stat-card .value {
  font-size: var(--font-size-stat); font-weight: var(--font-weight-bold); color: var(--color-text);
  line-height: var(--line-height-tight); font-variant-numeric: tabular-nums;
}
.stat-card .sub { font-size: var(--font-size-caption); color: var(--color-text-secondary); margin-top: var(--space-xs); }
.stat-card-icon { font-size: 18px; margin-bottom: var(--space-xs); }

/* ============================================================
   CHART CARDS — dashboard SVG charts (span 2 grid columns)
   ============================================================ */
.chart-card {
  grid-column: span 2;
  padding: var(--space-lg);
}
.chart-card-sm {
  grid-column: span 1;
}
.chart-card-header {
  margin-bottom: var(--space-md);
}
.chart-card-header .label {
  font-size: var(--font-size-small);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}
.chart-card-header .sub {
  font-size: var(--font-size-caption);
  color: var(--color-text-secondary);
}
.chart-container {
  width: 100%;
  overflow: hidden;
}
.chart-container-center {
  display: flex;
  justify-content: center;
}
.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}
.chart-donut {
  max-width: 240px;
}
.chart-bar { transition: opacity 0.15s ease; }
.chart-bar:hover, .chart-donut-seg:hover { opacity: 0.8; }
.chart-dot { transition: r 0.15s ease; }
.chart-dot:hover { r: 6; }
.chart-hover-zone { cursor: default; }
.chart-table-container {
  max-height: 400px;
  overflow-y: auto;
}
.chart-table-container table { margin: 0; }

/* ============================================================
   TABLES — sticky headers, better hover, monospace numbers
   ============================================================ */
table { width: 100%; border-collapse: collapse; max-width: 100%; }
th {
  text-align: left; padding: 12px 14px;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--color-text-secondary); border-bottom: 2px solid var(--color-border);
  font-weight: 700; background: var(--color-bg-secondary);
  position: sticky; top: 0; z-index: 1;
}
td {
  padding: 12px 14px; border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-small); vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0, 75, 193, 0.03); }
/* Monospace for numeric columns */
td .ext-badge, td .fwd-target, .cdr-time, .cdr-dur, .cdr-from, .cdr-to {
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   PRESENCE DOTS — with accessible labels
   ============================================================ */
.presence-dot {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 50%; margin-right: var(--space-sm); vertical-align: middle;
  flex-shrink: 0;
}
.presence-dot.available { background: var(--color-success); }
.presence-dot.busy, .presence-dot.dnd { background: var(--color-error); }
.presence-dot.away { background: #FFD500; }
.presence-dot.lunch { background: #FF991F; }
.presence-dot.offline { background: var(--color-border); }
.presence-dot.business_trip { background: var(--color-info); }

/* ============================================================
   BADGES — call status pills (3CX/FreePBX pattern)
   ============================================================ */
.ext-badge {
  display: inline-block; background: #E6EFFF; color: var(--color-link);
  padding: var(--space-xs) 12px; border-radius: var(--border-radius-sm);
  font-family: var(--font-mono); font-size: var(--font-size-small);
  font-weight: var(--font-weight-bold); font-variant-numeric: tabular-nums;
}
.dept-badge { color: var(--color-link); font-size: var(--font-size-small); font-weight: 600; }
.fwd-target { font-family: monospace; font-size: var(--font-size-small); color: var(--color-warning); font-weight: 700; }

/* Voicemail badge */
.vm-badge {
  display: inline-block; padding: 1px 8px; border-radius: var(--border-radius-pill);
  background: var(--color-error, #d33); color: #fff;
  font-size: 12px; font-weight: 700; margin-left: 8px; vertical-align: middle;
}

/* Phone SIP status badges */
.phone-badge {
  display: inline-block; padding: 1px 8px; border-radius: var(--border-radius-pill);
  font-size: 11px; font-weight: 700; vertical-align: middle; letter-spacing: 0.3px;
}
.phone-online { background: var(--color-success-light); color: var(--color-success-dark); }
.phone-dnd { background: #FDE8E8; color: #C53030; }
.phone-offline { background: var(--color-border); color: var(--color-text-secondary); }
.phone-ringing { background: #FFF3CD; color: #856404; animation: phone-ring 0.6s ease-in-out infinite alternate; }
.phone-incall { background: #D4EDDA; color: #155724; font-weight: 700; }
@keyframes phone-ring {
  from { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,193,7,0.5); }
  to { transform: scale(1.05); box-shadow: 0 0 8px 2px rgba(255,193,7,0.3); }
}

/* Call status pills with background — brand book pill style */
.status-on, .call-answered {
  display: inline-block; padding: 2px 10px; border-radius: var(--border-radius-pill);
  background: var(--color-success-light); color: var(--color-success-dark);
  font-size: var(--font-size-caption); font-weight: var(--font-weight-bold);
}
.status-off, .call-missed {
  display: inline-block; padding: 2px 10px; border-radius: var(--border-radius-pill);
  background: var(--color-error-light); color: var(--color-error-dark);
  font-size: var(--font-size-caption); font-weight: var(--font-weight-bold);
}
.call-busy {
  display: inline-block; padding: 2px 10px; border-radius: var(--border-radius-pill);
  background: var(--color-busy-light); color: var(--color-busy);
  font-size: var(--font-size-caption); font-weight: var(--font-weight-bold);
}

/* ============================================================
   ACTION BUTTONS (small inline)
   ============================================================ */
.action-btn {
  width: 36px; height: 36px; min-width: 36px; min-height: 36px;
  padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--color-border); background: var(--color-bg-primary);
  color: var(--color-text-secondary); border-radius: 6px;
  font-size: 16px; cursor: pointer; margin-right: 4px;
  transition: all 0.15s; line-height: 1;
}
.action-btn:hover { background: var(--color-link); color: #fff; border-color: var(--color-link); }
.action-btn:focus-visible { outline: 3px solid var(--color-focus); outline-offset: var(--focus-offset); }

/* ============================================================
   TOGGLE — design.gov.ua: ON=#004BC1, OFF=#C2C5CB
   ============================================================ */
.toggle {
  position: relative; display: inline-block; vertical-align: middle;
  width: 48px; min-width: 48px; height: 26px;
  flex: none !important; flex-shrink: 0 !important; flex-grow: 0 !important;
}
.toggle input {
  opacity: 0; width: 0; height: 0; position: absolute; top: 0; left: 0;
  flex: none !important;
}
.toggle .slider {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: #ccc; border-radius: 26px; cursor: pointer; transition: 0.3s;
}
.toggle .slider:before {
  content: ''; position: absolute; height: 20px; width: 20px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%;
  transition: 0.3s; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle input:checked + .slider { background: var(--color-success); }
.toggle input:checked + .slider:before { transform: translateX(22px); }
.toggle input:focus-visible + .slider { outline: 2px solid var(--color-link); outline-offset: 2px; }
/* Wrapper divs containing toggles in form-rows */
.form-row .toggle { margin: 0; }

/* ============================================================
   TABS
   ============================================================ */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tab {
  min-height: 40px; padding: 8px 20px;
  font-size: var(--font-size-small); font-weight: 600;
  border: 2px solid var(--color-border); color: var(--color-text-secondary);
  cursor: pointer; background: var(--color-bg-primary);
  transition: all 0.15s; border-radius: var(--border-radius);
}
.tab:first-child { border-right: 1px solid var(--color-border); }
.tab:last-child { border-left: 1px solid var(--color-border); }
.tab.active { background: var(--color-link); color: #fff; border-color: var(--color-link); }
.tab:hover:not(.active) { background: var(--color-bg-secondary); color: var(--color-text); }
.tab:focus-visible { outline: 3px solid var(--color-focus); outline-offset: var(--focus-offset); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 200;
  align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--color-bg-primary); border-radius: var(--border-radius-md);
  width: 720px; max-width: 95vw; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-modal); animation: modal-in 0.2s ease;
}
@keyframes modal-in { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  padding: 20px var(--space-lg); border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--color-bg-primary); z-index: 1;
}
.modal-header h3 { font-size: 20px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--color-text-secondary);
  font-size: 28px; cursor: pointer; padding: var(--space-xs) var(--space-sm);
  border-radius: 4px; line-height: 1; transition: all 0.15s;
}
.modal-close:hover { background: var(--color-bg-secondary); color: var(--color-text); }
.modal-close:focus-visible { outline: 2px solid var(--color-focus); }
.modal-body { padding: var(--space-lg); }
.modal-footer {
  padding: var(--space-md) var(--space-lg); border-top: 1px solid var(--color-border);
  display: flex; justify-content: flex-end; gap: var(--space-sm);
  position: sticky; bottom: 0; background: var(--color-bg-primary);
}

/* ============================================================
   FORMS — Labels ABOVE fields (gov.ua rule)
   ============================================================ */
.form-row { display: flex; gap: var(--space-md); margin-bottom: var(--space-md); align-items: center; }
.form-row > label:not(.toggle) {
  font-size: var(--font-size-small); font-weight: 700;
  color: var(--color-text); width: 160px; flex-shrink: 0;
}
.form-row > select, .form-row > input { flex: 1; min-width: 0; }
.form-row > div { flex-shrink: 0; flex-grow: 0; }
.form-row select { white-space: normal; word-wrap: break-word; }

/* ============================================================
   SERVICE BADGES
   ============================================================ */
.services { display: flex; gap: var(--space-sm); margin-bottom: var(--space-lg); flex-wrap: wrap; }
.service-badge {
  display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-primary); border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md); font-size: var(--font-size-small);
  box-shadow: var(--shadow-sm); transition: all var(--transition-normal);
}
.service-badge:hover { box-shadow: var(--shadow-md); }
.service-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.service-dot.ok { background: var(--color-success); }
.service-dot.warn { background: var(--color-warning); animation: pulse-dot 2s infinite; }
.service-dot.err { background: var(--color-error); animation: pulse-dot 1s infinite; }
.service-dot.unknown { background: var(--text-dim, #999); }
@keyframes pulse-dot { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

/* ============================================================
   TRUNK CARDS
   ============================================================ */
.trunk-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: var(--space-md); margin-bottom: var(--space-lg);
}
.trunk-card {
  background: var(--color-bg-primary); border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md); padding: var(--space-lg); box-shadow: var(--shadow-sm);
  overflow-x: auto; transition: all var(--transition-normal);
}
.trunk-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-4px); }
.trunk-card h4 {
  font-size: 16px; font-weight: 700; margin-bottom: 12px;
  display: flex; align-items: center; gap: var(--space-sm); color: var(--color-text);
}
.trunk-detail { font-size: var(--font-size-small); color: var(--color-text-secondary); margin: 6px 0; line-height: 1.6; }
.trunk-detail b { color: var(--color-text); font-weight: 700; }

/* ============================================================
   CDR ROWS
   ============================================================ */
.cdr-row {
  display: flex; gap: 12px; padding: 14px 20px;
  border-bottom: 1px solid var(--color-border); align-items: center;
  font-size: var(--font-size-small); transition: background 0.1s;
}
.cdr-row:last-child { border-bottom: none; }
.cdr-row:hover { background: rgba(0, 75, 193, 0.03); }
.cdr-time { color: var(--color-text-secondary); width: 60px; flex-shrink: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.cdr-dir { width: 20px; flex-shrink: 0; font-size: 18px; }
.cdr-dir.in { color: var(--color-success); }
.cdr-dir.out { color: var(--color-link); }
.cdr-dir.miss { color: var(--color-error); }
.cdr-from, .cdr-to { width: 140px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cdr-dur { margin-left: auto; color: var(--color-text-secondary); font-weight: 600; font-variant-numeric: tabular-nums; }
.cdr-rec a { color: var(--color-link); text-decoration: none; font-weight: 700; }
.cdr-rec a:hover { text-decoration: underline; }

/* ============================================================
   ADDRESS BOOK
   ============================================================ */
.ab-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-md);
}
.ab-card {
  background: var(--color-bg-secondary); border-radius: var(--border-radius-md);
  padding: var(--space-md); display: flex; gap: var(--space-md); align-items: center;
  cursor: pointer; transition: all var(--transition-fast); border: 2px solid transparent;
}
.ab-card:hover { border-color: var(--color-link); background: var(--color-bg-primary); box-shadow: var(--shadow-sm); }
.ab-card:focus-visible { outline: 2px solid var(--color-focus); }
.ab-name { font-size: var(--font-size-small); font-weight: 700; color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ab-pos { font-size: var(--font-size-caption); color: var(--color-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ab-ext { font-size: var(--font-size-caption); color: var(--color-link); font-weight: 700; }
.ab-card > div:last-child { overflow: hidden; min-width: 0; }

/* ============================================================
   SOFTPHONE — floating overlay, gov.ua blue
   ============================================================ */
.softphone {
  position: fixed; bottom: 20px; right: 20px; width: 290px;
  background: var(--color-bg-primary); border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md); box-shadow: var(--shadow-lg);
  overflow: hidden; z-index: 1000;
  transition: transform 0.3s ease, opacity 0.3s ease, width 0.3s ease, height 0.3s ease, border-radius 0.3s ease;
}
/* Test-plan page: dock softphone to bottom-LEFT so it doesn't overlap
   the test action buttons in the right column of the test table. */
body.softphone-dock-left .softphone { right: auto; left: 20px; }
body.softphone-dock-left #sp-fab    { right: auto; left: 24px; }
/* Hidden state — fully off screen, no interaction */
.softphone.sp-hidden {
  transform: translateY(calc(100% + 40px));
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}
/* FAB toggle button — always visible */
#sp-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--color-link); color: #fff; border: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  cursor: pointer; font-size: 24px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.15s;
  /* Ensure it stays bottom-right above all content */
}
#sp-fab:hover { background: var(--color-link-hover); transform: scale(1.08); }
#sp-fab:active { transform: scale(0.95); }
/* Hide FAB when softphone is visible */
#sp-fab.sp-fab-hidden { transform: scale(0); opacity: 0; pointer-events: none; }
/* Status dot on FAB */
#sp-fab .sp-fab-dot {
  position: absolute; top: 6px; right: 6px;
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--color-link);
  background: var(--color-border);
}
#sp-fab .sp-fab-dot.registered { background: var(--color-success); }
#sp-fab .sp-fab-dot.in-call { background: var(--color-success); animation: sp-pulse 1.5s ease-in-out infinite; }
#sp-fab .sp-fab-dot.ringing { background: var(--color-accent); animation: sp-pulse 0.5s ease-in-out infinite; }
.sp-header {
  padding: 14px var(--space-md); background: var(--color-link); color: #fff;
  display: flex; align-items: center; justify-content: space-between; cursor: pointer;
}
.sp-header .sp-title { font-size: var(--font-size-small); font-weight: 700; }
.sp-header .sp-status { font-size: var(--font-size-caption); opacity: 0.8; }
.sp-display { padding: var(--space-md); text-align: center; border-bottom: 1px solid var(--color-border); }
.sp-number { font-size: 24px; font-weight: 700; font-family: monospace; min-height: 32px; color: var(--color-text); font-variant-numeric: tabular-nums; }
.sp-label { font-size: var(--font-size-caption); color: var(--color-text-secondary); margin-top: var(--space-xs); }
.sp-dialpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: var(--space-sm); }
.sp-key {
  aspect-ratio: 1.4; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--color-bg-secondary); border-radius: 4px;
  cursor: pointer; font-size: 20px; font-weight: 700; transition: all 0.1s;
  margin: 3px; color: var(--color-text);
}
.sp-key:hover { background: var(--color-border); }
.sp-key:active { background: var(--color-link); color: #fff; transform: scale(0.95); }
.sp-key .sub { font-size: 10px; color: var(--color-text-secondary); letter-spacing: 1.5px; }
.sp-actions { display: flex; padding: 12px; gap: var(--space-sm); }
.sp-call {
  flex: 1; min-height: var(--button-height); background: var(--color-success); color: #fff;
  border: none; border-radius: var(--border-radius); font-size: var(--font-size-base);
  font-weight: 700; cursor: pointer; transition: background 0.15s;
}
.sp-call:hover { background: var(--color-success-hover); }
.sp-end {
  flex: 1; min-height: var(--button-height); background: var(--color-error); color: #fff;
  border: none; border-radius: var(--border-radius); font-size: var(--font-size-base);
  font-weight: 700; cursor: pointer; transition: background 0.15s;
}
.sp-end:hover { background: #cc0000; }

/* ============================================================
   NOTIFICATIONS
   ============================================================ */
.notif-bar {
  background: #E6EFFF; border: 2px solid var(--color-link);
  border-radius: var(--border-radius); padding: 14px 20px;
  margin-bottom: var(--space-lg); display: flex; align-items: center;
  gap: 12px; font-size: var(--font-size-base);
}
.notif-bar .notif-action {
  min-height: 36px; padding: 8px 16px; background: var(--color-link); color: #fff;
  border: none; border-radius: var(--border-radius); font-size: var(--font-size-small);
  cursor: pointer; margin-left: auto; font-weight: 600;
}

/* ============================================================
   WAGTAIL SYNC BADGE
   ============================================================ */
.wagtail-sync {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--font-size-caption); color: var(--color-text-secondary);
  padding: 6px 12px; background: var(--color-bg-secondary);
  border: 1px solid var(--color-border); border-radius: var(--border-radius);
}
.wagtail-sync .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--color-success); }

/* ============================================================
   GRID LAYOUTS
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); }
@media (max-width: 1200px) { .grid-2 { grid-template-columns: 1fr; } }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 300;
  display: flex; flex-direction: column; gap: var(--space-sm);
}
.toast {
  padding: var(--space-md) var(--space-lg); border-radius: var(--border-radius-md);
  font-size: var(--font-size-small); font-weight: 600;
  box-shadow: var(--shadow-lg); animation: toast-in 0.3s ease;
}
.toast.success { background: var(--color-success); color: #fff; }
.toast.error { background: var(--color-error); color: #fff; }
.toast.info { background: var(--color-link); color: #fff; }
@keyframes toast-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============================================================
   GLOBAL READABILITY OVERRIDES
   ============================================================ */
#content * { min-height: 0; }
/* Removed forced font-size overrides — they broke badges, labels, and metadata */

/* ============================================================
   MISC
   ============================================================ */
.loading { padding: 60px; text-align: center; color: var(--color-text-secondary); font-size: 16px; }
.empty-state {
  padding: 60px 20px; text-align: center; color: var(--color-text-secondary);
  font-size: var(--font-size-base);
}
.presence-select-inline {
  height: 36px; padding: 4px 10px;
  background: var(--color-bg-secondary); border: 1px solid var(--color-border);
  border-radius: var(--border-radius); color: var(--color-text); font-size: var(--font-size-caption);
}
.presence-label { font-size: var(--font-size-small); }
.stat-value { font-size: 30px; font-weight: 700; color: var(--color-text); line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-label { font-size: var(--font-size-small); color: var(--color-text-secondary); margin-bottom: var(--space-xs); }

/* ============================================================
   FORWARDING
   ============================================================ */
.fwd-summary {
  font-size: var(--font-size-small); color: var(--color-text-secondary);
  padding: var(--space-sm) 0;
}
.fwd-tab {
  padding: 12px 16px; border: none; background: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--color-text-secondary);
  border-bottom: 3px solid transparent; transition: all 0.15s;
  display: flex; align-items: center; gap: 6px;
}
.fwd-tab:hover { color: var(--color-text); background: var(--color-bg-secondary); }
.fwd-tab-active { color: var(--color-link); border-bottom-color: var(--color-link); }

/* ============================================================
   LOGOUT BUTTON
   ============================================================ */
.btn-logout {
  min-height: 36px; padding: 8px 16px;
  border: 2px solid var(--color-border); background: var(--color-bg-primary);
  color: var(--color-text-secondary); border-radius: var(--border-radius);
  font-size: var(--font-size-small); cursor: pointer; font-weight: 600;
  transition: all 0.15s; font-family: var(--font-family);
}
.btn-logout:hover { background: var(--color-error); color: #fff; border-color: var(--color-error); }
.btn-logout:focus-visible { outline: 3px solid var(--color-focus); outline-offset: var(--focus-offset); }

/* ============================================================
   SIM TABLE (trunks page)
   ============================================================ */
.sim-table { width: 100%; border-collapse: collapse; }
.sim-table th, .sim-table td { padding: 10px 12px; font-size: 14px; }

hr { border: none; border-top: 1px solid var(--color-border); margin: var(--space-lg) 0; }

/* ============================================================
   RESPONSIVE — sidebar collapse on mobile
   ============================================================ */
@media (max-width: 768px) {
  /* --- Mobile drawer sidebar --- */
  #app { flex-direction: row; }

  #sidebar {
    position: fixed; top: 0; left: 0; z-index: 1200;
    width: 280px; height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  body.sidebar-mobile-open #sidebar { transform: translateX(0); }

  .sidebar {
    width: 100% !important; height: 100vh !important;
    flex-direction: column !important; flex-wrap: nowrap !important;
    overflow: visible !important;
  }
  .sidebar-logo { padding: 16px; }
  .sidebar-nav {
    display: flex !important; flex-direction: column !important;
    flex-wrap: nowrap !important; overflow-y: auto !important;
    overflow-x: hidden !important; flex: 1;
    padding: 0 !important;
  }
  .nav-section { display: block; }
  .nav-item {
    padding: 12px 16px !important; font-size: 15px !important;
    white-space: nowrap; border-left: 3px solid transparent !important;
  }
  .nav-item.active { border-left-color: var(--color-accent) !important; }
  .nav-label { display: inline !important; }
  .nav-icon { font-size: 18px !important; }
  .sidebar-presence { padding: var(--space-sm) var(--space-md); }
  .sidebar-user { padding: var(--space-sm) var(--space-md); }

  /* Override collapsed mode on mobile — always show full sidebar in drawer */
  body.sidebar-collapsed #sidebar { width: 280px; }
  body.sidebar-collapsed .sidebar { width: 100% !important; }
  body.sidebar-collapsed .nav-label { display: inline !important; }
  body.sidebar-collapsed .nav-section { display: block !important; }
  body.sidebar-collapsed .sidebar-brand { display: block !important; }
  body.sidebar-collapsed .sidebar-presence { display: block !important; }
  body.sidebar-collapsed .user-name { display: block !important; }
  body.sidebar-collapsed .user-ext { display: block !important; }
  body.sidebar-collapsed .nav-item { justify-content: flex-start !important; padding: 12px 16px !important; gap: 12px !important; font-size: 15px !important; }
  body.sidebar-collapsed .nav-icon { font-size: 18px !important; }

  /* Sidebar overlay backdrop */
  .sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 1199;
  }
  body.sidebar-mobile-open .sidebar-overlay { display: block; }

  /* Hide desktop sidebar toggle, show mobile hamburger in header */
  .sidebar-toggle { display: none !important; }
  .mobile-menu-btn { display: flex !important; }

  /* Main content takes full width */
  #main-wrapper { width: 100%; height: 100vh; overflow: hidden; }
  #content { padding: var(--space-md); overflow-y: auto; flex: 1; }

  .header { padding: 0 var(--space-md); }
  .header h2 { font-size: 16px; }
  .search-input { width: 100% !important; }

  /* Content grids */
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-sm); }
  .chart-card, .chart-card-sm { grid-column: span 1; }
  .trunk-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .ab-grid { grid-template-columns: 1fr; }
  .ab-name { white-space: normal; overflow: visible; text-overflow: clip; }

  .tabs { flex-wrap: wrap; }
  .tab { font-size: var(--font-size-caption); padding: 6px 12px; min-height: 32px; }

  /* Header: hide non-essential items on mobile */
  .header .btn { display: none; }  /* hide "+ Новий користувач" etc. */
  .header .search-input { display: none; }  /* hide search on mobile header */
  .header .btn-logout { font-size: 13px; padding: 6px 12px; }

  /* Card header: stack actions below title */
  .card-header { flex-wrap: wrap; gap: 8px; }

  /* Modals: fullscreen on mobile */
  .modal { width: 100vw; max-width: 100vw; max-height: 100vh; border-radius: 0; }
  .modal-body { padding: var(--space-md); }
  .modal-header { padding: var(--space-md); }
  .modal-footer { padding: var(--space-sm) var(--space-md); }
  .modal .form-grid-2col, .modal .form-grid-3col, .modal .form-grid-2-1-1 { grid-template-columns: 1fr; }

  /* FAB button: smaller on mobile */
  #sp-fab { width: 48px; height: 48px; font-size: 20px; bottom: 16px; right: 16px; }

  /* Tables: horizontal scroll inside cards */
  .card { overflow-x: auto; }
  table { min-width: 500px; }
  th { padding: 8px 10px; font-size: 11px; }
  td { padding: 8px 10px; font-size: 13px; }

  /* My-schedule and forwarding now use CSS grid classes (.grid-content-aside, .grid-sidebar) */
}

/* Mobile hamburger button in header — hidden on desktop */
.mobile-menu-btn {
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: none; background: none;
  font-size: 24px; cursor: pointer; color: var(--color-text);
  margin-right: var(--space-sm); flex-shrink: 0;
}

/* ============================================================
   REUSABLE GRID UTILITIES
   ============================================================ */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.grid-3col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-md); }
.grid-sidebar { display: grid; grid-template-columns: 320px 1fr; gap: var(--space-md); align-items: start; }
.grid-content-aside { display: grid; grid-template-columns: 1fr 280px; gap: 24px; align-items: start; }
@media (max-width: 768px) {
  .grid-2col, .grid-3col, .grid-sidebar, .grid-content-aside { grid-template-columns: 1fr; }
}

/* ============================================================
   RECORDING PLAYER — fixed bottom bar (Spotify-style)
   ============================================================ */
.rec-player {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 150;
  background: linear-gradient(135deg, #0f1923 0%, #1a2f5a 40%, #1e3c72 100%);
  color: #fff;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.4);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.rec-player-inner {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 8px 20px;
  height: 64px;
}

/* Left: call info */
.rec-player-info {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}
.rec-player-icon {
  width: 40px; height: 40px;
  background: var(--cta, #FFE358);
  color: #0f1923;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
  flex-shrink: 0;
}
.rec-player-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
.rec-player-label {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.rec-player-label .rec-dir { opacity: 0.6; }
.rec-player-sub {
  font-size: 11px;
  opacity: 0.5;
  white-space: nowrap;
}

/* Center: transport controls + progress */
.rec-player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.rec-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.rec-btn:hover { background: rgba(255,255,255,0.25); transform: scale(1.05); }
.rec-btn-play {
  width: 40px; height: 40px;
  font-size: 18px;
  background: var(--cta, #FFE358);
  color: #0f1923;
}
.rec-btn-play:hover { background: #fff; transform: scale(1.08); }

.rec-btn-sm {
  width: 28px; height: 28px;
  font-size: 12px;
  border-radius: 6px;
  text-decoration: none;
}
.rec-btn-close { color: rgba(255,255,255,0.5); }
.rec-btn-close:hover { color: #fff; background: rgba(220,38,38,0.6); }

.rec-progress-wrap {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  min-width: 80px;
  transition: height 0.15s;
}
.rec-progress-wrap:hover { height: 6px; }
.rec-progress-bar {
  height: 100%;
  background: var(--cta, #FFE358);
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
  pointer-events: none;
}

.rec-time {
  font-size: 11px;
  font-family: monospace;
  white-space: nowrap;
  opacity: 0.5;
  min-width: 32px;
}

/* Right: volume + actions */
.rec-player-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rec-vol-icon {
  font-size: 14px;
  opacity: 0.6;
  cursor: default;
}

.rec-volume {
  width: 70px;
  height: 4px;
  accent-color: var(--cta, #FFE358);
  cursor: pointer;
}

/* Active play button highlight in tables */
.cdr-play-btn.playing {
  background: var(--accent, #004BC1) !important;
  color: #fff !important;
  border-color: var(--accent, #004BC1) !important;
}

/* Bottom padding when player is visible */
body.rec-player-open #content { padding-bottom: 72px; }

/* Pulse animation for playing icon */
@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ============================================================
   RESPONSIVE — small phone (≤480px)
   ============================================================ */
@media (max-width: 480px) {
  /* Tables: ensure horizontal scroll inside .card */
  table { min-width: 600px; }

  /* Search input full width */
  .search-input { width: 100% !important; }
  .form-row {
    flex-direction: column; align-items: stretch;
  }
  .form-row label { width: auto; margin-bottom: var(--space-xs); }
}

@media (max-width: 768px) {
  .rec-player-inner {
    grid-template-columns: 1fr auto;
    padding: 6px 12px;
    height: 56px;
  }
  .rec-player-info { display: none; }
  .rec-volume, .rec-vol-icon { display: none; }
}

/* ============================================================
   Department tree
   ============================================================ */
.dept-tree { list-style: none; padding: 0; }
.dept-tree ul { list-style: none; padding-left: 24px; }
.dept-node { padding: 6px 0; }
.dept-toggle { cursor: pointer; display: inline-block; width: 20px; transition: transform 0.2s; }
.dept-toggle.open { transform: rotate(90deg); }
.dept-name { font-weight: 600; cursor: pointer; color: var(--color-link); }
.dept-name:hover { color: var(--color-link-hover); text-decoration: underline; }
.dept-count { color: var(--color-text-secondary); font-size: 13px; }
.dept-children { display: none; }
.dept-children.open { display: block; }

/* ============================================================
   Schedule badges
   ============================================================ */
.sched-badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.sched-badge.vacation { background: #FFF3E0; color: #E65100; }
.sched-badge.day-off { background: #F5F5F5; color: #616161; }
.sched-badge.custom { background: #E3F2FD; color: #1565C0; }
.sched-badge.business-trip { background: #F3E5F5; color: #7B1FA2; }

/* ============================================================
   Schedule calendar grid
   ============================================================ */
.sched-grid { display: grid; gap: 1px; background: var(--color-border); border-radius: 8px; overflow: hidden; }
.sched-cell { padding: 4px; text-align: center; font-size: 11px; background: var(--color-surface); min-height: 28px; }
.sched-cell.weekend { background: #FAFAFA; }
.sched-cell.vacation { background: #FFF3E0; }
.sched-cell.day-off { background: #EEEEEE; }
.sched-cell.custom { background: #E3F2FD; }
.sched-cell.header { font-weight: 700; font-size: 12px; background: var(--color-bg); }
.sched-cell.name { text-align: left; font-weight: 600; padding: 4px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   Blocklist page
   ============================================================ */
.blocklist-type { font-size: 16px; }
.blocklist-prefix { font-family: var(--font-mono); font-weight: 700; }
.preset-btn { padding: 4px 10px; margin: 2px; border-radius: 12px; font-size: 12px; cursor: pointer; border: 1px solid var(--color-border); background: var(--color-surface); }
.preset-btn:hover { background: var(--color-accent); color: white; }

/* ── Forwarding modal improvements ── */
#fwd-presence-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
#fwd-presence-tabs::-webkit-scrollbar { display: none; }
#fwd-presence-tabs .fwd-tab {
    white-space: nowrap;
    flex-shrink: 0;
}
/* State content section */
#fwd-state-content .form-row {
    margin-bottom: 12px;
}
#fwd-state-content .form-row label {
    min-width: 120px;
    width: 120px;
}
#fwd-state-content select,
#fwd-state-content input[type="tel"],
#fwd-state-content input[type="number"] {
    height: 40px;
    font-size: 14px;
}
#fwd-state-content h4 {
    margin-top: 8px;
}
/* Forwarding modal wider for all the tabs */
.modal:has(#fwd-presence-tabs) {
    width: 800px;
}

/* Forwarding responsive: handled by .grid-sidebar class */
.fwd-user-item:hover {
    background: var(--color-bg-secondary) !important;
}

/* ============================================================
   UTILITY CLASSES — text, typography, layout, spacing
   ============================================================ */

/* Text color utilities */
.text-muted { color: var(--color-text-secondary); }
.text-error { color: var(--color-danger, #d33); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning, #e65100); }
.text-link { color: var(--color-link); }

/* Typography utilities */
.text-xs { font-size: 11px; }
.text-sm { font-size: 12px; }
.text-caption { font-size: 13px; }
.text-base { font-size: 14px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 22px; }
.text-2xl { font-size: 24px; }
.fw-bold { font-weight: 700; }
.fw-semi { font-weight: 600; }
.mono { font-family: monospace; font-variant-numeric: tabular-nums; }

/* Layout utilities */
.flex-1 { flex: 1; }
.flex-row { display: flex; align-items: center; gap: 8px; }
.flex-row-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Spacing utilities */
.mb-0 { margin-bottom: 0; }
.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

/* ============================================================
   COMPONENT CLASSES — reusable UI patterns
   ============================================================ */

/* Mini stat box (used in ring-groups, queues, conferences, IVR) */
.mini-stat-box {
  background: var(--color-bg-secondary); border-radius: 8px;
  padding: 12px 16px; text-align: center;
}
.mini-stat-label { font-size: 11px; color: var(--color-text-secondary); margin-bottom: 4px; }
.mini-stat-value { font-size: 22px; font-weight: 700; }

/* Empty state row in tables */
.empty-row { text-align: center; color: var(--color-text-secondary); padding: 20px; }

/* Detail metadata text */
.detail-meta { font-size: 12px; color: var(--color-text-secondary); }

/* Section separator */
.separator-top { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--color-border); }

/* Card toolbar (filter rows) */
.card-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 16px; border-bottom: 1px solid var(--color-border);
}

/* Section label (IVR scenario headers, form sections) */
.section-label {
  font-size: 13px; font-weight: 700; margin-bottom: 8px;
  color: var(--color-text); 
}

/* ============================================================
   FORM GRID CLASSES — for modals and settings
   ============================================================ */
.form-grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-grid-2-1-1 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px; }

/* Content grids */
.grid-auto-sm { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.grid-auto-md { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }

/* DTMF digit grid (IVR) */
.dtmf-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.dtmf-cell {
  background: var(--color-bg-secondary); border: 1px solid var(--color-border);
  padding: 8px; text-align: center; border-radius: 4px; cursor: pointer;
}
.dtmf-cell:hover { background: var(--color-bg); border-color: var(--color-link); }

/* Responsive: all form/content grids collapse on mobile */
@media (max-width: 768px) {
  .form-grid-2col, .form-grid-3col, .form-grid-2-1-1 { grid-template-columns: 1fr; }
  .dtmf-grid { grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); }
  .card-toolbar { padding: 8px 12px; }
  .card-toolbar input[type="date"] { flex: 1; min-width: 100px; }
}

/* Additional utilities (batch 2 pass) */
.text-stat { font-size: 48px; }
.clickable { cursor: pointer; }
.form-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; }

/* Width utilities */
.w-70 { width: 70px; }
.w-80 { width: 80px; }
.w-90 { width: 90px; }
.w-100 { width: 100px; }
.w-120 { width: 120px; }
.w-140 { width: 140px; }
.w-160 { width: 160px; }
.w-full { width: 100%; }

/* Input compact (forms in modals/cards) */
.input-compact { height: 36px; padding: 4px 8px; font-size: var(--font-size-small); }

/* Card section divider (header inside card body) */
.card-section {
  padding: 12px 16px; border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; gap: 8px;
}
.card-section-between {
  padding: 12px 16px; border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
}

/* Confirm modal icon */
.confirm-icon { font-size: 48px; margin-bottom: 16px; }

/* Dropdown overlay */
.dropdown-list {
  display: none; position: absolute; top: 100%; left: 0; right: 0;
  background: var(--color-bg-primary); border: 1px solid var(--color-border);
  max-height: 200px; overflow-y: auto; z-index: 50; box-shadow: var(--shadow-md);
}

.mt-sm { margin-top: var(--space-sm); }
.mt-xs { margin-top: var(--space-xs); }
.sched-legend-dot { display: inline-block; width: 16px; height: 16px; border-radius: 3px; vertical-align: middle; }

/* Small delete button */
.btn-delete-sm {
  background: none; border: 1px solid var(--color-danger, #d33);
  color: var(--color-danger, #d33); border-radius: 4px;
  padding: 2px 8px; cursor: pointer; font-size: 12px;
}
.btn-delete-sm:hover { background: var(--color-danger, #d33); color: #fff; }

/* More utilities */
.flex-none { flex: none; }
.pos-relative { position: relative; }
.badge-error { background: var(--color-danger, #d33); color: #fff; padding: 2px 6px; border-radius: 3px; font-size: 12px; }

.section-header {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--color-text-secondary);
  margin-bottom: 8px; padding-bottom: 4px;
  border-bottom: 1px solid var(--color-border);
}
.btn-outline-sm {
  background: none; border: 1px solid var(--color-link); color: var(--color-link);
  border-radius: 4px; padding: 2px 8px; cursor: pointer; font-size: 12px;
}
.btn-outline-sm:hover { background: var(--color-link); color: #fff; }
.btn-icon-danger {
  background: none; border: none; color: var(--color-danger, #d33);
  cursor: pointer; font-size: 18px; padding: 2px 6px; line-height: 1;
}
.btn-icon-danger:hover { color: #a00; }

/* More width/layout utilities */
.w-200 { width: 200px; }
.min-w-0 { min-width: 0; }
.input-sm { padding: 6px 8px; font-size: 11px; }
.input-md { padding: 6px 12px; }
.input-bordered { height: 36px; padding: 4px 8px; font-size: 13px; border: 1px solid var(--color-border); border-radius: 4px; }
.btn-sm-pad { font-size: 13px; padding: 6px 14px; }
.member-slot { padding: 8px 16px; min-height: 40px; }
.stat-cell { text-align: center; min-width: 60px; }

.ml-auto { margin-left: auto; }
.bordered { border: 1px solid var(--color-border); }
.bordered-card { border: 1px solid var(--color-border); border-radius: 8px; padding: 20px; margin-bottom: 20px; background: var(--color-bg-secondary); }
.bordered-box { border: 1px solid var(--color-border); padding: 16px; margin-bottom: 20px; }
.status-banner-ok { background: #E8F5E9; border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.icon-btn { font-size: 18px; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.list-item-row { padding: 8px 12px; cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 13px; border-bottom: 1px solid var(--color-border); }
.list-item-row:hover { background: var(--color-bg-secondary); }
.card-subheader { padding: 12px 20px; background: var(--color-bg-secondary); border-bottom: 1px solid var(--color-border); font-size: 13px; color: var(--color-text-secondary); }

/* Ring group members in address book */
.rg-member {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--color-bg-secondary);
    border-radius: 12px;
    font-size: 12px;
    color: var(--color-text-primary);
    white-space: nowrap;
}
.rg-member .presence-dot {
    width: 7px;
    height: 7px;
}

/* IVR key buttons grid (address book) */
.ivr-buttons-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}
.ivr-key-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}
.ivr-key-btn:hover {
    background: var(--color-bg);
    border-color: var(--color-link);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
.ivr-key-btn:active {
    transform: translateY(0);
}
.ivr-key-digit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-link);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
}
.ivr-key-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-primary);
    line-height: 1.3;
    max-height: 2.6em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.ivr-key-ext {
    font-size: 10px;
    color: var(--color-text-secondary);
}
@media (max-width: 768px) {
    .ivr-buttons-grid { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
}

/* Ring group tree toggle */
.rg-tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-link);
  line-height: 1;
  padding: 0;
  transition: all 0.15s;
  flex-shrink: 0;
}
.rg-tree-toggle:hover {
  background: var(--color-link);
  color: #fff;
  border-color: var(--color-link);
}
.rg-tree-icon {
  pointer-events: none;
}
