:root {
  --bg: #0b111a;
  --panel: #131c29;
  --panel-alt: #182334;
  --border: #253449;
  --text: #e6edf6;
  --muted: #8fa3bd;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
}

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

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
code {
  background: #0d1520;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 245px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-title { font-size: 18px; font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-btn {
  text-align: left;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: 0.15s;
}
.nav-btn:hover { background: var(--panel-alt); color: var(--text); }
.nav-btn.active {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.4);
  color: #93c5fd;
  font-weight: 600;
}

.sidebar-footer { display: flex; flex-direction: column; gap: 8px; }
.pill {
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  background: var(--panel-alt);
  border: 1px solid var(--border);
}
.pill.ok { border-color: rgba(34, 197, 94, 0.5); color: #86efac; }
.pill.warn { border-color: rgba(245, 158, 11, 0.5); color: #fcd34d; }

.main {
  flex: 1;
  padding: 20px 26px;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.topbar h1 { margin: 0; font-size: 22px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tab { display: none; }
.tab.active { display: block; }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 16px; }
.stat-label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-value.accent { color: var(--accent); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.card-header.wrap { flex-wrap: wrap; }

.inline-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 13px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.btn:hover { border-color: #4b6587; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { background: rgba(239, 68, 68, 0.16); border-color: rgba(239, 68, 68, 0.45); color: #fca5a5; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 9px; font-size: 12px; }

input, select, textarea {
  width: 100%;
  background: #0d1520;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}
label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  cursor: pointer;
  margin-bottom: 8px;
}
.checkbox-label input { width: auto; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px 16px;
}
.form-grid .full { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row-end { display: flex; justify-content: flex-end; align-items: center; gap: 14px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th { color: var(--muted); font-size: 12px; font-weight: 600; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--panel-alt);
  border: 1px solid var(--border);
}
.badge.ok { color: #86efac; background: rgba(34, 197, 94, 0.14); border-color: rgba(34, 197, 94, 0.5); }
.badge.info { color: #7dd3fc; background: rgba(14, 165, 233, 0.16); border-color: rgba(14, 165, 233, 0.5); }
.badge.warn { color: #fcd34d; background: rgba(245, 158, 11, 0.15); border-color: rgba(245, 158, 11, 0.5); }
.badge.danger { color: #fca5a5; background: rgba(239, 68, 68, 0.16); border-color: rgba(239, 68, 68, 0.5); }
.badge.purple { color: #e9d5ff; background: rgba(168, 85, 247, 0.16); border-color: rgba(168, 85, 247, 0.5); }
.badge.muted { color: #cbd5e1; background: rgba(148, 163, 184, 0.12); border-color: rgba(148, 163, 184, 0.35); }

.hint-badge {
  font-size: 11px;
  color: #93c5fd;
  margin-left: 6px;
}

.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(560px, calc(100vw - 40px));
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--panel-alt);
  border: 1px solid var(--primary);
  padding: 11px 16px;
  border-radius: 9px;
  z-index: 1000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.toast.err { border-color: var(--danger); color: #fecaca; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  padding: 16px;
}
.login-card, .modal-card {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.error-text { color: #fca5a5; margin-top: 8px; font-size: 13px; }

.filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.filter-pill {
  background: var(--panel-alt);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
}
.filter-pill:hover { color: var(--text); border-color: #4b6587; }
.filter-pill.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: var(--primary);
  color: #bfdbfe;
}
.filter-pill.pill-ok { border-color: rgba(34, 197, 94, 0.32); }
.filter-pill.pill-ok.active { background: rgba(34, 197, 94, 0.2); border-color: #22c55e; color: #86efac; }
.filter-pill.pill-warn { border-color: rgba(245, 158, 11, 0.35); }
.filter-pill.pill-warn.active { background: rgba(245, 158, 11, 0.2); border-color: #f59e0b; color: #fde68a; }
.filter-pill.pill-danger { border-color: rgba(239, 68, 68, 0.35); }
.filter-pill.pill-danger.active { background: rgba(239, 68, 68, 0.2); border-color: #ef4444; color: #fecaca; }
.filter-pill.pill-purple { border-color: rgba(168, 85, 247, 0.35); }
.filter-pill.pill-purple.active { background: rgba(168, 85, 247, 0.2); border-color: #a855f7; color: #e9d5ff; }

tr.order-row-ok { box-shadow: inset 3px 0 0 #22c55e; background: rgba(34, 197, 94, 0.045); }
tr.order-row-info { box-shadow: inset 3px 0 0 #38bdf8; background: rgba(56, 189, 248, 0.075); }
tr.order-row-warn { box-shadow: inset 3px 0 0 #f59e0b; background: rgba(245, 158, 11, 0.06); }
tr.order-row-danger { box-shadow: inset 3px 0 0 #ef4444; background: rgba(239, 68, 68, 0.08); }
tr.order-row-purple { box-shadow: inset 3px 0 0 #a855f7; background: rgba(168, 85, 247, 0.06); }
tr.order-row-muted { box-shadow: inset 3px 0 0 #64748b; opacity: 0.78; }
tr.order-row-muted:hover { opacity: 1; }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: #93c5fd;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

.catalog-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.catalog-bulk-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 12px;
}

tr.row-active {
  box-shadow: inset 3px 0 0 var(--accent);
  background: rgba(34, 197, 94, 0.04);
}
tr.row-inactive {
  opacity: 0.72;
}
tr.row-inactive:hover { opacity: 1; }

.switch-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.switch-slider {
  position: absolute;
  inset: 0;
  background: #334155;
  border-radius: 999px;
  transition: 0.18s;
}
.switch-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.18s;
}
.switch input:checked + .switch-slider {
  background: var(--accent);
}
.switch input:checked + .switch-slider::before {
  transform: translateX(18px);
}
.switch-label {
  font-size: 12px;
  font-weight: 600;
  min-width: 64px;
}
.switch-label.on { color: #86efac; }
.switch-label.off { color: var(--muted); }

.shop-switch-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.shop-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  transition: 0.15s;
}
.shop-chip.selected {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.14);
}
.shop-chip-name {
  background: none;
  border: none;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.shop-chip-name:hover { color: #93c5fd; }

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .form-grid { grid-template-columns: 1fr; }
}
