/* ИИ-контур ФХД МИСИС — дизайн-система по токенам НейроАгента (светлая тема, Inter, один синий акцент).
   Источник токенов: ~/NeuroAgentMain/ui/src/tokens/light.css, tailwind.config.js, styles.css. */
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("../assets/fonts/inter-400.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("../assets/fonts/inter-500.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("../assets/fonts/inter-600.woff2") format("woff2"); }

:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --bg: #F2F6FC;            /* подложка окна */
  --surface: #FFFFFF;        /* панели и карточки */
  --ink: #010533;            /* основной текст — тёмно-синий, не чёрный */
  --ink-2: #5B6172;          /* вторичный текст */
  --ink-3: #879CBB;          /* даты, подписи групп */
  --faint: #9AA0B0;          /* шаги агента, метаданные */
  --steps: #8A90A0;          /* текст рассуждений */
  --line: #E9EDF3;           /* рамки полей и карточек */
  --hair: #ECEEF4;           /* волоски между строками */
  --hair-2: #DDE1EA;         /* линия под шапкой таблицы */
  --fill: rgba(64, 76, 123, .08);  /* приглушённая зона, пузырь пользователя */
  --fill-2: #F2F6FC;         /* hover и активная строка */
  --placeholder: #BCC7D8;
  --icon-2: #A2B3CA;

  --accent: #2C72E2;
  --accent-2: #1C65D9;
  --accent-soft: #EAF1FC;
  --dark: #010533;

  --ok: #16A34A;   --ok-ink: #15803D;   --ok-soft: #EAF7EE;
  --bad: #D92D20;  --bad-ink: #B42318;  --bad-soft: #FBE9E8;
  --warn: #C27434; --warn-ink: #A35B26; --warn-soft: #F6ECE3;
  --run: #64748B;  --run-soft: #E9EDF3;
  --na: #9AA0B0;   --na-soft: #F2F6FC;

  --r-btn: 8px;
  --r-ctl: 12px;
  --r-card: 16px;
  --r-panel: 24px;

  --sh-card: 0 1px 2px rgba(15, 18, 34, .04), 0 8px 24px rgba(15, 18, 34, .06);
  --sh-input: 0 2px 8px rgba(15, 18, 34, .06);
  --sh-pop: 0 4px 50px rgba(92, 92, 92, .15);
  --sh-modal: 0 12px 40px rgba(15, 18, 34, .16);

  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11";
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
img { display: block; max-width: 100%; }
.num, .tn { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
::selection { background: rgba(44, 114, 226, .16); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ——— типографика: выделение — 600, не 700; без капса с трекингом ——— */
h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--ink); }
h1 { font-size: 22px; line-height: 1.25; letter-spacing: -.01em; }
h2 { font-size: 18px; line-height: 1.3; }
h3 { font-size: 15px; line-height: 1.35; }
h4 { font-size: 14px; line-height: 1.4; }
.label { font-size: 12px; font-weight: 500; color: var(--ink-3); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.big-num { font-size: 28px; line-height: 1.1; font-weight: 500; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* ——— поверхности ——— */
.card { background: var(--surface); border-radius: var(--r-card); }
.panel { background: var(--surface); border-radius: var(--r-panel); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 0; min-height: 40px; }
.card-head h3, .card-head h2 { flex: 1; min-width: 0; }
.well { background: var(--fill-2); border-radius: var(--r-ctl); }

/* ——— кнопки (h 40, r 8, 14/600, без градиентов и цветных теней) ——— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 14px; border-radius: var(--r-btn);
  font-weight: 600; font-size: 14px; line-height: 1;
  transition: background .15s, color .15s, border-color .15s, transform .06s;
  white-space: nowrap; user-select: none;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-dark { background: var(--dark); color: #fff; }
.btn-dark:hover { background: #1A1E28; }
.btn-line, .btn-soft { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-line:hover, .btn-soft:hover { background: var(--fill-2); }
.btn-ghost { color: var(--ink); }
.btn-ghost:hover { background: var(--fill-2); }
.btn-link { height: auto; padding: 0; color: var(--accent); }
.btn-link:hover { color: var(--accent-2); }
.btn-danger { background: #fff; color: var(--bad); border: 1px solid var(--line); }
.btn-danger:hover { background: rgba(217, 45, 32, .08); }
.btn-ok { background: #fff; color: var(--ok-ink); border: 1px solid var(--line); }
.btn-ok:hover { background: var(--ok-soft); }
.btn-ai { background: var(--accent); color: #fff; }
.btn-ai:hover { background: var(--accent-2); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-sm svg { width: 16px; height: 16px; }
.btn-lg { height: 48px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn[disabled], .btn.is-disabled { opacity: .4; pointer-events: none; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: #fff; border: 1px solid var(--line); color: var(--ink);
  transition: background .15s;
}
.icon-btn:hover { background: var(--fill-2); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.icon-btn.plain { border-color: transparent; background: transparent; }
.icon-btn.plain:hover { background: var(--fill-2); }

/* ——— чипы и бейджи: 12/500, текст цвета статуса на фоне того же цвета ~14% ——— */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap; line-height: 1;
  background: var(--fill-2); color: var(--ink-2);
}
.chip svg { width: 13px; height: 13px; flex: none; }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.sm { height: 20px; padding: 0 7px; font-size: 11.5px; }
.chip.brand, .chip.ai, .chip.sky { background: var(--accent-soft); color: var(--accent-2); }
.chip.ok { background: var(--ok-soft); color: var(--ok-ink); }
.chip.bad, .chip.err { background: var(--bad-soft); color: var(--bad-ink); }
.chip.warn { background: var(--warn-soft); color: var(--warn-ink); }
.chip.na, .chip.teal, .chip.c1 { background: var(--fill-2); color: var(--ink-2); }
.chip.line { background: #fff; border: 1px solid var(--line); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: inline-grid; place-items: center;
  font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums;
  background: var(--fill-2); color: var(--ink-2);
}
.badge.bad { background: var(--bad); color: #fff; }
.badge.brand { background: var(--accent); color: #fff; }
.badge.soft, .badge.ai { background: var(--fill-2); color: var(--ink-2); }

/* статус-метка: кружок-иконка + слово (цвет никогда не один) */
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.st svg { width: 16px; height: 16px; flex: none; }
.st.ok { color: var(--ok-ink); } .st.bad, .st.critical, .st.error { color: var(--bad-ink); }
.st.warn, .st.warning { color: var(--warn-ink); } .st.manual, .st.sky { color: var(--accent-2); }
.st.na, .st.undescribed, .st.pending { color: var(--faint); }
.st .st-t { color: var(--ink); }

/* ——— сегмент-контрол (трек #F2F6FC, активный — белый) и вкладки ——— */
.seg { display: inline-flex; padding: 4px; gap: 2px; background: var(--fill); border-radius: 14px; }
.seg button {
  height: 32px; padding: 0 12px; border-radius: 10px;
  font-weight: 600; font-size: 13.5px; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s;
}
.seg button svg { width: 16px; height: 16px; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(15, 18, 34, .06); }
.seg button .badge { height: 18px; min-width: 18px; font-size: 11.5px; background: transparent; padding: 0 2px; }
.seg button.on .badge { color: var(--ink-2); }
.seg.sm button { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--hair); }
.tabs button {
  position: relative; height: 40px; padding: 0;
  font-weight: 500; font-size: 14px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--ink); font-weight: 600; }
.tabs button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }
.tabs button .badge { height: 18px; min-width: 18px; font-size: 11.5px; }

