:root {
  --bg: #f3f2ee;
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --ink: #1c2220;
  --muted: #69716d;
  --line: #e2e0da;
  --accent: #1b3662;          /* тёмно-синий из логотипа ГРС */
  --accent-ink: #ffffff;
  --accent-soft: #e5eaf3;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --ok: #2c6e49;
  --ok-soft: #e3f1e8;
  --warn: #8a5a00;
  --warn-soft: #fbf0d9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05);
  --tabbar: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111413;
    --surface: #1a1e1d;
    --surface-2: #151918;
    --ink: #e7eae8;
    --muted: #9aa29e;
    --line: #2b3130;
    --accent: #9db8e8;
    --accent-ink: #0d1626;
    --accent-soft: #1d2840;
    --danger: #f2a49c;
    --danger-soft: #3a1f1c;
    --ok: #8fd0a8;
    --ok-soft: #1c3127;
    --warn: #e8c271;
    --warn-soft: #362b14;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111413;
  --surface: #1a1e1d;
  --surface-2: #151918;
  --ink: #e7eae8;
  --muted: #9aa29e;
  --line: #2b3130;
  --accent: #9db8e8;
  --accent-ink: #0d1626;
  --accent-soft: #1d2840;
  --danger: #f2a49c;
  --danger-soft: #3a1f1c;
  --ok: #8fd0a8;
  --ok-soft: #1c3127;
  --warn: #e8c271;
  --warn-soft: #362b14;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--accent); }

svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- каркас */

.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-in {
  max-width: 1100px; margin: 0 auto;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.01em; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 11px; font-weight: 800; letter-spacing: .02em;
}
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; line-height: 1.2; }
.top .who { margin-left: auto; text-align: right; font-size: 13px; line-height: 1.25; }
.top .who b { display: block; font-weight: 600; }
.top .who span { color: var(--muted); }

main {
  max-width: 760px; margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) calc(var(--tabbar) + 96px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
main.wide { max-width: 1100px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-in { max-width: 760px; margin: 0 auto; display: flex; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 4px 8px; min-height: var(--tabbar);
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500; position: relative;
}
.tab[aria-current="page"] { color: var(--accent); }
.tab .count {
  position: absolute; top: 5px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}

/* ---------- типографика и блоки */

h1 { font-size: 24px; line-height: 1.2; margin: 4px 0 14px; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 22px 0 10px; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card.pad { padding: 16px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

.empty {
  text-align: center; color: var(--muted); padding: 40px 16px;
  border: 1px dashed var(--line); border-radius: var(--radius);
}

.notice { padding: 12px 14px; border-radius: 12px; font-size: 14px; background: var(--accent-soft); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.err { background: var(--danger-soft); color: var(--danger); }

/* ---------- кнопки */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, .tab:focus-visible, .chip:focus-visible, .input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; padding: 0; color: var(--ink);
}
.icon-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- поля */

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 14px; font-weight: 600; }
.field .req { color: var(--danger); }
.field .hint { font-size: 13px; color: var(--muted); }
.field .err { font-size: 13px; color: var(--danger); }
.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); font-size: 16px;
}
textarea.input { min-height: 84px; resize: vertical; }
/* Поля формы, которые растут по тексту (fitField): в одну строку — как обычное поле. */
textarea.input[data-grow] { resize: none; overflow-y: hidden; }
textarea.input[data-single] { min-height: 46px; line-height: 1.5; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.field.has-err .input { border-color: var(--danger); }
/* Заполнено распознаванием фото документа — агенту сверить. */
.field.scanned .input { border-color: var(--warn); background: var(--warn-soft); }
.field.scanned > label::after { content: " · с фото, сверьте"; color: var(--warn); font-weight: 400; font-size: 13px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.search { position: relative; }
.search .i { position: absolute; left: 12px; top: 13px; color: var(--muted); }
.search .input { padding-left: 40px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; margin: 12px -16px 6px; padding-inline: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-n { display: inline-block; min-width: 20px; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--surface-2);
  color: var(--muted); font-size: 12px; font-weight: 600; line-height: 18px; text-align: center; }
.chip[aria-pressed="true"] .chip-n { background: color-mix(in srgb, var(--accent-ink) 22%, transparent); color: var(--accent-ink); }

.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label {
  flex: 1 1 140px; display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 15px;
}
.seg input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- каталог */

.cat-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 2px 8px; font-weight: 600; }
.product { display: flex; align-items: center; gap: 12px; padding: 14px; }
.product .name { font-weight: 600; line-height: 1.3; }
.product .descr { font-size: 13px; color: var(--muted); margin-top: 2px; }
.product .price { font-size: 15px; margin-top: 4px; font-weight: 600; }
.product .price span { color: var(--muted); font-weight: 400; font-size: 13px; }

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper .qty { min-width: 28px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

.cartbar {
  position: fixed; left: 0; right: 0; z-index: 25;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding: 10px 16px; pointer-events: none;
}
.cartbar .btn {
  pointer-events: auto; max-width: 728px; margin: 0 auto; display: flex; width: 100%;
  min-height: 52px; box-shadow: 0 6px 20px rgba(20, 40, 32, .25); justify-content: space-between;
}

/* ---------- корзина, заказ */

.line { display: flex; gap: 12px; padding: 14px; align-items: center; }
.line + .line { border-top: 1px solid var(--line); }
.totals { display: flex; justify-content: space-between; align-items: baseline; padding: 14px; border-top: 1px solid var(--line); font-weight: 700; font-size: 18px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.badge.new { background: var(--accent-soft); color: var(--accent); }
.badge.work { background: var(--warn-soft); color: var(--warn); }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.cancel, .badge.error { background: var(--danger-soft); color: var(--danger); }
.badge.muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

.order-card { display: block; padding: 14px; text-decoration: none; color: inherit; }
.order-card:hover { border-color: var(--accent); }
.order-card .title { font-weight: 600; }

.kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 0; }
.kv > div { padding: 10px 14px; border-top: 1px solid var(--line); font-size: 15px; }
.kv > div:nth-child(-n+2) { border-top: 0; }
.kv .k { color: var(--muted); font-size: 14px; }
.kv .v { word-break: break-word; white-space: pre-wrap; }

.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 15px; margin-bottom: 4px; }

/* ---------- админка */

.subnav { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 16px; padding: 0 16px 2px; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }

.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 14px; }
.table td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface-2); }
.table tr.off td { color: var(--muted); }
.table-wrap { overflow-x: auto; }

