/* ═══════════════════════════════════════════════════════════════
   WA-bot Dashboard — Design System
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* Surfaces — cool, deep, layered */
  --surface-0: #0a0e14;
  --surface-1: #10151d;
  --surface-2: #161c26;
  --surface-3: #1d2530;
  --surface-hover: rgba(255, 255, 255, 0.045);
  --surface-active: rgba(255, 255, 255, 0.07);

  /* Chat-specific surfaces */
  --chat-bg: #0c1015;
  --bubble-in: #1a212b;
  --bubble-out: #0d4a3d;
  --bubble-bot: #122a24;

  /* Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  /* Text */
  --text-1: #eef1f4;
  --text-2: #aab4bf;
  --text-3: #76828d;
  --text-4: #4d5862;

  /* Accent — refined emerald */
  --accent: #1fd9a8;
  --accent-strong: #0fb98c;
  --accent-soft: rgba(31, 217, 168, 0.14);
  --accent-text-on: #04261d;

  /* Semantic */
  --danger: #f1556c;
  --danger-soft: rgba(241, 85, 108, 0.14);
  --warning: #f6ad55;
  --warning-soft: rgba(246, 173, 85, 0.14);
  --info: #5fb3e8;
  --info-soft: rgba(95, 179, 232, 0.14);

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);

  /* Motion */
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
  --t-fast: 120ms;
  --t-base: 200ms;

  /* Layout */
  --sidebar-w: 380px;
  --topbar-h: 58px;
}

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

html, body {
  height: 100%;
  background: var(--surface-0);
  color: var(--text-1);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: var(--r-pill); }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.18); }

.icon { width: 16px; height: 16px; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }

/* ═══ App Shell ═══ */
.app-shell { height: 100vh; display: flex; flex-direction: column; }

/* ═══ Top Bar ═══ */
.topbar {
  height: var(--topbar-h);
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  flex-shrink: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 28px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; flex-shrink: 0; }
.brand-mark {
  width: 30px; height: 30px; border-radius: var(--r-md);
  background: linear-gradient(140deg, var(--accent), var(--accent-strong));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08) inset;
}
.brand-mark svg { width: 17px; height: 17px; color: var(--accent-text-on); }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.2px; }
.brand-name span { color: var(--text-3); font-weight: 500; }

.nav-tabs { display: flex; align-items: center; gap: 2px; background: var(--surface-2); border-radius: var(--r-md); padding: 3px; }
.nav-tab {
  display: flex; align-items: center; gap: 7px;
  border: none; background: transparent; color: var(--text-3);
  font-size: 13px; font-weight: 500; padding: 7px 14px;
  border-radius: var(--r-sm); transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  position: relative; white-space: nowrap;
}
.nav-tab:hover { color: var(--text-2); }
.nav-tab.active { background: var(--surface-3); color: var(--text-1); box-shadow: var(--shadow-sm); }
.nav-tab .dot-flag {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  position: absolute; top: 6px; right: 7px; box-shadow: 0 0 0 2px var(--surface-2);
}

.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.status-pill {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-2);
  padding: 6px 12px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--border);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; position: relative; }
.status-dot.connected { background: var(--accent); box-shadow: 0 0 0 0 rgba(31,217,168,0.5); animation: pulse-ring 2.4s var(--ease) infinite; }
.status-dot.disconnected { background: var(--danger); }
.status-dot.connecting { background: var(--warning); }
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(31,217,168,0.45); }
  70% { box-shadow: 0 0 0 6px rgba(31,217,168,0); }
  100% { box-shadow: 0 0 0 0 rgba(31,217,168,0); }
}

.brain-switch {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-3); font-size: 12px; font-weight: 500;
  padding: 5px 6px 5px 12px; border-radius: var(--r-pill); cursor: pointer;
  transition: border-color var(--t-fast) var(--ease);
}
.brain-switch:hover { border-color: var(--border-strong); }
.brain-switch.active { color: var(--accent); }
.toggle-track { width: 28px; height: 16px; border-radius: var(--r-pill); background: var(--surface-3); position: relative; transition: background var(--t-base) var(--ease); }
.brain-switch.active .toggle-track { background: var(--accent-soft); }
.toggle-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--text-4); position: absolute; top: 2px; left: 2px; transition: transform var(--t-base) var(--ease), background var(--t-base) var(--ease); }
.brain-switch.active .toggle-thumb { background: var(--accent); transform: translateX(12px); }

