/* ==========================================================================
   CoolBrew Web — токены и базовые компоненты для веб-систем
   (dash.coolbrewco.ru, erp.coolbrewco.ru, маркетплейсы, СД).
   Источник истины: CoolBrew Design System (Claude Design), раздел «Web».
   Утверждено айдентикой 30.09.2026: знак, вордмарк, brand-orange, чёрный,
   белый, Geologica. Всё остальное — предложение системы (см. README).
   Версия 1 · 2026-10-05
   ========================================================================== */

/* ---- 1. Токены -------------------------------------------------------- */
:root, [data-theme="light"] {
  /* айдентика */
  --brand-orange: #D2451E;
  --on-orange: #FFFFFF;
  --ground: #FFFFFF;        /* фон страницы */
  --ink: #000000;           /* заголовки, основной текст */
  --black: #000000;
  --white: #FFFFFF;
  /* предложение системы — нейтрали */
  --ink-muted: #5C5C5C;     /* вторичный текст, подписи осей */
  --ink-faint: #8A8A8A;     /* плейсхолдеры, третичный текст */
  --ground-alt: #F3F3F3;    /* карточки и панели */
  --surface-sunken: #E7E7E7;/* поля ввода, неактивные pills внутри карточек */
  --line: #DADADA;          /* линейки таблиц, сетка графиков */
  --line-strong: #BDBDBD;   /* рамки контролов */
  --orange-soft: #FBE6DF;   /* плашки с оранжевым текстом */
  --orange-ink: #A8361A;    /* оранжевый текст мелким кеглем на светлом (4,5:1+) */
  /* статусы */
  --ok: #1E7A4E;      --ok-soft: #E1F2E8;
  --warn: #8F5B00;    --warn-soft: #F8EDD6;
  --bad: #B5382C;     --bad-soft: #F8E4E1;
  /* графики */
  --series-1: #D2451E; --series-2: #2458C8; --series-3: #0E9C8C;
  --series-4: #8A3FA8; --series-5: #A87A00; --series-6: #C2367A;
  --series-other: #9A9A9A;
  --year-current: #D2451E; --year-prev: #3A3A3A; --year-older: #BDBDBD;
  --chart-grid: #E4E4E4;
  --focus: #2458C8;
  /* форма */
  --radius-card: 24px; --radius-control: 12px; --radius-pill: 999px;
  --space-8: 8px; --space-12: 12px; --space-16: 16px; --space-24: 24px; --space-48: 48px;
  --font-sans: 'Geologica', 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --ground: #000000; --ink: #FFFFFF;
  --ink-muted: #A3A3A3; --ink-faint: #7A7A7A;
  --ground-alt: #161616; --surface-sunken: #242424;
  --line: #3A3A3A; --line-strong: #555555;
  --orange-soft: #2E1711; --orange-ink: #F08A66;
  --ok: #5BC48B; --ok-soft: #12291D;
  --warn: #E0A030; --warn-soft: #2E2410;
  --bad: #F08A7C; --bad-soft: #351A17;
  --series-1: #E8603A; --series-2: #5B8DF0; --series-3: #2FA8A0;
  --series-4: #B36AD4; --series-5: #B37F18; --series-6: #E05590;
  --series-other: #6B6B6B;
  --year-current: #E8603A; --year-prev: #D0D0D0; --year-older: #5A5A5A;
  --chart-grid: #262626;
  --focus: #5B8DF0;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #000000; --ink: #FFFFFF;
    --ink-muted: #A3A3A3; --ink-faint: #7A7A7A;
    --ground-alt: #161616; --surface-sunken: #242424;
    --line: #3A3A3A; --line-strong: #555555;
    --orange-soft: #2E1711; --orange-ink: #F08A66;
    --ok: #5BC48B; --ok-soft: #12291D;
    --warn: #E0A030; --warn-soft: #2E2410;
    --bad: #F08A7C; --bad-soft: #351A17;
    --series-1: #E8603A; --series-2: #5B8DF0; --series-3: #2FA8A0;
    --series-4: #B36AD4; --series-5: #B37F18; --series-6: #E05590;
    --series-other: #6B6B6B;
    --year-current: #E8603A; --year-prev: #D0D0D0; --year-older: #5A5A5A;
    --chart-grid: #262626;
    --focus: #5B8DF0;
    color-scheme: dark;
  }
}

