/* ============================================================
   OZON Agent — общая тема для нового UI (v3)

   Подключается во всех новых страницах через _base.html.
   Цветовая логика и плотность вдохновлены приложенным отчётом
   (Manrope + Geist Mono, ровные карточки, седые границы, акцент — фирменный синий).
   ============================================================ */

:root {
  /* Алиасы для обратной совместимости → tokens.css */
  --bg:        var(--c-bg);
  --panel:     var(--c-panel);
  --ink:       var(--c-ink);
  --ink-soft:  var(--c-ink-soft);
  --muted:     var(--c-muted);
  --line:      var(--c-line);
  --line-soft: var(--c-line-soft);

  --blue:    var(--c-blue);
  --blue-d:  var(--c-blue-hover);
  --green:   var(--c-green);
  --red:     var(--c-red);
  --orange:  var(--c-orange);
  --violet:  var(--c-violet);
  --teal:    var(--c-teal);
  --yellow:  var(--c-yellow);

  --bg-good:  var(--c-green-bg);
  --bg-bad:   var(--c-red-bg);
  --bg-warn:  var(--c-orange-bg);
  --bg-info:  var(--c-blue-bg);

  /* тени: theme-aliases ↔ tokens */
  /* --shadow-sm, --shadow-md, --shadow-lg определены в tokens.css */
  --shadow: var(--shadow-md);

  --radius-sm: var(--r-sm);
  --radius:    var(--r-md);
  --radius-lg: var(--r-lg);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ff-body);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-d); }

button, input, select, textarea { font: inherit; color: inherit; }

/* Global focus-visible ring for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 91, 255, .12);
}

/* Smooth scrolling */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ============================================================
   Layout: sidebar + content
   ============================================================ */

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

.sidebar {
  background: linear-gradient(180deg, #fbfdff 0%, #ffffff 100%);
  border-right: 1px solid var(--line);
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px 18px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 12px;
}
.sidebar .brand-mark {
  width: 36px; height: 36px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(37, 99, 235, .12), rgba(59, 130, 246, .06));
  color: var(--blue);
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
  border: 1px solid rgba(37, 99, 235, .12);
}
.sidebar .brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .01em;
}
.sidebar .brand-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}
.sidebar .nav-group {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: 16px 10px 8px;
}
.sidebar a.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--ink-soft);
  font-weight: 500;
  transition: background .15s, color .15s, border-color .15s;
  position: relative;
  border: 1px solid transparent;
}
.sidebar a.nav-link:hover {
  background: rgba(241, 245, 249, .78);
  color: var(--ink);
}
.sidebar a.nav-link.active {
  background: rgba(37, 99, 235, .08);
  color: var(--blue);
  border-color: rgba(37, 99, 235, .08);
}
.sidebar a.nav-link.active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 999px;
  background: var(--blue);
}
.sidebar a.nav-link .nav-icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  color: currentColor;
  flex-shrink: 0;
}
.sidebar .footer,
.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-footer .text-xs:first-child::before {
  content: "•";
  color: #22c55e;
  margin-right: 4px;
}
.nav-divider {
  border: none;
  border-top: 1px solid var(--line-soft);
  margin: 8px 0;
}
.text-xs { font-size: 11px; }

