/* Пульт ИИ-контура — прототип. Нативная админка: системный шрифт, работает без сети. */
:root {
  --bg: #F3F5F9;
  --surface: #FFFFFF;
  --surface-2: #F7F8FB;
  --line: #E1E5EE;
  --line-2: #EDF0F5;
  --ink: #131833;
  --ink-2: #3B4263;
  --mute: #666E90;
  --faint: #9AA2BF;
  --accent: #0054E8;
  --accent-ink: #FFFFFF;
  --accent-soft: #E7EEFD;
  --ok: #137A45;
  --ok-soft: #E2F3E9;
  --warn: #8F5B00;
  --warn-soft: #FFF2D4;
  --bad: #C8292F;
  --bad-soft: #FDE8E9;
  --info-soft: #EAF0FF;
  --nav: #0E1330;
  --nav-ink: #C9CEE6;
  --nav-mute: #7E86AD;
  --nav-on: #1D2552;
  --banner: #FFF7D6;
  --banner-ink: #5A4700;
  --shadow: 0 1px 2px rgba(19, 24, 51, .06), 0 8px 24px -16px rgba(19, 24, 51, .28);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;
  --r: 12px;
  --ease: cubic-bezier(.23, 1, .32, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0A0D1F;
    --surface: #121731;
    --surface-2: #171D3B;
    --line: #262D55;
    --line-2: #1E2448;
    --ink: #E8EBF8;
    --ink-2: #C3C8E2;
    --mute: #8F96BB;
    --faint: #5E6690;
    --accent: #6F9CFF;
    --accent-ink: #061036;
    --accent-soft: #1A2659;
    --ok: #55CC8A;
    --ok-soft: #0F3020;
    --warn: #F0BF57;
    --warn-soft: #36280A;
    --bad: #FF8086;
    --bad-soft: #3B151A;
    --info-soft: #172352;
    --nav: #070A18;
    --nav-ink: #C9CEE6;
    --nav-mute: #6F779F;
    --nav-on: #182047;
    --banner: #2E2708;
    --banner-ink: #F2DC8A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -16px rgba(0, 0, 0, .8);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0A0D1F;
  --surface: #121731;
  --surface-2: #171D3B;
  --line: #262D55;
  --line-2: #1E2448;
  --ink: #E8EBF8;
  --ink-2: #C3C8E2;
  --mute: #8F96BB;
  --faint: #5E6690;
  --accent: #6F9CFF;
  --accent-ink: #061036;
  --accent-soft: #1A2659;
  --ok: #55CC8A;
  --ok-soft: #0F3020;
  --warn: #F0BF57;
  --warn-soft: #36280A;
  --bad: #FF8086;
  --bad-soft: #3B151A;
  --info-soft: #172352;
  --nav: #070A18;
  --nav-ink: #C9CEE6;
  --nav-mute: #6F779F;
  --nav-on: #182047;
  --banner: #2E2708;
  --banner-ink: #F2DC8A;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -16px rgba(0, 0, 0, .8);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.mono { font-family: var(--mono); font-size: .93em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--mute); }

/* ——— Каркас ——— */
.proto { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; justify-content: space-between; padding: 8px 16px; background: var(--banner); color: var(--banner-ink); font-size: 13px; }
.proto b { font-weight: 650; }
.proto label { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; font-weight: 600; }
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: calc(100vh - 38px); }
.nav { background: var(--nav); color: var(--nav-ink); padding: 14px 10px 18px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: env(safe-area-inset-top, 0px); height: 100vh; overflow: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: #FFFFFF; position: relative; flex: none; }
.brand-mark::before { content: ''; position: absolute; inset: 7px; border-radius: 50%; border: 2.5px solid #0E1330; }
.brand-mark::after { content: ''; position: absolute; left: 13.75px; top: 6px; width: 2.5px; height: 9px; background: #0E1330; border-radius: 1px; }
.brand b { display: block; color: #FFFFFF; font-size: 14.5px; line-height: 1.2; }
.brand small { display: block; color: var(--nav-mute); font-size: 11.5px; }
.nav-group { margin: 12px 8px 4px; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--nav-mute); font-weight: 600; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--nav-ink); text-decoration: none; font-weight: 500; }
.nav a .ic { color: var(--nav-mute); }
.nav a .badge { margin-left: auto; }
.nav a.on { background: var(--nav-on); color: #FFFFFF; }
.nav a.on .ic { color: #FFFFFF; }
@media (hover: hover) and (pointer: fine) { .nav a:hover { background: var(--nav-on); } }
.nav-foot { margin-top: auto; padding: 16px 10px 0; font-size: 11.5px; color: var(--nav-mute); line-height: 1.55; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--accent); color: #FFFFFF; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .crumb { font-weight: 600; margin-right: auto; }
.topbar .crumb small { color: var(--mute); font-weight: 400; margin-left: 6px; }
.user { display: inline-flex; gap: 8px; align-items: center; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.content { padding: 22px 24px 64px; display: grid; gap: 28px; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; flex-direction: row; overflow-x: auto; gap: 4px; padding: 8px 12px; align-items: center; }
  .brand { padding: 0 8px 0 0; }
  .brand small, .nav-group, .nav-foot { display: none; }
  .nav a { flex: none; padding: 7px 10px; }
  .topbar { padding: 10px 16px; }
  .topbar .user, .topbar .btn-ghost, .topbar .crumb small, .brand > span:last-child { display: none; }
  .content { padding: 16px 16px 48px; }
}

/* ——— Экран ——— */
.screen { display: grid; gap: 18px; align-content: start; scroll-margin-top: 70px; }
.js .screen:not(.on) { display: none; }
.js.all .screen:not(.on) { display: grid; }
.js.all .screen + .screen { border-top: 2px dashed var(--line); padding-top: 28px; }
.screen-head { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; justify-content: space-between; }
.screen-head h1 { margin: 0; font-size: 22px; line-height: 1.25; letter-spacing: -.01em; font-weight: 700; }
.screen-head p { margin: 4px 0 0; color: var(--mute); max-width: 70ch; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
h2.sec { margin: 6px 0 0; font-size: 15px; font-weight: 700; }
h3.sub { margin: 0; font-size: 13.5px; font-weight: 700; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { flex: none; border: 0; background: none; padding: 9px 12px; border-bottom: 2px solid transparent; color: var(--mute); font-weight: 600; cursor: pointer; }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); }
.js .tabpanel:not(.on) { display: none; }
.js.all .tabpanel:not(.on) { display: grid; }
.tabpanel { display: grid; gap: 16px; align-content: start; }
.js.all .tabpanel + .tabpanel { margin-top: 10px; }
.js.all .tabpanel[data-title]::before { content: attr(data-title); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--mute); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-start; justify-content: space-between; }
.card-head .t { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.card-head b { display: block; font-size: 14.5px; }
.card-head small { display: block; color: var(--mute); font-size: 12.5px; }
.card-ic { width: 32px; height: 32px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1100px) { .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } }

/* ——— Поля ——— */
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.fields .wide { grid-column: 1 / -1; }
@media (max-width: 720px) { .fields { grid-template-columns: 1fr; } }
.f { display: grid; gap: 4px; align-content: start; min-width: 0; }
.f > label, .f > .l { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.f .req { color: var(--bad); margin-left: 2px; }
.f .hint { font-size: 12px; color: var(--mute); line-height: 1.4; }
.in, .sel, .ta {
  width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2);
  padding: 7px 10px; font-size: 13.5px; line-height: 1.35; color: var(--ink);
}
.in.mono { font-family: var(--mono); font-size: 12.5px; }
.in[readonly] { background: var(--line-2); color: var(--ink-2); }
.ta { min-height: 76px; resize: vertical; }
.row-in { display: flex; gap: 6px; }
.row-in .in { flex: 1; }
.chk { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; align-items: start; font-size: 13.5px; }
.chk input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--accent); }
.chk small { display: block; color: var(--mute); font-size: 12px; }
.lock { display: inline-flex; gap: 4px; align-items: center; font-size: 11.5px; color: var(--mute); }

.tgl-row { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line-2); }
.tgl-row:first-child { border-top: 0; padding-top: 0; }
.tgl-row b { display: block; font-weight: 600; font-size: 13.5px; }
.tgl-row small { display: block; color: var(--mute); font-size: 12px; }
.tgl { flex: none; width: 40px; height: 22px; border-radius: 999px; border: 0; background: var(--faint); position: relative; cursor: pointer; transition: background-color 160ms ease; }
.tgl::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #FFFFFF; transition: transform 180ms var(--ease); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.tgl[aria-checked="true"] { background: var(--accent); }
.tgl[aria-checked="true"]::after { transform: translateX(18px); }
.tgl[disabled] { opacity: .55; cursor: default; }

.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface-2); }
.seg button { border: 0; background: none; padding: 6px 11px; font-size: 13px; font-weight: 600; color: var(--mute); cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.seg button[disabled] { opacity: .5; cursor: default; }

/* ——— Кнопки ——— */
.btn {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); border-radius: 9px; padding: 7px 12px; font-size: 13px; font-weight: 600; line-height: 1.2;
  cursor: pointer; white-space: nowrap; transition: transform 120ms var(--ease), background-color 150ms ease;
}
.btn:active { transform: scale(.97); }
a.btn, a.pill { text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { color: var(--bad); border-color: var(--bad-soft); }
.btn-ghost { border-color: transparent; background: none; color: var(--accent); padding-inline: 6px; }
.btn-sm { padding: 5px 9px; font-size: 12.5px; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--surface-2); }
  .btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
  .btn-ghost:hover { background: var(--accent-soft); }
}