/* ——— поля (40px, r 12, рамка #E9EDF3 → синяя в фокусе) ——— */
.input {
  height: 40px; width: 100%; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-ctl); background: #fff;
  outline: none; transition: border-color .15s;
}
.input::placeholder { color: var(--placeholder); }
.input:focus { border-color: var(--accent); }
textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--icon-2); pointer-events: none; }
.search .input { padding-left: 38px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.toggle { position: relative; width: 36px; height: 20px; border-radius: 999px; background: var(--line); transition: background .15s; flex: none; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .15); transition: transform .18s var(--ease); }
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(16px); }

/* ——— таблицы: без сетки, только волоски; шапка 600 с линией 1.5px ——— */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.tbl th {
  text-align: left; font-size: 13px; font-weight: 600; color: var(--ink);
  padding: 10px 12px; border-bottom: 1.5px solid var(--hair-2); white-space: nowrap;
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--hair); vertical-align: middle; }
.tbl th:first-child, .tbl td:first-child { padding-left: 2px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 2px; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover { background: var(--fill-2); }
.tbl .r { text-align: right; }
.tbl .grp td { padding-top: 18px; font-weight: 600; color: var(--ink); border-bottom-color: var(--hair-2); }

/* ——— аватары: ровный кружок с инициалами, без градиентов ——— */
.ava {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center;
  font-size: 12px; font-weight: 600; color: #637082;
  background: #E9EDF3;
}
.ava.sm { width: 24px; height: 24px; font-size: 10px; }
.ava.lg { width: 40px; height: 40px; font-size: 14px; }
.ava.feu { background: #DCE6FB; color: var(--ink); }
.ava.me { background: #DCE6FB; color: var(--ink); }
.ava.agent { background: var(--dark); color: #fff; }

/* ——— всплывающие ——— */
.tip {
  position: fixed; z-index: 400; pointer-events: none;
  max-width: 320px; padding: 8px 10px; border-radius: 10px;
  background: #000; color: #fff; font-size: 12.5px; line-height: 1.45; font-weight: 400;
  opacity: 0; transition: opacity .12s;
}
.tip.on { opacity: 1; }
.tip b { font-weight: 600; }
.tip .t-sub { color: #B8BFCC; margin-top: 2px; }

.toasts { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 500; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  display: flex; align-items: baseline; gap: 10px; max-width: 560px;
  padding: 11px 16px; border-radius: 12px; background: var(--dark); color: #fff;
  box-shadow: var(--sh-pop); animation: rise .18s ease-out;
}
.toast .ti { display: none; }
.toast .tt { font-weight: 500; font-size: 14px; }
.toast .ts { font-size: 13px; color: #B8BFCC; margin-top: 1px; }
.toast.out { animation: fadeOut .2s ease forwards; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fadeOut { to { opacity: 0; } }

/* ——— модальные окна: затемнение без размытия, радиус 24, крестик — круг 36 ——— */
.modal-back {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(48, 50, 74, .6);
  display: grid; place-items: center; padding: 24px;
  animation: fadeIn .15s ease;
}
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 48px);
  background: #fff; border-radius: var(--r-panel); box-shadow: var(--sh-modal);
  display: flex; flex-direction: column; overflow: hidden;
  animation: rise .15s ease-out;
}
.modal.wide { width: min(1240px, 100%); height: min(840px, calc(100vh - 48px)); }
.modal.mid { width: min(820px, 100%); }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 22px 24px 12px; }
.modal-head .mh-t { flex: 1; min-width: 0; }
.modal-head h2 { font-size: 20px; }
.modal-body { padding: 8px 24px 20px; overflow: auto; flex: 1; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 24px 20px; }
.modal-foot .sp { flex: 1; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ——— прочее ——— */
.divider { height: 1px; background: var(--hair); margin: 16px 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.scroll { overflow: auto; }
.scroll::-webkit-scrollbar, .modal-body::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll::-webkit-scrollbar-thumb, .modal-body::-webkit-scrollbar-thumb { background: #D6DDE7; border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #E6E8F0; border-top-color: #9AA0B0; animation: spin .8s linear infinite; flex: none; }
.spin.brand { border-top-color: var(--accent); }
.spin.white { border-color: rgba(255, 255, 255, .35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmerText { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skel { border-radius: 8px; background: linear-gradient(90deg, #EEF1F6 0%, #F6F8FB 50%, #EEF1F6 100%); background-size: 200% 100%; animation: shimmerText 1.4s linear infinite; }
.shimmer {
  background: linear-gradient(90deg, var(--faint) 0%, var(--ink) 45%, var(--faint) 90%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmerText 2s linear infinite;
}
.demo-mark { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-3); }
.demo-reset { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; margin-right: -6px; border: 0; border-radius: 6px; background: none; font: inherit; color: var(--ink-3); cursor: pointer; }
.demo-reset:hover { background: var(--fill-2); color: var(--ink); }
.demo-reset svg { width: 13px; height: 13px; }
kbd { font-family: var(--font); font-size: 12px; font-weight: 600; min-width: 24px; height: 24px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; padding: 28px 20px; color: var(--ink-3); }
.empty img { width: 120px; height: 120px; object-fit: contain; margin-bottom: 6px; }
.empty b { color: var(--ink); font-weight: 600; font-size: 15px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* [frontend] пометка «имитация» у шагов, которые без внешних систем невозможны (R9 §4.2): серая, неброская */
.sim { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 999px; background: var(--fill-2); color: var(--ink-3); font-size: 11px; font-weight: 500; line-height: 1; margin-left: 6px; vertical-align: middle; white-space: nowrap; }
