/* ════════════════════════════════════════════════════════════
   Asterisk SIP Manager — CSS
   Dark theme, glassmorphism, smooth animations
   ════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0f1a;
  --bg-1:      #12152a;
  --bg-2:      #1a1e36;
  --bg-3:      #222744;
  --surface:   rgba(255,255,255,0.04);
  --surface-h: rgba(255,255,255,0.07);
  --border:    rgba(255,255,255,0.08);
  --border-h:  rgba(255,255,255,0.14);

  --accent:    #6366f1;
  --accent-h:  #7c7ff5;
  --accent-s:  #8b5cf6;
  --danger:    #ef4444;
  --danger-h:  #f87171;
  --success:   #22c55e;
  --warning:   #f59e0b;
  --info:      #3b82f6;

  --text:      #f1f5f9;
  --text-2:    #94a3b8;
  --text-3:    #64748b;

  --radius:    12px;
  --radius-s:  8px;
  --radius-l:  16px;
  --radius-xl: 24px;

  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --shadow-l:  0 8px 48px rgba(0,0,0,0.6);

  --sidebar-w: 220px;
  --transition: 0.2s ease;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

.hidden { display: none !important; }

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-h); }

/* ════════════════════════════════════════════════════════════
   LOGIN SCREEN
   ════════════════════════════════════════════════════════════ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 80% 80% at 50% -20%, rgba(99,102,241,0.25), transparent),
              var(--bg);
  animation: fade-in 0.4s ease;
}

.login-card {
  width: 380px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  box-shadow: var(--shadow-l);
  animation: slide-up 0.4s ease;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.login-title {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.login-subtitle {
  text-align: center;
  color: var(--text-2);
  margin-bottom: 28px;
  font-size: 13px;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

/* ════════════════════════════════════════════════════════════
   FORM FIELDS
   ════════════════════════════════════════════════════════════ */
.field-group { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field-input, .field-select, .field-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field-input:focus, .field-select:focus, .field-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.field-input::placeholder { color: var(--text-3); }
.field-select { cursor: pointer; }
.field-select option { background: var(--bg-2); }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-row-3 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
}

.field-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  cursor: pointer;
  user-select: none;
  transition: border-color var(--transition);
}

.field-toggle:hover { border-color: var(--border-h); }

.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-3);
  border-radius: 20px;
  transition: background var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
}

.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ════════════════════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-s);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-h); box-shadow: 0 0 20px rgba(99,102,241,0.35); }

.btn-secondary {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-3); border-color: var(--border-h); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-h); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: var(--danger-h); }

.btn-block { width: 100%; justify-content: center; }

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.btn-icon:hover { background: var(--surface-h); color: var(--text); }
.btn-icon svg { width: 16px; height: 16px; }

.btn-icon-sm {
  width: 28px;
  height: 28px;
}

.btn-icon-sm svg { width: 14px; height: 14px; }

/* ════════════════════════════════════════════════════════════
   ERROR BANNER
   ════════════════════════════════════════════════════════════ */
.error-banner {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-s);
  padding: 10px 14px;
  color: #fca5a5;
  font-size: 13px;
  animation: fade-in 0.2s ease;
}

/* ════════════════════════════════════════════════════════════
   APP LAYOUT
   ════════════════════════════════════════════════════════════ */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  animation: fade-in 0.3s ease;
}

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  gap: 8px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-s);
  color: var(--text-2);
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
}

.nav-item:hover { background: var(--surface-h); color: var(--text); }

.nav-item.active {
  background: rgba(99,102,241,0.15);
  color: var(--accent-h);
}

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px 0;
  border-top: 1px solid var(--border);
}

.user-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-s));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

#user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Main content ───────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  padding: 32px 36px;
}

.tab-content { display: none; animation: fade-in 0.25s ease; }
.tab-content.active { display: block; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.page-desc {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 2px;
}

/* ════════════════════════════════════════════════════════════
   CARDS
   ════════════════════════════════════════════════════════════ */
.cards-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
  animation: slide-up 0.3s ease;
}

