/* MOMMY ERP — оформление в духе Apple: монохром, системный шрифт, крупные заголовки, мягкие карточки. */
:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --fill: rgba(118, 118, 128, .12);      /* подложка сегментов и полей */
  --fill-strong: rgba(118, 118, 128, .2);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --sep: rgba(60, 60, 67, .14);
  --ink: #1d1d1f;                         /* главный акцент — чёрный, как логотип */
  --ink-contrast: #ffffff;
  --bar: #1d1d1f;
  --bar-neg: #d70015;
  --pos: #248a3d;
  --neg: #d70015;
  /* каналы продаж */
  --wb: #8944ab;
  --ozon: #0071e3;
  --site: #c93400;
  /* статусы */
  --st-new: #0071e3;   --st-new-bg: rgba(0, 113, 227, .1);
  --st-sold: #248a3d;  --st-sold-bg: rgba(36, 138, 61, .1);
  --st-cancel: #6e6e73; --st-cancel-bg: rgba(118, 118, 128, .12);
  --st-return: #c93400; --st-return-bg: rgba(201, 52, 0, .1);
  --glass: rgba(245, 245, 247, .72);
  --glass-surface: rgba(255, 255, 255, .78);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --shadow-pop: 0 10px 30px rgba(0, 0, 0, .14), 0 2px 6px rgba(0, 0, 0, .08);
  --radius: 20px;
  --tabbar-h: 58px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Inter", "Segoe UI", Roboto, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000; --surface: #1c1c1e; --fill: rgba(118, 118, 128, .24); --fill-strong: rgba(118, 118, 128, .36);
    --text: #f5f5f7; --muted: #98989d; --sep: rgba(84, 84, 88, .55);
    --ink: #f5f5f7; --ink-contrast: #000000; --bar: #f5f5f7; --bar-neg: #ff453a; --pos: #30d158; --neg: #ff453a;
    --wb: #bf5af2; --ozon: #0a84ff; --site: #ff9f0a;
    --st-new: #0a84ff; --st-new-bg: rgba(10, 132, 255, .18); --st-sold: #30d158; --st-sold-bg: rgba(48, 209, 88, .16);
    --st-cancel: #98989d; --st-cancel-bg: rgba(118, 118, 128, .24); --st-return: #ff9f0a; --st-return-bg: rgba(255, 159, 10, .16);
    --glass: rgba(0, 0, 0, .7); --glass-surface: rgba(28, 28, 30, .78);
    --shadow: 0 0 #0000; --shadow-pop: 0 10px 30px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000; --surface: #1c1c1e; --fill: rgba(118, 118, 128, .24); --fill-strong: rgba(118, 118, 128, .36);
  --text: #f5f5f7; --muted: #98989d; --sep: rgba(84, 84, 88, .55);
  --ink: #f5f5f7; --ink-contrast: #000000; --bar: #f5f5f7; --bar-neg: #ff453a; --pos: #30d158; --neg: #ff453a;
  --wb: #bf5af2; --ozon: #0a84ff; --site: #ff9f0a;
  --st-new: #0a84ff; --st-new-bg: rgba(10, 132, 255, .18); --st-sold: #30d158; --st-sold-bg: rgba(48, 209, 88, .16);
  --st-cancel: #98989d; --st-cancel-bg: rgba(118, 118, 128, .24); --st-return: #ff9f0a; --st-return-bg: rgba(255, 159, 10, .16);
  --glass: rgba(0, 0, 0, .7); --glass-surface: rgba(28, 28, 30, .78);
  --shadow: 0 0 #0000; --shadow-pop: 0 10px 30px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font: 15px/1.47 var(--font); letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { -webkit-appearance: none; appearance: none; }
a { color: var(--ink); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--ozon); outline-offset: 2px; }

/* ---------- логотип ---------- */
.logo-svg { display: block; height: 100%; width: auto; color: var(--text); }
.login-logo { height: 40px; margin-bottom: 8px; }
.side-logo { display: block; height: 26px; margin: 4px 12px 28px; }
.mhead { display: none; }

