/* Админка Мии, вариант A «Пульт»: тёплый фон, цветные плитки, крупные кнопки. */
:root {
  --bg: #FBF6F1; --ink: #1F1A17; --muted: #6B625C; --line: #EADFD4; --card: #FFFFFF; --soft: #F4E3D6;
  --peach: #F4B69C; --amber: #F2C879; --matcha: #CFDDBE; --chrome: #DCDFE3; --accent: #E9A23B;
  --danger: #8E2F1D; --ok-bg: #E3EBD9; --ok-ink: #33461F; --err-bg: #F6D9CF; --warn-bg: #F7E3B5;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17140F; --ink: #F3ECE4; --muted: #B5AAA0; --line: #3A322B; --card: #211C17; --soft: #2D251E;
    --peach: #7A4A36; --amber: #7A5A1E; --matcha: #3E4C32; --chrome: #3A3E44; --accent: #F2B042;
    --danger: #F0A88A; --ok-bg: #2A3522; --ok-ink: #CFE3BC; --err-bg: #4A2419; --warn-bg: #4A3A16;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17140F; --ink: #F3ECE4; --muted: #B5AAA0; --line: #3A322B; --card: #211C17; --soft: #2D251E;
  --peach: #7A4A36; --amber: #7A5A1E; --matcha: #3E4C32; --chrome: #3A3E44; --accent: #F2B042;
  --danger: #F0A88A; --ok-bg: #2A3522; --ok-ink: #CFE3BC; --err-bg: #4A2419; --warn-bg: #4A3A16;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, system-ui, sans-serif; }
a { color: inherit; }
h1 { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; margin: 0 0 20px; }
h2 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 12px; }
h3 { font-size: 16px; font-weight: 700; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* каркас */
.shell { display: flex; min-height: 100vh; }
.side { width: 232px; flex: none; padding: 24px 16px; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side a { display: flex; align-items: center; justify-content: space-between; min-height: 44px;
  border-radius: 12px; padding: 0 12px; text-decoration: none; color: var(--ink); }
.side a:hover { background: var(--soft); }
.side a.on { background: var(--soft); font-weight: 600; }
.side .logo { gap: 10px; justify-content: flex-start; font-weight: 800; font-size: 18px; margin-bottom: 14px; }
.side .logo:hover { background: none; }
.side-foot { margin-top: auto; padding-top: 16px; }
.logo-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--peach); color: #1F1A17; font-weight: 800; }
.logo-mark.big { width: 56px; height: 56px; font-size: 24px; margin-bottom: 14px; }
.count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent);
  color: #1F1A17; font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.theme { min-height: 44px; width: 100%; border-radius: 12px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.main { flex: 1; min-width: 0; padding: 28px 36px 96px; max-width: 1200px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.head h1 { margin: 0; }