.card:hover { border-color: var(--border-h); box-shadow: var(--shadow); }

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-s);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-icon svg { width: 22px; height: 22px; }

.card-icon-trunk {
  background: rgba(99,102,241,0.15);
  color: var(--accent-h);
}

.card-icon-b24 {
  background: rgba(139,92,246,0.15);
  color: #a78bfa;
}

.card-body { flex: 1; min-width: 0; }

.card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg-2);
  border-radius: 999px;
  font-size: 11px;
  color: var(--text-2);
  border: 1px solid var(--border);
}

.meta-limit-badge {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.25);
  font-weight: 500;
}

.meta-rtp-badge {
  background: rgba(14, 165, 233, 0.12);
  color: #38bdf8;
  border-color: rgba(14, 165, 233, 0.25);
  font-weight: 500;
}

.card-extra-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
  font-size: 11px;
}

.extra-label {
  color: var(--text-3);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ip-chips {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ip-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  background: rgba(14, 165, 233, 0.08);
  border: 1px solid rgba(14, 165, 233, 0.2);
  border-radius: 4px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  color: #7dd3fc;
  letter-spacing: 0.2px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-success { background: rgba(34,197,94,0.15); color: #86efac; }
.badge-online  { background: rgba(34,197,94,0.15); color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.badge-offline { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.badge-waiting { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.badge-muted   { background: var(--bg-3); color: var(--text-3); }
.badge-ip      { background: rgba(99,102,241,0.12); color: var(--accent-h); }
.badge-reg     { background: rgba(245,158,11,0.12); color: #fbbf24; }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  display: inline-block;
}
.dot-online {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34,197,94,0.6);
}
.dot-offline {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239,68,68,0.6);
}
.dot-waiting {
  background: #f59e0b;
}

.spinning svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-3);
  text-align: center;
  gap: 12px;
  background: var(--bg-1);
  border: 1px dashed var(--border);
  border-radius: var(--radius-l);
}

.empty-state svg { width: 40px; height: 40px; opacity: 0.4; }
.empty-state p { font-size: 15px; }
.empty-state span { font-size: 13px; }

/* Skeleton */
.skeleton-card {
  height: 86px;
  background: linear-gradient(90deg, var(--bg-1) 25%, var(--bg-2) 50%, var(--bg-1) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius-l);
  animation: skeleton 1.4s ease infinite;
}

@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ════════════════════════════════════════════════════════════
   B24 INFO
   ════════════════════════════════════════════════════════════ */
.b24-info-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: rgba(59,130,246,0.08);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  color: #93c5fd;
  font-size: 13px;
  line-height: 1.7;
}

.b24-info-card .info-icon { color: #60a5fa; flex-shrink: 0; margin-top: 2px; }
.b24-info-card strong { color: #bfdbfe; display: block; margin-bottom: 2px; }
.b24-info-card p { color: #93c5fd; }
.b24-info-card em { color: #bfdbfe; font-style: normal; }

/* ════════════════════════════════════════════════════════════
   CONFIG BOX
   ════════════════════════════════════════════════════════════ */
.config-box {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 24px;
  overflow: auto;
}

#config-content {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre;
}

/* ════════════════════════════════════════════════════════════
   MODAL
   ════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fade-in 0.2s ease;
}

.modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 480px;
  max-width: 95vw;
  box-shadow: var(--shadow-l);
  animation: slide-up 0.25s ease;
}

.confirm-modal { width: 360px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-form {
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 24px;
}

.confirm-message {
  padding: 0 24px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.6;
}

/* ════════════════════════════════════════════════════════════
   TOAST
   ════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
  min-width: 260px;
  max-width: 360px;
  pointer-events: auto;
  animation: slide-right 0.3s ease, fade-out 0.3s ease 2.7s forwards;
}

.toast-success { border-color: rgba(34,197,94,0.3); }
.toast-error   { border-color: rgba(239,68,68,0.3); }
.toast-info    { border-color: rgba(59,130,246,0.3); }

.toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.toast-success .toast-dot { background: var(--success); }
.toast-error   .toast-dot { background: var(--danger); }
.toast-info    .toast-dot { background: var(--info); }

/* ════════════════════════════════════════════════════════════
   ANIMATIONS
   ════════════════════════════════════════════════════════════ */
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slide-right {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes fade-out {
  to { opacity: 0; transform: translateX(10px); }
}

/* ════════════════════════════════════════════════════════════
   DIVIDER
   ════════════════════════════════════════════════════════════ */
.form-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  margin-top: 4px;
}

/* ════════════════════════════════════════════════════════════
   TAG INPUT (phone numbers)
   ════════════════════════════════════════════════════════════ */
.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  min-height: 42px;
  cursor: text;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.tag-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 10px;
  background: rgba(99,102,241,0.18);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-h);
  white-space: nowrap;
  animation: fade-in 0.15s ease;
}

.tag-remove {
  background: none;
  border: none;
  color: var(--accent-h);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  opacity: 0.6;
  transition: opacity var(--transition);
}

.tag-remove:hover { opacity: 1; }

.tag-ip {
  background: rgba(14, 165, 233, 0.15);
  border-color: rgba(14, 165, 233, 0.35);
  color: #38bdf8;
  font-family: monospace;
  font-size: 11.5px;
}

.tag-ip .tag-remove {
  color: #38bdf8;
}

.tag-input {
  flex: 1;
  min-width: 140px;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  color: var(--text) !important;
  font-family: inherit;
  font-size: 13px;
  padding: 4px 6px;
  -webkit-appearance: none;
  appearance: none;
}

.tag-input::-webkit-search-decoration,
.tag-input::-webkit-search-cancel-button,
.tag-input::-webkit-search-results-button,
.tag-input::-webkit-search-results-decoration {
  display: none;
  -webkit-appearance: none;
}

.tag-input:-webkit-autofill,
.tag-input:-webkit-autofill:hover, 
.tag-input:-webkit-autofill:focus,
.tag-input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text) !important;
  -webkit-box-shadow: 0 0 0px 1000px rgba(17, 24, 39, 1) inset !important;
  transition: background-color 5000s ease-in-out 0s !important;
}

