/* Пульт ИИ-агентов: витрина ИИ-сотрудников EXPONERA AI.
   Нейтральная основа + один синий акцент для действий; у каждого агента свой цвет с фона его портрета.
   Радиусы: карточки 20px, плитки/поля/кнопки 12px, бейджи и шаги — полностью скруглённые. */

:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: #fdfdfd;
  --surface-2: #f6f7f9;
  --line: #e3e5ea;
  --ink: #17181c;
  --ink-2: #4f525c;
  --ink-3: #868a95;
  --accent: #2448c9;
  --accent-ink: #ffffff;
  --accent-soft: #e8edfc;
  --good: #16924a;
  --warn: #c98500;
  --bad: #d03b3b;
  --shadow: 0 1px 2px rgb(23 24 28 / 0.04), 0 8px 24px -12px rgb(23 24 28 / 0.12);
  --agent: #b8c0d0;
  --r-card: 20px;
  --r: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0e0f12;
    --surface: #17181c;
    --surface-2: #1e2025;
    --line: #2b2e35;
    --ink: #f2f3f5;
    --ink-2: #b9bcc6;
    --ink-3: #8a8e99;
    --accent: #7b96ff;
    --accent-ink: #0e0f12;
    --accent-soft: #1d2440;
    --good: #3cc274;
    --warn: #f0b429;
    --bad: #f06565;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 12px 32px -16px rgb(0 0 0 / 0.6);
  }
}

