:root {
  --bg: #f0f1f3;
  --panel: #ffffff;
  --ink: #1a1a1a;
  --muted: #6b7280;
  --line: #e0e2e6;
  --primary: #1a1a1a;
  --primary-ink: #ffffff;
  --accent: #f59e0b;
  --danger: #dc2626;
  --radius: 10px;
  --topbar-bg: #1a1a1a;
  --topbar-ink: #ffffff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.4;
}

.container { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }

/* ========== Топбар (тёмный, в стиле логотипа) ========== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  background: var(--topbar-bg);
  padding: 0 20px;
  min-height: 56px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--topbar-ink);
  font-weight: 800; font-size: 15px; letter-spacing: 1px;
  text-transform: uppercase;
}
.brand img { height: 38px; width: auto; filter: invert(1); }
.brand-text { line-height: 1.15; }
.brand-sub { font-size: 11px; font-weight: 600; letter-spacing: 0.5px; opacity: 0.6; }
.topbar nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topbar nav a {
  text-decoration: none; color: var(--topbar-ink); font-weight: 600;
  font-size: 15px; opacity: 0.85; transition: opacity .1s;
}
.topbar nav a:hover { opacity: 1; }
.topbar .who { color: var(--topbar-ink); font-size: 13px; opacity: 0.55; }
.inline { display: inline; margin: 0; }
.btn-ghost-top { background: transparent; border: 1px solid rgba(255,255,255,.25); color: #fff; font-size: 14px; padding: 6px 12px; }
.btn-ghost-top:hover { border-color: rgba(255,255,255,.5); }

h1 { font-size: 26px; margin: 6px 0 18px; font-weight: 800; }
h2 { font-size: 20px; margin: 20px 0 12px; font-weight: 700; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 14px; margin-top: 8px; }
.error { background: #fef2f2; color: var(--danger); padding: 10px 12px; border-radius: 8px; font-weight: 600; }

/* ========== Кнопки ========== */
.btn {
  display: inline-block; cursor: pointer;
  padding: 10px 16px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 16px; font-weight: 600; text-decoration: none;
  transition: all .1s;
}
.btn:hover { border-color: #b8bcc2; }
.btn-primary {
  background: var(--primary); border-color: var(--primary); color: var(--primary-ink);
}
.btn-primary:hover { background: #333; border-color: #333; }
.btn-accent {
  background: var(--accent); border-color: var(--accent); color: #000;
  font-weight: 700;
}
.btn-accent:hover { filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: #fca5a5; }
.btn-ghost { background: transparent; }
.btn-lg { padding: 14px 22px; font-size: 18px; width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 14px; }

/* ========== Сетка карточек ========== */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1024px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px)  { .grid { grid-template-columns: repeat(2, 1fr); } }
.card {
  display: flex; flex-direction: column; text-decoration: none; color: inherit;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: transform .08s, box-shadow .08s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.1); }
.card-img {
  aspect-ratio: 4/3; background: #e8eaed;
  display: flex; align-items: center; justify-content: center;
}
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.noimg { color: var(--muted); font-size: 14px; }
.card-body { padding: 12px; }
.card-name { font-weight: 700; }
.card-sku { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* ========== Плитки в админке ========== */
.tile { align-items: center; text-align: center; padding: 22px 12px; }
.tile-num { font-size: 40px; font-weight: 900; color: var(--ink); }
.tile-label { color: var(--muted); margin-top: 6px; font-weight: 600; }

/* ========== Панели ========== */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.product-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.badge {
  background: #f3f4f6; color: var(--muted);
  padding: 3px 10px; border-radius: 20px; font-size: 14px; font-weight: 600;
}
.product-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-top: 12px; }
.manual-text { white-space: pre-wrap; font-family: inherit; font-size: 16px; margin: 0; }
.sticker-box label { display: block; margin-bottom: 12px; font-weight: 600; }
.sticker-box select { width: 100%; }

@media (max-width: 720px) {
  .product-cols { grid-template-columns: 1fr; }
}

/* ========== Формы ========== */
.form { max-width: 620px; }
.form label, .sticker-box label { display: block; margin-bottom: 14px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 11px 12px; margin-top: 6px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 16px; font-family: inherit;
  background: #fff; color: var(--ink);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--ink); box-shadow: 0 0 0 2px rgba(26,26,26,.08);
}
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; margin: 0; }
fieldset {
  border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 14px; padding: 14px;
}
legend { padding: 0 8px; color: var(--muted); font-weight: 700; font-size: 15px; }