/* ---- Глобальный store-switcher в шапке ---- */
.topbar-store-switcher {
  position: relative;
  display: flex;
  align-items: center;
}
.topbar-store-switcher .tss-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line, #e2e8f0);
  background: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink, #0f172a);
  cursor: pointer;
  max-width: 260px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.topbar-store-switcher .tss-trigger:hover:not(:disabled) {
  border-color: var(--blue, #2563eb);
  background: #f8fafc;
}
.topbar-store-switcher .tss-trigger:focus-visible {
  outline: none;
  border-color: var(--blue, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .18);
}
.topbar-store-switcher .tss-trigger:disabled { opacity: .55; cursor: not-allowed; }
.topbar-store-switcher .tss-trigger[aria-expanded="true"] {
  border-color: var(--blue, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}
.topbar-store-switcher .tss-icon {
  display: inline-flex;
  color: var(--muted, #64748b);
}
.topbar-store-switcher .tss-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-store-switcher .tss-caret {
  display: inline-flex;
  color: var(--muted, #64748b);
  transition: transform .15s ease;
}
.topbar-store-switcher .tss-trigger[aria-expanded="true"] .tss-caret { transform: rotate(180deg); }
.topbar-store-switcher .tss-demo { font-size: 10px; padding: 1px 6px; }
.topbar-store-switcher .tss-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  max-width: 320px;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .12), 0 2px 6px rgba(15, 23, 42, .06);
  z-index: 60;
}
.topbar-store-switcher .tss-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  color: var(--ink, #0f172a);
  cursor: pointer;
  text-align: left;
  transition: background .12s ease;
}
.topbar-store-switcher .tss-item:hover { background: #f1f5f9; }
.topbar-store-switcher .tss-item.is-active { background: rgba(37, 99, 235, .08); color: var(--blue, #2563eb); font-weight: 600; }
.topbar-store-switcher .tss-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-store-switcher .tss-check { color: var(--blue, #2563eb); }
.topbar-store-switcher .tss-empty { padding: 10px; color: var(--muted, #64748b); font-size: 12px; text-align: center; }

/* ---- Кнопка сворачивания сайдбара ---- */
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  margin-top: 8px;
  text-align: left;
}
.sidebar-collapse-btn:hover { background: rgba(241, 245, 249, .78); color: var(--ink); }
.sidebar-collapse-btn .nav-icon {
  width: 18px; height: 18px; display: inline-grid; place-items: center; flex-shrink: 0;
}

/* ---- Свернутое состояние сайдбара (только на десктопе ≥ 961px) ---- */
@media (min-width: 961px) {
  .app.sidebar-collapsed { grid-template-columns: 68px minmax(0, 1fr); }
  .app.sidebar-collapsed .sidebar { padding: 20px 8px; }
  .app.sidebar-collapsed .sidebar .brand { gap: 0; padding: 0 0 18px; justify-content: center; }
  .app.sidebar-collapsed .sidebar .brand-text { display: none; }
  .app.sidebar-collapsed .sidebar a.nav-link {
    justify-content: center;
    padding: 10px 0;
  }
  .app.sidebar-collapsed .sidebar a.nav-link.active::before { left: -8px; }
  .app.sidebar-collapsed .sidebar .nav-text { display: none; }
  .app.sidebar-collapsed .sidebar-collapse-btn { justify-content: center; padding: 8px 0; }
  .app.sidebar-collapsed .sidebar-footer { align-items: center; padding-top: 8px; }
  .app.sidebar-collapsed .sidebar-footer .text-xs { font-size: 9px; display: inline-block; opacity: .7; }
  .app.sidebar-collapsed .sidebar-footer .nav-text { display: none; }
}

.content {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 var(--line, transparent), 0 4px 12px -8px rgba(15,23,42,.08);
  padding: 10px 24px;
  height: var(--header-h);
}
.topbar-inner {
  width: 100%;
  max-width: 1480px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar .page-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}
.topbar .spacer { flex: 1; }
.topbar .account-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 4px 4px;
  border: 1px solid rgba(210, 221, 236, .88);
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 6px 16px rgba(148, 163, 184, .08);
}
.topbar .user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: 13px;
  color: var(--ink-soft);
}
.topbar .user-chip .avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 700;
}
.topbar .user-chip .user-role {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}
.topbar .account-logout {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background .16s ease, color .16s ease;
}
.topbar .account-logout:hover {
  background: rgba(37, 99, 235, .08);
  color: var(--blue);
}

.shell {
  padding: 22px 24px;
  max-width: 1480px;
  width: 100%;
}

/* ============================================================
   Универсальная store-bar (выбор магазина)
   ============================================================ */

.store-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.store-pill {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .15s;
}
.store-pill:hover { border-color: var(--blue); color: var(--blue); }
.store-pill.active {
  background: var(--bg-info);
  border-color: var(--blue);
  color: var(--blue);
  font-weight: 600;
}

/* ============================================================
   Карточки и секции
   ============================================================ */

.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  overflow: hidden;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.section-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.section-head .hint { color: var(--muted); font-size: 12px; }
.section-body { padding: 16px 18px; }

/* KPI-плитки */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 4px;
  height: 100%;
  background: var(--accent, var(--blue));
}
.kpi .kpi-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.kpi .kpi-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  margin-top: 8px;
  line-height: 1.1;
}
.kpi .kpi-sub {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

/* Bridge — горизонтальный финансовый мост */
.bridge {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.bridge-step {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  position: relative;
  box-shadow: var(--shadow-sm);
  min-height: 86px;
}
.bridge-step::before {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 4px;
  height: 100%;
  background: var(--accent, var(--muted));
}
.bridge-step.positive { --accent: var(--green); }
.bridge-step.negative { --accent: var(--red); }
.bridge-step.subtotal { --accent: var(--violet); }
.bridge-step.total    { --accent: var(--blue); }
.bridge-step .b-label {
  font-size: 12px;
  color: var(--muted);
}
.bridge-step .b-value {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}
.bridge-step.negative .b-value { color: var(--red); }
.bridge-step.positive .b-value { color: var(--green); }
.bridge-step.subtotal .b-value { color: var(--violet); }
.bridge-step.total .b-value { color: var(--blue); }
.bridge-step .b-note {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

/* Periods — кнопки селектора периода */
.periods {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.period-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .15s;
}
.period-btn:hover { border-color: var(--blue); color: var(--blue); }
.period-btn.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 600;
}

/* Action-tiles — операционные проблемы */
.actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.action-tile {
  border: 1px solid var(--line);
  background: #fbfdff;
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  text-align: left;
  transition: all .15s;
  position: relative;
  overflow: hidden;
}
.action-tile:hover { border-color: var(--blue); }
.action-tile.active {
  border-color: var(--blue);
  background: var(--bg-info);
}
.action-tile.severity-high { border-left: 4px solid var(--red); }
.action-tile.severity-medium { border-left: 4px solid var(--orange); }
.action-tile.severity-low { border-left: 4px solid var(--muted); }
.action-tile .a-count {
  font-size: 24px;
  font-weight: 700;
  display: block;
}
.action-tile .a-title {
  display: block;
  margin-top: 4px;
  font-weight: 600;
  font-size: 13px;
}
.action-tile .a-desc {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

/* Pill — мини-индикатор */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  background: var(--bg-info);
  color: var(--ink-soft);
  font-weight: 500;
  white-space: nowrap;
}
.pill.good { background: var(--bg-good); color: var(--green); }
.pill.bad  { background: var(--bg-bad);  color: var(--red); }
.pill.warn { background: var(--bg-warn); color: var(--orange); }
.pill.info { background: var(--bg-info); color: var(--blue); }

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

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(auto-fit, minmax(150px, 200px));
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.controls input, .controls select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--panel);
}
.controls input:focus, .controls select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 91, 255, .12);
}

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
}
table.data th, table.data td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  font-size: 13px;
}
table.data th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
  background: #fafcfe;
  position: sticky;
  top: 0;
}
table.data tbody tr { cursor: pointer; transition: background .1s; }
table.data tbody tr:hover { background: #f5f9ff; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }
table.data td.text-bad { color: var(--red); font-weight: 600; }
table.data td.text-good { color: var(--green); font-weight: 600; }

.product-cell {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 240px;
}
.product-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--line-soft);
  border: 1px solid var(--line);
}
.product-name {
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.product-meta {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-soft);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.btn.primary:hover { background: var(--blue-d); border-color: var(--blue-d); color: #fff; }
.btn.danger {
  background: var(--panel);
  border-color: var(--red);
  color: var(--red);
}
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--line-soft); border-color: var(--line); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* ============================================================
   Drawer (боковая панель деталей SKU)
   ============================================================ */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 35, 55, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 9;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(480px, 100vw);
  height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 50px rgba(20, 35, 55, .14);
  transform: translateX(105%);
  transition: transform .22s;
  z-index: 10;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  padding: 18px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
}
.drawer-body { padding: 18px; overflow: auto; }
.drawer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.drawer-cell {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.drawer-cell .l { color: var(--muted); font-size: 11px; }
.drawer-cell .v { display: block; margin-top: 4px; font-size: 16px; font-weight: 700; }

/* ============================================================
   Toast уведомления
   ============================================================ */

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
  pointer-events: none;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  padding: 12px 14px;
  padding-right: 36px; /* место под кнопку закрытия */
  box-shadow: var(--shadow);
  font-size: 13px;
  pointer-events: auto;
  position: relative;
  animation: toast-in .2s ease-out;
  transition: opacity .25s ease-out;
}
.toast .toast-text { display: block; line-height: 1.35; }
.toast .toast-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
}
.toast .toast-close:hover { color: var(--ink); background: var(--line-soft); }
.toast .toast-close:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
.toast.warn    { border-left-color: var(--orange); }
@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}

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