code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
pre.json {
  margin: 8px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--line); overflow-x: auto; font-size: 12px; line-height: 1.5; max-height: 360px;
}
details.log { border-top: 1px solid var(--line); padding: 10px 14px; }
details.log summary { cursor: pointer; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; }

.ref-list { max-height: 280px; overflow: auto; font-size: 14px; }
.ref-list div { padding: 6px 14px; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.ref-list div:first-child { border-top: 0; }
.ref-list code { color: var(--accent); flex: none; }

/* ---------- модалка и тост */

dialog {
  border: 0; padding: 0; border-radius: 18px; width: min(560px, calc(100vw - 24px));
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  max-height: calc(100dvh - 24px);
}
dialog::backdrop { background: rgba(15, 20, 18, .45); }
dialog form { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
dialog .head { padding: 18px 18px 6px; font-size: 18px; font-weight: 700; }
dialog .body { padding: 10px 18px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
dialog .foot { padding: 12px 18px 18px; display: flex; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--line); }
dialog .foot .spacer { flex: 1; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px); z-index: 100;
  bottom: calc(var(--tabbar) + 80px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- плашка «Вышло обновление» */

.update-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 12px;
  padding: calc(8px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: var(--accent); color: var(--accent-ink); font-size: 15px; font-weight: 600;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .2);
}
.update-bar .update-btns { display: flex; gap: 6px; }
.update-bar .btn.ghost { color: inherit; }
.update-bar .btn.ghost:hover { background: rgba(255, 255, 255, .14); }

/* ---------- вход */

.login { max-width: 400px; margin: 8vh auto 0; }
.login-logo { display: block; width: 220px; max-width: 70%; margin-bottom: 22px; }

.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 900px) {
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
}
.show-sm { display: none; }
@media (max-width: 520px) {
  .kv { grid-template-columns: 1fr; }
  .kv > div.k { border-top: 1px solid var(--line); padding-bottom: 0; }
  .kv > div.v { border-top: 0; padding-top: 2px; }
  .kv > div:first-child { border-top: 0; }
  .hide-sm { display: none; }
  .show-sm { display: block; }
}

/* ---------- утилиты */

.mt { margin-top: 14px; }
.mt-lg { margin-top: 22px; }
.pad { padding: 16px; }
.right { text-align: right; }
h2.flat { margin: 0 0 8px; }
.req { color: var(--danger); }
.chip[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); text-decoration: none; }
a.chip { color: var(--ink); text-decoration: none; }
.order-card .row + .row, .order-card .row + div { margin-top: 4px; }
.card.pad > :first-child { margin-top: 0; }
.card.pad > :last-child { margin-bottom: 0; }
.row > h1 { margin-bottom: 4px; }
.hint { font-size: 13px; color: var(--muted); }
.stack > p, .stack > h3 { margin: 0; }
.icon-btn.danger { color: var(--danger); }
dialog .foot { flex-wrap: nowrap; align-items: center; }
dialog .foot .icon-btn { width: 44px; height: 44px; }

/* ---------- каталог с фото */

.product { align-items: flex-start; }
.thumb {
  flex: none; width: 72px; height: 72px; padding: 0; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); background: var(--surface-2); cursor: zoom-in;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.none { cursor: default; }
.product .bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.product .price { margin-top: 0; }
.sku { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); margin-top: 2px; }
.chip-title { margin: 28px 2px 6px; font-size: 19px; }
.chip-title:first-child { margin-top: 6px; }
.chips[hidden] { display: none; }

dialog.photo { width: min(720px, calc(100vw - 24px)); overflow: hidden; }
.photo-cap { display: flex; gap: 12px; align-items: center; padding: 14px 16px; }

/* ---------- админка: дерево разделов */

