/* qwind.tech — оформление сайта.
   Чтобы поменять цвета, шрифт или отступы, достаточно поправить переменные ниже. */

:root {
  color-scheme: light;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #f4f6fa;            /* фон страницы */
  --surface: #ffffff;       /* карточки и таблицы */
  --surface-2: #f8f9fc;     /* шапки таблиц, подсветка строк */
  --border: #e3e7ef;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;
  --accent: #2a78d6;        /* основной синий */
  --accent-soft: #e8f1fc;
  --sidebar: #0f1b2d;
  --sidebar-text: #c7d2e3;
  --sidebar-active: #1d2d47;
  --good: #0a8a0a;  --good-bg: #e7f6e7;
  --warn: #9a6400;  --warn-bg: #fff4dc;  --warn-mark: #fab219;
  --bad: #c62f2f;   --bad-bg: #fdeaea;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  --grid: #e9edf3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121417; --surface: #1a1a19; --surface-2: #222321; --border: #30312e;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #9a998f;
    --accent: #3987e5; --accent-soft: #1d2a3c;
    --sidebar: #0c0d0f; --sidebar-text: #b9c2cf; --sidebar-active: #1f2733;
    --good: #4cc94c; --good-bg: #16301a; --warn: #fab219; --warn-bg: #33290f;
    --bad: #f07a7a; --bad-bg: #3a1c1c;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
    --grid: #2a2b28; --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121417; --surface: #1a1a19; --surface-2: #222321; --border: #30312e;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #9a998f;
  --accent: #3987e5; --accent-soft: #1d2a3c;
  --sidebar: #0c0d0f; --sidebar-text: #b9c2cf; --sidebar-active: #1f2733;
  --good: #4cc94c; --good-bg: #16301a; --warn: #fab219; --warn-bg: #33290f;
  --bad: #f07a7a; --bad-bg: #3a1c1c;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  --grid: #2a2b28; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- каркас: меню слева, содержимое справа ---------- */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 20px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 18px; padding: 4px 10px 18px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; font-size: 16px; }
.brand small { display: block; font-weight: 400; font-size: 11px; color: var(--sidebar-text); opacity: .8; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--sidebar-text); padding: 9px 10px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: var(--sidebar-active); text-decoration: none; color: #fff; }
.nav a.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav-count { margin-left: auto; font-size: 11px; background: rgba(255,255,255,.1); padding: 1px 7px; border-radius: 10px; }
.sidebar-foot { margin-top: auto; padding: 10px; font-size: 12px; display: flex; flex-direction: column; gap: 8px; }
.sidebar-foot button { background: none; border: 1px solid #2c3b55; color: var(--sidebar-text); border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit; }

.main { min-width: 0; padding: 24px 28px 48px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.topbar .sub { color: var(--muted); margin-top: 4px; }
.day-picker { display: flex; align-items: center; gap: 8px; }
select, input[type=text], input[type=search], input[type=password] {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; min-height: 36px; }
select:focus, input:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; border-radius: 8px; padding: 8px 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; min-height: 36px; }
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }

/* ---------- карточки ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); margin-bottom: 16px; }
.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi a { color: inherit; }
.kpi-label { color: var(--text-2); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-delta { font-size: 12px; color: var(--muted); }
.kpi-delta.up-bad, .kpi-delta.down-good { font-weight: 600; }
.kpi-delta.up-bad { color: var(--bad); }
.kpi-delta.down-good { color: var(--good); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.two { grid-template-columns: 3fr 2fr; margin-bottom: 16px; }
.two-even { grid-template-columns: 1fr 1fr; margin-bottom: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.chart-box { position: relative; height: 260px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.box { height: 10px; width: 10px; border-radius: 3px; }
.takeaway { background: var(--accent-soft); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; color: var(--text); }

/* полосы долей (структура расходов) */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 56px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }

/* разбор цены товара */
.stack { display: flex; height: 18px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--surface); }
.stack div { height: 100%; }
.c-cost { background: #2a78d6; } .c-commission { background: #eb6834; } .c-logistics { background: #1baf7a; }
.c-services { background: #eda100; } .c-ads { background: #e87ba4; } .c-tax { background: #94a3b8; } .c-profit { background: #008300; }
.parts { display: grid; grid-template-columns: 1fr auto auto; gap: 6px 16px; margin-top: 14px; font-size: 13px; }
.parts .total { font-weight: 700; border-top: 1px solid var(--border); padding-top: 6px; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: 12px; position: sticky; top: 0; white-space: nowrap; }
th a { color: inherit; }
th.sorted a { color: var(--accent); }
td.r, th.r { text-align: right; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.product-cell { min-width: 260px; max-width: 420px; }
.product-cell .title { color: var(--text); font-weight: 500; display: block; }
.product-cell .meta { color: var(--muted); font-size: 12px; }
.neg { color: var(--bad); }
.pos { color: var(--good); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-bad { color: var(--bad); background: var(--bad-bg); }
.badge-warn { color: var(--warn); background: var(--warn-bg); }
.badge-good { color: var(--good); background: var(--good-bg); }

/* фильтры над таблицей */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.tabs { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.tabs a { padding: 6px 12px; border-radius: 7px; color: var(--text-2); font-weight: 500; white-space: nowrap; }
.tabs a:hover { text-decoration: none; background: var(--surface-2); }
.tabs a.on { background: var(--accent); color: #fff; }
.tabs a .cnt { opacity: .75; font-size: 12px; margin-left: 4px; }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--text-2); }
.pager { display: flex; gap: 6px; align-items: center; justify-content: space-between; margin-top: 12px; color: var(--muted); }
.pager .btns { display: flex; gap: 6px; }

/* формы */
.form { display: grid; gap: 14px; max-width: 520px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 3px; }
.field input[type=text] { width: 160px; }
.alert { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.alert-ok { background: var(--good-bg); color: var(--good); }
.alert-err { background: var(--bad-bg); color: var(--bad); }
details.method summary { cursor: pointer; color: var(--text-2); font-weight: 600; }
details.method { margin-top: 16px; }
details.method p, details.method li { color: var(--text-2); }

/* вход */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { color: var(--text); padding: 0 0 16px; }
.login-card input { width: 100%; }

/* ---------- узкие экраны ---------- */
@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px 12px; gap: 8px; }
  .brand { padding: 0 8px 0 0; }
  .brand small { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a { padding: 8px 10px; white-space: nowrap; }
  .nav a.active { box-shadow: inset 0 -3px 0 var(--accent); }
  .nav-count { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; flex-direction: row; align-items: center; }
  .sidebar-foot .who { display: none; }
  .main { padding: 16px 16px 40px; }
  .two, .two-even { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar-row { grid-template-columns: 110px 1fr 48px; }
}
