/* Matrix — синтетическая панель · дизайн-система v2 (коммерческий светлый SaaS) */

:root {
  --bg: #f7f9f8;
  --surface: #ffffff;
  --ink: #10201a;
  --ink-soft: #33463d;
  --muted: #64766d;
  --faint: #93a29a;
  --line: #e4eae6;
  --line-strong: #d3ddd7;

  --accent: #0a8754;
  --accent-ink: #076341;
  --accent-soft: #e9f6ef;
  --accent-border: #bfe3d0;

  --amber: #9a6b15;
  --amber-soft: #fbf3e3;
  --danger: #c0392b;
  --danger-soft: #fceeec;
  --pos: #0a8754;
  --pos-soft: #e9f6ef;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 26, .05), 0 4px 16px rgba(16, 32, 26, .05);
  --shadow-hover: 0 2px 4px rgba(16, 32, 26, .06), 0 10px 28px rgba(16, 32, 26, .09);

  font-size: 15.5px;
}

:root[data-theme="dark"] {
  --bg: #0e1512;
  --surface: #161f1b;
  --ink: #eaf1ed;
  --ink-soft: #c3d0c9;
  --muted: #8ca097;
  --faint: #63756c;
  --line: #253029;
  --line-strong: #33443b;

  --accent: #2ecb82;
  --accent-ink: #6fe0aa;
  --accent-soft: #16281f;
  --accent-border: #2c4a3a;

  --amber: #e0b155;
  --amber-soft: #2e2513;
  --danger: #f0776a;
  --danger-soft: #2e1a18;
  --pos: #2ecb82;
  --pos-soft: #16281f;

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .28);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, .35), 0 10px 28px rgba(0, 0, 0, .4);
}

.theme-toggle {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent-ink); }

/* экран входа */
.auth-screen {
  position: fixed; inset: 0; z-index: 200; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background-image: radial-gradient(700px 320px at 50% -10%, var(--accent-soft), transparent 70%);
}
.auth-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-hover); padding: 32px 34px; width: 100%; max-width: 380px;
}
.auth-brand { display: flex; align-items: center; gap: 8px; font-size: 20px; }
.auth-brand .dot { width: 11px; height: 11px; border-radius: 3.5px; background: var(--accent); }
.auth-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 20px; }
.auth-card h3 { margin: 0 0 16px; font-size: 18px; }
.auth-error {
  background: var(--danger-soft); color: var(--danger); padding: 8px 12px;
  border-radius: 8px; font-size: 13px; margin-bottom: 12px;
}

/* чип пользователя */
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.user-chip #user-name { font-weight: 600; }
@media (max-width: 720px) {
  .user-chip #user-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

* { box-sizing: border-box; }

body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- шапка ---------- */
header {
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
  padding: 14px 28px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 9px; }
.brand .dot {
  width: 11px; height: 11px; border-radius: 3.5px; background: var(--accent);
  align-self: center; flex: 0 0 auto;
}
h1.logo { font-size: 19px; margin: 0; font-weight: 700; letter-spacing: -.02em; }
.sub { font-size: 12.5px; color: var(--muted); }

nav { display: flex; gap: 2px; flex-wrap: wrap; }
nav button {
  border: none; background: transparent; padding: 8px 14px; border-radius: 9px;
  cursor: pointer; font-size: 14px; font-weight: 500; color: var(--ink-soft);
  font-family: inherit;
}
nav button:hover { background: var(--bg); color: var(--ink); }
nav button.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

.health { margin-left: auto; font-size: 12.5px; color: var(--muted); text-align: right; }
.health .chip {
  display: inline-block; padding: 3px 10px; border-radius: 20px; margin-left: 8px;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 500;
}
.health .chip.mock { background: var(--amber-soft); color: var(--amber); }

/* ---------- полоса честности ---------- */
.disclaimer {
  padding: 7px 28px; font-size: 12.5px; color: var(--muted);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.disclaimer b { color: var(--ink-soft); font-weight: 600; }
.disclaimer a { color: var(--accent-ink); }

main { max-width: 1180px; margin: 0 auto; padding: 30px 28px 80px; }
.tab { display: none; }
.tab.active { display: block; }

h2 { font-size: 20px; margin: 30px 0 14px; font-weight: 650; letter-spacing: -.01em; }
h2:first-child { margin-top: 0; }
h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); font-weight: 400; font-size: 13px; }
.hidden { display: none !important; }
a { color: var(--accent-ink); }