.muted { color: var(--muted); }
.tiny  { font-size: 12px; }
.no-data {
  padding: 32px;
  text-align: center;
  color: var(--muted);
}
/* Базовый skeleton — серый блок с бегущим градиентом.
   Используется внутри карточек и таблиц как плейсхолдер на время загрузки.
   Не использовать одновременно с реальным контентом — управляйте видимостью
   через Alpine x-show/x-cloak или HTMX hx-swap. */
.skeleton {
  display: inline-block;
  background: linear-gradient(90deg, var(--line-soft) 25%, #fff 50%, var(--line-soft) 75%);
  background-size: 200% 100%;
  animation: skel 1.4s ease-in-out infinite;
  border-radius: 4px;
  color: transparent;
  user-select: none;
  pointer-events: none;
}
.skeleton.block { display: block; }
.skeleton.line  { display: block; height: 12px; margin: 6px 0; }
.skeleton.line.lg { height: 22px; }
.skeleton.line.sm { height: 9px; }
.skeleton.circle { border-radius: 50%; }

/* Готовые шаблоны: KPI-карточка и строка таблицы. */
.skeleton-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 90px;
}
.skeleton-card .skeleton.line { margin: 0; }

.skeleton-row {
  display: grid;
  grid-template-columns: 40px 1fr 80px 80px 80px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
}

@keyframes skel {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; opacity: .55; }
}

/* ============================================================
   Spinner — компактный индикатор загрузки
   ============================================================ */

.spinner-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-5);
  justify-content: center;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; opacity: .55; }
}

/* ============================================================
   Empty state — нет данных / нет синхронизации
   ============================================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-10) var(--sp-5);
  color: var(--muted);
  text-align: center;
}
.empty-state-icon {
  margin-bottom: var(--sp-3);
  color: var(--c-muted-soft);
}
.empty-state-text {
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  margin: 0;
}

/* ============================================================
   Error state — ошибка загрузки
   ============================================================ */

.error-state {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-4);
  border: 1px solid var(--c-red-bg-s);
  border-radius: var(--radius);
  background: var(--c-red-bg);
  color: var(--c-red);
}
.error-state-icon { flex-shrink: 0; margin-top: 1px; }
.error-state-text {
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  margin: 0;
}

/* ============================================================
   Sync error banner — предупреждение об ошибке синхронизации
   ============================================================ */

.sync-error-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--c-orange-bg);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--c-orange);
  border-bottom: 1px solid var(--c-orange-bg-s);
}

/* ============================================================
   Period selector — выпадающий выбор периода
   ============================================================ */

.period-selector { position: relative; display: inline-block; }
.period-selector-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.period-selector-btn:hover { border-color: var(--blue); color: var(--blue); }
.period-selector-chevron {
  transition: transform var(--dur-fast) var(--ease-out);
}
.period-selector-chevron.rotated {
  transform: rotate(180deg);
}
.period-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: var(--z-toast);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: 4px 0;
}
.period-dropdown-option {
  display: block;
  width: 100%;
  padding: 8px 14px;
  text-align: left;
  font-size: 13px;
  color: var(--ink-soft);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--dur-fast);
}
.period-dropdown-option:hover { background: var(--c-bg-raised); }
.period-dropdown-option.active {
  background: var(--c-blue-bg);
  color: var(--blue);
  font-weight: 500;
}

/* HTMX indicator */
.htmx-indicator { opacity: 0; transition: opacity .15s; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* Alpine.js: скрываем элементы с x-cloak до инициализации Alpine,
   иначе мелькает «развалившаяся» разметка с {{ x-text }}-литералами. */
[x-cloak] { display: none !important; }

/* Только для скрин-ридеров — визуально скрыто, но доступно ассистивным технологиям. */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   Burger menu — мобильная кнопка меню
   ============================================================ */

.burger-menu {
  display: none; /* скрыта на десктопе, показана через @media */
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink-soft);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--dur-fast), color var(--dur-fast);
}
.burger-menu:hover { border-color: var(--blue); color: var(--blue); }

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay-dark);
  z-index: calc(var(--z-drawer) - 1);
}

/* ============================================================
   Адаптивность
   ============================================================ */

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }

  /* Mobile sidebar: offscreen by default, slides in when .open */
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    z-index: var(--z-drawer);
    transition: left var(--dur-normal) var(--ease-out);
  }
  .sidebar.open { left: 0; }

  /* Show overlay when sidebar is open */
  .sidebar.open ~ .sidebar-overlay { display: block; }

  /* Show burger menu */
  .burger-menu { display: flex; }

  .shell { padding: 16px; }

  /* Drawer full-width on mobile */
  .drawer { width: 100vw; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .bridge { grid-template-columns: repeat(2, 1fr); }
  .controls { grid-template-columns: 1fr; }

  .topbar { padding: 10px 12px; }
  .shell { padding: 12px; }
}

/* ============================================================
   Print (для печатных форм документов)
   ============================================================ */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .app { display: block; }
  .section { box-shadow: none; border: 1px solid #000; }
  body { background: #fff; }
}

/* ---- План закупок: новая сетка ---- */
.plan-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 12px;
  flex-wrap: wrap;
}
.plan-toolbar select {
  padding: 4px 8px;
  border: 1px solid var(--line, #cbd5e1);
  border-radius: 4px;
  font: inherit;
}
.plan-toolbar .store-multi { min-width: 180px; max-height: 80px; }
.plan-toolbar .small { font-size: 11px; }

.plan-grid {
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  overflow: hidden;
  font-size: 12px;
}
.plan-grid-head, .plan-grid-row {
  display: grid;
  grid-template-columns: 36px minmax(220px, 1fr) 64px 64px 64px 16px 96px 16px 80px 80px 88px 28px;
  align-items: center;
  padding: 6px 8px;
  gap: 6px;
}
.plan-row-del {
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  color: var(--c-muted);
}
.plan-row-del:hover { color: var(--c-red); background: var(--c-red-bg); }

/* Поиск товара в шапке плана */
.plan-add-search {
  position: relative;
  margin: 8px 0 4px;
}
.plan-add-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--c-panel);
  border: 1px solid var(--c-line);
  border-radius: 8px;
  padding: 0 8px 0 28px;
}
.plan-add-input-wrap svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--c-muted); }
.plan-add-input-wrap input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font: var(--fw-medium) 13px/1.4 var(--ff-body);
  padding: 8px 0;
  color: var(--c-ink);
}
.plan-add-suggest {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--c-panel);
  border: 1px solid var(--c-line);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  z-index: 5;
}
.plan-add-suggest-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: center;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--c-line-soft);
}
.plan-add-suggest-row:last-child { border-bottom: 0; }
.plan-add-suggest-row:hover { background: var(--c-blue-bg); }
.plan-add-thumb { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; }
.plan-add-thumb--placeholder {
  display: grid; place-items: center;
  background: var(--c-line-soft); color: var(--c-muted);
}
.plan-add-sug-name { font-size: 12px; font-weight: 600; color: var(--c-ink); line-height: 1.2; }
.plan-add-sug-offer { font-size: 11px; color: var(--c-muted); margin-top: 1px; font-family: var(--ff-mono); }

