/* Темы: светлая (по умолчанию) и тёмная — переключаются атрибутом data-theme на <html> */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e3e5e8;
  --border-soft: #eef0f2;
  --text: #1c1e21;
  --text-muted: #65676b;
  --accent: #1877f2;
  --up-text: #16a34a;
  --up-bg: rgba(34, 197, 94, 0.10);
  --up-border: rgba(34, 197, 94, 0.30);
  --down-text: #dc2626;
  --down-bg: rgba(248, 113, 113, 0.12);
  --down-border: rgba(248, 113, 113, 0.30);
  --amber-text: #a16207;
  --amber-bg: rgba(250, 204, 21, 0.20);
  --amber-border: rgba(234, 179, 8, 0.55);
  --warn-bg: #fdecea;
  --row-hover: rgba(0, 0, 0, 0.03);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
}
html[data-theme="dark"] {
  --bg: #0b0e13;
  --surface: #12161d;
  --surface-2: #1a1f29;
  --border: #232a36;
  --border-soft: #1d2430;
  --text: #e7e9ee;
  --text-muted: #8b93a3;
  --accent: #4d9aff;
  --up-text: #4ade80;
  --up-bg: rgba(34, 197, 94, 0.12);
  --up-border: rgba(34, 197, 94, 0.35);
  --down-text: #f87171;
  --down-bg: rgba(248, 113, 113, 0.12);
  --down-border: rgba(248, 113, 113, 0.35);
  --amber-text: #fde047;
  --amber-bg: rgba(250, 204, 21, 0.18);
  --amber-border: rgba(234, 179, 8, 0.50);
  --warn-bg: rgba(248, 113, 113, 0.14);
  --row-hover: rgba(255, 255, 255, 0.04);
  --shadow: none;
}

* { box-sizing: border-box; margin: 0; }
body { font-family: "Manrope", "Segoe UI", system-ui, sans-serif;
       background: var(--bg); color: var(--text); }
nav { background: var(--surface); border-bottom: 1px solid var(--border);
      padding: 10px 24px; display: flex; gap: 14px; align-items: center; }
nav .brand { font-weight: 700; margin-right: 16px; }
nav a { color: var(--text); text-decoration: none; padding: 6px 10px;
        border-radius: 8px; font-size: 14px; }
nav a:hover { background: var(--surface-2); }
nav select { background: var(--surface); color: var(--text);
             border: 1px solid var(--border); border-radius: 8px; }
.theme-toggle { margin-left: 8px; background: var(--surface-2); color: var(--text);
                border: 1px solid var(--border); border-radius: 8px;
                padding: 6px 10px; cursor: pointer; font-size: 14px; }
main { padding: 24px; max-width: 1500px; margin: 0 auto; }
h1 { font-size: 22px; margin-bottom: 16px; }

.cards { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--border);
        border-radius: 16px; padding: 14px 20px; min-width: 170px;
        box-shadow: var(--shadow); }
.card .label { font-size: 12px; color: var(--text-muted); }
.card .value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.delta-up { color: var(--up-text); font-size: 12px; }
.delta-down { color: var(--down-text); font-size: 12px; }

/* Бейджи процентов — как в финтех-таблицах */
.badge { display: inline-block; padding: 2px 8px; border-radius: 8px;
         font-size: 12px; font-weight: 600; border: 1px solid; }
.badge-up { color: var(--up-text); background: var(--up-bg);
            border-color: var(--up-border); }
.badge-down { color: var(--down-text); background: var(--down-bg);
              border-color: var(--down-border); }
.badge-neutral { color: var(--text-muted); background: var(--surface-2);
                 border-color: var(--border); }
.badge-warn { color: var(--amber-text); background: var(--amber-bg);
              border-color: var(--amber-border); }

table.data { width: 100%; border-collapse: collapse; background: var(--surface);
             border: 1px solid var(--border); border-radius: 16px;
             overflow: hidden; box-shadow: var(--shadow); }
table.data th, table.data td { padding: 9px 10px;
             border-bottom: 1px solid var(--border-soft);
             text-align: right; font-size: 13px; }
table.data th { background: var(--surface-2); position: sticky; top: 0;
                font-size: 11px; text-transform: uppercase;
                letter-spacing: 0.04em; color: var(--text-muted);
                font-weight: 600; }
