/* Внутренний B2B-инструмент: чисто, плотно, с телефона. Зелёная гамма — под
   привычные торговым мерч-приложения. Без внешних шрифтов — системный стек. */

:root {
  --green: #1a9c5b;
  --green-dark: #15834c;
  --ink: #1c1f23;
  --muted: #6b7280;
  --line: #e6e8eb;
  --page: #f4f6f8;
  --card: #ffffff;
  --bad: #d14343;
  --amber: #b7791f;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--green);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.btn:hover { background: var(--green-dark); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn--ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn--ghost:hover { background: #f7f8fa; }
.btn--block { width: 100%; }

.linklike {
  padding: 0; border: 0; background: none; color: var(--green);
  font-size: 14px; font-weight: 600; text-decoration: none;
}
.linklike:hover { text-decoration: underline; }
.danger { color: var(--bad) !important; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field > span i { font-style: normal; color: var(--bad); }
.field input, .field select, .field textarea {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 15px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--green);
  outline-offset: -1px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

.error { color: var(--bad); font-size: 14px; margin: 6px 0 0; }

/* ── Вход ─────────────────────────────────────────────────────────────────── */
.login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login__card {
  width: min(380px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
}
.login__logo {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 20px; font-weight: 800; letter-spacing: -0.02em; color: var(--green);
  margin-bottom: 4px;
}
.login__sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

/* ── Шапка приложения ──────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.topbar__brand { font-weight: 800; color: var(--green); letter-spacing: -0.02em; }
.topbar__spacer { margin-left: auto; }
.topbar__user { font-size: 13px; color: var(--muted); }
.iconbtn {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; font-size: 14px; font-weight: 600;
}
.badge {
  min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--green); color: #fff; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}

.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }

/* ── Вкладки/поиск ─────────────────────────────────────────────────────────── */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.search {
  flex: 1 1 220px; min-width: 0;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.tab {
  white-space: nowrap;
  padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; color: var(--ink); font-size: 14px; font-weight: 600;
}
.tab[aria-current="true"] { background: var(--green); color: #fff; border-color: var(--green); }

/* ── Каталог ───────────────────────────────────────────────────────────────── */
.section-title { margin: 18px 0 10px; font-size: 15px; font-weight: 700; color: var(--muted); }
.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 14px;
}
.pcard {
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.pcard__img { width: 100%; aspect-ratio: 1/1; object-fit: contain; background: #fff; display: block; }
.pcard__body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.pcard__name { font-size: 14px; font-weight: 600; line-height: 1.3; }
.pcard__meta { font-size: 12px; color: var(--muted); }
.pcard__bc { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.pcard__foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 8px; }
.pcard__price { font-size: 16px; font-weight: 800; color: var(--ink); }
.pcard__price--none { font-size: 12px; font-weight: 600; color: var(--muted); }

/* Степпер количества */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { width: 34px; height: 34px; border: 0; background: #fff; font-size: 18px; color: var(--green); }
.stepper button:hover { background: #f2f4f6; }
.stepper input { width: 42px; height: 34px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); text-align: center; font-weight: 700; }
.addbtn { padding: 8px 14px; border: 0; border-radius: 10px; background: var(--green); color: #fff; font-weight: 700; font-size: 13px; }

/* ── Корзина / чекаут ──────────────────────────────────────────────────────── */
.cartbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: #fff; border-top: 1px solid var(--line);
}
.cartbar__total { font-weight: 800; font-size: 16px; }
.cartbar__sub { font-size: 12px; color: var(--muted); }

.line {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.line img { width: 52px; height: 52px; border-radius: 8px; object-fit: contain; background: #f2f4f6; }
.line__name { font-size: 14px; font-weight: 600; }
.line__meta { font-size: 12px; color: var(--muted); }
.line__sum { margin-left: auto; font-weight: 700; white-space: nowrap; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.panel h2 { margin: 0 0 12px; font-size: 16px; }

/* ── Список результатов (контрагенты/заказы/юзеры) ─────────────────────────── */
.rowcard {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px;
}
.rowcard__main { min-width: 0; }
.rowcard__title { font-size: 14px; font-weight: 700; }
.rowcard__sub { font-size: 12px; color: var(--muted); }
.rowcard__side { margin-left: auto; text-align: right; white-space: nowrap; }

.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.chip--new { background: #e7f6ee; color: var(--green-dark); }
.chip--in_progress { background: #fdf3e0; color: var(--amber); }
.chip--done { background: #eef1f4; color: var(--muted); }
.chip--cancelled { background: #fdeaea; color: var(--bad); }

/* ── Модальные окна ────────────────────────────────────────────────────────── */
dialog.modal {
  width: min(560px, calc(100% - 20px));
  max-height: 90vh;
  padding: 0; border: 1px solid var(--line); border-radius: 16px;
}
dialog.modal::backdrop { background: rgba(15, 23, 20, 0.4); }
.modal__body { padding: 20px; overflow-y: auto; max-height: 90vh; }
.modal__head { display: flex; align-items: center; margin-bottom: 14px; }
.modal__head h2 { margin: 0; font-size: 18px; }
.modal__close { margin-left: auto; }
.modal__actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 12px; }

.empty { padding: 40px 0; text-align: center; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 50;
  padding: 11px 18px; border-radius: 999px; background: var(--ink); color: #fff;
  font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.toast--bad { background: var(--bad); }

/* ── Красивые детали заказа (оператор) ─────────────────────────────────────── */
.ocp { background: #f7f9fb; border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.ocp__name { font-size: 18px; font-weight: 800; margin-bottom: 10px; }
.ocp__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
@media (max-width: 520px) { .ocp__grid { grid-template-columns: 1fr; } }
.ocp__row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 13px; }
.ocp__row > span { color: var(--muted); }
.ocp__row > b { font-weight: 700; text-align: right; }
.ocp__sub { margin-top: 12px; font-size: 12px; color: var(--muted); }
.copyable {
  border: 0; background: none; color: var(--green-dark); font: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer; padding: 0; text-align: right;
}
.copyable:hover { text-decoration: underline; }

.oitems { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.oitem { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.oitem__img { width: 56px; height: 56px; border-radius: 10px; object-fit: contain; background: #f2f4f6; flex: 0 0 auto; }
.oitem__img--none { background: #eef1f4; }
.oitem__main { min-width: 0; flex: 1; }
.oitem__name { font-size: 14px; font-weight: 700; line-height: 1.3; }
.oitem__meta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.bcchip {
  margin-top: 5px; display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; background: #f7f9fb;
  color: var(--muted); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.03em; cursor: pointer;
}
.bcchip:hover { border-color: var(--green); color: var(--green-dark); }
.oitem__nums { text-align: right; white-space: nowrap; }
.oitem__qty { font-size: 12px; color: var(--muted); }
.oitem__sum { font-size: 15px; font-weight: 800; }

.ototal { display: flex; justify-content: space-between; align-items: center; padding: 12px 4px; font-size: 18px; font-weight: 800; border-top: 2px solid var(--line); }
.ocomment { padding: 12px; background: #f7f9fb; border-radius: 12px; font-size: 14px; margin-bottom: 12px; }
.ostatuses { display: flex; flex-wrap: wrap; gap: 8px; }

/* Согласование скидки */
.approval-box { background: #fdf3e0; border: 1px solid #f0d9a8; border-radius: 12px; padding: 14px; margin-bottom: 12px; font-size: 14px; color: #8a5a12; font-weight: 600; }
.approval-box__btns { display: flex; gap: 10px; margin-top: 10px; }
.oitem__qty .disc { color: var(--green-dark); font-weight: 800; }

/* Подтверждение выполнения (рискованное) */
.btn--danger { background: var(--bad); }
.btn--danger:hover { background: #b53535; }
.confirm-box { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 2px solid var(--line); }
.confirm-box--done { flex-direction: column; align-items: stretch; gap: 12px; background: #e7f6ee; border: 1px solid #b8e6cd; border-radius: 12px; padding: 14px; border-top: 1px solid #b8e6cd; font-size: 14px; color: var(--green-dark); }
.confirm-box__btns { display: flex; flex-wrap: wrap; gap: 10px; }
.confirm-box a.btn { text-decoration: none; }
