/* =====================================================================
   Content Intelligence — стили. Дизайн-система Century (_ДИЗАЙН_СИСТЕМА.md):
   токены, светлая тема, card-layout, цвет = смысл.
   ===================================================================== */
:root {
  /* нейтральная база */
  --bg:#f4f5f7; --surface:#ffffff; --surface-2:#fafbfc;
  --border:#e6e8ec; --border-soft:#eef0f3;
  --text-1:#1a1d24; --text-2:#5b6472; --text-3:#9aa1ac;
  /* семантика — цвет несёт смысл */
  --risk:#dc2626; --warn:#d97706; --ok:#059669; --info:#2563eb;
  --accent:#2563eb; --accent-hover:#1d4ed8;
  --risk-bg:#fef2f2; --warn-bg:#fffbeb; --ok-bg:#ecfdf5; --info-bg:#eef4ff;
  /* геометрия */
  --r-sm:8px; --r-md:10px; --r-lg:14px;
  --shadow-sm:0 1px 2px rgba(16,24,40,.05);
  --shadow-md:0 6px 20px rgba(16,24,40,.09);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text-1);
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- шапка --------------------------------------------------------- */
header {
  display: flex; align-items: center; gap: 24px;
  background: #161a22; color: #fff; padding: 0 24px; height: 56px;
  position: sticky; top: 0; z-index: 20;
  box-shadow: 0 1px 0 rgba(255,255,255,.04), 0 2px 8px rgba(0,0,0,.18);
}
header .brand { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
header nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
header nav a {
  color: #c2cad6; padding: 7px 13px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 500; transition: background .12s, color .12s;
}
header nav a:hover { color: #fff; background: rgba(255,255,255,.09); text-decoration: none; }
header .user { font-size: 12.5px; color: #8b94a3; }
header .user a { color: #8fb4ff; }

main { max-width: 1180px; margin: 28px auto; padding: 0 24px; }
footer {
  max-width: 1180px; margin: 36px auto 0; padding: 20px 24px 32px;
  color: var(--text-3); font-size: 12px; border-top: 1px solid var(--border);
}

/* --- типографика --------------------------------------------------- */
h1 { font-size: 21px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 14px; letter-spacing: -.01em; }
h3 { font-size: 13px; font-weight: 600; margin: 22px 0 10px;
     color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
p  { margin: 8px 0; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }

/* --- блоки-сообщения ----------------------------------------------- */
.hint, .error, .warn, .flash, .reco {
  padding: 12px 16px; border-radius: var(--r-md); margin: 14px 0;
  font-size: 13.5px; border: 1px solid transparent;
}
.hint  { background: var(--info-bg); border-color: #d6e4ff; color: #1e3a8a; }
.error { background: var(--risk-bg); border-color: #fbd5d5; color: #991b1b; }
.warn  { background: var(--warn-bg); border-color: #fde4bc; color: #92610a; }
.flash { background: var(--ok-bg);  border-color: #b7ebd4; color: #066b48; font-weight: 600; }
.reco  { background: var(--warn-bg); border-color: #fde4bc; color: #7c4a07;
         font-size: 14px; }
.ok-text   { color: var(--ok);   font-weight: 600; }
.warn-text { color: var(--risk); font-weight: 600; }

/* --- карточка-панель — базовый кирпич ------------------------------ */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px 22px; margin: 16px 0;
  box-shadow: var(--shadow-sm);
}
.panel > h2:first-child { margin-bottom: 4px; }
.panel > h2 + .muted    { margin-top: 0; }

/* --- строка KPI ---------------------------------------------------- */
.stats { display: grid; gap: 14px; margin: 18px 0;
         grid-template-columns: repeat(4, 1fr); }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 18px;
  border-top: 3px solid var(--border-soft); box-shadow: var(--shadow-sm);
  transition: box-shadow .14s, transform .14s;
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat b { display: block; font-size: 30px; font-weight: 700;
          line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--text-2); }
.stat.prio-high   { border-top-color: var(--risk); }
.stat.prio-medium { border-top-color: var(--warn); }
.stat.prio-ok     { border-top-color: var(--ok); }
.stat.prio-insufficient_data { border-top-color: #b9c0ca; }

.metrics { display: flex; gap: 32px; flex-wrap: wrap; }
.metrics div b { display: block; font-size: 22px; font-weight: 700;
                 letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metrics div span { font-size: 12px; color: var(--text-2); }

/* --- фильтры / поиск ----------------------------------------------- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 16px 0; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters a {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px;
  font-size: 13px; font-weight: 500; color: var(--text-2); background: var(--surface);
  transition: border-color .12s, color .12s;
}
.filters a:hover { text-decoration: none; border-color: var(--text-3); color: var(--text-1); }
.filters a.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.search { display: flex; gap: 8px; margin-left: auto; }
.search input { width: 240px; }

/* --- таблицы ------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch;
              border-radius: var(--r-md); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td {
  text-align: left; padding: 12px 14px; font-size: 13.5px;
  white-space: nowrap; border-bottom: 1px solid var(--border-soft);
}
th {
  background: var(--surface-2); color: var(--text-3); font-weight: 600;
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.wrap, th.wrap { white-space: normal; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td a { font-weight: 500; }
table.mini th, table.mini td { text-align: center; }
table.mini td:first-child, table.mini th:first-child { text-align: left; }

/* --- бейджи -------------------------------------------------------- */
.badge {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; letter-spacing: .01em;
}
.prio-high   { background: var(--risk-bg); color: #b91c1c; }
.prio-medium { background: var(--warn-bg); color: #92610a; }
.prio-ok     { background: var(--ok-bg);   color: #047857; }
.prio-insufficient_data { background: #eef0f3; color: #6b7280; }
.st-queued      { background: #eef0f3; color: #4b5563; }
.st-in_progress { background: var(--info-bg); color: #1d4ed8; }
.st-review      { background: var(--warn-bg); color: #92610a; }
.st-done        { background: var(--ok-bg);   color: #047857; }

/* --- чипы сигналов ------------------------------------------------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 999px; font-size: 11.5px; font-weight: 500; white-space: nowrap;
  background: var(--risk-bg); color: #b91c1c; border: 1px solid #fbd9d9;
}
.chip.content { background: #f1ecfe; color: #6d3bd1; border-color: #e2d8fb; }
.chip.ok { background: var(--ok-bg); color: #047857; border-color: #b7ebd4; }

/* --- индикатор качества контента (CQS) ----------------------------- */
.cqs { display: flex; align-items: center; gap: 12px; }
.cqs-bar { flex: 1; max-width: 240px; height: 8px; background: #eceef1;
           border-radius: 999px; overflow: hidden; }
.cqs-fill { height: 100%; border-radius: 999px; transition: width .3s; }
.cqs-fill.g { background: var(--ok); }
.cqs-fill.y { background: var(--warn); }
.cqs-fill.r { background: var(--risk); }
.cqs b { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }

.signals { margin: 6px 0; padding: 0; list-style: none; }
.signals li { padding: 4px 0; }
.returns { margin: 6px 0; padding-left: 18px; }
.returns b { color: var(--risk); }
.card-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* --- формы --------------------------------------------------------- */
form label { display: block; margin: 10px 0; font-size: 13px;
              font-weight: 500; color: var(--text-2); }
form input, form select {
  display: block; width: 100%; max-width: 380px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 14px; margin-top: 5px; color: var(--text-1); background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
form input:focus, form select:focus {
  outline: 0; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.task-form { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-end; }
.task-form label { margin: 0; }
button {
  background: var(--accent); color: #fff; border: 0; border-radius: var(--r-sm);
  padding: 9px 18px; font-size: 13.5px; cursor: pointer; font-weight: 600;
  transition: background .12s, box-shadow .12s;
}
button:hover { background: var(--accent-hover); }
button:active { transform: translateY(1px); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-ok { background: var(--ok); }
.btn-ok:hover { background: #047857; }
.inline { display: inline; }
.pager { display: flex; gap: 16px; align-items: center; margin: 18px 0; }

/* --- вход ---------------------------------------------------------- */
.login-body { display: flex; align-items: center; justify-content: center;
              min-height: 100vh; background: var(--bg); }
.login-box {
  background: var(--surface); padding: 38px 40px; border-radius: var(--r-lg);
  border: 1px solid var(--border); width: 372px; box-shadow: var(--shadow-md);
}
.brand-big { font-size: 22px; font-weight: 700; margin-bottom: 4px;
             letter-spacing: -.02em; }
.login-box button { width: 100%; margin-top: 16px; padding: 11px; }

/* --- результат AI -------------------------------------------------- */
.ai-out {
  white-space: pre-wrap; font-family: inherit; font-size: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 16px 18px; margin: 4px 0;
}

/* --- администрирование --------------------------------------------- */
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions button { padding: 6px 12px; font-size: 12px; }
.btn-warn { background: var(--risk); }
.btn-warn:hover { background: #b91c1c; }
.row-off { opacity: .5; }
code.pw, .pw {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 3px 9px; font-weight: 700; letter-spacing: .5px;
}

/* --- воронка продаж ------------------------------------------------ */
.funnel { display: flex; align-items: stretch; flex-wrap: wrap; gap: 4px; margin: 10px 0; }
.fstage {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 12px 16px; text-align: center; min-width: 96px;
}
.fstage b { display: block; font-size: 20px; font-weight: 700;
            font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.fstage span { font-size: 11px; color: var(--text-2); }
.farrow {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 8px; font-size: 11.5px; color: var(--text-2); font-weight: 600;
  text-align: center; line-height: 1.3;
}

/* --- адаптив ------------------------------------------------------- */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  header { gap: 12px; padding: 0 14px; }
  main { padding: 0 14px; margin: 18px auto; }
  .stats { grid-template-columns: 1fr; }
  .search { margin-left: 0; }
  .search input { width: 100%; }
  .metrics { gap: 18px; }
  .panel { padding: 16px; }
}
