/* Админ-панель VK-бота.
   Спокойный светлый интерфейс для ежедневной работы: нейтрали с лёгким холодным оттенком,
   один акцентный синий для действий и выбранного, смысловые цвета только для статусов. */

:root {
  /* нейтрали */
  --bg: oklch(0.972 0.004 255);
  --surface: oklch(1 0 0);
  --surface-sunken: oklch(0.982 0.003 255);
  --sidebar: oklch(0.955 0.007 255);
  --line: oklch(0.905 0.007 255);
  --line-strong: oklch(0.84 0.01 255);
  --ink: oklch(0.25 0.02 255);
  --ink-2: oklch(0.45 0.02 255);
  --ink-3: oklch(0.56 0.015 255);

  /* акцент */
  --accent: oklch(0.53 0.155 257);
  --accent-hover: oklch(0.47 0.155 257);
  --accent-soft: oklch(0.955 0.025 257);
  --accent-ink: oklch(0.42 0.14 257);
  --focus: oklch(0.62 0.16 257 / 0.45);

  /* статусы */
  --ok: oklch(0.47 0.11 152);
  --ok-soft: oklch(0.955 0.04 152);
  --err: oklch(0.5 0.17 27);
  --err-soft: oklch(0.96 0.025 27);
  --err-line: oklch(0.85 0.07 27);
  --warn: oklch(0.5 0.1 70);
  --warn-soft: oklch(0.965 0.05 85);

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px oklch(0.25 0.02 255 / 0.05), 0 1px 1px oklch(0.25 0.02 255 / 0.03);
  --sidebar-w: 236px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* слои */
  --z-sticky: 10;
  --z-scrim: 40;
  --z-drawer: 50;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3 { text-wrap: balance; color: var(--ink); }
h1 { font-size: 24px; line-height: 1.25; font-weight: 650; margin: 0 0 20px; letter-spacing: -0.01em; }
h2 { font-size: 17px; line-height: 1.3; font-weight: 620; margin: 32px 0 12px; }
h3 { font-size: 15px; line-height: 1.35; font-weight: 620; margin: 20px 0 10px; }
h1 + h2, .panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
p { margin: 0 0 12px; max-width: 75ch; text-wrap: pretty; }

.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.neg { color: var(--err); }
.pos { color: var(--ok); }

/* ---------- каркас ---------- */

.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 16px 12px 12px;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 16px; font-weight: 650; font-size: 15px; color: var(--ink);
}
.brand:hover { color: var(--ink); text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 700;
}
.nav { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-title { font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 0 10px 4px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 500;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.nav-link:hover { background: oklch(0.925 0.01 255); color: var(--ink); text-decoration: none; }
.nav-link.active { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow); font-weight: 600; }
.nav-link.active .icon { color: var(--accent); }

.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

.sidebar-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 16px; padding: 10px 6px 0 8px; border-top: 1px solid var(--line);
}
.who { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; font-weight: 700;
}
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--ink-2);
}
.icon-btn:hover { background: oklch(0.925 0.01 255); color: var(--ink); border-color: transparent; }

.main { min-width: 0; }
.content { max-width: 1320px; margin: 0 auto; padding: 28px 32px 48px; }
.mobilebar { display: none; }
.scrim { display: none; }

/* вход без меню */
body.bare .content { max-width: 440px; padding-top: 12vh; }

/* ---------- поверхности ---------- */

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-bottom: 20px; }
.grid > .panel { margin-bottom: 0; }

/* показатели: плотная полоса, а не россыпь карточек */
.cards {
  display: flex; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden;
}
.card {
  flex: 1 1 210px; padding: 16px 20px;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0;
}
.card .label { color: var(--ink-2); font-size: 13px; font-weight: 500; }
.card .value { font-size: 26px; line-height: 1.2; font-weight: 650; margin-top: 6px; letter-spacing: -0.01em; }
.card .sub { color: var(--ink-2); font-size: 12.5px; margin-top: 4px; }

/* ---------- таблицы ---------- */

