/* AISIR-IDEAL Design System v25
   One token source for every production screen. */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --page-bg: #e7edf2;
  --card-bg: #ffffff;
  --surface-subtle: #f1f5f8;
  --surface-strong: #d4dee6;
  --row-alt: #e8eef3;
  --row-hover: #d9ebe7;
  --row-selected: #c6e3dd;
  --border: #aebbc6;
  --border-strong: #7d8b99;
  --text-primary: #17212b;
  --text-secondary: #465568;
  --text-placeholder: #59687a;
  --accent: #08695f;
  --accent-strong: #064f48;
  --success: #067647;
  --error: #b42318;
  --warning: #8a4b08;
  --info: #175cd3;
  --focus: #175cd3;
  --disabled-bg: #d5dde4;
  --disabled-text: #52606d;
  --tooltip-bg: #111827;
  --tooltip-text: #ffffff;
  --store-sirik: #0f766e;
  --store-baza: #5b21b6;
  --store-vip: #92400e;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);

  /* Compatibility aliases used by the existing screens. */
  --bg: var(--page-bg);
  --bg-soft: var(--surface-subtle);
  --surface: var(--card-bg);
  --surface-solid: var(--card-bg);
  --surface-2: var(--surface-subtle);
  --surface-3: var(--row-alt);
  --surface2: var(--surface-subtle);
  --line: var(--border);
  --line-strong: var(--border-strong);
  --text: var(--text-primary);
  --text-strong: var(--text-primary);
  --muted: var(--text-secondary);
  --muted-2: var(--text-placeholder);
  --blue: var(--accent);
  --brand-a: var(--accent);
  --brand-b: var(--accent-strong);
  --good: var(--success);
  --bad: var(--error);
  --warn: var(--warning);
  --cyan: var(--info);
  --glass: var(--card-bg);
  --shadow: var(--shadow-card);
  --shadow-small: var(--shadow-card);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #0b1118;
  --card-bg: #151e28;
  --surface-subtle: #1b2733;
  --surface-strong: #2d3c4b;
  --row-alt: #223140;
  --row-hover: #263f3d;
  --row-selected: #17423d;
  --border: #526171;
  --border-strong: #738195;
  --text-primary: #f3f6fa;
  --text-secondary: #b7c2cf;
  --text-placeholder: #a7b3c1;
  --accent: #5fe0d0;
  --accent-strong: #7ce9dc;
  --success: #6ce9a6;
  --error: #fda29b;
  --warning: #fec84b;
  --info: #84adff;
  --focus: #84adff;
  --disabled-bg: #202a35;
  --disabled-text: #a7b3c1;
  --tooltip-bg: #050a10;
  --tooltip-text: #ffffff;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .28), 0 12px 30px rgba(0, 0, 0, .22);

  --bg: var(--page-bg);
  --bg-soft: var(--surface-subtle);
  --surface: var(--card-bg);
  --surface-solid: var(--card-bg);
  --surface-2: var(--surface-subtle);
  --surface-3: var(--row-alt);
  --surface2: var(--surface-subtle);
  --line: var(--border);
  --line-strong: var(--border-strong);
  --text: var(--text-primary);
  --text-strong: var(--text-primary);
  --muted: var(--text-secondary);
  --muted-2: var(--text-placeholder);
  --blue: var(--accent);
  --brand-a: #0f766e;
  --brand-b: #0b5f58;
  --good: var(--success);
  --bad: var(--error);
  --warn: var(--warning);
  --cyan: var(--info);
  --glass: var(--card-bg);
  --shadow: var(--shadow-card);
  --shadow-small: var(--shadow-card);
}

