:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1b2733;
  --muted: #6b7a8d;
  --line: #e2e8f0;
  --accent: #1f6feb;
  --accent-soft: #e8f0fe;
  --ok: #1a7f37;
  --ok-bg: #e6f4ea;
  --warn: #b35900;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --shadow: 0 6px 24px rgba(20, 40, 70, 0.10);
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
}

#app { max-width: 1180px; margin: 0 auto; padding: 16px 20px 36px; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 14px;
}
.brand { font-size: 1.25rem; font-weight: 700; }
.freshness { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.freshness.fresh::before { content: "● "; color: var(--ok); }
.freshness.stale::before { content: "● "; color: var(--warn); }

/* ── Controls ───────────────────────────────────────────── */
.controls { display: grid; grid-template-columns: 1fr 2fr; gap: 14px; }
@media (max-width: 720px) { .controls { grid-template-columns: 1fr; } }

.field label {
  display: block;
  font-size: 0.78rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted); margin: 0 0 6px 2px;
}
.combo { position: relative; }
.combo input {
  width: 100%;
  font-size: 1.1rem;
  padding: 13px 16px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.combo input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.combo input:disabled { background: #f0f2f5; color: var(--muted); }

/* City autocomplete dropdown */
.dropdown {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px);
  margin: 0; padding: 6px; list-style: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); max-height: 56vh; overflow-y: auto;
}
.dropdown li {
  padding: 11px 12px; border-radius: 8px; cursor: pointer;
  display: flex; align-items: baseline; gap: 10px;
}
.dropdown li.active, .dropdown li:hover { background: var(--accent-soft); }
.dropdown li .name { flex: 1; font-size: 1.02rem; }
.dropdown li .meta { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }

/* ── Доп. фильтр по цене ─────────────────────────────────── */
.subbar { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 0.9rem; }
.subbar-label { font-weight: 600; }
.subbar .dash { color: var(--muted); }
.price-input {
  width: 110px; font-size: 1rem; padding: 8px 12px;
  border: 2px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); outline: none;
}
.price-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.price-clear { background: none; border: none; color: var(--accent); cursor: pointer; text-decoration: underline; font-size: 0.85rem; }
.price-clear[hidden] { display: none; }

/* ── Master-detail ──────────────────────────────────────── */
.browser {
  margin-top: 16px;
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px;
  align-items: start;
}
@media (max-width: 860px) { .browser { grid-template-columns: 1fr; } }

.list-pane, .detail-pane {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow);
}
.list-pane { max-height: 70vh; overflow-y: auto; display: flex; flex-direction: column; }
.detail-pane { position: sticky; top: 12px; min-height: 180px; }

.list-meta {
  padding: 12px 16px 8px; font-size: 0.85rem; color: var(--muted);
  position: sticky; top: 0; background: var(--card); z-index: 3;
}

/* Общая сетка колонок для заголовка и строк — чтобы кол-во и цена были выровнены. */
.list-head, .prod-list li {
  display: grid;
  grid-template-columns: 1fr 92px 120px;
  gap: 12px; align-items: baseline;
  padding: 10px 16px;
}
.list-head {
  position: sticky; top: 40px; z-index: 2;
  background: var(--card); border-bottom: 1px solid var(--line);
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
.col-qty, .col-price { text-align: right; }

.prod-list { list-style: none; margin: 0; padding: 6px; flex: 1; }
.prod-list li { border-radius: 9px; cursor: pointer; }
.prod-list li:hover { background: #f2f6ff; }
.prod-list li.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.prod-list li .col-name { min-width: 0; }
.prod-list li .col-name .nm { font-size: 1.02rem; }
.prod-list li .col-name mark { background: #fff3bf; color: inherit; border-radius: 3px; padding: 0 1px; }
.prod-list li .col-name .art { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 1px; }
.prod-list li .col-price { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.prod-list li .col-qty { white-space: nowrap; font-size: 0.92rem; }
.qty-ok { color: var(--ok); }
.qty-no { color: var(--bad); }

.list-status { padding: 12px 16px; color: var(--muted); font-size: 0.9rem; text-align: center; }
.list-status.error { color: var(--bad); }

/* ── Detail card ────────────────────────────────────────── */
.detail { padding: 0; }
.detail-empty { padding: 40px 24px; color: var(--muted); text-align: center; }
.detail .rc-title { font-size: 1.3rem; font-weight: 700; padding: 20px 22px 4px; }
.detail .rc-sub { color: var(--muted); padding: 0 22px 16px; font-size: 0.9rem; line-height: 1.5; }
.detail-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.detail-table th, .detail-table td {
  width: 33.33%; text-align: center; padding: 16px 12px; border-top: 1px solid var(--line);
}
/* вертикальные разделители между колонками */
.detail-table th + th, .detail-table td + td { border-left: 1px solid var(--line); }
.detail-table th {
  font-size: 0.74rem; text-transform: uppercase; color: var(--muted); letter-spacing: .04em;
}
.detail-table td { font-size: 1.12rem; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: 0.95rem; }
.badge.in { background: var(--ok-bg); color: var(--ok); }
.badge.out { background: var(--bad-bg); color: var(--bad); }

/* ── Hints / footer ─────────────────────────────────────── */
.hints {
  display: flex; gap: 18px; align-items: center;
  margin-top: 18px; color: var(--muted); font-size: 0.82rem;
}
.hints .logout {
  margin-left: auto; background: none; border: none; color: var(--muted);
  cursor: pointer; text-decoration: underline; font-size: 0.82rem;
}

/* ── Login modal ────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(20,30,45,.35);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal[hidden] { display: none; }
.login-card {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
  padding: 28px; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { margin: 0 0 6px; font-size: 1.3rem; }
.login-card input {
  font-size: 1.05rem; padding: 12px 14px; border: 2px solid var(--line); border-radius: 10px; outline: none;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.login-card button {
  font-size: 1.05rem; font-weight: 600; padding: 12px; border: none; border-radius: 10px;
  background: var(--accent); color: #fff; cursor: pointer;
}
.login-card button:hover { filter: brightness(1.05); }
.login-error { color: var(--bad); font-size: 0.9rem; }
.login-error[hidden] { display: none; }