/* Save-button state feedback */
.plan-save-btn.saving { opacity: .7; }
.plan-save-btn.saved {
  background: var(--c-green) !important;
  border-color: var(--c-green) !important;
  color: #fff !important;
}
.plan-save-btn.saved svg { color: #fff; }
.plan-save-btn.error {
  background: var(--c-red) !important;
  border-color: var(--c-red) !important;
  color: #fff !important;
}
.plan-save-btn.error svg { color: #fff; }
@keyframes save-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(35,122,87,.4); }
  70%  { box-shadow: 0 0 0 8px rgba(35,122,87,0); }
  100% { box-shadow: 0 0 0 0 rgba(35,122,87,0); }
}
.plan-save-btn.saved { animation: save-pulse 700ms ease-out 1; }
.plan-grid-head {
  background: #f8fafc;
  color: var(--muted, #64748b);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--line, #e2e8f0);
}
.plan-grid-row { border-bottom: 1px solid var(--line-soft, #f1f5f9); }
.plan-grid-row:last-of-type { border-bottom: none; }
.plan-grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.plan-grid .ctr { text-align: center; }
.plan-grid .divider {
  width: 1px;
  height: 60%;
  background: var(--line, #e2e8f0);
  justify-self: center;
}
.plan-grid-head .divider { background: transparent; }
.plan-grid .name b { font-weight: 500; }
.plan-grid .name span { display: block; color: var(--muted, #94a3b8); font-size: 10px; }
.plan-grid img.thumb {
  width: 28px; height: 28px;
  border-radius: 4px; object-fit: cover;
  background: #e2e8f0;
}
.plan-grid .nothumb {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: #f1f5f9; border-radius: 4px;
  color: #94a3b8;
}
.plan-grid .qty, .plan-grid .price {
  width: 100%;
  box-sizing: border-box;
  padding: 3px 6px;
  border: 1px solid var(--line, #cbd5e1);
  border-radius: 4px;
  font: inherit;
  text-align: right;
}
.plan-grid .pill { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.plan-grid .pill.ok { background: #dafbe1; color: #1a7f37; }
.plan-grid .pill.warn { background: #fff8c5; color: #9a6700; }
.plan-grid .pill.danger { background: #ffebe9; color: #cf222e; }
.plan-grid .pill.muted { background: #eaeef2; color: #57606a; }
.plan-grid-footer {
  padding: 10px 12px;
  background: #f8fafc;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  border-top: 1px solid var(--line, #e2e8f0);
}

.plan-grid-head .sortable {
  cursor: pointer;
  user-select: none;
}
.plan-grid-head .sortable:hover {
  color: var(--blue, #2563eb);
}
.plan-grid-head .sort-active {
  color: var(--blue, #2563eb);
}

/* ============================================================
   Theme toggle (segmented auto/light/dark)
   ============================================================ */
.theme-toggle {
  display: inline-flex;
  background: var(--c-line-soft);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 2px;
}
.theme-toggle .tt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--c-muted);
  cursor: pointer;
  transition: background 120ms var(--ease-out), color 120ms var(--ease-out);
}
@media (hover: hover) {
  .theme-toggle .tt-btn:hover { color: var(--c-ink); }
}
.theme-toggle .tt-btn.active {
  background: var(--c-panel);
  color: var(--c-ink);
  box-shadow: var(--shadow-xs);
}

/* === btn ===
   ============================================================
   Single button component. Variants: primary, ghost, danger,
   sm, icon. Customise via --btn-* CSS variables on instance.
   ============================================================ */
.btn {
  --btn-bg: var(--c-panel);
  --btn-ink: var(--c-ink);
  --btn-border: var(--c-line);
  --btn-pad-y: 8px;
  --btn-pad-x: 14px;
  --btn-fs: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  border: 1px solid var(--btn-border);
  padding: var(--btn-pad-y) var(--btn-pad-x);
  border-radius: var(--r-sm);
  font: var(--fw-semi) var(--btn-fs)/1.2 var(--ff-body);
  cursor: pointer;
  text-decoration: none;
  transition: transform 120ms var(--ease-out),
              box-shadow 120ms var(--ease-out),
              background 120ms var(--ease-out),
              border-color 120ms var(--ease-out);
  min-height: 36px;
}
@media (hover: hover) {
  .btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
  }
}
.btn:active { transform: translateY(0); }
.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: .5;
  pointer-events: none;
}

.btn.primary {
  --btn-bg: var(--c-blue);
  --btn-ink: var(--c-blue-ink);
  --btn-border: var(--c-blue);
}
.btn.primary:hover { --btn-bg: var(--c-blue-hover); --btn-border: var(--c-blue-hover); }

.btn.ghost {
  --btn-bg: transparent;
  --btn-border: transparent;
  --btn-ink: var(--c-ink-soft);
}
.btn.ghost:hover { --btn-bg: var(--c-line-soft); --btn-ink: var(--c-ink); }

.btn.danger {
  --btn-bg: var(--c-red);
  --btn-ink: #ffffff;
  --btn-border: var(--c-red);
}
.btn.danger:hover { --btn-bg: var(--c-red-hover); --btn-border: var(--c-red-hover); }

.btn.sm {
  --btn-pad-y: 5px;
  --btn-pad-x: 10px;
  --btn-fs: 12px;
  min-height: 28px;
}

.btn.icon {
  --btn-pad-x: 8px;
  min-width: 36px;
  justify-content: center;
}
.btn.icon.sm { min-width: 28px; }

/* === card ===
   ============================================================
   Container component for grouped content.
   Variants: raised (stronger shadow), dashed (dashed border),
   flat (no shadow), interactive (hover lift).
   ============================================================ */
.card {
  background: var(--c-panel);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-xs);
}
.card.raised { box-shadow: var(--shadow-md); }
.card.flat { box-shadow: none; }
.card.dashed { border-style: dashed; box-shadow: none; }
.card.interactive {
  cursor: pointer;
  transition: box-shadow 160ms var(--ease-out), transform 160ms var(--ease-out);
}
@media (hover: hover) {
  .card.interactive:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
  }
}

.card-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.card-head h2, .card-head h3 { margin: 0; }
.card-title {
  font: var(--fw-bold) var(--fs-lg)/1.2 var(--ff-display);
  letter-spacing: -0.01em;
  color: var(--c-ink);
}
.card-sub {
  font-size: var(--fs-sm);
  color: var(--c-muted);
}

/* === kpi ===
   ============================================================
   KPI tile — label + value + delta.
   Variants: highlight (accent border), compact (smaller).
   ============================================================ */
.kpi {
  background: var(--c-panel-2);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.kpi.highlight {
  background: var(--c-blue-bg);
  border-color: color-mix(in srgb, var(--c-blue) 30%, transparent);
}
.kpi.compact { padding: var(--sp-3); }

.kpi-label {
  font: var(--fw-semi) var(--fs-xs)/1.2 var(--ff-body);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-muted);
}
.kpi-value {
  font: 500 var(--fs-2xl)/1.05 var(--ff-mono);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--c-ink);
}
.kpi.compact .kpi-value { font-size: var(--fs-xl); }
.kpi-delta {
  font: var(--fw-semi) var(--fs-sm)/1.2 var(--ff-mono);
  font-variant-numeric: tabular-nums;
}
.kpi-delta.pos { color: var(--c-green); }
.kpi-delta.neg { color: var(--c-red); }
.kpi-delta.flat { color: var(--c-muted); }

/* === field ===
   ============================================================
   Label + input wrapper. Variants: error, disabled.
   ============================================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.field > .field-label,
.field > label > span:first-child {
  font: var(--fw-semi) var(--fs-sm)/1.2 var(--ff-body);
  color: var(--c-ink-soft);
}
.field input[type="text"],
.field input[type="number"],
.field input[type="email"],
.field input[type="password"],
.field input[type="date"],
.field input[type="search"],
.field textarea,
.field .select select {
  font: var(--fw-medium) var(--fs-base)/1.4 var(--ff-body);
  color: var(--c-ink);
  background: var(--c-panel);
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  min-height: 36px;
  transition: border-color 120ms var(--ease-out), box-shadow 120ms var(--ease-out);
  width: 100%;
}
.field input:focus,
.field textarea:focus,
.field .select select:focus {
  outline: none;
  border-color: var(--c-blue);
  box-shadow: 0 0 0 3px var(--c-blue-bg);
}
.field.error input,
.field.error textarea,
.field.error .select select {
  border-color: var(--c-red);
}
.field.error .field-msg { color: var(--c-red); font-size: var(--fs-sm); }
.field.disabled { opacity: .55; pointer-events: none; }
.field .field-hint {
  font-size: var(--fs-sm);
  color: var(--c-muted);
}

/* === form layout ===
   ============================================================ */
.form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.form-row {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-end;
  flex-wrap: wrap;
}
.form-row > .field { flex: 1 1 200px; min-width: 0; }
.form-grid {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.form-actions {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* === select ===
   ============================================================
   Native <select> styled. Variant: compact.
   ============================================================ */
.select {
  position: relative;
  display: inline-flex;
  min-width: 120px;
}
.select select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--c-panel);
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  padding: 7px 28px 7px 10px;
  font: var(--fw-medium) var(--fs-base)/1.2 var(--ff-body);
  color: var(--c-ink);
  cursor: pointer;
  width: 100%;
  min-height: 36px;
}
.select::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--c-muted);
  border-bottom: 1.5px solid var(--c-muted);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}
.select.compact select { padding: 5px 24px 5px 8px; min-height: 28px; font-size: var(--fs-sm); }

/* === pill ===
   ============================================================
   Badge / status chip. Variants: success, warn, danger, info, neutral.
   ============================================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font: var(--fw-semi) var(--fs-xs)/1.4 var(--ff-body);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--c-line-soft);
  color: var(--c-ink-soft);
  white-space: nowrap;
}
.pill.success { background: var(--c-green-bg); color: var(--c-green); }
.pill.warn    { background: var(--c-orange-bg); color: var(--c-orange); }
.pill.danger  { background: var(--c-red-bg); color: var(--c-red); }
.pill.info    { background: var(--c-blue-bg); color: var(--c-blue); }
.pill.neutral { background: var(--c-line-soft); color: var(--c-muted); }

/* === tbl ===
   ============================================================
   Data table base. Variants: compact, zebra.
   ============================================================ */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
}
.tbl th {
  text-align: left;
  font: var(--fw-semi) var(--fs-xs)/1.4 var(--ff-body);
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-line);
  background: var(--c-panel-2);
  position: sticky;
  top: 0;
  z-index: 1;
}
.tbl td {
  padding: 12px;
  border-bottom: 1px solid var(--c-line-soft);
  vertical-align: middle;
}
.tbl td.num,
.tbl th.num {
  text-align: right;
  font-family: var(--ff-mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.tbl tr:last-child td { border-bottom: 0; }
.tbl.compact th { padding: 7px 10px; }
.tbl.compact td { padding: 8px 10px; font-size: var(--fs-sm); }
.tbl.zebra tbody tr:nth-child(even) td { background: var(--c-line-soft); }
@media (hover: hover) {
  .tbl tbody tr:hover td { background: var(--c-blue-bg); }
}

/* === tabs ===
   ============================================================
   Tab navigation. Variants: pills (rounded buttons).
   ============================================================ */
.tabs {
  display: inline-flex;
  gap: 2px;
  border-bottom: 1px solid var(--c-line);
}
.tab {
  padding: 8px 14px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  font: var(--fw-semi) var(--fs-sm)/1.2 var(--ff-body);
  color: var(--c-muted);
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 120ms var(--ease-out), border-color 120ms var(--ease-out);
}
.tab:hover { color: var(--c-ink); }
.tab.active { color: var(--c-ink); border-bottom-color: var(--c-blue); }

.tabs.pills {
  border-bottom: 0;
  background: var(--c-line-soft);
  padding: 2px;
  border-radius: var(--r-md);
  gap: 2px;
}
.tabs.pills .tab {
  border-radius: var(--r-sm);
  border-bottom: 0;
  margin-bottom: 0;
}
.tabs.pills .tab.active {
  background: var(--c-panel);
  border-bottom-color: transparent;
  box-shadow: var(--shadow-xs);
}

/* === filter-pills ===
   ============================================================
   Toggle pill row (used in product/inventory grade filters).
   ============================================================ */
.filter-pills {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.filter-pill {
  padding: 5px 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--c-line);
  background: var(--c-panel);
  color: var(--c-ink-soft);
  font: var(--fw-semi) var(--fs-sm)/1.2 var(--ff-body);
  cursor: pointer;
  transition: background 120ms var(--ease-out), color 120ms var(--ease-out), border-color 120ms var(--ease-out);
}
.filter-pill:hover { background: var(--c-line-soft); }
.filter-pill.active {
  background: var(--c-blue);
  color: var(--c-blue-ink);
  border-color: var(--c-blue);
}

/* === modal ===
   ============================================================
   Centered overlay. Variants: lg (wider).
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay-dark);
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms var(--ease-out);
  z-index: var(--z-modal);
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(540px, calc(100vw - var(--sp-8)));
  max-height: calc(100vh - var(--sp-8));
  background: var(--c-panel);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--sp-5);
  opacity: 0;
  transform: translate(-50%, calc(-50% + 8px));
  pointer-events: none;
  transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out);
  z-index: calc(var(--z-modal) + 1);
  overflow: auto;
}
.modal.open {
  opacity: 1;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}
.modal.lg { width: min(820px, calc(100vw - var(--sp-8))); }
.modal-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.modal-title {
  font: var(--fw-bold) var(--fs-xl)/1.2 var(--ff-display);
  letter-spacing: -0.02em;
  margin: 0;
  flex: 1;
}
.modal-close {
  background: transparent;
  border: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  color: var(--c-muted);
  cursor: pointer;
}
.modal-close:hover { background: var(--c-line-soft); color: var(--c-ink); }
.modal-actions {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  margin-top: var(--sp-5);
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .modal {
    top: auto;
    bottom: 0;
    left: 0;
    transform: translateY(100%);
    width: 100%;
    max-width: 100%;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    max-height: 90vh;
  }
  .modal.open { transform: translateY(0); }
}

/* === drawer ===
   ============================================================
   Side panel from the right. Variants: lg.
   ============================================================ */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay-dark);
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms var(--ease-out);
  z-index: var(--z-drawer);
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: var(--drawer-w);
  max-width: 100vw;
  background: var(--c-panel);
  box-shadow: var(--shadow-xl);
  transform: translateX(100%);
  transition: transform 280ms var(--ease-out);
  z-index: calc(var(--z-drawer) + 1);
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer.lg { width: min(720px, 100vw); }
.drawer-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--c-line);
}
.drawer-title {
  font: var(--fw-bold) var(--fs-lg)/1.2 var(--ff-display);
  margin: 0;
  flex: 1;
}
.drawer-body {
  flex: 1;
  overflow: auto;
  padding: var(--sp-4) var(--sp-5);
}
@media (max-width: 640px) {
  .drawer { width: 100vw; }
}

/* === toast ===
   ============================================================
   Notification stack (top-right). Variants: success, error, info.
   ============================================================ */
.toast-stack {
  position: fixed;
  top: var(--sp-4);
  right: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: var(--z-toast);
  pointer-events: none;
  max-width: 360px;
}
.toast {
  pointer-events: auto;
  background: var(--c-panel);
  border: 1px solid var(--c-line);
  border-left: 3px solid var(--c-blue);
  border-radius: var(--r-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-md);
  font: var(--fw-medium) var(--fs-sm)/1.4 var(--ff-body);
  color: var(--c-ink);
  opacity: 0;
  transform: translateX(20px);
  animation: toast-in 220ms var(--ease-out) forwards;
}
.toast.success { border-left-color: var(--c-green); }
.toast.error   { border-left-color: var(--c-red); }
.toast.info    { border-left-color: var(--c-blue); }
.toast.fading { animation: toast-out 160ms var(--ease-in) forwards; }
@keyframes toast-in {
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(20px); }
}

/* === empty ===
   ============================================================
   Empty / error / loading state. Variants via data-variant
   attribute: no-data, filtered, error, loading.
   ============================================================ */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--sp-8) var(--sp-5);
  gap: var(--sp-2);
  color: var(--c-muted);
  background: var(--c-panel-2);
  border: 1px dashed var(--c-line);
  border-radius: var(--r-lg);
}
.empty-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--r-full);
  background: var(--c-line-soft);
  color: var(--c-muted);
  margin-bottom: var(--sp-2);
}
.empty[data-variant="error"] .empty-icon {
  background: var(--c-red-bg);
  color: var(--c-red);
}
.empty[data-variant="loading"] .empty-icon {
  background: var(--c-blue-bg);
  color: var(--c-blue);
}
.empty-title {
  font: var(--fw-bold) var(--fs-lg)/1.2 var(--ff-display);
  letter-spacing: -0.01em;
  color: var(--c-ink);
  margin: 0;
}
.empty-text {
  font-size: var(--fs-base);
  max-width: 380px;
  margin: 0;
  line-height: 1.5;
}
.empty-actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  flex-wrap: wrap;
  justify-content: center;
}

