/* PS ERP — компактная дизайн-система. Без сборки, чистый CSS. */
:root {
    --bg: #f4f5f7;
    --panel: #ffffff;
    --panel-2: #f9fafb;
    --line: #e5e7eb;
    --line-2: #eef0f3;
    --text: #111827;
    --text-2: #374151;
    --muted: #6b7280;
    --faint: #9ca3af;
    --primary: #2563eb;
    --primary-600: #1d4ed8;
    --primary-50: #eff4ff;
    --primary-100: #dbe6fe;
    --green: #059669; --green-50: #ecfdf5;
    --amber: #d97706; --amber-50: #fffbeb;
    --red: #dc2626; --red-50: #fef2f2;
    --violet: #7c3aed; --violet-50: #f5f3ff;
    --cyan: #0891b2; --cyan-50: #ecfeff;
    --gray-50: #f3f4f6;
    --side: #0f172a;
    --side-2: #1e293b;
    --side-text: #cbd5e1;
    --side-muted: #64748b;
    --radius: 6px;
    --radius-lg: 9px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .22), 0 2px 6px rgba(16, 24, 40, .06);
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
    --side-w: 188px;
    --top-h: 46px;
    color-scheme: light;
}
[data-theme="dark"] {
    --bg: #0b0f17;
    --panel: #121826;
    --panel-2: #161d2c;
    --line: #232c3d;
    --line-2: #1c2433;
    --text: #e5e7eb;
    --text-2: #cbd5e1;
    --muted: #94a3b8;
    --faint: #64748b;
    --primary: #4f8bff;
    --primary-600: #3b7bff;
    --primary-50: #15213b;
    --primary-100: #1c2c4f;
    --green-50: #0c2a22; --amber-50: #2c2110; --red-50: #2d1416; --violet-50: #221a3a; --cyan-50: #0c2830;
    --gray-50: #1a2232;
    --side: #080b12;
    --side-2: #141b29;
    --shadow: none;
    --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, .6);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 13px; line-height: 1.45; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01", "tnum"; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 18px; } h2 { font-size: 15px; } h3 { font-size: 13.5px; } h4 { font-size: 12px; }