:root[data-theme="navy"] {
  color-scheme: dark;
  --page-bg: #071521;
  --card-bg: #102536;
  --surface-subtle: #173247;
  --surface-strong: #29465d;
  --row-alt: #1b3a50;
  --row-hover: #1c4a47;
  --row-selected: #145348;
  --border: #4a667e;
  --border-strong: #6f879a;
  --text-primary: #f2f7fb;
  --text-secondary: #b8cad8;
  --text-placeholder: #a8bac9;
  --accent: #63dfd0;
  --accent-strong: #85eadf;
  --success: #6ce9a6;
  --error: #fda29b;
  --warning: #fec84b;
  --info: #84adff;
  --focus: #84adff;
  --disabled-bg: #20394c;
  --disabled-text: #b0c0cd;
  --tooltip-bg: #020811;
  --tooltip-text: #ffffff;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .26), 0 12px 30px rgba(0, 0, 0, .2);

  --bg: var(--page-bg);
  --bg-soft: var(--surface-subtle);
  --surface: var(--card-bg);
  --surface-solid: var(--card-bg);
  --surface-2: var(--surface-subtle);
  --surface-3: var(--row-alt);
  --surface2: var(--surface-subtle);
  --line: var(--border);
  --line-strong: var(--border-strong);
  --text: var(--text-primary);
  --text-strong: var(--text-primary);
  --muted: var(--text-secondary);
  --muted-2: var(--text-placeholder);
  --blue: var(--accent);
  --brand-a: #0f766e;
  --brand-b: #0b5f58;
  --good: var(--success);
  --bad: var(--error);
  --warn: var(--warning);
  --cyan: var(--info);
  --glass: var(--card-bg);
  --shadow: var(--shadow-card);
  --shadow-small: var(--shadow-card);
}

html { background: var(--page-bg) !important; }
body {
  background: var(--page-bg) !important;
  color: var(--text-primary) !important;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif !important;
}

/* The legacy main screen used a higher-specificity nearly-white background. */
:root[data-theme="light"] body,
:root[data-theme="light"] .dashboard,
:root[data-theme="light"] .right-rail { background: var(--page-bg) !important; }

:root[data-theme="light"] .panel,
:root[data-theme="light"] .kpi,
:root[data-theme="light"] .store-card {
  border-color: var(--border) !important;
}

:root[data-theme="light"] .kpi-value,
:root[data-theme="light"] .panel h2,
:root[data-theme="light"] .store-card h3 { color: var(--text-primary) !important; }

body,
button,
input,
select,
textarea { font-size: 14px; }

input[type="number"],
input[type="date"],
input[type="month"],
.number,
[data-numeric] {
  font-variant-numeric: tabular-nums lining-nums;
}

input[type="number"] { text-align: right; }

button,
a,
input,
select,
textarea,
[role="button"] { transition: background-color .14s ease, border-color .14s ease, color .14s ease, box-shadow .14s ease; }

a { color: var(--accent); }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--text-primary); }
input[type="checkbox"],
input[type="radio"] { accent-color: var(--accent); }
option { background: var(--card-bg); color: var(--text-primary); }
code,
kbd { background: var(--surface-subtle); color: var(--text-primary); border-color: var(--border); }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus) !important;
  outline-offset: 3px !important;
}

input,
select,
textarea {
  background: var(--card-bg) !important;
  border-color: var(--border-strong) !important;
  color: var(--text-primary) !important;
}

input::placeholder,
textarea::placeholder { color: var(--text-placeholder) !important; opacity: 1; }

:where(button:not(.primary):not(.primary-btn):not(.v23-primary)),
.back,
.ghost-btn,
.icon-btn,
.panel-open-btn,
.top-actions a {
  background: var(--surface-subtle) !important;
  border-color: var(--border-strong) !important;
  color: var(--text-primary) !important;
}

button:not(:disabled):hover,
.back:hover,
.ghost-btn:hover,
.icon-btn:hover,
.panel-open-btn:hover,
.top-actions a:hover { background: var(--row-hover) !important; border-color: var(--accent) !important; }

.primary,
.primary-btn,
.v23-primary {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #ffffff !important;
}

