:root {
  --blue: #007FB4;
  --blue-dark: #006a97;
  --sky: #D8F3FF;
  --green: #0D8A40;
  --gold: #E1A238;
  --red: #c0392b;
  --ink: #12324a;
  --muted: #5a7183;
  --line: #e2edf3;
  --bg: #f3f8fb;
  --card: #fff;
  --radius: 16px;
  --shadow: 0 4px 18px rgba(0, 63, 90, 0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  font-family: "Montserrat", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.warn-text { color: #a25f00; font-weight: 600; }

/* ---------- Верхняя панель ---------- */
.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.bar-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 17px; color: var(--blue); }
.bar-user { display: flex; align-items: center; gap: 6px; min-width: 0; }
.avatar-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  text-decoration: none;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(0,127,180,.25);
}
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }

.tabs {
  position: sticky;
  top: 61px;
  z-index: 19;
  display: flex;
  gap: 4px;
  padding: 6px 12px;
  overflow-x: auto;
  background: #fff;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}
.tabs a:hover { background: var(--sky); }
.tabs a.is-active { background: var(--blue); color: #fff; }

.readonly-note {
  max-width: 1120px;
  margin: 12px auto 0;
  padding: 10px 16px;
  border-radius: 12px;
  background: #fff6e5;
  color: #6b4500;
  font-size: 14px;
  font-weight: 600;
  width: calc(100% - 32px);
}
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); font-weight: 600; margin-right: 6px; }
.bar-link {
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.bar-link:hover { background: var(--sky); color: var(--blue); }

.app { max-width: 1120px; margin: 0 auto; padding: 18px 16px 64px; }

/* ---------- Состояния ---------- */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 56px 16px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}
.state.is-error { color: #8a2a1c; }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--sky);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 16px;
  border: 1.5px dashed #c9dde8;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .15s ease;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: #fff; color: var(--blue); box-shadow: inset 0 0 0 1.5px #bfe0ef; }
.btn-ghost:hover { background: var(--sky); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #a33024; }
.btn-danger:disabled { opacity: .45; cursor: not-allowed; }
.btn-danger-ghost { background: #fff; color: var(--red); box-shadow: inset 0 0 0 1.5px #f0c4bd; margin-top: 4px; }
.btn-danger-ghost:hover { background: #fdecea; }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:focus-visible, .chip:focus-visible, .input:focus-visible, a:focus-visible { outline: 3px solid rgba(0,127,180,.35); outline-offset: 2px; }
.link-btn { border: 0; background: none; color: var(--blue); font-weight: 600; font-size: 14px; cursor: pointer; padding: 8px 4px; }

/* ---------- Заголовки ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
h1 { font-size: 26px; font-weight: 800; line-height: 1.2; }
h2 { font-size: 18px; font-weight: 800; }
h3 { font-size: 15px; font-weight: 700; }
.back { display: inline-block; margin-bottom: 12px; font-weight: 600; text-decoration: none; }
.back:hover { text-decoration: underline; }

/* ---------- Фильтры ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}
.filter { flex: 1 1 140px; }
.filter-search { flex: 2 1 200px; }
.chip {
  min-height: 40px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: #eef5f9;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.chip.is-active { background: var(--blue); color: #fff; }
.chip-toggle.is-active { background: #5a7183; }
.chip-danger.is-active { background: var(--red); }
.filters { flex-direction: column; align-items: stretch; }
.filters-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filters-fields > * { flex: 1 1 160px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.input {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1.5px solid #d3e4ee;
  border-radius: 12px;
  background: #fbfdfe;
  font-size: 16px;
}
select.input { cursor: pointer; }
select.input.is-active { border-color: var(--blue); background: #eef8fd; color: var(--blue); font-weight: 600; }
textarea.input { resize: vertical; }
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,127,180,.15); }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }

/* ---------- Список магазинов ---------- */
.store-list { display: grid; gap: 10px; }
.store-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease;
}
.store-card:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(0, 63, 90, 0.12); }
.store-card.is-archived { opacity: .65; }
.store-card.is-deleted { background: #fbf4f3; }
.store-card > .thumb { width: 56px; height: 56px; font-size: 22px; }
.store-card-main { flex: 1; }
.tag-del { background: rgba(192,57,43,.12); color: var(--red); }
.tag-points { background: rgba(225,162,56,.18); color: #8a5a0b; }
.store-card-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.store-card h3 { font-size: 17px; overflow-wrap: anywhere; }
.store-card-debt { display: flex; flex-direction: column; align-items: flex-end; text-align: right; flex-shrink: 0; }
.store-card-debt span { font-size: 12px; color: var(--muted); font-weight: 600; }
.store-card-debt strong { font-size: 17px; }
.store-card-debt.is-debt strong { color: var(--red); }
.store-card-debt.is-credit strong { color: var(--green); }
.store-card-debt.is-zero strong { color: var(--muted); }

.tags, .warns { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 3px 10px; border-radius: 999px; background: #eef2f5; font-size: 12px; font-weight: 700; color: #3c5465; }
.tag-city { background: rgba(0,127,180,.1); color: var(--blue); }
.tag-ok { background: rgba(13,138,64,.12); color: var(--green); }
.tag-muted { background: #eceff1; color: #6b7c88; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-ok { background: rgba(13,138,64,.12); color: var(--green); }
.badge-low { background: rgba(225,162,56,.2); color: #8a5a0b; }
.badge-out { background: rgba(192,57,43,.12); color: var(--red); }

/* ---------- Карточка магазина ---------- */
.card { padding: 18px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.card h2 { margin-bottom: 10px; }
.card h3 { margin-bottom: 10px; }
.store-head-top { display: flex; align-items: flex-start; gap: 14px; }
.store-head-title { flex: 1; min-width: 0; }
.store-head h1 { margin-bottom: 8px; overflow-wrap: anywhere; }
.info { display: grid; gap: 8px; margin-top: 14px; }
.info-row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; font-size: 14px; }
.info-row dt { color: var(--muted); font-weight: 600; }
.info-row dd { font-weight: 600; overflow-wrap: anywhere; }

.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 12px 0; }
.metrics-1 { grid-template-columns: 1fr !important; }
.metrics-2 { grid-template-columns: 1fr 1fr !important; }
.metric.is-link { cursor: pointer; text-align: left; border: 0; font: inherit; color: inherit; transition: box-shadow .12s ease, transform .12s ease; }
.metric.is-link:hover { box-shadow: 0 8px 24px rgba(0, 63, 90, 0.14); transform: translateY(-1px); }
.metric.is-link .metric-hint { color: var(--blue); font-weight: 600; }
.metric { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); min-width: 0; }
.metric-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.metric-value { font-size: 20px; font-weight: 800; overflow-wrap: anywhere; }
.metric-hint { font-size: 12px; color: var(--muted); }
.metric.is-debt .metric-value { color: var(--red); }
.metric.is-credit .metric-value { color: var(--green); }
.metric.is-warn .metric-value { color: #8a5a0b; font-size: 16px; }

.actions { display: flex; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 auto; }

.section { margin-top: 24px; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }

.item-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.item-card {
  display: flex;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  border-left: 4px solid transparent;
  transition: transform .12s ease;
}
.item-card:hover { transform: translateY(-1px); }
.item-card.is-low { border-left-color: var(--gold); }
.item-card.is-out { border-left-color: var(--red); }
.item-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.item-card h3 { overflow-wrap: anywhere; }
.item-stock { font-size: 14px; font-weight: 600; color: var(--muted); }
.item-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.price { font-weight: 800; color: var(--blue); }

.thumb {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--sky), #eaf7ef);
  color: var(--blue);
  font-size: 26px;
  font-weight: 800;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-lg { width: 96px; height: 96px; font-size: 38px; }
.thumb-sm { width: 44px; height: 44px; font-size: 18px; border-radius: 10px; }
.product-card { border: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; width: 100%; }
.product-card.is-archived { opacity: .6; }

/* ---------- История ---------- */
.ops { display: flex; flex-direction: column; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); overflow: hidden; }
.op { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); border-left: 4px solid #cfdde6; }
.op:last-child { border-bottom: 0; }
.op-sale { border-left-color: var(--blue); }
.op-customer_return { border-left-color: var(--gold); }
.op-payment { border-left-color: var(--green); }
.op-adjustment { border-left-color: #8a6ad1; }
.op-main { min-width: 0; }
.op-title { font-size: 14px; }
.op-detail { font-size: 13px; color: var(--ink); }
.op-comment { font-size: 13px; color: var(--muted); font-style: italic; }
.op-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Товар ---------- */
.item-head { display: flex; gap: 16px; align-items: center; }
.item-head-body { min-width: 0; }
.item-head h1 { font-size: 22px; overflow-wrap: anywhere; }
.item-big { margin-top: 6px; font-size: 18px; font-weight: 800; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.alert-danger { background: #fdecea !important; border-color: #f0c4bd !important; color: #8a2a1c !important; }
.alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: #fff6e5;
  border: 1.5px solid #f1cf8f;
  color: #6b4500;
  font-size: 14px;
}

.two-col { display: grid; gap: 12px; margin-top: 16px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv:last-of-type { border-bottom: 0; }
.kv span { color: var(--muted); font-weight: 600; }
.kv strong { text-align: right; }

.stat-grid { display: grid; gap: 10px; }
.stat-top { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.stat-label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); }
.stat-big { font-size: 20px; font-weight: 800; color: var(--blue); }
.period { margin-top: 10px; }
.period-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }
.period-row .input { min-width: 0; padding-inline: 8px; }
.custom-stat .card { box-shadow: none; padding: 0; margin-top: 4px; }
.section > .card + .card { margin-top: 10px; }

/* График */
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart-axis { stroke: #d5e3eb; stroke-width: 1; }
.chart-bar { fill: #7cc3e0; }
.chart-bar.is-current { fill: var(--blue); }
.chart-hit { fill: transparent; }
.chart-col { cursor: pointer; outline: none; }
.chart-col:hover .chart-hit, .chart-col:focus .chart-hit { fill: rgba(0,127,180,.06); }
.chart-label { font-size: 12px; fill: var(--muted); font-family: inherit; }
.chart-val { font-size: 13px; font-weight: 700; fill: var(--ink); font-family: inherit; }
.chart-tip {
  position: absolute;
  top: -6px;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
}
.chart-empty { text-align: center; margin-top: 4px; }

/* ---------- Модальное окно и формы ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 40, 60, 0.45); }
.modal-card {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: #fff;
  box-shadow: 0 -10px 40px rgba(0, 40, 60, 0.25);
}
.modal-card h2 { padding-right: 40px; margin-bottom: 14px; font-size: 19px; overflow-wrap: anywhere; }
.modal-x { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-x:hover { background: #f1f6f9; }

.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 13px; font-weight: 700; }
.field-hint { font-size: 12px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }
.grid-2 .input { min-width: 0; }
.ref-select { display: flex; flex-direction: column; gap: 6px; }
.subbox { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 12px; background: #f4f9fc; }
.note-danger { background: #fdecea !important; color: #8a2a1c; }
.note { padding: 10px 12px; border-radius: 10px; background: #eef7fc; font-size: 14px; }
.preview { padding: 10px 12px; border-radius: 12px; background: #f6faf7; border: 1px solid #dcefe2; }
.warn { color: var(--red); font-weight: 700; font-size: 14px; margin-top: 4px; }
.form-error { padding: 10px 12px; border-radius: 10px; background: #fdecea; color: #a12a1c; font-size: 14px; font-weight: 600; }

.toast {
  position: fixed;
  left: 50%;
  top: calc(72px + env(safe-area-inset-top));
  z-index: 60;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.toast.is-bad { background: var(--red); }

/* ---------- Адаптив ---------- */
@media (max-width: 480px) {
  .grid-2 { grid-template-columns: 1fr; }
  .info-row { grid-template-columns: 1fr; gap: 0; }
  .bar-name { display: none; }
  .store-card { flex-direction: column; }
  .store-card .store-card-debt { flex-direction: row; justify-content: space-between; align-items: baseline; width: 100%; padding-top: 8px; border-top: 1px solid var(--line); }
  .kassa-card { flex-wrap: wrap; }
  .kassa-card .store-card-debt { align-items: flex-start; text-align: left; }
  .metric-value { font-size: 17px; }
  .actions .btn { flex: 1 1 calc(50% - 8px); white-space: normal; }
  .page-head h1 { font-size: 22px; }
}

@media (min-width: 640px) {
  .item-grid { grid-template-columns: repeat(2, 1fr); }
  .modal { align-items: center; padding: 16px; }
  .modal-card { border-radius: 22px; padding: 26px 24px 22px; }
  .actions .btn { flex: 0 0 auto; }
}

@media (min-width: 900px) {
  .metrics { grid-template-columns: repeat(4, 1fr); }
  .item-grid { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr 1fr; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .app { padding: 26px 24px 80px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Этап 2 ---------- */
.actions-3 { display: grid !important; grid-template-columns: repeat(3, 1fr); }
.actions-3 .btn { white-space: normal; padding: 10px 8px; }
.points-head { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 4px; text-align: center; }
.points-big { font-size: 34px; font-weight: 800; color: var(--blue); }
.points-big.is-neg { color: var(--red); }
.modal-sub { margin: 18px 0 8px; font-size: 15px; }
.modal-card .ops { box-shadow: none; border: 1px solid var(--line); }

.picker { display: flex; flex-direction: column; gap: 8px; }
.picker-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.picker-list { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; padding: 2px; }
.picker-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 12px;
  background: #fff; text-align: left; cursor: pointer; font: inherit; color: inherit;
}
.picker-item:hover { border-color: #bfe0ef; background: #f7fbfd; }
.picker-item.is-selected { border-color: var(--blue); background: #eef8fd; box-shadow: 0 0 0 2px rgba(0,127,180,.15); }
.picker-text { display: flex; flex-direction: column; min-width: 0; }
.picker-text strong { overflow-wrap: anywhere; }
.picker-empty { padding: 12px; text-align: center; }
.picked { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: #eef8fd; }
.picked strong { flex: 1; overflow-wrap: anywhere; }
.terms-box { display: flex; flex-direction: column; gap: 12px; }

.photo-field { display: flex; align-items: center; gap: 14px; }
.photo-field > div { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.photo-preview {
  display: grid; place-items: center; flex-shrink: 0;
  width: 88px; height: 88px; border-radius: 14px; overflow: hidden;
  background: #eef5f9; border: 1.5px dashed #c9dde8;
}
.photo-preview.is-round { border-radius: 50%; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-empty { font-size: 12px; color: var(--muted); font-weight: 600; text-align: center; padding: 4px; }
.photo-preview.is-round .photo-empty { font-size: 30px; font-weight: 800; color: var(--blue); }

.kassa-grid { display: grid; gap: 10px; }
.kassa-card {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 16px; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow);
  color: inherit; text-decoration: none; border-left: 4px solid var(--blue);
}
.kassa-card h3 { margin-bottom: 6px; }
.kassa-card:hover { box-shadow: 0 8px 24px rgba(0, 63, 90, 0.12); }

.user-row { gap: 12px; justify-content: flex-start; }
.user-row .op-main { flex: 1; }
.user-row.is-off { opacity: .55; }
.user-ava {
  display: grid; place-items: center; flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; overflow: hidden;
  background: linear-gradient(135deg, var(--blue), var(--green)); color: #fff; font-weight: 800;
}
.user-ava img { width: 100%; height: 100%; object-fit: cover; }

.op-points_accrual { border-left-color: var(--gold); }
.op-points_writeoff, .op-points_payout { border-left-color: #b07d22; }
.op-debt_adjust { border-left-color: #8a6ad1; }
.op-debt_charge, .op-opening_debt { border-left-color: var(--red); }

@media (min-width: 640px) {
  .kassa-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .metrics-2 { grid-template-columns: 1fr !important; }
  .store-head-top { flex-wrap: wrap; }
  .store-head-top .store-head-title { flex: 1 1 calc(100% - 90px); }
  .store-head-top > .btn { order: 3; width: 100%; }
  .store-head-top .thumb-lg { width: 72px; height: 72px; font-size: 30px; }
  .actions-3 { grid-template-columns: 1fr; }
}

/* ---------- Этап 3 ---------- */
.field-hint.is-bad { color: var(--red); font-weight: 600; }
.eyebrow-sm { font-size: 12px; font-weight: 700; color: var(--green); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.op-btns { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.op-reset { border-left-color: var(--gold); }

.city-title { font-size: 20px; margin-bottom: 10px; color: var(--blue); }
.restock-card { padding: 0; overflow: hidden; margin-bottom: 12px; }
.restock-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.restock-store { font-size: 17px; font-weight: 800; color: var(--ink); text-decoration: none; }
.restock-store:hover { color: var(--blue); }
.restock-links { display: flex; flex-wrap: wrap; gap: 6px; }
.restock-row {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none;
  border-left: 4px solid var(--gold);
}
.restock-row:last-child { border-bottom: 0; }
.restock-row.is-out { border-left-color: var(--red); }
.restock-row:hover { background: #f7fbfd; }
.restock-name { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.restock-qty { font-weight: 800; white-space: nowrap; }
.restock-qty small { font-weight: 600; color: var(--muted); }

.report-grid { display: grid; gap: 10px; margin-top: 12px; }
.report-card { display: flex; flex-direction: column; gap: 8px; }
.report-card h3 { margin: 0; font-size: 17px; }
.report-card .btn { align-self: flex-start; margin-top: auto; }

@media (min-width: 640px) { .report-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .report-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 480px) {
  .restock-row { grid-template-columns: auto 1fr auto; }
  .restock-row .badge { grid-column: 2 / 4; justify-self: start; }
}

/* ---------- Этап 4 ---------- */
.field-hint.is-ok { color: var(--green); font-weight: 600; }
.coords-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.head-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.order-list { display: flex; flex-direction: column; gap: 6px; }
.order-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; }
.order-row.is-hidden { opacity: .55; }
.order-num { width: 24px; text-align: center; font-weight: 800; color: var(--gold); }
.order-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.order-name strong { overflow-wrap: anywhere; }
.order-name small { color: var(--muted); font-size: 12px; font-weight: 600; }
.order-btns { display: flex; gap: 4px; }
.order-btn { width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--sky); color: var(--blue); font-size: 18px; font-weight: 800; cursor: pointer; }
.order-btn:disabled { opacity: .3; cursor: default; }
@media (max-width: 480px) { .head-btns .btn { padding: 10px 12px; font-size: 14px; } }

/* ---------- Этап 5 ---------- */
.prefix-input { display: flex; align-items: stretch; border: 1.5px solid #d3e4ee; border-radius: 12px; background: #fbfdfe; overflow: hidden; }
.prefix-input span { display: flex; align-items: center; padding: 0 4px 0 12px; color: var(--muted); font-weight: 600; font-size: 15px; white-space: nowrap; }
.prefix-input .input { border: 0; border-radius: 0; padding-left: 0; background: transparent; min-width: 0; }
.prefix-input:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,127,180,.15); }
.prefix-input .input:focus { box-shadow: none; }
.gallery-edit { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.gallery-item { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #eef5f9; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.gallery-del { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border: 0; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 17px; line-height: 1; cursor: pointer; }
.gallery-add { aspect-ratio: 1; border: 1.5px dashed #b9d4e2; border-radius: 10px; background: #f4f9fc; color: var(--blue); font: inherit; font-weight: 800; font-size: 14px; cursor: pointer; }
.gallery-add:hover { background: var(--sky); }
.store-page-link { font-size: 13px; font-weight: 700; }

/* ---------- Этап 6 ---------- */
.link-danger { color: var(--red) !important; }
.photo-btns { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chips-bar { margin: 0 0 12px; }
.chips-bar .chip { text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; }
.chips-bar .chip.is-active { color: #fff; }
.refs-block { margin-bottom: 8px; }
.refs-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 6px; margin-bottom: 6px; }
.refs-row .input { min-height: 40px; padding: 6px 10px; font-size: 15px; }
.refs-count { font-size: 12px; color: var(--muted); font-weight: 600; min-width: 44px; text-align: center; }
.refs-add { grid-template-columns: minmax(0, 1fr) auto; }
@media (max-width: 480px) {
  .refs-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .refs-row .refs-count { display: none; }
  .refs-row .btn { padding: 6px 10px; }
}
.actions-wrap .btn-danger-ghost { margin-top: 0; }

.tool-row { display: flex; gap: 8px; margin: -4px 0 12px; overflow-x: auto; scrollbar-width: none; }
.tool-row::-webkit-scrollbar { display: none; }
.tool-btn { flex-shrink: 0; padding: 8px 12px; border: 1.5px solid #cfe3ee; border-radius: 999px; background: #fff; color: var(--blue); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.tool-btn:hover { background: var(--sky); }

/* Продажа по другой цене */
.custom-toggle { width: 100%; margin: 4px 0 12px; border-style: dashed; }
.custom-toggle.is-active { border-style: solid; background: #FFF6E5; border-color: #E1A238; color: #8a5a00; }
.custom-price { background: #FFF9EE; border: 1px solid #F3D9A8; border-radius: 14px; padding: 12px 12px 4px; margin-bottom: 12px; }
.custom-price .field-hint { margin: 0 0 8px; }

/* Каталог: применить цену во всех магазинах */
.apply-box { background: #EEF8FD; border: 1px solid #BFE3F3; border-radius: 14px; padding: 10px 12px; margin: 4px 0 12px; }
.apply-box .check { margin: 0; font-weight: 600; }
.apply-box .field-hint { margin: 6px 0 0; }

/* Под заказ */
.badge-order { background: rgba(0,127,180,.12); color: var(--blue, #007FB4); }
.item-card.is-order { border-left-color: var(--blue, #007FB4); }
.order-mode { margin: 6px 0 12px; }
.order-mode .field-label { display: block; margin-bottom: 6px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid #BFE3F3; border-radius: 12px; overflow: hidden; margin-bottom: 10px; }
.seg-btn { min-height: 42px; border: 0; background: #fff; font: inherit; font-weight: 700; color: #4b6576; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid #BFE3F3; }
.seg-btn.is-active { background: var(--blue, #007FB4); color: #fff; }
.order-extra { background: #EEF8FD; border: 1px solid #BFE3F3; border-radius: 14px; padding: 10px 12px 2px; }
.order-extra .field-hint { margin: 0 0 8px; }
.item-desc { margin: 4px 0 6px; color: #4b6576; font-size: 14px; line-height: 1.4; }
.order-info { margin-top: 6px; font-size: 14px; color: #0b5f86; }

/* Отчёт магазина */
.report-open { margin: 4px 0 18px; }
.report-chips { margin-bottom: 10px; }
.report-h { font-size: 16px; margin: 16px 0 6px; }
.report-top .kv { padding: 6px 0; border-bottom: 1px dashed #dbe8ef; }
.store-report .btn-block { margin-top: 14px; }

/* Поиск товара в магазине */
.item-search { margin: 0 0 12px; }
.item-search input { width: 100%; padding-left: 40px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236b8796' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 13px center; }
.search-info { margin: 6px 2px 0; }

/* Инструменты магазина: отчёт, посещения, QR */
.store-tools { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 4px 0 18px; }
@media (min-width: 640px) { .store-tools { grid-template-columns: repeat(3, 1fr); } }

/* Посещения */
.stats-table { display: grid; gap: 4px; margin: 10px 0 4px; }
.stats-row { display: grid; grid-template-columns: 1.2fr repeat(4, 1fr); gap: 6px; align-items: center; padding: 9px 10px; border-radius: 12px; background: #f3f9fc; font-size: 14px; }
.stats-row b { text-align: center; font-size: 16px; }
.stats-head { background: transparent; padding-top: 0; padding-bottom: 0; font-size: 11px; font-weight: 700; color: var(--muted, #4d6577); }
.stats-head span { text-align: center; }
.stats-head span:first-child { text-align: left; }
.stats-bars { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; align-items: end; height: 150px; padding: 6px 0 0; }
.stats-bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; }
.stats-bar i { display: block; width: 100%; max-width: 22px; border-radius: 6px 6px 2px 2px; background: var(--blue, #007FB4); min-height: 3px; }
.stats-bar small { font-size: 10px; color: var(--muted, #4d6577); }
.stats-bar-val { font-size: 10px; font-weight: 700; color: var(--blue, #007FB4); min-height: 12px; }
@media (max-width: 420px) { .stats-row { font-size: 12px; padding: 8px; } .stats-row b { font-size: 14px; } }

/* QR */
.qr-box { display: grid; gap: 10px; }
.qr-preview { width: 100%; max-width: 360px; margin: 0 auto; border-radius: 14px; box-shadow: 0 6px 24px rgba(0,63,90,.15); }

/* ---------- Количество: «Без количества» рядом с полем ---------- */
.qty-row { display: flex; gap: 8px; align-items: stretch; }
.qty-row .input { flex: 1; min-width: 0; }
.qty-row .input:disabled { opacity: .45; }
.nocount-pill {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; padding: 0 12px; min-height: 44px;
  border: 1px solid #cfe6f1; border-radius: 12px; background: #fff; font-size: 13px; font-weight: 700; color: #4b6576; cursor: pointer; user-select: none;
}
.nocount-pill input { width: 16px; height: 16px; accent-color: var(--blue, #007FB4); margin: 0; }
.nocount-pill:has(input:checked) { background: #EEF8FD; border-color: var(--blue, #007FB4); color: var(--blue, #007FB4); }
.nocount-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }

/* ---------- Статус товара ---------- */
.status-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.status-chips::-webkit-scrollbar { display: none; }
.status-chip {
  flex-shrink: 0; min-height: 40px; padding: 7px 14px; border: 1px solid #cfe6f1; border-radius: 999px; background: #fff;
  font: inherit; font-size: 14px; font-weight: 700; color: #4b6576; cursor: pointer; white-space: nowrap;
}
.status-chip.is-active { color: #fff; border-color: transparent; }
.status-chip.is-auto.is-active { background: #4b6576; }
.status-chip.is-ok.is-active { background: var(--green, #0D8A40); }
.status-chip.is-low.is-active { background: var(--gold, #E1A238); color: #3b2600; }
.status-chip.is-out.is-active { background: var(--red, #c0392b); }
.status-chip.is-order.is-active { background: var(--blue, #007FB4); }
.status-chip.is-preorder.is-active { background: #6d4fc2; }
.status-hint { margin: 2px 0 10px; }
.badge-preorder { background: rgba(109, 79, 194, .13); color: #5a3fae; }
.item-card.is-preorder { border-left-color: #6d4fc2; }

/* ---------- WhatsApp магазина ---------- */
.wa-fields { margin-bottom: 4px; }
.wa-row { margin-top: 2px; }
.wa-row > .btn { margin: -4px 0 10px; }
.wa-add { margin: -2px 0 6px; border-style: dashed; }

/* ---------- Категории товаров ---------- */
.tag-cat { align-self: flex-start; background: #EEF8FD; color: var(--blue, #007FB4); }
.refs-row.pc-row { grid-template-columns: auto minmax(0, 1fr) auto auto auto; }
.pc-row .pc-order { display: inline-flex; gap: 4px; }
.pc-row .pc-order .order-btn { width: 34px; height: 40px; }
@media (max-width: 480px) {
  .refs-row.pc-row { grid-template-columns: auto minmax(0, 1fr) auto auto; }
}

/* iPhone: поле даты не вылезает за край */
input[type="date"].input { min-width: 0; max-width: 100%; -webkit-appearance: none; appearance: none; display: block; }
.preview[hidden] { display: none !important; }