p { margin: 0 0 8px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
img { max-width: 100%; }
[x-cloak] { display: none !important; }
::selection { background: var(--primary-100); }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -.01em; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.small { font-size: 12px; } .xs { font-size: 11px; }
.b { font-weight: 600; } .nowrap { white-space: nowrap; } .right { text-align: right; } .center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.green { color: var(--green); } .red { color: var(--red); } .amber { color: var(--amber); }

/* ── Каркас ─────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.app.collapsed { --side-w: 56px; }
.side { position: sticky; top: 0; height: 100vh; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; overflow: hidden; z-index: 30; }
.side-brand { height: var(--top-h); display: flex; align-items: center; gap: 9px; padding: 0 14px; color: #fff; font-weight: 700; letter-spacing: .02em; border-bottom: 1px solid rgba(255,255,255,.06); flex-shrink: 0; }
.side-brand .logo { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, #3b82f6, #6366f1); display: grid; place-items: center; font-size: 11px; flex-shrink: 0; }
.side-brand .name { white-space: nowrap; font-size: 13.5px; }
.side-brand .name small { display: block; color: var(--side-muted); font-weight: 500; font-size: 10.5px; letter-spacing: 0; }
.side-nav { flex: 1; overflow-y: auto; padding: 10px 8px 16px; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; scrollbar-color: #334155 transparent; }
.side-group { margin-top: 12px; }
.side-group-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--side-muted); padding: 0 8px 4px; white-space: nowrap; }
.side-link { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 8px; border-radius: 6px; color: var(--side-text); font-size: 13px; white-space: nowrap; position: relative; }
.side-link:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.side-link.active { background: rgba(59, 130, 246, .16); color: #fff; }
.side-link.active::before { content: ""; position: absolute; left: -8px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: #3b82f6; }
.side-link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .85; }
.side-link .count { margin-left: auto; background: #3b82f6; color: #fff; border-radius: 9px; font-size: 10.5px; padding: 0 6px; line-height: 17px; font-weight: 600; }
.side-foot { border-top: 1px solid rgba(255,255,255,.06); padding: 8px; }
.app.collapsed .side-group-title, .app.collapsed .side-link span, .app.collapsed .side-brand .name, .app.collapsed .side-link .count { display: none; }
.app.collapsed .side-link { justify-content: center; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; height: var(--top-h); background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; padding: 0 14px; }
.top-search { position: relative; flex: 0 1 440px; }
.top-search input { padding-left: 30px; background: var(--panel-2); height: 30px; }
.top-search > svg { position: absolute; left: 9px; top: 8px; width: 14px; height: 14px; color: var(--faint); }
.top-search kbd { position: absolute; right: 7px; top: 6px; }
.top-spacer { flex: 1; }
.page { padding: 14px 16px 40px; max-width: 1680px; width: 100%; }
.page-wide { max-width: none; }
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; min-height: 32px; flex-wrap: wrap; }
.page-head h1 { display: flex; align-items: center; gap: 8px; }
.page-head .sub { color: var(--muted); font-size: 12.5px; }
.page-head .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); }
.crumbs svg { width: 12px; height: 12px; }

/* Вкладки раздела */
.section-tabs { display: flex; gap: 2px; margin: -4px 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.section-tabs a { padding: 6px 11px 8px; color: var(--muted); font-weight: 500; font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.section-tabs a:hover { color: var(--text); }
.section-tabs a.on { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Кнопки ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); color: var(--text-2); font: inherit; font-weight: 500; font-size: 12.5px; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, color .12s, box-shadow .12s; box-shadow: var(--shadow); text-decoration: none !important; user-select: none; }
.btn:hover { background: var(--panel-2); border-color: #d1d5db; color: var(--text); }
.btn:focus-visible { outline: 2px solid var(--primary-100); outline-offset: 1px; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-50); border-color: #fecaca; color: var(--red); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(.95); color: #fff; background: var(--green); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--gray-50); border-color: transparent; }
.btn-sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn-xs { height: 22px; padding: 0 6px; font-size: 11.5px; gap: 4px; }
.btn-xs svg { width: 13px; height: 13px; }
.btn-icon { width: 30px; padding: 0; }
.btn-sm.btn-icon { width: 26px; } .btn-xs.btn-icon { width: 22px; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group .btn.on { background: var(--primary-50); color: var(--primary); border-color: var(--primary-100); z-index: 1; }

/* ── Поля ───────────────────────────────────────────────── */
.input, .select, textarea.input { width: 100%; height: 30px; padding: 0 9px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); font: inherit; font-size: 13px; transition: border-color .12s, box-shadow .12s; }
textarea.input { height: auto; min-height: 64px; padding: 6px 9px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.input::placeholder { color: var(--faint); }
.input-sm { height: 26px; font-size: 12.5px; }
.select { appearance: none; padding-right: 26px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }
.input.error, .select.error { border-color: var(--red); }
.err { color: var(--red); font-size: 11.5px; margin-top: 3px; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.check input { width: 15px; height: 15px; accent-color: var(--primary); margin: 0; }
.input-group { display: flex; }
.input-group > .input, .input-group > .select { border-radius: var(--radius) 0 0 var(--radius); }
.input-group > .btn { border-radius: 0 var(--radius) var(--radius) 0; margin-left: -1px; box-shadow: none; }
.input-addon { position: relative; }
.input-addon > svg { position: absolute; left: 9px; top: 8px; width: 14px; height: 14px; color: var(--faint); pointer-events: none; }
.input-addon > svg + .input { padding-left: 29px; }
.input-addon .suffix ~ .input, .input-addon > .input:has(+ .suffix) { padding-right: 62px; }
.input-addon .suffix { position: absolute; right: 9px; top: 6px; color: var(--faint); font-size: 12px; pointer-events: none; }

/* Форма «подпись слева — поле справа» как в карточке */
.form-rows { display: grid; gap: 6px; }
.frow { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 10px; }
.frow > label { color: var(--muted); font-size: 12.5px; }
.frow.ta { align-items: start; } .frow.ta > label { padding-top: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 10px 12px; }
.f { display: flex; flex-direction: column; gap: 4px; grid-column: span 12; min-width: 0; }
.f > label { font-size: 12px; color: var(--muted); font-weight: 500; }
.f.s2 { grid-column: span 2; } .f.s3 { grid-column: span 3; } .f.s4 { grid-column: span 4; } .f.s5 { grid-column: span 5; } .f.s6 { grid-column: span 6; } .f.s8 { grid-column: span 8; } .f.s9 { grid-column: span 9; }
.hint { font-size: 11.5px; color: var(--faint); }

/* ── Карточки ───────────────────────────────────────────── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line); min-height: 40px; }
.card-h h2, .card-h h3 { display: flex; align-items: center; gap: 7px; }
.card-h h3 svg { width: 15px; height: 15px; color: var(--muted); }
.card-h .actions { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.card-b { padding: 12px; }
.card-b.tight { padding: 8px 10px; }
.card-f { padding: 9px 12px; border-top: 1px solid var(--line); display: flex; gap: 6px; justify-content: flex-end; background: var(--panel-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } .g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; align-items: start; }
.split-l { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 12px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* KPI */
.kpi { padding: 11px 13px; display: flex; flex-direction: column; gap: 3px; position: relative; overflow: hidden; }
.kpi .label { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .label svg { width: 14px; height: 14px; }
.kpi .value { font-size: 20px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 11.5px; color: var(--muted); }
.kpi .bar { height: 4px; border-radius: 3px; background: var(--gray-50); overflow: hidden; margin-top: 4px; }
.kpi .bar > i { display: block; height: 100%; background: var(--primary); border-radius: 3px; }

/* ── Таблицы ────────────────────────────────────────────── */
.table-wrap { overflow: auto; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.8px; }
.table th { position: sticky; top: 0; z-index: 1; background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 11.3px; text-transform: uppercase; letter-spacing: .035em; text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th .sort { display: inline-block; width: 10px; color: var(--primary); }
.table td { padding: 6px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr { transition: background .08s; }
.table tbody tr:hover td { background: var(--panel-2); }
.table tbody tr.selected td { background: var(--primary-50); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { padding: 7px 10px; border-top: 1px solid var(--line); font-weight: 600; background: var(--panel-2); }
.table .cb { width: 30px; padding-right: 0; }
.table .acts { width: 1%; white-space: nowrap; text-align: right; }
.table .acts .btn { opacity: .55; }
.table tr:hover .acts .btn { opacity: 1; }
.table .title-cell { display: flex; align-items: center; gap: 9px; min-width: 220px; }
.table .title-cell .t { font-weight: 550; color: var(--text); }
.table .title-cell .s { font-size: 11.5px; color: var(--muted); }
.table input.input { height: 26px; }
.thumb { width: 34px; height: 34px; border-radius: 5px; object-fit: cover; background: var(--gray-50); flex-shrink: 0; display: grid; place-items: center; color: var(--faint); border: 1px solid var(--line-2); }
.thumb svg { width: 16px; height: 16px; }
.thumb-lg { width: 46px; height: 46px; }

.toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar .input, .toolbar .select { height: 28px; font-size: 12.5px; }
.toolbar .search { width: 260px; }
.toolbar .select { width: auto; min-width: 130px; }
.bulkbar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--primary-50); border-bottom: 1px solid var(--primary-100); font-size: 12.5px; }
.pager { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.pager .links { margin-left: auto; display: flex; gap: 3px; }
.pager .links .btn { min-width: 26px; }
.pager .links .btn.on { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Бейджи / чипы ─────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 11.3px; font-weight: 600; background: var(--gray-50); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }
.badge.plain::before { display: none; }
.badge.blue { background: var(--primary-50); color: var(--primary); }
.badge.green { background: var(--green-50); color: var(--green); }
.badge.amber { background: var(--amber-50); color: var(--amber); }
.badge.red { background: var(--red-50); color: var(--red); }
.badge.violet { background: var(--violet-50); color: var(--violet); }
.badge.cyan { background: var(--cyan-50); color: var(--cyan); }
.badge.gray { background: var(--gray-50); color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border: 1px solid var(--line); border-radius: 11px; font-size: 11.8px; color: var(--text-2); background: var(--panel); }
.chip svg { width: 12px; height: 12px; color: var(--muted); }
/* Место хранения: цветная точка склада, название, ниже — ряд и секция */
.loc { display: inline-flex; align-items: center; gap: 7px; max-width: 200px; min-width: 0; vertical-align: middle; line-height: 1.25; }
.loc > i { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 0 2px var(--panel); }
.loc-t { display: flex; flex-direction: column; min-width: 0; }
.loc-n { font-size: 12.5px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loc-s { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.tag-loc { display: inline-flex; gap: 0; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; font-size: 11.5px; font-weight: 600; }
.tag-loc span { padding: 1px 6px; background: var(--panel-2); border-left: 1px solid var(--line); }
.tag-loc span:first-child { border-left: 0; color: #fff; }
kbd { font-family: var(--mono); font-size: 10.5px; padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--panel); color: var(--muted); }

/* ── Табы ───────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 10px; overflow-x: auto; }
.tab { padding: 9px 10px 8px; font-size: 12.8px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 6px; font-weight: 500; background: none; border-top: 0; border-left: 0; border-right: 0; font-family: inherit; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.on { color: var(--primary); border-bottom-color: var(--primary); }
.tab .n { font-size: 10.5px; background: var(--gray-50); color: var(--muted); border-radius: 8px; padding: 0 5px; }
.seg { display: inline-flex; background: var(--gray-50); border-radius: 7px; padding: 2px; gap: 2px; }
.seg button, .seg a { border: 0; background: transparent; padding: 0 10px; height: 24px; border-radius: 5px; font: inherit; font-size: 12px; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 5px; font-weight: 500; }
.seg button.on, .seg a.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg svg { width: 14px; height: 14px; }

/* ── Описания (ключ — значение) ─────────────────────────── */
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 0; font-size: 12.8px; }
.dl > dt { color: var(--muted); padding: 5px 0; border-bottom: 1px dashed var(--line-2); }
.dl > dd { margin: 0; padding: 5px 0; border-bottom: 1px dashed var(--line-2); font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.dl > dt:nth-last-child(2), .dl > dd:last-child { border-bottom: 0; }

/* ── Выпадающие меню / модалки / дроверы ────────────────── */
.dropdown { position: relative; display: inline-block; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); min-width: 190px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 4px; z-index: 50; }
.menu.left { left: 0; right: auto; }
.menu.up { top: auto; bottom: calc(100% + 4px); }
.menu a, .menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border-radius: 5px; border: 0; background: none; font: inherit; font-size: 12.8px; color: var(--text-2); cursor: pointer; text-align: left; text-decoration: none; white-space: nowrap; }
.menu a:hover, .menu button:hover { background: var(--gray-50); color: var(--text); text-decoration: none; }
.menu svg { width: 15px; height: 15px; color: var(--muted); }
.menu .sep { height: 1px; background: var(--line); margin: 4px 0; }
.menu .menu-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 6px 8px 3px; }
.menu .danger { color: var(--red); } .menu .danger svg { color: var(--red); }

.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .38); z-index: 60; backdrop-filter: blur(1.5px); }
.modal { position: fixed; z-index: 61; left: 50%; top: 8vh; transform: translateX(-50%); width: min(560px, calc(100vw - 24px)); max-height: 84vh; display: flex; flex-direction: column; background: var(--panel); border-radius: 10px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.modal.lg { width: min(860px, calc(100vw - 24px)); }
.modal.xl { width: min(1100px, calc(100vw - 24px)); }
.modal.sm { width: min(400px, calc(100vw - 24px)); }
.modal-h { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.modal-h h2 { font-size: 14px; }
.modal-h .x { margin-left: auto; }
.modal-b { padding: 14px; overflow: auto; }
.modal-f { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; gap: 6px; justify-content: flex-end; background: var(--panel-2); border-radius: 0 0 10px 10px; }
.drawer { position: fixed; z-index: 61; right: 0; top: 0; bottom: 0; width: min(560px, 100vw); background: var(--panel); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; border-left: 1px solid var(--line); animation: slidein .16s ease-out; }
.drawer.lg { width: min(780px, 100vw); }
@keyframes slidein { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer .modal-b { flex: 1; }
.drawer .modal-f { border-radius: 0; }

/* ── Тосты ──────────────────────────────────────────────── */
.toasts { position: fixed; right: 14px; bottom: 14px; z-index: 90; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; min-width: 260px; max-width: 380px; background: #111827; color: #f9fafb; padding: 9px 12px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 12.8px; display: flex; gap: 9px; align-items: flex-start; animation: toastin .18s ease-out; }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.toast.success svg { color: #34d399; } .toast.error svg { color: #f87171; } .toast.info svg { color: #60a5fa; }
@keyframes toastin { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Прочее ─────────────────────────────────────────────── */
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty svg { width: 30px; height: 30px; color: var(--faint); margin-bottom: 6px; }
.empty .t { font-weight: 600; color: var(--text-2); margin-bottom: 2px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, #60a5fa, #6366f1); color: #fff; display: inline-grid; place-items: center; font-size: 11px; font-weight: 600; flex-shrink: 0; overflow: hidden; position: relative; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 22px; height: 22px; font-size: 9.5px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar.xl { width: 96px; height: 96px; font-size: 32px; }
.avatar .dot, .online-dot { position: absolute; right: 0; bottom: 0; width: 8px; height: 8px; border-radius: 50%; background: #22c55e; border: 2px solid var(--panel); }
.progress { height: 6px; border-radius: 4px; background: var(--gray-50); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); }
.progress.amber > i { background: var(--amber); } .progress.red > i { background: var(--red); } .progress.green > i { background: var(--green); }
.loader { width: 14px; height: 14px; border: 2px solid var(--primary-100); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-bar { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 100; background: linear-gradient(90deg, transparent, var(--primary), transparent); background-size: 50% 100%; animation: lb 1s linear infinite; }
@keyframes lb { from { background-position: -50% 0; } to { background-position: 150% 0; } }
[wire\:loading], [wire\:loading\.delay] { display: none; }
.icon { width: 16px; height: 16px; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; margin: 4px 0 6px; }
.notice { padding: 9px 11px; border-radius: 7px; background: var(--primary-50); color: var(--text-2); font-size: 12.5px; display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--primary-100); }
.notice svg { width: 16px; height: 16px; color: var(--primary); flex-shrink: 0; margin-top: 1px; }
.notice.amber { background: var(--amber-50); border-color: #fde68a; } .notice.amber svg { color: var(--amber); }
.notice.red { background: var(--red-50); border-color: #fecaca; } .notice.red svg { color: var(--red); }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line-2); color: var(--text); text-decoration: none !important; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover, button.list-item:hover { background: var(--panel-2); }
.list-item .meta { margin-left: auto; text-align: right; font-size: 12px; color: var(--muted); }
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 1px; background: var(--line); }
.tl { position: relative; padding: 0 0 12px; font-size: 12.5px; }
.tl::before { content: ""; position: absolute; left: -17px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--panel); border: 2px solid var(--primary); }
.tl.green::before { border-color: var(--green); } .tl.amber::before { border-color: var(--amber); } .tl.red::before { border-color: var(--red); }
.tl .when { font-size: 11px; color: var(--faint); }

/* Галерея фото */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.gallery .ph { position: relative; aspect-ratio: 4/3; border-radius: 6px; overflow: hidden; background: var(--gray-50); border: 1px solid var(--line); cursor: zoom-in; }
.gallery .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .ph .del { position: absolute; top: 3px; right: 3px; opacity: 0; transition: opacity .1s; }
.gallery .ph:hover .del { opacity: 1; }
.gallery.sortable .ph[draggable="true"] { cursor: grab; }
.gallery .ph.drop-over { outline: 2px solid var(--primary); outline-offset: -2px; }
@media (hover: none) { .gallery .ph .del { opacity: 1; } }
/* Фото имущества: главное крупно, остальные плиткой; порядок перетаскиванием */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; align-items: start; }
/* главное фото — на всю ширину, остальные плиткой под ним */
.pgrid:not(.plain) .pt:first-child { grid-column: 1 / -1; }
/* высоту задаёт ::before (4:3 от ширины) — работает во всех браузерах, включая Safari,
   где aspect-ratio у растянутых ячеек сетки схлопывается в полоску */
.pt { position: relative; border-radius: 8px; overflow: hidden; background: var(--gray-50); border: 1px solid var(--line); min-width: 0; transition: transform .12s, box-shadow .12s, opacity .12s; }
.pt::before { content: ""; display: block; padding-top: 75%; }
.pt img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; -webkit-user-drag: none; }
.pt[draggable="true"] { cursor: grab; }
.pt[draggable="true"]:active { cursor: grabbing; }
.pt.dragging { opacity: .35; }
.pt.drop-over { box-shadow: 0 0 0 3px var(--primary); transform: scale(.97); }
.pt .pt-main { position: absolute; left: 6px; top: 6px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 4px; display: flex; align-items: center; gap: 3px; }
.pt .pt-main svg { width: 11px; height: 11px; fill: currentColor; }
.pt .pt-num { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; font-weight: 600; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; display: grid; place-items: center; }
.pt .pt-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 3px; padding: 14px 4px 5px; background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.pt .pt-bar button { width: 24px; height: 24px; flex: 0 0 auto; border-radius: 6px; border: 0; background: rgba(255,255,255,.92); color: #111; display: grid; place-items: center; cursor: pointer; padding: 0; }
.pt .pt-bar button:hover { background: #fff; }
.pt .pt-bar button.danger { color: var(--red); }
.pt .pt-bar button svg { width: 14px; height: 14px; }
.pgrid-hint { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.pgrid-hint svg { width: 13px; height: 13px; }
@media (max-width: 640px) { .pgrid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); } }
.gallery .ph.main::after { content: "Главное"; position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 10px; padding: 1px 5px; border-radius: 3px; }
.dropzone { border: 1.5px dashed var(--line); border-radius: 8px; padding: 14px; text-align: center; color: var(--muted); font-size: 12.5px; cursor: pointer; transition: border-color .12s, background .12s; display: block; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.dropzone svg { width: 20px; height: 20px; display: block; margin: 0 auto 4px; }
.lightbox { position: fixed; inset: 0; z-index: 95; background: rgba(0,0,0,.88); display: flex; align-items: center; justify-content: center; }
.lightbox img, .lightbox video { max-width: 92vw; max-height: 88vh; border-radius: 6px; }
.lightbox .btn { position: absolute; }

/* Карта склада */
.wh-map { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.wh-row { flex: 0 0 auto; min-width: 128px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.wh-row-h { display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 12px; padding: 2px 4px 6px; }
.wh-cells { display: grid; gap: 4px; }
.wh-cell { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); padding: 5px 7px; cursor: pointer; text-align: left; font: inherit; font-size: 12px; color: var(--text); display: flex; flex-direction: column; gap: 2px; transition: border-color .1s, box-shadow .1s; min-height: 46px; }
.wh-cell:hover { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-100); }
.wh-cell.on { border-color: var(--primary); background: var(--primary-50); }
.wh-cell .n { font-weight: 600; display: flex; justify-content: space-between; }
.wh-cell .bar { height: 3px; border-radius: 2px; background: var(--gray-50); overflow: hidden; }
.wh-cell .bar i { display: block; height: 100%; background: var(--green); }
.wh-cell.busy .bar i { background: var(--amber); } .wh-cell.full .bar i { background: var(--red); }

/* Мессенджер */
/* ── Мессенджер ── */
.mx { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: calc(100vh - var(--top-h) - 104px); min-height: 480px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; position: relative; }
.mx-single { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 52px - 50px); }
.mx-list { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; background: var(--panel); }
.mx-list-h { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line-2); }
.mx-list-h .input { height: 32px; background: var(--panel-2); }
.mx-list-h .btn-icon { width: 32px; height: 32px; border-radius: 8px; }
.mx-convs { flex: 1; overflow-y: auto; }
.mx-list-f { padding: 6px 12px; border-top: 1px solid var(--line-2); text-align: center; }
.mx-conv { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; border: 0; background: none; font: inherit; color: var(--text); text-align: left; cursor: pointer; border-radius: 0; }
.mx-conv:hover { background: var(--panel-2); }
.mx-conv.on { background: var(--primary-50); }
.mx-conv-b { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.mx-conv-r1, .mx-conv-r2 { display: flex; align-items: center; gap: 6px; min-width: 0; }
.mx-conv-t { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.mx-conv-time { font-size: 11px; color: var(--faint); flex-shrink: 0; }
.mx-conv.unread .mx-conv-time { color: var(--primary); font-weight: 600; }
.mx-conv-p { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.mx-conv-p b { font-weight: 500; color: var(--text-2); }
.mx-pin svg { width: 12px; height: 12px; color: var(--faint); }
.mx-badge { background: var(--primary); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; min-width: 19px; height: 19px; line-height: 19px; padding: 0 6px; text-align: center; flex-shrink: 0; }
.mx-badge.dot { min-width: 10px; width: 10px; height: 10px; padding: 0; }
.mx-ava { width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; color: #fff; font-weight: 650; font-size: 14px; background: linear-gradient(135deg, #818cf8, #4f46e5); position: relative; overflow: visible; }
.mx-ava img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.mx-ava svg { width: 19px; height: 19px; }
.mx-ava.t-partner { background: linear-gradient(135deg, #34d399, #059669); }
.mx-ava.t-group { background: linear-gradient(135deg, #fbbf24, #ef4444); }
.mx-ava.sm { width: 36px; height: 36px; font-size: 12.5px; }
.mx-ava.ghost { visibility: hidden; }
.mx-ava.xs { width: 28px; height: 28px; font-size: 10.5px; align-self: flex-end; margin-bottom: 2px; }
.mx-online { position: absolute; right: 0; bottom: 1px; width: 11px; height: 11px; border-radius: 50%; background: #22c55e; border: 2px solid var(--panel); }

.mx-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; background: var(--bg); }
.mx-empty-pane { align-items: center; justify-content: center; }
.mx-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; min-height: 54px; background: var(--panel); border-bottom: 1px solid var(--line); }
.mx-head-t { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.mx-head-t b { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx-head-t span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx-typing-t { color: var(--primary); }
.mx-back { display: none; }
.mx-selbar { background: var(--primary-50); }
.mx-pinned { display: flex; align-items: center; gap: 8px; padding: 7px 14px; background: var(--panel); border: 0; border-bottom: 1px solid var(--line); font: inherit; font-size: 12.5px; color: var(--text-2); cursor: pointer; text-align: left; }
.mx-pinned > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mx-pinned b { color: var(--primary); font-weight: 600; margin-right: 4px; }
.mx-pinned svg { width: 15px; height: 15px; color: var(--primary); flex-shrink: 0; }

.mx-box { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 20px 18px; display: flex; flex-direction: column; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    background-color: var(--bg); background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 22px 22px; }
.mx-box > div { flex-shrink: 0; }
.mx-loading { display: flex; justify-content: center; padding: 6px; }
.mx-day { display: flex; justify-content: center; margin: 16px 0 8px; position: sticky; top: 0; z-index: 2; }
.mx-day span { font-size: 11.5px; font-weight: 500; color: var(--text-2); background: color-mix(in srgb, var(--panel) 90%, transparent); border: 1px solid var(--line); padding: 2px 10px; border-radius: 12px; backdrop-filter: blur(6px); }
.mx-unread-sep { text-align: center; margin: 8px -14px; padding: 4px; background: var(--primary-50); color: var(--primary); font-size: 12px; font-weight: 600; }
.mx-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 12px; position: relative; border-radius: 8px; }
.mx-row.grp { margin-top: 5px; }
.mx-row.mine { flex-direction: row-reverse; }
.mx-row.picked { background: var(--primary-50); }
.mx-row.hl .mx-bub { animation: mxhl 1.6s ease; }
@keyframes mxhl { 0%, 40% { box-shadow: 0 0 0 3px var(--primary-100); } 100% { box-shadow: none; } }
.mx-check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex-shrink: 0; align-self: center; color: transparent; }
.mx-check svg { width: 13px; height: 13px; }
.mx-row.picked .mx-check { background: var(--primary); border-color: var(--primary); color: #fff; }
.mx-col { display: flex; flex-direction: column; max-width: min(72%, 560px); min-width: 0; }
.mx-row.mine .mx-col { align-items: flex-end; }
.mx-bub { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 8px 13px 8px; font-size: 14px; line-height: 1.45; min-width: 72px; max-width: 100%; box-shadow: 0 1px 1px rgba(16,24,40,.04); -webkit-touch-callout: none; user-select: text; }
.mx-row:not(.mine).last .mx-bub { border-bottom-left-radius: 4px; }
.mx-row.mine .mx-bub { background: #dbe8ff; border-color: #c7dafe; color: #0b1b3a; }
.mx-row.mine.last .mx-bub { border-bottom-right-radius: 4px; }
[data-theme="dark"] .mx-row.mine .mx-bub { background: #1e3a6e; border-color: #24467f; color: #e5edff; }
.mx-bub.imp { box-shadow: inset 3px 0 0 var(--red); }
.mx-bub.del { background: transparent !important; border-style: dashed; color: var(--muted) !important; }
.mx-bub.pend { opacity: .75; }
.mx-bub.fail { border-color: var(--red) !important; }
.mx-bub.img { padding: 3px; }
.mx-bub.img .mx-meta { position: absolute; right: 8px; bottom: 7px; background: rgba(0,0,0,.45); color: #fff; padding: 0 6px; border-radius: 9px; }
.mx-author { font-size: 12px; font-weight: 650; color: var(--primary); margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx-co { color: var(--muted); font-weight: 500; }
.mx-fwd { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.mx-fwd svg { width: 13px; height: 13px; }
.mx-fwd b { color: var(--primary); font-weight: 600; }
.mx-quote { border-left: 3px solid var(--primary); background: color-mix(in srgb, var(--primary) 9%, transparent); border-radius: 5px; padding: 3px 8px; margin: 2px 0 4px; font-size: 12.5px; cursor: pointer; display: flex; flex-direction: column; max-width: 100%; }
.mx-quote b { color: var(--primary); font-weight: 600; font-size: 12px; }
.mx-quote span { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx-deleted { font-style: italic; font-size: 13px; display: flex; align-items: center; gap: 5px; }
.mx-deleted svg { width: 13px; height: 13px; }
.mx-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.mx-text a { color: var(--primary); text-decoration: underline; }
.mx-meta { float: right; display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); margin: 8px 0 -2px 14px; line-height: 1; user-select: none; position: relative; top: 2px; }
.mx-meta svg { width: 11px; height: 11px; }
.mx-imp svg { color: var(--red); }
.mx-tick { font-size: 11px; letter-spacing: -2px; color: var(--faint); }
.mx-tick.read { color: var(--primary); }
.mx-retry { border: 0; background: none; color: var(--red); cursor: pointer; padding: 0; display: inline-flex; }
.mx-more { align-self: center; flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--muted); display: grid; place-items: center; cursor: pointer; padding: 0; opacity: 0; transition: opacity .12s; }
.mx-more svg { width: 15px; height: 15px; }
.mx-more:hover { color: var(--primary); border-color: var(--primary); }
.mx-row:hover .mx-more { opacity: 1; }
@media (hover: none) { .mx-more { opacity: .75; width: 30px; height: 30px; } }
.mx-img { display: block; border-radius: 11px; overflow: hidden; max-width: 320px; }
.mx-img img { display: block; width: 100%; max-height: 360px; object-fit: cover; }
.mx-file { display: flex; align-items: center; gap: 10px; text-decoration: none !important; color: inherit; padding: 3px 0; min-width: 200px; max-width: 320px; }
.mx-file-i { width: 40px; height: 40px; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; flex-shrink: 0; }
.mx-file-b { display: flex; flex-direction: column; min-width: 0; }
.mx-file-n { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.mx-file-s { font-size: 11.5px; color: var(--muted); }
.mx-voice { display: flex; align-items: center; gap: 9px; padding: 3px 0 2px; min-width: 220px; }
.mx-play { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.mx-play svg { width: 15px; height: 15px; }
.mx-play[disabled] { opacity: .5; }
.mx-wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 28px; cursor: pointer; min-width: 120px; }
.mx-wave i { flex: 1; max-width: 3px; min-width: 2px; border-radius: 2px; background: color-mix(in srgb, var(--primary) 35%, transparent); }
.mx-wave i.on { background: var(--primary); }
.mx-vdur { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 30px; }
.mx-rate { border: 0; background: var(--primary-100); color: var(--primary); font: inherit; font-size: 11px; font-weight: 700; border-radius: 8px; padding: 1px 6px; cursor: pointer; }
.mx-reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.mx-react { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font: inherit; font-size: 13px; cursor: pointer; }
.mx-react b { font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.mx-react.mine { background: var(--primary-50); border-color: var(--primary); }
.mx-react.mine b { color: var(--primary); }
.mx-typing { display: flex; gap: 4px; padding: 10px 12px; margin-top: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: fit-content; }
.mx-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: mxdot 1.2s infinite; }
.mx-typing span:nth-child(2) { animation-delay: .15s; } .mx-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes mxdot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.mx-down { position: absolute; right: 16px; bottom: 76px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow-lg); display: grid; place-items: center; cursor: pointer; color: var(--text-2); z-index: 3; }
.mx-down svg { width: 18px; height: 18px; }
.mx-down b { position: absolute; top: -6px; right: -4px; background: var(--primary); color: #fff; font-size: 10.5px; border-radius: 9px; min-width: 18px; height: 18px; line-height: 18px; text-align: center; padding: 0 4px; }
.mx-drop { position: absolute; inset: 60px 10px 70px; border: 2px dashed var(--primary); border-radius: 14px; background: color-mix(in srgb, var(--primary-50) 90%, transparent); display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--primary); font-weight: 600; z-index: 4; pointer-events: none; }
.mx-saved { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-top: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.mx-saved-t { font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }

.mx-compose { background: var(--panel); border-top: 1px solid var(--line); padding: 8px 10px; }
.mx-ctx { display: flex; align-items: center; gap: 8px; padding: 2px 2px 8px; color: var(--primary); }
.mx-ctx > span svg { width: 18px; height: 18px; }
.mx-ctx-b { flex: 1; min-width: 0; display: flex; flex-direction: column; border-left: 2px solid var(--primary); padding-left: 8px; font-size: 12.5px; }
.mx-ctx-b b { font-weight: 600; } .mx-ctx-b span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx-inrow, .mx-rec { display: flex; align-items: flex-end; gap: 6px; }
.mx-rec { align-items: center; }
.mx-input { flex: 1; min-height: 38px; max-height: 160px; resize: none; border: 1px solid var(--line); border-radius: 19px; padding: 9px 14px; font: inherit; font-size: 14px; line-height: 1.35; background: var(--panel-2); color: var(--text); outline: none; overflow-y: auto; }
.mx-input:focus { border-color: var(--primary); background: var(--panel); }
.mx-attach { width: 38px; height: 38px; color: var(--muted); }
.mx-attach svg { width: 20px; height: 20px; }
.mx-send, .mx-mic { width: 38px; height: 38px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.mx-send { background: var(--primary); color: #fff; }
.mx-mic { background: var(--gray-50); color: var(--text-2); }
.mx-mic:hover { color: var(--primary); }
.mx-send svg, .mx-mic svg { width: 18px; height: 18px; }
.mx-rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: mxblink 1s infinite; }
@keyframes mxblink { 50% { opacity: .2; } }
.mx-rec-t { font-variant-numeric: tabular-nums; min-width: 38px; }
.mx-rec-wave { flex: 1; display: flex; align-items: center; justify-content: flex-end; gap: 2px; height: 32px; overflow: hidden; }
.mx-rec-wave i { width: 3px; border-radius: 2px; background: var(--red); flex-shrink: 0; }

.mx-menu-wrap { position: fixed; inset: 0; z-index: 75; }
.mx-menu { position: fixed; width: 282px; display: flex; flex-direction: column; gap: 6px; }
.mx-emojis { display: flex; align-items: center; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 26px; padding: 4px 6px; box-shadow: var(--shadow-lg); }
.mx-emojis button { width: 31px; height: 34px; border: 0; background: none; font-size: 21px; cursor: pointer; border-radius: 50%; padding: 0; transition: transform .1s; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.mx-emojis button:hover { transform: scale(1.22); }
.mx-emojis button.on { background: var(--primary-100); }
.mx-emo-more { width: 30px !important; height: 30px !important; background: var(--gray-50) !important; display: grid; place-items: center; margin-left: auto; }
.mx-emo-more svg { width: 16px; height: 16px; color: var(--muted); }
.mx-emojis-all { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px; box-shadow: var(--shadow-lg); }
.mx-emojis-all button { height: 32px; border: 0; background: none; font-size: 20px; cursor: pointer; border-radius: 8px; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.mx-emojis-all button:hover { background: var(--gray-50); }
.mx-acts { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 5px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.mx-acts button, .mx-acts a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border: 0; background: none; border-radius: 8px; font: inherit; font-size: 13.5px; color: var(--text); cursor: pointer; text-align: left; text-decoration: none !important; }
.mx-acts button:hover, .mx-acts a:hover { background: var(--gray-50); }
.mx-acts svg { width: 17px; height: 17px; color: var(--text-2); }
.mx-acts .danger, .mx-acts .danger svg { color: var(--red); }
.mx-acts .sep { height: 1px; background: var(--line); margin: 4px 6px; }
.mx-toast { position: absolute; left: 50%; bottom: 80px; transform: translateX(-50%); background: rgba(17,24,39,.92); color: #fff; font-size: 13px; padding: 7px 14px; border-radius: 18px; z-index: 6; white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis; }

/* Диск */
.drive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; padding: 10px; }
.drive-tile { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--panel); display: flex; flex-direction: column; gap: 6px; cursor: pointer; position: relative; min-width: 0; }
.drive-tile:hover { border-color: var(--primary); }
.tile-sel { position: relative; min-width: 0; }
.tile-sel .tile-cb { position: absolute; top: 12px; left: 12px; z-index: 2; background: var(--panel); border-radius: 4px; padding: 3px; line-height: 0; box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,.15)); cursor: pointer; }
.tile-sel .tile-cb input { width: 18px; height: 18px; margin: 0; cursor: pointer; }
.tile-sel.on .drive-tile { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-100); }
.drive-tile .pv { aspect-ratio: 4/3; border-radius: 5px; background: var(--panel-2); display: grid; place-items: center; overflow: hidden; color: var(--faint); }
.drive-tile .pv img, .drive-tile .pv video { width: 100%; height: 100%; object-fit: cover; }
.drive-tile .pv svg { width: 30px; height: 30px; }
.drive-tile .nm { font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drive-tile .sz { font-size: 11px; color: var(--muted); }
.drive-tile .more { position: absolute; top: 4px; right: 4px; opacity: 0; }
.drive-tile:hover .more { opacity: 1; }

/* Календарь осмотров */
.cal { display: grid; grid-template-columns: 54px repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.cal-h { padding: 6px; font-size: 11.5px; font-weight: 600; text-align: center; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line-2); background: var(--panel-2); position: sticky; top: 0; }
.cal-h.today { color: var(--primary); }
.cal-t { font-size: 10.5px; color: var(--faint); text-align: right; padding: 2px 6px; border-bottom: 1px solid var(--line-2); height: 30px; }
.cal-c { border-left: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); height: 30px; position: relative; padding: 1px 2px; display: flex; gap: 2px; }
.cal-c.off { background: repeating-linear-gradient(45deg, transparent 0 5px, var(--line-2) 5px 6px); }
.cal-ev { flex: 1; min-width: 0; font-size: 10.8px; border-radius: 4px; padding: 1px 5px; background: var(--primary-50); color: var(--primary); border-left: 3px solid var(--primary); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; line-height: 1.35; }
.cal-ev.confirmed { background: var(--green-50); color: var(--green); border-color: var(--green); }
.cal-ev.done { background: var(--gray-50); color: var(--muted); border-color: var(--faint); }
.cal-ev.cancelled { background: var(--red-50); color: var(--red); border-color: var(--red); text-decoration: line-through; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 6px; }
.slot { height: 32px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--text); }
.slot:hover { border-color: var(--primary); color: var(--primary); }
.slot.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.slot[disabled] { opacity: .35; cursor: not-allowed; text-decoration: line-through; }
.days { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.day { flex: 0 0 64px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 4px; text-align: center; cursor: pointer; background: var(--panel); font: inherit; color: var(--text); }
.day .w { font-size: 10.5px; text-transform: uppercase; color: var(--muted); }
.day .d { font-size: 17px; font-weight: 650; }
.day .m { font-size: 10.5px; color: var(--muted); }
.day.on { border-color: var(--primary); background: var(--primary-50); }
.day[disabled] { opacity: .4; cursor: not-allowed; }

/* Редактор этикеток */
.lbl-editor { display: grid; grid-template-columns: 210px minmax(0, 1fr) 270px; gap: 12px; align-items: start; }
.lbl-stage { background: repeating-conic-gradient(var(--line-2) 0 25%, transparent 0 50%) 0 0 / 16px 16px; border-radius: 9px; padding: 28px; display: flex; justify-content: center; align-items: flex-start; min-height: 560px; overflow: auto; border: 1px solid var(--line); }
.lbl-canvas { position: relative; background: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.18); color: #000; flex-shrink: 0; }
.lbl-el { position: absolute; cursor: move; outline: 1px dashed transparent; overflow: hidden; color: #000; line-height: 1.12; user-select: none; }
.lbl-el:hover { outline-color: #93c5fd; }
.lbl-el.sel { outline: 1.5px solid #2563eb; overflow: visible; z-index: 5; }
.lbl-el .h { position: absolute; width: 9px; height: 9px; background: #fff; border: 1.5px solid #2563eb; border-radius: 2px; right: -5px; bottom: -5px; cursor: nwse-resize; display: none; }
.lbl-el.sel .h { display: block; }
.lbl-guide { position: absolute; background: #ec4899; pointer-events: none; z-index: 6; }
.palette button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); font: inherit; font-size: 12.5px; cursor: pointer; color: var(--text-2); margin-bottom: 5px; }
.palette button:hover { border-color: var(--primary); color: var(--primary); }
.palette button svg { width: 15px; height: 15px; }

/* Матрица прав */
.perm-list { display: flex; flex-direction: column; }
.perm-row { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 12px; align-items: center; padding: 7px 12px; border-bottom: 1px solid var(--line-2); }
.perm-row:hover { background: var(--panel-2); }
.perm-mod { display: flex; align-items: center; gap: 8px; cursor: pointer; min-width: 0; }
.perm-mod input { width: 15px; height: 15px; accent-color: var(--primary); margin: 0; flex-shrink: 0; }
.perm-ico { width: 24px; height: 24px; border-radius: 6px; background: var(--gray-50); color: var(--muted); display: grid; place-items: center; flex-shrink: 0; }
.perm-name { font-weight: 600; font-size: 12.8px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.perm-cnt { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; padding: 0 6px; border-radius: 8px; background: var(--gray-50); line-height: 17px; }
.perm-cnt.full { background: var(--green-50); color: var(--green); } .perm-cnt.part { background: var(--amber-50); color: var(--amber); }
.perm-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.pchip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px 0 7px; border: 1px solid var(--line); border-radius: 12px; font-size: 12px; color: var(--muted); background: var(--panel); cursor: pointer; user-select: none; transition: background .1s, border-color .1s, color .1s; white-space: nowrap; }
.pchip input { display: none; }
.pchip svg { width: 13px; height: 13px; opacity: .7; }
.pchip:hover { border-color: var(--primary); color: var(--text); }
.pchip.on { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary); font-weight: 500; }
.pchip.on svg { opacity: 1; }
.pchip.danger.on { background: var(--red-50); border-color: #fecaca; color: var(--red); }
.pchip.locked { cursor: default; }
@media (max-width: 900px) { .perm-row { grid-template-columns: 1fr; gap: 6px; } }

/* Авторизация */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: radial-gradient(1200px 600px at -10% -10%, #1e3a8a 0%, transparent 60%), radial-gradient(800px 500px at 110% 110%, #4c1d95 0%, transparent 55%), #0b1220; color: #e2e8f0; padding: 40px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h2 { font-size: 26px; color: #fff; line-height: 1.2; max-width: 420px; letter-spacing: -.02em; }
.auth-side ul { padding: 0; list-style: none; display: grid; gap: 10px; margin: 22px 0 0; color: #cbd5e1; }
.auth-side li { display: flex; gap: 10px; align-items: center; }
.auth-side li svg { width: 18px; height: 18px; color: #60a5fa; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 30px; background: var(--panel); }
.auth-box { width: 100%; max-width: 360px; }
.auth-box h1 { font-size: 21px; margin-bottom: 4px; }

/* Портал партнёра */
.portal-top { background: var(--panel); border-bottom: 1px solid var(--line); }
.portal-top .in { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 14px; height: 52px; padding: 0 16px; }
.portal-nav { display: flex; gap: 2px; }
.portal-nav a { padding: 7px 11px; border-radius: 6px; color: var(--muted); font-weight: 500; display: flex; gap: 6px; align-items: center; }
.portal-nav a svg { width: 15px; height: 15px; }
.portal-nav a:hover { background: var(--gray-50); color: var(--text); text-decoration: none; }
.portal-nav a.active { background: var(--primary-50); color: var(--primary); }
.portal-page { max-width: 1240px; margin: 0 auto; padding: 16px; }

/* Сканер штрихкодов */
html.no-scroll, html.no-scroll body { overflow: hidden; }
.scanner { position: fixed; inset: 0; z-index: 85; background: #05070c; color: #fff; display: flex; flex-direction: column; }
.scanner-top { display: flex; align-items: center; gap: 6px; padding: calc(6px + env(safe-area-inset-top)) 8px 6px; }
.scanner-top .btn-ghost { color: #fff; width: 40px; height: 40px; }
.scanner-top .btn-ghost:hover, .scanner-top .btn-ghost.on { background: rgba(255,255,255,.14); color: #fff; }
.scanner-top .btn svg { width: 20px; height: 20px; }
.scanner-top .t { flex: 1; font-weight: 600; font-size: 15px; display: flex; flex-direction: column; line-height: 1.25; }
.scanner-top .t small { font-weight: 500; font-size: 12px; color: #86efac; }
.scanner-stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; min-height: 0; }
#scanner-view { width: 100%; max-width: 640px; }
#scanner-view video { width: 100% !important; height: auto !important; display: block; border-radius: 0; }
#scanner-view #qr-shaded-region { border-color: rgba(0,0,0,.5) !important; }
.scanner-hint { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; font-size: 13px; color: rgba(255,255,255,.85); text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.scanner-flash { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: #16a34a; color: #fff; border-radius: 20px; padding: 6px 14px; font-weight: 600; font-size: 13px; display: flex; gap: 6px; align-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.scanner-flash svg { width: 16px; height: 16px; }
.scanner-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; color: rgba(255,255,255,.85); padding: 20px; }
.scanner-msg .btn:not(.btn-primary) { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.scanner-sheet { background: var(--panel); color: var(--text); border-radius: 16px 16px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); }
.scanner-sheet .input { height: 40px; font-size: 16px; }
.scanner-sheet .btn { height: 40px; }
.scanner-acts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.scanner-acts .btn-primary { grid-column: 1 / -1; }
@media (min-width: 901px) { .scanner { left: 50%; top: 50%; right: auto; bottom: auto; transform: translate(-50%, -50%); width: 520px; height: min(760px, 92vh); border-radius: 14px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.5); } .scanner-sheet { border-radius: 0; } }

/* Печать */
@media print {
    .side, .top, .no-print, .toasts, .tabbar { display: none !important; }
    .app { display: block; }
    body { background: #fff; }
}

/* Адаптив */
.doc-viewer-bg { background: var(--gray-50); padding: 14px; }
.m-card, .doc-mbar { display: none; }
.m-only, .tabbar, .side-sub, .side-backdrop, .top-title { display: none; }
.doc-tap { display: none; }
@media (max-width: 1200px) { .g5, .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .split, .split[style] { grid-template-columns: minmax(0, 1fr) !important; } .lbl-editor { grid-template-columns: minmax(0, 1fr); } }

/* ── Планшет и телефон ── */
@media (max-width: 900px) {
    :root { --tabbar-h: 56px; }
    html { -webkit-text-size-adjust: 100%; }
    body { font-size: 13.5px; }
    .m-only { display: inline-flex; }
    .d-only { display: none !important; }
    /* документ: миниатюра на всю ширину, нажатие — открыть целиком */
    .doc-viewer { position: relative; }
    .doc-tap { display: block; position: absolute; inset: 0; z-index: 2; }
    .doc-open { display: flex !important; width: 100%; justify-content: center; height: 46px; font-size: 15px; border-radius: 10px; margin-bottom: 10px; }

    /* Каркас: выезжающее меню + нижняя панель */
    .app { grid-template-columns: 1fr; }
    .side { position: fixed; left: 0; top: 0; bottom: 0; height: 100%; width: min(290px, 84vw); transform: translateX(-102%); transition: transform .2s ease; z-index: 70; box-shadow: none; }
    .app.mobile-open .side { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
    .side-backdrop { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(15, 23, 42, .45); }
    .side-foot { display: none; }
    .side-nav { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
    .app.collapsed .side-group-title, .app.collapsed .side-link span, .app.collapsed .side-brand .name { display: initial; }
    .app.collapsed .side-link { justify-content: flex-start; }
    .side-link { height: 38px; font-size: 14px; }
    .side-sub { display: flex; flex-direction: column; margin: 0 0 6px 34px; border-left: 1px solid rgba(255,255,255,.08); }
    .side-sub a { color: var(--side-muted); font-size: 13px; padding: 6px 10px; border-radius: 5px; text-decoration: none; }
    .side-sub a.on { color: #fff; background: rgba(255,255,255,.05); }

    .top { z-index: 45; padding: 0 6px 0 4px; gap: 2px; padding-top: env(safe-area-inset-top); height: calc(var(--top-h) + env(safe-area-inset-top)); }
    .top-title { display: block; font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; padding-left: 2px; }
    .top-spacer { display: none; }
    .top .btn-icon { width: 36px; height: 36px; }
    .top-create { width: 32px; height: 32px; padding: 0; border-radius: 9px; margin-right: 2px; }
    .top-create span { display: none; }
    .top-scan { color: var(--primary); }
    .btn-scan span { display: none; }
    .btn-scan { width: 40px; padding: 0; }
    .top-create svg { width: 17px; height: 17px; }
    .top-search { display: none; }
    .app.search-open .top-search { display: flex; align-items: center; position: absolute; left: 0; right: 0; bottom: 0; height: var(--top-h); padding: 0 6px 0 8px; background: var(--panel); z-index: 5; gap: 4px; }
    .app.search-open .top-search > svg { left: 18px; top: 50%; transform: translateY(-50%); }
    .app.search-open .top-search input { height: 34px; font-size: 16px; flex: 1; }
    .top-search kbd { display: none; }
    .top-search .menu { position: fixed; left: 6px; right: 6px; top: calc(var(--top-h) + env(safe-area-inset-top) + 2px); width: auto !important; max-height: calc(100vh - 140px) !important; }
    .top .menu { position: fixed; left: 8px; right: 8px; top: calc(var(--top-h) + env(safe-area-inset-top) + 4px); width: auto !important; max-height: calc(100vh - var(--top-h) - var(--tabbar-h) - 30px); overflow: auto; }
    .top .menu a, .top .menu button { padding: 10px 10px; font-size: 14px; }

    .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; top: auto; width: 100%; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -2px 10px rgba(16,24,40,.05); transform: translateZ(0); }
    .tabbar a, .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--tabbar-h); color: var(--faint); font: inherit; font-size: 10.5px; font-weight: 500; background: none; border: 0; text-decoration: none !important; cursor: pointer; -webkit-tap-highlight-color: transparent; }
    .tabbar svg { width: 21px; height: 21px; }
    .tabbar .on { color: var(--primary); }
    .page { padding: 10px 10px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); }
    .toasts { bottom: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom)) !important; }

    /* Заголовок страницы */
    .page-head { gap: 8px; margin-bottom: 10px; }
    .page-head > div:first-child { min-width: 0; flex: 1 1 100%; }
    .page-head h1 { font-size: 18px; flex-wrap: wrap; }
    .page-head .sub { font-size: 12px; }
    .page-head .actions { margin-left: 0; width: 100%; }
    .page-head .actions > .btn, .page-head .actions > a.btn, .page-head .actions > .dropdown { flex: 1 1 auto; }
    .page-head .actions > .dropdown > .btn { width: 100%; }
    .page-head .actions .btn { height: 34px; }
    .section-tabs, .tabs { scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .section-tabs::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
    .section-tabs { margin: -2px -10px 10px; padding: 0 6px; }
    .section-tabs a { padding: 8px 10px 9px; font-size: 13.5px; }

    /* Сетки и формы */
    .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .g5, .g6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .split-l, .split-l[style], .chat, .m-stack, .m-stack[style] { grid-template-columns: minmax(0, 1fr) !important; }
    .kpis[style] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px; }
    .kpis > :last-child:nth-child(odd) { grid-column: 1 / -1; }
    .frow { grid-template-columns: 1fr; gap: 3px; }
    .auth { grid-template-columns: 1fr; } .auth-side { display: none; }
    .f.s2, .f.s3, .f.s4, .f.s5, .f.s6 { grid-column: span 6; }
    .input, .select, textarea.input { font-size: 16px; }
    .input, .select { height: 36px; }
    .toolbar .input, .toolbar .select { height: 34px; font-size: 16px; }
    .dl { grid-template-columns: minmax(96px, 38%) 1fr; }
    .card-h { flex-wrap: wrap; }
    .card-h .actions { flex-wrap: wrap; }

    /* Панель фильтров */
    .toolbar { gap: 6px; padding: 8px; }
    .toolbar .search { width: 100%; flex: 1 1 100%; }
    .toolbar .select { flex: 1 1 140px; min-width: 0; max-width: none !important; }
    .toolbar input[type=date] { flex: 1 1 0; width: auto !important; min-width: 0; }
    .toolbar .spacer { display: none; }
    .toolbar .seg, .seg.scroll { display: flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
    .toolbar .seg::-webkit-scrollbar { display: none; }
    .seg button, .seg a { height: 30px; flex-shrink: 0; }
    .toolbar.has-filters:not(.f-open) > :not(.search):not(.f-toggle):not(.m-keep) { display: none; }
    .toolbar.has-filters .search { flex: 1 1 calc(100% - 50px); width: auto; }
    .f-toggle { display: inline-flex; height: 34px; }
    .bulkbar { flex-wrap: wrap; position: sticky; top: var(--top-h); z-index: 3; }
    .pager { flex-wrap: wrap; justify-content: center; }
    .pager .links { margin-left: 0; flex-wrap: wrap; justify-content: center; }
    .pager .links .btn { min-width: 32px; height: 32px; }

    /* Окна: снизу на весь экран */
    .modal, .modal.lg, .modal.xl, .modal.sm { left: 0; right: 0; top: auto; bottom: 0; transform: none; width: 100%; max-height: 92vh; border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom); }
    .modal-f { border-radius: 0; flex-wrap: wrap; }
    .modal-f .btn { flex: 1 1 auto; height: 38px; }
    .drawer, .drawer.lg { width: 100vw; }
    .menu { max-width: calc(100vw - 16px); }

    /* Календарь, склад, чат, этикетки */
    .cal-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .cal-scroll .cal { min-width: 680px; }
    .lbl-stage { padding: 12px; min-height: 0; }
    .lbl-editor > * { min-width: 0; }
    .lbl-editor > :nth-child(2) { order: -2; }
    .lbl-editor > :nth-child(3) { order: -1; }
    .lbl-toolbar { flex-wrap: wrap; gap: 6px; }
    .lbl-sample { width: auto !important; flex: 1; min-width: 0; max-width: 100%; }
    .lbl-toolbar > .row:first-child { flex: 1 1 100%; min-width: 0; }
    .lbl-toolbar > .row:first-child > span { flex-shrink: 0; }
    .lbl-el { touch-action: none; }
    .lbl-el .h { width: 18px; height: 18px; right: -9px; bottom: -9px; border-radius: 4px; }

    /* Мессенджер на телефоне: список или переписка на весь экран; страница под ним не прокручивается */
    html.chat-page, html.chat-page body { overflow: hidden; overscroll-behavior: none; height: 100%; }
    html.chat-page body { position: fixed; inset: 0; width: 100%; }
    html.chat-page .main { height: 100%; }
    .mx { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - var(--top-h) - var(--tabbar-h) - 74px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); min-height: 0; border-radius: 12px; }
    .mx.has-active .mx-list, .mx:not(.has-active) .mx-main { display: none !important; }
    .mx.has-active { position: fixed; left: 0; right: 0; top: calc(var(--vv-top, 0px) + var(--top-h) + env(safe-area-inset-top)); height: calc(var(--vv-h, 100dvh) - var(--top-h) - env(safe-area-inset-top)); z-index: 35; border: 0; border-radius: 0; }
    html.chat-open:not(.chat-single) .tabbar { display: none; }
    .portal-page .mx.has-active { top: calc(var(--vv-top, 0px) + 50px + env(safe-area-inset-top)); height: calc(var(--vv-h, 100dvh) - 50px - env(safe-area-inset-top) - var(--tabbar-h) - env(safe-area-inset-bottom)); }
    html.kb-open .portal-page .mx.has-active { height: calc(var(--vv-h, 100dvh) - 50px - env(safe-area-inset-top)); }
    html.kb-open .tabbar { display: none; }
    .portal-page .mx-compose { padding-bottom: 6px; }
    .mx-back { display: inline-flex; margin-left: -6px; }
    .mx-head { padding: 6px 10px; min-height: 52px; }
    .mx-box { padding: 10px 10px 14px; }
    .mx-col { max-width: 84%; }
    .mx-compose { padding: 6px 8px calc(6px + var(--kb-safe, env(safe-area-inset-bottom))); }
    .mx-input { font-size: 16px; }
    .mx-down { bottom: calc(70px + env(safe-area-inset-bottom)); }
    .mx-menu.mob { left: 8px !important; right: 8px; top: auto !important; bottom: calc(10px + env(safe-area-inset-bottom)); width: auto; }
    .mx-menu-wrap:has(.mx-menu.mob) { background: rgba(15,23,42,.35); }
    .mx-menu.mob .mx-emojis { justify-content: space-between; }
    .mx-menu.mob .mx-emojis button { width: 36px; height: 40px; font-size: 25px; }
    .mx-menu.mob .mx-acts button, .mx-menu.mob .mx-acts a { padding: 11px 12px; font-size: 15px; }
    .mx-conv { padding: 9px 12px; }
    .mx-list-f { display: none; }
    .drive-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

    /* Портал партнёра */
    .portal-top { position: sticky; top: 0; z-index: 45; padding-top: env(safe-area-inset-top); }
    .portal-top .in { height: 50px; gap: 6px; padding: 0 6px 0 12px; }
    .portal-top .in > .row { min-width: 0; flex: 1; }
    .portal-top .top-spacer { display: none; }
    .portal-top .in > .row .b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
    .portal-top .menu { position: fixed; left: 8px; right: 8px; top: calc(54px + env(safe-area-inset-top)); width: auto !important; }
    .portal-page { padding: 10px 10px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); }
}

/* ── Телефон: таблицы-карточки ── */
@media (max-width: 640px) {
    .g2, .g3, .g4 { grid-template-columns: 1fr; }
    .g5, .g6, .g4.m2, .g3.m2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .g5 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
    .f.s2, .f.s3, .f.s4, .f.s5, .f.s6, .f.s8, .f.s9 { grid-column: span 12; }
    .f.m6 { grid-column: span 6; }
    .form-grid > .f[style*="grid-column"] { grid-column: span 12 !important; }
    .form-grid > .f[style*="span 3"] { grid-column: span 6 !important; }
    .form-grid > .f[style*="span 2"]:not([style*="span 12"]) { grid-column: span 6 !important; }
    .form-grid > .f[style*="span 1;"], .form-grid > .f[style*="span 1\""], .form-grid > .f[style$="span 1"] { grid-column: span 4 !important; }
    .kpi { padding: 10px 11px; }
    .kpi .value { font-size: 18px; }
    .card { border-radius: 10px; }
    .card-b { padding: 10px; }

    .drive-grid[style] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .kpi .label { font-size: 11px; }
    .kpi .delta { font-size: 11px; }
    .table-wrap { overflow: visible; }
    .table:not(.no-cards) { display: block; font-size: 13px; }
    .table:not(.no-cards) thead { display: none; }
    .table:not(.no-cards) tbody, .table:not(.no-cards) tfoot { display: block; }
    .table:not(.no-cards) tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 12px; padding: 11px 12px; border-bottom: 1px solid var(--line); position: relative; }
    .table:not(.no-cards) tbody tr:last-child { border-bottom: 0; }
    .table:not(.no-cards) tbody tr:hover td { background: none; }
    .table:not(.no-cards) tbody tr.selected { background: var(--primary-50); }
    .table:not(.no-cards) td { display: block; padding: 0; border: 0 !important; min-width: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; background: none !important; }
    .table:not(.no-cards) td.num { text-align: left; }
    .table:not(.no-cards) td[data-label]::before { content: attr(data-label); display: block; font-size: 10.5px; line-height: 1.3; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; margin-bottom: 1px; }
    .table:not(.no-cards) td:empty, .table:not(.no-cards) td.m-hide { display: none; }
    .table:not(.no-cards) td.m-title { grid-column: 1 / -1; font-size: 14px; font-weight: 600; order: -1; }
    .table.m3:not(.no-cards) tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .table:not(.no-cards) td[style] { width: auto !important; max-width: none !important; }
    .table:not(.no-cards) td.m-title::before { display: none; }
    .table:not(.no-cards) td.m-full, .table:not(.no-cards) td.m-span { grid-column: 1 / -1; }
    .table:not(.no-cards) td.m-w2 { grid-column: span 2; }
    .table:not(.no-cards) td.m-nolabel::before { display: none; }
    .table:not(.no-cards) td.cb { position: absolute; right: 10px; top: 10px; width: auto; }
    .table:not(.no-cards) td.cb input { width: 20px; height: 20px; }
    .table:not(.no-cards) td.cb::before { display: none; }
    .table:not(.no-cards) td.acts { order: 99; grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-start; width: auto; }
    .table:not(.no-cards) td.acts::before { display: none; }
    .table:not(.no-cards) td.acts.m-hide { display: none; }
    .table:not(.no-cards) td.acts .btn { opacity: 1; }
    .table:not(.no-cards) td.acts .btn-icon { width: 34px; height: 30px; border: 1px solid var(--line); }
    .table:not(.no-cards) tr:has(td.cb) td.m-title { padding-right: 34px; }
    .table:not(.no-cards) tr.grp { background: var(--panel-2); border-top: 1px solid var(--line); }
    .table:not(.no-cards) td.m-span .row.between { flex-wrap: wrap; gap: 6px; }
    .table-wrap[style*="max-height"] { max-height: none !important; }
    .table:not(.no-cards) .title-cell { min-width: 0; }
    .table:not(.no-cards) .title-cell .t { white-space: normal; max-width: none !important; }
    .table:not(.no-cards) .ellipsis { white-space: normal; max-width: none !important; }
    .table:not(.no-cards) td .input, .table:not(.no-cards) td .select { width: 100%; height: 36px; }
    .table:not(.no-cards) tfoot tr { background: var(--panel-2); border-radius: 0 0 10px 10px; }
    .table:not(.no-cards) tfoot td { background: none; padding: 0; font-weight: 650; }
    .table:not(.no-cards) tfoot td[colspan] { grid-column: 1 / -1; }
    .table.no-cards { min-width: 560px; }

    /* Просмотр документа */
    .doc-badges { display: inline-flex; gap: 4px; flex-wrap: wrap; }
    .doc-mbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; width: 100%; }
    .doc-mbar .dropdown { display: block; }
    .doc-mbar .dm { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 54px; width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text-2); font: inherit; font-size: 11.5px; font-weight: 500; text-decoration: none; cursor: pointer; }
    .doc-mbar .dm svg { width: 19px; height: 19px; color: var(--primary); }
    .doc-mbar .dm-main { grid-column: 1 / -1; height: 42px; font-size: 14.5px; border-radius: 10px; }
    .doc-mbar .menu { min-width: 250px; }
    .doc-viewer-card { border: 0; box-shadow: none; background: transparent; }
    .doc-viewer-bg { background: transparent !important; padding: 0 !important; display: block !important; }
    .doc-viewer { overflow: hidden; border-radius: 6px; box-shadow: 0 2px 14px rgba(16,24,40,.14); background: #fff; }
    .doc-viewer iframe[data-fit] { box-shadow: none !important; border-radius: 0 !important; margin: 0 !important; }
    .doc-full { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; color: var(--primary); padding: 8px; }
    .doc-full svg { width: 15px; height: 15px; }

    /* Компактные карточки списков (своя разметка в td.m-card) */
    .table.m-custom tr { display: block; padding: 0; position: relative; }
    .table.m-custom tbody tr > td:not(.m-card):not(.cb):not(.m-span) { display: none; }
    .table.m-custom td.m-card { display: flex !important; flex-direction: column; gap: 4px; padding: 11px 14px 12px !important; cursor: pointer; -webkit-tap-highlight-color: transparent; }
    .table.m-custom td.m-card:active { background: var(--panel-2) !important; }
    .table.m-custom tr:has(> td.cb) td.m-card { padding-left: 46px !important; }
    .table.m-custom td.cb { left: 14px; right: auto; top: 13px; }
    .mc-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
    .mc-title { font-weight: 650; font-size: 14.5px; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mc-top .mc-title { flex: 0 1 auto; }
    .mc-right { margin-left: auto; white-space: nowrap; font-size: 13.5px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
    .mc-line { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mc-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; margin-top: 1px; }
    .mc-meta { color: var(--muted); font-size: 12px; min-width: 0; flex: 1 1 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mc-meta b { color: var(--text-2); font-weight: 600; }
    .mc-dl { display: inline-flex; gap: 2px; margin-left: auto; }
    .mc-dl a { font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; text-decoration: none; }
    .mc-top .thumb { width: 38px; height: 38px; }
    .table-wrap:has(.no-cards) { overflow-x: auto; }
}

/* ── Окно поверх страницы (документ целиком / страницы из «новой вкладки» в приложении) ── */
.ps-sheet { position: fixed; inset: 0; z-index: 2000; background: #525659; display: none; flex-direction: column; }
.ps-sheet.on { display: flex; }
html.ps-sheet-open, html.ps-sheet-open body { overflow: hidden; }
.ps-sheet-bar { display: flex; align-items: center; gap: 6px; padding: calc(env(safe-area-inset-top) + 8px) 10px 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.ps-sheet-bar button { height: 38px; min-width: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); font: inherit; font-size: 15px; color: var(--text); cursor: pointer; }
.ps-sheet-close { font-weight: 650; background: var(--primary) !important; color: #fff !important; border-color: var(--primary) !important; }
.ps-sheet-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); }
.ps-sheet-zoom { display: inline-flex; gap: 4px; }
.ps-sheet-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 8px; padding-bottom: calc(env(safe-area-inset-bottom) + 8px); }
.ps-sheet-body iframe { display: block; border: 0; background: #fff; margin: 0 auto; box-shadow: 0 2px 12px rgba(0, 0, 0, .3); }
.ps-sheet.generic .ps-sheet-body { padding: 0; overflow: hidden; }
.ps-sheet.generic .ps-sheet-body iframe { width: 100%; height: 100%; box-shadow: none; }
.ps-sheet.generic .ps-sheet-zoom { display: none; }