.acat { margin: 6px 0 0 calc(var(--depth, 0) * 18px); }
.acat > summary, .acat.folder {
  display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; list-style: none; cursor: pointer;
}
.acat > summary::-webkit-details-marker { display: none; }
.acat > summary::before, .acat.folder::before { content: "▸"; width: 14px; color: var(--muted); flex: none; }
.acat[open] > summary::before { content: "▾"; }
.acat.folder { cursor: default; }
.acat.folder::before { content: "▫"; }
.acat.off > summary, .acat.folder.off { color: var(--muted); }
.acat > .card { margin: 4px 0 10px; }
.table td.thumb-td { width: 52px; padding-right: 0; }
.mini { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; display: block; background: var(--surface-2); }
.notice ul { margin: 8px 0 10px; padding-left: 20px; }
.notice li + li { margin-top: 4px; }
.notice img.preview { display: block; max-height: 180px; max-width: 100%; margin: 0 auto; border-radius: 8px; }
.notice + .search { margin-top: 12px; }
.dt { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 8px; }

/* ---------- каталог: вкладки, плитки разделов, карточки товаров */

.segtabs {
  display: inline-flex; gap: 4px; padding: 4px; margin-top: 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
}
.segtabs button {
  border: 0; background: transparent; padding: 8px 20px; border-radius: 999px;
  font-weight: 600; color: var(--muted); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.segtabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.segtabs[hidden] { display: none; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.tile {
  display: flex; flex-direction: column; overflow: hidden; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.tile:hover { border-color: var(--accent); }
.tile:active { transform: scale(.98); }
.tile-img { position: relative; aspect-ratio: 4 / 3; background: #fff; display: grid; place-items: center; overflow: hidden; }
.tile-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 8px; display: block; }
.tile-img.none { background: var(--accent-soft); color: var(--accent); font-size: 30px; font-weight: 700; }
.tile-body { padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.tile-name { font-weight: 600; line-height: 1.25; }
.tile-count { font-size: 12px; color: var(--muted); margin-top: 3px; }

.pgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.pcard {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
/* Квадрат фиксирован: высокое фото не должно растягивать карточку. */
.pcard-img { position: relative; flex: none; display: block; width: 100%; aspect-ratio: 1; padding: 0; border: 0;
  background: #fff; cursor: zoom-in; overflow: hidden; }
.pcard-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.pcard-img.none { background: var(--surface-2); cursor: default; }
.pcard-body { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.pcard-name {
  font-size: 14px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.pcard-price { margin-top: auto; padding-top: 4px; font-size: 17px; font-weight: 700; }
.pcard-price span { font-size: 13px; font-weight: 400; color: var(--muted); }
.pcard .ctl { margin-top: 6px; }
.pcard .ctl > .btn { width: 100%; }
.pcard .stepper { justify-content: space-between; }

@media (min-width: 600px) {
  .tiles, .pgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 900px) {  /* iPad горизонтально, компьютер: каталог шире — 4 колонки */
  .tiles, .pgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- фото товара: галерея в админке, просмотр у агента */

.gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.gimg { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 10px; border: 2px solid var(--line); background: #fff; }
.gimg.cover { border-color: var(--accent); }
.gimg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.gload { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: #69716d; }
.gbadge {
  position: absolute; left: 6px; bottom: 6px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700;
}
.gbtn {
  position: absolute; left: 6px; right: 6px; bottom: 6px; padding: 5px 4px; border: 0; border-radius: 8px;
  background: rgba(255, 255, 255, .94); color: #1c2220; font-size: 11px; font-weight: 600; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
}
.gdel {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 8px;
  display: grid; place-items: center; background: rgba(255, 255, 255, .94); color: #b3261e; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
}
.gdel .i { width: 16px; height: 16px; }
.gadd { margin-top: 10px; align-self: flex-start; cursor: pointer; }
.gadd.busy { pointer-events: none; opacity: .7; }
.gerr:empty { display: none; }

.vis-td { width: 52px; padding-left: 0 !important; vertical-align: middle !important; }
.vis-td .icon-btn { width: 36px; height: 36px; color: var(--muted); }
.table tr.off .vis-td .icon-btn { color: var(--danger); }

.pcount {
  position: absolute; right: 8px; bottom: 8px; padding: 2px 8px; border-radius: 999px;
  background: rgba(28, 34, 32, .72); color: #fff; font-size: 11px; font-weight: 600;
}
dialog.photo .photo-main { display: block; width: 100%; max-height: 62dvh; object-fit: contain; background: #fff; }
.photo-thumbs { display: flex; gap: 8px; padding: 10px 16px 0; overflow-x: auto; }
.photo-thumbs button {
  flex: none; width: 56px; height: 56px; padding: 0; overflow: hidden; border-radius: 8px;
  border: 2px solid var(--line); background: #fff; cursor: pointer;
}
.photo-thumbs button[aria-current] { border-color: var(--accent); }
.photo-thumbs img { width: 100%; height: 100%; object-fit: contain; }


/* ---------- модификаторы */

.incart { font-size: 12px; color: var(--accent); font-weight: 600; margin-bottom: 4px; }
.opts { color: var(--accent); }
dialog.chooser .head .small { font-weight: 400; margin-top: 2px; }
.mgroup { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 6px; margin: 0; }
.mgroup legend { padding: 0 6px; font-weight: 700; }
.mgroup.has-err { border-color: var(--danger); }
.mgroup .err { font-size: 13px; color: var(--danger); min-height: 0; }
.mopt { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-top: 1px solid var(--line); cursor: pointer; }
.mopt:first-of-type { border-top: 0; }
.mopt input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; flex: none; }
.mopt[hidden] { display: none; }
.picker { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 0 10px; margin-top: 8px; }
.gp-new { display: grid; grid-template-columns: minmax(0, 1fr) 100px auto; gap: 8px; margin-top: 8px; }
.gp-err:empty, .perr:empty { display: none; }
.pm-list { display: flex; flex-direction: column; gap: 8px; }
.pm-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; }
.pm-num { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.pm-num .input { width: 56px; min-height: 38px; padding: 6px 8px; text-align: center; }
.pm-add { margin-top: 8px; }
dialog .foot .btn { white-space: nowrap; }
dialog.chooser .foot { flex-wrap: wrap; justify-content: flex-end; }
dialog.chooser .foot .primary { flex: 1 1 auto; }
.pm-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.pm-actions .pm-add { margin-top: 0; flex: 1 1 200px; }
.pm-row { flex-wrap: wrap; }
.pm-row > .grow { flex: 1 1 160px; }
.pm-ctl { display: flex; align-items: center; gap: 8px; flex: none; margin-left: auto; }
.picker[data-multi] { max-height: 220px; }

/* ---------- остаток */

.stock { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.stock.none { color: var(--danger); font-weight: 600; }
.pcard.out .pcard-img img { opacity: .45; filter: grayscale(1); }
.pcard.out .pcard-price { color: var(--muted); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.table tr.sep td {
  padding: 8px 14px; background: var(--surface-2); color: var(--muted);
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}

/* ---------- карточка товара (шторка) */

dialog.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; margin: auto auto 0; padding: 0;
  border-radius: 20px 20px 0 0; overflow: hidden;
}
dialog.sheet[open] { display: flex; flex-direction: column; }
@media (min-width: 600px) { dialog.sheet { margin: auto; border-radius: 20px; } }
/* Высота — по содержимому (flex-basis: auto), а не «0% + растянуться»: Safari на iPhone при окне
   без явной высоты считает 0% нулём, и от карточки товара оставалась только нижняя полоса. */
.sheet-body { flex: 1 1 auto; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot { flex: none; }
.sheet-grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 0; }
.sheet-photo { background: #fff; margin-top: 8px; }
.sheet-photo .photo-main { display: block; width: 100%; max-height: 46dvh; object-fit: contain; }
.sheet-info { padding: 14px 18px 18px; }
.sheet-name { font-size: 19px; line-height: 1.3; margin: 0; }
.sheet-price { font-size: 22px; font-weight: 700; margin-top: 8px; }
.sheet-price span { font-size: 14px; font-weight: 400; color: var(--muted); }
.sheet-h {
  display: inline-block; margin: 16px 0 8px; padding: 5px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; font-weight: 600;
}
.sheet-descr { white-space: pre-line; color: var(--ink); font-size: 15px; line-height: 1.5; }
.sheet-foot {
  display: flex; align-items: flex-end; gap: 10px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--surface);
}
.sheet-ctl { display: flex; flex-direction: column; gap: 6px; }
.pcard-name[data-act] { cursor: pointer; }
.pcard-img.none { cursor: pointer; }
.sheet-ctl .btn { white-space: nowrap; }
.cat-cover { aspect-ratio: 4 / 3; max-width: 260px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  display: grid; place-items: center; overflow: hidden; padding: 8px; text-align: center; }
.cat-cover img { width: 100%; height: 100%; object-fit: contain; }
.cat-actions { margin-top: 10px; }
.cat-pick { margin-top: 10px; max-height: 300px; overflow: auto; }
button.gimg { padding: 0; cursor: pointer; }
/* поле количества в «− N +»: без стрелок, вписывается как число */
.stepper .qty {
  width: 52px; min-width: 0; height: 40px; padding: 0 4px; text-align: center;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  font: inherit; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink);
  -moz-appearance: textfield; appearance: textfield;
}
.stepper .qty::-webkit-outer-spin-button, .stepper .qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .qty:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- задачи агента */

.tab .count.warn { background: var(--warn); color: #fff; left: calc(50% - 26px); }
.task-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none; color: inherit; border-left: 4px solid var(--warn); }
.task-card.late, .card.late { border-left: 4px solid var(--danger); }
.task-card .grow { display: flex; flex-direction: column; gap: 2px; }
.task-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); display: grid; place-items: center; flex: none; }
.files { display: flex; flex-wrap: wrap; gap: 8px; }
.fthumb { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #fff; flex: none; }
.fthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fpdf { display: grid; place-items: center; width: 100%; height: 100%; font-size: 12px; font-weight: 700; color: var(--accent); text-decoration: none; }
.fdel { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border: 0; border-radius: 8px; padding: 0;
  background: rgba(255, 255, 255, .94); color: #b3261e; display: grid; place-items: center; cursor: pointer; }
.fdel .i { width: 15px; height: 15px; }
.fadd { align-self: flex-start; cursor: pointer; }
.fadd.busy { pointer-events: none; opacity: .7; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
details.memo summary { cursor: pointer; font-weight: 600; font-size: 14px; }
details.memo ul { margin: 8px 0 0; padding-left: 20px; font-size: 14px; color: var(--muted); }
details.memo li + li { margin-top: 4px; }
h2 .i { vertical-align: -3px; color: var(--accent); }

/* ---------------------------------------------------------------- каталог для заказчиков */
.top-right { margin-left: auto; }
.contact-card { text-align: center; padding-block: 24px; }
.contact-phone { display: block; font-size: 26px; font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.contact-note { color: var(--muted); white-space: pre-line; margin: 0; }
.contact-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.contact-btns .btn { flex: 1 1 130px; justify-content: center; }
.mods-info { font-size: 14px; line-height: 1.45; margin-top: 4px; }

/* ---------------------------------------------------------------- логотип ГРС */
img.brand-mark { object-fit: cover; background: #fff; }
.brand-logo { display: block; height: 38px; width: auto; }
:root[data-theme="dark"] .brand-logo, :root[data-theme="dark"] .login-logo { background: #fff; border-radius: 8px; padding: 3px 6px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo, :root:not([data-theme="light"]) .login-logo { background: #fff; border-radius: 8px; padding: 3px 6px; }
}
.warn-text { color: var(--warn); }

/* Порядок полей формы: стрелки «выше / ниже» */
.move-td { width: 1%; padding-right: 0 !important; }
.move { display: flex; flex-direction: column; gap: 2px; }
.move .icon-btn { width: 32px; height: 26px; min-height: 0; }
.move .icon-btn[disabled] { opacity: .25; cursor: default; }

/* «Дата или текст»: строка + кнопка-календарь (под ней невидимое поле даты — оно и открывает календарь) */
.dtx { display: flex; gap: 8px; }
.dtx .input { flex: 1; min-width: 0; }
.dtx-pick { position: relative; padding: 0 12px; flex: none; }
.dtx-pick input[type="date"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dtx-pick input[type="date"]::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }

/* ---------------------------------------------------------------- живые фото товаров */
.live-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.live-item { margin: 0; }
.live-img { display: block; width: 100%; padding: 0; border: 0; background: var(--surface-2); border-radius: 12px; overflow: hidden; aspect-ratio: 1; cursor: zoom-in; }
.live-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.live-item figcaption { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-top: 4px; }
.live-item figcaption .icon-btn { width: 32px; height: 32px; min-height: 0; }
/* Выбор источника фото — небольшое окно снизу */
dialog.picker { border: 0; padding: 16px; border-radius: 18px 18px 0 0; margin: auto auto 0; width: min(420px, 100%); background: var(--surface); color: var(--ink);
  max-height: 88dvh; overflow: auto; }  /* не 260px от списка .picker выше: в окне выбора бывает 15 вариантов */
dialog.picker::backdrop { background: rgba(0, 0, 0, .4); }
@media (min-width: 700px) { dialog.picker { border-radius: 18px; margin: auto; } }

/* Удаление заказа — отдельно внизу карточки, чтобы не нажать случайно */
.danger-zone { margin-top: 28px; padding-top: 16px; border-top: 1px dashed var(--line); display: flex; justify-content: flex-end; }

/* ---------------------------------------------------------------- фото на весь экран */
.photo-open { display: block; position: relative; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.zoom-hint { position: absolute; right: 10px; bottom: 10px; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(20, 24, 30, .55); color: #fff; pointer-events: none; }
.zoom-hint .i { width: 18px; height: 18px; }
dialog.viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  border-radius: 0; background: #000; color: #fff; overflow: hidden;
  /* Свайп листает фото: браузеру его не отдаём (иначе — «назад» по истории), увеличение двумя пальцами — можно */
  touch-action: pinch-zoom; overscroll-behavior: contain; }
dialog.viewer::backdrop { background: #000; }
.v-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.v-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: linear-gradient(rgba(0, 0, 0, .55), transparent); }
.v-count { font-size: 15px; font-weight: 600; }
.v-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: rgba(255, 255, 255, .16); color: #fff; font-size: 18px; cursor: pointer; }
.v-btn .i { width: 22px; height: 22px; }
.v-prev, .v-next { position: absolute; top: 50%; transform: translateY(-50%); }
.v-prev { left: max(12px, env(safe-area-inset-left)); }
.v-next { right: max(12px, env(safe-area-inset-right)); }
.v-next .i { transform: scaleX(-1); }
@media (hover: none) { .v-prev, .v-next { opacity: .7; } }
/* Вопрос «да / нет»: кнопки одна под другой во всю ширину — длинные подписи не обрезаются */
dialog .foot.confirm-foot { flex-direction: column-reverse; align-items: stretch; flex-wrap: nowrap; }
dialog .foot.confirm-foot .btn { width: 100%; white-space: normal; }

/* Главная без входа: «Вы агент или гость?» */
.choice { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px; text-align: left;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink);
  text-decoration: none; cursor: pointer; font: inherit; box-shadow: var(--shadow); }
.choice:hover { border-color: var(--accent); }
.choice b { display: block; font-size: 17px; }
.choice .small { display: block; margin-top: 2px; }
.choice-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); flex: none; }
.choice-go { color: var(--muted); flex: none; }
.choice-go .i { transform: scaleX(-1); }

/* Строка над плитками: «Товары / Услуги» слева, переключатель темы справа */
.cat-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.cat-bar .segtabs { margin-top: 0; }
.theme-switch { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; flex: none;
  -webkit-tap-highlight-color: transparent; }
.theme-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ts-track { position: relative; width: 46px; height: 28px; border-radius: 999px; background: var(--line);
  border: 1px solid var(--line); transition: background .2s; }
.ts-thumb { position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.theme-switch input:checked + .ts-track { background: var(--accent); border-color: var(--accent); }
.theme-switch input:checked + .ts-track .ts-thumb { transform: translateX(18px); }
.theme-switch input:focus-visible + .ts-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- профиль агента */

.profile-card { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 17px;
}
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 12px; }
.month-nav h2 { margin: 0; text-align: center; }
.month-nav .icon-btn[disabled] { opacity: .3; cursor: default; }
.month-nav .fwd .i { transform: scaleX(-1); }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.stat.wide { grid-column: 1 / -1; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-val { font-size: 22px; letter-spacing: -.01em; }
.stat.wide .stat-val { font-size: 28px; color: var(--accent); }
.src-list { padding: 4px 14px; }
.src-row { padding: 10px 0; }
.src-row + .src-row { border-top: 1px solid var(--line); }
.src-bar { height: 6px; border-radius: 3px; background: var(--surface-2); margin-top: 8px; overflow: hidden; }
.src-bar span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
@media (min-width: 600px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat.wide { grid-column: auto; }
}
.duty-list { padding: 2px 14px; }
.card.pad .duty-list { padding: 0; }
.duty-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.duty-row + .duty-row { border-top: 1px solid var(--line); }
.duty-day { font-weight: 700; min-width: 44px; }
.duty-row.soon .duty-day { color: var(--accent); }

/* ---------- правка состава заказа */

.h2-row { margin: 22px 0 10px; }
.h2-row h2 { margin: 0; }
.eline { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.eline + .eline { border-top: 1px solid var(--line); }
.eline .ehead { align-items: flex-start; }
.eline .name { font-weight: 600; }
.eline-ctl { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.eline-ctl > * { display: flex; flex-direction: column; gap: 4px; }
.eprice .input { width: 140px; max-width: 100%; }
.input.bad { border-color: var(--danger); outline-color: var(--danger); }
.esum { margin-left: auto; font-size: 16px; padding-bottom: 10px; }
.edit-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }
.edit-foot .btn.primary { flex: 1 1 220px; max-width: 320px; }
.changes .change { padding: 12px 14px; }
.changes .change + .change { border-top: 1px solid var(--line); }
.change-text { white-space: pre-line; font-size: 14px; margin-top: 4px; }
dialog.picker-sheet { height: 88dvh; }
.picker-head { padding: 14px 16px 8px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); flex: none; }
.picker-head .search { margin: 0; }
.picker-head [data-m="close"] .i { transform: rotate(-90deg); }
.pick-list { padding: 4px 0 calc(12px + env(safe-area-inset-bottom)); }
.pick-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 16px; min-height: 52px;
  background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); text-align: left; font: inherit; cursor: pointer;
}
.pick-row:disabled { opacity: .5; cursor: default; }
.pick-row img, .pick-noimg { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface-2); }
.pick-row .grow { display: flex; flex-direction: column; gap: 2px; }
.pick-row.up { color: var(--accent); }
.pick-row .fwd .i { transform: scaleX(-1); color: var(--muted); }

/* ---------- фото в строках корзины и заказа */

.lthumb {
  flex: none; width: 56px; height: 56px; padding: 0; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); background: #fff; display: grid; place-items: center; cursor: zoom-in;
}
.lthumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.lthumb.none { background: var(--surface-2); color: var(--muted); cursor: default; }
.eline .ehead { gap: 12px; }
@media (min-width: 600px) { .lthumb { width: 64px; height: 64px; } }
.cart-line { align-items: flex-start; }
.cart-ctl { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- документы заказа */

.docs .doc-block { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.docs .doc-block + .doc-block { border-top: 1px solid var(--line); }
.doc-row { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.doc-row .grow { display: flex; flex-direction: column; gap: 2px; min-width: 160px; }
.doc-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.doc-old summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
.doc-old .doc-row { padding: 8px 0; border-top: 1px dashed var(--line); }
.doc-wait { display: flex; align-items: center; gap: 8px; margin: 0; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; margin: 0; display: inline-block; }

/* ---------- PDF внутри приложения */

dialog.docview { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  border-radius: 0; background: #3b3f42; color: #fff; overflow: hidden; }
dialog.docview[open] { display: flex; flex-direction: column; }
dialog.docview::backdrop { background: #000; }
.dv-bar { flex: none; display: flex; align-items: center; gap: 8px; background: #1f2224;
  padding: calc(8px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left)); }
.dv-title { flex: 1; min-width: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dv-bar .v-btn { flex: none; width: 40px; height: 40px; }
.dv-pages { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  touch-action: pan-x pan-y pinch-zoom; padding: 10px 0 calc(16px + env(safe-area-inset-bottom)); }
.dv-inner { --z: 1; width: calc(min(100%, 900px) * var(--z)); margin: 0 auto; display: flex; flex-direction: column; gap: 10px;
  padding: 0 8px; box-sizing: border-box; }
.dv-page { display: block; width: 100%; height: auto; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .35); }
.dv-inner .spinner { margin: 30vh auto; }
.dv-err { padding: 20px; color: var(--ink); }
.fthumb .fimg { padding: 0; border: 0; background: none; cursor: zoom-in; display: block; }
.fthumb .fimg { width: 100%; height: 100%; }
.fthumb button.fpdf { border: 0; background: #fff; font-family: inherit; cursor: pointer; }
a.v-btn { text-decoration: none; }

/* ---------- чат агентов */

main.chat-main { padding-bottom: calc(var(--tabbar) + var(--composer-h, 150px) + 16px + env(safe-area-inset-bottom)); }
.chat { display: flex; flex-direction: column; gap: 4px; }
.chat-day { text-align: center; margin: 14px 0 6px; }
.chat-day span { font-size: 12px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); padding: 3px 10px; border-radius: 999px; }
.msg { max-width: 82%; align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 16px 16px 16px 6px;
  padding: 7px 11px 5px; margin-top: 6px; cursor: pointer; position: relative; box-shadow: var(--shadow); }
.msg.cont { margin-top: 2px; }
.msg.mine { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); border-radius: 16px 16px 6px 16px; }
.msg.bot { background: var(--surface-2); max-width: 94%; }
.msg-name { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.msg.bot .msg-name { color: var(--muted); }
.msg-text { white-space: pre-wrap; word-break: break-word; font-size: 15px; line-height: 1.4; }
.msg.mine .msg-text a { color: inherit; }
.msg-time { font-size: 11px; opacity: .6; text-align: right; margin-top: 2px; }
.msg-quote { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--accent); background: rgba(127, 127, 127, .12);
  border-radius: 6px; padding: 4px 8px; margin: 2px 0 4px; font: inherit; color: inherit; cursor: pointer; }
.msg.mine .msg-quote { border-left-color: var(--accent-ink); background: rgba(255, 255, 255, .16); }
.msg-quote b { display: block; font-size: 12px; }
.msg-quote span { display: block; font-size: 13px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.flash { outline: 3px solid var(--warn); outline-offset: 2px; }
.chat-new { position: fixed; right: 16px; bottom: calc(var(--tabbar) + var(--composer-h, 150px) + 12px + env(safe-area-inset-bottom)); z-index: 26;
  border: 0; border-radius: 999px; padding: 8px 14px; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600;
  display: flex; align-items: center; gap: 6px; box-shadow: var(--shadow); cursor: pointer; }
.chat-new[hidden] { display: none; }
.composer { position: fixed; left: 0; right: 0; z-index: 25; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line); padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 6px; max-width: 100vw; }
body.kb-open .tabbar { display: none; }
.chat-status { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-chips { flex-wrap: nowrap; overflow-x: auto; margin: 0; padding-bottom: 2px; scrollbar-width: none; }
.chat-chips .chip { flex: none; }
dialog.chat-report .head .small { font-weight: 400; margin-top: 2px; }
dialog.chat-report .foot { flex-wrap: wrap; }
dialog.chat-report .foot .btn { flex: 1 1 auto; }
dialog.chat-report .foot .btn[hidden] { display: none; }
dialog.chat-report .report-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.45; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer-row textarea { flex: 1; min-height: 42px; max-height: 140px; resize: none; padding-top: 10px; line-height: 1.35; }
.composer-row .icon-btn { width: 44px; height: 44px; flex: none; }
.reply-bar { display: flex; align-items: center; gap: 8px; border-left: 3px solid var(--accent); padding: 2px 0 2px 8px; }
.reply-bar[hidden], .cmd-hints[hidden] { display: none; }
.reply-bar .grow { display: flex; flex-direction: column; min-width: 0; }
.reply-bar .grow span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar b .i { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.cmd-hints { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cmd-hints button { display: flex; gap: 10px; align-items: baseline; padding: 9px 12px; border: 0; background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.cmd-hints button + button { border-top: 1px solid var(--line); }
.notify-row input { width: 22px; height: 22px; flex: none; }
@media (min-width: 760px) { .composer { left: 50%; transform: translateX(-50%); width: 760px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
.tab .count[hidden] { display: none; }
.composer-row textarea { overflow-y: hidden; }
.notify-row > span { display: flex; flex-direction: column; gap: 2px; }

/* Смена, выезды и консультации агента (блок в «Заказах» и окно нового выезда) */
.geo-box { margin-bottom: 14px; }
.geo-box:empty { display: none; }
.geo-shift.free { border-left: 4px solid var(--ok); }
.geo-shift.busy { border-left: 4px solid var(--warn); }
.geo-card { gap: 8px; }
.geo-card.offered, .geo-card.sent { border: 2px solid var(--accent); }
.geo-card.accepted, .geo-card.arrived, .geo-card.taken { border-left: 4px solid var(--ok); }
.geo-card.done { color: var(--muted); }
.geo-addr { font-size: 16px; }
.geo-comment { white-space: pre-wrap; word-break: break-word; }
.geo-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.geo-btns .btn { flex: 1 1 auto; }
dialog.geo-offer { width: min(440px, calc(100vw - 24px)); }
dialog.geo-offer .body { padding: 14px; }
dialog.geo-offer .geo-card { box-shadow: none; }
.dbox { gap: 8px; border-left: 4px solid var(--accent); }
.dbox-trip { display: block; color: var(--ink); text-decoration: none; padding: 6px 0; border-top: 1px solid var(--line);
  word-break: break-word; }

/* Заказы у администратора: дата и агент жирным, усопший мелко; выбор дня оформления */
.order-card.adm .oc-date { font-size: 17px; }
.order-card.adm .oc-agent { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.order-card.adm .oc-agent .i { width: 16px; height: 16px; color: var(--muted); }
.order-card.adm .oc-who { color: var(--muted); min-width: 0; }
.order-card.adm .oc-src { flex: none; margin-left: 8px; padding: 1px 8px; border-radius: 8px; background: var(--accent-soft);
  color: var(--accent); font-weight: 600; }
.date-filter { gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.date-pick { display: flex; align-items: center; gap: 8px; flex: 1 1 260px; min-width: 0; color: var(--muted); }
.date-pick .input { flex: 1; min-width: 150px; color: var(--ink); }
.date-filter [hidden] { display: none; }
.day-sum { margin: 4px 0 10px; }

/* Кабинет логиста */
.logist-filter .chips { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.chips-gap { flex-basis: 100%; height: 0; }
.logist-card .lc-morgue { margin-top: 2px; }
.logist-card .lc-items { color: var(--ink); word-break: break-word; }
.logist-head { display: flex; flex-direction: column; gap: 4px; }
.logist-head .lh-date { font-size: 22px; font-weight: 700; }
.logist-head .lh-morgue { font-size: 17px; font-weight: 600; word-break: break-word; }
.input.bad { border-color: var(--danger); }
.logist-card .lc-changed { color: var(--warn); font-weight: 600; }
.logist-card .lc-stage { color: var(--muted); }
.logist-card .lc-stage.mark { color: var(--ok); font-weight: 600; }
.logist-stage { gap: 8px; margin-top: 12px; }
.logist-stage .ls-name { font-size: 17px; }
.logist-field { margin-bottom: 2px; }
.logist-card .lc-other { color: var(--muted); }
.logist-head .lh-farewell { font-size: 15px; color: var(--muted); }
.logist-field { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; border-radius: 14px; }
.logist-field button { padding: 8px 6px; font-size: 14px; line-height: 1.2; border-radius: 10px; }
#ldate-box[hidden] { display: none; }
.logist-card .oc-date { line-height: 1.35; }
.logist-card .lc-warn { color: var(--warn); font-weight: 600; }

/* выбор «Кто принимает»: подрядчик заголовком, под машиной — что пойдёт в заявку */
.pick-group { margin-top: 6px; }
.btn.pick-opt { flex-direction: column; align-items: flex-start; gap: 1px; min-height: 0; padding: 7px 12px;
  text-align: left; font-size: 15px; line-height: 1.25; }
.pick-opt .pick-hint { font-weight: 400; opacity: .75; }

/* фото агента: у его заказов в «Все заказы», в таблице и карточке агента */
.ava { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; background: var(--surface-2); }
.ava-none { display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  color: var(--muted); border: 1px solid var(--line); }
.order-card.adm .oc-agent { gap: 8px; }
.order-card.adm .ava { width: 36px; height: 36px; }
.agent-cell { display: flex; align-items: flex-start; gap: 10px; }
.agent-photo { align-items: center; gap: 10px; }
.agent-photo .ava { width: 64px; height: 64px; font-size: 20px; }

/* «Все заказы»: источник заказа цветом, как в таблице «Учет СРС» */
.order-card.adm.src-color { border-left: 6px solid var(--src); }
.order-card.adm.src-color .oc-src { background: var(--src); color: var(--src-ink); font-weight: 600; }

/* «Все заказы»: галочки у заказов и панель «перевести отмеченные в статус» над вкладками */
.opick-all { margin: 4px 2px 10px; width: fit-content; }
.opick { display: flex; align-items: stretch; gap: 6px; }
.opick .order-card { flex: 1; min-width: 0; }
.opick-box { flex: none; display: flex; align-items: center; justify-content: center; width: 34px; cursor: pointer; }
.opick-box input { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.opick.on .order-card { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.bulkdock { position: fixed; left: 0; right: 0; z-index: 25; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding: 10px 16px; pointer-events: none; }
.bulkbar { pointer-events: auto; max-width: 728px; margin: 0 auto; padding: 10px 14px 12px; display: flex; flex-direction: column;
  gap: 6px; box-shadow: 0 6px 20px rgba(20, 40, 32, .25); }
.bulk-st { display: flex; flex-wrap: wrap; gap: 8px; }
.bulk-st .btn { padding: 0 6px; }
.bulk-st .badge { font-size: 14px; padding: 4px 10px; }
body:has(.bulkbar) main { padding-bottom: calc(var(--tabbar) + 170px + env(safe-area-inset-bottom)); }

/* Кабинет логиста: рамка заказа по стадии сделки — не укомплектован / укомплектован / доставлен в морг */
.logist-card.pack-unpacked { border: 2px solid #2563eb; }
.logist-card.pack-packed { border: 2px solid #f08c00; }
.logist-card.pack-done { border: 2px solid #ec4899; }
.logist-card.pack-morgue { border: 2px solid #15803d; }
.pack-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 10px; }
.pk-btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.pk-btn[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-weight: 600; }
.pk-btn .pk-n { color: var(--muted); font-variant-numeric: tabular-nums; }
.pk-btn.pk-all { color: var(--muted); }
.pack-legend .pk { width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--pk); flex: none; }
.pk-btn[aria-pressed="true"] .pk { background: var(--pk); }  /* выбранный цвет — закрашенный квадратик */
.pk-unpacked { --pk: #2563eb; }
.pk-packed { --pk: #f08c00; }
.pk-done { --pk: #ec4899; }
.pk-morgue { --pk: #15803d; }
