/* ===========================================================
   Толмач — единая дизайн-система.
   Палитра: янтарно-жёлтый акцент #fdb022 (Т-Банк-стиль).
   Ночная тема по умолчанию.
   =========================================================== */

:root {
  --bg:            #ffffff;
  --surface:       #f7f7f5;
  --surface-2:     #efefec;
  --border:        #e6e6e2;
  --text:          #1a1a1a;
  --text-muted:    #6b6b72;
  --primary:       #fdb022;
  --primary-hover: #f59e0b;
  --primary-text:  #1a1a1a;
  --accent:        #b45309;
  --success:       #10b981;
  --danger:        #ef4444;
  --warning:       #ea580c;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.06);
  --shadow:        0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:     0 12px 32px rgba(0,0,0,.12);
}

[data-theme="dark"] {
  --bg:            #0e0e11;
  --surface:       #18181b;
  --surface-2:     #232328;
  --border:        #323239;
  --text:          #f4f4f5;
  --text-muted:    #a1a1aa;
  --primary:       #fdb022;
  --primary-hover: #fdc04a;
  --primary-text:  #1a1a1a;
  --accent:        #fdb022;
  --success:       #34d399;
  --danger:        #f87171;
  --warning:       #fb923c;
  --shadow-sm:     none;
  --shadow:        none;
  --shadow-lg:     0 12px 32px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
  font-size: 15px;
}

a { color: var(--accent); text-decoration: none; transition: opacity .15s; }
a:hover { opacity: 0.8; }

h1, h2, h3, h4 { color: var(--text); margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 32px; letter-spacing: -0.01em; }
h2 { font-size: 28px; letter-spacing: -0.01em; }
h3 { font-size: 18px; line-height: 1.35; }
h4 { font-size: 15px; }

p { color: var(--text); margin: 0 0 12px; }
small { color: var(--text-muted); font-size: 13px; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ============ КНОПКИ ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 600; font-size: 15px;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .15s, transform .08s, border .15s, box-shadow .15s;
  user-select: none;
  font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); opacity: 1; }

.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); opacity: 1; }

.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--surface-2); opacity: 1; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.95); opacity: 1; }

.btn-sm { padding: 8px 18px; font-size: 14px; }
.btn-block { display: flex; width: 100%; }
.btn[disabled], .btn.disabled { opacity: 0.5; cursor: not-allowed; }

.icon-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; cursor: pointer;
  transition: background .15s;
}
.icon-btn:hover { background: var(--surface-2); }

/* ============ ФОРМЫ ============ */
label { display: block; font-size: 14px; color: var(--text); font-weight: 500; margin-bottom: 6px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=color], input[type=url], textarea, select {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border .15s, background .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); background: var(--bg); }

textarea { min-height: 80px; resize: vertical; line-height: 1.5; }
.form-row { margin-bottom: 18px; }
.form-row.inline { display: flex; gap: 12px; align-items: center; }
.form-help { color: var(--text-muted); font-size: 13px; margin-top: 6px; }

/* Чекбокс — единая строка, никаких блочных разрывов */
.consent-row {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 8px 0 22px;
  cursor: pointer;
  user-select: none;
}
.consent-check {
  width: 18px; height: 18px;
  margin: 2px 0 0; padding: 0;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.consent-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  display: inline;
}
.consent-text a { color: var(--accent); text-decoration: underline; }

/* Обычный чекбокс */
.checkbox { display: inline-flex; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }
.checkbox input { width: auto; accent-color: var(--primary); }

/* ============ КАРТОЧКИ ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.card h3 { margin: 0; }

.badge {
  display: inline-block; padding: 3px 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; font-size: 12px; color: var(--text-muted);
  font-weight: 500;
}
.badge-success { background: rgba(16,185,129,.12); border-color: var(--success); color: var(--success); }
.badge-danger  { background: rgba(239,68,68,.12); border-color: var(--danger);  color: var(--danger); }
.badge-warning { background: rgba(234,88,12,.12); border-color: var(--warning); color: var(--warning); }
.badge-primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }

/* ============ ПУБЛИЧНАЯ ШАПКА ============ */
.public-topbar {
  display: flex; justify-content: space-between; align-items: center;
  height: 64px;
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
}
.brand { display: inline-flex; align-items: center; height: 44px; color: var(--text); }
.brand .logo { height: 44px; width: auto; }