/* === skeleton ===
   ============================================================
   Loading placeholder shimmer.
   ============================================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--c-line-soft) 0%,
    var(--c-line) 50%,
    var(--c-line-soft) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s linear infinite;
  border-radius: var(--r-sm);
}
.skeleton.line { height: 14px; width: 100%; }
.skeleton.line.sm { height: 10px; }
.skeleton.line.lg { height: 20px; }
.skeleton.line.w-full { width: 100%; }
.skeleton.line.w-3-4 { width: 75%; }
.skeleton.line.w-1-2 { width: 50%; }
.skeleton.block { width: 100%; height: 80px; }
.skeleton.tbl-row { height: 36px; margin-bottom: 2px; }
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   Touch targets (≥ 40px on mobile)
   ============================================================ */
@media (max-width: 640px) {
  .btn:not(.icon.sm) { min-height: 40px; }
  .btn.icon { min-width: 40px; min-height: 40px; }
  .tab { padding: 10px 14px; min-height: 40px; }
  .filter-pill { min-height: 32px; padding: 6px 12px; }
}

/* ============================================================
   Topbar mobile collapse
   ============================================================ */
@media (max-width: 900px) {
  .topbar-store-switcher,
  .theme-toggle,
  .account-chip { gap: var(--sp-1); }
  .account-chip .user-chip > div { display: none; }
}
@media (max-width: 640px) {
  .topbar .page-title { display: none; }
  .topbar .spacer { display: none; }
}