/* ---- 2. База ---------------------------------------------------------- */
.cb-root, .cb-root * { box-sizing: border-box; }
.cb-root {
  margin: 0; font-family: var(--font-sans); font-size: 14px; line-height: 1.5;
  color: var(--ink); background: var(--ground);
  font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased;
}
.cb-root a { color: inherit; }
.cb-root :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { .cb-root * { transition: none !important; } }

/* типографика (классы = стили группы «Интерфейс» в tokens.json) */
.ui-h1 { font-size: 20px; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
.ui-h2 { font-size: 16px; line-height: 1.3; font-weight: 600; }
.ui-kpi { font-size: 28px; line-height: 1.05; font-weight: 600; letter-spacing: -0.01em; }
.ui-kpi-lg { font-size: 36px; line-height: 1; font-weight: 600; letter-spacing: -0.015em; }
.ui-body { font-size: 14px; line-height: 1.5; font-weight: 400; }
.ui-small { font-size: 12px; line-height: 1.4; font-weight: 400; }
.ui-label { font-size: 11px; line-height: 1.2; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); }

/* ---- 3. Оболочка и шапка --------------------------------------------- */
.cb-shell { max-width: 1500px; margin: 0 auto; padding: var(--space-16) var(--space-16) var(--space-24); }
.cb-topbar { --topbar-pad-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-16); flex-wrap: wrap; padding: var(--topbar-pad-top) 0 var(--space-16); }
.cb-brand { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1 1 0%; }
.cb-brand__logo { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; flex: none; }
.cb-brand__logo .cb-wordmark { display: block; height: 32px; width: auto; fill: currentColor; }
.cb-brand__divider { width: 1px; height: 36px; background: var(--line-strong); flex: none; }
.cb-brand__product { min-width: 0; overflow: hidden; flex: 1 1 0%; }
.cb-brand__product .ui-h1 { white-space: nowrap; }
.cb-brand__product .ui-small, .cb-brand__product .subtitle { color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-topbar__actions { display: flex; align-items: center; gap: var(--space-8); flex-wrap: wrap; flex: none; }
/* язычок — фирменный маркер-закладка: висит с верхнего края слева от вордмарка и выходит ниже шапки,
   при прокрутке едет вместе с закреплённой шапкой поверх контента. Единый размер для всех внутренних систем:
   ширина 56 px, высота 126 px (SVG обрезан по верху: viewBox от y=30), знак ≈47 px в нижней части — ниже строки вордмарка. */
.cb-tab { position: absolute; top: 0; left: var(--space-16); width: 56px; height: 126px; pointer-events: none; }
.cb-tab svg { width: 100%; height: 100%; display: block; }
/* шапка закреплена: переключатели метрик и сброс доступны при прокрутке */
.cb-topbar--sticky { position: sticky; top: 0; z-index: 20; background: var(--ground); border-bottom: 1px solid var(--line); margin: 0 calc(-1 * var(--space-16)); padding: var(--topbar-pad-top, 10px) var(--space-16) 10px; align-items: center; }
.cb-topbar--sticky .cb-brand__logo { padding-left: 68px; } /* место под язычок */

/* ---- 4. Карточки ------------------------------------------------------ */
.cb-card { background: var(--ground-alt); border-radius: var(--radius-card); padding: 20px 22px; min-width: 0; }
.cb-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-12); flex-wrap: wrap; margin-bottom: var(--space-12); }
.cb-card__hint { font-size: 12px; color: var(--ink-muted); }
.cb-grid { display: grid; gap: var(--space-16); margin-bottom: var(--space-16); }
.cb-grid > * { min-width: 0; }
.cb-grid--3 { grid-template-columns: repeat(3, 1fr); }
.cb-grid--2-1 { grid-template-columns: 2fr 1fr; }
.cb-grid--kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
@media (max-width: 980px) { .cb-grid--3, .cb-grid--2-1 { grid-template-columns: 1fr; } }

/* KPI-плитка: подпись → цифра → контекст */
.cb-kpi .ui-label { margin-bottom: 8px; display: block; }
.cb-kpi .ui-kpi, .cb-kpi .ui-kpi-lg { display: block; }
.cb-kpi__sub { font-size: 12px; color: var(--ink-muted); margin-top: 6px; }
.cb-kpi--accent .ui-kpi, .cb-kpi--accent .ui-kpi-lg { color: var(--brand-orange); }