/* Цвета агентов: фон портрета. Неизвестный агент получает нейтральный --agent из :root */
.agent-seller { --agent: #e99c84; }
.agent-seo { --agent: #9fcec5; }
.agent-zoya { --agent: #e5bf81; }
.agent-jarvis { --agent: #86a5d7; }
.agent-airop { --agent: #aad7c2; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; line-height: 1.15; }
p { margin: 0; }
img { display: block; max-width: 100%; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.err { color: var(--bad); }

/* ---------- шапка ---------- */
header.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 64px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
header.top nav { display: flex; gap: 22px; align-items: center; }
header.top nav a { color: var(--ink-2); font-weight: 500; }
header.top nav a:hover { color: var(--ink); text-decoration: none; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink) !important; font-weight: 650; letter-spacing: -0.01em; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 800;
}
.brand small { color: var(--ink-3); font-weight: 500; }
.user-box { display: flex; align-items: center; gap: 12px; }
main { max-width: 1180px; margin: 0 auto; padding: 32px 28px 64px; }

/* ---------- главная: вступление ---------- */
.intro { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 32px; align-items: end; margin-bottom: 32px; }
.intro h1 { font-size: 40px; font-weight: 700; }
.intro p { margin-top: 12px; color: var(--ink-2); font-size: 17px; max-width: 46ch; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .label { color: var(--ink-3); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .value.err { color: var(--bad); }

/* ---------- карточка агента ---------- */
.team { display: grid; gap: 20px; }
.agent {
  position: relative; display: grid; grid-template-columns: 248px minmax(0, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  overflow: hidden; box-shadow: var(--shadow);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.agent:hover { transform: translateY(-2px); box-shadow: var(--shadow), 0 20px 40px -24px color-mix(in srgb, var(--agent) 70%, transparent); }
.portrait { position: relative; background: var(--agent); min-height: 100%; }
.portrait img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 1 / 1; }
.agent.is-offline .portrait img, .agent-hero.is-offline .portrait img { filter: saturate(0.35) brightness(0.97); }
.agent-body { padding: 22px 26px 20px; display: grid; gap: 16px; align-content: start; }
.agent-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.agent-head h2 { font-size: 24px; font-weight: 700; }
.agent-head h2 a { color: inherit; }
.role { color: var(--ink-3); font-size: 14px; margin-top: 4px; }
.desc { color: var(--ink-2); max-width: 70ch; }

/* как работает: четыре шага */
.flow { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; counter-reset: step; }
.flow li {
  position: relative; counter-increment: step;
  background: color-mix(in srgb, var(--agent) 16%, var(--surface)); border-radius: var(--r);
  padding: 10px 12px 11px 12px; font-size: 13px; line-height: 1.35; color: var(--ink);
}
.flow li::before {
  content: counter(step); display: grid; place-items: center;
  width: 22px; height: 22px; margin-bottom: 6px; border-radius: 999px;
  background: var(--agent); color: #17181c; font-size: 12px; font-weight: 700;
}
.flow li:not(:last-child)::after {
  content: ""; position: absolute; right: -9px; top: 21px; width: 8px; height: 2px;
  background: color-mix(in srgb, var(--agent) 70%, var(--line));
}
.flow.is-live li::before { animation: step-pulse 2.4s cubic-bezier(0.16, 1, 0.3, 1) infinite; }
.flow.is-live li:nth-child(2)::before { animation-delay: 0.6s; }
.flow.is-live li:nth-child(3)::before { animation-delay: 1.2s; }
.flow.is-live li:nth-child(4)::before { animation-delay: 1.8s; }
@keyframes step-pulse {
  0%, 70%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--agent) 0%, transparent); }
  20% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--agent) 45%, transparent); }
}

/* сейчас и цифры за сегодня */
.now { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 14px; }
.now strong { color: var(--ink); font-weight: 600; }
.kpis-title { font-size: 12.5px; font-weight: 600; color: var(--ink-3); margin-bottom: 6px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.kpi { border-top: 1px solid var(--line); padding-top: 10px; }
.kpi .num { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .cap { font-size: 12.5px; color: var(--ink-3); line-height: 1.3; }
.agent-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; font-size: 13px; color: var(--ink-3); }
.open-link { font-weight: 600; }

.offline-note {
  padding: 12px 14px; border-radius: var(--r); font-size: 14px;
  color: var(--ink-2); background: var(--surface-2); border: 1px dashed var(--line);
}

/* статус */
.badge {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font-size: 13px; font-weight: 600; padding: 5px 12px 5px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.badge.ok { color: var(--good); background: color-mix(in srgb, var(--good) 10%, var(--surface)); border-color: color-mix(in srgb, var(--good) 25%, var(--line)); }
.badge.ok::before { background: var(--good); animation: live 2s ease-out infinite; }
.badge.paused, .badge.stale { color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 25%, var(--line)); }
.badge.paused::before, .badge.stale::before { background: var(--warn); }
.badge.degraded { color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--surface)); border-color: color-mix(in srgb, var(--bad) 22%, var(--line)); }
.badge.degraded::before { background: var(--bad); }
.badge.offline::before { background: var(--ink-3); }
.badge .icon { display: none; }
@keyframes live {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 55%, transparent); }
  80%, 100% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--good) 0%, transparent); }
}

/* ---------- страница агента ---------- */
.back { display: inline-block; margin-bottom: 16px; color: var(--ink-3); font-weight: 500; }
.agent-hero {
  display: grid; grid-template-columns: 300px minmax(0, 1fr); margin-bottom: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; box-shadow: var(--shadow);
}
.agent-hero .agent-body { padding: 28px 32px 26px; gap: 18px; }
.agent-hero h1 { font-size: 34px; font-weight: 700; }
.meta { font-size: 13px; color: var(--ink-3); }

.columns { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: grid; gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 22px 24px; box-shadow: var(--shadow); }
.card h2 { font-size: 17px; margin-bottom: 14px; }
.busy { color: var(--ink-2); font-size: 14px; margin: 0 0 12px; }