/* ============================================================
   Finance breakdown (drawer-секция «Юнит-экономика»)
   ============================================================ */
.finance-breakdown {
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--c-line);
}
.finance-breakdown-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-3);
}
.finance-breakdown-head h4 {
  margin: 0;
  font: var(--fw-bold) var(--fs-md)/1.2 var(--ff-display);
  letter-spacing: -0.01em;
}
.fb-period {
  background: var(--c-panel-2);
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  padding: 4px 8px;
  font: var(--fw-medium) var(--fs-sm)/1.2 var(--ff-body);
}

.fb-summary {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: var(--sp-2); margin-bottom: var(--sp-3);
}
.fb-summary-card {
  padding: var(--sp-3);
  background: var(--c-panel-2);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
}
.fb-summary-card.highlight {
  background: var(--c-blue-bg);
  border-color: var(--c-blue);
}
.fb-summary-card .lbl {
  font: var(--fw-semi) var(--fs-xs)/1.2 var(--ff-body);
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--c-muted);
}
.fb-summary-card .val {
  font: 500 var(--fs-xl)/1.1 var(--ff-mono);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.fb-summary-card .val.pos { color: var(--c-green); }
.fb-summary-card .val.neg { color: var(--c-red); }

.fb-groups { display: flex; flex-direction: column; gap: 4px; }
.fb-group {
  background: var(--c-panel-2);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.fb-group summary {
  display: grid; grid-template-columns: 8px 1fr auto;
  gap: 10px; align-items: center;
  padding: 10px 14px; cursor: pointer; list-style: none;
}
.fb-group summary::-webkit-details-marker { display: none; }
.fb-group[open] summary { border-bottom: 1px solid var(--c-line-soft); }
.fb-dot {
  width: 8px; height: 8px; border-radius: 999px; display: inline-block;
}
.fb-dot--revenue          { background: var(--c-green); }
.fb-dot--partner_program  { background: var(--c-teal); }
.fb-dot--discount_points  { background: var(--c-violet); }
.fb-dot--commission       { background: var(--c-blue); }
.fb-dot--delivery         { background: var(--c-orange); }
.fb-dot--partner_services { background: var(--c-yellow); }
.fb-dot--promo            { background: #d946ef; }
.fb-dot--other            { background: var(--c-muted); }
.fb-name {
  font: var(--fw-semi) var(--fs-sm)/1.2 var(--ff-body);
  color: var(--c-ink);
}
.fb-total {
  font-family: var(--ff-mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.fb-total.pos { color: var(--c-green); }
.fb-total.neg { color: var(--c-red); }
.fb-items {
  padding: 6px 14px 12px 32px;
  display: grid; gap: 4px;
}
.fb-item {
  display: grid; grid-template-columns: 1fr auto 60px;
  gap: 12px; font-size: var(--fs-sm);
}
.fb-item .num {
  font-family: var(--ff-mono);
  font-variant-numeric: tabular-nums;
}
.fb-item .num.pos { color: var(--c-green); }
.fb-item .num.neg { color: var(--c-red); }
.fb-item .cnt {
  color: var(--c-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.fb-meta {
  margin-top: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--c-muted);
}
.fb-meta .link { color: var(--c-blue); text-decoration: none; }
.fb-meta .link:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .fb-summary { grid-template-columns: 1fr; }
  .fb-items   { padding-left: 14px; }
}

/* ---- Stock popover (детализация остатков) ---- */
.stock-cell {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; font: inherit; cursor: pointer;
  color: var(--ink, #0f172a);
}
.stock-cell:hover { background: #f1f5f9; border-color: var(--line, #e2e8f0); }
.stock-cell-hint { color: var(--muted, #64748b); font-size: 11px; }

.stock-popover {
  position: absolute; z-index: 80;
  width: 320px; max-height: 70vh; overflow-y: auto;
  background: #fff; border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px; box-shadow: 0 12px 32px rgba(15,23,42,.14);
}
.stock-popover-body { padding: 10px 12px; font-size: 13px; }
.stock-popover-head { display:flex; justify-content:space-between; margin-bottom:8px; font-weight:600; }
.stock-popover-wh { padding: 6px 0; border-top: 1px solid var(--line, #e2e8f0); }
.stock-popover-wh:first-child { border-top: none; }
.stock-popover-wh-name { display:flex; flex-direction:column; }
.stock-popover-wh-name .muted { font-weight: normal; }
.stock-popover-buckets { list-style:none; margin:4px 0 0; padding:0; }
.stock-popover-buckets li { display:flex; justify-content:space-between; padding:2px 0; color: var(--ink, #0f172a); }
.stock-popover-buckets li.prob { color: rgba(239,68,68,.95); }
.stock-popover-foot { margin-top:8px; padding-top:6px; border-top: 1px solid var(--line, #e2e8f0);
                      color: var(--muted, #64748b); font-size: 12px; }

.stock-breakdown { margin-top: 16px; }
.stock-breakdown h3 { font-size: 14px; margin: 0 0 8px; }
.sb-summary { padding: 8px 10px; background: #f8fafc; border-radius: 8px; font-size: 13px; }
.sb-wh-list { list-style: none; margin: 8px 0 0; padding: 0; }
.sb-wh-list > li { padding: 8px 0; border-top: 1px solid var(--line, #e2e8f0); }
.sb-wh-list > li:first-child { border-top: none; }
.sb-wh-head { display: flex; justify-content: space-between; }
.sb-wh-buckets { list-style: none; padding-left: 12px; margin: 4px 0 0; font-size: 13px; }
.sb-wh-buckets li { display: flex; justify-content: space-between; padding: 1px 0; }
.sb-wh-buckets li.prob { color: rgba(239,68,68,.95); }

.stock-popover-top-skus { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line, #e2e8f0); }
.stock-popover-section-head { font-weight: 600; font-size: 12px; margin-bottom: 6px; color: var(--muted, #64748b); }
.stock-popover-top-skus ul { list-style: none; padding: 0; margin: 0; }
.stock-popover-top-skus li { display: grid; grid-template-columns: auto 1fr auto; gap: 6px; padding: 2px 0; font-size: 13px; }
.stock-popover-top-skus li .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stock-popover-top-skus li .num { font-weight: 600; }

/* ---- Глобальный topbar sync-chip ---- */
.topbar-sync-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background: #f1f5f9; color: var(--ink, #0f172a);
  margin-right: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s ease, border-color .15s ease;
}
.topbar-sync-chip:hover {
  background: #e2e8f0;
  border-color: var(--line, #cbd5e1);
}
.topbar-sync-chip:focus-visible {
  outline: none;
  border-color: var(--blue, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .18);
}
.topbar-sync-chip.fresh { background: rgba(34,197,94,.12); color: #166534; }
.topbar-sync-chip.stale { background: rgba(245,158,11,.12); color: #92400e; }
.topbar-sync-dot {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}

/* ---- Period selector in topbar ---- */
.topbar-period {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line, #e2e8f0); border-radius: 10px;
  background: #fff;
  margin-right: 8px;
}
.topbar-period-icon { color: var(--muted, #64748b); font-size: 14px; }
.topbar-period-label { font-size: 12px; color: var(--muted, #64748b); user-select: none; }
.topbar-period-select { border: none; background: transparent; font-size: 13px; cursor: pointer; }
.topbar-period-select:focus { outline: none; }

/* ── Account popover (mobile kebab menu) ── */
.account-chip { position: relative; }
.burger-toggle {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 6px;
  color: var(--ink, #0f172a);
  align-items: center;
  border-radius: 8px;
}
.burger-toggle:hover { background: #f1f5f9; }
.account-menu-btn {
  border: none; background: transparent; padding: 6px; border-radius: 8px;
  cursor: pointer; color: var(--ink, #0f172a);
}
.account-menu-btn:hover { background: #f1f5f9; }
.account-popover {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: #fff; border: 1px solid var(--line, #e2e8f0); border-radius: 12px;
  padding: 10px 14px; min-width: 180px;
  box-shadow: 0 12px 32px rgba(15,23,42,.12);
  z-index: 60;
}
.account-popover-name { font-weight: 600; }
.account-popover-role { font-size: 11px; color: var(--muted, #64748b); margin-bottom: 8px; }
.account-popover-link {
  display: block; padding: 6px 0; color: var(--blue, #2563eb); text-decoration: none;
}

/* ── Stock popover: tabs, filters, clusters, empty state ──────────────── */
.stock-popover-tabs {
  display: inline-flex; padding: 2px; margin: 6px 0;
  border-radius: 8px; background: #f1f5f9;
}
.stock-popover-tabs button {
  border: 0; background: transparent; padding: 4px 10px;
  font: inherit; font-size: 12px; cursor: pointer; border-radius: 6px;
  color: var(--ink, #0f172a);
}
.stock-popover-tabs button.active {
  background: #fff; color: var(--blue, #2563eb); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.stock-popover-filters {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: 6px;
}
.stock-popover-filters button {
  border: 1px solid var(--line, #e2e8f0); border-radius: 999px;
  padding: 3px 9px; font: inherit; font-size: 11px; cursor: pointer;
  background: #fff; color: var(--muted, #64748b);
}
.stock-popover-filters button:hover { color: var(--ink, #0f172a); }
.stock-popover-filters button.active {
  background: var(--blue, #2563eb); color: #fff; border-color: transparent;
}
.stock-popover-cluster { padding: 6px 0; border-top: 1px solid var(--line, #e2e8f0); }
.stock-popover-cluster:first-child { border-top: 0; }
.stock-popover-cluster-head { display: flex; justify-content: space-between; align-items: baseline; }
.stock-popover-empty {
  padding: 12px; text-align: center; color: var(--muted, #64748b); font-size: 12px;
}

/* === Phase 5: Price Planner === */
.price-plan-card {
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  margin-bottom: 12px;
  background: #fff;
}
.price-plan-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}
.price-plan-head:hover { background: #f8fafc; }
.price-plan-title strong { display: block; font-size: 14px; }
.price-plan-meta { display: flex; gap: 12px; align-items: center; }
.price-plan-meta .badge {
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500;
}
.price-plan-meta .badge.ok { background: #d1fae5; color: #065f46; }
.price-plan-meta .badge.warn { background: #fef3c7; color: #92400e; }
.price-plan-meta .badge.muted { background: #f1f5f9; color: #64748b; }
.price-plan-body { padding: 6px 14px 12px; border-top: 1px solid var(--line, #e2e8f0); }
.price-plan-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.price-plan-table th, .price-plan-table td {
  padding: 6px 8px; border-bottom: 1px solid var(--line, #e2e8f0); text-align: left;
}
.price-plan-table .down { color: #dc2626; font-weight: 600; }
.price-plan-table .up   { color: #059669; font-weight: 600; }
.price-plan-table tr.applied { opacity: 0.6; }
.price-plan-table tr.failed  { background: #fef2f2; }
.price-plan-table .ai-reason {
  max-width: 280px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.price-plan-foot {
  display: flex; gap: 8px; margin-top: 10px;
}
.btn-primary {
  background: var(--blue, #2563eb); color: #fff; border: 0;
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font: inherit;
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger {
  background: #fff; color: #dc2626; border: 1px solid #fee2e2;
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font: inherit;
}
.btn-danger:hover { background: #fef2f2; }
.page-actions { display: flex; justify-content: flex-end; margin: 12px 0; }

/* === Phase 6: Review Replies === */
.review-card {
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
  background: #fff;
}
.review-card.replied { opacity: 0.65; }
.review-card.errored { background: #fef2f2; }
.review-card header {
  display: flex; gap: 10px; align-items: center; margin-bottom: 8px;
}
.review-card .rating { color: #f59e0b; font-size: 14px; }
.review-card .date { color: var(--muted, #64748b); font-size: 12px; }
.review-card .badge {
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500;
}
.review-card .badge.ok { background: #d1fae5; color: #065f46; }
.review-card .badge.bad { background: #fee2e2; color: #991b1b; }
.review-card .badge.muted { background: #f1f5f9; color: #64748b; }
.review-card .review-text { font-size: 14px; line-height: 1.45; margin-bottom: 6px; }
.review-card .draft-block {
  margin-top: 10px; padding: 10px;
  background: #f0f9ff; border-radius: 6px; border-left: 3px solid #2563eb;
}
.review-card .draft-label { margin-bottom: 4px; }
.review-card .draft-text { font-size: 13px; line-height: 1.4; margin-bottom: 8px; white-space: pre-wrap; }
.review-card .draft-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.review-card .our-reply {
  margin-top: 10px; padding: 8px 10px;
  background: #ecfdf5; border-radius: 6px; border-left: 3px solid #059669;
  font-size: 13px;
}
.review-card textarea {
  width: 100%; min-height: 80px; padding: 6px 8px;
  font: inherit; font-size: 13px;
  border: 1px solid var(--line, #e2e8f0); border-radius: 6px;
  resize: vertical;
}
.page-actions .filters {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.page-actions .filters button {
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line, #e2e8f0);
  background: #fff; cursor: pointer; font: inherit; font-size: 12px;
  color: var(--muted, #64748b);
}
.page-actions .filters button.active {
  background: var(--blue, #2563eb); color: #fff; border-color: transparent;
}

.readonly-banner {
  margin: 12px 0;
  padding: 10px 14px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 6px;
  border-left: 3px solid #d97706;
  font-size: 13px;
}