.public-nav { display: flex; align-items: center; gap: 16px; }
.nav-link { color: var(--text); font-size: 15px; font-weight: 500; }
.nav-link:hover { color: var(--accent); opacity: 1; }

/* ============ HERO ============ */
.hero {
  padding: 80px 24px 60px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--surface) 100%);
}
.hero-inner {
  max-width: 1140px; margin: 0 auto;
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: center;
}
.hero-text h1 {
  font-size: 48px; line-height: 1.15; letter-spacing: -0.02em; font-weight: 700;
  margin-bottom: 20px;
}
.hero-sub {
  font-size: 20px; line-height: 1.6; color: var(--text-muted);
  margin-bottom: 32px; max-width: 540px;
}
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-art img { width: 100%; max-width: 480px; height: auto; display: block; margin: 0 auto; color: var(--text); }

/* ============ СЕКЦИИ ============ */
.section {
  max-width: 1140px;
  margin: 0 auto;
  padding: 80px 24px;
}
.section-narrow { max-width: 880px; }
.section h2 { text-align: center; font-size: 32px; line-height: 1.25; margin-bottom: 40px; }
.section-cta { display: flex; justify-content: center; margin-top: 40px; }

.page-title { font-size: 36px; margin-bottom: 12px; }
.page-lead { font-size: 18px; color: var(--text-muted); margin-bottom: 40px; }

/* ============ ФИЧИ ============ */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.feature:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--text-muted);
}
.feature-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--primary-text);
  margin-bottom: 16px;
}
.feature-icon img { width: 28px; height: 28px; color: var(--primary-text); }
.feature h3 { margin: 0 0 8px; font-size: 18px; }
.feature p { margin: 0; font-size: 15px; line-height: 1.6; color: var(--text-muted); }

/* ============ ШАГИ ============ */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
}
.step-num {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: var(--primary-text);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
  margin-bottom: 16px;
}
.step-card h3 { margin: 0 0 8px; }
.step-card p { margin: 0; color: var(--text-muted); font-size: 15px; }

/* ============ КОНТАКТЫ ============ */
.contacts-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 24px;
  align-items: start;
}
.contacts-info { display: flex; flex-direction: column; gap: 12px; }
.contact-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  display: flex; gap: 14px; align-items: center;
}
.contact-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.contact-label { font-size: 13px; color: var(--text-muted); margin-bottom: 2px; }
.contacts-form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
}
.contacts-form-card h3 { margin: 0 0 6px; font-size: 22px; }

/* ============ CTA-секция «Остались вопросы?» ============ */
.contact-cta {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 64px 24px;
  text-align: center;
}
.contact-cta-inner { max-width: 640px; margin: 0 auto; }
.contact-cta h2 { font-size: 28px; margin-bottom: 8px; }
.contact-cta p { color: var(--text-muted); font-size: 17px; margin-bottom: 24px; }

/* ============ ПОДВАЛ ============ */
.public-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 40px 24px;
  margin-top: 24px;
}
.public-footer-inner {
  max-width: 1140px; margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 16px;
  justify-content: space-between; align-items: center;
}
.footer-brand { font-size: 14px; }
.footer-brand strong { color: var(--text); }
.footer-links { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 13px; }
.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--accent); }
.footer-links span { color: var(--text-muted); }

/* ============ COOKIE-БАР (узкий!) ============ */
.cookie-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  z-index: 999;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  box-shadow: 0 -4px 16px rgba(0,0,0,.06);
}
.cookie-text { font-size: 13px; color: var(--text-muted); flex: 1; min-width: 240px; }
.cookie-text a { color: var(--accent); text-decoration: underline; }
.cookie-actions { display: flex; gap: 8px; }
.cookie-actions form { margin: 0; }

/* ============ AUTH (карточка регистрации/входа) ============ */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--surface) 100%);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg);
}
.auth-brand {
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 24px; height: 44px; color: var(--text);
}
.auth-brand .logo { height: 40px; width: auto; }
.auth-card h1 { font-size: 26px; margin: 0 0 6px; }
.auth-sub { color: var(--text-muted); font-size: 15px; margin-bottom: 24px; }
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-muted); font-size: 13px;
  margin: 24px 0;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.oauth-stack { display: flex; flex-direction: column; gap: 8px; }
.auth-footer-text { margin: 18px 0 0; text-align: center; color: var(--text-muted); font-size: 14px; }