:root[data-theme="dark"] .primary,
:root[data-theme="dark"] .primary-btn,
:root[data-theme="dark"] .v23-primary,
:root[data-theme="navy"] .primary,
:root[data-theme="navy"] .primary-btn,
:root[data-theme="navy"] .v23-primary { color: #071411 !important; }

.sync {
  background: color-mix(in srgb, var(--accent) 10%, var(--card-bg)) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

.ghost-btn.danger,
button.danger,
.return-actions .no-restock {
  background: color-mix(in srgb, var(--error) 9%, var(--card-bg)) !important;
  border-color: var(--error) !important;
  color: var(--error) !important;
}

.return-actions .restock {
  background: color-mix(in srgb, var(--success) 10%, var(--card-bg)) !important;
  border-color: var(--success) !important;
  color: var(--success) !important;
}

button:disabled:disabled,
input:disabled:disabled,
select:disabled:disabled,
textarea:disabled:disabled,
[aria-disabled="true"][aria-disabled="true"] {
  background: var(--disabled-bg) !important;
  border-color: var(--border) !important;
  color: var(--disabled-text) !important;
  cursor: not-allowed !important;
  opacity: 1 !important;
}

.topbar,
.business-topbar {
  background: var(--card-bg) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
  z-index: 50 !important;
}

.panel,
.card,
.metric,
.store,
.business-card,
.workspace-card,
.workspace-stat,
.kpi,
.store-card,
.login-card,
.shared-settings,
.store-setting-card,
.ozb-total,
.ozb-reconcile,
.ozb-row,
.openai-status-grid > div,
.ai-chat-message {
  background: var(--card-bg) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
  box-shadow: var(--shadow-card) !important;
}

.mini > div,
.formula-grid > div,
.quality-grid > div,
.report-store-grid > div,
.return-row,
.snapshot-detail-totals > div,
.ozon-finance-numbers > div,
.ozon-cost-numbers > div,
.ozon-profit-numbers > div,
.workspace-feature-grid > div,
.integration-row,
.timeline-item,
.reconcile,
.tax-rule,
.openai-budget-card,
.agent-policy-list > div {
  background: var(--surface-subtle) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}

.panel h1,
.panel h2,
.panel h3,
.card strong,
.metric strong,
.store h3,
.business-card h1,
.business-card h2,
.business-card h3,
.workspace-card h3,
.workspace-stat strong,
.kpi-value,
.store-number { color: var(--text-primary) !important; }

.panel p,
.panel-title p,
.card span,
.card small,
.metric span,
.store .status,
.business-card > p,
.card-head p,
.business-stat > span,
.business-stat > small,
.workspace-card p,
.workspace-stat span,
.workspace-stat small,
.kpi-title,
.kpi-sub,
.hint,
.sub,
.muted { color: var(--text-secondary) !important; }

.eyebrow,
.business-eyebrow,
.v23-eyebrow,
.top p,
.top .sub,
.business-sidebar-title,
label,
.form-hint,
.tax-rule,
.snapshot-message { color: var(--text-secondary) !important; }

.badge,
.source-chip,
.business-badge {
  background: var(--surface-subtle) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-secondary) !important;
}

/* Persistent store identity. These exact colors are shared across every theme. */
[data-store="sirik_baza"] { --store-color: var(--store-sirik); }
[data-store="baza_i_tochka"] { --store-color: var(--store-baza); }
[data-store="viptatsnab"] { --store-color: var(--store-vip); }

.store-name {
  color: var(--text-primary) !important;
  font-weight: 750;
}

h1.store-name,
h2.store-name,
h3.store-name,
strong.store-name,
span.store-name,
div.store-name { display: inline-flex; align-items: center; gap: 8px; }

.store-name::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 2px;
  background: var(--store-color);
  margin-right: 8px;
}

h1.store-name::before,
h2.store-name::before,
h3.store-name::before,
strong.store-name::before,
span.store-name::before,
div.store-name::before { margin-right: 0; }

.store[data-store],
.store-card[data-store],
.report-store[data-store],
.store-setting-card[data-store],
.workspace-card[data-store] { border-top: 4px solid var(--store-color) !important; }

