:root {
  --ink: #172334;
  --muted: #667085;
  --line: #dbe3ea;
  --surface: #ffffff;
  --canvas: #f2f5f7;
  --navy: #153a5b;
  --blue: #23669a;
  --blue-soft: #e8f2f9;
  --green: #26734d;
  --green-soft: #e5f3ea;
  --amber: #9b6a00;
  --amber-soft: #fff4d6;
  --red: #b42318;
  --red-soft: #fce8e6;
  --shadow: 0 12px 34px rgba(25, 43, 60, 0.08);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 264px minmax(0, 1fr); }
/* На экране макбука (800 px по высоте) содержимое панели — 1091 px. Без
   прокрутки лишние 291 px просто вываливались наружу: карточка пользователя и
   кнопки оказывались ниже синего фона, на белом, а у администратора туда же
   уходил десятый пункт меню. */
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 24px 20px; background: #102f49; color: #fff;
  display: flex; flex-direction: column; gap: 18px;
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: #365d79 transparent;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { border-radius: 99px; background: #365d79; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: #fff; color: var(--navy); font-weight: 800; }
.brand strong { display: block; font-size: 16px; }
.brand span { display: block; color: #b8cad8; font-size: 12px; margin-top: 3px; }
.field-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #a8bece; margin-bottom: -14px; }
.select { width: 100%; border: 1px solid #365d79; border-radius: 10px; padding: 11px 12px; background: #183e5b; color: #fff; }
.main-nav { display: grid; gap: 6px; }
.nav-item { border: 0; border-radius: 10px; padding: 10px 12px; background: transparent; color: #c3d2dd; text-align: left; display: flex; align-items: center; gap: 12px; }
.nav-item span { font-size: 10px; color: #7fa1b9; font-weight: 800; }
.nav-item:hover, .nav-item.active { background: #214b69; color: #fff; }
.privacy-note { margin-top: auto; padding: 14px; border: 1px solid #315a76; border-radius: 12px; display: flex; gap: 10px; color: #bdd0dc; font-size: 11px; line-height: 1.45; }
.privacy-dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; margin-top: 3px; background: #62d39b; box-shadow: 0 0 0 4px rgba(98, 211, 155, .12); }
.account-card { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid #315a76; }
.account-card strong, .account-card span { display: block; }
.account-card span { margin-top: 3px; color: #a8bece; font-size: 11px; }
.account-card .ghost { width: 100%; padding: 8px 10px; background: transparent; border-color: #365d79; color: #d8e4ec; }

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top left, #e4f0f7, var(--canvas) 48%); }
.auth-card { width: min(430px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.auth-mark { margin-bottom: 22px; background: var(--navy); color: #fff; }
.auth-card label { display: grid; gap: 7px; margin: 16px 0; color: #42515e; font-size: 12px; font-weight: 700; }
.auth-card input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px; color: var(--ink); }
.auth-card .alert { margin: 14px 0; }
.auth-help { margin: 18px 0 0; padding: 12px; border-radius: 10px; color: var(--amber); background: var(--amber-soft); font-size: 12px; line-height: 1.5; }

.workspace { min-width: 0; padding: 30px clamp(20px, 4vw, 56px) 60px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(24px, 2.4vw, 30px); letter-spacing: -.03em; }
h2 { margin-bottom: 6px; font-size: 22px; letter-spacing: -.02em; }
h3 { margin-bottom: 5px; font-size: 16px; }
.eyebrow { margin-bottom: 7px; color: var(--blue); font-weight: 800; font-size: 10px; letter-spacing: .15em; }
.subtitle, .muted { color: var(--muted); }
.subtitle { margin: 0; }
.top-actions, .artifact-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.primary, .ghost, .danger, .soft-button { border-radius: 10px; padding: 10px 15px; font-weight: 700; border: 1px solid transparent; }
.primary { background: var(--blue); color: #fff; }
.primary:hover { background: #195582; }
.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.ghost:hover { background: #f8fafb; }
.danger { background: var(--red-soft); border-color: #f2c8c3; color: var(--red); }
.soft-button { background: var(--blue-soft); color: var(--blue); }
.wide { width: 100%; }
.sidebar .primary { background: #fff; color: var(--navy); }

.status-pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 7px 11px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.status-pill.completed, .status-pill.approved { color: var(--green); background: var(--green-soft); }
.status-pill.review_required, .status-pill.running { color: var(--amber); background: var(--amber-soft); }
.status-pill.blocked, .status-pill.error { color: var(--red); background: var(--red-soft); }
.status-pill.pending, .status-pill.awaiting_input, .status-pill.neutral { color: #5b6977; background: #e9edf1; }

.alert { padding: 13px 16px; border: 1px solid #f0c5bf; background: var(--red-soft); color: var(--red); border-radius: 12px; margin-bottom: 20px; }
.hidden { display: none !important; }
.view { display: none; }
.view.active { display: block; }
#view-inputs.active { display: flex; flex-direction: column; }
#source-lineage-panel { order: 100; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: 0 4px 14px rgba(22, 40, 55, .04); }
.kpi-label { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.kpi-value { display: block; margin-top: 9px; font-size: clamp(20px, 2.2vw, 29px); font-weight: 800; letter-spacing: -.03em; white-space: normal; overflow-wrap: anywhere; line-height: 1.12; }
.kpi-note { display: block; color: var(--muted); font-size: 11px; margin-top: 6px; }
.kpi-card.positive .kpi-value { color: var(--green); }
.kpi-card.warning .kpi-value { color: var(--amber); }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, .85fr); gap: 18px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.panel-heading { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 16px; }
.progress-label { color: var(--muted); font-size: 12px; }
.progress-track { height: 5px; border-radius: 99px; background: #e7edf1; overflow: hidden; margin-bottom: 18px; }
.progress-track span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), #4ca8d8); transition: width .25s ease; }

.stage-list { display: grid; }
.stage-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 13px; align-items: center; padding: 14px 6px; border-top: 1px solid #edf1f4; background: transparent; width: 100%; text-align: left; border-left: 0; border-right: 0; border-bottom: 0; }
.stage-row:hover, .stage-row.selected { background: #f7fafc; }
.stage-number { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: #e9eef2; color: #5f6d79; font-size: 11px; font-weight: 800; }
.stage-row.completed .stage-number { background: var(--green-soft); color: var(--green); }
.stage-row.blocked .stage-number, .stage-row.error .stage-number { background: var(--red-soft); color: var(--red); }
.stage-row.review_required .stage-number, .stage-row.running .stage-number { background: var(--amber-soft); color: var(--amber); }
.stage-copy strong { display: block; font-size: 15px; margin-bottom: 4px; }
.stage-copy span { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.stage-detail { position: sticky; top: 24px; min-height: 470px; }
.detail-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.detail-description { color: var(--muted); line-height: 1.55; }
.detail-box { border-radius: 12px; padding: 14px; margin: 14px 0; background: #f7f9fb; border: 1px solid #e3e9ee; }
.detail-box.error { background: var(--red-soft); border-color: #f1c8c3; color: var(--red); }
.detail-box h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.detail-list { margin: 0; padding-left: 18px; line-height: 1.6; font-size: 13px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.empty-state { min-height: 420px; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-index { font-size: 72px; line-height: 1; font-weight: 900; color: #e2e8ed; }

.report-panel { min-height: 70vh; }
.report-heading { align-items: center; }
.sheet-tabs { display: flex; overflow-x: auto; gap: 7px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.sheet-tab { flex: 0 0 auto; border: 0; border-radius: 8px; padding: 8px 11px; background: #eef2f5; color: #53616d; font-size: 12px; font-weight: 700; }
.sheet-tab.active { background: var(--navy); color: #fff; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 15px 0; }
.table-toolbar input { width: min(420px, 100%); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.table-toolbar span { color: var(--muted); font-size: 11px; }
.report-period-context { margin-bottom: 12px; padding: 11px 13px; border: 1px solid #c9ddeb; border-radius: 10px; background: var(--blue-soft); color: #244b68; font-size: 12px; line-height: 1.5; }
.report-period-context strong { color: var(--ink); }
.table-wrap { overflow: auto; max-height: 72vh; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; min-width: 1050px; border-collapse: collapse; font-size: 13.5px; }
th { position: sticky; top: 0; z-index: 1; min-width: 120px; background: var(--navy); color: #fff; font-size: 12px; text-align: left; padding: 10px 11px; white-space: nowrap; }
td { min-width: 120px; padding: 9px 11px; border-bottom: 1px solid #e8edf1; vertical-align: top; max-width: 360px; }
tbody tr:nth-child(even) { background: #f8fafb; }
.money-cell { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.summary-preview { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 12px; padding: 18px; }
.summary-preview .kpi-card { box-shadow: none; }
.pagination { display: flex; justify-content: center; gap: 8px; padding-top: 14px; }

.issue-list { display: grid; gap: 10px; }
.issue-card { border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: 10px; padding: 14px 16px; display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 14px; align-items: start; }
.issue-card.error { border-left-color: var(--red); background: #fffafa; }
.issue-card.pass { border-left-color: var(--green); }
.issue-code { color: var(--muted); font-size: 10px; font-weight: 800; }
.issue-card p { margin: 4px 0 0; color: var(--muted); line-height: 1.5; }

.timeline { display: grid; gap: 0; }
.timeline-item { position: relative; padding: 0 0 24px 28px; border-left: 2px solid #dfe6ec; margin-left: 7px; }
.timeline-item::before { content: ""; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.timeline-item strong { display: block; font-size: 13px; }
.timeline-item span { color: var(--muted); font-size: 11px; }
.timeline-item p { margin: 6px 0 0; line-height: 1.5; }

.source-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.source-card { border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }
.source-card h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-card dl { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 8px; margin: 12px 0 0; font-size: 11px; }
.source-card dt { color: var(--muted); }
.source-card dd { margin: 0; overflow-wrap: anywhere; }
.hash { font-family: Consolas, monospace; font-size: 10px; color: #4d5b66; }

.dodo-api-panel { margin-top: 18px; }
.dodo-api-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.integration-wide { grid-column: 1 / -1; }
.integration-step {
  display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; min-width: 0;
  padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: #fbfcfd;
}
.integration-number {
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%;
  color: var(--blue); background: var(--blue-soft); font-size: 12px; font-weight: 800;
}
.integration-step h3 { margin-top: 4px; }
.integration-step p { line-height: 1.5; }
.integration-form { display: grid; gap: 11px; margin-top: 14px; }
.integration-form label:not(.checkbox) { display: grid; gap: 6px; color: #42515e; font-size: 12px; font-weight: 700; }
.integration-form input, .integration-form select {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 11px; color: var(--ink); background: #fff;
}
.integration-form.compact { max-width: 520px; }
.integration-confirmation {
  align-items: flex-start; margin: 2px 0; color: #42515e; font-size: 12px; line-height: 1.45;
}
.integration-placeholder {
  margin-top: 12px; padding: 12px; border-radius: 10px; background: #eef2f5;
  color: var(--muted); font-size: 12px; line-height: 1.5;
}
.integration-placeholder.ready { background: var(--green-soft); color: var(--green); }
.integration-placeholder.error { background: var(--red-soft); color: var(--red); }
.integration-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 10px; }
.shadow-section { display: grid; gap: 10px; margin-top: 16px; }
.shadow-section h4 { margin: 8px 0 0; font-size: 13px; }
.compact-table { max-height: 340px; }
.compact-table table { min-width: 880px; }
.compact-table th, .compact-table td { min-width: 105px; }
.inline-action { display: inline-flex; text-decoration: none; margin-bottom: 12px; }
.device-code-box {
  display: grid; gap: 4px; margin: 0 0 12px; padding: 12px; border: 1px dashed #a9becd;
  border-radius: 10px; background: #fff;
}
.device-code-box span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.device-code-box strong { font-family: Consolas, monospace; font-size: 24px; letter-spacing: .08em; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Вводный блок объясняет источник, а не показывает цифры. Экран нужен тому,
   что читают каждый день, поэтому здесь всё сжато. */
.diagnostic-intro { margin-bottom: 18px; padding: 15px 18px; }
.diagnostic-intro .panel-heading { margin-bottom: 11px; flex-wrap: wrap; }
.diagnostic-intro .panel-heading > div:first-child { flex: 1 1 260px; min-width: 240px; }
.diagnostic-intro .artifact-actions { flex: 1 1 auto; justify-content: flex-end; }
.diagnostic-intro h2 { font-size: 17px; margin-bottom: 4px; }
.diagnostic-intro .eyebrow { margin-bottom: 5px; }
.diagnostic-intro .muted { font-size: 12px; line-height: 1.45; margin-bottom: 0; }
.diagnostic-intro .diagnostic-message { padding: 9px 12px; font-size: 12.5px; line-height: 1.45; }
/* Длинная строка во всю ширину экрана читается как заголовок. Служебному
   тексту ширину ограничиваем, чтобы главным на экране осталась матрица. */
.diagnostic-intro .diagnostic-message, .diagnostic-intro .intro-note { max-width: 108ch; }
.diagnostic-message { padding: 11px 14px; border-radius: 11px; background: #f5f8fa; color: var(--muted); font-size: 13px; line-height: 1.5; }
.diagnostic-message.ready { background: var(--green-soft); color: var(--green); }
.diagnostic-message.error { background: var(--red-soft); color: var(--red); }
.diagnostic-message.warning { background: var(--amber-soft); color: var(--amber); }
.diagnostic-kpis { margin-bottom: 18px; }
.diagnostic-kpis .period-card .kpi-value { font-size: clamp(17px, 1.65vw, 23px); }
.diagnostic-section + .diagnostic-section { margin-top: 18px; }
.diagnostic-heading { align-items: flex-end; }
.diagnostic-filter-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.compact-field { display: grid; gap: 6px; min-width: 210px; color: var(--muted); font-size: 11px; font-weight: 700; }
.compact-field select, .compact-field input[type="date"] { border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; color: var(--ink); background: #fff; font: inherit; }
.diagnostic-filter-row .compact-field:has(input[type="date"]) { min-width: 150px; }
/* Поля выбора стоят внизу свода, у самых цифр. В шапке они отнимали ширину
   у заголовка и переносились на макбуке в две строки. */
.traffic-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
/* Поля ужимаются, чтобы весь ряд помещался на макбуке в одну строку:
   иначе кнопка «Пересчитать» уезжала на вторую и висела одна. */
.traffic-filters .compact-field { margin: 0; flex: 1 1 140px; min-width: 0; max-width: 165px; }
.traffic-filters .compact-field select, .traffic-filters .compact-field input { width: 100%; }
.traffic-dds-load { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-top: 12px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 13px; background: #fbfcfd; }
.traffic-dds-load p { margin: 0; }
.traffic-dds-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.traffic-dds-load .muted { max-width: 620px; }
.traffic-dds-load button[disabled] { opacity: 0.55; cursor: progress; }
.artifact-actions .compact-field:has(input[type="date"]) { min-width: 150px; }
.window-presets { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-top: 10px; color: var(--muted); font-size: 11px; font-weight: 700; }
.chip-button { border: 1px solid var(--line); border-radius: 99px; padding: 5px 11px; background: #fff; color: #42515e; font-size: 11px; font-weight: 700; }
.chip-button:hover { background: #f2f6f9; }
.window-note { font-weight: 600; }
.window-note.error { color: var(--red); }
.relationship-meta { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.focus-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.focus-card { min-width: 0; border: 1px solid var(--line); border-top: 4px solid var(--amber); border-radius: 13px; padding: 16px; background: #fffdf8; }
.focus-card.high { border-top-color: var(--red); background: #fffafa; }
.focus-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.focus-card-head h3 { margin: 4px 0 0; line-height: 1.35; }
.focus-rank { color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.focus-values { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin: 14px 0; }
.focus-values span { min-width: 0; padding: 9px; border-radius: 9px; background: rgba(255, 255, 255, .78); color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .03em; }
.focus-values strong { display: block; margin-top: 5px; color: var(--ink); font-size: 13px; letter-spacing: 0; text-transform: none; overflow-wrap: anywhere; }
.focus-evidence { min-height: 66px; margin: 0 0 12px; color: #42515e; font-size: 11px; line-height: 1.5; }
.focus-action { margin: 0 0 12px; padding: 11px; border-radius: 10px; background: var(--blue-soft); color: #244860; }
.focus-action strong { display: block; margin-bottom: 4px; color: var(--blue); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.focus-action p { margin: 0; font-size: 11px; line-height: 1.5; }
.focus-empty { grid-column: 1 / -1; padding: 26px; border: 1px dashed #b9c7d2; border-radius: 12px; background: #f8fafb; text-align: center; color: var(--muted); }
.focus-empty.completed { border-color: #b8d9c6; background: var(--green-soft); color: var(--green); }
.focus-empty h3 { color: var(--ink); }
.focus-empty p { margin: 0; line-height: 1.5; }
.diagnostic-details { margin-top: 16px; }
.diagnostic-details summary { cursor: pointer; color: var(--blue); font-size: 12px; font-weight: 800; }
.diagnostic-details[open] summary { margin-bottom: 12px; }
.mini-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 2px 0 18px; }
/* Шесть счётчиков вместо четырёх: две цифры смены и четыре цвета. В базовую
   сетку они встают 4+2 и ряд выглядит обрубленным. */
.mini-kpi-grid.wide { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1180px) { .mini-kpi-grid.wide { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.mini-kpi { border: 1px solid var(--line); border-radius: 11px; padding: 13px; background: #f8fafb; }
.mini-kpi span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.mini-kpi strong { display: block; margin-top: 7px; font-size: 20px; font-variant-numeric: tabular-nums; }
.month-chart { display: grid; gap: 7px; padding: 14px 0 18px; }
.month-change-row { display: grid; grid-template-columns: 105px minmax(160px, 1fr) 76px; gap: 12px; align-items: center; font-size: 11px; }
.month-change-row > span:last-child { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.change-track { position: relative; height: 10px; border-radius: 99px; background: #edf1f4; overflow: hidden; }
.change-track::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #9aa8b3; }
.change-bar { position: absolute; top: 1px; bottom: 1px; width: var(--bar-width); max-width: 50%; border-radius: 99px; }
.change-bar.positive { left: 50%; background: #5aa877; }
.change-bar.negative { right: 50%; background: #5d94bd; }
.diagnostic-table { max-height: 430px; }
.diagnostic-table table { min-width: 760px; }
.diagnostic-table th, .diagnostic-table td { min-width: auto; }
/* Недостижение цели видно по строке, а не только по цифре: жёлтый — разрыв
   до 5%, красный — больше. Направление берётся из справочника метрик. */
.diagnostic-table tr.target-soft td { background: var(--amber-soft); }
.diagnostic-table tr.target-hard td { background: var(--red-soft); }
.diagnostic-table tr.no-data td { color: var(--muted); }
.diagnostic-table tr.metric-divider td { padding: 7px 12px; background: #eef2f5; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.target-flag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 99px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.target-flag.soft { background: #fde8b0; color: var(--amber); }
.target-flag.hard { background: #f8d2ce; color: var(--red); }
.target-flag.met { background: var(--green-soft); color: var(--green); }
.traffic-price { color: #7a4a12; font-weight: 700; }
.traffic-card-price { color: #7a4a12; font-weight: 700; }
.source-health { margin: 0 0 18px; padding: 14px 18px; border: 1px solid var(--line); border-left-width: 4px; border-radius: 13px; background: var(--surface); }
.source-health.health-dead { border-left-color: var(--red); background: var(--red-soft); }
.source-health.health-attention, .source-health.health-unknown { border-left-color: var(--amber); background: var(--amber-soft); }
.health-title { margin: 0 0 8px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.source-health ul { margin: 0 0 10px; padding: 0; list-style: none; display: grid; gap: 8px; }
.source-health li { display: grid; gap: 2px; font-size: 13px; line-height: 1.45; }
.source-health li strong { font-size: 14px; }
.source-health li small { color: var(--muted); font-size: 11px; }
.source-health li [data-open-operations-load] { margin-top: 8px; }
.busy-dot { display: inline-block; width: 11px; height: 11px; margin-right: 7px; vertical-align: -1px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: busy-spin .7s linear infinite; }
@keyframes busy-spin { to { transform: rotate(360deg); } }
/* Движение — не единственный признак работы: надпись со счётчиком времени
   остаётся и там, где анимация отключена системными настройками. */
@media (prefers-reduced-motion: reduce) { .busy-dot { animation: none; opacity: .55; } }
button[aria-busy="true"] { cursor: progress; }
.trend-cell { min-width: 148px; }
.sparkline { display: block; width: 132px; height: 30px; margin-top: 3px; }
/* Пунктир цели рисуется под линией ряда и своим цветом, а не цветом тренда:
   иначе он читался бы как часть ряда. */
.sparkline-goal { stroke: #5b6977; stroke-width: 1; stroke-dasharray: 3 3; opacity: .65; }
.sparkline-worse { color: var(--red); }
.sparkline-better { color: var(--green); }
.sparkline-flat { color: var(--muted); }
.fact-strip { display: flex; flex-wrap: wrap; align-items: baseline; gap: 7px 20px; margin: 0 0 14px; padding: 10px 15px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.fact-strip:empty { display: none; }
.fact-strip .fact { display: inline-flex; align-items: baseline; gap: 8px; }
.fact-strip .fact-label { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.fact-strip .fact-value { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.diagnostic-section .fact-strip { margin-top: 4px; }
.heading-with-hint { display: flex; align-items: center; gap: 9px; }
.hint-toggle { width: 21px; height: 21px; flex: 0 0 auto; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1; }
.hint-toggle:hover, .hint-toggle:focus-visible { border-color: var(--blue); color: var(--blue); }
.hint-toggle[aria-expanded="true"] { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
/* Разрыв до цели полоской: размер виден раньше, чем прочитано число. */
.focus-gap-note { margin: 0 0 14px; padding: 9px 12px; border: 1px solid #e5cd94; border-radius: 9px; background: var(--amber-soft); color: #6b4a00; font-size: 12px; line-height: 1.5; }
.target-source { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.gap-track { display: block; position: relative; height: 5px; margin-top: 6px; border-radius: 99px; background: #eef2f5; overflow: hidden; }
.gap-track span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: var(--amber); }
.gap-track.hard span { background: var(--red); }
/* Колонка «Что это значит» отвечает на вопрос человека, а не показывает
   служебное число, поэтому первая строка в ней — вывод, вторая — оговорка. */
.meaning-cell { min-width: 210px; }
.meaning-cell strong { display: block; line-height: 1.35; }
.meaning-cell span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.metric-note { display: block; margin-top: 3px; color: var(--amber); font-size: 10px; }
.focus-hypothesis { margin: 10px 0 0; color: #42515e; font-size: 12px; line-height: 1.5; }
.focus-method > summary { cursor: pointer; margin-top: 8px; color: var(--muted); font-size: 11px; }
.focus-method[open] > summary { margin-bottom: 6px; }
/* В ячейке плана две строки: сумма и способ, которым она получена. Способ —
   не деталь реализации: ближайший месяц считается точнее дальних. */
.diagnostic-table td small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.3; }
.plan-correction strong { display: block; color: var(--amber); }
.plan-total td { border-top: 2px solid var(--line); }
/* Итог за период — то, ради чего таблицу открывают на квартал: отделён
   линией, чтобы не читаться очередным месяцем. */
.plan-period { border-left: 2px solid var(--line); }
/* Экран «Сегодня»: список отклонений над таблицей. Красное и жёлтое разделены
   заголовками, а не только цветом — цвет один читатель различает, другой нет. */
.today-group-title { margin: 16px 0 8px; font-size: 14px; color: var(--muted); text-transform: none; }
.today-group-title:first-child { margin-top: 0; }
.metric-legend { margin: 11px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.diagnostic-note { color: var(--muted); font-size: 11px; margin: 12px 0 0; }
.pizzeria-health-table table { min-width: 820px; }
.pizzeria-link { border: 0; padding: 0; background: transparent; color: var(--blue); font-weight: 800; text-align: left; }
.pizzeria-link:hover { text-decoration: underline; }
.health-status { display: inline-flex; padding: 5px 8px; border-radius: 999px; background: #eef2f5; color: #53616d; font-size: 10px; font-weight: 800; white-space: nowrap; }
.health-status.high { background: var(--red-soft); color: var(--red); }
.health-status.medium, .health-status.watch { background: var(--amber-soft); color: var(--amber); }
.health-status.improved { background: var(--green-soft); color: var(--green); }
.target-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.target-group { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfd; }
.target-group h3 { margin-bottom: 12px; color: var(--blue); }
.target-field { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid #edf1f4; color: #42515e; font-size: 11px; }
.target-field > span { line-height: 1.35; }
.target-field > div { position: relative; }
.target-field input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 48px 9px 10px; background: #fff; color: var(--ink); text-align: right; }
.target-field small { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.target-actions { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-top: 14px; }
.quarter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 4px 0 8px; }
.quarter-card { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 15px; border: 1px solid var(--line); border-top: 4px solid var(--green); border-radius: 12px; background: #fbfcfd; }
.quarter-card.negative { border-top-color: var(--blue); }
.quarter-card > span { color: var(--muted); font-size: 11px; }
.quarter-card > strong { text-align: right; font-size: 18px; }
.quarter-card > div { min-width: 0; padding-top: 9px; border-top: 1px solid #e8edf1; }
.quarter-card small, .quarter-card b { display: block; }
.quarter-card small { margin-bottom: 4px; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.quarter-card b { font-size: 12px; overflow-wrap: anywhere; }
.advisor-controls { display: flex; align-items: end; gap: 12px; margin-bottom: 14px; }
.advisor-controls .compact-field { min-width: 260px; }
.advisor-summary { margin-top: 16px; padding: 18px; border: 1px solid #b8d9c6; border-radius: 13px; background: var(--green-soft); }
.advisor-summary h3 { margin: 6px 0 10px; line-height: 1.4; }
.advisor-summary p { line-height: 1.55; }
.advisor-empty { margin-top: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.advisor-empty.error { border-color: #edb7b1; background: var(--red-soft); }
.advisor-empty h3 { margin: 6px 0 8px; }
.advisor-empty p { line-height: 1.55; }
/* Свежесть данных стоит над сводкой: разбор устаревшего дня выглядит так же
   убедительно, как разбор вчерашнего, и отличить их можно только по этой
   строке. */
.diagnostic-freshness { margin-top: 14px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--muted); font-size: 12px; line-height: 1.55; }
/* Красное — только когда выводам нельзя верить: в разбираемом периоде дыра.
   Отставание от календаря на выводы не влияет и красным не кричит. */
.diagnostic-freshness.behind { border-color: #e5cd94; background: var(--amber-soft); color: #6b4a00; }
.diagnostic-freshness.broken { border-color: #edb7b1; background: var(--red-soft); color: #7a2d24; }
.diagnostic-freshness button { margin-left: 10px; }
/* Повод из сводки открывает свою таблицу, поэтому строка ведёт себя как
   ссылка, а не как текст. */
.advisor-local-preview li[data-evidence] { cursor: pointer; }
.advisor-local-preview li[data-evidence]:hover { background: rgba(24, 80, 119, .06); }
.evidence-divider { margin: 26px 0 10px; color: var(--muted); }
/* Блок LLM — часть верхней сводки, а не отдельная секция: у него своя рамка
   внутри, но не своя панель. */
.advisor-llm { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.advisor-llm-heading { margin-bottom: 12px; }
/* Проверки пилота нужны, когда что-то сломалось, а не каждый день. Внутри
   свёрнутого блока они идут без номеров: это набор инструментов, а не путь. */
.integration-diagnostics > summary { cursor: pointer; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: #42515e; font-size: 12px; font-weight: 700; }
.integration-diagnostics[open] > summary { margin-bottom: 14px; }
.integration-probe { display: block; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.integration-probe:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.advisor-local-preview { margin-top: 14px; padding: 16px; border: 1px solid #b8d4e8; border-radius: 13px; background: var(--blue-soft); }
.advisor-preview-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.advisor-preview-head div { display: grid; gap: 4px; }
.advisor-preview-head small { color: var(--muted); }
.advisor-preview-head > span { color: var(--green); font-size: 12px; font-weight: 800; }
.advisor-local-preview ul { display: grid; gap: 0; margin: 14px 0 0; padding: 0; list-style: none; }
/* Сводка остаётся списком: порядок здесь и есть сообщение, в сетке он бы
   потерялся. Но язык взят у карточек — светофор слева, крупное число справа,
   тот же ряд восьми недель. Длинная строка цифр разложена на подписи. */
.summary-row { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border-left: 4px solid var(--line); border-radius: 0 10px 10px 0; background: #fff; }
.summary-row + .summary-row { margin-top: 6px; }
.summary-mark { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; line-height: 1.3; }
.summary-body strong { display: block; line-height: 1.35; }
.summary-detail { display: block; margin-top: 3px; color: #5b6977; font-size: 12px; line-height: 1.45; }
.summary-side { display: flex; align-items: center; gap: 12px; justify-content: flex-end; }
.summary-value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.summary-side .focus-trend { color: inherit; }
.summary-red { border-left-color: var(--red); background: var(--red-soft); }
.summary-red .summary-value, .summary-red .summary-mark { color: var(--red); }
.summary-amber { border-left-color: var(--amber); background: var(--amber-soft); }
.summary-amber .summary-value, .summary-amber .summary-mark { color: var(--amber); }
.summary-grey { border-left-color: var(--line); background: #f4f6f8; }
@media (max-width: 860px) {
  .summary-row { grid-template-columns: 1fr; }
  .summary-side { justify-content: flex-start; }
}
.advisor-paid-confirm { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; color: #42515e; font-size: 12px; font-weight: 700; }
.advisor-paid-confirm input { margin-top: 2px; }
.advisor-gate { margin: 8px 0 0; padding: 9px 12px; border-radius: 9px; background: var(--blue-soft); color: #42515e; font-size: 12px; line-height: 1.55; }
.advisor-hypotheses { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.advisor-hypothesis { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.advisor-hypothesis h3 { margin: 9px 0; }
.advisor-numbers { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.advisor-numbers li { display: grid; gap: 2px; padding-top: 8px; border-top: 1px solid var(--line); }
.advisor-numbers span { color: #42515e; font-size: 12px; }

.advisor-hypothesis p, .advisor-hypothesis li, .advisor-checks li { color: #42515e; font-size: 12px; line-height: 1.55; }
.advisor-hypothesis small { color: var(--muted); }
.advisor-checks { margin-top: 12px; padding: 14px; border-radius: 11px; background: var(--blue-soft); }
/* Память агента: видно, какие гипотезы человек уже отверг и почему агент
   больше их не предлагает. Без показа непонятно, зачем ставить оценки. */
.advisor-memory { margin-bottom: 14px; padding: 12px 14px; border: 1px solid #cfe0d6; border-radius: 11px; background: var(--green-soft); font-size: 12px; line-height: 1.55; }
.advisor-memory ul { margin: 8px 0; padding-left: 18px; }
.advisor-memory small { color: var(--muted); }
.advisor-warnings { margin-bottom: 14px; padding: 12px 14px; border-radius: 11px; background: var(--amber-soft); color: var(--amber); font-size: 12px; line-height: 1.55; }
.advisor-warnings ul { margin: 7px 0 0; padding-left: 18px; }
.advisor-feedback { display: grid; gap: 12px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.advisor-feedback label { display: grid; gap: 6px; color: #42515e; font-size: 12px; font-weight: 700; }
.advisor-feedback select, .advisor-feedback textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; background: #fff; }

.dialog { width: min(580px, calc(100vw - 30px)); border: 0; border-radius: 18px; padding: 0; box-shadow: 0 26px 80px rgba(14, 29, 41, .28); }
.large-dialog { width: min(980px, calc(100vw - 30px)); max-height: 90vh; }
.dialog::backdrop { background: rgba(14, 32, 47, .55); backdrop-filter: blur(2px); }
.dialog form { padding: 24px; max-height: 88vh; overflow: auto; }
.dialog-heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.dialog-intro { color: var(--muted); line-height: 1.5; }
.icon-button { border: 0; width: 34px; height: 34px; border-radius: 50%; background: #eef2f5; font-size: 21px; color: #53616d; }
.form-grid { display: grid; gap: 13px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dialog label:not(.file-card):not(.checkbox) { display: grid; gap: 6px; color: #42515e; font-size: 12px; font-weight: 700; margin-bottom: 13px; }
.dialog input, .dialog textarea, .dialog select { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; color: var(--ink); background: #fff; }
.upload-section { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.upload-section h3 { margin-bottom: 12px; }
.upload-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.section-heading-inline { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.section-heading-inline h3 { margin: 0 0 5px; }
.section-heading-inline p { margin: 0; max-width: 680px; line-height: 1.5; }
.manual-events-list { display: grid; gap: 12px; margin-top: 14px; }
.manual-event-row { position: relative; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #f8fafb; }
.manual-event-grid { display: grid; grid-template-columns: 1.2fr .8fr .8fr 1fr; gap: 10px; }
.manual-event-row .checkbox { margin: 3px 38px 0 0; }
.remove-event { position: absolute; right: 12px; bottom: 12px; }
.anomaly-review { margin-top: 16px; padding: 14px; border: 1px solid #e8c66b; border-radius: 12px; background: #fff8df; }
.anomaly-review > h3 { margin: 0 0 6px; }
.anomaly-card { margin-top: 12px; padding: 13px; border: 1px solid #e5d39b; border-radius: 10px; background: #fff; }
.anomaly-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.anomaly-card-head strong { display: block; }
.anomaly-metrics { color: var(--muted); font-size: 12px; line-height: 1.5; }
.anomaly-fields { display: grid; grid-template-columns: .9fr 1.6fr; gap: 10px; }
.anomaly-card .checkbox { margin-top: 0; }
.file-card { display: grid; gap: 4px; padding: 13px; border: 1px dashed #b9c7d2; border-radius: 10px; background: #f8fafb; font-size: 12px; }
.file-card span { font-weight: 700; }
.file-card small { color: var(--muted); }
.file-card input { padding: 7px 0 0; border: 0; }
.checkbox { display: flex !important; align-items: center; gap: 8px; margin-top: 12px; font-weight: 500 !important; }
.checkbox input { width: auto; }
.pizzeria-files { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
.pizzeria-file { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px; align-items: center; font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.dialog-progress { margin-top: 16px; padding: 13px; border-radius: 10px; background: var(--blue-soft); color: var(--blue); }
/* Чтение LookinTeam занимает минуты: без шкалы неподвижная надпись выглядит
   как зависание, поэтому полоса показывает долю прочитанных пиццерий. */
.stage-progress { margin-top: 0; margin-bottom: 18px; }
.dialog-progress .progress-track { display: block; height: 6px; margin-bottom: 9px; border-radius: 999px; background: currentColor; opacity: 0.22; overflow: hidden; }
.dialog-progress .progress-track > span { display: block; height: 100%; border-radius: 999px; background: currentColor; opacity: 1; width: 0; transition: width 400ms ease; }
.dialog-progress > strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.access-selector { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.access-selector fieldset { min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.access-selector legend { padding: 0 6px; font-size: 12px; font-weight: 800; }
.access-selector fieldset div { display: grid; gap: 8px; }
.access-selector label { display: flex !important; align-items: center; gap: 8px !important; margin: 0 !important; font-weight: 500 !important; }
.access-selector input { width: auto; }
/* Список разделов — тот же вид, что у территорий. Без этих правил метка
   диалога раскладывалась сеткой, и галочка вставала над словом, а не рядом. */
.section-selector { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 16px; }
.section-selector legend { padding: 0 6px; font-size: 12px; font-weight: 800; }
.section-selector .section-mode { display: flex !important; align-items: center; gap: 8px !important; margin: 0 0 12px !important; font-weight: 700 !important; }
.section-selector #section-access-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; }
.section-selector label { display: flex !important; align-items: center; gap: 8px !important; margin: 0 !important; font-weight: 500 !important; }
.section-selector input { width: auto; }
.section-selector[data-mode="all"] #section-access-list { opacity: .45; }
@media (max-width: 900px) { .section-selector #section-access-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.admin-audit-grid { margin-top: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.admin-audit-grid table { min-width: 720px; }

.knowledge-hero { overflow: hidden; }
.knowledge-safety-note { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border: 1px solid #c9e5d3; border-radius: 12px; background: #eef8f1; color: #276846; }
.knowledge-safety-note strong { flex: 0 0 auto; }
.knowledge-settings-grid { grid-template-columns: 1.2fr .8fr; margin: 18px 0; }
.knowledge-form { display: grid; gap: 14px; }
.button-row { display: flex; flex-wrap: wrap; gap: 9px; }
.knowledge-access, .knowledge-model-status { margin-top: 16px; }
.knowledge-instructions { display: grid; gap: 10px; color: var(--muted); line-height: 1.6; }
.knowledge-instructions p { margin: 0; }
.knowledge-preview-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.knowledge-preview-kpis article { display: grid; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #f8fafb; }
.knowledge-preview-kpis span { color: var(--muted); font-size: 12px; }
.knowledge-preview-kpis strong { font-size: 24px; }
.knowledge-preview .diagnostic-message { margin-bottom: 16px; }

.toast-stack { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 100; }
.toast { max-width: 420px; padding: 12px 15px; background: #153a5b; color: #fff; border-radius: 10px; box-shadow: var(--shadow); animation: toast-in .2s ease-out; }
.toast.error { background: var(--red); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 1100px) {
  .content-grid { grid-template-columns: 1fr; }
  .stage-detail { position: static; min-height: 0; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .focus-grid { grid-template-columns: 1fr; }
  .target-grid { grid-template-columns: 1fr; }
  .quarter-grid { grid-template-columns: 1fr; }
  .advisor-hypotheses { grid-template-columns: 1fr; }
  .dodo-api-grid { grid-template-columns: 1fr; }
  .knowledge-settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 16px; }
  .main-nav { grid-template-columns: repeat(6, minmax(52px, 1fr)); overflow-x: auto; }
  .nav-item { justify-content: center; font-size: 0; }
  .nav-item span { font-size: 11px; }
  .privacy-note, .field-label { display: none; }
  .workspace { padding: 22px 14px 50px; }
  .topbar { flex-direction: column; }
  .kpi-grid, .source-grid, .form-grid.three, .form-grid.two, .upload-grid, .pizzeria-files, .summary-preview, .manual-event-grid, .anomaly-fields { grid-template-columns: 1fr; }
  .section-heading-inline, .anomaly-card-head { flex-direction: column; }
  .content-grid { display: block; }
  .stage-detail { margin-top: 14px; }
  .issue-card { grid-template-columns: 1fr; }
  .diagnostic-heading { align-items: stretch; flex-direction: column; }
  .compact-field { min-width: 0; width: 100%; }
  .mini-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mini-kpi-grid.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .focus-values { grid-template-columns: 1fr; }
  .target-field { grid-template-columns: 1fr; }
  .target-actions { align-items: stretch; flex-direction: column; }
  .advisor-controls { align-items: stretch; flex-direction: column; }
  .month-change-row { grid-template-columns: 86px minmax(110px, 1fr) 64px; gap: 8px; }
  .knowledge-preview-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .knowledge-safety-note { flex-direction: column; }
}
.weather-filters {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.weather-filters .compact-field {
  min-width: 190px;
}

@media (max-width: 760px) {
  .weather-filters,
  .weather-filters .compact-field {
    width: 100%;
  }
}

/* Пояснения для тех, кто видит панель впервые. */
.field-hint { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 5px; padding: 0; border-radius: 50%; border: 1px solid currentColor; background: transparent; color: inherit; opacity: .6; font-size: 10px; font-weight: 700; line-height: 1; vertical-align: middle; cursor: pointer; }
.field-hint:hover, .field-hint:focus { opacity: 1; }
.hint-bubble { position: absolute; z-index: 50; max-width: 320px; padding: 10px 12px; border-radius: 10px; background: var(--navy); color: #fff; font-size: 12px; line-height: 1.5; font-weight: 400; box-shadow: 0 10px 30px rgba(16, 32, 48, .28); }
th .field-hint { border-color: rgba(255, 255, 255, .6); }
.formula-explainer { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.formula-explainer > summary { display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; font-weight: 600; font-size: 13px; list-style: none; }
.formula-explainer > summary:hover { background: rgba(22, 40, 55, .04); border-radius: 12px; }
.formula-explainer > summary::after { content: "▾"; margin-left: auto; font-size: 11px; opacity: .5; transition: transform .15s ease; }
.formula-explainer[open] > summary::after { transform: rotate(180deg); }
.formula-explainer > summary::-webkit-details-marker { display: none; }
.formula-explainer > summary::before { content: "?"; display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex: 0 0 16px; border: 1px solid currentColor; border-radius: 50%; font-size: 10px; opacity: .6; }
.formula-explainer[open] > summary { border-bottom: 1px solid var(--line); }
.formula-body { padding: 4px 16px 14px; font-size: 13px; line-height: 1.55; }
.formula-body p { margin: 10px 0; }
.formula-body ul { margin: 8px 0 8px 18px; }
.formula-body li { margin: 5px 0; }

/* Разбивка попадания по дням раскрывается под строкой версии. */
.hit-day td { background: #f7fafc; color: var(--muted); font-size: 12px; }
.hit-day td:first-child { padding-left: 26px; }

/* Управленческий светофор. В каждой ячейке под числом стоит подпись — процент
   выполнения или причина серого: цвет один недоступен части читателей. */
.traffic-table { max-height: 70vh; }
.traffic-matrix { min-width: 1180px; border-collapse: collapse; }
.traffic-matrix th, .traffic-matrix td { min-width: 132px; }
.traffic-matrix th[scope="row"] { min-width: 124px; }
/* Матрица из тринадцати столбцов не помещается в экран. При прокрутке
   вправо название пиццерии обязано остаться на месте — иначе непонятно,
   чья это строка. Тень отделяет закреплённый столбец от уезжающих. */
.traffic-matrix th[scope="row"] { position: sticky; left: 0; z-index: 2; background: var(--surface); color: var(--ink); font-size: 13.5px; font-weight: 700; text-align: left; white-space: nowrap; box-shadow: 1px 0 0 var(--line), 6px 0 8px -6px rgba(21, 40, 58, .18); }
.traffic-matrix tbody tr:nth-child(even) th[scope="row"] { background: #f8fafb; }
.traffic-matrix thead th:first-child { left: 0; z-index: 4; box-shadow: 1px 0 0 var(--line), 6px 0 8px -6px rgba(21, 40, 58, .18); }
.traffic-matrix thead th { position: sticky; top: 0; z-index: 3; background: #eef2f5; color: #3c4b58; font-size: 11.5px; font-weight: 700; line-height: 1.3; vertical-align: bottom; padding: 9px 12px; }
.traffic-matrix tr.traffic-network th[scope="row"], .traffic-matrix tr.traffic-network td { background: #eef3f7; }
.traffic-point-counts { display: block; color: var(--muted); font-size: 10.5px; line-height: 1.3; }
.traffic-other-period { display: block; color: var(--blue); font-size: 10.5px; line-height: 1.3; white-space: nowrap; }
.traffic-cell { vertical-align: top; padding: 11px 12px; border-left: 3px solid transparent; font-variant-numeric: tabular-nums; }
.traffic-cell strong { display: block; font-size: 18px; font-weight: 600; line-height: 1.2; letter-spacing: -.01em; }
.traffic-cell small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.traffic-cell small:first-of-type { color: #5b6977; }
/* Карточки вместо матрицы, когда выбрана одна пиццерия: сравнивать не с
   чем, а прокручивать тринадцать столбцов ради одной строки незачем. */
.table-wrap.as-cards { max-height: none; overflow: visible; border: 0; border-radius: 0; }
/* Автозаполнение давало рваный хвост: на широком экране двенадцать карточек
   вставали как 8 + 4. Фиксированное число колонок делит их ровно — 6+6, 4+4+4
   или 3+3+3+3 — и ряды выглядят рядами, а не остатком. */
.traffic-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 1180px) { .traffic-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1560px) { .traffic-cards { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 860px) { .traffic-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .traffic-cards { grid-template-columns: 1fr; } }
.traffic-card { border: 1px solid var(--line); border-left-width: 4px; border-radius: 12px; padding: 14px 16px; }
.traffic-card h3 { margin: 0 0 9px; font-size: 13px; font-weight: 700; line-height: 1.3; }
.traffic-card strong { display: block; font-size: 26px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.quarter-bars { position: relative; display: flex; align-items: flex-end; gap: 6px; height: 48px; margin: 10px 0 2px; }
.qbar { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; width: 26px; height: 100%; }
.qbar-fill { display: block; width: 100%; border-radius: 3px 3px 0 0; background: #b9c6d1; }
.qbar-worse .qbar-fill { background: #d98b83; }
.qbar-better .qbar-fill { background: #8fbf9f; }
.qbar-month { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
/* Линия цели — это ответ на «выше или ниже», поэтому она поверх столбиков,
   а не позади: иначе её не видно там, где столбик высокий. */
.qbar-target { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed #5b6977; }
/* Часовой ряд шире квартального вчетверо: четырнадцать столбиков по 26 пикселей
   не помещаются в карточку и вылезают за неё на ноутбуке. Здесь ширина делится
   на всех, а не задаётся каждому. */
.quarter-bars.hourly { gap: 3px; }
.quarter-bars.hourly .qbar { width: auto; flex: 1 1 auto; min-width: 18px; max-width: 30px; }
.quarter-bars.hourly .qbar-month { font-size: 10px; white-space: nowrap; }
/* Карточка с почасовым рядом шире обычной: четырнадцать столбиков читаемой
   ширины требуют около четырёхсот пикселей, и сжимать их некуда — час здесь
   единица разбора. Поэтому в ряд помещается меньше карточек, а не меньше
   часов. */
.traffic-cards.hourly { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 1280px) { .traffic-cards.hourly { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1800px) { .traffic-cards.hourly { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 760px) { .traffic-cards.hourly { grid-template-columns: 1fr; } }
.traffic-card-lines { display: flex; flex-direction: column; gap: 2px; margin-top: 9px; color: #5b6977; font-size: 12px; line-height: 1.4; }
.traffic-card-period { color: var(--blue); }
.traffic-card.traffic-no_fact strong, .traffic-card.traffic-no_target strong, .traffic-card.traffic-pending strong { color: var(--muted); }
/* Карточка диагностики — та же карточка дашборда, плюс место для ранга
   фокуса, ряда восьми недель и строки «Что проверить». */
.diagnostic-card { position: relative; }
.diagnostic-card .focus-rank { display: inline-block; margin-bottom: 6px; padding: 2px 8px; border-radius: 99px; background: rgba(16, 47, 73, .08); color: #1d3c56; font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.diagnostic-card-chart { margin: 8px 0 2px; }
.diagnostic-card-chart svg { display: block; width: 100%; height: 34px; }
.diagnostic-verdict { font-weight: 700; color: #42515e; }
.diagnostic-card .focus-action { margin-top: 10px; padding-top: 9px; border-top: 1px solid rgba(24, 80, 119, .14); }
.diagnostic-card .focus-action strong { display: block; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.diagnostic-card .focus-action p { margin: 4px 0 0; font-size: 12px; line-height: 1.45; }
/* Некрашеная ячейка: выручка и заказы внутри дня. Не серая — серое означает
   «нет данных», — а нейтральная: число есть, цвета у него быть не должно. */
.traffic-plain { background: var(--surface); border-left-color: var(--line); }
.traffic-green { background: var(--green-soft); border-left-color: var(--green); }
.traffic-yellow { background: var(--amber-soft); border-left-color: var(--amber); }
.traffic-red { background: var(--red-soft); border-left-color: var(--red); }
.traffic-no_fact, .traffic-no_target, .traffic-pending { background: #f4f6f8; color: var(--muted); border-left-color: var(--line); }
.traffic-network th[scope="row"], .traffic-network td { border-top: 2px solid var(--line); font-weight: 600; }
.traffic-kpi-green strong { color: var(--green); }
.traffic-kpi-yellow strong { color: var(--amber); }
.traffic-kpi-red strong { color: var(--red); }
.traffic-kpi-grey strong { color: var(--muted); }

/* «за 3 дн.» рядом с названием: без этой подписи итог за период неотличим от
   среднего за день, и цифра выглядит втрое больше без объяснения. */
.diagnostic-card h3 .card-period {
  font-weight: 500;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
