/* ROSSVIK · общее ядро дизайна для ВСЕХ сервисов markettools.su: токены, фон, стекло, шапка, кнопки, подсказки,
   кнопка «наверх», доступность, адаптив и печать. Источник — сервис «Прогноз закупок»
   (src/rossvik_forecast/web/static/css/app.css); этот файл собирается из его общих разделов.
   Подключайте его первым, стили своего сервиса — отдельным файлом после него. Ядро в отдельном сервисе не правят:
   изменения вносятся в docs/platform/ и обновляются во всех сервисах.
   Никаких внешних шрифтов и библиотек: сервер работает в закрытом контуре. Строгая политика безопасности
   (CSP): в разметке нет и не должно быть style="…", размеры из данных задаются в JS через data-атрибуты. */

:root {
  --navy: #1d2b4d;
  --navy-2: #2a3b63;
  /* Цвета подобраны под контраст WCAG AA (≥4.5:1) для текста на стекле и на цветных плашках. */
  --blue: #1671ae;
  --blue-bright: #2b95dd;
  --green: #17774e;
  --orange: #f39625;
  --orange-text: #7a4500;
  --red: #b82c2c;
  --text: #1d2b4d;
  --muted: #465064;
  --line: rgba(29, 43, 77, 0.14);
  --glass: rgba(255, 255, 255, 0.88);
  --glass-border: rgba(255, 255, 255, 0.65);
  --cell-bg: #eef1f6;      /* сплошной фон ячеек: нужен липким столбцам и шапке, иначе под ними просвечивает текст */
  --head-bg: #e3e9f2;
  --radius: 22px;
  --shadow: 0 12px 40px rgba(8, 16, 40, 0.28);
  --font: Arial, "Helvetica Neue", system-ui, -apple-system, "Segoe UI", sans-serif;
  --page-w: 1180px;
  --topbar-h: 64px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --tap: 44px;             /* минимальная цель касания */
}
@media (min-width: 1600px) { :root { --page-w: 1480px; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: #1d2b4d; overflow-x: clip; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  overflow-x: clip;
  font-family: var(--font);
  font-size: clamp(15px, 0.9rem + 0.2vw, 17px);
  color: var(--text);
  line-height: 1.5;
  overflow-wrap: break-word;
  display: flex; flex-direction: column;
}
main { flex: 1 0 auto; }
img, svg { max-width: 100%; }

/* ---------- фон: фирменный знак ROSSVIK, слегка размытый, как под стеклом ---------- */
/* Слой на весь экран (position: fixed). Не «background-attachment: fixed»: его не поддерживает Safari на iPhone.
   Картинка лежит рядом: static/img/rossvik-background.svg (исходник — docs/platform/rossvik-background.svg). */
.backdrop {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: #1d2b4d url("../img/rossvik-background.svg") center / cover no-repeat;
}
.blob { display: none; } /* старые «флажки» из прежней разметки больше не рисуются */

/* Только для чтения с экрана */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* «Перейти к содержимому»: появляется при первом нажатии Tab */
.skip-link {
  position: fixed; left: 12px; top: 12px; z-index: 100; padding: 12px 18px; border-radius: 12px;
  background: #fff; color: var(--navy); font-weight: 700; text-decoration: none; box-shadow: var(--shadow);
  clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap;
}
.skip-link:focus { clip-path: none; width: auto; height: auto; top: calc(12px + var(--safe-t)); }

/* ---------- стекло ---------- */
.glass, .glass-dark {
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(26px) saturate(170%);
  backdrop-filter: blur(26px) saturate(170%);
}
.glass { background: var(--glass); padding: clamp(16px, 3vw, 28px); margin: 0 0 20px; }
.glass-dark { background: rgba(20, 30, 58, 0.72); border-color: rgba(255, 255, 255, 0.16); color: #fff; }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: #f4f6fa; }
  .glass-dark { background: #1d2b4d; }
}

/* ---------- верхняя панель ---------- */
.topbar {
  position: sticky; top: calc(12px + var(--safe-t)); z-index: 10;
  max-width: var(--page-w); margin: calc(12px + var(--safe-t)) auto 0;
  width: calc(100% - 24px - var(--safe-l) - var(--safe-r));
  min-height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap;
  padding: 6px 20px; border-radius: 999px;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; min-height: var(--tap); }
.brand img { display: block; height: auto; }
.brand-logo { display: flex; align-items: center; min-height: var(--tap); color: #fff; text-decoration: none; }
a.brand-sub { text-decoration: none; display: flex; align-items: center; min-height: var(--tap); }
a.brand-sub:hover { color: #fff; text-decoration: underline; }
.brand-sub { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(255,255,255,.85); border-left: 1px solid rgba(255,255,255,.3); padding-left: 12px; }
.nav { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; justify-content: flex-end; }
.nav-link {
  color: #fff; text-decoration: none; font-size: 15px;
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 8px; border-radius: 12px;
}
.nav-link:hover { text-decoration: underline; }
.user { font-size: 14px; color: rgba(255,255,255,.85); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline { display: inline; margin: 0; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--blue); cursor: pointer; text-decoration: none; }
.nav .linklike { color: #fff; font-size: 15px; }
.linklike:hover { text-decoration: underline; }
a.linklike { display: inline-flex; align-items: center; min-height: var(--tap); }

.page {
  max-width: var(--page-w); margin: 24px auto 0;
  padding: 0 calc(12px + var(--safe-r)) 0 calc(12px + var(--safe-l));
  width: 100%; scroll-margin-top: 90px;
}
.page:focus { outline: none; }
.footer { text-align: center; color: rgba(255,255,255,.8); font-size: 13px; padding: 28px 12px calc(36px + var(--safe-b)); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 6px; flex-wrap: wrap; color: #fff; text-shadow: 0 1px 10px rgba(8,16,40,.45); }
.page-head h1 { margin: 0; font-size: clamp(1.45rem, 1.1rem + 1.6vw, 1.9rem); line-height: 1.2; }
.page > .muted, .page > .page-head + .muted { color: rgba(255,255,255,.88); text-shadow: 0 1px 8px rgba(8,16,40,.45); }

h1, h2 { margin: 0 0 8px; line-height: 1.25; }
h1 { font-size: clamp(1.45rem, 1.1rem + 1.6vw, 1.9rem); }
h2 { font-size: clamp(1.1rem, 1rem + 0.7vw, 1.35rem); }
.lead { font-size: 1.0625rem; color: var(--muted); margin: 4px 0 18px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.narrow { max-width: 620px; margin-left: auto; margin-right: auto; }
.right { text-align: right; }
.pre { white-space: pre-line; margin: 6px 0 0; }
.pad { padding: clamp(16px, 3vw, 24px) clamp(16px, 3vw, 28px) 0; }
.text-red { color: var(--red); font-weight: 700; }
.big-code { font-size: clamp(56px, 18vw, 72px); font-weight: 700; color: var(--blue); line-height: 1; margin: 0 0 8px; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 22px; border-radius: 999px; border: 1px solid transparent; cursor: pointer;
  font: 700 16px var(--font); color: #fff; text-decoration: none; text-align: center;
  background: linear-gradient(180deg, #1f7fc0, #145f95);
  box-shadow: 0 6px 18px rgba(20, 95, 149, 0.4), inset 0 1px 0 rgba(255,255,255,.3);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .65; cursor: progress; }
.btn-large { min-height: 52px; padding: 14px 30px; font-size: 17px; }
.btn-small { padding: 8px 16px; font-size: 15px; }
.btn-secondary { background: rgba(255,255,255,.92); color: var(--navy); border-color: rgba(29,43,77,.25); box-shadow: 0 4px 14px rgba(8,16,40,.15); }
.btn-light { background: rgba(255,255,255,.95); color: var(--navy); box-shadow: none; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.glass-dark :focus-visible, .page-head :focus-visible { outline-color: #ffd08a; }

/* ---------- всплывающие подсказки: текст лежит в data-tip, положение и открытие по касанию — в app.js ---------- */
.tip { position: relative; cursor: help; border-bottom: 1px dotted var(--muted); display: inline-block; }
.tip::after {
  content: attr(data-tip); display: none; position: absolute; left: var(--tip-x, 0px); bottom: calc(100% + 8px); z-index: 20;
  box-sizing: border-box; width: max-content; max-width: min(340px, calc(100vw - 24px)); padding: 10px 14px; border-radius: 12px;
  background: var(--navy); color: #fff; font-size: 14px; font-weight: 400; line-height: 1.4; text-align: left; white-space: normal;
  box-shadow: var(--shadow); pointer-events: none; text-transform: none; letter-spacing: 0;
}
.tip[data-below]::after { bottom: auto; top: calc(100% + 8px); }
.tip:hover::after, .tip:focus::after, .tip.is-open::after { display: block; animation: tip-in .15s ease-out; }
@keyframes tip-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.row-best > td { background-color: #d3ecdf; font-weight: 700; }
.table-scroll:has(.models) { overflow: visible; }
.tip:focus-visible { outline-offset: 3px; }

/* ---------- кнопка «наверх» ---------- */
.to-top {
  position: fixed; right: calc(16px + var(--safe-r)); bottom: calc(16px + var(--safe-b)); z-index: 30;
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid rgba(255,255,255,.4); cursor: pointer;
  background: rgba(20,30,58,.9); color: #fff; font: 700 22px/1 var(--font); box-shadow: var(--shadow);
  display: grid; place-items: center;
}
.to-top[hidden] { display: none; }
.to-top:focus-visible { outline-color: #ffd08a; }


/* ---------- общие правила адаптива, доступности и печати ---------- */
@media (max-width: 900px) {
  .topbar { border-radius: 28px; }
  .brand-sub { display: none; }
}
@media (max-width: 720px) {
  :root { --topbar-h: 0px; }
  .glass { padding: 20px 16px; border-radius: 20px; }
  .page-head h1 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media (prefers-contrast: more) {
  :root { --glass: #fff; --muted: #2c3547; --line: rgba(29,43,77,.45); }
  .glass, .glass-dark { -webkit-backdrop-filter: none; backdrop-filter: none; border-color: var(--navy); }
  .glass-dark { background: #101a33; }
}
@media (forced-colors: active) {
  .backdrop { display: none; }
  .glass, .glass-dark, .topbar { border: 1px solid CanvasText; background: Canvas; color: CanvasText; }
  .btn { border: 2px solid ButtonText; background: ButtonFace; color: ButtonText; box-shadow: none; }
  .tip::after { border: 1px solid CanvasText; background: Canvas; color: CanvasText; }
}
@media print {
  @page { margin: 12mm; }
  html, body { background: #fff !important; display: block; min-height: 0; }
  body { color: #000; }
  .backdrop, .topbar, .footer, .btn, .to-top, .skip-link { display: none !important; }
  .page { max-width: none; padding: 0; margin: 0; }
  .glass { box-shadow: none; background: #fff; border: 1px solid #bbb; border-radius: 8px; backdrop-filter: none; -webkit-backdrop-filter: none; }
}