tr[data-store] > :first-child,
.table-row[data-store] > :first-child,
.metric-row[data-store] > :first-child { box-shadow: inset 4px 0 0 var(--store-color); }

select[data-store] { border-left: 4px solid var(--store-color) !important; }

/* Theme toggle available on every screen. */
.aisir-theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong) !important;
  border-radius: 8px !important;
  background: var(--surface-subtle) !important;
  color: var(--text-primary) !important;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.aisir-theme-toggle:hover { background: var(--row-hover) !important; border-color: var(--accent) !important; }
.aisir-theme-toggle-icon { font-size: 16px; line-height: 1; }

/* KPIs: value first, label second, comparison always explicit. */
.kpi,
.card,
.metric,
.business-stat,
.workspace-stat { font-variant-numeric: tabular-nums lining-nums; }

.kpi-value,
.card > strong,
.metric > strong,
.business-stat > strong,
.workspace-stat > strong,
.store-number,
.report-store-grid strong,
.mini b,
.ozb-total strong {
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -.025em;
}

.kpi-delta {
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  width: fit-content;
  margin-top: 8px !important;
  padding: 3px 7px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 12px !important;
  font-weight: 750;
  line-height: 1.3;
}

.kpi-delta.up.good,
.kpi-delta.down.good { color: var(--success) !important; }
.kpi-delta.up.bad,
.kpi-delta.down.bad { color: var(--error) !important; }
.kpi-delta.neutral { color: var(--text-secondary) !important; }

.value-missing,
[data-value-state="missing"] { color: var(--text-secondary) !important; font-style: italic; font-weight: 650 !important; }
.value-zero,
[data-value-state="zero"] { color: var(--text-primary) !important; font-style: normal; }

/* Tables: visible structure, zebra rows, sticky head/first column, selection and sorting. */
.table-wrap,
.business-table-wrap {
  overflow: auto !important;
  max-height: min(72vh, 760px);
  border: 1px solid var(--border-strong) !important;
  border-radius: 10px !important;
  background: var(--card-bg) !important;
  scrollbar-color: var(--border-strong) var(--surface-subtle);
}

table,
.business-table {
  width: 100%;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  color: var(--text-primary) !important;
  font-variant-numeric: tabular-nums lining-nums;
}

table th,
table td,
.business-table th,
.business-table td {
  padding: 12px 13px !important;
  border-right: 1px solid var(--border) !important;
  border-bottom: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
  background: var(--card-bg) !important;
  font-size: 13px !important;
  line-height: 1.45;
  vertical-align: top;
}

table th:last-child,
table td:last-child { border-right: 0 !important; }
table tbody tr:last-child td { border-bottom: 0 !important; }

table thead th,
.business-table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 6 !important;
  background: var(--surface-strong) !important;
  color: var(--text-primary) !important;
  font-size: 12px !important;
  font-weight: 800 !important;
  letter-spacing: .02em !important;
  text-transform: none !important;
  white-space: normal !important;
}

table tbody tr:nth-child(even) td,
.business-table tbody tr:nth-child(even) td { background: var(--row-alt) !important; }

table tbody tr:hover td,
.business-table tbody tr:hover td { background: var(--row-hover) !important; }

table tbody tr.is-selected td,
.business-table tbody tr.is-selected td {
  background: var(--row-selected) !important;
  box-shadow: inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent);
}

table th:first-child,
table td:first-child,
.business-table th:first-child,
.business-table td:first-child {
  position: static !important;
  left: auto !important;
  min-width: 0;
  max-width: none;
  box-shadow: none;
}

table .is-primary-column,
.business-table .is-primary-column {
  position: sticky !important;
  left: 0 !important;
  z-index: 4 !important;
  min-width: 230px;
  max-width: 380px;
  white-space: normal !important;
  overflow-wrap: anywhere;
  text-overflow: clip !important;
}

table thead .is-primary-column,
.business-table thead .is-primary-column { z-index: 8 !important; background: var(--surface-strong) !important; }

