/* RixAI Design System 1.3.0 → панель управления. Токены из design-tokens.json,
   рецепты из app/globals.css кита и дашборда NewsAuto (тот же кит после правок Максима).
   Меняйте значения в :root, остальное подхватится. */

@font-face {
  font-family: "Inter";
  src: url("fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("fonts/GeistMonoVariable.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --background: #1d1d1c;
  --sidebar: #141414;
  --card: #202020;
  --card2: #262626;
  --row: #2a2a2a;
  --elevated: #2b2b2b;
  --popover: #252525;
  --border: #424242;
  --divider: #343434;
  --foreground: #f7f7f5;
  --muted: #aaa9a7;
  --faint: #8e8e8a;
  --primary: #ff970f;
  --primary-ink: #19150f;
  --positive: #29af6b;
  --positive-t: #67cb95;
  --positive-bg: #20352a;
  --positive-line: #2c4c39;
  --negative: #dd4761;
  --negative-t: #e87b8e;
  --negative-bg: #38252a;
  --negative-line: #53333b;
  --warn-t: #ffd096;
  --warn-bg: #3c3120;
  --warn-line: #5b4629;
  --focus: #68bbe8;

  --control-radius: 7px;
  --panel-radius: 11px;
  --panel-gap: 13px;
  --sidebar-size: 15.3rem;

  --sans: "Inter", Arial, sans-serif;
  --mono: "Geist Mono", "SFMono-Regular", Consolas, monospace;
  --art-frame-height: 6.1rem;
  --label-gap: 0.38rem;
  --motion-standard: 0.15s ease;
  --art-ink: #090b10;
  --art-ivory: #e8e7dd;
}

html { font-size: 100%; }
html[data-scale="125"] { font-size: 118%; }
html[data-scale="150"] { font-size: 134%; }
html[data-scale="175"] { font-size: 150%; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font: 0.875rem/1.5 var(--sans);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
button, a, input, textarea, summary { outline-offset: 4px; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--primary); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 1px solid var(--primary); outline-offset: -1px; }
::selection { background: rgba(255, 151, 15, 0.35); }
svg { flex-shrink: 0; }
h1, h2, h3, p, figure { margin: 0; }

.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.positive { color: var(--positive-t); }
.negative { color: var(--negative-t); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--primary); color: var(--primary-ink); padding: 6px 12px; border-radius: var(--control-radius); }
.skip:focus { left: 8px; z-index: 100; }

/* ---------- оболочка ---------- */
.frame { display: flex; min-height: 100vh; background: var(--background); }
.main { flex: 1; min-width: 0; padding: 24px; container: main / inline-size; }

