:root {
    --rcb-bg:    #f5f6fa;
    --rcb-card:  #ffffff;
    --rcb-line:  #e5e8f0;
    --rcb-muted: #6b7280;
    --rcb-blue:  #1976d2;
    --rcb-green: #2e7d32;
    --rcb-pink:  #ad1457;
    --rcb-amber: #f59e0b;
    --rcb-red:   #dc2626;
}

html, body { height: 100%; }
body {
    background: var(--rcb-bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ── topbar ───────────────────────────── */
.rcb-topbar {
    background: #fff;
    border-bottom: 1px solid var(--rcb-line);
    padding: 12px 24px;
    display: flex; align-items: center; gap: 24px;
    position: sticky; top: 0; z-index: 100;
}
.rcb-topbar .brand {
    font-weight: 800; font-size: 20px; color: #111;
    text-decoration: none; display: flex; align-items: center; gap: 10px;
}
.rcb-topbar .brand .dot {
    width: 28px; height: 28px; background: var(--rcb-blue);
    color: #fff; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 7px; font-size: 13px; font-weight: 800;
}
.rcb-topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.rcb-topbar nav a {
    color: #4b5563; font-weight: 500; padding: 7px 14px;
    border-radius: 8px; text-decoration: none; transition: background .12s;
    display: inline-flex; align-items: center; gap: 6px;
}
.rcb-topbar nav a:hover { background: #eef0f6; color: #111; }
.rcb-topbar nav a.active { background: #e8f0fe; color: var(--rcb-blue); }

/* ── page ─────────────────────────────── */
.rcb-page { padding: 24px; max-width: 1400px; margin: 0 auto; }
.rcb-page h1 { margin: 0 0 6px; font-size: 26px; }
.rcb-page .subtitle { color: var(--rcb-muted); margin: 0 0 24px; }
.rcb-toolbar {
    display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
    margin: 0 0 16px;
}
.rcb-toolbar .spacer { flex: 1; }

/* ── cards ────────────────────────────── */
.rcb-card {
    background: var(--rcb-card); border: 1px solid var(--rcb-line);
    border-radius: 10px; padding: 18px 20px;
}
.rcb-card.compact { padding: 14px 16px; }
.rcb-kpi {
    display: flex; flex-direction: column; gap: 6px;
}
.rcb-kpi .label { color: var(--rcb-muted); font-size: 13px; font-weight: 500; }
.rcb-kpi .value { font-size: 24px; font-weight: 700; color: #111; line-height: 1.1; }
.rcb-kpi .sub   { color: var(--rcb-muted); font-size: 12px; }
.rcb-kpi.green .value { color: var(--rcb-green); }
.rcb-kpi.pink  .value { color: var(--rcb-pink); }
.rcb-kpi.blue  .value { color: var(--rcb-blue); }
.rcb-kpi.amber .value { color: var(--rcb-amber); }

/* ── tables ───────────────────────────── */
.table-wrap {
    background: var(--rcb-card); border: 1px solid var(--rcb-line);
    border-radius: 10px; overflow: hidden;
}
.table-wrap table { margin: 0; }
.table-wrap thead th {
    background: #fafbfd; border-bottom: 1px solid var(--rcb-line);
    color: #4b5563; font-weight: 600; font-size: 12px;
    text-transform: uppercase; letter-spacing: .05em;
    padding: 10px 14px; white-space: nowrap;
}
.table-wrap thead th.num,
.table thead th.num { text-align: right; }   /* шапка чисел тоже по правому краю */
.table-wrap tbody td { padding: 11px 14px; border-top: 1px solid #f1f3f8; vertical-align: middle; }
.table-wrap tbody tr:hover { background: #fafbfd; }
.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    white-space: nowrap;
}
td.num, th.num { padding-left: 18px; }   /* запас слева для разной длины чисел */
.muted { color: var(--rcb-muted); }
.sku { font-family: "JetBrains Mono", "Consolas", monospace; font-size: 13px; color: #555; }

/* ── badges ───────────────────────────── */
.rcb-badge {
    display: inline-block; padding: 2px 8px; font-size: 11px; font-weight: 600;
    border-radius: 5px; text-transform: uppercase; letter-spacing: .03em;
}
.rcb-badge.in-stock  { background: #e8f5e9; color: var(--rcb-green); }   /* > 50% — достаточно */
.rcb-badge.partial   { background: #fff7c2; color: #b45309; }            /* 10–50% — частично */
.rcb-badge.low       { background: #ffe2c9; color: #c2410c; }            /* 1–10% — на исходе */
.rcb-badge.sold-out  { background: #fee2e2; color: #b91c1c; }            /* 0 — распродано */
.rcb-badge.in-transit{ background: #e8f0fe; color: var(--rcb-blue); }
.rcb-badge.expense   { background: #fbe7eb; color: var(--rcb-pink); }
.rcb-badge.income    { background: #e8f5e9; color: var(--rcb-green); }
.rcb-badge.investment{ background: #fff7e6; color: #b45309; }

.profit-pos { color: var(--rcb-green); font-weight: 600; }
.profit-neg { color: var(--rcb-red);   font-weight: 600; }

/* стэкинг модалок: вложенная модалка над основной */
#category-modal { z-index: 1075; }
.modal-backdrop.show ~ .modal-backdrop.show { z-index: 1070; }

/* пилюли каналов продаж */
.channel-pill {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    background: #eef0f6;
    color: #555;
}
.channel-pill.avito          { background: #e9ecef; color: #495057; }
.channel-pill.telegram       { background: #d6e8ff; color: #0a58ca; }
.channel-pill.avito-delivery { background: #ffe2c9; color: #c2410c; }

/* кастомный autocomplete-popup для подсказок имён моделей */
.ac-wrap   { position: relative; }
.ac-popup  {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: #fff;
    border: 1px solid var(--rcb-line);
    border-radius: 8px;
    box-shadow: 0 6px 22px rgba(20, 30, 60, .10);
    max-height: 280px;
    overflow-y: auto;
    z-index: 1080;
    padding: 4px 0;
    display: none;
}
.ac-popup.open  { display: block; }
.ac-item        {
    padding: 7px 14px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.3;
    user-select: none;
}
.ac-item:hover,
.ac-item.active { background: #eef0f6; }
.ac-item .meta  { color: var(--rcb-muted); font-size: 11px; }
.ac-item mark   { background: #fff3a8; padding: 0; }
.ac-empty       { padding: 10px 14px; color: var(--rcb-muted); font-size: 13px; }

/* пилюли точек продаж */
.point-pill {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    background: #eef0f6;
    color: #555;
}
.point-pill.pulkovo { background: #fee2e2; color: #b91c1c; }   /* красный — Пулково */
.point-pill.parnas  { background: #dbeafe; color: #1d4ed8; }   /* синий — Парнас */
.point-pill.regions { background: #e9ecef; color: #495057; }   /* серый — Регионы */

/* ── empty state ─────────────────────── */
.empty-state {
    padding: 40px; text-align: center; color: var(--rcb-muted);
}
.empty-state .icon { font-size: 36px; opacity: .35; margin-bottom: 8px; }

/* ── toasts ──────────────────────────── */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast-item {
    background: #111; color: #fff; padding: 10px 16px; border-radius: 8px;
    font-size: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.14);
    min-width: 240px; opacity: 0; transform: translateX(20px);
    transition: opacity .25s, transform .25s;
}
.toast-item.ok    { background: #047857; }
.toast-item.fail  { background: #b91c1c; }
.toast-item.show  { opacity: 1; transform: translateX(0); }