table tbody tr.is-selected .is-primary-column,
.business-table tbody tr.is-selected .is-primary-column { box-shadow: inset 4px 0 0 var(--accent), inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent); }

table td:not(.is-numeric),
.business-table td:not(.is-numeric) {
  white-space: normal !important;
  overflow-wrap: anywhere;
}

table .is-numeric,
.business-table .is-numeric,
.business-table .number {
  text-align: right !important;
  white-space: nowrap !important;
  font-variant-numeric: tabular-nums lining-nums;
}

.aisir-sort-button {
  display: inline-flex;
  align-items: center;
  justify-content: inherit;
  gap: 6px;
  width: 100%;
  min-height: 32px;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 5px !important;
  background: transparent !important;
  color: inherit !important;
  font: inherit;
  font-weight: inherit;
  text-align: inherit;
  cursor: pointer;
}

.is-numeric .aisir-sort-button { justify-content: flex-end; }
.aisir-sort-button:hover { color: var(--accent) !important; }
.aisir-sort-indicator { min-width: 14px; color: var(--text-secondary); font-size: 12px; }
th[aria-sort="ascending"] .aisir-sort-indicator,
th[aria-sort="descending"] .aisir-sort-indicator,
[role="columnheader"][aria-sort="ascending"] .aisir-sort-indicator,
[role="columnheader"][aria-sort="descending"] .aisir-sort-indicator { color: var(--accent); font-weight: 900; }

/* Div-based tables on the owner dashboard. */
.store-table,
.workspace-table,
.metric-table { border: 1px solid var(--border-strong) !important; border-radius: 10px !important; overflow: auto !important; }

.table-row,
.workspace-tr,
.metric-row {
  border-top: 1px solid var(--border) !important;
  background: var(--card-bg) !important;
  color: var(--text-primary) !important;
  font-variant-numeric: tabular-nums lining-nums;
}

.table-row > :first-child,
.workspace-tr > :first-child,
.metric-row > :first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 180px;
  padding-left: 12px;
  background: inherit;
  white-space: normal;
  overflow-wrap: anywhere;
}

.table-head > :first-child,
.workspace-tr.head > :first-child,
.metric-row.head > :first-child { z-index: 7; }

.table-row:nth-child(odd):not(.table-head),
.workspace-tr:nth-child(odd):not(.head),
.metric-row:nth-child(odd):not(.head) { background: var(--row-alt) !important; }

.table-row:not(.table-head):hover,
.workspace-tr.row:hover,
.metric-row:not(.head):hover { background: var(--row-hover) !important; }

.table-row.is-selected,
.workspace-tr.is-selected,
.metric-row.is-selected { background: var(--row-selected) !important; outline: 2px solid var(--accent); outline-offset: -2px; }

.table-row .is-numeric,
.workspace-tr .is-numeric,
.metric-row .is-numeric { text-align: right !important; white-space: nowrap; font-variant-numeric: tabular-nums lining-nums; }

.table-head,
.workspace-tr.head,
.metric-row.head {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface-strong) !important;
  color: var(--text-primary) !important;
  font-weight: 800;
}

/* Sticky filter surface and visible selected controls. */
.aisir-filter-panel,
.period-panel {
  position: sticky !important;
  top: 78px !important;
  z-index: 20 !important;
  background: color-mix(in srgb, var(--card-bg) 94%, transparent) !important;
  border: 1px solid var(--border-strong) !important;
  box-shadow: var(--shadow-card) !important;
  backdrop-filter: blur(14px);
}

.performance-stats-body .aisir-filter-panel { top: 12px !important; }
.finance-body .period-panel { top: 92px !important; }

.range,
.dates,
.business-toolbar {
  color: var(--text-primary) !important;
}

.filter-selection,
button.active,
.theme-option.active,
.admin-tabs button.active,
.business-sidebar nav button.active {
  border-color: var(--accent) !important;
  background: color-mix(in srgb, var(--accent) 14%, var(--card-bg)) !important;
  color: var(--text-primary) !important;
  box-shadow: inset 0 -3px 0 var(--accent) !important;
}