/* ——— Статусы ——— */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; padding: 3px 9px; border-radius: 999px; white-space: nowrap; line-height: 1.35; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.no-dot::before { display: none; }
.ok { background: var(--ok-soft); color: var(--ok); }
.warn { background: var(--warn-soft); color: var(--warn); }
.bad { background: var(--bad-soft); color: var(--bad); }
.idle { background: var(--line-2); color: var(--mute); }
.info { background: var(--info-soft); color: var(--accent); }
.res { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 8px; border-radius: 9px; padding: 9px 11px; font-size: 13px; line-height: 1.45; }
.res .ic { margin-top: 2px; }
.res.ok, .res.bad, .res.warn, .res.idle { font-weight: 500; }
.spin { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ——— Таблицы ——— */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top; }
.tbl th { font-size: 11.5px; font-weight: 650; color: var(--mute); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tr { transition: opacity 240ms ease; }
.tbl tr[data-state="pending"] { opacity: .2; }
.tbl td.mono { white-space: nowrap; }
.tbl td.n, .tbl th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td small { display: block; color: var(--mute); font-size: 12px; }
.tbl .acts { white-space: nowrap; text-align: right; }
.tbl-min { min-width: 760px; }
.tbl-mid { min-width: 620px; }

/* ——— Показатели ——— */
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 6px; align-content: start; }
.kpi > span { font-size: 12px; font-weight: 650; color: var(--mute); text-transform: uppercase; letter-spacing: .04em; }
.kpi > b { font-size: 20px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi > small { color: var(--mute); font-size: 12.5px; line-height: 1.45; }
.meter { display: grid; gap: 5px; }
.meter div:first-child { display: flex; justify-content: space-between; font-size: 12.5px; }
.meter .bar { height: 7px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.meter .bar i { display: block; height: 100%; width: var(--p); background: var(--accent); border-radius: inherit; }
.ev { list-style: none; margin: 0; padding: 0; display: grid; }
.ev li { display: grid; grid-template-columns: 92px 18px minmax(0, 1fr); gap: 8px; padding: 8px 0; border-top: 1px solid var(--line-2); font-size: 13px; }
.ev li:first-child { border-top: 0; }
.ev time { color: var(--mute); font-variant-numeric: tabular-nums; }
.ev .ic.ok-c { color: var(--ok); } .ev .ic.bad-c { color: var(--bad); } .ev .ic.warn-c { color: var(--warn); } .ev .ic.info-c { color: var(--accent); }

/* ——— Мастер ——— */
.wiz { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .wiz { grid-template-columns: 1fr; } }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; counter-reset: s; }
.steps button { width: 100%; display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; align-items: center; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 9px; cursor: pointer; color: var(--ink-2); }
.steps button small { display: block; color: var(--mute); font-size: 12px; }
.steps .dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--line-2); color: var(--mute); }
.steps [data-st="done"] .dot { background: var(--ok); color: #FFFFFF; }
.steps [data-st="cur"] { background: var(--accent-soft); color: var(--ink); }
.steps [data-st="cur"] .dot { background: var(--accent); color: #FFFFFF; }
.wiz-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }

/* ——— Разное ——— */
.drop { border: 1.5px dashed var(--faint); border-radius: var(--r); padding: 18px; display: grid; gap: 6px; justify-items: center; text-align: center; color: var(--mute); background: var(--surface-2); }
.drop b { color: var(--ink); }
.code { font-family: var(--mono); font-size: 12px; line-height: 1.55; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.note { font-size: 12.5px; color: var(--mute); line-height: 1.5; }
.callout { border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.5; background: var(--info-soft); color: var(--ink-2); }
.callout b { color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chipx { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 13px; margin: 0; }
.kv dt { color: var(--mute); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.prog { display: grid; gap: 6px; }
.prog .bar { height: 8px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.prog .bar i { display: block; height: 100%; width: var(--p, 0%); background: var(--accent); transition: width 260ms linear; }
.slist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.slist li { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 8px; font-size: 13px; align-items: start; }
.slist li small { display: block; color: var(--mute); font-size: 12px; }
.slist li em { font-style: normal; color: var(--mute); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.slist .s-ico { display: grid; place-items: center; width: 16px; height: 16px; margin-top: 2px; }
.slist li[data-state="done"] .s-ico { color: var(--ok); }
.slist li[data-state="run"] .s-ico { color: var(--accent); }
.slist li[data-state="pending"] { color: var(--mute); }
.slist li[data-state="pending"] .s-ico::before { content: ''; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--faint); }
.matrix td.c, .matrix th.c { text-align: center; }
.dotm { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.dotm.no { background: none; box-shadow: inset 0 0 0 1.5px var(--faint); }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); transform: translateX(-50%) translateY(12px); opacity: 0; pointer-events: none; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow); transition: opacity 180ms ease, transform 220ms var(--ease); max-width: min(560px, calc(100vw - 32px)); z-index: 20; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.copy-fallback { width: 100%; min-height: 80px; margin-top: 6px; font: 12px/1.45 var(--mono); border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--surface-2); color: var(--ink); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
}