table.data td:first-child, table.data th:first-child,
table.data td.txt, table.data th.txt { text-align: left; }
table.data tbody tr:hover { background: var(--row-hover); }
table.data tr.total { font-weight: 700; background: var(--surface-2); }
table.data tr.total:hover { background: var(--surface-2); }
table.data img.thumb { width: 44px; height: 58px; object-fit: cover;
                       border-radius: 8px; border: 1px solid var(--border-soft); }
table.data a { color: var(--accent); text-decoration: none; }
table.data a:hover { text-decoration: underline; }
.low-stock { background: var(--warn-bg) !important; }

/* кнопка выгрузки в Excel — карточка с круглыми углами, как графики */
.btn-excel { display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: var(--border-radius, 12px);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: 14px; font-weight: 500; text-decoration: none; cursor: pointer;
  line-height: 1; white-space: nowrap; transition: border-color .15s, color .15s; }
.btn-excel { --border-radius: 12px; }
.btn-excel:hover { border-color: var(--up-border); color: var(--up-text); }
.btn-excel::before { content: ""; width: 16px; height: 16px; flex-shrink: 0;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Cpath d='M3 9h18M3 15h18M9 3v18M15 3v18'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Cpath d='M3 9h18M3 15h18M9 3v18M15 3v18'/%3E%3C/svg%3E") center/contain no-repeat; }

.sz-toggle { cursor: pointer; color: var(--accent); font-size: 28px;
  font-weight: 700; line-height: 0.7; user-select: none; display: inline-block;
  width: 26px; text-align: center; vertical-align: middle; }
.sz-toggle:hover { opacity: 0.7; }
.sz-row td { background: var(--surface-2); }

/* размеры как мини-табличка с цветом по остатку */
.sizes-grid { display: flex; gap: 6px; flex-wrap: wrap; }
.sz-cell { min-width: 44px; text-align: center; border-radius: 8px;
  padding: 3px 6px; border: 1px solid; }
.sz-cell .sz-name { font-size: 11px; color: var(--text-muted); line-height: 1.4; }
.sz-cell .sz-qty { font-size: 14px; font-weight: 600; line-height: 1.2; }
.sz-red { background: var(--down-bg); border-color: var(--down-border); }
.sz-red .sz-qty { color: var(--down-text); }
.sz-amber { background: var(--amber-bg); border-color: var(--amber-border); }
.sz-amber .sz-qty { color: var(--amber-text); }
.sz-green { background: var(--up-bg); border-color: var(--up-border); }
.sz-green .sz-qty { color: var(--up-text); }
.sz-input { width: 44px; margin-top: 4px; padding: 3px 4px; font-size: 13px;
  text-align: center; border: 1px solid var(--accent); border-radius: 6px;
  background: var(--surface); color: var(--text); }
.supply-check { width: 17px; height: 17px; cursor: pointer; }

.spark { width: 64px; height: 20px; display: block; flex-shrink: 0; }
.spark polyline, .spark path { fill: none; stroke: var(--accent);
  stroke-width: 1.5; stroke-linecap: round; }

.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
           align-items: center; }
.filters input, .filters select, .filters button {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; background: var(--surface); color: var(--text); }
.filters button { background: var(--accent); color: #fff; border: none;
                  cursor: pointer; }
.filters label { font-size: 13px; color: var(--text-muted); }

.chart-box { background: var(--surface); border: 1px solid var(--border);
             border-radius: 16px; padding: 16px; margin-bottom: 20px;
             box-shadow: var(--shadow); }
.login-page { display: flex; align-items: center; justify-content: center;
              height: 100vh; background: var(--bg); }
.login-box { background: var(--surface); padding: 32px; border-radius: 16px;
             border: 1px solid var(--border); display: flex;
             flex-direction: column; gap: 12px; width: 320px; }
.login-box input, .login-box button { padding: 10px; border-radius: 8px;
             border: 1px solid var(--border); background: var(--surface);
             color: var(--text); }
.login-box button { background: var(--accent); color: #fff; border: none;
                    cursor: pointer; }
.error { color: var(--down-text); font-size: 13px; }
.badge-ok { color: var(--up-text); } .badge-err { color: var(--down-text); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
