:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f3f4f8;
  --border: #e4e6ee;
  --text: #171a23;
  --muted: #6b7180;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --accent-text: #ffffff;
  --green: #059669;
  --green-soft: #e7f8f1;
  --amber: #b45309;
  --amber-soft: #fff4dc;
  --red: #dc2626;
  --red-soft: #fdecec;
  --blue-soft: #e8f0ff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1017;
    --surface: #161924;
    --surface-2: #1d2130;
    --border: #2a2f40;
    --text: #e8eaf2;
    --muted: #9aa1b4;
    --accent: #7c74ff;
    --accent-soft: #24234a;
    --green: #34d399;
    --green-soft: #12301f;
    --amber: #fbbf24;
    --amber-soft: #33270c;
    --red: #f87171;
    --red-soft: #3a1717;
    --blue-soft: #1a2440;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }

.container { max-width: 1180px; margin: 0 auto; padding: 24px 16px 120px; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(16px, calc((100vw - 1180px) / 2 + 16px));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.logo-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: #fff;
}
.logo-mark svg { width: 22px; height: 22px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); font-weight: 500;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: transparent; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { width: 30px; padding: 0; }
.btn svg { width: 16px; height: 16px; flex: none; }

/* ---------- form controls ---------- */
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 70px; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 500; color: var(--muted); }
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 34px; }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 10px; gap: 2px; }
.segmented button {
  border: 0; background: transparent; padding: 0 12px; height: 30px; border-radius: 8px;
  cursor: pointer; color: var(--muted); font-weight: 500; font-size: 13px;
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- cards & layout ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 500; margin-bottom: 10px; }
.back:hover { color: var(--text); }
.back svg { width: 16px; height: 16px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.stat .hint { color: var(--muted); font-size: 12px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 500;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.ff { background: var(--blue-soft); color: var(--accent); }
.badge.draft { background: var(--surface-2); color: var(--muted); }
.badge.sent { background: var(--amber-soft); color: var(--amber); }
.badge.received { background: var(--green-soft); color: var(--green); }
.badge.return { background: var(--amber-soft); color: var(--amber); }
.badge.shipment { background: var(--blue-soft); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--green); }
.dot.err { background: var(--red); }
.dot.off { background: var(--border); }

/* ---------- list ---------- */
.month { margin: 26px 0 10px; display: flex; align-items: baseline; gap: 10px; }
.month h2 { text-transform: capitalize; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.ship-card { display: flex; gap: 14px; padding: 16px; transition: border-color .15s, transform .15s; }
.ship-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); transform: translateY(-1px); }
.datebox {
  flex: none; width: 54px; height: 58px; border-radius: 12px; background: var(--accent-soft); color: var(--accent);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.datebox b { font-size: 22px; }
.datebox small { font-size: 11px; font-weight: 600; text-transform: uppercase; }
.ship-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ship-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ship-brands { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ship-foot { display: flex; align-items: center; gap: 8px; margin-top: 2px; flex-wrap: wrap; }
.units { font-weight: 700; }
.units small { color: var(--muted); font-weight: 500; }

.empty { text-align: center; padding: 60px 20px; }
.empty .ico {
  width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 18px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.empty .ico svg { width: 34px; height: 34px; }
.empty p { color: var(--muted); max-width: 420px; margin: 6px auto 18px; }

/* ---------- detail ---------- */
.brand-card { margin-bottom: 16px; overflow: hidden; }
.brand-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.brand-head .owner { color: var(--muted); font-size: 13px; }
.brand-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 18px; }
.model-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table.qty { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.qty th, table.qty td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 8px 10px; text-align: center; }
table.qty tr > *:last-child { border-right: 0; }
table.qty tbody tr:last-child > *, table.qty tfoot tr:last-child > * { border-bottom: 0; }
table.qty thead th { background: var(--surface-2); font-weight: 600; font-size: 13px; vertical-align: top; }
table.qty thead th .art { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
table.qty th.size, table.qty td.size { font-weight: 600; width: 72px; text-align: left; }
table.qty tfoot td { background: var(--surface-2); font-weight: 700; }
table.qty td.empty-cell { color: var(--border); }
table.qty .rowtotal { font-weight: 600; color: var(--muted); }
.brand-total { display: flex; justify-content: flex-end; gap: 18px; color: var(--muted); font-size: 13px; }
.brand-total b { color: var(--text); font-size: 15px; }
.comment-box { padding: 14px 18px; margin-bottom: 16px; white-space: pre-wrap; color: var(--muted); }

/* ---------- editor ---------- */
.meta-grid { display: grid; grid-template-columns: 170px 1fr 1.4fr; gap: 12px; padding: 18px; margin-bottom: 16px; }
.meta-grid .status-field { grid-column: span 2; }
.meta-grid .status-field .segmented { align-self: flex-start; }
.ed-brand { margin-bottom: 16px; }
.ed-brand-head { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); align-items: end; }
.ed-brand-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.ed-model { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface); }
.ed-model.is-return { border-color: color-mix(in srgb, var(--amber) 40%, var(--border)); }
.ed-model-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.ed-model-head .input { max-width: 320px; }
.sizes { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.size-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 4px 0 10px; border-radius: 8px;
  background: var(--surface-2); font-weight: 600; font-size: 13px;
}
.size-chip button { border: 0; background: transparent; cursor: pointer; color: var(--muted); width: 20px; height: 20px; border-radius: 5px; line-height: 1; }
.size-chip button:hover { background: var(--red-soft); color: var(--red); }
.size-add { width: 96px; height: 28px; border-radius: 8px; border: 1px dashed var(--border); background: transparent; padding: 0 8px; outline: none; font-size: 13px; }
.size-add:focus { border-color: var(--accent); border-style: solid; }

table.grid-ed { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
table.grid-ed th, table.grid-ed td { padding: 4px; }
table.grid-ed thead th { vertical-align: bottom; min-width: 128px; }
table.grid-ed th.size { text-align: left; min-width: 54px; font-weight: 600; padding-right: 10px; }
.col-head { display: flex; flex-direction: column; gap: 4px; }
.col-head .input { height: 32px; padding: 0 8px; font-size: 13px; border-radius: 8px; }
.col-head .art-input { color: var(--muted); }
.col-tools { display: flex; justify-content: space-between; align-items: center; }
.col-tools .btn { height: 24px; font-size: 12px; padding: 0 6px; }
.cell {
  width: 100%; height: 36px; text-align: center; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); outline: none; font-weight: 500;
}
.cell:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cell:not(:placeholder-shown) { background: var(--accent-soft); border-color: transparent; }
table.grid-ed tfoot td { text-align: center; font-weight: 700; padding-top: 8px; }
table.grid-ed .rowtotal { text-align: center; color: var(--muted); font-weight: 600; min-width: 64px; }
.add-col {
  min-width: 110px; height: 100%; min-height: 72px; border: 1px dashed var(--border); border-radius: 10px;
  background: transparent; color: var(--muted); cursor: pointer; font-weight: 500;
}
.add-col:hover { border-color: var(--accent); color: var(--accent); }
.add-row {
  width: 100%; height: 44px; border: 1px dashed var(--border); border-radius: 12px;
  background: transparent; color: var(--muted); cursor: pointer; font-weight: 500;
}
.add-row:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.add-brand { height: 56px; font-size: 15px; }
.model-total { margin-left: auto; color: var(--muted); }
.model-total b { color: var(--text); }

.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.savebar-inner { max-width: 1180px; margin: 0 auto; padding: 12px 16px; display: flex; gap: 10px; align-items: center; }
.savebar .sum { display: flex; gap: 18px; color: var(--muted); }
.savebar .sum b { color: var(--text); font-size: 16px; }

/* ---------- login ---------- */
.login { max-width: 360px; margin: 10vh auto 0; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login .logo-mark { width: 44px; height: 44px; border-radius: 12px; }
.login .error { color: var(--red); font-size: 13px; min-height: 18px; }

/* ---------- misc ---------- */
.toasts { position: fixed; bottom: 84px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  padding: 10px 14px; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: var(--shadow);
  font-weight: 500; max-width: 360px; animation: pop .2s ease-out;
}
.toast.err { background: var(--red); color: #fff; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
@keyframes drop { from { opacity: 0; transform: translateY(6px); } }
.spinner {
  width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--border); border-top-color: var(--accent);
  animation: spin .7s linear infinite; margin: 60px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.sync-line { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.sync-line.err { color: var(--red); }

@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meta-grid { grid-template-columns: 1fr 1fr; }
  .meta-grid .title-field, .meta-grid .comment-field, .meta-grid .status-field { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  h1 { font-size: 20px; }
  .grid { grid-template-columns: 1fr; }
  .meta-grid, .ed-brand-head { grid-template-columns: 1fr; }
  .meta-grid > * { grid-column: 1 / -1 !important; }
  .stat .value { font-size: 22px; }
  .search { max-width: none; }
  .hide-sm { display: none; }
  .savebar .sum span.hide-sm { display: none; }
}
@media print {
  .topbar, .savebar, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}

/* ============================================================
   Телефон: редактор карточками, крупные цели касания
   ============================================================ */
.hidden { display: none !important; }
.only-mobile { display: none !important; }

.suggest { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.suggest-label { font-size: 12px; font-weight: 500; color: var(--muted); margin-right: 2px; }
.chip.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.chip small { color: var(--muted); font-weight: 500; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.ed-brand-body > [data-chips]:empty, .ed-model > [data-chips]:empty { display: none; }
.ed-brand-body > [data-chips] .suggest { margin-top: 0; }

.collapse svg { transition: transform .2s; }
.collapse.is-collapsed svg { transform: rotate(-90deg); }
.ed-model.is-collapsed { padding: 8px 14px; background: var(--surface-2); }
.ed-model.is-collapsed .ed-model-head { margin-bottom: 0; }
.model-summary {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  border: 0; background: transparent; cursor: pointer; text-align: left; padding: 4px 0;
}
.model-summary b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-summary span { color: var(--muted); font-size: 12px; }

/* нижняя шторка */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(10, 12, 20, .45);
  display: flex; align-items: flex-end; justify-content: center; animation: dim .15s ease-out;
}
.sheet {
  width: 100%; max-width: 440px; background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .2); animation: slideup .2s ease-out;
}
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto; }
.sheet-input { height: 56px; font-size: 26px; font-weight: 700; text-align: center; }
.sheet .quick .chip { height: 40px; min-width: 52px; justify-content: center; font-size: 15px; }
.sheet-actions { justify-content: flex-end; }
.sheet-actions .btn { height: 44px; padding: 0 20px; }
@media (min-width: 701px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 20px; }
}
@keyframes dim { from { background: rgba(10, 12, 20, 0); } }
@keyframes slideup { from { transform: translateY(40px); } }

details.more { grid-column: 1 / -1; }
details.more summary { cursor: pointer; color: var(--accent); font-weight: 500; font-size: 13px; padding: 4px 0; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: '+ '; }
details.more[open] summary::before { content: '− '; }
.more-body { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }

/* карточки цветов (мобильный редактор) */
.color-cards { display: flex; flex-direction: column; gap: 10px; }
.color-card {
  border: 1px solid var(--border); border-radius: 14px; padding: 12px; background: var(--surface);
  display: flex; flex-direction: column; gap: 8px;
}
.cc-head { display: flex; gap: 6px; align-items: center; }
.cc-name { font-weight: 600; }
.cc-sizes { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 8px; margin-top: 2px; }
.cc-size { display: flex; flex-direction: column; gap: 4px; }
.cc-size span { font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; }
.cc-size .cell { height: 50px; font-size: 20px; font-weight: 600; border-radius: 12px; }
.cc-foot { display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
.cc-foot b { color: var(--text); font-size: 16px; }

/* компактный просмотр */
.color-list { display: flex; flex-direction: column; gap: 8px; }
.cl-row { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.cl-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.cl-head .muted { font-size: 12px; }
.cl-sizes { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.cl-size {
  display: flex; flex-direction: column; align-items: center; padding: 4px 6px;
  border-radius: 8px; background: var(--accent-soft); font-weight: 700; font-variant-numeric: tabular-nums;
}
.cl-size small { font-size: 11px; color: var(--muted); font-weight: 600; }
.cl-size.zero { background: var(--surface-2); color: var(--muted); font-weight: 500; }

@media (max-width: 700px) {
  .only-mobile { display: flex !important; }
  .only-desktop { display: none !important; }
  html { scroll-padding-bottom: 120px; scroll-padding-top: 70px; }
  .container { padding: 16px 12px calc(110px + env(safe-area-inset-bottom)); }
  .topbar { padding: 10px 12px; }
  .topbar .btn { height: 38px; }
  .topbar .btn.primary { width: 44px; padding: 0; border-radius: 11px; }
  .topbar .btn.icon { width: 38px; }

  /* 16px — чтобы iOS не зумил страницу при фокусе */
  .input, .select, .textarea, .cell, .size-add { font-size: 16px; }
  .input { height: 44px; }
  .btn { height: 42px; }
  .btn.icon { width: 40px; height: 40px; }
  .segmented button { height: 36px; }

  .page-head { margin-bottom: 12px; }
  .meta-grid { grid-template-columns: 1fr 1fr; padding: 14px; gap: 10px; }
  .meta-grid > * { grid-column: auto !important; }
  .meta-grid .status-field, .meta-grid details.more { grid-column: 1 / -1 !important; }
  .meta-grid .status-field .segmented { display: flex; align-self: stretch; }
  .status-field .segmented button { flex: 1; padding: 0 4px; white-space: nowrap; font-size: 13px; }

  .ed-brand { border-radius: 16px; }
  .ed-brand-head { grid-template-columns: 1fr; padding: 12px; gap: 8px; }
  .brand-tools { justify-content: space-between; }
  .ed-brand-body { padding: 10px; gap: 10px; }
  .ed-model { padding: 10px; border-radius: 14px; }
  .ed-model-head { gap: 6px; margin-bottom: 10px; }
  .ed-model-head .model-name { flex: 1 1 calc(100% - 46px); max-width: none; order: 0; }
  .ed-model-head .segmented.kind { order: 1; }
  .ed-model-head .model-total { order: 2; margin-left: auto; }
  .ed-model-head > .btn:not(.collapse) { order: 3; }
  .ed-model.is-collapsed { padding: 6px 8px; }
  .sizes { gap: 6px; margin-bottom: 10px; }
  .size-chip { height: 34px; }
  .size-chip button { width: 28px; height: 28px; font-size: 16px; }
  .size-add { height: 34px; width: 110px; }
  .add-row { height: 50px; font-size: 15px; }
  .chip.sm { height: 36px; padding: 0 12px; font-size: 14px; }

  .savebar-inner { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .savebar .sum { flex-direction: column; gap: 0; line-height: 1.3; font-size: 13px; }
  .savebar .sum b { font-size: 15px; }
  .save-btn { height: 48px; padding: 0 28px; font-size: 16px; border-radius: 12px; }

  .toasts { left: 12px; right: 12px; bottom: calc(88px + env(safe-area-inset-bottom)); align-items: center; pointer-events: none; }
  .toast { max-width: 100%; padding: 8px 14px; font-size: 14px; border-radius: 999px; animation: drop .2s ease-out; }

  .brand-head { flex-direction: column; align-items: flex-start; padding: 12px 14px; }
  .brand-body { padding: 12px; }
  .page-head > .row { width: 100%; }
  .page-head > .row .btn.primary { flex: 1; }
}

/* ============================================================
   Справочник ИП в редакторе
   ============================================================ */
.select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7180' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.brand-fixed { display: flex; align-items: center; background: var(--surface-2); font-weight: 600; cursor: default; }
.brand-fixed.muted { font-weight: 400; }

/* ============================================================
   Акт приёма-передачи — лист A4
   ============================================================ */
.act-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.act-toolbar .back { margin-bottom: 0; }
.act-hint { flex-basis: 100%; font-size: 12px; }
.act-stage { overflow: hidden; }
.act-scale { display: flex; flex-direction: column; align-items: center; gap: 20px; }

.act-page {
  width: 210mm; min-height: 297mm; padding: 16mm 14mm 14mm; box-sizing: border-box;
  background: #fff; color: #111; box-shadow: 0 2px 20px rgba(0, 0, 0, .18); border-radius: 2px;
  font: 10.5pt/1.4 Inter, Arial, sans-serif; display: flex; flex-direction: column;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.act-top { display: flex; justify-content: space-between; font-size: 9pt; color: #555; }
.act-title { text-align: center; font-size: 15pt; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin: 8mm 0 1mm; }
.act-sub { text-align: center; color: #333; margin-bottom: 7mm; }
.act-parties { border-collapse: collapse; margin-bottom: 4mm; width: 100%; }
.act-parties td { padding: 1.2mm 0; vertical-align: top; }
.act-parties td.k { width: 32mm; font-weight: 600; }
.act-parties .blank { display: inline-block; width: 80mm; border-bottom: 1px solid #111; }
.act-text { margin: 3mm 0; }
.act-h3 { font-size: 10.5pt; font-weight: 700; margin: 4mm 0 2mm; }
.act-table { width: 100%; border-collapse: collapse; font-size: 9.5pt; font-variant-numeric: tabular-nums; }
.act-table th, .act-table td { border: 1px solid #333; padding: 1.4mm 1.8mm; vertical-align: middle; }
.act-table thead th { background: #eee; font-weight: 700; text-align: left; }
.act-table tfoot td { background: #f4f4f4; }
.act-table .c { text-align: center; }
.act-table .r { text-align: right; }
.act-table .b { font-weight: 700; }
.act-table .sz { width: 11mm; }
.act-table .model { font-weight: 600; }
.act-table .art { color: #555; font-size: 8.5pt; }
.act-table tr { break-inside: avoid; }
.act-total { margin: 4mm 0 1mm; display: flex; flex-direction: column; gap: 1mm; }
.act-signs { display: grid; grid-template-columns: 1fr 1fr; gap: 14mm; margin-top: auto; padding-top: 12mm; break-inside: avoid; }
.act-sign .role { font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.act-sign .who { min-height: 5mm; margin: 1mm 0 9mm; color: #333; }
.act-sign .lines { display: flex; align-items: flex-end; gap: 2mm; }
.act-sign .line { flex: 1; border-bottom: 1px solid #111; height: 1px; }
.act-sign .line.wide { flex: 1.6; }
.act-sign .hints { display: flex; justify-content: space-between; font-size: 8pt; color: #666; padding: 0.5mm 6mm 0 6mm; }
.act-sign .date { margin-top: 7mm; }

@page { size: A4; margin: 0; }
@media print {
  html, body { background: #fff !important; }
  .container { max-width: none; padding: 0; margin: 0; }
  .act-stage { overflow: visible; }
  .act-scale { zoom: 1 !important; display: block; }
  .act-page { box-shadow: none; border-radius: 0; break-after: page; margin: 0; min-height: 296mm; }
  .act-page:last-child { break-after: auto; }
  .toasts { display: none; }
}

/* ============================================================
   Настройки: аккаунт, пользователи, юрлица
   ============================================================ */
.user-btn svg { width: 18px; height: 18px; }
.edited { font-size: 13px; }
.small { font-size: 12.5px; }
.settings-tabs { margin-bottom: 16px; }
.settings-tabs a {
  display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: 8px;
  color: var(--muted); font-weight: 500; font-size: 14px;
}
.settings-tabs a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.settings-card { padding: 20px; display: flex; flex-direction: column; gap: 16px; max-width: 560px; }
.profile { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 22px;
}
.avatar.sm { width: 38px; height: 38px; font-size: 16px; }
.settings-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.settings-list { display: flex; flex-direction: column; gap: 8px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.list-title { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.list-actions { display: flex; gap: 2px; flex: none; }
.dialog-fields { display: flex; flex-direction: column; gap: 12px; }
.input-with-btn { display: flex; gap: 6px; }
.input-with-btn .btn { flex: none; height: 38px; }
.sheet .error { color: var(--red); font-size: 13px; min-height: 0; }

@media (max-width: 700px) {
  .settings-tabs { display: flex; }
  .settings-tabs a { flex: 1; justify-content: center; height: 36px; padding: 0 6px; }
  .list-row { flex-wrap: wrap; padding: 12px; }
  .list-row .badge { order: 3; }
  .list-actions { order: 4; margin-left: auto; }
  .input-with-btn .btn { height: 44px; width: 44px; padding: 0; }
  .settings-head .btn.primary { flex: 1; }
}

/* ============================================================
   Доступ пользователей к юрлицам
   ============================================================ */
.sheet { max-height: 92vh; overflow-y: auto; }
.access-field[hidden] { display: none; }
.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 10px; font-size: 14px; color: var(--text);
}
.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.radio input, .check input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; flex: none; }
.access-list {
  display: flex; flex-direction: column; max-height: 260px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 12px; transition: opacity .15s;
}
.access-list.disabled { opacity: .4; pointer-events: none; }
.check { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.check:last-child { border-bottom: 0; }
.check:has(input:checked) { background: var(--accent-soft); }
.check span { display: flex; flex-direction: column; color: var(--text); font-size: 14px; }
.check b { font-weight: 600; }
.check small { color: var(--muted); font-size: 12px; }
.access-hint { line-height: 1.4; }
.access-sum { color: var(--muted); }
.access-sum.warn { color: var(--red); }
@media (max-width: 700px) {
  .radio { flex: 1; justify-content: center; height: 42px; }
  .check { padding: 12px; }
  .access-list { max-height: 40vh; }
}