.aisir-filter-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  margin-top: 10px;
}

.aisir-filter-chip {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
}

.aisir-filter-chip[data-store="sirik_baza"],
.aisir-filter-chip[data-store="baza_i_tochka"],
.aisir-filter-chip[data-store="viptatsnab"] {
  border-color: var(--store-color);
  box-shadow: inset 4px 0 0 var(--store-color);
  padding-left: 12px;
}

/* Loading is visible structure, never an empty white surface. */
.aisir-skeleton-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; width: 100%; }
.aisir-skeleton-card,
.aisir-skeleton-line {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface-strong) !important;
}
.aisir-skeleton-card { min-height: 104px; border: 1px solid var(--border); }
.aisir-skeleton-line { height: 16px; margin: 8px 0; }
.aisir-skeleton-card::after,
.aisir-skeleton-line::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--card-bg) 72%, transparent), transparent);
  animation: aisir-shimmer 1.15s infinite;
}
@keyframes aisir-shimmer { 100% { transform: translateX(100%); } }

/* Native chart primitives used by the advertising screen. */
.aisir-chart-panel { overflow: visible; }
#storeChart { overflow-x: auto; }
.aisir-chart-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.aisir-chart-head h2 { margin: 0; font-size: 18px; }
.aisir-chart-head p { margin: 4px 0 0; color: var(--text-secondary); }
.aisir-chart-legend { display: flex; gap: 12px; flex-wrap: wrap; color: var(--text-primary); font-size: 12px; }
.aisir-chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.aisir-chart-legend i { width: 18px; height: 8px; border-radius: 2px; background: var(--text-secondary); }
.aisir-chart-legend i.spend { opacity: .45; }
.aisir-store-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: -4px 0 14px; color: var(--text-primary); font-size: 12px; font-weight: 700; }
.aisir-store-legend span { display: inline-flex; align-items: center; gap: 7px; }
.aisir-store-legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--store-color); }
.aisir-chart-axis { display: grid; grid-template-columns: 150px repeat(5, 1fr); gap: 0; min-width: 650px; color: var(--text-primary); font-size: 11px; font-variant-numeric: tabular-nums; }
.aisir-chart-axis span:first-child { color: transparent; }
.aisir-chart-axis span:not(:first-child) { text-align: right; }
.aisir-chart-plot { min-width: 650px; margin-top: 6px; border-top: 1px solid var(--border-strong); }
.aisir-chart-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.aisir-chart-label { color: var(--text-primary); font-weight: 750; }
.aisir-chart-bars { display: grid; gap: 6px; background-image: linear-gradient(to right, var(--border) 1px, transparent 1px); background-size: 25% 100%; }
.aisir-chart-track { min-height: 23px; }
.aisir-chart-bar { position: relative; min-width: 3px; height: 23px; border-radius: 4px; background: var(--store-color); outline: 1px solid color-mix(in srgb, var(--store-color) 72%, black); }
.aisir-chart-bar.spend { opacity: .48; background-image: repeating-linear-gradient(135deg, transparent 0 5px, rgba(255,255,255,.38) 5px 8px); }
.aisir-chart-bar::after {
  content: attr(data-tooltip);
  position: absolute;
  left: min(100%, calc(100vw - 320px));
  bottom: calc(100% + 8px);
  z-index: 40;
  display: none;
  width: max-content;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0,0,0,.32);
  white-space: normal;
}
.aisir-chart-bar:hover::after,
.aisir-chart-bar:focus-visible::after { display: block; }