.table-wrap {
  overflow-x: auto; margin-bottom: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
.table-wrap table { border: 0; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th {
  background: var(--surface-sunken); font-weight: 600; font-size: 12.5px; color: var(--ink-2);
  white-space: nowrap;
}
tbody tr { transition: background-color 120ms var(--ease); }
tbody tr:hover { background: oklch(0.985 0.006 257); }
tbody tr:last-child td { border-bottom: none; }
tfoot th { position: static; border-top: 1px solid var(--line-strong); border-bottom: none; color: var(--ink); font-size: 13px; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
td > input[type=text], td > input[type=number] { width: 100%; min-width: 80px; }
td.num > input { text-align: right; }

/* ---------- статусы ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 550; line-height: 1.5; white-space: nowrap;
  background: oklch(0.94 0.006 255); color: var(--ink-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--accent-soft); color: var(--accent-ink); }

.flash {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px;
  border: 1px solid transparent; font-weight: 500;
}
.flash-ok { background: var(--ok-soft); color: var(--ok); border-color: oklch(0.87 0.06 152); }
.flash-error { background: var(--err-soft); color: var(--err); border-color: var(--err-line); }

/* ---------- формы ---------- */

form.inline { display: inline; }
form.filters {
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin-bottom: 16px;
}
form.filters label, .form-grid label, .field label {
  display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; color: var(--ink-2);
}
.form-grid { display: grid; gap: 14px 20px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 14px; }
.field { margin-bottom: 14px; }
.field.wide { grid-column: 1 / -1; }
.hint { display: block; font-size: 12px; font-weight: 400; color: var(--ink-2); margin-top: -2px; }
.form-grid > label { justify-content: flex-end; }
.field-check { display: flex; flex-direction: column; justify-content: center; gap: 2px; min-height: 60px; }
.savebar {
  position: sticky; bottom: 0; z-index: var(--z-sticky);
  display: flex; justify-content: flex-end; gap: 10px;
  margin: 0 -32px 20px; padding: 12px 32px;
  background: oklch(0.972 0.004 255 / 0.92); backdrop-filter: blur(6px); border-top: 1px solid var(--line);
}
.check { display: flex; flex-direction: row !important; align-items: center; gap: 8px; color: var(--ink) !important; font-size: 14px !important; font-weight: 400 !important; }

input[type=text], input[type=number], input[type=password], input[type=date], input[type=email], input[type=datetime-local], select, textarea {
  height: 36px; padding: 6px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font: inherit; color: var(--ink); background: var(--surface); min-width: 0;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:hover, select:hover, textarea:hover { border-color: oklch(0.76 0.015 255); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
input.narrow { width: 100px; }
textarea { height: auto; min-height: 84px; resize: vertical; width: 100%; line-height: 1.5; }
textarea.tall { min-height: 160px; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  background: var(--accent); color: #fff;
  font: inherit; font-weight: 600; line-height: 1; cursor: pointer; white-space: nowrap;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease);
}
button:hover, .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary, .btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
button.secondary:hover, .btn.secondary:hover { background: var(--surface-sunken); border-color: oklch(0.76 0.015 255); color: var(--ink); }
button.danger, .btn.danger { background: var(--surface); color: var(--err); border-color: var(--err-line); }
button.danger:hover, .btn.danger:hover { background: var(--err-soft); color: var(--err); border-color: var(--err); }
button.link { height: auto; padding: 0; border: none; background: none; color: var(--accent-ink); font-weight: 500; }
button.link:hover { background: none; color: var(--accent-hover); text-decoration: underline; }
button.sm, .btn.sm { height: 30px; padding: 0 11px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- навигация внутри страниц ---------- */

.pager { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin: 4px 0 20px; }
.pager a, .pager span {
  min-width: 32px; height: 32px; padding: 0 10px; display: inline-grid; place-items: center;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.pager a:hover { border-color: var(--line-strong); text-decoration: none; }
.pager span.current { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.pager span.muted { border: none; background: none; color: var(--ink-2); }

.tabs {
  display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; margin-bottom: 18px;
  background: oklch(0.935 0.008 255); border-radius: var(--radius);
}
.tabs a { padding: 6px 14px; border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 500; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }

/* ---------- прочее ---------- */

pre {
  background: var(--surface-sunken); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; overflow-x: auto; font-size: 12.5px; white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
.prompt { white-space: pre-wrap; word-break: break-word; max-width: 60ch; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
dl.kv dt { color: var(--ink-2); }
dl.kv dd { margin: 0; word-break: break-word; }
img.thumb { max-width: 320px; max-height: 320px; border-radius: var(--radius-sm); border: 1px solid var(--line); }

.login-box { padding: 28px 28px 24px; }
.login-box h1 { font-size: 20px; margin-bottom: 18px; }
.login-box .field input { width: 100%; }
.login-box button { width: 100%; margin-top: 4px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; margin-bottom: 20px; color: var(--ink-2); }

/* ---------- цены ---------- */

.page-lead { color: var(--ink-2); margin: -8px 0 20px; }
.model-block { padding: 0; overflow: hidden; }
.model-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.model-head h3 { margin: 0; }
.model-block .table-wrap { margin: 0; border: 0; border-radius: 0; box-shadow: none; }
.price-table { table-layout: fixed; min-width: 990px; }
.price-table col.c-name { width: 180px; }
.price-table col.c-in { width: 120px; }
.price-table col.c-fact { width: 145px; }
.price-table col.c-pct { width: 96px; }
.price-table col.c-money { width: 135px; }
.price-table col.c-on { width: 82px; }
.price-table col.c-act { width: 124px; }
.price-table td > input[type=text], .price-table td > input[type=number] { min-width: 0; }
.preset-title { font-weight: 500; }
.low { color: var(--warn); font-weight: 600; }
.cost-fact { font-weight: 600; }
.cost-fact.over { color: var(--warn); }
.cost-note { display: block; font-size: 12px; color: var(--ink-2); font-weight: 400; }
.legend { display: grid; gap: 6px 24px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); font-size: 13px; color: var(--ink-2); }
.legend b { color: var(--ink); font-weight: 600; }

/* ---------- узкие экраны ---------- */

@media (max-width: 960px) {
  .shell { display: block; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(280px, 86vw); z-index: var(--z-drawer);
    transform: translateX(-100%); visibility: hidden;
    transition: transform 220ms var(--ease), visibility 0s linear 220ms;
  }
  body.nav-open .sidebar {
    transform: none; visibility: visible; transition: transform 220ms var(--ease);
    box-shadow: 0 10px 40px oklch(0.2 0.02 255 / 0.18);
  }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: var(--z-scrim);
    background: oklch(0.2 0.02 255 / 0.35); opacity: 0; pointer-events: none; transition: opacity 220ms var(--ease);
  }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .mobilebar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: var(--z-sticky);
    padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .mobilebar-title { font-weight: 600; }
  .content { padding: 20px 16px 40px; }
  .savebar { margin: 0 -16px 20px; padding: 12px 16px; }
}
@media (max-width: 640px) {
  h1 { font-size: 21px; }
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dd { margin-bottom: 8px; }
  .card .value { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; }
}