/* ---------- боковая панель ---------- */
.side {
  width: var(--sidebar-size); flex: 0 0 var(--sidebar-size);
  background: var(--sidebar); padding: 15px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; scrollbar-width: thin;
}
.brand { display: flex; align-items: center; gap: 0.81rem; min-height: 2.63rem; margin-bottom: 1rem; white-space: nowrap; }
.rixai-mark {
  height: 36px; width: 36px; flex-shrink: 0; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--primary);
  background: linear-gradient(135deg, #313131, #242424);
  box-shadow: inset 0 0 0 1px #3b3b3b, inset 0 1px 4px #ffffff0d;
}
.rixai-mark svg { width: 22px; height: 22px; stroke-width: 2; }
.brand-name { font-size: 1.06rem; letter-spacing: -0.3px; font-weight: 450; line-height: 1.15; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.brand-name small { display: block; font: 0.69rem/1.2 var(--mono); letter-spacing: 1.2px; color: var(--muted); margin-top: 3px; text-transform: uppercase; }
.icon-button { border: 0; background: transparent; color: inherit; padding: 4px; display: inline-flex; align-items: center; justify-content: center; border-radius: 5px; }
.icon-button:hover { background: #ffffff10; }
.brand .icon-button { margin-left: auto; }
.side-close { display: none; }

.sky-frame {
  display: block; position: relative; isolation: isolate; width: 100%; padding: 0; cursor: pointer;
  height: var(--art-frame-height); flex: 0 0 var(--art-frame-height); margin: 0 0 21px;
  overflow: hidden; border: 1px solid #ffffff20; border-radius: 10px; background: var(--art-ink); box-shadow: 0 2px 8px #0004;
}
.sky-frame img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 10%; opacity: 0.78; display: block; transition: opacity var(--motion-standard); }
.sky-frame:hover img, .sky-frame:focus-visible img { opacity: 0.95; }
.sky-frame-caption {
  position: absolute; inset: auto 0 0; display: flex; flex-direction: column; align-items: flex-start;
  padding: 0.9rem 0.62rem 0.44rem; background: linear-gradient(transparent, #090b10e8);
  font: 0.7rem/1.4 var(--mono); letter-spacing: 0.6px; color: var(--art-ivory); pointer-events: none; z-index: 1; text-align: left;
}
.sky-frame-caption .go { color: var(--primary); white-space: nowrap; }

.sidebar-section { border-top: 1px solid var(--divider); padding-top: 15px; margin-top: 4px; }
.sidebar-section:first-of-type { border-top: 0; padding-top: 0; }
.section-label { font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.2px; color: var(--muted); margin: 0 0 10px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; min-height: 2.5rem; padding: 0.4rem 12px; border-radius: 13px;
  color: #b1b1af; font-size: 0.95rem; white-space: nowrap; text-decoration: none; width: 100%;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: #252525; color: #fff; }
.nav-item[aria-current="page"] { color: #fff; background: var(--elevated); }
.nav-item svg { width: 18px; height: 18px; stroke-width: 1.5; }
.nav-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item .cnt { margin-left: auto; flex: none; font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.nav-item[aria-current="page"] .cnt { color: #ddd; }
.nav-item .cnt.alert { color: var(--warn-t); }

.sidebar-bottom { margin-top: auto; padding-top: 22px; }
.status {
  border: 1px solid #363636; border-radius: var(--panel-radius); padding: 14px 12px;
  background: linear-gradient(135deg, #292929, #1c1c1c); box-shadow: 0 5px 12px #0004;
}
.status b { display: flex; align-items: center; gap: 8px; font-size: 0.844rem; font-weight: 500; }
.status .dot { font-size: 0.56rem; color: var(--positive); flex: none; margin: 0 0.35rem 0 0.15rem; position: relative; top: -0.12rem; }
.status .dot.off { color: var(--negative); }
.status p { margin: 6px 0 0; font-size: 0.75rem; color: var(--muted); line-height: 1.5; }
.status .who { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px solid #333; font-size: 0.75rem; color: var(--muted); line-height: 1.3; }
.status .who .btn { min-height: 28px; padding: 3px 8px; font-size: 0.75rem; }
.status .who b { font-size: 0.781rem; color: var(--foreground); display: inline; }
.status .who form { margin-left: auto; }
.sidebar-bottom > small { display: flex; justify-content: space-between; color: #6f6f6f; font-family: var(--mono); font-size: 0.688rem; margin: 14px 0 2px; letter-spacing: 0.3px; }

/* ---------- заголовки ---------- */
.crumb { display: flex; align-items: center; gap: 12px; font-size: 0.95rem; color: var(--foreground); margin-bottom: 24px; height: 26px; white-space: nowrap; overflow: hidden; }
.crumb span { display: inline-flex; color: var(--muted); }
.crumb svg { width: 13px; height: 13px; color: #8a8a86; }
.crumb a { text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
h1 { font-size: 1.9rem; line-height: 1.25; font-weight: 500; letter-spacing: -1px; margin: 0 0 7px; }
.sub { font-size: 0.85rem; line-height: 1.5; color: #a5a5a5; margin: 0 0 22px; max-width: 720px; }
h2 { font-size: 0.95rem; font-weight: 500; margin: 0; }
.head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.head-row .counter { margin-top: 10px; }
.eyebrow { font-family: var(--mono); font-size: 0.73rem; color: var(--muted); letter-spacing: 0.15px; margin: 0 0 4px; }
.counter { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.section-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.25rem 0.75rem; margin: 1.38rem 0 0.62rem; }
.section-heading h2 { flex: none; }
.section-heading > .cnt, .section-heading > .eyebrow { flex: 1 1 auto; }
.section-heading details.action[open] { flex: 1 0 100%; }
.section-heading details.action .card { width: 100%; max-width: 44rem; }
.section-heading h2 { font-size: 0.95rem; }

/* ---------- показатели ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(16.5rem, 1fr)); gap: var(--panel-gap); margin-bottom: var(--panel-gap); }
/* Плитка читается с одного взгляда: крупное число слева, подпись и уточнение справа. */
.stat {
  border: 1px solid var(--border); border-radius: var(--panel-radius); padding: 0.88rem 1rem;
  min-height: 6rem; background: linear-gradient(130deg, #2a2a2a, #1d1d1d); min-width: 0;
  display: grid; grid-template-columns: minmax(0, auto) minmax(7rem, 1fr); grid-template-rows: auto auto;
  column-gap: 1rem; align-content: center;
}
.stat .l { grid-column: 2; grid-row: 1; align-self: end; font-size: 0.95rem; color: var(--muted); margin: 0; line-height: 1.35; letter-spacing: 0.15px; }
.stat .v { grid-column: 1; grid-row: 1 / span 2; align-self: center; font-family: var(--mono); font-size: 2.4rem; font-weight: 400; line-height: 1.05; letter-spacing: -1.5px; margin: 0; }
.stat .d { grid-column: 2; grid-row: 2; align-self: start; font-size: 0.82rem; color: var(--muted); margin-top: 0.25rem; line-height: 1.4; }
.stat:not(:has(.d)) .l { grid-row: 1 / span 2; align-self: center; }
.stat .v small { display: block; font-size: 0.75rem; letter-spacing: 0; color: var(--muted); margin: 0; }
/* Словесное значение («работает», «боевая») слева не ставится: читается в столбик. */
.stat:has(.v.txt) { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; }
.stat:has(.v.txt) .l { grid-column: 1; grid-row: 1; align-self: start; margin-bottom: 0.35rem; }
.stat:has(.v.txt) .v { grid-column: 1; grid-row: 2; font-family: var(--sans); font-size: 1.5rem; letter-spacing: -0.5px; font-weight: 500; }
.stat:has(.v.txt) .d { grid-column: 1; grid-row: 3; margin-top: 0.4rem; }
.stat .d.ok { color: #72b78c; }
.stat .d.w { color: var(--primary); }

/* ---------- панели и карточки ---------- */
.card, .grp { border: 1px solid var(--border); border-radius: var(--panel-radius); background: var(--card); min-width: 0; }
.card { padding: 16px 18px; margin-bottom: var(--panel-gap); }
.card > h2 { font-size: 0.95rem; font-weight: 500; margin: 0 0 0.75rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.56rem; }
.card > h2 .cnt { margin-left: auto; font-family: var(--mono); font-size: 0.75rem; color: var(--muted); font-weight: 400; }
.grp { margin-bottom: var(--panel-gap); overflow: hidden; }
.grp-h { display: flex; align-items: center; gap: 0.62rem; padding: 0.81rem 1rem; border-bottom: 1px solid var(--divider); background: #242424; flex-wrap: wrap; }
.grp-h .nm { font-size: 0.875rem; font-weight: 500; }
.grp-h .st { font-family: var(--mono); font-size: 0.688rem; color: var(--muted); }
/* пояснение к главному выключателю стоит под ним, а не продолжает строку заголовка */
.grp-h .right { margin-left: auto; display: grid; justify-items: end; gap: 0.25rem; max-width: 24rem; }
.grp-h .right small { color: var(--faint); font-size: 0.78rem; line-height: 1.45; text-align: right; }
.grp-b { padding: 14px 16px 16px; }
.switch, .field label.switch {
  display: inline-flex; align-items: center; gap: 0.5rem; font-family: var(--sans);
  font-size: 0.9rem; letter-spacing: 0; color: var(--foreground); cursor: pointer;
}
.switch input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.inner.review { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-top: 12px; }
.inner.review b { color: var(--foreground); font-weight: 500; }
.inner { margin-top: 10px; padding: 10px 12px; background: var(--card2); border: 1px solid var(--divider); border-radius: var(--control-radius); font-size: 0.85rem; line-height: 1.5; color: var(--muted); }
.inner b { color: var(--foreground); font-weight: 500; }
.warnbox { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--panel-radius); padding: 12px 16px; margin-bottom: var(--panel-gap); font-size: 0.88rem; color: var(--warn-t); line-height: 1.5; }
.warnbox b { font-family: var(--mono); font-weight: 500; font-size: 0.719rem; letter-spacing: 0.2px; margin-right: 6px; }
.flash { border: 1px solid var(--positive-line); background: var(--positive-bg); color: #b8f0cf; padding: 10px 14px; border-radius: var(--panel-radius); margin-bottom: var(--panel-gap); font-size: 0.9rem; }
.flash-error { border-color: var(--negative-line); background: var(--negative-bg); color: #f0b8c4; }
.empty { padding: 4px 0; color: var(--muted); font-size: 0.88rem; }

/* ---------- элемент списка ---------- */
.item { position: relative; border: 1px solid var(--border); border-radius: var(--panel-radius); padding: 15px 16px; margin-bottom: var(--panel-gap); background: var(--card); }
.item:last-child { margin-bottom: 0; }
.item .t { font-weight: 500; font-size: 1rem; line-height: 1.35; letter-spacing: -0.2px; padding-right: 40px; }
.item .t a { color: inherit; text-decoration: none; }
.item .t a:hover { color: var(--primary); }
.item .meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; color: var(--muted); font-family: var(--mono); font-size: 0.76rem; letter-spacing: 0.15px; margin: 7px 0 0; min-height: 24px; }
.item .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.item .body { font-size: 0.88rem; line-height: 1.5; color: #cfcfcb; margin-top: 8px; }
.item.must { border-color: var(--warn-line); background: linear-gradient(112deg, #2a241a, #201f1c 60%); }
.item.must .t::before { content: ""; display: inline-block; width: 8px; height: 8px; background: var(--primary); transform: rotate(45deg); border-radius: 1px; margin: 0 9px 2px 1px; }
.item.dim { opacity: 0.7; }
.srcbtn {
  position: absolute; top: 12px; right: 12px; width: 28px; height: 28px; border-radius: var(--control-radius);
  display: flex; align-items: center; justify-content: center; border: 1px solid #414141;
  background: linear-gradient(120deg, #272727, #171717); box-shadow: inset 0 0 5px #ffffff16; color: #cfcfcb; text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.srcbtn:hover { color: #fff; border-color: #777; filter: brightness(1.12); }
.srcbtn svg { width: 14px; height: 14px; }
.acts { display: flex; gap: 0.38rem; margin-top: 0.75rem; flex-wrap: wrap; align-items: flex-start; }
.acts > form { display: inline; }
/* раскрытая панель занимает свою строку целиком, иначе она сдавлена между кнопками */
.acts details.action[open], .acts details.action .card, .acts form.card { width: 100%; max-width: 44rem; }

/* ---------- кнопки ---------- */
.btn, .rix-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid #414141;
  background: linear-gradient(120deg, #272727, #171717); box-shadow: inset 0 0 5px #ffffff16, 0 0 0 2px #ffffff03; color: #f4f4f3;
  border-radius: var(--control-radius); padding: 0.4rem 0.85rem; min-height: 2.15rem; font-size: 0.85rem; line-height: 1.2; white-space: nowrap;
  text-decoration: none; cursor: pointer; transition: border-color 0.15s, filter 0.15s;
}
.btn:hover, .rix-button:hover { border-color: #777; filter: brightness(1.12); }
.btn svg, .rix-button svg { width: 13px; height: 13px; stroke-width: 1.5; }
.btn:disabled, .rix-button:disabled { opacity: 0.45; cursor: default; }
.primary, .primary-button { background: linear-gradient(#ffb129, #ff9509); border-color: #e48a0d; color: var(--primary-ink); box-shadow: inset 0 1px 2px #ffe4a16b; font-weight: 500; }
.primary:hover, .primary-button:hover { border-color: #ffb02d; filter: brightness(1.05); }
.quiet, .quiet-button { background: transparent; box-shadow: none; border-color: transparent; color: var(--muted); }
.quiet:hover, .quiet-button:hover { background: #2a2a2a; border-color: transparent; color: var(--foreground); filter: none; }
.danger, .danger-button { color: var(--negative-t); }
.danger:hover, .danger-button:hover { border-color: var(--negative-line); background: var(--negative-bg); }
.btn.w { width: 100%; }
.large { min-height: 2.75rem; padding: 0.6rem 1.15rem; font-size: 0.95rem; }
.large svg { width: 1rem; height: 1rem; }

/* ---------- чипы и статусы ---------- */
.chip, .status-badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.688rem; line-height: 1.6; border-radius: 5px; padding: 2px 7px; white-space: nowrap;
  border: 1px solid #3f3f3f; background: var(--row); color: #bbb; font-family: var(--mono); vertical-align: 1px;
}
.chip i, .status-badge i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.chip.ok, .status-active { color: var(--positive-t); background: var(--positive-bg); border-color: var(--positive-line); }
.chip.err, .status-error { color: var(--negative-t); background: var(--negative-bg); border-color: var(--negative-line); }
.chip.warn, .status-running { color: var(--warn-t); background: var(--warn-bg); border-color: var(--warn-line); }
.chip.dim, .status-draft { color: var(--faint); background: #262626; }
.status-paused { background: #303030; color: #bbb; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 5px; }
.badge-note { display: flex; gap: 12px; align-items: baseline; padding: 10px 14px; border-radius: var(--panel-radius); background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-t); font-size: 0.812rem; line-height: 1.5; }
.badge-note b { font-family: var(--mono); font-weight: 500; font-size: 0.719rem; letter-spacing: 0.2px; white-space: nowrap; }
.badge-block { display: grid; gap: 8px; margin-bottom: 16px; }
.warnbox.notes { padding: 12px 16px 6px; }
.warnbox.notes .l { font-family: var(--mono); font-size: 0.688rem; letter-spacing: 0.2px; color: var(--warn-t); opacity: 0.8; margin-bottom: 6px; }
.warnbox.notes .note { display: grid; gap: 3px; padding: 8px 0; border-top: 1px dashed #5b462955; color: #f1dcbc; line-height: 1.45; }
.warnbox.notes .note b { font-family: var(--mono); font-weight: 500; font-size: 0.688rem; letter-spacing: 0.2px; white-space: nowrap; color: var(--warn-t); }
.inner.confirm { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin: 0 0 12px; padding: 10px 12px; }
.inner.confirm .lbl { font-family: var(--mono); font-size: 0.688rem; color: var(--muted); }
.inner.confirm label { display: inline-flex; gap: 7px; align-items: center; font-size: 0.844rem; color: var(--foreground); }
.inner.confirm .btn { margin-left: auto; }

/* ---------- таблицы полосами ---------- */
.table-wrap { overflow-x: auto; }
table.set { width: 100%; border-collapse: separate; border-spacing: 0 6px; font-size: 0.88rem; }
table.set th { font-family: var(--mono); font-size: 0.688rem; color: #a4a4a2; font-weight: 400; text-align: left; padding: 0 10px 2px; }
table.set td { padding: 7px 10px; background: var(--row); vertical-align: middle; line-height: 1.45; }
table.set td:first-child { border-radius: 5px 0 0 5px; }
table.set td:last-child { border-radius: 0 5px 5px 0; }
table.set td.num, table.set th.num { font-family: var(--mono); white-space: nowrap; }
table.set td.acts-cell { width: 1%; white-space: nowrap; text-align: right; padding-left: 12px; }
table.set td.acts-cell .row-actions { justify-content: flex-end; flex-wrap: nowrap; }
table.set a.row-link { text-decoration: none; color: var(--foreground); }
table.set a.row-link:hover { color: var(--primary); }
table.set .hint { font-size: 0.8rem; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row-actions > form { display: inline; }
.row-actions details.action[open] { flex: 1 0 100%; }
.row-actions details.action .card, .row-actions form.card { width: 100%; max-width: 44rem; }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 7px 18px; margin: 0; font-size: 0.9rem; }
dl.kv dt { color: var(--muted); font-family: var(--mono); font-size: 0.78rem; padding-top: 3px; }
dl.kv dd { margin: 0; }
dl.kv ul { margin: 0; padding-left: 16px; }

/* ---------- формы ---------- */
.field { display: grid; gap: var(--label-gap); margin-bottom: 0.75rem; }
.field label, .field .label { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); letter-spacing: 0.15px; }
.field small { color: var(--faint); font-size: 0.82rem; font-family: var(--sans); }
input[type="text"], input[type="url"], input[type="date"], input[type="time"], input[type="number"], input[type="password"], input[type="email"], input[type="file"], select, textarea {
  width: 100%; min-height: 2.15rem; padding: 0.4rem 0.7rem; border-radius: var(--control-radius);
  border: 1px solid #414141; background: #1c1c1c; color: var(--foreground); font-size: 0.9rem;
}
input:focus, select:focus, textarea:focus { border-color: #5a5a5a; }
textarea { min-height: 6rem; resize: vertical; line-height: 1.5; }
input[type="file"] { padding: 6px 8px; }
/* Строка полей — сетка с тремя общими строками: подпись, поле, пояснение.
   subgrid делает полосу подписей одинаковой для всей строки, поэтому поля стоят
   на одной линии, даже когда у одной подписи две строки, а у другой одна, и когда
   у соседа есть пояснение, а у этого поля его нет. */
.inline-fields, .filters { display: grid; grid-template-rows: auto auto auto; align-items: start; }
.inline-fields { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: var(--label-gap) 0.62rem; margin-bottom: 0.88rem; }
.inline-fields > .field, .filters > .field {
  display: grid; grid-row: span 3; grid-template-rows: subgrid; margin: 0; min-width: 0;
}
/* кнопка строки живёт в такой же ячейке с пустой подписью: так она встаёт на линию полей */
.field > .btn { justify-self: start; }
/* длинная подпись на кнопке переносится по словам, иначе кнопка уезжает за край */
.btn.wrap { white-space: normal; text-align: left; }
.warn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.62rem; }
/* поле, которому нужно больше места, занимает две ячейки строки */
.inline-fields > .field.wide, .filters > .field.wide { grid-column: span 2; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; }
.checks label, .radio-row label {
  display: inline-flex; gap: 0.5rem; align-items: start; font-size: 0.9rem;
  color: var(--foreground); font-family: var(--sans); cursor: pointer; line-height: 1.45;
}
.checks label input, .radio-row label input { margin-top: 0.15rem; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }
.filters { grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: var(--label-gap) 0.5rem; margin-bottom: var(--panel-gap); }
.hint { color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
/* подводка абзаца под подзаголовком: было отрицательным отступом в пикселях */
.lede { margin: -0.5rem 0 1rem; max-width: 45rem; }
table.set a svg { width: 1em; height: 1em; vertical-align: -0.12em; }
.who { font-family: var(--mono); font-size: 0.688rem; color: var(--faint); letter-spacing: 0.2px; }
.who.group { margin-bottom: 0.62rem; }
.who.group.later { margin-top: 1.12rem; }
details.action { margin: 0; }
details.action > summary { list-style: none; }
details.action > summary::-webkit-details-marker { display: none; }
details.action[open] > summary { border-color: var(--primary); }
details.action .card { margin-top: 10px; margin-bottom: 0; }

/* ---------- материал ---------- */
.material-text { font-size: 0.98rem; line-height: 1.6; max-width: 70ch; }
.material-text p { margin: 0 0 14px; }
.material-text p:last-child { margin-bottom: 0; }
.material-image { border-radius: var(--panel-radius); overflow: hidden; border: 1px solid var(--border); margin-bottom: var(--panel-gap); background: #111; }
.material-image img { display: block; width: 100%; max-height: 520px; object-fit: contain; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; align-items: flex-start; }
.actions > form { display: inline; }
.actions details.action[open] { flex: 1 0 100%; }
.actions .large { min-width: 200px; }
.actions details.action .card, .actions form.card { width: 100%; max-width: 720px; }
.actions > form.card { flex: 1 0 100%; }

/* ---------- страница материала: один поток чтения ---------- */
.reading { max-width: 62rem; }
/* две колонки, пока хватает места; при крупном тексте сами встают друг под друга */
.material-grid { display: flex; flex-wrap: wrap; gap: var(--panel-gap); align-items: flex-start; }
.material-main { flex: 1 1 26rem; min-width: 0; max-width: 40rem; }
.material-side { flex: 1 1 19rem; min-width: 0; }
.material-side:empty { display: none; }
.material-side .card { margin-bottom: 0; }
.reading h1 { margin-bottom: 16px; }
.reading .post { max-width: none; margin-bottom: var(--panel-gap); }
/* «Перед решением» — свой блок: класс .checks занят строкой галочек и там display: flex */
.pre-decide { margin: 0 0 0.88rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--divider); }
.pre-decide .l { font-family: var(--mono); font-size: 0.76rem; color: var(--muted); letter-spacing: 0.15px; margin-bottom: 0.38rem; }
.checks-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.checks-list li { padding-left: 14px; position: relative; font-size: 0.9rem; line-height: 1.45; color: #dcdcd9; }
.checks-list li::before { content: ""; position: absolute; left: 2px; top: 8px; width: 5px; height: 5px; border-radius: 50%; background: var(--primary); }
.checks-list b { font-weight: 500; color: var(--foreground); }
.checks-list.plain { margin: 0 0 var(--panel-gap); padding: 0 4px; }
/* решение одной формой (как ревью в GitHub): переключатель, поле, одна кнопка */
.decide { padding: 14px 16px 16px; }
.material-side .decide-foot { flex-direction: column; align-items: stretch; }
.material-side .decide-foot .btn { width: 100%; }
.seg { display: flex; flex-wrap: wrap; gap: 1px; border-radius: var(--control-radius); overflow: hidden; border: 1px solid #414141; background: #414141; box-shadow: inset 0 0 5px #ffffff16; margin-bottom: 14px; }
.seg label { position: relative; cursor: pointer; flex: 1 1 auto; background: linear-gradient(120deg, #272727, #171717); }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 2.15rem; padding: 0.4rem 0.9rem; font-size: 0.88rem; white-space: nowrap; color: #dcdcd9; }
.seg label:hover span { background: #303030; }
.seg input:checked + span { background: linear-gradient(#ffb129, #ff9509); color: var(--primary-ink); font-weight: 500; }
.seg input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: -2px; }
.decide .if-approve, .decide .if-revise, .decide .if-reject { display: none; }
.decide:has(input[value="approve"]:checked) .if-approve { display: revert; }
.decide:has(input[value="revise"]:checked) .if-revise { display: revert; }
.decide:has(input[value="reject"]:checked) .if-reject { display: revert; }
.decide .field.if-revise, .decide .field.if-reject { display: none; }
.decide:has(input[value="revise"]:checked) .field.if-revise { display: grid; }
.decide:has(input[value="reject"]:checked) .field.if-reject { display: grid; }
.decide textarea { min-height: 5rem; }
.decide-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.decide-foot .btn { min-width: 160px; }
.more-info { margin-bottom: var(--panel-gap); }
.more-info > summary { cursor: pointer; font-size: 0.9rem; color: var(--muted); padding: 6px 0; list-style: none; display: flex; align-items: center; gap: 8px; }
.more-info > summary::-webkit-details-marker { display: none; }
.more-info > summary::before { content: "›"; display: inline-block; transition: transform 0.15s; color: var(--faint); }
.more-info[open] > summary::before { transform: rotate(90deg); }
.more-info > summary:hover { color: var(--foreground); }
.more-info .card { margin-top: 4px; }
.item .thumb .more { position: absolute; right: 4px; bottom: 4px; font: 500 0.69rem/1 var(--mono); padding: 3px 5px; border-radius: 4px; background: #000c; color: #fff; }

/* ---------- предпросмотр записи ---------- */
.post { max-width: 42rem; border: 1px solid var(--border); border-radius: var(--panel-radius); background: var(--card); padding: 14px 16px 6px; margin-bottom: var(--panel-gap); }
.post-head { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 12px; flex-wrap: wrap; }
.post-head > div { min-width: 0; flex: 1 1 12rem; }
.post-avatar { width: 2.5rem; height: 2.5rem; border-radius: 50%; background: linear-gradient(135deg, #3a3a3a, #262626); border: 1px solid #444; display: inline-flex; align-items: center; justify-content: center; font: 500 0.81rem/1 var(--sans); color: var(--foreground); flex: none; overflow: hidden; }
.post-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-name { font-size: 0.92rem; font-weight: 500; }
.post-when { font-size: 0.8rem; color: var(--muted); font-family: var(--mono); margin-top: 2px; }
.post-text { font-size: 0.98rem; line-height: 1.5; }
.post-text p { margin: 0 0 10px; }
.post-media { margin: 0 0 12px; display: grid; gap: 4px; border-radius: 8px; overflow: hidden; }
.post-media img { display: block; width: 100%; height: 100%; object-fit: cover; background: #111; }
.post-media.n1 img { aspect-ratio: 16 / 10; }
.post-media.n2 img, .post-media.n3 img:not(:first-child), .post-media.n4 img { aspect-ratio: 1; }
.post-media.n2, .post-media.n4 { grid-template-columns: 1fr 1fr; }
.post-media.n3 { grid-template-columns: 1fr 1fr; }
.post-media.n3 img:first-child { grid-column: span 2; aspect-ratio: 16 / 9; }
.post-media.placeholder { aspect-ratio: 16 / 10; border: 1px dashed #444; display: grid; place-items: center; color: var(--faint); font-size: 0.781rem; text-align: center; padding: 16px; }
.item.with-thumb { padding-left: 104px; min-height: 84px; }
.item .thumb { position: absolute; left: 14px; top: 14px; width: 76px; height: 56px; border-radius: 6px; overflow: hidden; border: 1px solid #3a3a3a; background: #111; }
.item .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.move-form { display: inline-flex; gap: 6px; align-items: center; }
.move-form input { width: auto; min-width: 9rem; }
.scale { display: grid; gap: 5px; margin-bottom: 0.9rem; }
.scale label { font-size: 0.8rem; color: var(--muted); }
.scale select { min-height: 2rem; font-size: 0.85rem; padding: 0.25rem 0.5rem; }

/* ---------- прочее ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--divider); margin-bottom: var(--panel-gap); }
.tabs a { padding: 0.5rem 0.8rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 0.9rem; }
.tabs a:hover { color: var(--foreground); }
.tabs a[aria-current="page"] { color: var(--foreground); border-bottom-color: var(--primary); }
.bars { display: flex; align-items: flex-end; gap: 0.38rem; height: 9.4rem; margin-top: 0.38rem; }
.bars > div { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 0.25rem; position: relative; }
.bars .val { font-family: var(--mono); font-size: 0.688rem; color: var(--foreground); line-height: 1; }
.bars .val:empty { display: none; }
.bars .b { width: 100%; min-height: 2px; border-radius: 6px 6px 0 0; background: linear-gradient(#454545, #202020); border: 1px solid #6b6b6b; border-bottom: 0; }
.bars .b.hi { background: linear-gradient(to bottom, #fff7e9 0%, #ff9a25 20%, #ff6900 88%); border: 0; }
.bars span { font-family: var(--mono); font-size: 0.688rem; color: var(--muted); line-height: 1.2; }
pre.report { font-family: var(--mono); font-size: 0.85rem; line-height: 1.55; white-space: pre-wrap; margin: 0; color: #dcdcd9; }
.list-plain { margin: 0; padding-left: 16px; }
.list-plain li { margin-bottom: 3px; }

/* ---------- режим обучения ---------- */
/* затемнение из четырёх прямоугольников: подсвеченный элемент ничем не накрыт */
.tour { position: fixed; inset: 0; z-index: 200; pointer-events: none; }
.tour-mask { position: fixed; background: #000000d4; }
.tour-ring {
  position: fixed; border-radius: var(--panel-radius); pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--primary), 0 0 0 1px #ff970f40;
}
.tour-box {
  position: fixed; width: min(25rem, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow-y: auto;
  pointer-events: auto; z-index: 2;
  background: var(--card); border: 1px solid #4a4a4a; border-radius: var(--panel-radius);
  box-shadow: 0 18px 50px #000b; padding: 0.9rem 1.05rem 1.05rem;
}
.tour-box:focus { outline: none; }
.tour-box.centred { left: 50%; top: 50%; transform: translate(-50%, -50%); }
.tour-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.4rem; }
.tour-count { font-family: var(--mono); font-size: 0.74rem; color: var(--primary); letter-spacing: 0.3px; }
.tour-box h2 { font-size: 1.1rem; font-weight: 500; line-height: 1.3; margin-bottom: 0.45rem; }
.tour-text { font-size: 0.9rem; line-height: 1.55; color: #dcdcd9; }
.tour-foot { display: flex; gap: 0.5rem; margin-top: 0.9rem; }
.tour-foot .btn { flex: 1; }
.tour-keys { margin-top: 0.6rem; font-size: 0.76rem; color: var(--faint); text-align: center; line-height: 1.4; }
@media (max-width: 619px) {
  .tour-box { width: auto; }
  .tour-box.centred { left: 12px; right: 12px; top: auto; bottom: 12px; transform: none; }
  .tour-keys { display: none; }
}

/* ---------- вход ---------- */
.login-stage { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(ellipse at 50% 65%, #363636 0, var(--background) 70%); }
.login-card { width: min(26rem, 100%); border-radius: 15px; box-shadow: 0 36px 70px #0005; padding: 1.75rem; }
.login-card .brand { margin-bottom: 1.38rem; }

/* Содержимое реагирует на ширину рабочей области в rem: то же правило срабатывает
   и на узком экране, и когда читатель увеличил масштаб интерфейса. */
@container main (max-width: 52rem) {
  .post { max-width: none; }
  .seg { width: 100%; }
  .seg label { flex: 1 1 0; }
  dl.kv { grid-template-columns: 1fr; gap: 2px 0; }
  dl.kv dt { margin-top: 8px; }
  .bars { gap: 0.13rem; }
  .bars > div:not(:nth-child(3n + 1)) > span:last-child { display: none; }
  /* таблицы полосами складываются в карточки: одна колонка, крупные кнопки */
  table.set.stack thead { display: none; }
  table.set.stack tr { display: block; margin-bottom: 8px; background: var(--row); border-radius: 5px; padding: 8px 10px; }
  table.set.stack td { display: block; padding: 2px 0; background: transparent; border-radius: 0; }
  table.set.stack td:empty { display: none; }
  table.set.stack td[data-l]::before { content: attr(data-l) ": "; font-family: var(--mono); font-size: 0.688rem; color: var(--muted); }
  table.set.stack td.acts-cell::before { content: none; }
  table.set.stack td { width: auto; white-space: normal; }
  table.set.stack td.acts-cell { text-align: left; padding-top: 8px; }
  table.set.stack td.acts-cell .row-actions { justify-content: flex-start; flex-wrap: wrap; }
  table.set.stack td .rix-button, table.set.stack td .btn { min-height: 2.25rem; }
  .row-actions form, .row-actions .btn, .row-actions .rix-button { max-width: 100%; }
}

/* На телефоне рядом с числом текста не поместится: плитка читается сверху вниз. */
@container main (max-width: 30rem) {
  /* на узкой области длинная подпись кнопки переносится, а не обрезается */
  .btn, .rix-button { white-space: normal; }
  .inline-fields, .filters { grid-template-columns: minmax(0, 1fr); }
  .inline-fields > .field.wide, .filters > .field.wide { grid-column: auto; }
  .stat { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; }
  .stat .l, .stat:not(:has(.d)) .l { grid-column: 1; grid-row: 1; align-self: start; margin-bottom: 0.25rem; }
  .stat .v { grid-column: 1; grid-row: 2; }
  .stat .d { grid-column: 1; grid-row: 3; margin-top: 0.3rem; }
}

/* ---------- телефон и планшет ---------- */
.mobile-top, .mobile-backdrop { display: none; }
@media (max-width: 1400px) { :root { --sidebar-size: 14rem; } }
@media (max-width: 1250px) { :root { --sidebar-size: 13.5rem; } .nav-item { font-size: 0.85rem; gap: 9px; padding: 0.35rem 8px; } .nav-item svg { width: 17px; height: 17px; } .brand { gap: 10px; } .rixai-mark { width: 32px; height: 32px; } .brand-name { font-size: 0.95rem; } .main { padding: 20px; } h1 { font-size: 1.7rem; } }
@media (max-width: 1050px) { .main { padding: 17px; } }
@media (max-width: 900px) {
  .side { display: none; }
  body.nav-open .side { display: flex; position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; width: var(--sidebar-size); flex-basis: var(--sidebar-size); box-shadow: 20px 0 70px #0009; height: 100vh; }
  body.nav-open .mobile-backdrop { display: block; position: fixed; inset: 0; background: #0007; z-index: 49; border: 0; }
  .side-close { display: inline-flex; }
  .main { padding: 16px 14px 28px; }
  .mobile-top { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
  .mobile-top .brand-name { font-size: 1.0rem; }
  .icon-button.mobile-menu { border: 1px solid #414141; background: linear-gradient(120deg, #272727, #171717); width: 36px; height: 36px; border-radius: var(--control-radius); }
  .crumb { display: none; }
  h1 { font-size: 1.625rem; }
  .sub { margin-bottom: 16px; }
  .stats { gap: 10px; }
  .stat { min-height: 5rem; padding: 0.75rem 0.88rem; column-gap: 0.7rem; }
  .stat .v { font-size: 2rem; }
  .card { padding: 12px; }
  .item { padding: 13px; }
  .item.with-thumb { padding-left: 13px; padding-top: 76px; }
  .item .thumb { left: 13px; top: 13px; width: 88px; height: 56px; }
  .post { padding: 12px 12px 8px; }
  .btn, .rix-button { min-height: 36px; }
  .large { min-height: 46px; }
  .actions { display: grid; }
  .decide-foot .btn { width: 100%; }
  .acts .btn { min-height: 36px; }
  .inner.confirm .btn { margin-left: 0; width: 100%; }
  .actions .rix-button, .actions .btn { width: 100%; }
  .actions details.action .card, .actions form.card { max-width: none; }
}
@media (min-width: 901px) { .mobile-top { display: none; } body.nav-open .mobile-backdrop { display: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