/* бейджи изменения */
.cb-delta { display: inline-block; padding: 3px 10px; border-radius: var(--radius-pill); font-size: 11.5px; font-weight: 600; }
.cb-delta--up { background: var(--ok-soft); color: var(--ok); }
.cb-delta--down { background: var(--bad-soft); color: var(--bad); }
.cb-delta--note { background: var(--orange-soft); color: var(--orange-ink); }

/* ---- 5. Контролы ------------------------------------------------------ */
.cb-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.cb-pill { padding: 6px 12px; border-radius: var(--radius-pill); background: var(--ground); color: var(--ink); border: 1px solid transparent;
  font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; user-select: none; white-space: nowrap; transition: background .12s, color .12s; }
.cb-pill:hover { background: var(--surface-sunken); }
.cb-pill[aria-pressed="true"], .cb-pill.is-active { background: var(--ink); color: var(--ground); }
.cb-seg { display: inline-flex; background: var(--ground-alt); border-radius: var(--radius-pill); padding: 4px; }
.cb-seg button { font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); background: transparent; border: 0; padding: 7px 14px; border-radius: var(--radius-pill); cursor: pointer; }
.cb-seg button:hover { background: var(--surface-sunken); }
.cb-seg button[aria-pressed="true"], .cb-seg button.is-active { background: var(--ink); color: var(--ground); }
.cb-btn { font: inherit; font-size: 13px; font-weight: 600; padding: 9px 16px; border-radius: var(--radius-pill); border: 1.5px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; }
.cb-btn:hover { background: var(--ink); color: var(--ground); }
.cb-btn--primary { background: var(--brand-orange); border-color: var(--brand-orange); color: var(--on-orange); }
.cb-btn--primary:hover { background: #B83B19; border-color: #B83B19; color: var(--on-orange); }
.cb-btn--ghost { border-color: var(--line-strong); color: var(--ink-muted); }
.cb-btn--ghost:hover { background: var(--ground-alt); color: var(--ink); }
.cb-btn--icon { width: 38px; height: 38px; padding: 0; display: inline-grid; place-items: center; }
.cb-input { font: inherit; font-size: 13px; color: var(--ink); background: var(--ground); border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 9px 14px; width: 100%; }
.cb-input::placeholder { color: var(--ink-faint); }
.cb-input:focus { outline: none; border-color: var(--brand-orange); }
.cb-filter-group { display: flex; flex-direction: column; gap: 7px; min-width: 160px; flex: 1; }
.cb-filter-row { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; margin-bottom: var(--space-12); }
.cb-filter-row:last-child { margin-bottom: 0; }
.cb-more { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
.cb-more summary { list-style: none; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--ink-muted); display: inline-flex; align-items: center; gap: 6px; padding: 4px 0; }
.cb-more summary::-webkit-details-marker { display: none; }
.cb-more summary::after { content: ''; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); margin-top: -3px; transition: transform .12s; }
.cb-more[open] summary::after { transform: rotate(-135deg); margin-top: 3px; }
.cb-more .cb-filter-row { margin-top: 10px; }

/* табы */
.cb-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: var(--space-12); }
.cb-tab-btn { font: inherit; font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: var(--radius-pill); background: var(--ground); color: var(--ink-muted); border: 0; cursor: pointer; }
.cb-tab-btn:hover { color: var(--ink); background: var(--surface-sunken); }
.cb-tab-btn[aria-selected="true"], .cb-tab-btn.is-active { background: var(--ink); color: var(--ground); }

/* ---- 6. Таблица ------------------------------------------------------- */
.cb-table-wrap { overflow: auto; max-height: 520px; }
.cb-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cb-table th { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); color: var(--ink-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; position: sticky; top: 0; background: var(--ground-alt); cursor: pointer; user-select: none; }
.cb-table th:hover { color: var(--ink); }
.cb-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.cb-table .right { text-align: right; white-space: nowrap; }
.cb-table tr:hover td { background: var(--surface-sunken); }

/* ---- 7. Графики (Chart.js и любые canvas/svg) ------------------------- */
.cb-chart { position: relative; height: 300px; }
.cb-chart--tall { height: 380px; }
.cb-legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* ---- 8. Подвал -------------------------------------------------------- */
.cb-foot { font-size: 11.5px; color: var(--ink-muted); text-align: center; padding: var(--space-16) var(--space-16) 0; }