/* ============ АДМИНКА ============ */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; min-width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 16px 12px;
}
.sidebar-logo {
  display: flex; align-items: center;
  padding: 8px 8px 16px;
  color: var(--text);
}
.sidebar-logo .logo { height: 32px; width: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  color: var(--text); text-decoration: none;
  border-radius: 8px;
  margin-bottom: 2px;
  font-size: 14px;
  transition: background .15s;
}
.sidebar nav a:hover { background: var(--surface-2); opacity: 1; }
.sidebar nav a.active {
  background: var(--primary); color: var(--primary-text); font-weight: 600;
}
.sidebar nav a.active:hover { background: var(--primary-hover); }
.sidebar .nav-group-title {
  text-transform: uppercase; font-size: 11px; color: var(--text-muted);
  padding: 12px 12px 6px; letter-spacing: 0.5px; font-weight: 600;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title > div { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { padding: 24px; flex: 1; }

/* Гамбургер — только на мобиле */
.hamburger {
  display: none;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; cursor: pointer;
  flex-shrink: 0;
}
.hamburger:hover { background: var(--surface-2); }
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 90;
}

/* Профиль/статус */
.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  position: relative;
}
.user-pill .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: var(--primary-text);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-online  { background: var(--success); }
.status-away    { background: var(--warning); }
.status-offline { background: var(--text-muted); }

.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 8px;
  min-width: 240px;
  box-shadow: var(--shadow-lg);
  display: none; z-index: 50;
}
.dropdown.open { display: block; }
.dropdown a, .dropdown button {
  display: block; width: 100%; text-align: left;
  padding: 8px 12px; color: var(--text); background: transparent; border: none;
  border-radius: 6px; cursor: pointer; font-size: 14px;
  font-family: inherit;
}
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); opacity: 1; }
.dropdown hr { margin: 6px 0; }

.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}
.theme-toggle:hover { background: var(--surface-2); }

/* Таблицы */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
tr:hover td { background: var(--surface-2); }

/* Сетка метрик */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.metric {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
}
.metric .value { font-size: 28px; font-weight: 700; color: var(--text); }
.metric .label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* Алерты/флэши */
.alert {
  padding: 12px 16px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  margin-bottom: 16px;
  font-size: 14px;
}
.alert-danger  { background: rgba(239,68,68,.1);  border-color: var(--danger);  color: var(--danger); }
.alert-success { background: rgba(16,185,129,.1); border-color: var(--success); color: var(--success); }
.alert-info    { background: var(--surface-2); }