/* ---------- hero (обзор) ---------- */
.hero {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 44px 48px; margin-bottom: 26px;
  background-image: radial-gradient(900px 300px at 90% -20%, var(--accent-soft), transparent 65%);
}
.hero h2 {
  font-size: 31px; line-height: 1.18; margin: 0 0 12px; font-weight: 700;
  letter-spacing: -.025em; max-width: 620px;
}
.hero p { color: var(--ink-soft); font-size: 16px; max-width: 640px; margin: 0 0 24px; }
.hero .row { gap: 12px; }

/* карточки-возможности */
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.cap-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px; display: flex; flex-direction: column; gap: 8px;
  transition: box-shadow .18s, transform .18s;
}
.cap-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.cap-card .icon {
  width: 40px; height: 40px; border-radius: 11px; background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.cap-card b { font-size: 15.5px; }
.cap-card p { margin: 0; font-size: 13.5px; color: var(--muted); flex: 1; }
.cap-card button { align-self: flex-start; }

/* зоны доверия (полоска на главной) */
.trust-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.trust-chip {
  border-radius: var(--radius-sm); padding: 12px 16px; font-size: 13px;
  border: 1px solid var(--line); background: var(--surface);
}
.trust-chip b { display: block; margin-bottom: 2px; font-size: 13.5px; }
.trust-chip.green { border-left: 3px solid var(--accent); }
.trust-chip.yellow { border-left: 3px solid #d9a514; }
.trust-chip.red { border-left: 3px solid var(--danger); }

/* ---------- карточки и формы ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px; margin-bottom: 16px;
}
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.row.center { justify-content: center; }
.row.space-between { justify-content: space-between; }

label.block { display: block; margin: 14px 0; font-size: 13px; color: var(--muted); font-weight: 500; }
input, textarea, select {
  font: inherit; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); width: auto;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
label.block input, label.block textarea { width: 100%; margin-top: 6px; }
textarea { resize: vertical; }
input[type="number"] { width: 96px; }
input[type="checkbox"] { accent-color: var(--accent); }
input[type="radio"] { accent-color: var(--accent); }

button.primary {
  background: var(--accent); color: #fff; border: none; padding: 10px 20px;
  border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-weight: 600;
  transition: background .15s;
}
button.primary:hover { background: var(--accent-ink); }
button.primary:disabled { opacity: .5; cursor: default; }
button.ghost, a.ghost {
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink-soft);
  padding: 9px 16px; border-radius: var(--radius-sm); cursor: pointer; font: inherit;
  font-weight: 500; text-decoration: none; display: inline-block; font-size: 14px;
  transition: border-color .15s, color .15s;
}
button.ghost:hover, a.ghost:hover { border-color: var(--accent); color: var(--accent-ink); }

details { margin: 10px 0; }
details summary {
  cursor: pointer; font-size: 13.5px; color: var(--muted); font-weight: 500;
  padding: 4px 0; user-select: none;
}
details summary:hover { color: var(--ink-soft); }

/* выбор типа теста */
.type-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 18px; }
.type-card {
  border: 1.5px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  cursor: pointer; background: var(--surface); transition: all .15s;
  display: flex; gap: 12px; align-items: flex-start;
}
.type-card:hover { border-color: var(--accent-border); }
.type-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.type-card .icon { font-size: 22px; margin-top: 1px; }
.type-card b { display: block; font-size: 14.5px; margin-bottom: 2px; }
.type-card span { font-size: 12.5px; color: var(--muted); }

/* ---------- лента результатов ---------- */
.list .item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px; margin-bottom: 10px; cursor: pointer;
  display: flex; gap: 14px; align-items: center;
  transition: box-shadow .15s;
}
.list .item:hover { box-shadow: var(--shadow-hover); }
.list .item .kind {
  flex: 0 0 38px; width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.list .item .stim { flex: 1; font-size: 14px; min-width: 0; }
.list .item .stim .lbl { display: block; font-size: 11.5px; color: var(--faint); margin-bottom: 1px; }
.list .item .when { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; }

.badge {
  font-size: 11.5px; padding: 3px 10px; border-radius: 20px; font-weight: 600; white-space: nowrap;
}
.badge.running { background: #eef2ff; color: #4453c7; }
.badge.done { background: var(--pos-soft); color: var(--accent-ink); }
.badge.error { background: var(--danger-soft); color: var(--danger); }
.badge.низкий { background: var(--pos-soft); color: var(--accent-ink); }
.badge.средний { background: var(--amber-soft); color: var(--amber); }
.badge.высокий { background: var(--danger-soft); color: var(--danger); }

/* ---------- отчёт ---------- */
.report .verdict { font-size: 15.5px; }
.metrics-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.metric {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 20px; min-width: 132px;
}
.metric .val { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.metric .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 820px) { .two-cols { grid-template-columns: 1fr; } }

.arg { padding: 9px 13px; border-radius: var(--radius-sm); margin: 7px 0; font-size: 13.5px; }
.arg.for { background: var(--pos-soft); }
.arg.against { background: var(--danger-soft); }
.arg .seg { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.voice {
  border-left: 3px solid var(--accent); background: var(--surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  box-shadow: var(--shadow);
  padding: 12px 16px; margin: 10px 0;
}
.voice .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.voice .txt { font-size: 14px; }
.voice.neg { border-left-color: var(--danger); }
.voice.pos { border-left-color: var(--accent); }

.seg-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0 14px; }
.seg-table th, .seg-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.seg-table th { color: var(--muted); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
.seg-table .num { font-variant-numeric: tabular-nums; text-align: right; }
.seg-table tr.seg-row:hover td { background: var(--accent-soft); }
.heat { display: inline-block; width: 46px; text-align: center; border-radius: 6px; padding: 2px 0; }

.passport {
  font-size: 12px; color: var(--muted); background: var(--surface);
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  padding: 12px 16px; margin-top: 20px;
}

/* бары распределений */
.grid-marginals { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 12px; }
.marginal {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.marginal h3 { margin: 0 0 10px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.bar-row { display: grid; grid-template-columns: 1fr 44px; gap: 8px; align-items: center; margin: 4px 0; font-size: 12.5px; }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-wrap { grid-column: 1 / -1; display: block; height: 5px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar-val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- аудитория ---------- */
.grid-agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 12px; }
.agent-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px; cursor: pointer; transition: box-shadow .15s, transform .15s;
}
.agent-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.agent-card .name { font-weight: 600; font-size: 14.5px; }
.agent-card .meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.agent-card .tags { margin-top: 10px; display: flex; gap: 5px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 2.5px 9px; border-radius: 20px; background: var(--bg); color: var(--muted); }
.tag.pol { background: var(--accent-soft); color: var(--accent-ink); }
.tag.bio { background: var(--pos-soft); color: var(--accent-ink); }

/* модалка агента */
.modal-back {
  position: fixed; inset: 0; background: rgba(16, 32, 26, .4); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 44px 16px; overflow-y: auto;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border-radius: 18px; max-width: 720px; width: 100%;
  padding: 26px 30px; position: relative; box-shadow: var(--shadow-hover);
}
.modal .close {
  position: absolute; top: 14px; right: 16px; border: none; background: var(--bg);
  width: 30px; height: 30px; border-radius: 8px;
  font-size: 17px; cursor: pointer; color: var(--muted);
}
.modal h3 { margin: 0 0 4px; font-size: 18px; }
.modal .section { margin-top: 16px; }
.modal .section h4 { margin: 0 0 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.modal .bio { white-space: pre-wrap; font-size: 14px; }
.kv { display: grid; grid-template-columns: 165px 1fr; gap: 4px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* чат */
.chat-log { min-height: 120px; max-height: 460px; overflow-y: auto; margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 75%; padding: 10px 15px; border-radius: 15px; font-size: 14px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.msg.agent { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; box-shadow: var(--shadow); }

/* фокус-группа: тред */
.thread { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.comment {
  display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 13px 16px;
}
.comment.reply { margin-left: 38px; background: #fbfdfc; }
.avatar {
  flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: 12.5px;
  display: flex; align-items: center; justify-content: center;
}
.c-body { min-width: 0; }
.c-who { font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.c-replyto { font-size: 12px; color: var(--accent-ink); margin-bottom: 3px; }
.c-text { font-size: 14px; white-space: pre-wrap; }

/* тосты и прогресс */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 22px; border-radius: 12px;
  font-size: 14px; z-index: 100; max-width: 80%; box-shadow: var(--shadow-hover);
}
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center; color: var(--muted); padding: 36px 20px; font-size: 14px;
  background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius);
}

/* ---------- адаптив ---------- */
@media (max-width: 720px) {
  :root { font-size: 15px; }
  header {
    gap: 10px 14px; padding: 10px 16px;
    position: sticky; top: 0;
  }
  header .brand .sub { display: none; }
  nav {
    order: 3; width: 100%;
    overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  nav::-webkit-scrollbar { display: none; }
  nav button { white-space: nowrap; padding: 7px 12px; }
  .health { font-size: 11.5px; margin-left: auto; }
  .disclaimer { padding: 8px 16px; font-size: 12px; }
  main { padding: 20px 16px 60px; }

  .hero { padding: 28px 22px; border-radius: 14px; }
  .hero h2 { font-size: 23px; }
  .hero p { font-size: 15px; }

  .card { padding: 16px 16px; }
  .metric { min-width: calc(50% - 6px); flex: 1; }
  .metrics-row { gap: 8px; }
  .two-cols { grid-template-columns: 1fr; }
  .type-cards { grid-template-columns: 1fr; }

  .row { gap: 8px; }
  label.block input, label.block textarea { font-size: 16px; } /* без зума в iOS */
  input, select, textarea { font-size: 16px; }

  .list .item { flex-wrap: wrap; }
  .list .item .when { text-align: left; width: 100%; }
  .kv { grid-template-columns: 1fr; gap: 1px 0; }
  .kv dt { margin-top: 8px; }
  .modal { padding: 20px 18px; }
  .comment.reply { margin-left: 16px; }
  .msg { max-width: 88%; }
  .ztype { flex-direction: column; gap: 2px; }

  /* таблицы — горизонтальный скролл */
  .seg-table { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (max-width: 400px) {
  .metric { min-width: 100%; }
  nav button { padding: 7px 10px; font-size: 13px; }
}

/* онбординг */
.ob-card { border-left: 3px solid var(--accent); }
.ob-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 12px; }
@media (max-width: 720px) { .ob-steps { grid-template-columns: 1fr; } }
.ob-step { display: flex; gap: 12px; align-items: flex-start; }
.ob-step.done { opacity: .55; }
.ob-num {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.ob-step.done .ob-num { background: var(--accent); color: #fff; }
.ob-step b { font-size: 14px; }

.zone-types { display: flex; flex-direction: column; gap: 10px; }
.ztype {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.ztype:first-child { border-top: none; }
.ztype b { font-size: 14px; }
.ztype > div:last-child { white-space: nowrap; }
