/* Profit centre (Ozon and Wildberries). Built on design-tokens.css.
   Layout: a navigation rail (platform + sections) beside a fluid content column
   on a 12-column grid. Cards are size containers, so each chart adapts to the
   width it actually gets rather than to the window. Type is one step larger than
   the rest of the ERP: these pages are read, not scanned. */
* { box-sizing: border-box; }
:root {
  --fs-xs: 13px; --fs-sm: 14px; --fs-base: 15px; --fs-md: 17px; --fs-lg: 20px; --fs-xl: 26px; --fs-2xl: 32px; --fs-hero: 46px;
  --rail-width: 248px; --gutter: clamp(16px, 2vw, 32px); --gap: 20px; --card-pad: 22px;
}
body { margin: 0; background: var(--color-page); color: var(--color-text); font: var(--fs-base)/1.55 var(--font-ui); -webkit-font-smoothing: antialiased; }
a { color: var(--color-info); }
button, input, select { font: inherit; }
button { min-height: 40px; padding: 0 var(--space-4); border: 1px solid var(--color-border); border-radius: var(--control-radius); background: var(--color-surface); color: var(--color-text); cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--color-muted); }
button.primary { background: var(--color-action); border-color: var(--color-action); color: var(--white); font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--color-action-hover); }
button.danger { color: var(--color-danger); border-color: var(--color-danger); }
button:disabled { opacity: .55; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--color-info); outline-offset: 2px; }
input, select { min-height: 40px; padding: 0 var(--space-3); border: 1px solid var(--color-border); border-radius: var(--control-radius); background: var(--color-surface); color: var(--color-text); }
small { display: block; color: var(--color-muted); font-size: var(--fs-xs); line-height: 1.45; }
.op-skip { position: absolute; left: -9999px; }
.op-skip:focus { left: var(--space-4); top: var(--space-2); z-index: 20; background: var(--color-surface); padding: var(--space-2); }
.op-loading, .op-denied { max-width: 640px; margin: 15vh auto; padding: 0 var(--space-4); text-align: center; font-size: var(--fs-md); }

/* ---- App frame ---- */
.op-app { display: grid; grid-template-columns: var(--rail-width) minmax(0, 1fr); min-height: 100vh; }
.op-rail { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-6); padding: var(--space-6) var(--space-4); background: var(--color-surface); border-right: 1px solid var(--color-border); }
.op-rail-brand { display: grid; gap: 2px; padding: 0 var(--space-2); text-decoration: none; color: inherit; }
.op-rail-brand strong { color: var(--color-brand); font-size: var(--fs-lg); letter-spacing: .02em; }
.op-rail-brand span { color: var(--color-muted); font-size: var(--fs-sm); }
.op-rail-label { margin: 0 0 var(--space-2); padding: 0 var(--space-2); color: var(--color-muted); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; }
.op-platforms { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.op-platform { display: grid; place-items: center; gap: 2px; min-height: 64px; padding: var(--space-2); border: 1px solid var(--color-border); border-radius: var(--panel-radius); color: var(--color-text); text-decoration: none; font-weight: 600; font-size: var(--fs-sm); }
.op-platform b { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: var(--white); font-size: 12px; letter-spacing: .02em; }
.op-platform-ozon b { background: #005bff; } .op-platform-wb b { background: #a73afd; }
.op-platform[aria-current="page"] { border-color: var(--color-action); background: var(--color-action-soft); color: var(--color-action); box-shadow: inset 0 0 0 1px var(--color-action); }
.op-platform:hover { border-color: var(--color-muted); }
.op-nav { display: grid; gap: 2px; }
.op-nav button { display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 44px; padding: 0 var(--space-3); border: 0; border-radius: var(--control-radius); background: transparent; text-align: left; font-size: var(--fs-base); color: var(--color-text); }
.op-nav button svg { flex: none; width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: var(--color-muted); }
.op-nav button:hover:not(:disabled) { background: var(--slate-100); }
.op-nav button[aria-current="page"] { background: var(--color-action-soft); color: var(--color-action); font-weight: 600; }
.op-nav button[aria-current="page"] svg { color: var(--color-action); }
.op-nav-count { margin-left: auto; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--color-action); color: var(--white); font-size: 12px; font-weight: 600; text-align: center; }
.op-rail-foot { margin-top: auto; display: grid; gap: var(--space-2); padding: var(--space-3) var(--space-2) 0; border-top: 1px solid var(--color-border); font-size: var(--fs-sm); color: var(--color-muted); }
.op-main { min-width: 0; display: flex; flex-direction: column; }
.op-topbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3) var(--space-6);
  padding: var(--space-4) var(--gutter); background: rgb(255 255 255 / 92%); backdrop-filter: blur(8px); border-bottom: 1px solid var(--color-border); }