.tag-input::placeholder { color: var(--text-3); }

.field-hint {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
  display: block;
}

/* ─── Mode toggle buttons (tag / bulk) ──────────────────── */
.btn-tag-mode {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-3);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.btn-tag-mode:hover {
  border-color: var(--border-h);
  color: var(--text-2);
}

.btn-tag-mode.active {
  background: rgba(99,102,241,0.15);
  border-color: rgba(99,102,241,0.4);
  color: var(--accent-h);
}

/* ════════════════════════════════════════════════════════════
   NUMBER PICKER (Bitrix24 Connector)
   ════════════════════════════════════════════════════════════ */
.numbers-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  padding: 8px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  min-height: 60px;
}

.numbers-picker-grid::-webkit-scrollbar {
  width: 5px;
}
.numbers-picker-grid::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.number-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition), border-color var(--transition), transform 0.1s;
}

.number-chip:hover {
  border-color: var(--border-h);
  background: var(--bg-1);
}

.number-chip.selected {
  background: rgba(99,102,241,0.18);
  border-color: rgba(99,102,241,0.5);
  color: var(--accent-h);
}

.chip-check {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.number-chip.selected .chip-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chip-num {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.chip-trunk {
  font-size: 10px;
  color: var(--text-3);
  background: var(--bg-1);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.number-chip.selected .chip-trunk {
  background: rgba(99,102,241,0.25);
  border-color: rgba(99,102,241,0.3);
  color: var(--accent-h);
}

/* ══════════════════════════════════════════════════════════════════════════
   REPORTS & ANALYTICS STYLES
══════════════════════════════════════════════════════════════════════════ */

.reports-filter-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.filter-period-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.period-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.period-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition);
}

.period-btn:hover {
  background: var(--bg-3);
  color: var(--text-1);
  border-color: var(--border-h);
}

.period-btn.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: var(--accent);
  color: var(--accent-h);
  font-weight: 600;
}