/* Readable desktop density for the formerly 8–10 px advertising screen. */
.performance-stats-body .top p,
.performance-stats-body .hint,
.performance-stats-body .panel-head p,
.performance-stats-body .store .status { font-size: 12px !important; line-height: 1.45; }
.performance-stats-body .range label,
.performance-settings-body label { font-size: 12px !important; }
.performance-settings-body .notice,
.performance-settings-body .status,
.performance-settings-body .result,
.performance-settings-body #global { font-size: 12px !important; line-height: 1.5; }
.performance-stats-body .metric span,
.performance-stats-body .mini span { font-size: 11px !important; }
.performance-stats-body .metric strong { font-size: clamp(19px, 1.55vw, 24px) !important; }
.performance-stats-body .mini b { font-size: 13px !important; }
.performance-stats-body .reconcile,
.performance-stats-body .risk-totals { font-size: 12px !important; line-height: 1.45; }
.performance-stats-body .risk { font-size: 11px !important; }

.good,
.good-cell,
.profit-ready,
.snapshot-ready { color: var(--success) !important; }
.bad,
.danger-text,
.review-error,
.snapshot-blocked { color: var(--error) !important; }
.warn,
.blocked,
.snapshot-partial { color: var(--warning) !important; }

.status-panel,
.warning,
.readiness,
.notice,
.business-notice,
.review-empty,
.review-error,
.ozb-loading,
.ozb-error {
  background: var(--surface-subtle) !important;
  border-color: var(--border-strong) !important;
  color: var(--text-primary) !important;
}

.status-panel.good,
.readiness.good,
.business-notice.good,
.source-chip.good,
.business-badge.good {
  background: color-mix(in srgb, var(--success) 10%, var(--card-bg)) !important;
  border-color: var(--success) !important;
  color: var(--success) !important;
}

.readiness.warn,
.source-chip.warn,
.business-badge.warn,
.preliminary-badge {
  background: color-mix(in srgb, var(--warning) 10%, var(--card-bg)) !important;
  border-color: var(--warning) !important;
  color: var(--warning) !important;
}

.business-notice.bad,
.source-chip.bad,
.business-badge.bad,
.review-error,
.ozb-error {
  background: color-mix(in srgb, var(--error) 9%, var(--card-bg)) !important;
  border-color: var(--error) !important;
  color: var(--error) !important;
}

.card.featured,
.return-card { border-left: 4px solid var(--success) !important; }
.review-card { border-left: 4px solid var(--warning) !important; }

.risk.green { background: color-mix(in srgb, var(--success) 16%, var(--card-bg)) !important; color: var(--success) !important; }
.risk.yellow { background: color-mix(in srgb, var(--warning) 16%, var(--card-bg)) !important; color: var(--warning) !important; }
.risk.red,
.risk.waste { background: color-mix(in srgb, var(--error) 15%, var(--card-bg)) !important; color: var(--error) !important; }

/* Legacy special surfaces now follow the same semantic tokens in both themes. */
.ozon-readonly,
.review-empty,
.ozon-cost-numbers .ready,
.ozon-profit-numbers .ready,
.profit-ready {
  background: color-mix(in srgb, var(--success) 10%, var(--card-bg)) !important;
  border-color: var(--success) !important;
  color: var(--success) !important;
}

.ozon-finance-note,
.ozon-cost-numbers .waiting,
.ozon-profit-numbers .waiting,
.profit-blocked,
.month-load-panel,
#mainFinancePreliminaryV223 {
  background: color-mix(in srgb, var(--warning) 10%, var(--card-bg)) !important;
  border-color: var(--warning) !important;
  color: var(--warning) !important;
}

.ozon-finance-error,
.field-error,
.form-error { color: var(--error) !important; }

.ozon-notice.good,
.ozon-finance-group-row .positive,
.ozon-cost-all-ready { color: var(--success) !important; }
.ozon-notice.bad,
.ozon-finance-group-row .negative { color: var(--error) !important; }
.ozon-notice.warn { color: var(--warning) !important; }
.ozon-notice.live { color: var(--info) !important; }

@media (max-width: 900px) {
  .aisir-filter-panel,
  .period-panel { position: static !important; }
}

@media (prefers-reduced-motion: reduce) {
  .aisir-skeleton-card::after,
  .aisir-skeleton-line::after { animation: none; }
}
