:root {
  --bg: #f6f8f7;
  --panel: #ffffff;
  --line: #e9edeb;
  --line-strong: #dde3e0;
  --text: #18211d;
  --muted: #788883;
  --accent: #0f766e;
  --accent-weak: #e8f4f1;
  --accent-strong: #0b5d56;
  --hot-bg: #fdf3e0;
  --hot-text: #9a5b00;
  --danger: #b42318;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 35, 30, .04), 0 4px 16px rgba(20, 35, 30, .04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 60px;
  padding: 0 28px;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -.01em;
}
.brand:hover { color: var(--text); }

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

nav a {
  position: relative;
  color: var(--muted);
  padding: 9px 12px;
  border-radius: 8px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
nav a:hover { color: var(--text); background: var(--accent-weak); }
nav a.active { color: var(--accent); background: var(--accent-weak); }

/* ---------- Shell ---------- */
.shell {
  width: min(1480px, calc(100% - 40px));
  margin: 26px auto 64px;
}

.flash {
  margin-bottom: 16px;
  padding: 11px 14px;
  border: 1px solid #c4e7df;
  background: var(--accent-weak);
  color: var(--accent-strong);
  border-radius: var(--radius-sm);
}

/* ---------- Metrics ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px 20px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
}

.sub, .muted { color: var(--muted); }

/* ---------- Grid / Panels ---------- */
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.panel {
  padding: 18px 20px;
  overflow: auto;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

h1, h2 {
  margin: 0 0 14px;
  line-height: 1.25;
  letter-spacing: -.02em;
}
.panel-head h1, .panel h2 { margin-bottom: 0; }
h1 { font-size: 20px; font-weight: 700; }
h2 { font-size: 15px; font-weight: 600; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }

th, td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}

tbody tr { transition: background .12s; }
tbody tr:hover { background: #fafbfb; }
tbody tr:last-child td { border-bottom: none; }

.sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 10px;
  border-radius: 999px;
  background: #eef2f0;
  color: #3a4742;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge.hot { background: var(--hot-bg); color: var(--hot-text); }

/* ---------- Buttons ---------- */
.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .04s;
}
.button:hover, button:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.button:active, button:active { transform: translateY(1px); }

.button.ghost {
  background: #fff;
  color: var(--accent);
}
.button.ghost:hover { background: var(--accent-weak); color: var(--accent-strong); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Forms / Filters ---------- */
.filters, .inline-filter, .status-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.filters { margin-bottom: 16px; }

input, select, textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 8px 11px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
textarea { resize: vertical; }
.filters input { width: 170px; }

.form { display: grid; gap: 14px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.form-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
label.check {
  grid-auto-flow: column;
  align-items: center;
  justify-content: start;
}
label.check input { width: auto; }

/* ---------- Stat list ---------- */
.stat-list { list-style: none; padding: 0; margin: 0; }
.stat-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.stat-list li:last-child { border-bottom: none; }
.stat-list strong { font-weight: 600; }

/* Контакты — все каналы чипами */
.contacts { display: flex; flex-wrap: wrap; gap: 5px; max-width: 460px; }
.contact-chip {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fafbfb;
  color: var(--text);
  white-space: nowrap;
}
a.contact-chip:hover { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-weak); }

/* Кликабельная строка таблицы (открывает отчёт) */
tr[data-href] { cursor: pointer; }
tr[data-href]:hover { background: #f3f7f6; }

/* Панель товаров для парсинга (drag-and-drop) */
.product-list { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 9px; max-width: 540px; }
.product-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: var(--shadow);
  cursor: grab;
}
.product-item.dragging { opacity: .45; }
.product-item.off { opacity: .5; }
.product-item .drag { color: var(--muted); font-size: 16px; cursor: grab; }
.product-item .product-name { flex: 1; font-weight: 600; }
.product-item .product-actions { display: flex; gap: 6px; }
.product-item .product-actions form { display: inline; }
.product-item .product-actions .button { min-height: 30px; padding: 4px 11px; font-size: 12px; }

.message-cell { min-width: 360px; max-width: 640px; }
.status-form select { width: 130px; }
.status-form input { width: 160px; }

pre { white-space: pre-wrap; color: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 10px; padding: 12px 18px; }
  .metrics, .grid.two, .grid.three, .form-grid, .form-grid.compact { grid-template-columns: 1fr; }
  .shell { width: min(100% - 24px, 720px); }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .filters input, .filters button,
  .inline-filter select, .inline-filter button,
  .status-form select, .status-form input, .status-form button { width: 100%; }
}
