/* Apple Design: material hierarchy, system type, immediate feedback, restraint. */
:root {
  font-size: 100%;
  --bg: #f5f5f7; --ink: #1d1d1f; --muted: #64646c; --line: #e3e3e8;
  --accent: #7048c6; --accent-soft: #ece6f8; --sidebar: 232px;
  --surface: rgba(255,255,255,.92); --glass: rgba(241,242,247,.86);
  --shadow: 0 2px 5px #24263a03, 0 12px 35px #24263a06;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: .875rem; line-height: 1.5; font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  background: radial-gradient(ellipse at 90% 0%, #eaf0fb 0, transparent 45%), var(--bg);
}
body[data-market=ozon] { --accent: #0066cc; --accent-soft: #e0edfc; }
button, input, a { -webkit-tap-highlight-color: transparent; }
button, .market-link { touch-action: manipulation; }
button { min-height: 44px; border-radius: 12px; transition: background-color 120ms, color 120ms, box-shadow 120ms; }
button:active, .market-link:active { transform: scale(.98); background-color: var(--accent-soft); }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 4px;
}
input { min-height: 44px; border-radius: 10px; }
input:focus { border-color: var(--accent); }
.sidebar {
  padding: 30px 18px 20px; background: var(--glass);
  backdrop-filter: blur(26px) saturate(145%); -webkit-backdrop-filter: blur(26px) saturate(145%);
  border-right: 1px solid #d8dae566; z-index: 4;
}
.brand { gap: 11px; font-size: .9375rem; letter-spacing: .08em; }
.brand-icon { border-radius: 12px; padding: 10px; background: linear-gradient(145deg,#41434d,#202127); box-shadow: 0 3px 8px #1d1d1f12; }
.nav-label { font-size: .6875rem; letter-spacing: .07em; color: #62636e; margin: 46px 12px 10px; }
.market-link { min-height: 64px; padding: 12px; border-radius: 14px; gap: 12px; margin: 8px 0; }
.market-link.active { background: #fff; box-shadow: 0 2px 8px #2525410a; }
.market-link small { color: #62636e; font-size: .6875rem; margin-top: 2px; }
.market-icon { width: 34px; height: 34px; border-radius: 10px; }
.arrow { color: #6b6c75; }
.sidebar-note { font-size: .75rem; color: #50515d; border: 0; padding: 20px 12px 4px; }
.sidebar-note p { font-size: .6875rem; color: #62636e; }
.logout button { font-size: .75rem; min-height: 44px; padding: 10px 12px; }
.main { padding: 0 clamp(24px,3.5vw,64px); }
header { height: 76px; border: 0; gap: 16px; }
.eyebrow { font-size: .6875rem; letter-spacing: .065em; color: #666773; }
.status { color: #286b4d; background: #eaf4ee; border-color: #cde3d4; font-size: .6875rem; padding: 7px 12px; line-height: 1.4; }
.heading { margin: 28px 0 0; gap: 24px; align-items: center; }
h1 { font-size: clamp(2rem,3.1vw,3rem); line-height: 1.12; letter-spacing: -.035em; font-weight: 700; }
h2 { font-size: 1.125rem; letter-spacing: -.02em; line-height: 1.25; font-weight: 650; }
.heading .muted { font-size: .875rem; margin-top: 12px; }
.market-pill { margin-left: 12px; font-size: .6875rem; border: 0; background: #e9e9ee; color: #585863; border-radius: 7px; padding: 6px 9px; }
.date-control { background: #fff; border: 1px solid #e5e5ea; border-radius: 16px; padding: 6px 7px 6px 14px; gap: 12px; box-shadow: var(--shadow); }
.date-control label { color: #64646c; font-size: .625rem; letter-spacing: .07em; }
.date-control input { font-size: .75rem; width: 120px; min-height: 32px; padding: 2px 0; background: transparent; }
.date-control button { background: var(--accent); border: 0; color: #fff; font-size: .75rem; min-width: 106px; padding: 10px 14px; }
.date-control button:active { background: var(--accent); opacity: .8; }
.period-line { margin: 28px 0 18px; font-size: .75rem; gap: 14px; }
.presets { background: #e6e7ec; border-radius: 12px; padding: 3px; gap: 2px; }
.presets button { border: 0; font-size: .75rem; padding: 6px 13px; min-height: 38px; border-radius: 9px; }
.presets .selected { background: #fff; box-shadow: 0 2px 5px #272a3d14; color: var(--ink); }
.kpis { gap: 14px; margin-bottom: 24px; }
.kpi { background: var(--surface); border: 1px solid #fff; border-radius: 20px; padding: 22px 18px; box-shadow: var(--shadow); min-height: 170px; }
.kpi:first-child { border: 1px solid #fff; padding-top: 22px; background: linear-gradient(145deg,var(--accent-soft),#fff 80%); }
.kpi .label { font-size: .75rem; font-weight: 500; color: #595963; gap: 8px; }
.kpi .label b { color: var(--accent); font-size: 1rem; }
.kpi .value { font-size: clamp(1.5rem,2.35vw,2.375rem); letter-spacing: -.045em; line-height: 1.2; font-weight: 650; margin: 20px 0 12px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: .6875rem; color: #64646c; }
.kpi .sub { color: #64646c; font-size: .6875rem; line-height: 1.65; }
.panel { background: var(--surface); border: 1px solid #fff; border-radius: 22px; box-shadow: var(--shadow); }
.panel-head { padding: 26px 28px 4px; }
.panel-head p { font-size: .75rem; margin-top: 7px; }
.legend { font-size: .6875rem; color: #64646c; }
.chart { height: 254px; padding: 26px 26px 16px; }
.chart text { fill: #6f707a; font-family: inherit; }
.detail { margin-top: 24px; }
.tabbar { padding: 18px 22px; min-height: 78px; gap: 20px; flex-wrap: wrap; }
.tab-buttons { display: flex; position: relative; isolation: isolate; background: #eeeef2; border-radius: 12px; padding: 3px; gap: 2px; max-width: 100%; }
.tabbar .tab-buttons button { position: relative; z-index: 1; background: transparent; font-size: .75rem; min-height: 42px; padding: 8px 14px; border: 0; border-radius: 9px; color: #62626b; white-space: nowrap; }
.tabbar .tab-buttons .selected { color: var(--ink); font-weight: 600; background: #fff; box-shadow: 0 1px 4px #272a3d14; }
.tabbar .tab-buttons.has-indicator .selected { background: transparent; box-shadow: none; }
.selection-indicator { pointer-events: none; position: absolute; z-index: 0; left: 0; top: 3px; bottom: 3px; width: 1px; background: #fff; border-radius: 9px; box-shadow: 0 1px 4px #272a3d14; transform-origin: left center; }
.tabbar input { font-size: .75rem; width: 248px; min-width: 180px; background: #f5f5f7; border: 1px solid #e1e1e7; margin-left: auto; }
.table-scroll { max-height: 620px; overscroll-behavior-x: contain; }
th { color: #62626b; background: #f8f8fa; font-size: .6875rem; padding: 13px 22px; }
th button { min-height: 32px; }
td { font-size: .8125rem; padding: 16px 22px; border-color: #ededf1; }
tbody tr:hover { background: #f6f7fa; }
.product-cell { gap: 14px; }
.product-cell img, .image-placeholder { width: 40px; height: 48px; border-radius: 8px; }
.product-cell strong { font-size: .75rem; }
.product-cell small { font-size: .6875rem; color: #64646c; }
.table-footer { color: #64646c; font-size: .6875rem; padding: 16px 24px; }
.tag { font-size: .625rem; color: #585a68; background: #eeeef3; border-radius: 6px; }
.methodology { max-width: none; margin: 24px 0; padding: 18px 24px; border-radius: 16px; border: 1px solid #e0e1e8; color: #62626b; font-size: .75rem; }
.methodology summary { cursor: pointer; font-size: .8125rem; font-weight: 600; color: #4e4f58; min-height: 28px; padding: 3px 0; }
.methodology p { line-height: 1.7; margin-top: 12px; }
footer { font-size: .625rem; color: #62626b; padding: 22px 0; border-color: #dddde4; }
#error { border-radius: 14px; font-size: .8125rem; }
.empty { color: #64646c; }
.skip-link { position: fixed; left: 16px; top: -100px; z-index: 100; padding: 12px 18px; border-radius: 12px; background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.skip-link:focus { top: 16px; }
.login { background: radial-gradient(ellipse at 20% 15%,#e6eafb 0,transparent 55%),radial-gradient(ellipse at 80% 90%,#e9e3f4 0,transparent 55%),#f5f5f7; padding: 24px 0; }
.login-card { border: 1px solid #fff; background: rgba(255,255,255,.88); border-radius: 28px; box-shadow: 0 24px 80px #2224400d; padding: 40px; max-width: 440px; }
.login-card h1 { font-size: 2rem; line-height: 1.12; letter-spacing: -.03em; margin: 36px 0 14px; }
.login-card .muted { font-size: .875rem; line-height: 1.6; }
.login-card label { font-size: .8125rem; font-weight: 500; margin: 18px 0; }
.login-card input { min-height: 48px; border-radius: 12px; background: #f8f8fa; font-size: 1rem; }
.login-card button { background: #0066cc; border: 0; min-height: 48px; font-weight: 600; }
.login-card button:active { background: #0058b0; }
.login-card small { font-size: .6875rem; color: #62626b; }
[aria-busy=true] .chart { opacity: .65; }
.finance-summary { margin-top: 22px; }
.finance-summary .panel-head { padding-bottom: 20px; }
.finance-summary .panel-head p { max-width: 850px; line-height: 1.65; }
.finance-summary table { table-layout: fixed; }
.finance-summary th:first-child,.finance-summary td:first-child { width: 68%; white-space: normal; }
.finance-notice { padding: 16px 24px; background: #fff5df; color: #78531d; }
body[data-market=wb] .kpis { grid-template-columns: repeat(3,minmax(0,1fr)); }
body[data-market=wb] .kpi { grid-column: auto; }
@media (max-width: 1300px) {
  .heading { align-items: flex-start; flex-direction: column; }
  .kpis { grid-template-columns: repeat(6,minmax(0,1fr)); }
  .kpi { grid-column: span 2; min-height: 156px; }
  .kpi:nth-last-child(-n+2) { grid-column: span 3; }
  .kpi .value { font-size: 2rem; }
}
@media (max-width: 800px) {
  body[data-market=wb] .kpis { grid-template-columns: repeat(2,minmax(0,1fr)); }
  body[data-market=wb] .kpi:last-child { grid-column: auto; }
  .sidebar { position: sticky; top: 0; display: grid; grid-template-columns: 1fr auto; gap: 12px; width: 100%; padding: 12px 16px; border: 0; box-shadow: 0 6px 20px #24263a08; }
  .sidebar .brand { font-size: .8125rem; }
  .brand-icon { font-size: .8125rem; padding: 8px; }
  .sidebar nav { grid-row: 2; grid-column: 1/-1; gap: 8px; }
  .market-link { flex: 1; min-height: 46px; margin: 0; padding: 8px 10px; font-size: .8125rem; }
  .market-icon { width: 28px; height: 28px; }
  .logout { display: block; grid-row: 1; grid-column: 2; }
  .logout button { font-size: .625rem; padding: 4px; min-height: 36px; }
  .sidebar-note, .nav-label { display: none; }
  .main { padding: 0 16px; }
  header { height: auto; min-height: 64px; flex-wrap: wrap; padding: 14px 0; gap: 10px; }
  .eyebrow { font-size: .5625rem; }
  .status { font-size: .625rem; }
  .heading { margin: 14px 0 0; gap: 22px; }
  h1 { font-size: 2rem; }
  .heading .muted { font-size: .8125rem; }
  .date-control { padding: 6px 7px 6px 12px; gap: 6px; }
  .date-control input { width: 105px; font-size: .6875rem; }
  .date-control button { min-width: 85px; font-size: .6875rem; padding: 8px; }
  .period-line { align-items: flex-start; flex-direction: column; margin-top: 20px; }
  .presets { align-self: stretch; }
  .presets button { flex: 1; min-height: 44px; }
  .kpis { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .kpi,.kpi:nth-last-child(-n+2) { grid-column: auto; padding: 18px 15px; min-height: 160px; border-radius: 18px; }
  .kpi:first-child { padding-top: 18px; }
  .kpi:last-child { grid-column: 1/-1; min-height: 120px; }
  .kpi .value { font-size: 1.625rem; white-space: normal; overflow-wrap: anywhere; }
  .kpi .label { font-size: .6875rem; }
  .kpi .sub { font-size: .625rem; }
  .panel { border-radius: 18px; }
  .panel-head { padding: 22px 18px 4px; }
  .chart { padding: 22px 12px 12px; height: 220px; }
  .tabbar { padding: 14px 12px; gap: 12px; }
  .tab-buttons { width: 100%; overflow: auto; }
  .tabbar .tab-buttons button { flex: 1; font-size: .6875rem; padding: 8px 10px; }
  .tabbar input { width: 100%; margin: 0; }
  td,th { padding: 12px 14px; }
  .methodology { padding: 15px 18px; }
  footer { gap: 18px; align-items: flex-start; font-size: .5625rem; }
  .login-card { padding: 30px 26px; }
}
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
  button:active,.market-link:active { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .sidebar { background: #eeeef3; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .panel,.kpi,.login-card { background: #fff; }
}
@media (prefers-contrast: more) {
  :root { --muted: #34343a; --line: #75757f; }
  .sidebar { background: #f0f0f4; backdrop-filter: none; }
  .panel,.kpi,.login-card,.date-control,.methodology { background: #fff; border: 1px solid #75757f; }
  .kpi .label,.kpi .sub,.muted,.product-cell small,.table-footer,.eyebrow,th { color: #34343a; }
  .market-link.active,.tabbar .selected,.presets .selected { outline: 1px solid #34343a; }
}

/* Money is the primary reading level; operational counts stay secondary. */
.kpis { grid-template-columns: repeat(4,minmax(0,1fr)); }
body[data-market="ozon"] .kpis { grid-template-columns: repeat(2,minmax(0,1fr)); }
.kpis .kpi { grid-column: auto; }
.kpi.money-primary { background: #eef3ff; border-color: #bccdf1; }
.kpi.money-primary .value { font-weight: 750; }
.kpi .value { font-variant-numeric: tabular-nums; font-size: clamp(1.5rem,2.2vw,2.5rem); white-space: normal; overflow-wrap: anywhere; }
.operations-summary { color: var(--muted); font-size: .8125rem; line-height: 1.8; margin: 0 4px 24px; }
.money-cell { font-weight: 650; }
@media(max-width:1100px) { .kpis { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media(max-width:600px) { .kpis .kpi.money-primary { grid-column: 1/-1; } .kpi.money-primary .value { font-size: 2.5rem; } body[data-market="ozon"] .kpis { grid-template-columns: 1fr; } }
body[data-market=wb] .kpis { grid-template-columns: repeat(2,minmax(0,1fr)); }

.currency-toolbar { display:flex; align-items:center; flex-wrap:wrap; gap:14px; margin:0 0 22px; }
.currency-toolbar .muted { font-size:.75rem; max-width:38rem; }
.currency-switch button { min-height:44px; padding:8px 16px; }
.stock-tree { padding: 0 18px 18px; }
.stock-tree summary { cursor:pointer; display:flex; align-items:center; gap:16px; padding:18px 8px; list-style:none; }
.stock-tree summary::-webkit-details-marker { display:none; }
.stock-tree summary::before { content:'›'; font-size:1.5rem; flex:0 0 16px; color:var(--muted); }
.stock-tree details[open]>summary::before { transform:rotate(90deg); }
.stock-tree summary:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; border-radius:12px; }
.stock-product { border-bottom:1px solid var(--line); }
.stock-tree .product-cell { flex:1; min-width:0; }
.stock-totals { display:grid; grid-template-columns:repeat(4,minmax(75px,1fr)); gap:16px; text-align:right; }
.stock-totals small { display:block; font-size:.65rem; color:var(--muted); }
.stock-totals strong { font-variant-numeric:tabular-nums; font-size:1rem; }
.stock-sizes { margin:0 0 14px 28px; padding:0 12px; border-radius:14px; background:rgba(120,120,140,.04); }
.stock-size-label { flex:1; font-weight:600; }
.stock-tree .stock-size summary { padding-block:12px; }
@media(max-width:800px) { .stock-tree summary { flex-wrap:wrap; gap:10px; } .stock-totals { flex-basis:100%; grid-template-columns:repeat(4,minmax(0,1fr)); gap:6px; } .stock-sizes { margin-left:12px; padding:0 6px; } .stock-tree { padding:0 10px 14px; } .stock-tree .product-cell small { white-space:normal; } }

.profit-table,.shipping-deadlines { margin-top:24px; }
.profit-scroll { max-height:680px; }
.profit-scroll table { min-width:2320px; }
.profit-scroll th,.profit-scroll td { padding-inline:12px; }
.metric-share { margin-left:5px; color:var(--muted); font-size:.625rem; font-weight:500; white-space:nowrap; }
.profit-scroll .product-cell { min-width:230px; max-width:300px; }
.profit-head { display:flex; align-items:flex-end; justify-content:space-between; gap:20px; padding-bottom:18px; }
.profit-controls { display:flex; align-items:center; justify-content:flex-end; flex-wrap:wrap; gap:10px; }
.profit-controls input { width:240px; background:#f5f5f7; border:1px solid #e1e1e7; }
.product-filter { width:100%; min-height:0; padding:0; border:0; border-radius:10px; background:transparent; color:inherit; text-align:left; }
.product-filter:hover { background:var(--accent-soft); }
.product-filter:focus-visible { outline-offset:3px; }
.profit-product { display:flex; align-items:center; gap:6px; }
.profit-product .product-filter { flex:1; }
.size-toggle { flex:0 0 34px; width:34px; min-height:40px; padding:0; border:0; background:transparent; color:var(--muted); font-size:1.35rem; }
.size-toggle[aria-expanded=true] { transform:rotate(90deg); color:var(--accent); }
.size-row td { background:#fafafd; }
.size-row-label { display:block; padding-left:42px; font-weight:650; color:#555663; }
.crossfilter-selected td { background:var(--accent-soft); }
.crossfilter-selected .product-filter { color:var(--accent); }
.profit-cell { font-weight:700; color:#286b4d; }
.profit-cell.negative { color:#a33b3b; }
.total-row td { position:sticky; bottom:0; z-index:1; background:#f3f4f7; border-top:2px solid #d8dae3; font-weight:700; }
.shipping-scroll { max-height:430px; }
.shipping-scroll table { min-width:1050px; }
.age-chart { height:250px; padding:18px 24px 8px; border-bottom:1px solid var(--line); }
.age-chart svg { display:block; width:100%; height:100%; overflow:visible; }
.age-chart text { fill:#6f707a; font-family:inherit; font-size:12px; }
.age-chart .sla-line { stroke:#b86161; stroke-width:1.5; stroke-dasharray:7 6; }
.age-chart .sla-label { fill:#934545; font-weight:650; }
.age-chart .point-label { fill:var(--ink); font-size:12px; font-weight:700; paint-order:stroke; stroke:#fff; stroke-width:4px; stroke-linejoin:round; }
.age-chart-empty { display:grid; place-items:center; height:100%; }
.urgent-row { background:#fff6e7; }
.risk-cell.high { color:#8b5b0f; font-weight:650; }
.risk-cell.critical { color:#a33b3b; font-weight:700; }
.secondary-action { white-space:nowrap; margin-left:auto; }
.tabbar .secondary-action { border:1px solid var(--line); border-radius:10px; padding:8px 12px; color:var(--accent); background:#fff; }
dialog { width:min(920px,calc(100% - 32px)); max-height:calc(100vh - 48px); padding:0; border:0; border-radius:22px; color:var(--ink); box-shadow:0 30px 90px #1d1d1f2e; }
dialog::backdrop { background:#16171b70; backdrop-filter:blur(5px); }
.dialog-card { display:flex; flex-direction:column; max-height:calc(100vh - 48px); }
.dialog-head { display:flex; justify-content:space-between; gap:24px; padding:24px 26px 18px; border-bottom:1px solid var(--line); }
.dialog-head p { color:var(--muted); font-size:.75rem; margin-top:6px; }
.dialog-close { flex:0 0 44px; width:44px; padding:0; font-size:1.5rem; }
.file-field { display:flex; align-items:center; gap:18px; padding:18px 26px 8px; font-size:.75rem; font-weight:600; }
.file-field input { flex:1; padding:8px; }
.dialog-status { min-height:34px; padding:4px 26px 12px; color:var(--muted); font-size:.75rem; }
.cost-grid-wrap { overflow:auto; border-block:1px solid var(--line); }
.cost-grid-wrap table { min-width:700px; }
.cost-grid-wrap th { top:0; }
.cost-input { width:150px; text-align:right; }
.cost-product-name { max-width:440px; white-space:normal; }
.dialog-actions { display:flex; justify-content:flex-end; gap:10px; padding:18px 26px; }
.primary-action { background:var(--accent); color:#fff; border-color:var(--accent); }
.primary-action:hover { color:#fff; filter:brightness(.94); }
@media(max-width:800px) {
  .profit-head { align-items:stretch; flex-direction:column; }
  .profit-controls,.profit-controls input,.profit-controls button { width:100%; }
  .age-chart { height:220px; padding-inline:10px; }
  .tabbar .secondary-action { margin-left:0; }
  .dialog-head,.dialog-actions { padding-inline:18px; }
  .file-field { align-items:flex-start; flex-direction:column; padding-inline:18px; }
  .file-field input { width:100%; }
  .dialog-status { padding-inline:18px; }
}