.icon-btn {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-md); border: 1px solid transparent; background: transparent;
  color: var(--text-3); position: relative; transition: all var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text-1); border-color: var(--border); }
.icon-btn .badge-dot {
  position: absolute; top: -3px; right: -3px; min-width: 16px; height: 16px; padding: 0 3px;
  background: var(--danger); color: white; font-size: 9.5px; font-weight: 700;
  border-radius: var(--r-pill); display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--surface-1);
}

/* ═══ Body Layout ═══ */
.app-body { flex: 1; display: flex; overflow: hidden; min-height: 0; }

/* ═══ Sidebar ═══ */
.sidebar { width: var(--sidebar-w); flex-shrink: 0; background: var(--surface-1); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }

.search-wrap { padding: 12px; flex-shrink: 0; }
.search-field { position: relative; display: flex; align-items: center; }
.search-field svg { position: absolute; left: 11px; width: 14px; height: 14px; color: var(--text-4); pointer-events: none; }
.search-field input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 8px 12px 8px 32px; font-size: 13px; color: var(--text-1);
  outline: none; transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.search-field input::placeholder { color: var(--text-4); }
.search-field input:focus { border-color: var(--accent); background: var(--surface-3); }

.sidebar-scroll { flex: 1; overflow-y: auto; min-height: 0; }

.list-stat-bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 11px; color: var(--text-3); flex-shrink: 0; }
.list-stat-bar select { background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 4px 6px; font-size: 11px; outline: none; }

/* Chat / conversation row */
.row {
  display: flex; align-items: center; gap: 11px; padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.025); transition: background var(--t-fast) var(--ease);
  position: relative;
}
.row:hover { background: var(--surface-hover); }
.row.active { background: var(--accent-soft); }
.row.active::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; background: var(--accent); border-radius: 0 3px 3px 0; }