.op-title { min-width: 0; }
.op-title h1 { margin: 0; font-size: var(--fs-xl); line-height: 1.25; display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.op-title p { margin: 2px 0 0; color: var(--color-muted); font-size: var(--fs-sm); }
.op-sim { font-size: var(--fs-xs); font-weight: 600; padding: 2px var(--space-2); border-radius: 999px; background: var(--color-warning-soft); color: var(--color-warning); }
.op-toolbar { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: end; }
.op-toolbar label { display: grid; gap: 2px; font-size: var(--fs-xs); color: var(--color-muted); }
.op-toolbar select { min-width: 150px; font-size: var(--fs-base); }
.op-toolbar button { min-height: 40px; }
.op-content { width: 100%; max-width: 1880px; margin: 0 auto; padding: var(--space-6) var(--gutter) 64px; }
.op-messages:empty { display: none; }
.op-messages { display: grid; gap: var(--space-2); margin-bottom: var(--space-4); }
.op-error { margin: 0; padding: var(--space-3) var(--space-4); border-radius: var(--control-radius); background: var(--color-danger-soft); color: var(--color-danger); }
.op-live { margin: 0; color: var(--color-success); font-weight: 600; }
.op-note { margin: 0 0 var(--space-2); padding: var(--space-3) var(--space-4); border-left: 4px solid var(--color-warning); border-radius: 0 var(--control-radius) var(--control-radius) 0; background: var(--color-warning-soft); font-size: var(--fs-sm); max-width: 120ch; }
.op-note.op-plain, .op-table-wrap + .op-note { border-left-color: var(--color-border); background: transparent; color: var(--color-muted); padding-left: var(--space-3); }
.op-note.op-ok { border-left-color: var(--color-success); background: var(--color-success-soft); }
.op-empty { color: var(--color-muted); padding: var(--space-6) 0; font-size: var(--fs-md); }
.op-empty-card { display: grid; gap: var(--space-3); justify-items: start; padding: 40px; background: var(--color-surface); border: 1px dashed var(--color-border); border-radius: var(--panel-radius); }
.op-empty-card h2 { margin: 0; font-size: var(--fs-lg); }
.op-empty-card p, .op-empty-card ol { margin: 0; color: var(--color-muted); max-width: 90ch; }
.op-empty-card ol { padding-left: 1.3em; display: grid; gap: var(--space-1); }

/* ---- Dashboard grid ---- */
.op-dash { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: stretch; }
.op-dash > * { grid-column: 1 / -1; min-width: 0; }
/* Cards side by side share one height; the overview centres its picture in it. */
.op-dash > [class*="op-span-"] > .op-card { height: 100%; }
.op-dash > .op-span-8 > .op-card { display: flex; flex-direction: column; justify-content: center; }
.op-span-8 { grid-column: span 8 !important; } .op-span-4 { grid-column: span 4 !important; }
.op-span-7 { grid-column: span 7 !important; } .op-span-5 { grid-column: span 5 !important; }
.op-span-6 { grid-column: span 6 !important; }
.op-card { container-type: inline-size; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; padding: var(--card-pad); min-width: 0; box-shadow: 0 1px 2px rgb(16 24 40 / 4%); }
.op-card > h3, .op-card-head h3 { margin: 0 0 var(--space-4); font-size: var(--fs-md); font-weight: 650; }
.op-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.op-card-head small { font-size: var(--fs-sm); }
.op-section-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.op-section-head h2, .op-subhead { margin: 0; font-size: var(--fs-lg); }
.op-section-head h2 small, .op-subhead small { display: inline; margin-left: var(--space-2); font-weight: 400; font-size: var(--fs-sm); }
.op-subhead { margin: var(--space-6) 0 var(--space-3); }
.op-card > .op-subhead:first-child, .op-viz-head .op-subhead { margin-top: 0; margin-bottom: var(--space-1); }
.op-table tr.is-total { background: var(--slate-50); }
.op-meta { color: var(--color-muted); font-size: var(--fs-sm); margin: var(--space-1) 0 0; }

/* KPI strip */
.op-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--space-3); margin: 0; }
.op-kpis > div { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; padding: var(--space-4) var(--space-4) var(--space-3); min-width: 0; }
.op-kpis dt { color: var(--color-muted); font-size: var(--fs-sm); }
.op-kpis dd { margin: var(--space-1) 0; font-size: var(--fs-xl); line-height: 1.2; font-weight: 650; font-variant-numeric: tabular-nums; }
.op-kpis-small { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.op-kpis-small { gap: var(--space-2); margin-top: var(--space-3); }
.op-kpis-small > div { background: var(--slate-50); border-color: transparent; padding: var(--space-3); }
.op-kpis-small dd { font-size: var(--fs-md); }

/* Tabs-free sections: tables */
.op-table-wrap { overflow-x: auto; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; }
.op-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.op-table caption { text-align: left; padding: var(--space-4) var(--space-4) var(--space-3); font-weight: 650; font-size: var(--fs-md); }
.op-table th, .op-table td { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--color-border); text-align: right; vertical-align: top; white-space: nowrap; }
.op-table thead th { background: var(--slate-50); color: var(--color-muted); font-weight: 600; font-size: var(--fs-xs); }
.op-table tbody tr:hover { background: var(--slate-50); }
.op-table th[scope="row"], .op-table thead th:first-child { text-align: left; white-space: normal; min-width: 240px; }
.op-table td small, .op-table th small { margin-top: 2px; }
.op-code { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--color-muted); }
.op-product { display: flex; align-items: center; gap: var(--space-3); text-align: left; }
.op-product > div { min-width: 0; }
.op-product strong { font-weight: 600; }
.op-thumb { flex: none; display: inline-block; object-fit: cover; border-radius: 6px; border: 1px solid var(--color-border); background: var(--slate-100); }
.op-suggestion header .op-thumb { margin-right: var(--space-1); }
.op-missing { color: var(--color-warning); font-weight: 600; }
.op-good { color: var(--color-success); font-weight: 600; }
.op-costs input { width: 140px; text-align: right; }
.op-switch { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-4); margin-bottom: var(--space-4); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; }
.op-switch p { margin: 0; }
.op-suggestion, .op-attempt { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; padding: var(--space-4) var(--space-6); margin-bottom: var(--space-3); }
.op-suggestion[data-status="open"] { border-left: 4px solid var(--color-action); }
.op-suggestion header { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.op-suggestion h3 { margin: 0; font-size: var(--fs-md); }
.op-suggestion p, .op-attempt p { margin: var(--space-2) 0 0; }
.op-suggestions { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 560px), 1fr)); gap: 0 var(--gap); align-items: start; }
.op-change { font-weight: 600; }
.op-chip { display: inline-block; padding: 2px var(--space-2); border-radius: 999px; font-size: var(--fs-xs); background: var(--slate-100); color: var(--color-muted); white-space: nowrap; }
.op-chip.ok { background: var(--color-success-soft); color: var(--color-success); }
.op-chip.warn { background: var(--color-warning-soft); color: var(--color-warning); }
.op-chip.bad { background: var(--color-danger-soft); color: var(--color-danger); }
.op-chip.action { background: var(--color-action-soft); color: var(--color-action); }
.op-approve { margin-top: var(--space-3); display: grid; gap: var(--space-2); max-width: 560px; }
.op-approve label { display: grid; gap: var(--space-1); font-size: var(--fs-sm); }
.op-check { display: flex !important; align-items: center; gap: var(--space-2); color: var(--color-text) !important; font-size: var(--fs-base) !important; }
.op-check input { min-height: auto; width: 18px; height: 18px; }
.op-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-2); }
.op-promo > .op-meta { margin: 0 0 var(--space-3); }
.op-promo-summary { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); align-items: center; margin: 0 0 var(--space-4); font-variant-numeric: tabular-nums; }
.op-promo-summary > span { white-space: nowrap; }
.op-promo .op-table td small { white-space: normal; max-width: 260px; margin-left: auto; }
.op-attempts { list-style: none; padding: 0; margin: 0; }
.op-settings-grid { display: grid; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.op-settings { display: grid; gap: var(--space-4); padding: var(--card-pad); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; }
.op-settings h2 { margin: 0; font-size: var(--fs-md); }
.op-settings label { display: grid; gap: var(--space-1); font-size: var(--fs-sm); color: var(--color-muted); }
/* Ozon Performance (ads): products over their ad ceiling are marked red. */
.op-ads { display: grid; gap: var(--gap); }
.op-ads .op-subhead { margin: var(--space-2) 0 0; }
.op-ads-key { max-width: 760px; }
.op-ads-key p { margin: 0; }
.op-ads-key p small { display: block; color: var(--color-muted); margin-top: var(--space-1); }
.op-kpis > div.op-kpi-bad { border-color: var(--color-danger); background: var(--color-danger-soft); }
.op-kpis > div.op-kpi-bad dd { color: var(--color-danger); }
.op-ads-table tr[data-ad-status="over"] > *, .op-ads-table tr[data-ad-status="no_room"] > * { background: var(--color-danger-soft); }
.op-ads-table td small { white-space: normal; max-width: 200px; margin-left: auto; }
.op-ads details > summary { cursor: pointer; font-weight: 600; }
/* Repricing plan: one card per product, its price read twice (buyer side, seller side). */
.op-plan { display: grid; gap: var(--gap); }
.op-plan-target > div { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3) var(--space-4); }
.op-plan-target label:not(.op-check) { display: grid; gap: var(--space-1); font-size: var(--fs-sm); color: var(--color-muted); }
.op-plan-target input[type="number"] { width: 120px; }
.op-plan-target .op-meta { margin: var(--space-2) 0 0; }
.op-plan-kpis { margin: 0; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.op-plan-list { display: grid; gap: var(--space-3); }
.op-plan-item { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; padding: var(--space-4) var(--space-6); display: grid; gap: var(--space-3); min-width: 0; }
.op-plan-item[data-plan-status="loss"] { border-left: 4px solid var(--color-danger); }
.op-plan-item[data-plan-status="below_target"] { border-left: 4px solid var(--color-warning); }
.op-plan-item[data-plan-status="ok"] { border-left: 4px solid var(--color-success); }
.op-plan-item > header { display: flex; align-items: center; gap: var(--space-3); }
.op-plan-item > header > div { flex: 1; min-width: 0; }
.op-plan-item h3 { margin: 0; font-size: var(--fs-md); overflow-wrap: anywhere; }
.op-plan-item > p, .op-plan-item details { margin: 0; }
.op-plan-prices { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); font-size: var(--fs-sm); color: var(--color-muted); font-variant-numeric: tabular-nums; }
.op-plan-prices b { color: var(--color-text); font-size: var(--fs-md); margin-left: var(--space-1); }
.op-plan-prices small { display: block; }
.op-plan-actions, .op-plan-manual { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.op-plan-actions li { padding: var(--space-2) var(--space-3); border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-action-soft); }
.op-plan-actions .op-check { align-items: flex-start; }
.op-plan-actions .op-check input { margin-top: 3px; flex: none; }
.op-plan-actions small { display: block; color: var(--color-muted); font-size: var(--fs-sm); margin-top: 2px; }
.op-plan-manual li { font-size: var(--fs-sm); color: var(--color-muted); padding-left: var(--space-3); border-left: 3px solid var(--color-border); }
.op-plan-item details > summary { cursor: pointer; font-weight: 600; }
.op-compositions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: var(--space-4) var(--gap); margin-top: var(--space-3); }
.op-composition h4 { margin: 0 0 var(--space-2); font-size: var(--fs-base); }
.op-ladder { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: var(--space-2); margin: 0 0 var(--space-3); }
.op-ladder > div { padding: var(--space-2) var(--space-3); border-radius: 10px; background: var(--slate-50, #f5f7fa); }
.op-ladder > div.op-ladder-main { background: var(--color-action-soft); }
.op-ladder dt { font-size: var(--fs-xs); color: var(--color-muted); }
.op-ladder dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.op-ladder small { display: block; font-size: var(--fs-xs); color: var(--color-muted); line-height: 1.35; }
.op-stack { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--slate-100); }
.op-seg { display: block; height: 100%; }
.op-stack-legend { list-style: none; margin: var(--space-2) 0 0; padding: 0; display: grid; gap: 2px; font-size: var(--fs-sm); }
.op-stack-legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 52px; gap: var(--space-2); align-items: baseline; }
.op-stack-legend i { width: 10px; height: 10px; border-radius: 2px; align-self: center; }
.op-stack-legend b { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.op-stack-legend em { font-style: normal; color: var(--color-muted); text-align: right; font-variant-numeric: tabular-nums; }
.op-stack-legend small { display: block; color: var(--color-muted); font-size: var(--fs-xs); }
.op-stack-legend li.op-excluded { color: var(--color-muted); }
.op-stack-legend li.op-excluded i { opacity: .35; }
.op-stack-legend li.op-profit-row { border-top: 1px solid var(--color-border); padding-top: var(--space-1); margin-top: var(--space-1); font-weight: 700; }
.op-stack-legend li.op-profit-row.bad b { color: var(--color-danger); }
.op-plan-promos td small, .op-plan-promos th small { display: block; white-space: normal; max-width: 280px; color: var(--color-muted); }
.op-plan-bar { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px)); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; box-shadow: 0 -4px 16px rgb(16 24 40 / 8%); }
.op-plan-bar [data-plan-count] { flex: 1; font-weight: 600; }
.op-costs-form { display: grid; gap: var(--space-3); justify-items: start; }
.op-costs-form .op-table-wrap { width: 100%; }
.op-audit { list-style: none; padding: 0; margin: 0; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; }
.op-audit li { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); align-items: baseline; padding: var(--space-3) var(--space-4); border-top: 1px solid var(--color-border); }
.op-audit li:first-child { border-top: 0; }
.op-audit time { color: var(--color-muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.op-audit small { flex-basis: 100%; }
.op-dialog { border: 0; border-radius: var(--dialog-radius); padding: var(--space-6); max-width: min(520px, calc(100vw - 32px)); box-shadow: var(--overlay-shadow); }
.op-dialog h2 { margin: 0 0 var(--space-3); font-size: var(--fs-lg); }
.op-dialog::backdrop { background: rgb(16 24 40 / 40%); }
.op-finance .op-balance { margin-top: var(--space-3); }
.op-balance summary, .op-viz-table summary { cursor: pointer; color: var(--color-info); font-size: var(--fs-sm); padding: var(--space-1) 0; }
.op-balance .op-table td:last-child { text-align: left; white-space: normal; color: var(--color-muted); }
.op-access { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: var(--space-3); margin: var(--space-4) 0; padding: 0; list-style: none; }
.op-access li { display: grid; gap: var(--space-1); padding: var(--space-4); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; }
.op-access li[data-status="ok"] { border-left: 4px solid var(--color-success); }
.op-access li[data-status="denied"] { border-left: 4px solid var(--color-danger); }
.op-access strong { display: flex; justify-content: space-between; gap: var(--space-2); align-items: center; }

/* ---- Charts. One fixed colour per category in every chart (validated set:
   adjacent CVD ΔE >= 9.1, normal-vision ΔE >= 15.2 on white). Aqua, yellow and
   magenta are below 3:1 on white, so every mark is also named in text and in a
   data table. Payer series and sales use neutrals so they never borrow a cost colour. */
.op-dash, .op-viz, .op-finance, .op-plan { --cat-commission: #2a78d6; --cat-logistics: #eb6834; --cat-ads: #1baf7a; --cat-fines: #eda100; --cat-services: #e87ba4;
  --cat-productCost: #6250d6; --cat-warehouseFee: #9085e9; --cat-profit: #008300; --cat-loss: #d03b3b; --cat-sales: #c5ced8;
  --cat-buyer: #52606d; --cat-subsidy: #9aa5b1; --cat-partner: #d9e0e8; --cat-zero: var(--slate-900); }
.op-fill-commission { fill: var(--cat-commission); background: var(--cat-commission); }
.op-fill-logistics { fill: var(--cat-logistics); background: var(--cat-logistics); }
.op-fill-ads { fill: var(--cat-ads); background: var(--cat-ads); }
.op-fill-fines { fill: var(--cat-fines); background: var(--cat-fines); }
.op-fill-services { fill: var(--cat-services); background: var(--cat-services); }
.op-fill-productCost { fill: var(--cat-productCost); background: var(--cat-productCost); }
.op-fill-warehouseFee { fill: var(--cat-warehouseFee); background: var(--cat-warehouseFee); }
.op-fill-profit { fill: var(--cat-profit); background: var(--cat-profit); }
.op-fill-loss { fill: var(--cat-loss); background: var(--cat-loss); }
.op-fill-sales { fill: var(--cat-sales); background: var(--cat-sales); }
.op-fill-buyer { fill: var(--cat-buyer); background: var(--cat-buyer); }
.op-fill-subsidy { fill: var(--cat-subsidy); background: var(--cat-subsidy); }
.op-fill-partner { fill: var(--cat-partner); background: var(--cat-partner); }
.op-fill-zero { fill: var(--cat-zero); background: var(--cat-zero); }
.op-light { opacity: .45; }
[class*="op-stroke-"] { fill: none; stroke-width: 28; }
.op-stroke-commission { stroke: var(--cat-commission); } .op-stroke-logistics { stroke: var(--cat-logistics); } .op-stroke-ads { stroke: var(--cat-ads); }
.op-stroke-fines { stroke: var(--cat-fines); } .op-stroke-services { stroke: var(--cat-services); } .op-stroke-productCost { stroke: var(--cat-productCost); }
.op-stroke-warehouseFee { stroke: var(--cat-warehouseFee); } .op-stroke-profit { stroke: var(--cat-profit); }
.op-stroke-loss { stroke: var(--cat-loss); } .op-loss-arc { stroke-width: 6; stroke-linecap: round; }
.op-viz-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.op-viz-head > div { min-width: 0; }
.op-toggle { display: inline-flex; border: 1px solid var(--color-border); border-radius: var(--control-radius); overflow: hidden; background: var(--color-surface); }
.op-toggle button { border: 0; border-radius: 0; min-height: 38px; font-size: var(--fs-sm); }
.op-toggle button + button { border-left: 1px solid var(--color-border); }
.op-toggle button[aria-pressed="true"] { background: var(--color-action-soft); color: var(--color-action); font-weight: 600; }
.op-overview { display: grid; grid-template-columns: 240px minmax(190px, 250px) minmax(0, 1fr); gap: 32px; align-items: center; }
.op-donut-wrap { position: relative; width: 240px; }
.op-donut { width: 100%; height: auto; display: block; }
.op-donut-track { fill: none; stroke: var(--slate-100); stroke-width: 28; }
.op-donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.op-donut-center strong { font-size: var(--fs-xl); }
.op-donut-center small { display: block; font-size: var(--fs-sm); }
.op-hero { margin: 0; display: grid; gap: var(--space-4); }
.op-hero dt { color: var(--color-muted); font-size: var(--fs-sm); }
.op-hero dd { margin: 0; font-size: var(--fs-xl); font-weight: 650; font-variant-numeric: tabular-nums; }
.op-hero-profit dd { font-size: var(--fs-hero); line-height: 1.05; letter-spacing: -.01em; }
.op-hero-profit.is-loss dd, .op-loss-text, .op-loss-mark { color: var(--color-danger); }
.op-loss-mark { display: block; font-size: var(--fs-sm); }
.op-hero .op-meta { margin: 0; }
.op-cat-list, .op-waterfall, .op-products, .op-legend, .op-subs { list-style: none; padding: 0; margin: 0; }
.op-cat-list, .op-waterfall, .op-products { display: grid; gap: var(--space-3); }
.op-cat-line, .op-wf-row { display: grid; grid-template-columns: minmax(118px, 160px) minmax(0, 1fr) minmax(112px, auto); gap: var(--space-3); align-items: center; }
summary.op-cat-line { cursor: pointer; list-style: none; }
summary.op-cat-line::-webkit-details-marker { display: none; }
summary.op-cat-line .op-cat-name::after { content: " ▾"; color: var(--color-muted); font-size: var(--fs-xs); }
details[open] > summary.op-cat-line .op-cat-name::after { content: " ▴"; }
.op-cat-name { font-size: var(--fs-base); white-space: nowrap; }
.is-total .op-cat-name { font-weight: 650; }
.op-cat-value { text-align: right; font-size: var(--fs-base); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.op-cat-value small { display: block; font-weight: 400; }
.op-bar { display: block; width: 100%; height: 18px; overflow: visible; }
/* The 2px surface gap between touching segments and neighbouring columns. */
.op-bar rect, .op-trend-plot rect { stroke: var(--color-surface); stroke-width: 2px; }
.op-bar rect.op-fill-zero { stroke: none; }
.op-subs { margin: var(--space-2) 0 var(--space-2) 22px; display: grid; gap: 4px; font-size: var(--fs-sm); color: var(--color-muted); }
.op-subs li { display: flex; justify-content: space-between; gap: var(--space-3); }
.op-source { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--slate-100); font-size: 11px; }
.op-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
.op-swatch-line { height: 3px; width: 16px; background: var(--cat-ads); vertical-align: 3px; }
.op-legend { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); margin-bottom: var(--space-4); font-size: var(--fs-sm); color: var(--color-muted); }
.op-prod-row { display: grid; grid-template-columns: minmax(170px, 260px) minmax(0, 1fr) minmax(120px, auto); gap: var(--space-3); align-items: center; }
.op-prod-row .op-bar { height: 24px; }
.op-prod-name { display: flex; gap: var(--space-3); align-items: center; min-width: 0; font-size: var(--fs-sm); }
.op-prod-name strong { display: block; font-weight: 600; font-size: var(--fs-base); overflow-wrap: anywhere; }
.op-trend { display: grid; gap: var(--space-1); }
.op-trend-plot { width: 100%; height: 240px; display: block; overflow: visible; }
.op-trend-max, .op-trend-min, .op-trend-axis { font-size: var(--fs-xs); color: var(--color-muted); font-variant-numeric: tabular-nums; }
.op-trend-axis { display: flex; justify-content: space-between; }
.op-axis { stroke: var(--slate-200); stroke-width: 1; }
.op-ads-line { stroke: var(--cat-ads); stroke-width: 2.5; stroke-linecap: round; }
.op-viz-table { margin-top: var(--space-4); }
.op-viz-table .op-table td, .op-viz-table .op-table th { white-space: nowrap; }
.op-settle { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr); gap: var(--space-3); align-items: center; }
.op-settle > div { display: grid; gap: 2px; min-width: 0; }
.op-settle span:first-child { color: var(--color-muted); font-size: var(--fs-sm); }
.op-settle strong { font-size: var(--fs-2xl); line-height: 1.15; font-variant-numeric: tabular-nums; }
.op-settle .is-total strong { color: var(--color-action); }
.op-settle-op { font-size: var(--fs-xl); color: var(--color-muted); }
.op-finance > .op-meta { margin-top: var(--space-3); }
.op-recon { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }

/* Cards that end up narrow (a side column or a phone) stack their insides. */
@container (max-width: 760px) {
  .op-overview { grid-template-columns: 180px minmax(0, 1fr); }
  .op-overview .op-cat-list { grid-column: 1 / -1; }
  .op-donut-wrap { width: 180px; }
  .op-hero-profit dd { font-size: 38px; }
}
@container (max-width: 560px) {
  .op-settle { grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
  .op-settle > div { padding: var(--space-3) 0; border-top: 1px solid var(--color-border); }
  .op-settle > div:first-child { border-top: 0; padding-top: 0; }
  .op-settle-op { display: none; }
  .op-cat-line, .op-wf-row, .op-prod-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 6px; }
  .op-cat-line .op-bar, .op-wf-row .op-bar, .op-prod-row .op-bar { grid-column: 1 / -1; grid-row: 2; }
}
@container (max-width: 460px) {
  .op-overview { grid-template-columns: minmax(0, 1fr); justify-items: stretch; }
  .op-donut-wrap { width: 170px; justify-self: center; }
  .op-hero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .op-hero-profit { grid-column: 1 / -1; order: -1; text-align: center; }
  .op-hero-profit dd { font-size: 34px; }
  .op-hero .op-meta { grid-column: 1 / -1; }
}

/* ---- Window breakpoints ---- */
@media (max-width: 1500px) {
  .op-span-8, .op-span-4, .op-span-7, .op-span-5 { grid-column: 1 / -1 !important; }
}
@media (max-width: 1100px) {
  .op-span-6 { grid-column: 1 / -1 !important; }
  .op-settings-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1024px) {
  .op-app { grid-template-columns: minmax(0, 1fr); }
  .op-rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--gutter); border-right: 0; border-bottom: 1px solid var(--color-border); }
  .op-rail-label, .op-rail-brand span { display: none; }
  .op-rail-group { display: contents; }
  .op-platforms { display: flex; margin-left: auto; }
  .op-platform { min-height: 40px; grid-auto-flow: column; padding: 0 var(--space-3); }
  .op-platform b { width: 24px; height: 24px; font-size: 11px; }
  .op-nav { order: 3; flex-basis: 100%; display: flex; overflow-x: auto; gap: var(--space-1); scrollbar-width: thin; }
  .op-nav button { width: auto; flex: none; min-height: 40px; white-space: nowrap; }
  .op-rail-foot { order: 4; flex-basis: 100%; margin: 0; padding: 0; border: 0; display: flex; justify-content: space-between; }
  .op-topbar { position: static; }
}
@media (max-width: 760px) {
  :root { --gap: 14px; --card-pad: 16px; }
  .op-title h1 { font-size: var(--fs-lg); }
  .op-toolbar { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .op-toolbar select { min-width: 0; width: 100%; }
  .op-toolbar button { grid-column: 1 / -1; }
  .op-nav button svg { display: none; }
  .op-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .op-kpis dd { font-size: var(--fs-lg); }
  .op-table thead { display: none; }
  .op-table, .op-table caption, .op-table tbody, .op-table tr, .op-table th, .op-table td { display: block; width: 100%; }
  .op-table tr { border-top: 1px solid var(--color-border); padding: var(--space-2) 0; }
  .op-table th, .op-table td { border: 0; text-align: left; white-space: normal; padding: var(--space-1) var(--space-4); }
  .op-table td::before { content: attr(data-label); display: block; color: var(--color-muted); font-size: var(--fs-xs); }
  .op-costs input { width: 100%; }
  .op-promo .op-table td small, .op-ads-table td small { margin-left: 0; max-width: none; }
  .op-viz-table .op-table thead { display: table-header-group; }
  .op-viz-table .op-table, .op-viz-table .op-table tbody { display: table; }
  .op-viz-table .op-table tr { display: table-row; }
  .op-viz-table .op-table th, .op-viz-table .op-table td { display: table-cell; width: auto; padding: var(--space-1) var(--space-2); }
  .op-empty-card { padding: var(--space-6); }
}
