/*
 * components.css — Stage 12.0.40
 * Reusable visual patterns aligned с Ozon Seller: .card, .tile, .stat-big,
 * .status-chip. Подключается в base.html после tokens.css и Tailwind CDN.
 */

/* ── Card ─────────────────────────────────────────────────────────── */
.card {
  background: var(--surface-card);
  border-radius: var(--radius-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  padding: 20px 24px;
  transition: border-color var(--duration-fast, 120ms) ease,
              box-shadow  var(--duration-normal, 180ms) var(--ease-out-quart, ease);
}
/* Anchor cards (.card on <a>) get a subtle hover lift — not decorative for
   container cards. */
a.card:hover,
.card--link:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-card-hover, var(--shadow-md));
}
.card--compact { padding: 14px 16px; }
.card--flush   { padding: 0; }

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.card__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.005em;
  line-height: 1.3;
}
.card__action {
  font-size: 12px;
  font-weight: 500;
  color: var(--brand-600);
  text-decoration: none;
  transition: color var(--duration-fast, 120ms) ease;
}
.card__action:hover { color: var(--brand-700); text-decoration: underline; text-underline-offset: 2px; }

/* ── Tile (mini row под hero) ─────────────────────────────────────── */
.tile {
  background: var(--surface-card);
  border-radius: var(--radius-tile);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform var(--duration-normal, 180ms) var(--ease-out-quart, ease),
              box-shadow var(--duration-normal, 180ms) var(--ease-out-quart, ease),
              border-color var(--duration-fast, 120ms) ease;
  border: 1px solid var(--border-subtle);
  text-decoration: none;
  color: inherit;
}
.tile:hover {
  transform: translateY(-1px);
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-tile-hover);
}
.tile:active { transform: translateY(0); transition-duration: 60ms; }
.tile__icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--brand-50);
  color: var(--brand-700);
  font-size: 16px;
  transition: background var(--duration-fast, 120ms) ease, color var(--duration-fast, 120ms) ease;
}
.tile:hover .tile__icon { background: var(--brand-100); }
.tile__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.tile__title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.1;
}
.tile__hint {
  font-size: 11px;
  color: var(--text-meta);
}
.tile__counter {
  margin-left: auto;
  background: var(--brand-50);
  color: var(--brand-700);
  border-radius: var(--radius-chip);
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.tile__counter--warn   { background: #FFF3E6; color: #B45F00; }
.tile__counter--danger { background: #FDE7E9; color: #B5172A; }
.tile__counter--muted  { background: var(--surface-tint); color: var(--text-secondary); }

/* ── StatBig (big number блок) ────────────────────────────────────── */
.stat-big { padding: 4px 0; }
.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.stat-value--positive { color: var(--stat-positive); }
.stat-value--negative { color: var(--stat-negative); }

.stat-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.stat-label {
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.stat-delta {
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.stat-delta--positive { color: var(--stat-positive); }
.stat-delta--negative { color: var(--stat-negative); }
.stat-delta--neutral  { color: var(--text-meta); }

/* ── Status chip (rounded pill для статусов решений) ──────────────── */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-chip);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.005em;
  font-variant-numeric: tabular-nums;
}
.status-chip::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  flex-shrink: 0;
}
.status-chip--pending   { background: #FFF3E6; color: #B45F00; }
.status-chip--approved  { background: var(--brand-50); color: var(--brand-700); }
.status-chip--executed  { background: #E6F7EE; color: #007038; }
.status-chip--rejected,
.status-chip--expired,
.status-chip--cancelled { background: var(--surface-tint); color: var(--text-secondary); }

/* ── Hero layout ──────────────────────────────────────────────────── */
.hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (min-width: 768px) {
  .hero-grid {
    grid-template-columns: 2fr 1fr; /* ≈ 8/12 + 4/12 */
  }
}

.hero-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Tile row ─────────────────────────────────────────────────────── */
.tile-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
@media (min-width: 640px) {
  .tile-row { grid-template-columns: repeat(4, 1fr); }
}

/* ──────────────────────────────────────────────────────────────────
 * Stage 12.0.83 — modern reusable components
 * Buttons, badges, tables, filter bars, empty state, skeleton.
 * Используются через Jinja2 macros в templates/components/.
 * ────────────────────────────────────────────────────────────────── */

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px 14px;
  min-height: 34px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  text-decoration: none;
  font-family: inherit;
  letter-spacing: 0.005em;
  transition: background var(--duration-fast, 120ms) ease,
              border-color var(--duration-fast, 120ms) ease,
              color var(--duration-fast, 120ms) ease,
              box-shadow var(--duration-fast, 120ms) ease,
              transform 80ms ease;
  white-space: nowrap;
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.btn:active { transform: translateY(0.5px); }
.btn--primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  box-shadow: 0 1px 0 0 color-mix(in oklab, var(--color-primary-strong) 60%, transparent),
              0 1px 2px rgba(0, 134, 209, 0.18);
}
.btn--primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: #fff;
  box-shadow: 0 1px 0 0 color-mix(in oklab, var(--color-primary-strong) 70%, transparent),
              0 2px 6px rgba(0, 134, 209, 0.22);
}
.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text-primary);
  border-color: var(--color-border-strong);
}
.btn--secondary:hover { background: var(--color-surface-soft); color: var(--color-text-primary); }
.btn--ghost {
  background: transparent;
  color: var(--color-text-secondary);
}
.btn--ghost:hover { background: var(--color-surface-soft); color: var(--color-text-primary); }
.btn--danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn--danger:hover { background: var(--color-danger-text); border-color: var(--color-danger-text); color: #fff; }
.btn--success {
  background: var(--color-success);
  color: #fff;
  border-color: var(--color-success);
}
.btn--success:hover { background: var(--color-success-text); border-color: var(--color-success-text); color: #fff; }

.btn--sm  { padding: 5px 10px; font-size: 12px; }
.btn--lg  { padding: 11px 18px; font-size: 14px; }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

/* ── Badges (semantic status pills) ──────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.badge--success { background: var(--color-success-soft); color: var(--color-success-text); }
.badge--warning { background: var(--color-warning-soft); color: var(--color-warning-text); }
.badge--danger  { background: var(--color-danger-soft);  color: var(--color-danger-text); }
.badge--info    { background: var(--color-info-soft);    color: var(--color-info-text); }
.badge--primary { background: var(--color-primary-soft); color: var(--color-primary-strong); }
.badge--muted   { background: var(--color-surface-soft); color: var(--color-text-secondary); }

.badge--dot::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
  margin-right: 4px;
}

/* ── Modern data tables ──────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--color-surface);
}
.data-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding: 10px var(--space-4);
  background: var(--color-surface-soft);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
.data-table thead th:first-child { border-top-left-radius: var(--radius-md); }
.data-table thead th:last-child  { border-top-right-radius: var(--radius-md); }
.data-table tbody td {
  padding: 11px var(--space-4);
  font-size: 13px;
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  transition: background var(--duration-fast, 120ms) ease;
}
.data-table tbody tr:last-child td {
  border-bottom: 0;
}
.data-table tbody tr:hover td {
  background: var(--color-surface-soft);
}
.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.data-table .sku {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--color-text-primary);
  font-weight: 500;
}
.data-table--bordered {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

th.data-table__sort {
  cursor: pointer;
  user-select: none;
}
th.data-table__sort:hover {
  color: var(--color-text-primary);
}
th.data-table__sort .data-table__sort-arrow {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.4;
}
th.data-table__sort--active .data-table__sort-arrow {
  opacity: 1;
  color: var(--color-primary-strong);
}

/* ── Filter bar ──────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: flex-end;
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-card);
}
.filter-bar__group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}
.filter-bar__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}
.filter-bar__control {
  height: 34px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: 13px;
  color: var(--color-text-primary);
  font-family: inherit;
  min-width: 140px;
}
.filter-bar__control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}
.filter-bar__actions {
  display: flex;
  gap: var(--space-2);
  margin-left: auto;
}

/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  background: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
}
.empty-state__icon {
  width: 44px;
  height: 44px;
  margin: 0 auto var(--space-4);
  color: var(--color-text-muted);
  padding: var(--space-2);
  background: var(--color-surface-soft);
  border-radius: var(--radius-full);
}
.empty-state__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
  letter-spacing: -0.005em;
}
.empty-state__description {
  font-size: 13px;
  color: var(--color-text-secondary);
  max-width: 360px;
  margin: 0 auto var(--space-4);
  line-height: 1.55;
}

/* ── Skeleton / loading ──────────────────────────────────────────── */
.skeleton {
  display: block;
  background: linear-gradient(
    90deg,
    var(--color-surface-soft) 0%,
    var(--color-border) 50%,
    var(--color-surface-soft) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton--text { height: 12px; margin: 4px 0; }
.skeleton--title { height: 18px; width: 60%; margin-bottom: 8px; }
.skeleton--block { height: 80px; }
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Stat card v2 (Stage 12.0.83) ────────────────────────────────── */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transition: border-color var(--duration-fast, 120ms) ease,
              box-shadow var(--duration-normal, 180ms) var(--ease-out-quart, ease),
              transform var(--duration-normal, 180ms) var(--ease-out-quart, ease);
}
.stat-card--link { cursor: pointer; text-decoration: none; color: inherit; }
.stat-card--link:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.stat-card__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.stat-card__value {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}
.stat-card__value--success { color: var(--color-success); }
.stat-card__value--danger  { color: var(--color-danger); }
.stat-card__trend {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.stat-card__trend--up   { color: var(--color-success); }
.stat-card__trend--down { color: var(--color-danger); }
.stat-card__trend--flat { color: var(--color-text-muted); }
.stat-card__footnote {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: auto;
}

/* ── Decision card (Stage 12.0.83 Group F) ───────────────────────── */
.decision-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.decision-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.decision-card__sku {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
}
.decision-card__timestamp {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-left: auto;
}
.decision-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.decision-card__change {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.decision-card__before, .decision-card__after {
  font-family: var(--font-mono);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-soft);
  color: var(--color-text-primary);
}
.decision-card__arrow {
  color: var(--color-text-muted);
}
.decision-card__rationale {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.5;
}
.decision-card__footer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}
.decision-card__checkbox {
  margin-right: auto;
}

/* ── Card body wrapper (12.0.83) ─────────────────────────────────
 * Допускает структуру:
 *   <div class="card card--flush">
 *     <div class="card__body">…</div>
 *   </div>
 * Старое использование `<div class="card">content</div>` (12.0.40)
 * продолжает работать через outer-padding 20px 24px на .card.
 * .card__header уже определён в 12.0.40 секции выше. */
.card__body {
  padding: var(--space-5);
}
.card__body--flush { padding: 0; }

/* ── Grid helpers ────────────────────────────────────────────────── */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.grid-two-col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-4);
}
@media (max-width: 1024px) {
  .grid-two-col { grid-template-columns: 1fr; }
}

/* ── Warehouse grid (Group D) ────────────────────────────────────── */
.wh-grid-wrap {
  overflow: auto;
  max-height: 70vh;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.wh-grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.wh-grid th, .wh-grid td {
  padding: 8px 10px;
  font-size: 12px;
  border-bottom: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  text-align: center;
  font-variant-numeric: tabular-nums;
  background: var(--color-surface);
}
.wh-grid th {
  position: sticky;
  top: 0;
  background: var(--color-surface-soft);
  z-index: 2;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10.5px;
}
.wh-grid th.sticky-col, .wh-grid td.sticky-col {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--color-surface-soft);
  text-align: left;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--color-text-primary);
  min-width: 120px;
}
.wh-grid th.sticky-col {
  z-index: 4;
}
.wh-grid td.wh-cell--zero { color: var(--color-text-muted); }
.wh-grid td.wh-cell--low  { background: var(--color-warning-soft); color: var(--color-warning-text); font-weight: 600; }
.wh-grid td.wh-cell--out  { background: var(--color-danger-soft);  color: var(--color-danger-text);  font-weight: 600; }
.wh-grid tr:hover td:not(.sticky-col):not(.wh-cell--low):not(.wh-cell--out) {
  background: var(--color-surface-soft);
}