/* плитки и карточки */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.tile { border-radius: 20px; padding: 18px 20px; color: #1F1A17; text-decoration: none; display: block; }
.tile .label { font-size: 13px; font-weight: 600; opacity: .8; }
.tile .big { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin-top: 6px; }
.tile .note { font-size: 13px; margin-top: 4px; opacity: .8; }
.peach { background: var(--peach); } .amber { background: var(--amber); }
.matcha { background: var(--matcha); } .chrome { background: var(--chrome); }
:root[data-theme="dark"] .tile { color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tile { color: var(--ink); } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 18px 20px; margin-bottom: 20px; }
.card > :last-child { margin-bottom: 0; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; padding-top: 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.spread { justify-content: space-between; }

/* кнопки и формы */
.btn { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; gap: 6px; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--accent); border-color: transparent; color: #1F1A17; }
.btn.dark { background: var(--ink); border-color: transparent; color: var(--bg); }
.btn.danger { color: var(--danger); background: transparent; border-color: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.wide { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions form { margin: 0; }
form.stack { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
label .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
input, select, textarea { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit; padding: 8px 12px; width: 100%; }
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input[type=checkbox] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--accent); }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.field-error { color: var(--danger); font-size: 13px; font-weight: 600; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* текст, моно, плашки */
.text { white-space: pre-wrap; font-size: 16px; line-height: 1.55; overflow-wrap: anywhere; }
pre.mono, .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; }
pre.mono { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 8px; background: var(--soft); font-size: 12px;
  font-weight: 600; white-space: nowrap; }
.badge.peach { background: var(--peach); color: #1F1A17; } .badge.amber { background: var(--amber); color: #1F1A17; }
.badge.matcha { background: var(--matcha); color: #1F1A17; }
.flash { border-radius: 14px; padding: 12px 16px; margin-bottom: 16px; font-weight: 600; }
.flash.ok { background: var(--ok-bg); color: var(--ok-ink); }
.flash.err { background: var(--err-bg); color: var(--danger); }
.flash.warn { background: var(--warn-bg); }
details > summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tabs a { min-height: 40px; padding: 0 14px; border-radius: 12px; display: inline-flex; align-items: center;
  text-decoration: none; border: 1px solid var(--line); }
.tabs a.on { background: var(--ink); color: var(--bg); border-color: transparent; }

/* таблицы */
.scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.dense td, table.dense th { padding: 3px 8px; }

/* графики */
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--soft); } .chart .bar.hi { fill: var(--accent); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 3; }
.chart text { fill: var(--muted); font: 11px Inter, system-ui, sans-serif; }

/* вход */
.login { max-width: 420px; margin: 12vh auto 0; text-align: center; }

/* нижняя панель телефона */
.tabbar { display: none; }
@media (max-width: 760px) {
  .side { display: none; }
  .main { padding: 16px 14px 96px; }
  h1 { font-size: 26px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tile .big { font-size: 28px; }
  .grid2 { grid-template-columns: 1fr; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--card); border-top: 1px solid var(--line); padding: 6px 6px calc(10px + env(safe-area-inset-bottom)); z-index: 10; }
  .tabbar a { min-height: 48px; display: grid; place-items: center; text-decoration: none; font-size: 12px;
    font-weight: 600; border-radius: 12px; color: var(--muted); text-align: center; }
  .tabbar a.on { color: var(--ink); background: var(--soft); }
  .tabbar .count { min-width: 18px; height: 18px; font-size: 11px; }
}

/* черновики и разделы */
.draft { display: grid; gap: 12px; }
.draft .text { margin: 0; }
.draft-img { max-width: 320px; width: 100%; border-radius: 14px; display: block; }
.draft details { border-top: 1px solid var(--line); padding-top: 10px; }
.draft details[open] > summary { margin-bottom: 8px; }
.attention { border-color: var(--accent); }
.more { display: grid; gap: 10px; }
.more .btn { justify-content: flex-start; }

/* агент и ход мысли */
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mode p { margin: 6px 0 0; }
form.row { align-items: flex-end; margin-top: 12px; flex-wrap: nowrap; }
.grow { flex: 1; }
.run-meta { margin-bottom: 20px; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: grid; gap: 10px; }
.step { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; }
.step.tool, .step.system, .step.user { background: transparent; }
.step .who { font-weight: 700; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.step .thought { color: var(--muted); font-size: 14px; border-left: 3px solid var(--amber); padding-left: 10px; margin-bottom: 8px; }
.step .call { margin-top: 8px; }
.step .call pre { background: var(--soft); border-radius: 10px; padding: 8px 10px; margin-top: 6px; }
.step details pre { max-height: 420px; overflow: auto; margin-top: 8px; }
@media (max-width: 760px) { .modes { grid-template-columns: 1fr; } }

/* логи */
.log-filter { align-items: flex-end; flex-wrap: wrap; margin-bottom: 8px; }
.log-filter label:first-child { width: 160px; }
table.log td { font-size: 12px; }
.nowrap { white-space: nowrap; }
.lv-warning .lvl { color: var(--accent); font-weight: 700; }
.lv-error .lvl, .lv-critical .lvl { color: var(--danger); font-weight: 700; }

/* настройки */
.settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; align-items: start; }
.steps-plain { padding-left: 20px; }
.steps-plain li { margin-bottom: 6px; }
@media (max-width: 1000px) { .settings { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  table.log, table.log tbody, table.log tr, table.log td { display: block; }
  table.log tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.log td { border: 0; padding: 1px 0; display: inline-block; margin-right: 8px; }
  table.log td:last-child { display: block; margin: 4px 0 0; }
  .log-filter label:first-child { width: auto; flex: 1 1 120px; }
}
