/* =====================================================
   mts-sms — визуальная дизайн-система.
   По лекалам OmniChat (Студия развития бизнеса Евгения Кулакова).
   Тёмная тема по умолчанию, светлая — html[data-theme="light"].
   Самодостаточный stylesheet — /shared/b24app.css не подключается.
   ===================================================== */

/* ===== Tokens — dark (default) ===== */
:root {
  --bg-0: #0B0D14;
  --bg-1: #11141C;
  --bg-2: #161A24;
  --bg-3: #1E2330;
  --bg-4: #262C3D;

  --line: rgba(255, 255, 255, 0.06);
  --line-strong: rgba(255, 255, 255, 0.12);

  --text-1: #F4F5F8;
  --text-2: #B8BCCC;
  --text-3: #7A8095;
  --text-4: #525870;

  --accent: #4F4DFF;
  --accent-2: #7B79FF;
  --accent-soft: rgba(79, 77, 255, 0.12);
  --accent-glow: rgba(79, 77, 255, 0.35);

  --success: #2DD4BF;
  --success-soft: rgba(45, 212, 191, 0.12);
  --warning: #F5B833;
  --warning-soft: rgba(245, 184, 51, 0.12);
  --danger: #FF5C7A;
  --danger-soft: rgba(255, 92, 122, 0.14);
  --info: #5BA8FF;

  --radius-s: 8px;
  --radius: 14px;
  --radius-l: 22px;

  --shadow-1: 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-2: 0 16px 48px rgba(0, 0, 0, 0.40);

  --font-display: 'Unbounded', sans-serif;
  --font-body: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== Light override ===== */
html[data-theme="light"] {
  --bg-0: #F4F5F8;
  --bg-1: #FFFFFF;
  --bg-2: #F1F3F8;
  --bg-3: #E7EAF2;
  --bg-4: #D4D9E5;

  --line: rgba(11, 13, 20, 0.06);
  --line-strong: rgba(11, 13, 20, 0.12);

  --text-1: #11141C;
  --text-2: #3F4456;
  --text-3: #6B7185;
  --text-4: #9097AB;

  --accent-2: #6361FF;
  --accent-soft: rgba(79, 77, 255, 0.10);
  --accent-glow: rgba(79, 77, 255, 0.22);

  --success: #10B981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --danger: #E5436A;
  --danger-soft: rgba(229, 67, 106, 0.10);

  --shadow-1: 0 4px 16px rgba(11, 13, 20, 0.06);
  --shadow-2: 0 16px 48px rgba(11, 13, 20, 0.12);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }
body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  position: relative;
  min-height: 100vh;
}
/* Фирменный radial-glow фон */
body.mts-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(800px 600px at 12% -10%, var(--accent-glow), transparent 60%),
    radial-gradient(700px 500px at 100% 100%, rgba(123, 121, 255, 0.10), transparent 60%);
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}
html[data-theme="light"] body.mts-page::before { opacity: 0.5; }

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

*:focus { outline: none; }
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Shell ===== */
.mts-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== Topbar ===== */
.topbar {
  height: 56px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}
.topbar__logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 6px 20px var(--accent-glow);
}
.topbar__logo svg { width: 16px; height: 16px; }
.crumbs { color: var(--text-3); font-size: 13px; }
.crumbs strong { color: var(--text-1); font-weight: 600; }
.crumbs .sep { margin: 0 8px; color: var(--text-4); }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ===== Theme switch ===== */
.theme-switch {
  display: inline-flex;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.theme-switch button {
  padding: 5px 11px;
  border-radius: 7px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color .15s, background .15s;
}
.theme-switch button:hover { color: var(--text-1); }
.theme-switch button.active {
  background: var(--bg-1);
  color: var(--text-1);
  box-shadow: var(--shadow-1);
}
.theme-switch svg { width: 13px; height: 13px; }

/* ===== Page ===== */
.page {
  padding: 28px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}
.page-header { margin-bottom: 22px; }
.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-subtitle { color: var(--text-3); font-size: 14px; margin: 0; max-width: 720px; }

.badge-new {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 12px var(--accent-glow);
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.tab {
  padding: 10px 14px;
  color: var(--text-3);
  font-weight: 500;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text-1); }
.tab.active { color: var(--text-1); border-bottom-color: var(--accent); }

/* ===== Cards ===== */
.cards { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-1);
}
.card-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}
.card-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-icon svg { width: 18px; height: 18px; }
.card-head-text { flex: 1; min-width: 0; }
.card-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: .2px;
  margin: 0 0 4px;
}
.card-desc { color: var(--text-3); font-size: 13px; margin: 0; }
.card-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.card-section + .card-section { margin-top: 16px; }

