/* АИС Flux. Цвета взяты из логотипа: фиолетовый — основной акцент,
   полный градиент логотипа (оранжевый, малиновый, фиолетовый, голубой) — только
   подчёркивание активной вкладки ленты. */

:root {
  --bg: #F6F6F9;
  --surface: #FFFFFF;
  --surface-2: #F0EFF5;
  --ink: #17161C;
  --muted: #6B6878;
  --line: #E4E2EA;
  --accent: #5B2BD6;
  --accent-ink: #FFFFFF;
  --accent-soft: #EEE8FD;
  --danger: #C4314B;
  --danger-soft: #FDECEF;
  --ok: #1E7F4F;
  --shadow: 0 12px 32px rgba(23, 22, 28, 0.12), 0 2px 6px rgba(23, 22, 28, 0.06);
  --flux: linear-gradient(90deg, #FF9A1F 0%, #F2357A 38%, #7B3FE4 70%, #2FA8FF 100%);
  --font: "Onest", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #121118;
  --surface: #1B1A23;
  --surface-2: #24222E;
  --ink: #F1EFF6;
  --muted: #A29EB2;
  --line: #2C2A37;
  --accent: #9C7BFF;
  --accent-ink: #120B26;
  --accent-soft: #2A2342;
  --danger: #FF6B85;
  --danger-soft: #3A1E26;
  --ok: #5ED39A;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: "tnum" 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

h1 { font-size: 28px; line-height: 1.2; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0; }

.boot { padding: 48px 24px; color: var(--muted); }
.muted { color: var(--muted); }

/* ---------- кнопки и поля ---------- */

button { font: inherit; color: inherit; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-wide { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

input {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; height: 42px; padding: 0 12px; width: 100%;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--muted); }

/* ---------- вход ---------- */

.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; position: relative;
}
.login-theme { position: absolute; top: 16px; right: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-logo { display: block; width: 132px; height: auto; margin: 0 auto 24px; }
.login-title { font-size: 22px; text-align: center; margin-bottom: 24px; }
.login-form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 14px; font-weight: 550; }
.field-hint { margin: 0; font-size: 13px; color: var(--muted); }
#f-code { letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }
.form-error {
  margin: 0; padding: 10px 12px; border-radius: 8px;
  background: var(--danger-soft); color: var(--danger); font-size: 14px;
}

/* ---------- шапка ---------- */

.topbar {
  height: 64px; display: flex; align-items: center; gap: 16px;
  padding: 0 24px; background: var(--surface);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-emblem { height: 32px; width: auto; display: block; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.env-badge {
  font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 6px;
  background: #FFF1D6; color: #8A5300;
}
:root[data-theme="dark"] .env-badge { background: #3A2B10; color: #FFC266; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-chip { display: grid; text-align: right; line-height: 1.2; margin-right: 8px; }
.user-login { font-weight: 600; font-size: 14px; }
.user-role { font-size: 12px; color: var(--muted); }

/* ---------- лента вкладок ---------- */

.ribbon {
  background: var(--surface); border-bottom: 1px solid var(--line); border-top: 1px solid var(--line);
  padding: 0 16px; position: relative; z-index: 20;
}
.ribbon-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; }
.ribbon-item { position: relative; display: flex; align-items: center; }
.tab {
  display: block; padding: 14px 12px 13px; color: var(--muted); font-weight: 600; font-size: 15px;
  position: relative;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab[aria-current="page"] { color: var(--ink); }
.tab::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px;
  border-radius: 3px 3px 0 0; background: var(--flux); transform: scaleX(0); transform-origin: left;
  transition: transform 0.2s ease;
}
.tab[aria-current="page"]::after { transform: scaleX(1); }
.has-menu .tab { padding-right: 2px; }
.has-menu .tab::after { right: -22px; }
.tab-caret {
  display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: 6px;
  border: 0; background: transparent; color: var(--muted); border-radius: 6px; cursor: pointer;
}
.tab-caret svg { transition: transform 0.15s ease; }
.menu-open .tab-caret { color: var(--ink); }
.menu-open .tab-caret svg { transform: rotate(180deg); }

/* выпадающий список товаров */
.menu-panel {
  position: absolute; top: calc(100% + 1px); left: 0; width: 400px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: min(480px, 70vh);
}
.menu-panel[hidden] { display: none; }
.menu-search-wrap {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--muted);
}
.menu-search { border: 0; height: 32px; padding: 0; background: transparent; }
.menu-search:focus { box-shadow: none; }
.menu-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.menu-item {
  display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 8px; color: var(--ink);
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); text-decoration: none; outline: none; }
.thumb { flex: none; width: 40px; height: 40px; border-radius: 6px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-fallback { display: grid; place-items: center; color: var(--muted); background: var(--surface-2); border-radius: 6px; flex: none; }
.menu-text { display: grid; min-width: 0; }
.menu-name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.menu-empty { padding: 16px 10px; color: var(--muted); font-size: 14px; }
.menu-footer { padding: 10px 14px; border-top: 1px solid var(--line); font-weight: 600; font-size: 14px; }

/* ---------- раскладка ---------- */

.layout {
  max-width: 1440px; margin: 0 auto; padding: 32px 24px 48px;
  display: grid; grid-template-columns: minmax(0, 1fr) 264px; gap: 32px; align-items: start;
}
/* ТЗ v2: в карточке товара слева — сайдбар разделов товара, справа — сайдбар вкладки. */
.layout.has-left { grid-template-columns: 220px minmax(0, 1fr) 264px; }
.content:focus { outline: none; }
.content[aria-busy="true"] { opacity: 0.6; transition: opacity 0.2s 0.15s; }

.sidebar {
  position: sticky; top: 24px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 12px;
}
.sidebar-title { padding: 0 8px 10px; color: var(--muted); font-size: 13px; font-weight: 600; }
.sidebar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.side-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 8px; border-radius: 8px;
  border: 0; background: transparent; color: var(--ink); font-weight: 550; font-size: 15px; text-align: left; cursor: pointer;
}
.side-btn svg { color: var(--muted); flex: none; }
.side-btn:hover { background: var(--surface-2); text-decoration: none; }
.side-btn[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.side-btn[aria-current="page"] svg { color: var(--accent); }
.side-btn:disabled { opacity: 0.6; cursor: progress; }
.side-msg { margin: 2px 8px 6px 36px; font-size: 13px; color: var(--muted); }
.side-msg:empty { display: none; }
.sidebar-note { margin: 8px 8px 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

/* ---------- страницы ---------- */

.page { display: grid; gap: 24px; }
.page-head { display: grid; gap: 6px; }
.lead { margin: 0; color: var(--muted); }

.facts { display: flex; flex-wrap: wrap; gap: 16px 56px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.fact { display: grid; gap: 2px; }
.fact-value { font-size: 40px; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.fact-value-sm { font-size: 24px; line-height: 1.6; }
.fact-label { color: var(--muted); font-size: 14px; }

.sections { display: grid; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.section-link {
  display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; column-gap: 14px;
  padding: 16px 18px; color: var(--ink);
}
.section-link + .section-link { border-top: 1px solid var(--line); }
.section-link:hover { background: var(--surface-2); text-decoration: none; }
.section-icon { grid-row: span 2; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.section-title { font-weight: 650; }
.section-text { color: var(--muted); font-size: 14px; }

.notice { margin: 0; padding: 12px 14px; border-radius: 8px; background: var(--surface-2); font-size: 14px; max-width: 72ch; }
.notice-error { background: var(--danger-soft); color: var(--danger); }

.empty {
  display: grid; justify-items: start; gap: 4px; padding: 28px; border: 1px dashed var(--line);
  border-radius: var(--radius); color: var(--ink);
}
.empty svg { color: var(--muted); margin-bottom: 8px; }
.empty p { margin: 0; max-width: 60ch; }

.table-filter { max-width: 420px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-product { min-width: 260px; }
.product-link { display: flex; align-items: center; gap: 12px; color: var(--ink); font-weight: 550; }
.pthumb { flex: none; border-radius: 6px; object-fit: cover; background: var(--surface-2); }
.pthumb-empty { display: grid; place-items: center; color: var(--muted); }

.back-link { font-size: 14px; font-weight: 600; }
.product-head { display: flex; gap: 20px; align-items: center; }
.product-head h1 { font-size: 24px; }
.props { display: grid; grid-template-columns: max-content 1fr; gap: 10px 32px; margin: 0; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); max-width: 640px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; font-variant-numeric: tabular-nums; }
.ext-link { font-weight: 600; }
.page-part { display: grid; gap: 12px; }
.eyebrow { margin: 0 0 2px; color: var(--muted); font-size: 14px; font-weight: 550; }
.small { font-size: 13px; margin: 0; }
.table tfoot th, .table tfoot td { border-top: 1px solid var(--line); font-weight: 650; color: var(--ink); padding: 10px 14px; }

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

/* Три колонки не помещаются: сайдбар вкладки уходит под содержимое. */
@media (max-width: 1180px) {
  .layout.has-left { grid-template-columns: 200px minmax(0, 1fr); }
  .layout.has-left .sidebar-right { grid-column: 2; position: static; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 20px 16px 40px; gap: 20px; }
  .sidebar { position: static; order: -1; }
  .layout.has-left { grid-template-columns: 1fr; }
  .layout.has-left .sidebar-right { grid-column: auto; order: -2; }
  /* Разделы товара на телефоне — строка кнопок над содержимым. */
  .sidebar-left { padding: 8px; }
  .sidebar-left .sidebar-title { display: none; }
  .sidebar-left .sidebar-list { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; }
  .sidebar-left .side-btn { white-space: nowrap; }
  .topbar { padding: 0 16px; }
  .user-chip { display: none; }
  .ribbon { padding: 0 4px; }
  .ribbon-item.has-menu { position: static; }
  .menu-panel { left: 12px; right: 12px; width: auto; max-width: none; border-radius: var(--radius); max-height: 60vh; }
  .fact-value { font-size: 32px; }
  h1 { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