.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; position: relative;
  background: linear-gradient(155deg, #2a3744, #1c2530);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600; color: var(--text-2);
}
.avatar.ring-bot { box-shadow: 0 0 0 2px var(--accent); }
.avatar.ring-handled { box-shadow: 0 0 0 2px var(--warning); }
.avatar.ring-idle { box-shadow: 0 0 0 2px var(--info); }
.avatar-flag {
  position: absolute; bottom: -2px; right: -2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface-1); border: 2px solid var(--surface-1);
  display: flex; align-items: center; justify-content: center; font-size: 10px; line-height: 1;
}
.avatar-flag.blocked { background: #2a1418; }

.row-body { flex: 1; min-width: 0; }
.row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.row-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-1); }
.row-time { font-size: 10.5px; color: var(--text-4); flex-shrink: 0; }
.row-preview { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.unread-pill { background: var(--accent); color: var(--accent-text-on); font-size: 10.5px; font-weight: 700; border-radius: var(--r-pill); min-width: 19px; height: 19px; padding: 0 5px; display: flex; align-items: center; justify-content: center; }

.skeleton-row { display: flex; align-items: center; gap: 11px; padding: 10px 14px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--r-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skel-avatar { width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; }
.skel-lines { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.skel-line { height: 10px; border-radius: 4px; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 50px 24px; color: var(--text-3); gap: 10px; height: 100%; }
.empty-state svg { width: 38px; height: 38px; color: var(--text-4); margin-bottom: 4px; }
.empty-state .e-title { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.empty-state .e-sub { font-size: 12px; color: var(--text-4); max-width: 240px; }

/* ═══ Main Panel ═══ */
.main-panel { flex: 1; display: flex; flex-direction: column; background: var(--chat-bg); min-width: 0; min-height: 0; }

.thread-header { height: 58px; flex-shrink: 0; display: flex; align-items: center; gap: 12px; padding: 0 18px; background: var(--surface-1); border-bottom: 1px solid var(--border); }
.thread-header .avatar { width: 36px; height: 36px; font-size: 13px; }
.thread-title { font-size: 13.5px; font-weight: 600; }
.thread-sub { font-size: 11px; color: var(--text-4); font-family: 'SF Mono', 'Cascadia Code', monospace; }

.thread-scroll { flex: 1; overflow-y: auto; padding: 18px 0; display: flex; flex-direction: column; gap: 2px; }
.thread-scroll-inner { max-width: 760px; margin: 0 auto; width: 100%; padding: 0 32px; display: flex; flex-direction: column; gap: 2px; }

.date-sep { text-align: center; padding: 14px 0 10px; }
.date-sep span { background: var(--surface-2); color: var(--text-3); font-size: 10.5px; font-weight: 500; padding: 4px 12px; border-radius: var(--r-pill); border: 1px solid var(--border); }

.bubble { max-width: 64%; padding: 8px 11px; border-radius: var(--r-md); font-size: 13.5px; line-height: 1.45; word-wrap: break-word; position: relative; box-shadow: var(--shadow-sm); }
.bubble.in { background: var(--bubble-in); align-self: flex-start; border-bottom-left-radius: 3px; }
.bubble.out { background: var(--bubble-out); align-self: flex-end; border-bottom-right-radius: 3px; }
.bubble.bot { background: var(--bubble-bot); align-self: flex-end; border-bottom-right-radius: 3px; border: 1px solid rgba(31,217,168,0.25); }
.bubble img.bubble-media { max-width: 100%; border-radius: var(--r-sm); margin-top: 2px; display: block; }
.bubble-bot-tag { font-size: 10px; font-weight: 700; color: var(--accent); margin-bottom: 2px; display: flex; align-items: center; gap: 4px; letter-spacing: 0.2px; }
.bubble-time { font-size: 10px; color: rgba(255,255,255,0.38); text-align: right; margin-top: 3px; }

.load-more-wrap { text-align: center; padding: 6px 0 14px; }
.btn-ghost-sm { background: transparent; border: 1px solid var(--border); color: var(--text-3); padding: 6px 14px; border-radius: var(--r-pill); font-size: 11.5px; transition: all var(--t-fast) var(--ease); }
.btn-ghost-sm:hover { border-color: var(--border-strong); color: var(--text-1); background: var(--surface-2); }

.composer { padding: 12px 18px; background: var(--surface-1); border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.composer input { flex: 1; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 10px 16px; font-size: 13.5px; color: var(--text-1); outline: none; transition: border-color var(--t-fast) var(--ease); }
.composer input:focus { border-color: var(--accent); }
.composer input::placeholder { color: var(--text-4); }
.send-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none; flex-shrink: 0;
  background: var(--accent); color: var(--accent-text-on); display: flex; align-items: center; justify-content: center;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.send-btn:hover { background: var(--accent-strong); transform: scale(1.05); }
.send-btn:disabled { background: var(--surface-3); color: var(--text-4); cursor: not-allowed; transform: none; }

/* ═══ Welcome / QR ═══ */
.welcome { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; }
.welcome-mark { width: 64px; height: 64px; border-radius: var(--r-lg); background: linear-gradient(140deg, var(--accent), var(--accent-strong)); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-md); }
.welcome-mark svg { width: 34px; height: 34px; color: var(--accent-text-on); }
.welcome h2 { font-size: 19px; font-weight: 600; }
.welcome p { font-size: 13px; color: var(--text-3); }
.qr-card { background: white; padding: 16px; border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
.qr-card img { width: 230px; height: 230px; display: block; border-radius: var(--r-sm); }
.qr-hint { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); padding: 8px 14px; border-radius: var(--r-pill); border: 1px solid var(--border); }
.qr-hint svg { width: 14px; height: 14px; color: var(--accent); }
.pairing-code { font-size: 26px; font-weight: 700; letter-spacing: 4px; font-family: 'SF Mono', monospace; color: var(--accent); background: var(--surface-2); padding: 12px 22px; border-radius: var(--r-md); border: 1px solid var(--border); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--border); border-top-color: var(--accent); animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ AI Log & Audit Log ═══ */
.log-scroll { flex: 1; overflow-y: auto; }
.log-card { border-bottom: 1px solid var(--border); padding: 16px 22px; transition: background var(--t-fast) var(--ease); }
.log-card:hover { background: rgba(255,255,255,0.012); }
.log-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.log-card-head .avatar { width: 32px; height: 32px; font-size: 12px; }
.log-card-name { font-size: 13px; font-weight: 600; }
.log-card-phone { font-size: 11px; color: var(--text-4); font-family: monospace; }
.log-msgs { margin-left: 42px; display: flex; flex-direction: column; gap: 5px; }
.log-line { font-size: 12.5px; line-height: 1.5; padding: 6px 10px; border-radius: var(--r-sm); max-width: 100%; word-wrap: break-word; white-space: pre-wrap; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.log-line.patient { background: var(--bubble-in); }
.log-line.bot { background: var(--bubble-bot); border-left: 2px solid var(--accent); }
.log-line.human { background: var(--warning-soft); border-left: 2px solid var(--warning); }
.log-tag { font-size: 9.5px; font-weight: 700; letter-spacing: 0.3px; flex-shrink: 0; }
.log-line.patient .log-tag { color: var(--info); }
.log-line.bot .log-tag { color: var(--accent); }
.log-line.human .log-tag { color: var(--warning); }
.log-time-stamp { font-size: 9.5px; color: var(--text-4); margin-left: auto; flex-shrink: 0; }

.audit-wrap { max-width: 880px; margin: 0 auto; padding: 28px 24px 60px; }
.audit-title { font-size: 16px; font-weight: 700; color: var(--accent); margin-bottom: 20px; display: flex; align-items: center; gap: 8px; }
.audit-entry { border-radius: var(--r-md); padding: 13px 16px; margin-bottom: 10px; cursor: pointer; transition: transform var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease); border-left: 3px solid var(--border); }
.audit-entry:hover { opacity: 0.85; }
.audit-entry.t-incoming { background: var(--surface-2); border-left-color: var(--text-4); }
.audit-entry.t-decision { background: var(--warning-soft); border-left-color: var(--warning); }
.audit-entry.t-outgoing { background: var(--bubble-out); border-left-color: var(--info); }
.audit-entry.t-bot { background: var(--bubble-bot); border-left-color: var(--accent); }
.audit-entry-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; padding-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,0.08); font-size: 12px; }
.audit-entry-head .who { font-weight: 600; }
.audit-entry-head .who .name { color: var(--accent); }
.audit-entry-head .when { font-size: 10.5px; color: rgba(255,255,255,0.45); }
.audit-entry-body { font-size: 13.5px; line-height: 1.6; }
.audit-divider { border-top: 1px dashed rgba(255,255,255,0.13); margin: 22px 0 16px; }

/* ═══ Modal Shell ═══ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,8,12,0.6); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  opacity: 0; pointer-events: none; transition: opacity var(--t-base) var(--ease);
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal-box {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); width: 520px; max-width: 92vw; max-height: 86vh;
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(8px) scale(0.98); transition: transform var(--t-base) var(--ease);
}
.modal-backdrop.open .modal-box { transform: translateY(0) scale(1); }
.modal-box.wide { width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-head h3 { font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); flex-shrink: 0; }

.modal-tabs { display: flex; gap: 4px; padding: 0 18px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-tab { background: none; border: none; color: var(--text-3); font-size: 12.5px; font-weight: 500; padding: 11px 8px; cursor: pointer; border-bottom: 2px solid transparent; display: flex; align-items: center; gap: 6px; transition: color var(--t-fast) var(--ease); }
.modal-tab:hover { color: var(--text-2); }
.modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.field-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.05); gap: 12px; }
.field-row:last-child { border-bottom: none; }
.field-row label { font-size: 12.5px; color: var(--text-2); }
.field-row .field-hint { font-size: 10px; color: var(--text-4); margin-top: 1px; }
.field-control { display: flex; align-items: center; gap: 6px; }
.field-control input[type=time], .field-control input[type=number], .field-control input[type=text] {
  background: var(--surface-1); border: 1px solid var(--border); color: var(--text-1);
  padding: 5px 8px; border-radius: var(--r-sm); font-size: 12.5px; outline: none;
}
.field-control input:focus { border-color: var(--accent); }
.field-control .unit { font-size: 11.5px; color: var(--text-4); }

.info-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface-1); border-radius: var(--r-md); border: 1px solid var(--border); margin-bottom: 14px; }
.info-card svg { width: 20px; height: 20px; color: var(--accent); flex-shrink: 0; }
.info-card .label { font-size: 9.5px; color: var(--text-4); text-transform: uppercase; letter-spacing: 0.6px; }
.info-card .value { font-size: 12.5px; color: var(--accent); font-weight: 500; }

.section-label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; margin-top: 4px; }
.note-box { margin-top: 14px; padding: 10px 12px; background: var(--surface-1); border-radius: var(--r-md); border: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); line-height: 1.7; }
.note-box .nb-title { font-size: 11px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; }

.btn-primary { width: 100%; padding: 10px; background: var(--accent); color: var(--accent-text-on); font-weight: 700; border: none; border-radius: var(--r-md); font-size: 13px; transition: background var(--t-fast) var(--ease); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:disabled { background: var(--surface-3); color: var(--text-4); cursor: not-allowed; }
.save-status { text-align: center; font-size: 11px; margin-top: 8px; min-height: 14px; transition: opacity var(--t-base) var(--ease); }

.price-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.price-row:last-of-type { border-bottom: none; }
.price-label .pl-main { font-size: 13px; color: var(--text-2); }
.price-label .pl-sub { font-size: 10px; color: var(--text-4); }
.stepper { display: flex; align-items: center; gap: 5px; }
.stepper button { width: 26px; height: 26px; border-radius: var(--r-sm); background: var(--surface-1); border: 1px solid var(--border); color: var(--text-2); font-size: 13px; transition: background var(--t-fast) var(--ease); }
.stepper button:hover { background: var(--surface-3); }
.stepper input { width: 78px; text-align: center; font-weight: 700; font-size: 13.5px; }
.stepper .curr { color: var(--text-4); font-size: 12.5px; }

.equalizer { display: flex; gap: 4px; align-items: flex-end; height: 200px; padding: 4px 2px; overflow-x: auto; }
.eq-col { flex: 0 0 30px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.eq-readout { font-size: 9px; color: var(--text-3); text-align: center; line-height: 1.3; font-variant-numeric: tabular-nums; }
.eq-readout .closed { color: var(--danger); }
.eq-bar { position: relative; width: 100%; height: 150px; background: var(--surface-1); border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--border); }
.eq-fill { position: absolute; left: 0; right: 0; background: linear-gradient(180deg, rgba(31,217,168,0.4), rgba(31,217,168,0.1)); }
.eq-handle { position: absolute; left: 0; right: 0; height: 4px; background: var(--accent); cursor: ns-resize; z-index: 2; border-radius: 2px; box-shadow: 0 0 6px rgba(31,217,168,0.6); }
.eq-handle:hover { background: var(--accent-strong); }
.eq-dot { position: absolute; left: 50%; transform: translateX(-50%); border-radius: 50%; z-index: 3; }
.eq-label { text-align: center; line-height: 1.3; }
.eq-label .day { font-size: 11px; font-weight: 600; }
.eq-label .date { font-size: 9px; color: var(--text-4); }
.eq-sep { width: 2px; min-width: 2px; background: var(--border); align-self: stretch; margin: 0 2px; border-radius: 1px; }

/* ═══ Phone Matcher / Blacklist ═══ */
.match-toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.btn-sm { padding: 7px 14px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-2); border-radius: var(--r-md); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; transition: all var(--t-fast) var(--ease); }
.btn-sm:hover { background: var(--surface-3); color: var(--text-1); }
.btn-sm.success { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.btn-sm.success:hover { background: var(--accent); color: var(--accent-text-on); }
.match-status { font-size: 12px; color: var(--text-3); margin-bottom: 10px; min-height: 16px; }
.match-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 8px; overflow: hidden; }
.match-card-main { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; }
.match-card .mc-name { font-weight: 600; font-size: 13px; }
.match-card .mc-phone { color: var(--accent); font-size: 11.5px; cursor: pointer; }
.match-card .mc-phone:hover { text-decoration: underline; }
.match-card .mc-conf { color: var(--text-4); }
.match-actions { display: flex; gap: 6px; }
.match-preview { display: none; padding: 0 12px 10px; max-height: 200px; overflow-y: auto; border-top: 1px solid var(--border); }
.match-preview-line { font-size: 11px; padding: 5px 0; border-top: 1px solid rgba(255,255,255,0.04); color: var(--text-3); }
.match-preview-line:first-child { border-top: none; }

.bl-row { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 12.5px; }
.bl-row:last-child { border-bottom: none; }
.bl-row .bl-name { flex: 1; color: var(--text-2); }
.bl-row .bl-num { color: var(--text-4); font-family: monospace; font-size: 11px; }
.bl-count { font-size: 11px; color: var(--text-4); margin-bottom: 8px; }

/* ═══ DB Viewer ═══ */
.db-search-wrap { padding: 12px 18px; border-bottom: 1px solid var(--border); }
.db-rows { flex: 1; overflow-y: auto; padding: 6px 18px; }
.db-row { display: flex; align-items: center; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 12.5px; gap: 10px; }
.db-row .idx { color: var(--text-4); min-width: 26px; text-align: right; font-size: 10px; }
.db-row .name { flex: 1; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-row .phone { color: var(--info); font-size: 11.5px; font-family: monospace; cursor: pointer; }
.db-row .phone:hover { text-decoration: underline; }
.db-row .tick { color: var(--accent); font-size: 13px; min-width: 16px; text-align: center; }
.pill-tag { font-size: 9px; padding: 2px 6px; border-radius: var(--r-sm); font-weight: 700; flex-shrink: 0; white-space: nowrap; }
.pill-tag.lid { background: var(--warning-soft); color: var(--warning); }
.pill-tag.info { background: var(--info-soft); color: var(--info); }
.pill-tag.surgery { background: var(--danger-soft); color: var(--danger); }
.db-stats-bar { padding: 8px 18px; background: var(--surface-1); border-top: 1px solid var(--border); font-size: 11px; color: var(--text-4); display: flex; gap: 16px; flex-shrink: 0; }
.db-stats-bar b { color: var(--accent); font-weight: 600; }

/* ═══ Chat Preview Popup ═══ */
.preview-box { background: var(--chat-bg); width: 460px; height: 64vh; }
.preview-msgs { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.preview-bubble { max-width: 82%; padding: 6px 9px; border-radius: var(--r-sm); font-size: 11.5px; line-height: 1.4; }
.preview-bubble.in { background: var(--bubble-in); align-self: flex-start; }
.preview-bubble.out { background: var(--bubble-out); align-self: flex-end; }
.preview-bubble.bot { background: var(--bubble-bot); align-self: flex-end; }
.preview-bubble .pb-time { font-size: 9px; color: var(--text-4); margin-top: 2px; text-align: right; }

/* ═══ Toasts ═══ */
.toast-stack { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 2000; align-items: flex-end; }
.toast {
  display: flex; align-items: center; gap: 10px; background: var(--surface-3); border: 1px solid var(--border-strong);
  color: var(--text-1); padding: 11px 16px; border-radius: var(--r-md); font-size: 12.5px; box-shadow: var(--shadow-md);
  max-width: 360px; animation: toast-in var(--t-base) var(--ease);
}
.toast.success { border-left: 3px solid var(--accent); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success svg { color: var(--accent); }
.toast.error svg { color: var(--danger); }
.toast.info svg { color: var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
.toast.leaving { animation: toast-out var(--t-fast) var(--ease) forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateX(8px); } }

/* ═══ Confirm Dialog ═══ */
.confirm-box { width: 380px; padding: 20px; text-align: center; }
.confirm-box .cf-icon { width: 42px; height: 42px; border-radius: 50%; background: var(--warning-soft); color: var(--warning); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.confirm-box .cf-icon.danger { background: var(--danger-soft); color: var(--danger); }
.confirm-box .cf-title { font-size: 14.5px; font-weight: 700; margin-bottom: 6px; }
.confirm-box .cf-msg { font-size: 12.5px; color: var(--text-3); line-height: 1.6; white-space: pre-line; margin-bottom: 18px; }
.confirm-actions { display: flex; gap: 8px; }
.confirm-actions button { flex: 1; padding: 9px; border-radius: var(--r-md); font-size: 13px; font-weight: 600; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-2); }
.confirm-actions button:hover { background: var(--surface-3); }
.confirm-actions button.danger { background: var(--danger); border-color: transparent; color: white; }
.confirm-actions button.danger:hover { background: #d8425a; }
.confirm-actions button.primary { background: var(--accent); border-color: transparent; color: var(--accent-text-on); }
.confirm-actions button.primary:hover { background: var(--accent-strong); }

/* ═══ Misc ═══ */
.media-label { display: inline-flex; align-items: center; gap: 5px; }

@media (max-width: 980px) {
  :root { --sidebar-w: 320px; }
  .thread-scroll-inner { padding: 0 16px; }
}