/* ===== Info grid ===== */
.info-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  row-gap: 12px;
  column-gap: 16px;
  padding: 14px 16px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  margin: 0;
}
.info-grid dt { color: var(--text-3); margin: 0; }
.info-grid dd { color: var(--text-1); margin: 0; }
.info-grid dd.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text-2);
}

/* ===== Pill ===== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}
.pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill.ok { background: var(--success-soft); color: var(--success); }
.pill.warn { background: var(--warning-soft); color: var(--warning); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.muted { background: var(--bg-3); color: var(--text-3); }
.pill.bare::before { display: none; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background .15s, transform .15s, border-color .15s;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-2); transform: translateY(-1px); color: #fff; }
.btn-ghost {
  background: var(--bg-2);
  border-color: var(--line);
  color: var(--text-1);
}
.btn-ghost:hover { background: var(--bg-3); border-color: var(--line-strong); color: var(--text-1); }
.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 6px 16px var(--danger-soft);
}
.btn-danger:hover { filter: brightness(1.06); color: #fff; }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
.btn svg { width: 14px; height: 14px; }

/* ===== Forms ===== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: 14px; }
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.input,
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  padding: 9px 12px;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  font-size: 13px;
  color: var(--text-1);
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 96px; resize: vertical; }
.field-hint { font-size: 12px; color: var(--text-3); }
.field-hint a { font-weight: 500; }

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* Радио-выбор режима */
.mode-option {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 6px 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  background: var(--bg-2);
  transition: border-color .15s, background .15s;
}
.mode-option + .mode-option { margin-top: 10px; }
.mode-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.mode-option input { margin-top: 3px; accent-color: var(--accent); }
.mode-option__title { font-weight: 600; }
.mode-option__sub { grid-column: 2; font-size: 12px; color: var(--text-3); }

/* ===== Status строка ===== */
.status-line {
  font-size: 12px;
  min-height: 16px;
  color: var(--text-3);
}
.status-line[data-state="ok"] { color: var(--success); }
.status-line[data-state="error"] { color: var(--danger); }

.muted-note {
  font-size: 12px;
  color: var(--text-3);
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.muted-note svg { width: 14px; height: 14px; color: var(--text-4); flex-shrink: 0; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-4);
  border-bottom: 1px solid var(--line);
}
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
}
.table tr:last-child td { border-bottom: 0; }
.table td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

@keyframes mts-row-flash {
  from { background: var(--accent-soft); }
  to { background: transparent; }
}
.mts-row-flash { animation: mts-row-flash 800ms ease-out; }

/* ===== Empty state ===== */
.empty {
  text-align: center;
  padding: 22px 16px;
  color: var(--text-3);
  font-size: 13px;
}

/* ===== Назначение номеров ===== */
.assign details { position: relative; }
.assign summary {
  cursor: pointer;
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg-1);
  font-size: 12px;
  list-style: none;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.assign summary::-webkit-details-marker { display: none; }
.assign select[multiple] {
  margin-top: 6px;
  width: 100%;
  max-width: 320px;
  min-width: 220px;
  background: var(--bg-1);
}
.assign-status { font-size: 11px; margin-left: 8px; }
.assign-status[data-state="ok"] { color: var(--success); }
.assign-status[data-state="error"] { color: var(--danger); }