/* ---------- вход ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 28px; padding: 36px 28px 28px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 24px 0 4px; }
.field { display: grid; gap: 6px; margin-top: 14px; }
.field label { font-size: 13px; color: var(--muted); }
.input { width: 100%; padding: 11px 14px; border-radius: 12px; border: 0; background: var(--fill); outline: none; min-height: 44px; }
.input:focus { box-shadow: 0 0 0 3px rgba(0, 113, 227, .35); }
select.input { appearance: auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 18px;
  border-radius: 999px; border: 0; background: var(--fill); cursor: pointer; font-weight: 500; transition: background .15s, transform .1s; }
.btn:hover { background: var(--fill-strong); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--ink); color: var(--ink-contrast); }
.btn-primary:hover { background: var(--ink); opacity: .88; }
.btn-block { width: 100%; margin-top: 24px; min-height: 50px; font-size: 17px; font-weight: 600; }
.btn:disabled { opacity: .45; cursor: default; }
.error { color: var(--neg); font-size: 14px; margin-top: 12px; min-height: 20px; }

/* ---------- каркас ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; padding: 24px 12px; background: var(--glass-surface);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-right: .5px solid var(--sep); display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--text);
  text-decoration: none; font-weight: 500; }
.nav-link:hover { background: var(--fill); }
.nav-link.active { background: var(--ink); color: var(--ink-contrast); }
.nav-link svg, .tab svg { width: 22px; height: 22px; flex: none; }
.sidebar-foot { margin-top: auto; padding: 14px 12px 0; border-top: .5px solid var(--sep); display: grid; gap: 10px; }
main { min-width: 0; padding: 28px 36px 48px; max-width: 1280px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.topbar h1 { font-size: 34px; font-weight: 700; letter-spacing: -.025em; margin: 0; line-height: 1.1; }
.tabbar { display: none; }

/* ---------- фильтры: ленты «таблеток» ---------- */
.filters { display: grid; gap: 10px; margin-bottom: 20px; min-width: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; scroll-snap-align: center; display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 16px;
  border-radius: 999px; border: 0; background: var(--surface); box-shadow: inset 0 0 0 .5px var(--sep), var(--shadow);
  font-size: 15px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .2s, color .2s, transform .1s; }
.chip:active { transform: scale(.96); }
.chip.on { background: var(--ink); color: var(--ink-contrast); box-shadow: none; }
.period-label { padding: 0 4px; }
.dates { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dates label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.dates input { padding: 7px 10px; border: 0; border-radius: 10px; background: var(--surface); color: var(--text);
  box-shadow: inset 0 0 0 .5px var(--sep); min-height: 38px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.dot-wb { background: var(--wb); } .dot-ozon { background: var(--ozon); } .dot-site { background: var(--site); }
.chip.on .dot { box-shadow: 0 0 0 1.5px var(--ink-contrast); }

/* iOS-сегменты (метрика графика, статусы заказов) */
.seg { display: inline-flex; background: var(--fill); border-radius: 10px; padding: 2px; gap: 0; max-width: 100%;
  overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; cursor: pointer; color: var(--text);
  font-size: 13px; font-weight: 500; min-height: 32px; white-space: nowrap; transition: background .2s; }
.seg button.on { background: var(--surface); font-weight: 600; box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); }
.seg button .muted { font-weight: 400; }

/* ---------- каналы продаж ---------- */
.channels-wrap { margin-bottom: 20px; min-width: 0; }
.channels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.ch-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 16px 18px;
  border: 0; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); cursor: pointer; min-width: 0;
  transition: transform .15s, box-shadow .2s; }
.ch-card:active { transform: scale(.98); }
.ch-card.on { box-shadow: inset 0 0 0 2px var(--ink), var(--shadow); }
.ch-name { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.ch-value { font-size: 24px; font-weight: 700; letter-spacing: -.025em; }
.ch-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.share { display: flex; gap: 2px; height: 6px; margin-top: 14px; border-radius: 3px; overflow: hidden; }
.share span { display: block; min-width: 3px; }

/* ---------- карточки ---------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 19px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two { grid-template-columns: 3fr 2fr; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .value { font-size: 30px; font-weight: 700; margin-top: 6px; letter-spacing: -.03em; line-height: 1.1; }
.kpi .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.banner { background: var(--surface); box-shadow: inset 0 0 0 .5px var(--sep); border-radius: 14px; padding: 12px 16px; margin-bottom: 18px; font-size: 14px; }
.stack { display: grid; gap: 14px; }
.stack > *, .grid > *, main > * { min-width: 0; }

/* ---------- график ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--sep); stroke-width: 1; }
.chart .zero-line { stroke: var(--muted); stroke-width: 1; opacity: .45; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--bar); transition: opacity .15s; }
.chart .bar.neg { fill: var(--bar-neg); }
.chart .bar.dim { opacity: .22; }
.tooltip { position: absolute; pointer-events: none; background: var(--glass-surface); color: var(--text);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow-pop); padding: 10px 12px; border-radius: 12px; font-size: 13px; line-height: 1.45; white-space: nowrap;
  transform: translate(-50%, -100%); margin-top: -10px; z-index: 5; }

/* ---------- списки ---------- */
.list { display: grid; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 2px; border-top: .5px solid var(--sep); align-items: center; }
.row:first-child { border-top: 0; }
.row .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--muted); font-size: 13px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row .right { text-align: right; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; margin-top: 2px; }
.mp { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; }
.mp-wb { color: var(--wb); background: color-mix(in srgb, var(--wb) 12%, transparent); }
.mp-ozon { color: var(--ozon); background: color-mix(in srgb, var(--ozon) 12%, transparent); }
.mp-site { color: var(--site); background: color-mix(in srgb, var(--site) 12%, transparent); }
.st-new { color: var(--st-new); background: var(--st-new-bg); }
.st-sold { color: var(--st-sold); background: var(--st-sold-bg); }
.st-cancelled { color: var(--st-cancel); background: var(--st-cancel-bg); }
.st-returned { color: var(--st-return); background: var(--st-return-bg); }
.st-unpaid { color: var(--st-cancel); background: transparent; box-shadow: inset 0 0 0 1px var(--sep); }
.search { max-width: 340px; }
.more { display: flex; justify-content: center; margin-top: 12px; }
.empty { text-align: center; color: var(--muted); padding: 32px 8px; }

