/* «Отклик» — единая дизайн-система портала.
   Направление: тёплый корпоративный (Stripe-класс), светлая тема.
   Палитра в OKLCH: тёплая нейтраль + один сдержанный акцент, семантика
   только для статусов. Тёмной темы нет (рабочий кабинет, дневной свет). */

/* ======================================================================
   Шрифт: Golos Text (self-hosted, OFL). Переменный wght 400–900,
   один файл на subset — покрывает все нужные веса. font-display: swap.
   Портал за CSP default-src 'self' — только локальные woff2.
   ====================================================================== */

@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/static/fonts/golos-text-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/static/fonts/golos-text-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F,
    U+FE2E-FE2F;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/static/fonts/golos-text-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/static/fonts/golos-text-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF,
    U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ======================================================================
   Токены
   ====================================================================== */

:root {
  /* --- Тёплая нейтраль (hue ~78, амбра-песок, низкая насыщенность) --- */
  --bg:            oklch(0.984 0.005 78);
  --surface:       oklch(0.999 0.001 78);
  --surface-sunk:  oklch(0.970 0.006 78);
  --border:        oklch(0.912 0.008 78);
  --border-strong: oklch(0.858 0.011 78);
  --row-divider:   oklch(0.940 0.006 78);
  --row-hover:     oklch(0.974 0.005 78);
  --text:          oklch(0.285 0.013 74);
  --text-2:        oklch(0.508 0.014 74);
  --text-3:        oklch(0.610 0.012 74);

  /* --- Один сдержанный акцент (спокойный синий, доверие) --- */
  --accent:        oklch(0.505 0.114 256);
  --accent-hover:  oklch(0.445 0.116 258);
  --accent-weak:   oklch(0.955 0.021 256);
  --accent-weak-bd:oklch(0.905 0.036 256);
  --accent-text:   oklch(0.430 0.104 258);
  --on-accent:     oklch(0.995 0.004 256);

  /* --- Семантика статусов --- */
  --success:       oklch(0.520 0.104 156);
  --success-weak:  oklch(0.958 0.031 158);
  --success-bd:    oklch(0.885 0.050 158);
  --danger:        oklch(0.528 0.166 27);
  --danger-hover:  oklch(0.470 0.168 27);
  --danger-weak:   oklch(0.957 0.034 30);
  --danger-bd:     oklch(0.885 0.055 30);
  --warn:          oklch(0.610 0.114 66);

  /* --- Роли и зоны (тинты, отличимые от статусов) --- */
  --role-owner-bg:   var(--accent-weak);
  --role-owner-fg:   var(--accent-text);
  --role-analyst-bg: oklch(0.957 0.030 300);
  --role-analyst-fg: oklch(0.455 0.120 300);
  --role-viewer-bg:  oklch(0.945 0.006 78);
  --role-viewer-fg:  var(--text-2);
  --scope-bg:        oklch(0.955 0.031 195);
  --scope-fg:        oklch(0.430 0.070 210);

  /* --- Радиусы --- */
  --r-sm: 6px;
  --r-md: 9px;
  --r-lg: 13px;
  --r-pill: 999px;

  /* --- Тени (тёплый тон, низкая интенсивность) --- */
  --shadow-sm:   0 1px 1px rgba(41, 37, 30, 0.04), 0 1px 2px rgba(41, 37, 30, 0.05);
  --shadow-card: 0 1px 2px rgba(41, 37, 30, 0.04), 0 6px 16px -8px rgba(41, 37, 30, 0.10);
  --shadow-pop:  0 12px 34px -10px rgba(41, 37, 30, 0.22), 0 2px 6px rgba(41, 37, 30, 0.08);

  /* --- Шаг сетки 4pt --- */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px; --s5: 20px;
  --s6: 24px; --s7: 32px; --s8: 40px; --s9: 48px; --s10: 64px;

  /* --- Типографика (база 15px, контраст ступеней ≥1.25) --- */
  --font-sans: "Golos Text", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 12px; --fs-sm: 13px; --fs-base: 15px; --fs-md: 16px;
  --fs-lg: 19px; --fs-xl: 23px; --fs-2xl: 28px;

  /* --- Движение (ease-out, без bounce; только transform/opacity) --- */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur: 150ms;
  --dur-2: 220ms;

  --sidebar-w: 250px;

  color-scheme: light;
  accent-color: var(--accent);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.55;
  font-feature-settings: "ss01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { color: var(--text); letter-spacing: -0.011em; }
h1 { font-size: var(--fs-xl); font-weight: 600; line-height: 1.25; margin: 0 0 var(--s2); }
h2 { font-size: var(--fs-md); font-weight: 600; line-height: 1.3; margin: var(--s7) 0 var(--s3); }
h3 { font-size: var(--fs-base); font-weight: 600; margin: var(--s5) 0 var(--s2); }
p  { margin: 0 0 var(--s3); }
a  { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }

.meta { color: var(--text-2); }
.hint {
  font-size: var(--fs-sm);
  color: var(--text-3);
  margin: var(--s2) 0 0;
  max-width: 62ch;
}
.num, .dt { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.mono { font-family: var(--font-mono); font-size: var(--fs-sm); }

/* Общий focus-visible: спокойное кольцо акцента. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* Ссылка «пропустить к содержимому» для клавиатуры. */
.skip-link {
  position: absolute;
  left: var(--s3);
  top: -3rem;
  z-index: 200;
  padding: var(--s2) var(--s4);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: var(--s3); text-decoration: none; }

/* ======================================================================
   Каркас: sidebar-shell
   ====================================================================== */

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

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--s5) var(--s4) var(--s4);
}