/* Тосты */
.toast-wrap {
  position: fixed; bottom: 80px; right: 24px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--surface); border: 1px solid var(--border);
  padding: 12px 16px; border-radius: 10px;
  box-shadow: var(--shadow-lg);
  color: var(--text); font-size: 14px;
  min-width: 280px; max-width: 360px;
  animation: toast-in .2s ease;
}
.toast.success { border-color: var(--success); }
.toast.danger  { border-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Чат */
.chat-shell {
  display: grid; grid-template-columns: 1fr 320px; gap: 16px;
  height: calc(100vh - 130px); min-height: 480px;
}
.chat-main {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px;
  display: flex; flex-direction: column; overflow: hidden;
}
.chat-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.msg { display: flex; flex-direction: column; max-width: 70%; }
.msg.client { align-self: flex-start; }
.msg.operator { align-self: flex-end; }
.msg.system { align-self: center; max-width: 80%; }
/* Группировка подряд идущих сообщений одного автора — плотнее, без двойного отступа */
.msg.grouped { margin-top: -6px; }
.msg.grouped .meta { display: none; }
.msg:hover .meta { display: block; }
/* Разделитель даты */
.date-sep { display: flex; align-items: center; justify-content: center; margin: 6px 0; }
.date-sep span {
  font-size: 11px; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 2px 10px; border-radius: 999px;
}
.msg .bubble {
  padding: 10px 14px; border-radius: 14px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
  word-wrap: break-word;
}
.msg.operator .bubble { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.msg.system .bubble {
  background: transparent; border: 1px dashed var(--border);
  color: var(--text-muted); font-size: 13px;
}
.msg .translation {
  margin-top: 4px; font-size: 12px; color: var(--text-muted); padding-left: 8px;
  font-style: italic;
}
.msg .meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; padding: 0 4px; }
.typing-indicator { font-size: 12px; color: var(--text-muted); padding: 4px 16px; min-height: 22px; font-style: italic; }
.chat-input { padding: 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.chat-input textarea { min-height: 44px; max-height: 120px; flex: 1; }

.client-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.client-card h4 { margin: 0 0 10px; font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.client-card .row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.client-card .row .label { color: var(--text-muted); }
.client-history a { display: block; padding: 6px 8px; border-radius: 6px; color: var(--text); font-size: 13px; }
.client-history a:hover { background: var(--surface-2); opacity: 1; }

/* Виджет (embed) */
.widget-container { display: flex; flex-direction: column; height: 100vh; background: var(--bg); }
.widget-header {
  padding: 14px 16px; color: var(--primary-text); background: var(--primary);
  font-weight: 600;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.widget-header .widget-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget-head-actions { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.widget-close {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--primary-text);
  border: none; border-radius: 8px; cursor: pointer;
  padding: 0; line-height: 0;
  transition: background .15s;
}
.widget-close:hover { background: rgba(0,0,0,.08); }
.widget-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.widget-input { padding: 8px; border-top: 1px solid var(--border); display: flex; gap: 6px; }
.widget-input input { flex: 1; }

/* В виджете «я» — это клиент, поэтому его сообщения справа (как «свои»),
   а оператор — слева (как «входящие»). В операторском чате — наоборот. */
.widget-container .msg.client   { align-self: flex-end; }
.widget-container .msg.operator { align-self: flex-start; }
.widget-container .msg.client   .bubble {
  background: var(--primary); color: var(--primary-text); border-color: var(--primary);
}
.widget-container .msg.operator .bubble {
  background: var(--surface-2); color: var(--text); border-color: var(--border);
}
.widget-container .msg.client   .meta { text-align: right; }
.widget-container .msg.operator .meta { text-align: left; }
.widget-offline-form { padding: 16px; }
.csat-stars { display: flex; gap: 6px; font-size: 28px; cursor: pointer; user-select: none; }
.csat-stars span { color: var(--text-muted); }
.csat-stars span.on { color: var(--primary); }

/* Demo site */
.demo-page { font-family: inherit; background: #f5f5f5; min-height: 100vh; color: #1a1a1a; }
.demo-header { background: #fff; padding: 16px 24px; border-bottom: 1px solid #e5e5e5; display: flex; justify-content: space-between; align-items: center; }
.demo-products { padding: 24px; max-width: 1100px; margin: 0 auto; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.product { background: #fff; border-radius: 10px; padding: 16px; border: 1px solid #e5e5e5; }
.product .price { color: #b45309; font-weight: 700; font-size: 20px; margin-top: 8px; }

/* Прайсинг */
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.plan-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.plan-card.current { border-color: var(--primary); border-width: 2px; }
.plan-card h3 { margin: 0; font-size: 22px; }
.plan-card .price { font-size: 32px; font-weight: 700; }
.plan-card ul { padding-left: 18px; margin: 0; }
.plan-card ul li { font-size: 14px; color: var(--text-muted); margin-bottom: 4px; }

.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); }

/* ============ АДАПТИВНОСТЬ ============ */

/* Планшеты и узкие десктопы: лендинговые сетки в 2 колонки,
   а админка переходит на off-canvas sidebar (иначе остаётся 240px
   сайдбара и контент задыхается). */
@media (max-width: 1024px) {
  .features { grid-template-columns: repeat(2, 1fr); }
  .steps-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-inner { grid-template-columns: 1fr; gap: 32px; text-align: center; }
  .hero-text h1 { margin: 0 auto 20px; }
  .hero-sub { margin-left: auto; margin-right: auto; }
  .hero-cta { justify-content: center; }
  .contacts-grid { grid-template-columns: 1fr; }

  /* Off-canvas sidebar — выезжает по гамбургеру */
  .hamburger { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .app-shell.sidebar-open .sidebar-backdrop { display: block; }

  /* Чат: сайдбар клиента под основным окном */
  .chat-shell { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .chat-main { min-height: calc(100vh - 220px); }
}

/* Телефоны */
@media (max-width: 640px) {
  /* Лендинг — одна колонка, кнопки во всю ширину */
  .features, .steps-grid { grid-template-columns: 1fr; }
  .hero { padding: 56px 16px 40px; }
  .hero-text h1 { font-size: 32px; }
  .hero-sub { font-size: 16px; }
  .hero-cta { flex-direction: column; align-items: stretch; }
  .hero-cta .btn { width: 100%; }
  .section { padding: 48px 16px; }
  .section h2 { font-size: 24px; }

  /* Базовая типографика и контент */
  body { font-size: 14px; }
  h1 { font-size: 24px; }
  h2 { font-size: 22px; }
  h3 { font-size: 16px; }
  .content { padding: 16px; }
  .card { padding: 16px; border-radius: 12px; }
  .card + .card { margin-top: 12px; }
  .card-header { flex-wrap: wrap; gap: 8px; }

  /* Шапка админки: убираем имя пользователя, оставляем аватар+статус */
  .topbar { padding: 10px 14px; }
  .topbar-title strong { font-size: 15px; }
  .topbar-title small { display: none; }
  .topbar-actions { gap: 8px; }
  .user-pill { padding: 4px 8px; }
  .user-pill > span.text-muted { display: none; }
  .dropdown { right: 0; min-width: 220px; }

  /* Формы — поля во всю ширину, мельче отступы */
  .form-row { margin-bottom: 12px; }
  .form-row input, .form-row select, .form-row textarea { font-size: 16px; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .btn { width: 100%; }
  .btn { padding: 10px 18px; font-size: 14px; }
  .btn-block { width: 100%; }

  /* Таблицы — горизонтальный скролл вместо обрезания.
     display:block превращает таблицу в скроллящийся контейнер. */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 13px;
    white-space: nowrap;
  }
  th, td { padding: 8px 10px; }

  /* Метрики — карточки уже, иконка/значение мельче */
  .metrics { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .metric { padding: 12px; }
  .metric .value { font-size: 22px; }

  /* Чат-сообщения шире (на узком экране 70% — слишком узко) */
  .chat-shell { gap: 12px; }
  .chat-main { min-height: 60vh; }
  .chat-input { padding: 8px; }
  .chat-input textarea { font-size: 16px; min-height: 40px; }
  .msg { max-width: 88%; }

  /* Публичные страницы */
  .auth-card { padding: 28px 20px; }
  .public-topbar { padding: 0 16px; }
  .public-nav { gap: 8px; }
  .public-nav .nav-link { display: none; }
  .brand .logo, .auth-brand .logo { height: 36px; }
  .public-footer { padding: 28px 16px; }
  .public-footer-inner { flex-direction: column; align-items: center; text-align: center; }
  .footer-links { justify-content: center; flex-wrap: wrap; }

  /* Cookie-плашка */
  .cookie-bar { padding: 12px 16px; }
  .cookie-text { min-width: 100%; }
  .cookie-actions { width: 100%; justify-content: stretch; }
  .cookie-actions form { flex: 1; }
  .cookie-actions .btn { width: 100%; }
}

/* Узкие телефоны */
@media (max-width: 380px) {
  .metrics { grid-template-columns: 1fr; }
  .msg { max-width: 94%; }
}

/* Утилиты */
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; } .gap-16 { gap: 16px; }
.hidden { display: none !important; }
.full-width { width: 100%; }

/* Бар-чарт на CSS Grid — адаптивный, без SVG */
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.chart-max {
  font-size: 12px; font-weight: 500;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border);
}
.chart {
  width: 100%;
  background-image: linear-gradient(to top, var(--border) 1px, transparent 1px);
  background-size: 100% 25%;
  background-position: 0 calc(100% - 28px);
  background-repeat: repeat-y;
}
.chart-bars {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  align-items: end;
  gap: 4px;
  height: 180px;
  border-bottom: 1px solid var(--border);
  padding: 0 2px;
}
.chart-col { display: flex; align-items: end; justify-content: center; height: 100%; }
.chart-bar {
  width: 70%; min-height: 0;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
  transition: background .15s, transform .15s;
}
.chart-col:hover .chart-bar { background: var(--primary-hover); }
.chart-axis {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: 4px;
  padding: 6px 2px 0;
}
.chart-tick {
  font-size: 11px; color: var(--text-muted);
  text-align: center; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .chart-bars { height: 140px; gap: 2px; }
  .chart-axis { gap: 2px; }
  .chart-tick { font-size: 10px; }
}

.scroll-x { overflow-x: auto; }