/* ── KPI card v3 — TrueStats-inspired (Stage 12.0.115) ────────────── */
.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, 12px);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 96px;
  transition: border-color var(--duration-fast, 120ms) ease,
              box-shadow var(--duration-normal, 180ms) var(--ease-out-quart, ease),
              transform var(--duration-normal, 180ms) var(--ease-out-quart, ease);
}
.kpi-card--link { cursor: pointer; text-decoration: none; color: inherit; }
.kpi-card--link:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-md, 0 2px 6px rgba(0,0,0,0.05));
  transform: translateY(-1px);
}
.kpi-card__label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.25;
}
.kpi-card__value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.kpi-card__delta {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.kpi-card__delta--good { color: var(--stat-positive, #00A85A); }
.kpi-card__delta--bad  { color: var(--stat-negative, #E63946); }
.kpi-card__delta--flat { color: var(--color-text-muted); }
.kpi-card__arrow { font-size: 13px; font-weight: 700; }
.kpi-card__delta-pct { opacity: 0.85; font-weight: 500; }
.kpi-card__prior {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: auto;
}

/* Dense KPI grid — 4 in a row на широком, 2 на mobile */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px)  { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px)  { .kpi-grid { grid-template-columns: 1fr; } }

/* ── Sparkline ─────────────────────────────────────────────────────── */
.sparkline { display: inline-block; }
.sparkline--line { display: inline-block; }

/* ── Filter chips ─────────────────────────────────────────────────── */
.filter-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 12px;
}
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--color-text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.filter-chip:hover { background: var(--color-surface-soft); border-color: var(--color-border-strong); }
.filter-chip--active { background: var(--brand-50, #EBF3FF); border-color: var(--brand-500); color: var(--brand-700); }
.filter-chip__caret { font-size: 9px; opacity: 0.6; }

/* ── Sub-navigation sidebar groups (Stage 12.0.115) ──────────────── */
.app-sidebar__group { margin-bottom: 4px; }
.app-sidebar__group-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 6px 12px;
  background: none; border: none;
  color: var(--color-text-muted);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  cursor: pointer;
  text-align: left;
}
.app-sidebar__group-toggle:hover { color: var(--color-text-primary); }
.app-sidebar__group-caret {
  margin-left: auto;
  font-size: 10px;
  transition: transform 0.15s;
}
.app-sidebar__group[open] > .app-sidebar__group-toggle .app-sidebar__group-caret {
  transform: rotate(90deg);
}
.app-sidebar__group-items { display: none; flex-direction: column; }
.app-sidebar__group[open] > .app-sidebar__group-items { display: flex; }

/* ── Sidebar divider + muted system group (Stage 12.0.173) ──────── */
.app-sidebar__divider {
  margin: 14px 12px 4px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border, rgba(0,0,0,0.08));
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  opacity: 0.7;
}
.app-sidebar__group--muted > .app-sidebar__group-toggle {
  opacity: 0.78;
}
.app-sidebar__group--muted .app-sidebar__link {
  font-size: 12px;
}
.app-sidebar__subgroup-label {
  padding: 8px 12px 2px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  opacity: 0.85;
}
.app-sidebar__subgroup-label:first-child { padding-top: 2px; }

/* ── Placeholder kpi-card (Stage 12.0.173) ───────────────────────── */
.kpi-card--placeholder {
  border-style: dashed !important;
  background: var(--color-surface-soft);
  opacity: 0.85;
}
.kpi-card--placeholder .kpi-card__value {
  font-weight: 500;
}

/* ── P&L drill-down table (Stage 12.0.115) ───────────────────────── */
.pnl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.pnl-table th, .pnl-table td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--color-border);
}
.pnl-table th:first-child, .pnl-table td:first-child {
  text-align: left;
  font-weight: 500;
}
.pnl-table thead th {
  background: var(--color-surface-soft);
  font-size: 11px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.pnl-table tr.pnl-row--parent td   { font-weight: 700; background: var(--color-surface-soft); }
.pnl-table tr.pnl-row--total td    { font-weight: 700; border-top: 2px solid var(--color-border-strong); }
.pnl-table .pnl-pct {
  display: block;
  font-size: 10px;
  color: var(--color-text-muted);
  font-weight: 400;
}
.pnl-table .pnl-cell-neg { color: var(--stat-negative, #E63946); }
.pnl-table .pnl-cell-pos { color: var(--stat-positive, #00A85A); }
.pnl-table tr.pnl-row--child td:first-child { padding-left: 28px; color: var(--color-text-secondary); font-weight: 400; }
.pnl-toggle {
  cursor: pointer;
  user-select: none;
}
.pnl-toggle::before {
  content: '▸';
  display: inline-block;
  margin-right: 6px;
  font-size: 10px;
  color: var(--color-text-muted);
  transition: transform 0.15s;
}
.pnl-toggle.is-open::before { transform: rotate(90deg); }

/* ── Plan-fact cards ───────────────────────────────────────────── */
.planfact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.planfact-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, 12px);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.planfact-card__title { font-size: 14px; font-weight: 700; color: var(--color-text-primary); }
.planfact-card__meta { font-size: 11px; color: var(--color-text-muted); }
.planfact-metric {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
}
.planfact-metric__label { color: var(--color-text-secondary); min-width: 100px; }
.planfact-metric__bar {
  flex: 1;
  height: 16px;
  background: var(--color-surface-soft);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}
.planfact-metric__fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  border-radius: 8px;
  transition: width 0.3s;
}
.planfact-metric__fill--good   { background: var(--stat-positive, #00A85A); }
.planfact-metric__fill--mid    { background: #F59E0B; }
.planfact-metric__fill--bad    { background: var(--stat-negative, #E63946); }
.planfact-metric__pct {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-primary);
  min-width: 42px;
  text-align: right;
}

/* ── RNP module ────────────────────────────────────────────────── */
.rnp-tabs {
  display: inline-flex;
  background: var(--color-surface-soft);
  padding: 3px;
  border-radius: var(--radius-md, 8px);
  gap: 2px;
  margin-bottom: 12px;
}
.rnp-tabs__tab {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
}
.rnp-tabs__tab--active {
  background: var(--color-surface);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.04));
}
.rnp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.rnp-table th, .rnp-table td {
  padding: 6px 8px;
  text-align: right;
  border-bottom: 1px solid var(--color-border);
}
.rnp-table th { background: var(--color-surface-soft); font-size: 10px; text-transform: uppercase; color: var(--color-text-muted); }
.rnp-table th:first-child, .rnp-table td:first-child {
  text-align: left; font-weight: 500;
  position: sticky; left: 0; background: var(--color-surface);
}

/* ── Donut + Pie placeholders ─────────────────────────────────── */
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 900px) { .chart-row { grid-template-columns: 1fr; } }
.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, 12px);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chart-card__title { font-size: 13px; font-weight: 600; color: var(--color-text-primary); }
.chart-card__canvas-wrap { position: relative; height: 220px; }

/* ──────────────────────────────────────────────────────────────────
 * Stage 12.0.246 — design polish layer
 * Alerts, section titles, list-rows, legacy-bootstrap-class compat
 * so older pages (reports_list, reports_detail) inherit the design
 * system without rewriting their markup top-to-bottom.
 * ────────────────────────────────────────────────────────────────── */

/* Section title — for inline H2/H3 within cards or pages */
.section-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text-primary);
  margin: var(--space-6) 0 var(--space-3);
}
.section-title:first-child { margin-top: 0; }
.section-subtitle {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.55;
  margin: 0 0 var(--space-4);
  max-width: 65ch;
}

/* List-row pattern — clean alternative to ul-li with inline styles */
.list-rows {
  list-style: none;
  padding: 0;
  margin: 0;
}
.list-rows > li {
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  transition: background var(--duration-fast, 120ms) ease;
}
.list-rows > li:first-child { border-top: 0; }
.list-rows > li:hover { background: var(--color-surface-soft); }
.list-rows__primary { font-size: 13px; color: var(--color-text-primary); flex: 1; min-width: 0; }
.list-rows__meta { font-size: 12px; color: var(--color-text-muted); flex-shrink: 0; }

/* Alert / callout — inline banner inside content */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: var(--space-4);
  border: 1px solid transparent;
}
.alert__icon { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.alert__body { flex: 1; min-width: 0; }
.alert__title { font-weight: 600; margin-bottom: 2px; }
.alert--info,
.alert-info {
  background: var(--color-info-soft);
  color: var(--color-info-text);
  border-color: color-mix(in oklab, var(--color-info) 22%, transparent);
}
.alert--success,
.alert-success {
  background: var(--color-success-soft);
  color: var(--color-success-text);
  border-color: color-mix(in oklab, var(--color-success) 22%, transparent);
}
.alert--warning,
.alert-warning {
  background: var(--color-warning-soft);
  color: var(--color-warning-text);
  border-color: color-mix(in oklab, var(--color-warning) 25%, transparent);
}
.alert--danger,
.alert-danger {
  background: var(--color-danger-soft);
  color: var(--color-danger-text);
  border-color: color-mix(in oklab, var(--color-danger) 25%, transparent);
}

/* Legacy-bootstrap class compatibility — minimal so old pages don't look raw.
   Maps `.table .table-striped`, `.btn-primary`, `.btn-link`, etc. onto our
   tokens. Pages we own should migrate to design-system classes; this is the
   safety net while we do so. */
table.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--color-surface);
  font-size: 13px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-4);
}
table.table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding: 10px 14px;
  background: var(--color-surface-soft);
  border-bottom: 1px solid var(--color-border);
}
table.table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  color: var(--color-text-primary);
}
table.table tbody tr:last-child td { border-bottom: 0; }
table.table tbody tr:hover td { background: var(--color-surface-soft); }
table.table.table-striped tbody tr:nth-child(even) td {
  background: color-mix(in oklab, var(--color-surface-soft) 50%, transparent);
}