table.metrics { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.metrics th, table.metrics td { padding: 8px 4px; text-align: right; }
table.metrics th:first-child, table.metrics td:first-child { text-align: left; }
table.metrics th { color: var(--ink-3); font-weight: 500; font-size: 12.5px; border-bottom: 1px solid var(--line); }
table.metrics tbody tr + tr td { border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.foot { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 12px; color: var(--ink-3); font-size: 13px; }

.events { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.events li { display: grid; grid-template-columns: 92px 1fr; gap: 10px; padding: 8px 0; font-size: 14px; }
.events li + li { border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.events time { color: var(--ink-3); font-variant-numeric: tabular-nums; }

.chart svg { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--agent); }
.chart .bar:hover { opacity: 0.8; }
.chart .axis { fill: var(--ink-3); font-size: 11px; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
details summary { cursor: pointer; color: var(--ink-3); margin-top: 8px; }

/* ---------- формы и кнопки ---------- */
form.inline { display: grid; gap: 10px; margin-bottom: 16px; }
form.inline + form.inline { border-top: 1px solid var(--line); padding-top: 16px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 14px; font-weight: 400; }
input[type=text], input[type=password], input[type=number], select {
  font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 10px 12px; width: 100%;
}
input::placeholder { color: var(--ink-3); }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input.code { letter-spacing: 4px; font-variant-numeric: tabular-nums; max-width: 170px; }
.help { color: var(--ink-3); font-size: 12.5px; }
button {
  font: inherit; font-weight: 600; border-radius: var(--r); padding: 10px 16px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  transition: transform 0.15s ease, background 0.15s ease;
}
button:active { transform: translateY(1px) scale(0.99); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
button.danger { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); color: var(--bad); }
button.link { border: 0; background: none; color: var(--ink-3); padding: 0; font-weight: 500; }
button.link:hover { color: var(--ink); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }

.flash { padding: 12px 16px; border-radius: var(--r); margin-bottom: 16px; border: 1px solid var(--line); background: var(--surface); }
.flash.ok { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.flash.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.showcase-note { margin-top: 32px; text-align: center; font-size: 12px; color: var(--ink-3); }
.demo-banner { margin-bottom: 20px; padding: 10px 14px; border-radius: var(--r); font-size: 13px; color: var(--ink-2); background: var(--surface); border: 1px dashed var(--line); }

/* ---------- вход ---------- */
.login { min-height: calc(100dvh - 140px); display: grid; place-items: center; }
.login-card {
  width: min(420px, 100%); display: grid; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 28px; box-shadow: var(--shadow);
}
.login-faces { display: flex; margin-bottom: 4px; }
.login-faces img { width: 44px; height: 44px; border-radius: 999px; border: 2px solid var(--surface); margin-right: -10px; object-fit: cover; }
.login-card h1 { font-size: 24px; }

/* ---------- журнал ---------- */
table.audit { width: 100%; border-collapse: collapse; font-size: 14px; }
table.audit td, table.audit th { text-align: left; padding: 9px 8px; vertical-align: top; }
table.audit th { color: var(--ink-3); font-weight: 500; font-size: 12.5px; border-bottom: 1px solid var(--line); }
table.audit tbody tr + tr td { border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.page-title { font-size: 30px; font-weight: 700; margin-bottom: 6px; }

/* ---------- адаптив ---------- */
@media (max-width: 960px) {
  .intro { grid-template-columns: 1fr; align-items: start; }
  .columns { grid-template-columns: 1fr; }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow li:nth-child(2)::after { display: none; }
}
@media (max-width: 720px) {
  main { padding: 20px 16px 48px; }
  header.top { padding: 0 16px; height: 56px; }
  header.top nav { gap: 14px; }
  .brand small, .brand-name { display: none; }
  .intro h1 { font-size: 30px; }
  .agent, .agent-hero { grid-template-columns: 1fr; }
  .portrait img { aspect-ratio: 16 / 10; object-position: center 22%; }
  .agent-body, .agent-hero .agent-body { padding: 18px 18px 18px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agent-hero h1 { font-size: 28px; }
  .table-wrap { overflow-x: auto; }
}
@media (max-width: 420px) {
  .flow li { font-size: 12.5px; }
  .flow li::after { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