.sidebar__brand {
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-lg);
  font-weight: 650;
  color: var(--text);
  padding: var(--s1) var(--s3) var(--s5);
  letter-spacing: -0.02em;
}
.sidebar__brand a { color: inherit; }
.sidebar__brand a:hover { color: inherit; text-decoration: none; }
.brand-dot { color: var(--accent); }

/* Бренд текущего тенанта под маркой «Отклик.»: логотип на белой плашке
   (логотип «Да!» — белый текст на зелёном, плашка отделяет его от sidebar).
   Фолбэк без файла логотипа — имя тенанта текстом. Виден и в мобильном drawer
   (та же разметка sidebar). */
.sidebar__tenant {
  display: flex;
  align-items: center;
  margin: 0 var(--s3) var(--s5);
  padding: var(--s2) var(--s3);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.sidebar__tenant-logo {
  display: block;
  height: 30px;
  width: auto;
  max-width: 100%;
}
.sidebar__tenant-name {
  font-size: var(--fs-sm);
  font-weight: 650;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }

.nav-group-label {
  margin: var(--s5) var(--s3) var(--s2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 550;
  line-height: 1.35;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-link:hover { background: var(--row-hover); color: var(--text); text-decoration: none; }
.nav-link.active {
  background: var(--accent-weak);
  color: var(--accent-text);
  font-weight: 600;
}
.nav-link .nav-ico { flex: none; width: 18px; height: 18px; color: currentColor; opacity: 0.9; }
.nav-link.active .nav-ico { opacity: 1; }

.sidebar__footer {
  margin-top: auto;
  padding-top: var(--s4);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.footer-tenant { font-size: var(--fs-xs); color: var(--text-3); }
.footer-id { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.footer-name {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar__footer form { margin-top: var(--s1); }
.sidebar__footer .btn { width: 100%; }

.content { min-width: 0; display: flex; flex-direction: column; }
main {
  width: min(100% - 2 * var(--s7), 74rem);
  margin-inline: auto;
  padding: var(--s7) 0 var(--s10);
  flex: 1;
}

/* ----------------------------------------------------------------------
   Flush-режим: дашборд во фрейме занимает всю контентную область без полей.
   Оболочка фиксируется по высоте вьюпорта, iframe скроллится внутри себя —
   у body нет ни вертикального, ни горизонтального второго скролла.
   ---------------------------------------------------------------------- */
.shell--flush { height: 100vh; height: 100dvh; min-height: 0; }
.shell--flush .content { min-height: 0; overflow: hidden; }
main.main--flush {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: 0;
  overflow: hidden;
}
.dashboard-frame {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg);
}

/* Верхняя шапка — только мобайл (drawer-триггер). */
.topbar { display: none; }

/* Логин: узкая колонка по центру, без каркаса. */
main.auth-main {
  width: min(100% - 2 * var(--s4), 25.5rem);
  margin: 12vh auto 3rem;
  padding: 0;
}

/* ======================================================================
   Карточки, пустые состояния
   ====================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s6);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: var(--s5); }
.card > *:first-child { margin-top: 0; }
.card > *:last-child { margin-bottom: 0; }

.page-head { margin-bottom: var(--s5); }
.page-head .meta { margin-top: calc(-1 * var(--s1)); }

.auth-card { padding: var(--s8) var(--s7); box-shadow: var(--shadow-card); }
.auth-brand {
  font-size: var(--fs-2xl);
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-bottom: var(--s2);
}

.empty {
  margin-top: var(--s5);
  padding: var(--s8) var(--s6);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface-sunk);
  text-align: center;
}
.empty h2 { margin-top: 0; }
.empty .meta { max-width: 46ch; margin-inline: auto; }

/* ======================================================================
   Кнопки
   ====================================================================== */

button, .btn { font: inherit; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 0.55rem 0.95rem;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.2;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(0.5px); }

.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--row-hover); border-color: var(--text-3); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--row-hover); color: var(--text); }

.btn-danger { background: var(--danger); color: var(--on-accent); }
.btn-danger:hover { background: var(--danger-hover); color: var(--on-accent); }

.btn-ghost-danger { background: transparent; color: var(--danger); }
.btn-ghost-danger:hover { background: var(--danger-weak); color: var(--danger-hover); }

.btn-sm { padding: 0.32rem 0.6rem; font-size: var(--fs-xs); border-radius: var(--r-sm); }

.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* ======================================================================
   Формы
   ====================================================================== */

form { margin: 0; }
label {
  display: block;
  margin-top: var(--s4);
  margin-bottom: var(--s1);
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--text);
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select, textarea {
  display: block;
  width: 100%;
  max-width: 28rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font: inherit;
  font-size: var(--fs-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
input::placeholder { color: var(--text-3); }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):hover,
select:hover { border-color: var(--text-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23787066' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
}
select:disabled { background-color: var(--surface-sunk); color: var(--text-3); cursor: not-allowed; }

input[type="file"] {
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--text-2);
  max-width: 28rem;
}
input[type="file"]::file-selector-button {
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  margin-right: var(--s3);
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
input[type="file"]::file-selector-button:hover { background: var(--row-hover); }

.form-actions {
  margin-top: var(--s6);
  display: flex;
  gap: var(--s3);
  align-items: center;
  flex-wrap: wrap;
}

.inline-form { display: inline-flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.inline-form label { margin: 0; }
.inline-form select { margin: 0; width: auto; }

/* ======================================================================
   Таблицы
   ====================================================================== */

.table-wrap { width: 100%; overflow-x: auto; margin-top: var(--s3); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl td {
  padding: 0.7rem var(--s3);
  border-bottom: 1px solid var(--row-divider);
  vertical-align: middle;
}
.tbl tbody tr { transition: background var(--dur) var(--ease); }
.tbl tbody tr:hover { background: var(--row-hover); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl .dt { white-space: nowrap; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tbl td form { display: inline; margin: 0; }
.tbl td form.inline-form { display: inline-flex; }

/* ======================================================================
   Бейджи и статусы
   Классы самодостаточны: JS страницы задачи переписывает className
   целиком ("status-" + status).
   ====================================================================== */

.badge,
.status-queued, .status-running, .status-done, .status-failed,
.st-on, .st-off {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.14rem 0.55rem;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid transparent;
}
/* Точка-маркер статуса — намеренная деталь, не «полоска». */
.status-queued::before, .status-running::before,
.status-done::before, .status-failed::before,
.st-on::before, .st-off::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.status-done, .st-on { background: var(--success-weak); color: var(--success); border-color: var(--success-bd); }
.status-failed { background: var(--danger-weak); color: var(--danger); border-color: var(--danger-bd); }
.status-running { background: var(--accent-weak); color: var(--accent-text); border-color: var(--accent-weak-bd); }
.status-queued, .st-off { background: var(--role-viewer-bg); color: var(--text-2); border-color: var(--border); }
.status-running::before { animation: pulse-dot 1.4s var(--ease) infinite; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.badge-role-owner { background: var(--role-owner-bg); color: var(--role-owner-fg); }
.badge-role-analyst { background: var(--role-analyst-bg); color: var(--role-analyst-fg); }
.badge-role-viewer { background: var(--role-viewer-bg); color: var(--role-viewer-fg); }
.badge-scope { background: var(--scope-bg); color: var(--scope-fg); }

/* ======================================================================
   Зоны доступа (админка)
   ====================================================================== */

.scope-cell { min-width: 17rem; }
.tbl td form.scope-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: center;
  margin-top: var(--s2);
}
.scope-form select, .scope-form input {
  margin: 0;
  width: auto;
  max-width: 13rem;
  font-size: var(--fs-sm);
}
.scope-form input[name="scope_stores"] { max-width: 9rem; }

/* ======================================================================
   Сообщения (алерты) — заливка + рамка целиком, без боковых полосок
   ====================================================================== */

.error, .notice {
  padding: 0.7rem 0.9rem;
  border-radius: var(--r-md);
  margin-bottom: var(--s4);
  font-size: var(--fs-sm);
  display: flex;
  gap: var(--s2);
  align-items: flex-start;
}
.error {
  background: var(--danger-weak);
  border: 1px solid var(--danger-bd);
  color: var(--danger);
}
.notice {
  background: var(--success-weak);
  border: 1px solid var(--success-bd);
  color: var(--success);
}
.error::before, .notice::before {
  font-weight: 700;
  flex: none;
  line-height: 1.5;
}
.error::before { content: "!"; }
.notice::before { content: "\2713"; }

/* ======================================================================
   Строка фактов
   ====================================================================== */

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3) var(--s6);
  margin: var(--s4) 0 0;
  padding: var(--s4) var(--s5);
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.fact { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fact-label { font-size: var(--fs-xs); color: var(--text-3); }
.fact-value {
  font-size: var(--fs-lg);
  font-weight: 650;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.fact-value .unit { font-size: var(--fs-sm); font-weight: 500; color: var(--text-3); }
/* Компактная строка фактов (внутри блоков пересчёта) — в одну линию. */
.facts-inline {
  display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5);
  margin: 0; padding: 0; background: none; border: none;
}
.facts-inline span { color: var(--text-2); font-size: var(--fs-sm); }
.facts-inline strong { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }

/* KPI-обзор главной (спокойная сетка, не hero) */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--s4);
  margin: var(--s5) 0 0;
}
.kpi {
  padding: var(--s4) var(--s5);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
.kpi-label { font-size: var(--fs-xs); color: var(--text-3); margin-bottom: var(--s1); }
.kpi-value {
  font-size: var(--fs-2xl);
  font-weight: 650;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.kpi-value.muted { color: var(--text-3); }

/* ======================================================================
   Выгрузки: dropzone
   ====================================================================== */

.upload-form {
  margin-top: var(--s4);
  padding: var(--s5);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface-sunk);
}
.upload-form .row { display: flex; flex-wrap: wrap; gap: var(--s5); align-items: flex-end; }
.upload-form .field { display: flex; flex-direction: column; }
.upload-form label { margin-top: 0; }
.upload-form .kinds { display: flex; flex-direction: column; gap: var(--s2); }
.upload-form .kinds > span { font-size: var(--fs-sm); font-weight: 600; }
.radio-line {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-weight: 400;
  font-size: var(--fs-sm);
  color: var(--text);
  cursor: pointer;
}
.upload-form .kinds input[type="radio"] { width: auto; margin: 0; cursor: pointer; }

/* Drag-and-drop как progressive enhancement (FB-04). Без JS (класс
   dropzone--enhanced не добавлен) виден только нативный input и работает
   как раньше; подсказка «перетащите» и рамка появляются лишь с JS. */
.dropzone-area { display: flex; flex-direction: column; gap: var(--s2); }
.dropzone-hint { display: none; }
.dropzone-filename {
  margin: var(--s2) 0 0;
  min-height: 1.2em;
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.dropzone--enhanced .dropzone-area {
  padding: var(--s4);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone--enhanced .dropzone-hint {
  display: block;
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.dropzone--enhanced .dropzone-area.is-dragover {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-weak);
}

.rebuild {
  margin-top: var(--s6);
  padding-top: var(--s6);
  border-top: 1px solid var(--border);
}
.rebuild-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s5);
  align-items: center;
  justify-content: space-between;
}
.rebuild-grid .facts-inline { flex-direction: column; gap: var(--s1); align-items: flex-start; }

/* ======================================================================
   Настройки: получатели
   ====================================================================== */

.settings-section + .settings-section {
  margin-top: var(--s7);
  padding-top: var(--s6);
  border-top: 1px solid var(--border);
}
.settings-section h2 { margin-top: 0; }
.key-line { color: var(--text-2); font-size: var(--fs-sm); margin-bottom: var(--s2); }
.key-line .mono {
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.1rem 0.4rem;
  color: var(--text);
}
.recipient-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  align-items: flex-end;
  margin-top: var(--s3);
  padding: var(--s3);
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.recipient-row label { margin-top: 0; flex: 1 1 12rem; max-width: 18rem; }
.recipient-row input { max-width: none; }

/* ======================================================================
   Страница задачи: лог-панель (SSE)
   ====================================================================== */

.log-panel {
  margin-top: var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.log-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0.55rem var(--s4);
  background: var(--surface-sunk);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.log-dots { display: inline-flex; gap: 5px; }
.log-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); }
.job-log {
  margin: 0;
  padding: var(--s4) var(--s5);
  background: oklch(0.238 0.011 74);
  color: oklch(0.905 0.014 82);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 30rem;
  overflow-y: auto;
}
.job-meta { margin: var(--s2) 0 0; }
.job-meta a { font-weight: 500; }

/* Шаги пересчёта */
.steps { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s4) 0 0; padding: 0; list-style: none; }
.steps li {
  font-size: var(--fs-xs);
  color: var(--text-2);
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
}

/* ======================================================================
   Мобильный drawer (sidebar → верхняя шапка + выезжающая панель)
   ====================================================================== */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(41, 37, 30, 0.38);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-2) var(--ease), visibility var(--dur-2) var(--ease);
}
.burger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.burger:hover { background: var(--row-hover); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; align-content: start; }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    gap: var(--s3);
    height: 58px;
    padding: 0 var(--s4);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  .topbar__brand {
    font-size: var(--fs-lg);
    font-weight: 650;
    color: var(--text);
    letter-spacing: -0.02em;
  }
  .topbar__brand a { color: inherit; }
  .topbar__brand a:hover { text-decoration: none; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(84vw, var(--sidebar-w));
    height: 100dvh;
    z-index: 100;
    transform: translateX(-102%);
    transition: transform var(--dur-2) var(--ease);
    box-shadow: var(--shadow-pop);
    border-right: 1px solid var(--border);
  }
  .shell.drawer-open .sidebar { transform: translateX(0); }
  .shell.drawer-open .scrim { opacity: 1; visibility: visible; }

  main { width: min(100% - 2 * var(--s4), 74rem); padding: var(--s5) 0 var(--s9); }
}

@media (min-width: 901px) {
  .burger { display: none; }
  /* Один строковый трек = вся высота оболочки: контент-грид-элемент (.content)
     получает определённую высоту, от неё живёт height:100% у iframe.
     На мобиле трек-раскладка своя (auto 1fr под topbar) — её не трогаем. */
  .shell--flush { grid-template-rows: 1fr; }
}

/* ======================================================================
   Frame-body: honest-state страницы дашборда (нет данных / зона не настроена),
   которые рендерятся ВНУТРИ iframe оболочки. Центрированная карточка, без
   собственного sidebar-shell.
   ====================================================================== */
.frame-body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  display: grid;
  place-items: center;
}
.frame-panel {
  width: min(100% - 2 * var(--s5), 34rem);
  padding: var(--s6) 0;
}
.frame-panel .empty { margin-top: 0; }

/* ======================================================================
   Утилиты
   ====================================================================== */

.stack-sm > * + * { margin-top: var(--s2); }
.mt-0 { margin-top: 0; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ======================================================================
   Уважение к prefers-reduced-motion
   ====================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