/* Bootstrap btn-* compatibility — render the same as our .btn family */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2); padding: 8px 14px; min-height: 34px;
  border-radius: var(--radius-md); font-size: 13px; font-weight: 600;
  line-height: 1.2; cursor: pointer;
  border: 1px solid var(--color-primary);
  background: var(--color-primary); color: #fff;
  text-decoration: none; font-family: inherit;
  transition: background var(--duration-fast, 120ms) ease;
}
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); color: #fff; }
.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2); padding: 8px 14px; min-height: 34px;
  border-radius: var(--radius-md); font-size: 13px; font-weight: 600;
  line-height: 1.2; cursor: pointer;
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface); color: var(--color-text-primary);
  text-decoration: none; font-family: inherit;
  transition: background var(--duration-fast, 120ms) ease;
}
.btn-secondary:hover { background: var(--color-surface-soft); }
.btn-link {
  color: var(--color-primary-strong);
  text-decoration: none;
  font-weight: 500;
}
.btn-link:hover { text-decoration: underline; text-underline-offset: 2px; }

/* Bootstrap row/col compat — minimum so reports_detail layout doesn't collapse */
.row {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.col-md-6 { grid-column: span 12; }
@media (min-width: 768px) {
  .col-md-6 { grid-column: span 6; }
}

/* Bootstrap badge compat */
.badge.bg-warning {
  display: inline-flex; align-items: center; padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600;
  background: var(--color-warning-soft); color: var(--color-warning-text);
}
.badge.bg-secondary {
  display: inline-flex; align-items: center; padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600;
  background: var(--color-surface-soft); color: var(--color-text-secondary);
}