/* товары */
.prod { border-top: .5px solid var(--sep); }
.prod:first-child { border-top: 0; }
.prod-head { display: grid; grid-template-columns: minmax(0, 1fr) repeat(4, 110px) 20px; gap: 12px; align-items: center;
  padding: 12px 8px; cursor: pointer; width: 100%; background: none; border: 0; text-align: left; border-radius: 12px; }
.prod-head:hover { background: var(--fill); }
.prod-head .cell { text-align: right; }
.prod-head .cell .muted { display: block; font-size: 12px; }
.chev { transition: transform .2s; color: var(--muted); }
.prod.open .chev { transform: rotate(90deg); }
.prod-body { padding: 4px 8px 18px; display: grid; gap: 14px; }
.ue-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.ue { background: var(--bg); border-radius: 16px; padding: 16px; }
.ue h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; display: flex; gap: 8px; align-items: center; }
.ue table { width: 100%; border-collapse: collapse; }
.ue td { padding: 5px 0; }
.ue td:last-child { text-align: right; }
.ue tr.total td { border-top: .5px solid var(--sep); font-weight: 700; padding-top: 8px; }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 10px 8px; border-top: .5px solid var(--sep); text-align: right; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl thead th { border-top: 0; color: var(--muted); font-weight: 600; font-size: 13px; }
.tbl tr.total td { font-weight: 700; }
.tbl .pct { color: var(--muted); font-size: 12px; margin-left: 6px; }
.scroll-x { overflow-x: auto; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px; }
.actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--glass-surface); color: var(--text); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow-pop); padding: 12px 18px; border-radius: 14px; z-index: 50; font-size: 14px; font-weight: 500; max-width: calc(100% - 32px); }
.spinner { padding: 48px; text-align: center; color: var(--muted); }

/* ---------- планшет ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two { grid-template-columns: 1fr; }
}

/* ---------- телефон ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  /* шапка с логотипом: полупрозрачная, как в iOS */
  .mhead { display: flex; justify-content: center; align-items: center; position: sticky; top: 0; z-index: 30;
    height: calc(48px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top);
    background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
    border-bottom: .5px solid var(--sep); }
  .mhead a { display: block; height: 24px; }
  main { padding: 10px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
  .topbar { margin-bottom: 14px; }
  .topbar h1 { font-size: 30px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--glass-surface); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
    border-top: .5px solid var(--sep); }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); text-decoration: none; font-size: 10px; font-weight: 500; }
  .tab.active { color: var(--ink); }
  .tab.active svg { stroke-width: 2.3; }

  /* ленты фильтров и каналов листаются вбок от края до края экрана */
  .chips, .channels { margin: 0 -16px; padding: 2px 16px; scroll-padding: 0 16px; }
  .chip { height: 40px; padding: 0 18px; font-size: 15px; }
  .channels { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
    scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
  .channels::-webkit-scrollbar { display: none; }
  .ch-card { flex: 0 0 auto; width: 68%; max-width: 250px; scroll-snap-align: start; }
  .ch-value { font-size: 22px; }

  .kpi .value { font-size: 23px; }
  .kpi .label { font-size: 12px; }
  .card { padding: 16px; border-radius: 18px; }
  .card h2 { font-size: 17px; }
  .card-head .seg { width: 100%; }
  .card-head .seg button { flex: 1 0 auto; }
  .search { max-width: none; width: 100%; }
  .prod-head { grid-template-columns: minmax(0, 1fr) auto 20px; }
  .prod-head .cell.hide-sm { display: none; }
  .filters > .seg { width: 100%; }
}