/* ===== About — поддержка ===== */
.support-row { display: flex; gap: 12px; flex-wrap: wrap; }
.support-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  transition: border-color .15s, background .15s;
  min-width: 220px;
}
.support-btn:hover { border-color: var(--line-strong); background: var(--bg-3); }
.support-btn__logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.support-btn__logo svg { width: 22px; height: 22px; }
.support-btn__logo--tg { background: #229ED9; color: #fff; }
.support-btn__logo--max { background: #fff; color: #000; border: 1px solid var(--line-strong); }
.support-btn__title { font-weight: 600; font-size: 13px; color: var(--text-1); }
.support-btn__sub { font-size: 12px; color: var(--text-3); }

/* ===== About — другие приложения ===== */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.app-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  background: var(--bg-2);
}
.app-card__title { font-weight: 600; margin: 0 0 4px; font-size: 14px; }
.app-card__tag { color: var(--text-3); font-size: 12px; margin: 0 0 12px; }

/* ===== KB ===== */
.kb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.kb-card {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  background: var(--bg-2);
  transition: border-color .15s, transform .15s;
}
.kb-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.kb-card__cat {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 6px;
}
.kb-card__title { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.kb-card__excerpt { font-size: 12px; color: var(--text-3); line-height: 1.5; }
.kb-card__date { font-size: 11px; color: var(--text-4); margin-top: 10px; }
.kb-article__back {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 12px;
  display: inline-flex;
  gap: 6px;
}
.kb-article__back:hover { color: var(--text-1); }
.kb-article__title { font-family: var(--font-display); font-size: 20px; margin: 0 0 8px; }
.kb-article__content { font-size: 14px; color: var(--text-2); line-height: 1.6; }
.kb-article__content img { max-width: 100%; border-radius: 8px; }

/* ===== Footer (slim) ===== */
.mts-footer {
  border-top: 1px solid var(--line);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-3);
  background: var(--bg-1);
}
.mts-footer__logo {
  width: 24px;
  height: 24px;
  color: var(--accent);
}
.mts-footer strong { color: var(--text-2); font-weight: 600; }
.mts-footer .spacer { flex: 1; }

/* ===== Install hero ===== */
.install-hero {
  max-width: 520px;
  margin: 60px auto;
  text-align: center;
  padding: 0 24px;
}
.install-hero__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
}
.install-hero h1 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 10px;
}
.install-hero p { color: var(--text-3); font-size: 14px; }

/* ===== Widget (в карточке CRM) ===== */
.mts-widget-body {
  margin: 0;
  background: var(--bg-0);
  padding: 10px 12px 16px;
}
.mts-widget {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-1);
}
.mts-widget__pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  box-shadow: 0 6px 16px var(--accent-glow);
  transition: background .15s;
}
.mts-widget__pill:hover { background: var(--accent-2); }
.mts-widget__pill svg { width: 15px; height: 15px; }
.mts-widget__form { display: flex; flex-direction: column; gap: 12px; }
.mts-widget__counter { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.mts-widget__actions { display: flex; gap: 8px; justify-content: flex-end; }
.mts-widget__status { font-size: 11px; min-height: 14px; }
.mts-widget__status[data-state="ok"] { color: var(--success); }
.mts-widget__status[data-state="error"] { color: var(--danger); }

/* ===== Адаптив ===== */
@media (max-width: 640px) {
  .page { padding: 18px 14px; }
  .page-title { font-size: 22px; }
  .topbar { padding: 0 14px; }
  /* На узком экране хлебные крошки прячем — секцию называет page-title ниже. */
  .crumbs { display: none; }
  .info-grid { grid-template-columns: 1fr; row-gap: 4px; }
  .info-grid dt { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }
  .card { padding: 18px 16px; }
  .card-title { font-size: 14px; }
  .mts-footer { flex-wrap: wrap; padding: 14px; }
}
