/* ─── IBM Plex Sans ───────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;600&display=swap');

/* ─── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 220px;
  --bg:        #ffffff;
  --surface:   #f4f4f4;
  --surface2:  #e0e0e0;
  --border:    #e0e0e0;
  --accent:    #0f62fe;
  --accent-h:  #0050e6;
  --text:      #161616;
  --muted:     #525252;
  --subtle:    #8c8c8c;
  --success:   #24a148;
  --danger:    #da1e28;
  --warning:   #f1c21b;
  --radius:    0px;
  --shadow:    0 2px 8px rgba(0,0,0,.08);
}

/* ─── Dark theme tokens ───────────────────────────────────────────────────── */
.dark {
  --bg:      #161616;
  --surface: #262626;
  --surface2:#393939;
  --border:  #525252;
  --accent:  #4589ff;
  --accent-h:#78a9ff;
  --text:    #f4f4f4;
  --muted:   #c6c6c6;
  --subtle:  #6f6f6f;
  --success: #42be65;
  --danger:  #ff8389;
  --warning: #f1c21b;
  --shadow:  0 2px 8px rgba(0,0,0,.5);
}
.dark .sidebar          { background: #262626; }
.dark .nav-item:hover   { background: #393939; }
.dark .nav-item.active  { background: #4589ff; }
.dark .input            { background: #262626; border-bottom-color: #525252; }
.dark .input:focus      { border-bottom-color: #4589ff; }
.dark .chat-bubble.assistant { background: #262626; border-color: #525252; }
.dark .chat-messages    { background: #1c1c1c; }
.dark .modal            { background: #262626; }
.dark .user-menu-dropdown { background: #262626; }

@media (prefers-color-scheme: dark) {
  .auto {
    --bg:      #161616;
    --surface: #262626;
    --surface2:#393939;
    --border:  #525252;
    --accent:  #4589ff;
    --accent-h:#78a9ff;
    --text:    #f4f4f4;
    --muted:   #c6c6c6;
    --subtle:  #6f6f6f;
    --success: #42be65;
    --danger:  #ff8389;
    --warning: #f1c21b;
    --shadow:  0 2px 8px rgba(0,0,0,.5);
  }
  .auto .sidebar          { background: #262626; }
  .auto .nav-item:hover   { background: #393939; }
  .auto .nav-item.active  { background: #4589ff; }
  .auto .input            { background: #262626; border-bottom-color: #525252; }
  .auto .input:focus      { border-bottom-color: #4589ff; }
  .auto .chat-bubble.assistant { background: #262626; border-color: #525252; }
  .auto .chat-messages    { background: #1c1c1c; }
  .auto .modal            { background: #262626; }
  .auto .user-menu-dropdown { background: #262626; }
}

/* ─── Theme toggle button ─────────────────────────────────────────────────── */
.theme-toggle {
  background: none; border: 1px solid var(--border);
  color: var(--muted); cursor: pointer;
  width: 32px; height: 32px; border-radius: 0px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; transition: border-color .15s, color .15s;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

html, body { height: 100%; font-family: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif; font-size: 14px; letter-spacing: 0.16px; }
body { background: var(--bg); color: var(--text); overflow: hidden; }

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.layout { display: flex; height: 100vh; }

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #161616;
  border-right: none;
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  gap: 28px;
  transition: width .2s ease;
  overflow: hidden;
}
.sidebar.collapsed { width: 56px; padding: 20px 8px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .brand { justify-content: center; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; gap: 0; }
.sidebar.collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.sidebar-toggle {
  margin-top: 4px;
  background: none; border: 1px solid var(--border);
  color: var(--muted); cursor: pointer; border-radius: 0px;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s; flex-shrink: 0; align-self: flex-start;
}
.sidebar.collapsed .sidebar-toggle { align-self: center; }
.sidebar-toggle:hover { border-color: var(--accent); color: var(--accent); }
.sidebar-toggle svg { transition: transform .2s ease; }

.sidebar.collapsed .sidebar-toggle {
  width: 32px; height: 32px; align-self: center;
}
.sidebar { position: relative; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
}
.brand-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 0px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff; letter-spacing: 0.5px;
}
.brand-text { font-size: 15px; font-weight: 600; color: #ffffff; }

/* Nav */
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 0px;
  color: #c6c6c6; text-decoration: none;
  font-size: 13.5px; font-weight: 400;
  cursor: pointer; transition: all .15s;
}
.nav-item svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-item:hover { background: #262626; color: #ffffff; }
.nav-item.active { background: var(--accent); color: #ffffff; }

/* Header client switcher */
.header-client {
  display: flex; align-items: center; gap: 7px; flex-shrink: 0;
}
.header-client-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted); white-space: nowrap;
}
.header-client-select {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 0px;
  padding: 5px 10px; font-size: 13px; cursor: pointer;
  outline: none; transition: border-color .15s; max-width: 180px;
}
.header-client-select:focus { border-color: var(--accent); }

/* ─── Main ───────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  padding: 18px 28px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 16px;
}
.page-title { font-size: 18px; font-weight: 600; flex: 1; color: var(--text); }

.header-user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.header-user-email { font-size: 12px; color: var(--muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 0px; padding: 5px 7px; cursor: pointer; display: flex;
  align-items: center; transition: color .15s, border-color .15s;
}
.btn-logout:hover { color: var(--danger); border-color: var(--danger); }

/* ─── User menu dropdown ──────────────────────────────────────────────────── */
.user-menu-wrap { position: relative; }
.user-menu-btn {
  background: none; border: none; cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  color: var(--muted); font-size: 12px;
  padding: 5px 8px; border-radius: 0px; max-width: 190px;
  transition: background .15s, color .15s;
}
.user-menu-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-btn:hover { background: var(--surface); color: var(--text); }
.user-menu-btn svg { flex-shrink: 0; transition: transform .2s; }
.user-menu-wrap.open .user-menu-btn svg { transform: rotate(180deg); }
.user-menu-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 0px; box-shadow: var(--shadow);
  min-width: 170px; z-index: 200; overflow: hidden;
}
.user-menu-dropdown.hidden { display: none; }
.user-menu-item {
  display: block; padding: 10px 16px; color: var(--text);
  text-decoration: none; font-size: 13px; cursor: pointer;
  transition: background .15s; border: none; background: none; width: 100%; text-align: left;
}
.user-menu-item:hover { background: var(--surface); }

/* ─── Plan lock banner — hidden in lifetime ───────────────────────────────── */
.plan-lock-banner { display: none !important; }
button:disabled { opacity: 0.45; cursor: not-allowed !important; }

/* ─── Plan badges ─────────────────────────────────────────────────────────── */
.plan-badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 0px; font-size: 12px; font-weight: 600; letter-spacing: .3px;
}
.plan-badge-free       { background: #e0e0e0; color: var(--muted); }
.plan-badge-paid       { background: rgba(15,98,254,.15); color: var(--accent); }
.plan-badge-expired    { background: rgba(218,30,40,.1); color: var(--danger); }
.plan-badge-enterprise { background: rgba(241,194,27,.18); color: #8c6900; }

/* ─── Plan tier card ──────────────────────────────────────────────────────── */
.plan-tier-row   { margin-bottom: 10px; }
.plan-tier-row .plan-badge { font-size: 16px; font-weight: 600; padding: 4px 14px; letter-spacing: .5px; }
.plan-tier-desc  { font-size: 13px; color: var(--muted); line-height: 1.55; margin-bottom: 10px; }
.plan-tier-price { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 18px; }
.plan-tier-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ─── Role badges ─────────────────────────────────────────────────────────── */
.role-badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 0px; font-size: 12px; font-weight: 600;
}
.role-owner    { background: rgba(15,98,254,.12); color: var(--accent); }
.role-manager  { background: rgba(36,161,72,.12);  color: #1a7a38; }
.role-operator { background: #e0e0e0; color: var(--muted); }

/* ─── Pages ──────────────────────────────────────────────────────────────── */
.page { display: none; flex: 1; overflow-y: auto; padding: 24px 28px; flex-direction: column; gap: 20px; }
.page.active { display: flex; }

/* ─── Settings sub-tabs ──────────────────────────────────────────────────── */
.settings-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); padding-bottom: 0; margin-bottom: 4px; flex-shrink: 0; }
.settings-tab {
  padding: 10px 20px;
  font-size: 13px; font-weight: 400;
  color: var(--muted);
  background: none; border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer; transition: color .15s, border-color .15s;
  letter-spacing: 0.16px;
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.settings-panel { display: none; flex: 1; flex-direction: column; gap: 20px; overflow-y: auto; }
.settings-panel.active { display: flex; }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.cards-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card { background: var(--bg); border: 1px solid var(--border); border-radius: 0px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.card-full { grid-column: 1 / -1; }
.card-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.card-divider { border: none; border-top: 1px solid var(--border); margin: 2px 0; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; }
.card-title-row > span { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
label { font-size: 12px; color: var(--muted); font-weight: 400; letter-spacing: 0.16px; }
.hint { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 6px; }

.input {
  background: var(--surface); color: var(--text);
  border: none; border-bottom: 1px solid var(--border);
  border-radius: 0px;
  padding: 11px 16px; font-size: 14px; width: 100%;
  outline: none; transition: border-color .15s;
  font-family: inherit; letter-spacing: 0.16px;
}
.input:focus { border-bottom: 2px solid var(--accent); }
.input:disabled { opacity: .5; cursor: not-allowed; }
select.input { cursor: pointer; }
.input-sm { padding: 5px 10px; font-size: 12px; width: auto; }
.textarea { resize: vertical; min-height: 320px; line-height: 1.6; font-family: inherit; }

/* Secret inputs */
.secret-wrap { position: relative; }
.secret-wrap .input { padding-right: 38px; }
.eye-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--muted);
  padding: 2px; display: flex; align-items: center; transition: color .15s;
}
.eye-btn:hover { color: var(--text); }
.eye-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Webhook URL */
.webhook-url { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; padding: 8px 0 2px; }
.label-muted { color: var(--muted); }
.webhook-url code { color: var(--accent); font-size: 11.5px; word-break: break-all; }

/* Tools list */
.tools-list { display: flex; flex-direction: column; gap: 8px; }
.tool-item { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.tool-item input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.tool-item span { font-size: 13px; }
.tool-badge {
  font-size: 10px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase;
  padding: 2px 6px; border-radius: 0px;
  background: rgba(218,30,40,.1); color: var(--danger);
}

/* ─── Bottom bar ─────────────────────────────────────────────────────────── */
.bottom-bar { display: flex; align-items: center; gap: 12px; padding: 16px 0 4px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; transition: background .3s; }
.status-dot.ok  { background: var(--success); }
.status-dot.err { background: var(--danger); }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 12px 16px; border-radius: 0px;
  font-size: 14px; font-weight: 400; cursor: pointer;
  border: none; transition: all .15s; white-space: nowrap;
  letter-spacing: 0.16px; font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b81921; }
.btn-sm { padding: 8px 12px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.flex-gap { display: flex; align-items: center; gap: 8px; }

/* ─── Stats row ──────────────────────────────────────────────────────────── */
.stats-row { display: flex; gap: 12px; flex-wrap: wrap; padding-bottom: 4px; }
.stat-chip {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 0px; padding: 8px 14px;
  font-size: 12px; color: var(--muted);
  display: flex; flex-direction: column; gap: 2px;
}
.stat-chip strong { font-size: 20px; font-weight: 600; color: var(--text); }

/* ─── Table ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 9px 14px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover td { background: var(--surface); }
.table tbody tr:last-child td { border-bottom: none; }

/* Status badges */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 0px; font-size: 11px; font-weight: 600; }
.badge-pending  { background: rgba(241,194,27,.15); color: #8c6900; }
.badge-shipped  { background: rgba(15,98,254,.12);  color: var(--accent); }
.badge-completed{ background: rgba(36,161,72,.12);  color: #1a7a38; }
.badge-cancelled{ background: rgba(218,30,40,.1);   color: var(--danger); }

/* ─── Status select ──────────────────────────────────────────────────────── */
.status-select { border: none; outline: none; border-radius: 0px; padding: 3px 9px; font-size: 11px; font-weight: 600; cursor: pointer; appearance: none; -webkit-appearance: none; }
.status-select.badge-pending  { background: rgba(241,194,27,.15); color: #8c6900; }
.status-select.badge-shipped  { background: rgba(15,98,254,.12);  color: var(--accent); }
.status-select.badge-completed{ background: rgba(36,161,72,.12);  color: #1a7a38; }
.status-select.badge-cancelled{ background: rgba(218,30,40,.1);   color: var(--danger); }

/* ─── Pagination ─────────────────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; padding: 12px 0 4px; flex-wrap: wrap; }
.pg-btn {
  min-width: 32px; height: 32px; border-radius: 0px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0 8px; transition: all .15s;
}
.pg-btn:hover { border-color: var(--accent); color: var(--accent); }
.pg-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pg-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 0px; box-shadow: 0 4px 32px rgba(0,0,0,.12);
  width: 480px; max-width: 95vw; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-title { padding: 18px 20px 14px; font-size: 15px; font-weight: 600; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ─── Confirm dialog ─────────────────────────────────────────────────────── */
.confirm-modal { max-width: 400px; width: 95vw; }
.confirm-head {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 24px 0;
}
.confirm-icon {
  width: 22px; height: 22px; flex-shrink: 0;
  color: var(--accent-h); stroke-width: 1.8;
}
.confirm-title { font-size: 15px; font-weight: 600; color: var(--text); }
.confirm-body {
  padding: 12px 24px 20px 54px;
  font-size: 13.5px; line-height: 1.65; color: var(--muted);
}
.confirm-foot {
  padding: 12px 24px 16px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  padding: 7px 14px; border-radius: 0px; font-size: 13px; font-weight: 400;
  opacity: 0; pointer-events: none; transition: opacity .25s; max-width: 360px;
}
.toast.show { opacity: 1; }
.toast.ok  { background: rgba(36,161,72,.1);  color: #1a7a38; border: 1px solid rgba(36,161,72,.3); }
.toast.err { background: rgba(218,30,40,.08); color: var(--danger); border: 1px solid rgba(218,30,40,.2); }

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 0px; }

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty { padding: 40px; text-align: center; color: var(--muted); font-size: 13px; }

/* ─── Voice toggle ───────────────────────────────────────────────────────── */
.toggle-row { display: flex; align-items: center; justify-content: space-between; cursor: pointer; margin-bottom: 6px; }
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--border); border-radius: 22px; transition: .2s; }
.toggle-slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }
.hint-text { font-size: 12px; color: var(--muted); margin-top: 2px; }
#voiceSettings { margin-top: 12px; display: flex; flex-direction: column; gap: 14px; }

/* ─── Chats page ─────────────────────────────────────────────────────────── */
#page-chats { padding: 0; gap: 0; overflow: hidden; }
.chats-layout { flex: 1; display: flex; min-height: 0; }
.chats-sidebar { width: 280px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.chats-topbar { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chats-list { flex: 1; overflow-y: auto; }
.chat-item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.chat-item:hover { background: var(--surface); }
.chat-item.active { background: rgba(15,98,254,.08); border-left: 3px solid var(--accent); padding-left: 13px; }
.chat-item-phone { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.chat-item-preview { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.chat-item-meta { display: flex; justify-content: space-between; align-items: center; }
.chat-item-time { font-size: 11px; color: var(--muted); }
.chat-item-count { font-size: 11px; background: var(--surface); color: var(--muted); border-radius: 0px; padding: 1px 7px; }
.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); gap: 10px; font-size: 14px; }
.chat-empty-icon { font-size: 42px; }
.chat-loading { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
.chat-header { padding: 12px 20px; flex-shrink: 0; border-bottom: 1px solid var(--border); background: var(--bg); display: flex; align-items: center; justify-content: space-between; }
.chat-header-phone { font-size: 15px; font-weight: 600; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; background: var(--surface); }
.chat-date-divider { text-align: center; font-size: 11px; color: var(--muted); margin: 10px 0 4px; position: relative; }
.chat-date-divider::before, .chat-date-divider::after { content: ''; position: absolute; top: 50%; width: calc(50% - 52px); height: 1px; background: var(--border); }
.chat-date-divider::before { left: 0; }
.chat-date-divider::after  { right: 0; }
.chat-bubble { max-width: 72%; padding: 8px 12px; border-radius: 0px; display: flex; flex-direction: column; gap: 3px; }
.chat-bubble.user { align-self: flex-end; background: var(--accent); color: #fff; }
.chat-bubble.assistant { align-self: flex-start; background: var(--bg); border: 1px solid var(--border); }
.chat-bubble-text { font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.chat-bubble-time { font-size: 10px; opacity: 0.55; align-self: flex-end; }
.chat-bubble.operator { align-self: flex-start; background: rgba(241,194,27,.1); border: 1px solid rgba(241,194,27,.3); }
.chat-bubble.operator .chat-bubble-text { color: var(--text); }
.operator-mode-bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 20px; flex-shrink: 0; background: rgba(241,194,27,.08); border-bottom: 1px solid rgba(241,194,27,.3); }
.operator-mode-label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: #8c6900; }
.operator-mode-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); animation: pulse-dot 1.5s ease-in-out infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.chat-reply-form { flex-shrink: 0; display: flex; flex-direction: column; gap: 8px; padding: 10px 16px 12px; border-top: 1px solid rgba(241,194,27,.25); background: var(--bg); }
.chat-reply-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-image-preview { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.chat-image-thumb { max-height: 72px; max-width: 120px; border-radius: 0px; object-fit: cover; border: 1px solid var(--border); }
.chat-image-remove { width: 22px; height: 22px; border-radius: 0px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-size: 11px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chat-image-remove:hover { background: var(--surface2); }
.btn-attach { flex-shrink: 0; width: 38px; height: 38px; background: var(--surface); border: 1px solid var(--border); border-radius: 0px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; transition: border-color .15s; }
.btn-attach:hover { border-color: var(--warning); }
.chat-bubble-image { font-size: 13px; color: var(--muted); font-style: italic; padding: 2px 0; }
.chat-reply-input { flex: 1; resize: none; min-height: 38px; max-height: 120px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 0px; padding: 9px 12px; font-size: 13px; font-family: inherit; line-height: 1.45; overflow-y: auto; transition: border-color .15s; }
.chat-reply-input:focus { outline: none; border-color: var(--warning); }
.btn-send { flex-shrink: 0; height: 38px; padding: 0 16px; background: var(--accent); color: #fff; border: none; border-radius: 0px; font-size: 13px; font-weight: 400; cursor: pointer; transition: opacity .15s; font-family: inherit; }
.btn-send:hover { background: var(--accent-h); }
.btn-send:disabled { opacity: .4; cursor: default; }
.takeover-badge { display: inline-block; font-size: 10px; font-weight: 600; color: #8c6900; background: rgba(241,194,27,.12); border: 1px solid rgba(241,194,27,.3); border-radius: 0px; padding: 1px 5px; margin-left: 6px; vertical-align: middle; }

/* ─── Broadcasts ──────────────────────────────────────────────────────────── */
.bc-warn { background: rgba(241,194,27,.08); border: 1px solid rgba(241,194,27,.3); border-radius: 0px; padding: 10px 14px; font-size: 13px; color: var(--text); line-height: 1.5; }
.bc-recipients { font-size: 13px; color: var(--muted); padding: 4px 0; }
.bc-batch-btns { display: flex; gap: 8px; margin-top: 8px; }
.bc-param-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bc-param-label { font-size: 12px; font-weight: 600; color: #8c6900; min-width: 36px; font-family: monospace; }
.bc-param-input { flex: 1; max-width: 360px; }
.bc-template-badge { font-family: monospace; font-size: 12px; background: var(--surface); border-radius: 0px; padding: 2px 6px; color: var(--text); }
.bc-chan-tg { display: inline-block; font-size: 11px; font-weight: 700; background: #229ed9; color: #fff; border-radius: 0px; padding: 2px 6px; }
.bc-chan-wa { display: inline-block; font-size: 11px; font-weight: 700; background: #25d366; color: #fff; border-radius: 0px; padding: 2px 6px; }
.status-badge { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 0px; padding: 2px 7px; }
.status-done    { background: rgba(36,161,72,.1);  color: #1a7a38; }
.status-running { background: rgba(241,194,27,.15); color: #8c6900; }
.status-err     { background: rgba(218,30,40,.08);  color: var(--danger); }
.bc-template-preview { background: var(--surface); border: 1px solid var(--border); border-radius: 0px; padding: 10px 14px; font-size: 13px; color: var(--muted); line-height: 1.55; margin-bottom: 12px; white-space: pre-wrap; word-break: break-word; }

/* ─── Business type cards ────────────────────────────────────────────────── */
.btype-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.btype-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 10px; border-radius: 0px; border: 1px solid var(--border); cursor: pointer; transition: border-color .15s, background .15s; text-align: center; user-select: none; }
.btype-card:hover { border-color: var(--accent); background: rgba(15,98,254,.04); }
.btype-card.selected { border-color: var(--accent); background: rgba(15,98,254,.08); }
.btype-icon { font-size: 26px; line-height: 1; }
.btype-title { font-size: 13px; font-weight: 600; color: var(--text); }
.btype-desc { font-size: 11px; color: var(--muted); line-height: 1.4; }
.btype-info-strip { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 0px; background: rgba(15,98,254,.06); border: 1px solid rgba(15,98,254,.2); }
.btype-info-emoji { font-size: 22px; line-height: 1; }
.btype-info-text { flex: 1; }
.btype-info-title { font-size: 14px; font-weight: 600; }
.btype-info-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ─── Ask AI button ──────────────────────────────────────────────────────── */
.btn-ask-ai { display: flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 0px; background: rgba(15,98,254,.08); color: var(--accent); border: 1px solid rgba(15,98,254,.25); font-size: 13px; font-weight: 400; cursor: pointer; transition: background .15s, border-color .15s; white-space: nowrap; flex-shrink: 0; }
.btn-ask-ai:hover { background: rgba(15,98,254,.15); border-color: var(--accent); }
.btn-ask-ai svg { flex-shrink: 0; }

/* ─── Support Chat Panel ─────────────────────────────────────────────────── */
.sc-panel { position: fixed; top: 0; right: 0; bottom: 0; width: 360px; z-index: 200; background: var(--bg); border-left: 1px solid var(--border); box-shadow: -4px 0 24px rgba(0,0,0,.08); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .25s cubic-bezier(.4,0,.2,1); }
.sc-panel.open { transform: translateX(0); }
.sc-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sc-header-left { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--accent); }
.sc-header-left svg { color: var(--accent); }
.sc-header-right { display: flex; align-items: center; gap: 4px; }
.sc-btn-icon { background: none; border: none; color: var(--muted); padding: 5px; border-radius: 0px; cursor: pointer; display: flex; align-items: center; transition: color .15s, background .15s; }
.sc-btn-icon:hover { color: var(--text); background: var(--surface); }
.sc-page-badge { padding: 5px 16px 6px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sc-page-badge::before { content: "Страница: "; }
.sc-messages { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.sc-msg { display: flex; }
.sc-msg-user { justify-content: flex-end; }
.sc-msg-assistant { justify-content: flex-start; }
.sc-bubble { max-width: 82%; padding: 9px 13px; border-radius: 0px; font-size: 13px; line-height: 1.55; word-break: break-word; white-space: pre-wrap; }
.sc-msg-user .sc-bubble { background: var(--accent); color: #fff; }
.sc-msg-assistant .sc-bubble { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.sc-bubble strong { font-weight: 600; }
.sc-bubble code { background: rgba(0,0,0,.06); border-radius: 0px; padding: 1px 5px; font-size: 12px; font-family: monospace; }
.sc-typing .sc-bubble { display: flex; align-items: center; gap: 4px; padding: 12px 16px; }
.sc-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: scDot 1.2s infinite; }
.sc-dot:nth-child(2) { animation-delay: .2s; }
.sc-dot:nth-child(3) { animation-delay: .4s; }
@keyframes scDot { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }
.sc-footer { padding: 10px 12px; border-top: 1px solid var(--border); display: flex; align-items: flex-end; gap: 8px; flex-shrink: 0; }
.sc-input { flex: 1; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 0px; padding: 8px 12px; font-size: 13px; font-family: inherit; outline: none; resize: none; line-height: 1.5; max-height: 120px; overflow-y: auto; transition: border-color .15s; }
.sc-input:focus { border-color: var(--accent); }
.sc-send { background: var(--accent); color: #fff; border: none; border-radius: 0px; width: 36px; height: 36px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background .15s; }
.sc-send:hover { background: var(--accent-h); }
.sc-send:disabled { opacity: .5; cursor: not-allowed; }