/* ========== Таблицы ========== */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.table {
  width: 100%; border-collapse: collapse;
  background: var(--panel); border-radius: var(--radius); overflow: hidden;
}
.table th, .table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
.table th { background: #f3f4f6; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
.row-actions { display: flex; gap: 8px; }

/* ========== Экран входа ========== */
.login-body {
  display: flex; flex-direction: column;
  min-height: 100vh; align-items: center; justify-content: center;
  padding: 20px; background: var(--ink);
}
.login-logo { margin-bottom: 24px; text-align: center; }
.login-logo img { height: 60px; filter: invert(1); margin: 0 auto; display: block; }
.login-logo .login-brand {
  color: #fff; font-weight: 800; font-size: 18px;
  letter-spacing: 2px; text-transform: uppercase; margin-top: 8px;
}
.login-card {
  background: var(--panel); border: none;
  border-radius: var(--radius); padding: 28px;
  width: 100%; max-width: 380px;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.login-card h1 { margin-top: 0; text-align: center; }
.login-card label { display: block; margin-bottom: 16px; font-weight: 600; }

/* ========== Ряды полей ========== */
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .row-2, .row-3 { grid-template-columns: 1fr; } }

/* ========== Блок ИП в форме карточки ========== */
.entity-block {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; margin-bottom: 10px;
  background: #fafbfc;
}
.entity-fields { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.form-wide { max-width: 900px; }

/* ========== Цветовая точка ========== */
.color-dot {
  display: inline-block; width: 18px; height: 18px;
  border-radius: 50%; border: 1px solid var(--line); vertical-align: middle;
}
.color-input-row { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.color-picker { width: 50px; height: 40px; padding: 2px; cursor: pointer; border: 1px solid var(--line); border-radius: 6px; }
.color-hex-text { width: 100px !important; }

/* ========== Категории ========== */
.cat-group { margin-bottom: 10px; }
.cat-root { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sub-list { list-style: none; padding-left: 24px; margin: 8px 0 0; }
.sub-list li { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.sub-opt { padding-left: 16px; }

/* ========== ЗП ========== */
.salary-filters {
  display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
  margin-bottom: 20px;
}
.salary-filters label { margin-bottom: 0; font-weight: 600; font-size: 15px; }
.salary-filters input[type="date"],
.salary-filters select { margin-top: 4px; }
.salary-summary {
  display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap;
}
.sum-block {
  flex: 1; min-width: 160px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 18px; text-align: center;
}
.sum-label { font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.sum-val { font-size: 24px; font-weight: 900; margin-top: 4px; }
.sum-paid .sum-val { color: #16a34a; }
.sum-unpaid .sum-val { color: #dc2626; }
.status-paid {
  background: #dcfce7 !important; color: #15803d !important;
  border-color: #86efac !important; font-weight: 700;
}
.status-unpaid {
  background: #fef2f2 !important; color: #dc2626 !important;
  border-color: #fca5a5 !important; font-weight: 700;
}
.row-paid td { background: #f0fdf4; }
.row-unpaid td { background: #fef2f2; }
.td-toggle { width: 28px; text-align: center; }
.toggle-arrow { display: inline-block; transition: transform .15s; font-size: 12px; color: var(--muted); }
.detail-row td { padding: 0 12px 12px; background: #f9fafb; }
.detail-table {
  width: 100%; border-collapse: collapse;
  font-size: 14px; margin-top: 4px;
}
.detail-table th {
  text-align: left; padding: 6px 8px; font-size: 12px;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px;
  border-bottom: 1px solid var(--line); background: transparent;
}
.detail-table td { padding: 6px 8px; border-bottom: 1px solid #eee; }
.badge-sm { font-size: 12px; padding: 2px 8px; }

/* ========== Файл этикетки ========== */
.current-label { margin: 4px 0 6px; }
.current-label a { color: var(--ink); font-size: 14px; font-weight: 600; }
input[type="file"] { padding: 8px 0; }

/* ========== Курьер ========== */
.badge-paid { background: #dcfce7; color: #15803d; }
.badge-pending { background: #fef9c3; color: #854d0e; }
.settle-actions { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.settle-actions .panel h3 { margin: 0 0 10px; font-size: 15px; }

/* ========== Каталог: сайдбар + контент ========== */
.catalog-layout { display: grid; grid-template-columns: 230px 1fr; gap: 20px; align-items: start; }
@media (max-width: 1024px) { .catalog-layout { grid-template-columns: 200px 1fr; } }
@media (max-width: 600px)  { .catalog-layout { display: block; } }

/* Сайдбар */
.sidebar {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
  position: sticky; top: 12px;
}
@media (max-width: 600px) {
  .sidebar { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000; border-radius: 0; overflow-y: auto; padding: 20px 16px;
    background: #fff; }
  .sidebar.open { display: block; }
}
.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.4); z-index: 999; }
.sidebar-overlay.open { display: block; }
.sidebar-close { display: none; background: none; border: none; font-size: 28px; cursor: pointer;
  position: absolute; top: 10px; right: 14px; color: var(--ink); line-height: 1; }
@media (max-width: 600px) { .sidebar-close { display: block; } }
.filter-toggle { display: none; margin-bottom: 14px; }
@media (max-width: 600px) { .filter-toggle { display: inline-flex; align-items: center; gap: 6px; } }

/* Поиск в сайдбаре */
.sidebar-search { margin-bottom: 14px; }
.sidebar-search input { margin-top: 0; padding: 9px 10px; font-size: 14px; }

/* Фильтры-чипы (вертикальные в сайдбаре) */
.filters-bar { margin-bottom: 0; }
.filter-group { display: flex; flex-direction: column; align-items: stretch; gap: 4px; margin-bottom: 12px; }
.filter-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 2px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-radius: 6px; border: 1px solid transparent;
  background: transparent; color: var(--ink); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all .1s; white-space: nowrap;
}
.chip:hover { background: #f3f4f6; }
.chip-active { background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.chip-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); }
.filter-count { font-size: 13px; color: var(--muted); margin-top: 8px; }

.courier-actions { margin-bottom: 28px; }
.courier-btns {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

/* ========== Вкладки маркетплейсов ========== */
.mp-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); }
.mp-tab {
  padding: 10px 20px; font-size: 16px; font-weight: 700; cursor: pointer;
  border: none; background: transparent; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  transition: all .1s;
}
.mp-tab:hover { color: var(--ink); }
.mp-tab-active { color: var(--ink); border-bottom-color: var(--ink); }
.mp-tab-disabled { opacity: 0.35; cursor: not-allowed; }