.filter-controls-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 12px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.filter-sublabel {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
}

.filter-input, .filter-select {
  height: 36px;
  padding: 6px 10px;
  font-size: 13px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  color: var(--text-1);
}

.filter-input:focus, .filter-select:focus {
  border-color: var(--accent);
  outline: none;
}

.filter-search-group {
  flex: 1;
  min-width: 200px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper input {
  width: 100%;
  padding-right: 30px;
}

.btn-clear-search {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 2px;
}

.btn-clear-search:hover {
  color: var(--text-1);
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--transition), border-color var(--transition);
}

.kpi-card:hover {
  border-color: var(--border-h);
  transform: translateY(-2px);
}

.kpi-icon-box {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bg-indigo { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.bg-emerald { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.bg-amber   { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.bg-cyan    { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }
.bg-purple  { background: rgba(168, 85, 247, 0.15); color: #c084fc; }

.kpi-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kpi-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-value-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.02em;
}

.kpi-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
}

.kpi-subtext {
  font-size: 12px;
  color: var(--text-3);
}

.kpi-hint {
  font-size: 11px;
  color: var(--text-3);
}

/* Report Table */
.report-table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.report-table-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.report-table-title-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.report-table-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
}

.report-count-badge {
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-2);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.data-table th {
  background: var(--bg-2);
  padding: 12px 14px;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

.data-table th.sortable {
  cursor: pointer;
  transition: color var(--transition);
}

.data-table th.sortable:hover {
  color: var(--text-1);
}

.data-table th.sortable::after {
  content: ' ⇅';
  font-size: 10px;
  opacity: 0.4;
}

.data-table th.sorted-asc::after {
  content: ' ▲';
  opacity: 1;
  color: var(--accent-h);
}

.data-table th.sorted-desc::after {
  content: ' ▼';
  opacity: 1;
  color: var(--accent-h);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-2);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.table-empty {
  text-align: center;
  padding: 36px 16px !important;
  color: var(--text-3);
  font-size: 14px;
}

.text-right { text-align: right; }
.text-center { text-align: center; }

.num-cell {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: 0.02em;
}

.rate-cell-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.rate-bar-bg {
  width: 48px;
  height: 6px;
  background: var(--bg-2);
  border-radius: 999px;
  overflow: hidden;
}

.rate-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: #22c55e;
}

.rate-bar-fill.rate-mid { background: #f59e0b; }
.rate-bar-fill.rate-low { background: #ef4444; }

.btn-details {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-details:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.modal-lg {
  max-width: 860px;
  width: 90%;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 2px;
}

.badge-disposition {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}

.badge-answered   { background: rgba(34, 197, 94, 0.15); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.badge-noanswer   { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-busy       { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-failed     { background: rgba(148, 163, 184, 0.15); color: #94a3b8; border: 1px solid rgba(148, 163, 184, 0.3); }

/* ═══════════════════════════════════════════════════════════
   WEBPHONE (WEBRTC SOFTPHONE) STYLES
   ═══════════════════════════════════════════════════════════ */

.webphone-container {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 960px) {
  .webphone-container {
    grid-template-columns: 1fr;
  }
}

.webphone-dialer-card,
.webphone-settings-card,
.webphone-history-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.webphone-side-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.card-section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
  margin: 0;
}

.card-section-desc {
  font-size: 13px;
  color: var(--text-3);
  margin: 4px 0 0 0;
}

/* Custom Styled CallerID Select */
.dialer-select-wrap {
  position: relative;
  width: 100%;
}

.dialer-select-wrap::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #94a3b8;
  pointer-events: none;
}

.dialer-callerid-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: #1e293b !important;
  color-scheme: dark;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  border-radius: 10px !important;
  color: #f8fafc !important;
  font-family: inherit;
  font-size: 13px !important;
  font-weight: 500;
  padding: 11px 38px 11px 14px !important;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.dialer-callerid-select:hover {
  border-color: rgba(255, 255, 255, 0.28) !important;
  background-color: #243248 !important;
}

.dialer-callerid-select:focus {
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25) !important;
}

.dialer-callerid-select option {
  background-color: #0f172a !important;
  color: #f8fafc !important;
  padding: 10px 14px;
}

/* Dialer Display */
.dialer-display {
  position: relative;
  margin: 12px 0 16px 0;
}

.dialer-input {
  width: 100%;
  height: 52px;
  background: #0b1120;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-md);
  padding: 0 48px 0 16px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 20px;
  font-weight: 600;
  color: #f8fafc;
  letter-spacing: 0.05em;
  outline: none;
  transition: all var(--transition);
}

.dialer-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.dialer-backspace {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.dialer-backspace:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

/* Dialpad Grid */
.dialpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.dial-btn {
  height: 64px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}

.dial-btn:hover {
  background: #334155;
  border-color: #818cf8;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  transform: translateY(-2px);
}

.dial-btn:active {
  background: #4338ca;
  border-color: #a5b4fc;
  transform: translateY(1px) scale(0.97);
}

.dial-btn .digit {
  font-size: 24px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.dial-btn .letters {
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.14em;
  margin-top: 2px;
}

/* Call Button */
.btn-call-primary {
  width: 100%;
  height: 52px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  transition: all var(--transition);
}

.btn-call-primary:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

.btn-call-primary:active {
  transform: translateY(1px);
}

/* Hangup Button */
.btn-hangup {
  width: 100%;
  height: 52px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
  transition: all var(--transition);
}

.btn-hangup:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
  transform: translateY(-1px);
}

/* Active Call Panel */
.active-call-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 8px 8px 8px;
}

.call-pulse-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-bottom: 14px;
  position: relative;
  box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
  animation: avatar-pulse 2s infinite;
}

@keyframes avatar-pulse {
  0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7); }
  70% { box-shadow: 0 0 0 16px rgba(99, 102, 241, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.active-call-dest {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-1);
}

.active-call-status {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
}

.active-call-timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px;
  font-weight: 700;
  color: #4ade80;
  margin: 14px 0 20px 0;
  letter-spacing: 0.05em;
}

.in-call-controls {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.in-call-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 11px;
  font-weight: 500;
}

.in-call-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-1);
  border-color: rgba(255, 255, 255, 0.2);
}

.in-call-btn.active {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #f87171;
}

/* Incoming Call Overlay Modal */
.incoming-call-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.incoming-call-card {
  width: 90%;
  max-width: 380px;
  background: var(--bg-1);
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: 20px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 40px rgba(34, 197, 94, 0.2);
  animation: modal-enter 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.incoming-pulse-ring {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-bottom: 16px;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: incoming-ring-pulse 1.2s infinite;
}

@keyframes incoming-ring-pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 24px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.incoming-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  margin-bottom: 12px;
}

.incoming-caller-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  margin: 0 0 6px 0;
}

.incoming-call-info {
  font-size: 13px;
  color: var(--text-3);
  margin: 0 0 24px 0;
}

.incoming-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
}

.incoming-btn {
  height: 48px;
  font-size: 14px;
  border-radius: 12px;
}

/* ════════════════════════════════════════════════════════════
   ANNOUNCEMENTS (АВТОИНФОРМАТОР)
   ════════════════════════════════════════════════════════════ */
.card-icon-announcement {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.announcement-phone-badge {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 15px;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.5px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.announcement-audio-box {
  margin-top: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.announcement-audio-box audio {
  height: 32px;
  max-width: 280px;
  flex: 1;
  outline: none;
  filter: invert(0.9) hue-rotate(180deg);
}

.audio-file-info {
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audio-dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.audio-dropzone:hover, .audio-dropzone.dragover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
}

.audio-dropzone input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 8px;
  color: var(--accent-h);
}

.dropzone-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.dropzone-hint {
  font-size: 12px;
  color: var(--text-3);
}

.audio-preview-box {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-s);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.audio-preview-box audio {
  height: 32px;
  max-width: 240px;
  filter: invert(0.9) hue-rotate(180deg);
}



