:root {
  --coin-empty: #d3d7dd; --coin-empty-line: #8d939c; --coin-fill: #ffd02e; --coin-fill-line: #b8860b;
  --bank-fill: #e4eefb; --bank-line: #2f63a8; --cash-fill: #e1f3e6; --cash-line: #23824a;
  --bg: #f4f5f7; --panel: #fff; --line: #d9dde3; --line-strong: #b9c0ca; --cell: #e4e7eb;
  --text: #1d2330; --muted: #6b7482; --accent: #1f6feb; --accent-d: #1858c0; --accent-bg: #e8f0fe;
  --err: #d1242f; --err-bg: #fff0f0; --ro: #f1f3f6; --row-hover: #f8fafc; --warn: #d4a72c;
  --ok: #1a7f37;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.4 "Segoe UI", Roboto, Arial, sans-serif; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 20px; margin: 0; font-weight: 600; }
h2 { font-size: 16px; margin: 0 0 10px; font-weight: 600; }

/* ---------- header ---------- */
header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 16px; min-height: 52px; background: #1d2330; color: #fff;
         position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 700; font-size: 16px; margin-right: 16px; letter-spacing: .3px; }
nav { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-width: 0; }
nav a { color: #c9d1dc; padding: 8px 12px; border-radius: 6px; }
nav a:hover { background: #2b3342; color: #fff; }
nav a.on { background: #2f3b52; color: #fff; }
.nav-service { position: relative; }
.nav-menu-toggle, html[data-theme="dark"] .nav-menu-toggle { border: 0; background: transparent; color: #c9d1dc; padding: 8px 12px; }
.nav-menu-toggle:hover, .nav-menu-toggle[aria-expanded="true"],
html[data-theme="dark"] .nav-menu-toggle:hover, html[data-theme="dark"] .nav-menu-toggle[aria-expanded="true"] { background: #2b3342; color: #fff; }
.nav-menu-toggle.on, html[data-theme="dark"] .nav-menu-toggle.on { background: #2f3b52; color: #fff; }
.nav-service-links { position: absolute; top: calc(100% + 4px); right: 0; min-width: 190px; padding: 4px;
                     background: #1d2330; border: 1px solid #3a465c; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.nav-service-links a, .nav-service-links button { display: block; white-space: nowrap; }
.nav-service-links button, html[data-theme="dark"] .nav-service-links button { width: 100%; text-align: left; border: 0; background: transparent; color: #c9d1dc; padding: 8px 12px; }
.nav-service-links button:hover, html[data-theme="dark"] .nav-service-links button:hover { background: #2b3342; color: #fff; }
.nav-menu-toggle:focus-visible, nav a:focus-visible, .nav-service-links button:focus-visible { outline: 2px solid #c9d1dc; outline-offset: -2px; }
.who { color: #c9d1dc; font-size: 13px; margin-right: 6px; white-space: nowrap; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #e7eaee; color: #3b4250; vertical-align: 1px; }
header .badge { background: #3a465c; color: #dfe6f0; }
.badge.admin { background: #fde2e1; color: #9a1b1f; }
.badge.user { background: #dcebff; color: #1b4f9c; }
.badge.client { background: #dff3e4; color: #1a6b33; }
.st { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #eef0f3; white-space: nowrap; }
.st0 { background: #dcebff; color: #1b4f9c; }
.st1 { background: #fff1c2; color: #7a5500; }
.st2 { background: #dff3e4; color: #1a6b33; }
.st3 { background: #e9e4f7; color: #4b3a8c; }
.st4 { background: #f1f1f1; color: #777; text-decoration: line-through; }
select.st { border: 1px solid transparent; cursor: pointer; font-size: 12px; }

/* ---------- controls ---------- */
button, .btn { font: inherit; border-radius: 6px; padding: 7px 14px; cursor: pointer; border: 1px solid var(--line-strong);
               background: #fff; color: var(--text); white-space: nowrap; display: inline-block; }
button:hover, .btn:hover { background: #f0f2f5; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-d); }
button.danger { color: var(--err); }
button.danger:hover { background: var(--err-bg); border-color: var(--err); }
button.ghost { background: transparent; border-color: transparent; color: #c9d1dc; }
button.ghost:hover { background: #2b3342; color: #fff; }
button.sm { padding: 4px 9px; font-size: 13px; }
button.icon { border: none; background: none; color: var(--muted); padding: 2px 6px; font-size: 16px; line-height: 1; }
button.icon:hover { color: var(--err); }
input, select, textarea { font: inherit; color: var(--text); }
.field { border: 1px solid var(--line-strong); border-radius: 6px; padding: 6px 8px; background: #fff; }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(31,111,235,.15); }
label.lbl, div.lbl { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
label.chk { display: flex; align-items: center; gap: 6px; color: var(--text); cursor: pointer; }

/* ---------- layout ---------- */
main { padding: 16px; max-width: 1500px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.panel-pad { padding: 14px 16px; }
.head-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.filters .field { min-width: 0; }
.status-filter { width: 200px; }
.status-filter details { position: relative; }
.status-filter summary { display: flex; justify-content: space-between; align-items: center; gap: 8px; cursor: pointer; list-style: none; color: var(--text); }
.status-filter summary::-webkit-details-marker { display: none; }
.status-filter summary span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-options { position: absolute; top: calc(100% + 4px); left: 0; z-index: 50; width: max-content; min-width: 100%; max-width: calc(100vw - 60px); max-height: min(360px, 50vh); overflow-y: auto; padding: 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--panel); color: var(--text); box-shadow: 0 6px 18px #0003; box-sizing: border-box; }
.status-options .chk { display: flex; padding: 7px 8px; border-radius: 4px; cursor: pointer; white-space: normal; }
.status-options .chk:hover { background: var(--bg); }
.status-options button { margin: 6px 8px 2px; }
.order-presets { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.order-presets .lbl { min-width: 0; max-width: 100%; }
.order-presets select { width: 260px; max-width: 100%; }
.order-presets .small { flex-basis: 100%; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.catalog-tabs { flex-wrap: wrap; }
.modal-box.film-milling-modal { max-width: 760px; max-height: 94vh; overflow-y: auto; }
.tabs button.on { background: var(--accent-bg); border-color: var(--accent); color: var(--accent-d); font-weight: 600; }

/* ---------- tables ---------- */
.tbl-wrap { overflow: auto; }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; }
table.grid th { position: sticky; top: 0; background: #fafbfc; z-index: 2; padding: 8px 6px; border-bottom: 2px solid var(--line-strong);
                font-weight: 600; font-size: 13px; text-align: left; white-space: nowrap; }
table.grid td { border-bottom: 1px solid var(--line); padding: 4px 6px; vertical-align: middle; }
table.grid tbody tr:hover td { background: var(--row-hover); }
table.list tbody tr { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.idx { color: var(--muted); text-align: right; width: 40px; }
td.acts { white-space: nowrap; text-align: right; }
td.acts button { margin-left: 4px; }
td.acts.acts-wrap { white-space: normal; }            /* строка с «Отправить в Planfix»: кнопки переносятся, если не помещаются */
td.acts.acts-wrap button { white-space: nowrap; margin-top: 2px; margin-bottom: 2px; }
.empty-row td { text-align: center; color: var(--muted); padding: 30px; cursor: default; }

/* ---------- order editor ---------- */
.ed-head.has-client { grid-template-columns: minmax(160px, 0.8fr) minmax(200px, 1.2fr) minmax(200px, 1.4fr) auto auto; }
.ed-head { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(200px, 1.5fr) auto auto; gap: 12px; align-items: end; padding: 14px 16px;
           border-bottom: 1px solid var(--line); }
.ed-grid td input, .ed-grid td select { width: 100%; border: 1px solid var(--cell); border-radius: 4px; padding: 5px 6px; background: transparent; }
.ed-grid td input:hover { border-color: var(--line-strong); }
.ed-grid td input:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 2px rgba(31,111,235,.15); }
.ed-grid td input.n { text-align: right; font-variant-numeric: tabular-nums; }
.ed-grid td input[readonly] { background: var(--ro); color: var(--muted); }
.ed-grid td input::placeholder { color: transparent; }
.ed-grid td input:focus::placeholder { color: #a3aab5; }
.ed-grid.ro td input { border-color: transparent; background: transparent; color: var(--text); }
.ed-grid.ro td input.combo { background-image: none; }
.invalid { border-color: var(--err) !important; background: var(--err-bg) !important; }
.cbx { display: flex; align-items: center; gap: 4px; }
.cbx img.sel { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); flex: none; background: #fff; cursor: zoom-in; }
input.combo { padding-right: 22px !important; cursor: text;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7482'/%3E%3C/svg%3E") no-repeat right 8px center !important; }
input.combo:focus { background-color: #fff !important; }
input.combo.stale { border-color: var(--warn); }
.ed-foot { padding: 10px 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); }

/* ---------- dropdown with thumbnails ---------- */
.dd { position: fixed; z-index: 50; display: none; background: #fff; border: 1px solid var(--line-strong); border-radius: 6px;
      box-shadow: 0 8px 24px rgba(0,0,0,.15); max-height: 340px; overflow-y: auto; padding: 4px 0; }
.dd-it { display: flex; align-items: center; gap: 8px; padding: 4px 10px; cursor: pointer; white-space: nowrap; }
.dd-it.act { background: var(--accent-bg); }
.dd-it .th { width: 36px; height: 36px; flex: none; border-radius: 4px; background: #f0f2f5; object-fit: cover; border: 1px solid var(--line); }
.dd-it .th.none { display: inline-block; }
.dd-it mark { background: #ffe58a; color: inherit; padding: 0; border-radius: 2px; }
.dd .note { color: var(--muted); padding: 6px 10px; font-size: 13px; }
.preview { position: fixed; z-index: 60; display: none; background: #fff; border: 1px solid var(--line-strong); border-radius: 8px;
           box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 8px; width: 236px; pointer-events: none; }
.preview img { width: 220px; height: 220px; object-fit: contain; display: block; background: #f7f8fa; border-radius: 4px; }
.preview .cap { font-size: 12px; color: var(--muted); margin-top: 6px; white-space: normal; }

/* ---------- catalog admin ---------- */
.cat-grid td input { width: 100%; border: 1px solid transparent; border-radius: 4px; padding: 5px 6px; background: transparent; }
.cat-grid td input:hover { border-color: var(--cell); }
.cat-grid td input:focus { outline: none; border-color: var(--accent); background: #fff; }
.cat-grid td input.saved { border-color: var(--ok); }
.film-inline-grid { min-width: 1550px; }
.film-inline-grid [data-inline-field] { min-width: 95px; }
.film-inline-grid [data-inline-field="name"], .film-inline-grid [data-inline-field="image"] { min-width: 140px; }
.film-inline-grid [data-inline-field="extra"] { min-width: 175px; }
.film-inline-grid select[data-inline-field="mtype"] { min-width: 60px; }
.film-inline-grid select[data-inline-field="price_group"] { min-width: 190px; max-width: 260px; }
.film-inline-grid select[data-inline-field] { padding: 5px 6px; border: 1px solid var(--cell); border-radius: 4px; background: transparent; color: inherit; }
.film-inline-grid > tbody > tr[data-id] > td:last-child { white-space: nowrap; }
.film-inline-grid [data-fc-cell="conflicts"] { min-width: 150px; max-width: 260px; white-space: normal; }
.film-inline-grid [data-inline-status] { display: block; margin-top: 4px; overflow-wrap: anywhere; }
.film-inline-details { position: sticky; left: 0; max-width: min(900px, 85vw); padding: 8px 12px; }
.film-inline-details p { margin: 0 0 8px; }
.film-inline-details input { min-width: 85px; }
.cat-grid img.th { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); display: block; background: #f0f2f5; cursor: zoom-in; }
.cat-grid .noimg { width: 40px; height: 40px; border-radius: 4px; border: 1px dashed var(--line-strong); display: block; }
.import-box { border: 1px dashed var(--line-strong); border-radius: 8px; padding: 14px; margin-bottom: 14px; background: #fbfcfd; }
.map-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin: 10px 0; }
.prev-tbl { font-size: 13px; }
.prev-tbl td, .prev-tbl th { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: left; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prev-tbl th.hl { background: var(--accent-bg); }

/* ---------- login ---------- */
.login { max-width: 360px; margin: 10vh auto; }
.login .panel { padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { text-align: center; margin-bottom: 4px; }
.login .field { width: 100%; }
.err-text { color: var(--err); font-size: 13px; min-height: 18px; }

/* ---------- modal & toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(20,24,33,.45); z-index: 70; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: #fff; border-radius: 10px; padding: 20px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px;
             box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal-box .field { width: 100%; }
.modal-box .btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.msg { position: fixed; right: 20px; bottom: 20px; max-width: 440px; padding: 12px 16px; border-radius: 8px; z-index: 80;
       background: #1d2330; color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.2); display: none; white-space: pre-line; }
.msg.err { background: var(--err); }

@media (max-width: 800px) {
  main { padding: 8px; }
  header { flex-wrap: wrap; height: auto; padding: 6px 8px; }
  .who { display: none; }
  .ed-head { grid-template-columns: 1fr; }
}

/* ---------- стоимость ---------- */
td.price { white-space: nowrap; color: var(--text); font-variant-numeric: tabular-nums; padding-right: 10px; }
td.price[data-c="sum"] { font-weight: 600; }
.totals { display: flex; flex-wrap: wrap; gap: 10px; }
.order-summary { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.manual-discount { width: 120px; flex: 0 0 120px; }
.manual-discount input { text-align: right; font-variant-numeric: tabular-nums; }
@media (min-width: 801px) and (max-width: 1350px) {
  .ed-head, .ed-head.has-client { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.tot-box { display: flex; flex-direction: column; align-items: flex-end; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfc; min-width: 130px; }
.tot-box b { font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot tr.tot td { border-top: 2px solid var(--line-strong); font-weight: 600; padding: 8px 6px; background: #fafbfc; position: sticky; bottom: 0; }

/* ---------- группы клиентов ---------- */
.badge.grp { background: #fff1c2; color: #7a5500; }
.groups-layout { display: grid; grid-template-columns: minmax(360px, 1fr) minmax(420px, 1.3fr); gap: 16px; align-items: start; }
.groups-layout .filters { align-items: center; }
@media (max-width: 1000px) { .groups-layout { grid-template-columns: 1fr; } }

/* ---------- пароли и блокировка ---------- */
.pw-row { display: flex; gap: 6px; }
.pw-row .field { flex: 1; min-width: 0; }
.mono { font-family: Consolas, "Courier New", monospace; letter-spacing: 1px; font-size: 15px; }
.badge.lock { background: #fde2e1; color: #9a1b1f; margin-top: 3px; }

/* ---------- позиция ---------- */
td.pos { width: 152px; white-space: nowrap; }
.ed-grid td input.posn { text-align: center; width: 104px; font-variant-numeric: tabular-nums; }
.ed-grid td input.posn.auto { color: var(--muted); }
.ed-grid td input.posn.dup { border-color: var(--err); background: var(--err-bg); color: var(--err); }

/* ---------- автовыход ---------- */
.idle-bar { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; align-items: center; gap: 12px;
            background: #fff8e1; border: 1px solid var(--warn); color: #6b4e00; padding: 10px 14px; border-radius: 8px;
            box-shadow: 0 6px 24px rgba(0,0,0,.18); max-width: calc(100vw - 32px); }
.settings { max-width: 640px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- виды фасадов ---------- */
.dd-it .meta { margin-left: auto; padding-left: 12px; font-size: 11.5px; color: var(--muted); flex: none; }
.ed-grid td input.fixed { background: var(--ro) !important; color: var(--muted); border-color: transparent !important; }
.ed-grid input.combo.free { background-image: none !important; padding-right: 6px !important; font-style: italic; }

/* ---------- статусы ---------- */
select.st { border: 1px solid rgba(0,0,0,.08); border-radius: 10px; padding: 2px 6px; font-size: 12px; cursor: pointer; }
select.field.st-field { font-weight: 600; }
.st-colors { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.st-color { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.st-color input[type=color] { width: 36px; height: 28px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 1px; background: #fff; cursor: pointer; }
[data-recall] button { border-color: var(--warn); background: #fff8e1; }
[data-until] { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- логотипы ---------- */
.brand img.logo { width: 36px; height: 36px; object-fit: contain; display: block; background: transparent; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.login-brand h1 { text-align: center; }
img.logo-lg { width: 96px; height: 96px; object-fit: contain; display: block; }
img.logo-ed { width: 40px; height: 40px; object-fit: contain; }
.logo-row { display: flex; gap: 14px; align-items: flex-start; }
.logo-prev { width: 96px; height: 96px; flex: none; border: 1px solid var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; text-align: center;
  background: repeating-conic-gradient(#eef0f3 0% 25%, #fff 0% 50%) 50% / 16px 16px; }
.logo-prev img { width: 100%; height: 100%; object-fit: contain; }
.logo-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
/* ---------- дилер ---------- */
.dealer-price { width: auto; max-width: min(320px, 100%); }
.dealer-base { color: var(--muted); font-size: .85em; font-weight: normal; white-space: nowrap; }
.tot-box b:has(.dealer-base) { white-space: normal; text-align: right; }
.dealer-markup-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px auto; gap: 8px; align-items: end; margin-bottom: 10px; }
.dealer-markup-row input { width: 100%; }
.dealer-rounding { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.dealer-rounding input[type=checkbox] { width: auto; }
.dealer-rounding input[data-round-to] { width: 140px; }
@media (max-width: 520px) {
  .dealer-markup-row { grid-template-columns: minmax(0, 1fr) 95px; }
  .dealer-markup-row button { grid-column: 1 / -1; justify-self: end; }
}
.dl-cell { display: flex; gap: 6px; align-items: center; }
.dl-btn.on { background: #fff8e1; border-color: var(--warn); font-weight: 600; }
.dl-link { word-break: break-all; }
.modal-box textarea, .settings textarea { width: 100%; resize: vertical; }

.dom-grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
@media (max-width: 700px) { .dom-grid { grid-template-columns: 1fr; } }

.dd .dd-grp { position: sticky; top: -4px; z-index: 1; background: #f4f5f7; color: var(--muted); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px; padding: 5px 10px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }

/* ---------- окно просмотра изображения ---------- */
.lightbox { position: fixed; inset: 0; z-index: 95; background: rgba(20,24,33,.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.lb-box { background: #fff; border-radius: 10px; box-shadow: 0 16px 48px rgba(0,0,0,.35); max-width: min(92vw, 1100px); max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; }
.lb-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.lb-title { font-weight: 600; }
.lb-close { font-size: 24px !important; }
.lb-img { position: relative; display: flex; align-items: center; justify-content: center; min-width: 280px; min-height: 200px; padding: 12px;
  background: repeating-conic-gradient(#f1f3f6 0% 25%, #fff 0% 50%) 50% / 20px 20px; overflow: auto; }
.lb-img img { display: block; max-width: calc(min(92vw, 1100px) - 24px); max-height: calc(92vh - 90px); object-fit: contain; }
.lb-load { position: absolute; }
.cbx img.sel { cursor: pointer; }

/* вид изделия, ДС, толщина, превышение размеров */
.ed-grid td select { padding: 4px 3px; cursor: pointer; }
.ed-grid td select:hover:not(:disabled) { border-color: var(--line-strong); }
.ed-grid td select:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 2px rgba(31,111,235,.15); }
.ed-grid td select:disabled { background: transparent; color: var(--text); cursor: default; opacity: 1; -webkit-appearance: none; appearance: none; }
.ed-grid td select.th { text-align: right; }
.ed-grid td select.invalid { border-color: var(--err); background: var(--err-bg); }
.ed-grid th.ds, .ed-grid td.ds { width: 38px; text-align: center; }
.ed-grid td.ds input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.ed-grid td.ds input:disabled { cursor: default; opacity: .35; }
.ed-grid td input.over { border-color: var(--err) !important; background: var(--err-bg); color: var(--err); }
/* импорт прайсов */
.imp-fmt { margin: 4px 0 8px; padding: 8px 10px; background: #f6f8fa; border: 1px solid var(--line); border-radius: 6px; font: 12px/1.55 ui-monospace, Consolas, monospace; white-space: pre-wrap; }
.imp-sum { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 10px 0 6px; }
.imp-err { color: var(--err); }
.imp-err td { color: var(--err); }
.cat-grid td input.num { text-align: right; }
.ed-grid.ro td select { border-color: transparent; }
.ed-grid.ro td.ds input:disabled { opacity: .8; }
.lock-panel { max-width: 720px; margin: 24px auto; }
.lock-panel h2 { margin-top: 0; }
.lock-ic { margin-right: 4px; font-size: 12px; cursor: help; }
/* изображения номенклатуры */
#f-drop.drag { border-color: var(--accent); background: var(--accent-bg); }
.files-grid img.th { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); display: block; background: #f0f2f5; cursor: zoom-in; }
.files-grid td.f-name { word-break: break-all; }
.files-grid tr.f-big td { background: #fff8e6; }
.f-warn { color: #9a6700; }
#f-results { margin-top: 8px; max-height: 180px; overflow: auto; }
.f-res { font-size: 13px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.f-res.ok { color: #1a7f37; }
.f-res.err { color: var(--err); }
.f-res.warn { color: #9a6700; }
.f-res button { margin-left: 6px; }
/* загрузка строк заказа из CSV */
.modal-box.wide { max-width: min(1200px, 96vw); }
.imp-opts { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center; }
.ci-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px 12px; }
.ci-map .lbl { font-size: 12.5px; }
.ci-map select { font-size: 13px; }
#ci-prev td.ci-notes { white-space: normal; min-width: 240px; max-width: 340px; color: #1a7f37; }
#ci-prev tr.ci-bad td.ci-notes { color: var(--err); }
.pr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 16px; margin-bottom: 10px; }
.pr-grid .field { max-width: 160px; text-align: right; }
.ed-grid th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.ed-grid th.sortable:hover { color: var(--accent); }
.ed-grid th .sort-ic { font-size: 10px; color: var(--accent); }
/* состояние сервера */
.sv-bar { position: relative; height: 16px; background: #e8ebf0; border-radius: 8px; overflow: hidden; margin: 6px 0 8px; }
.sv-bar span { position: absolute; left: 0; top: 0; bottom: 0; }
.sv-bar .sv-used { background: #9aa4b2; }
.sv-bar .sv-svc { background: var(--accent); min-width: 2px; }
.sv-legend, .sv-info { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 13.5px; }
.sv-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.sv-legend i.sv-used { background: #9aa4b2; } .sv-legend i.sv-svc { background: var(--accent); }
.sv-tbl tr.sv-head td { background: #f7f8fa; }
/* отчёт */
.rp-filters { display: grid; grid-template-columns: 200px 220px minmax(260px, 1fr) 200px; gap: 16px; align-items: start; }
.rp-h { font-weight: 600; font-size: 13px; margin-bottom: 6px; display: flex; gap: 8px; align-items: baseline; }
.rp-list { max-height: 210px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.rp-list label.chk { font-size: 13.5px; }
.rp-filters .lbl { margin-bottom: 6px; }
.rp-tbl tfoot td { font-weight: 700; background: #f7f8fa; }
@media (max-width: 1100px) { .rp-filters { grid-template-columns: 1fr 1fr; } }
.ed-grid th.fin, .ed-grid td.fin { width: 96px; }
.ed-grid th.tex, .ed-grid td.tex { width: 136px; }
/* выгрузка CSV: для производства (серая), для 1С (жёлтая), Базис (синяя) */
button.btn-prod { background: #e3e6ea; border-color: #b4bac3; color: #2f353d; }
button.btn-prod:hover { background: #d3d8de; }
button.btn-bazis { background: #1f5fbf; border-color: #174a96; color: #fff; }
button.btn-bazis:hover { background: #174a96; }
button.btn-1c { background: #ffe58a; border-color: #e0bf3e; color: #5c4600; }
button.btn-1c:hover { background: #ffdb5c; }
button.btn-drill { background: #fde2e1; border-color: #e0a3a0; color: #8a1f1a; white-space: nowrap; }
button.btn-drill:hover { background: #f9cfcd; }
.f-res { display: flex; align-items: center; gap: 8px; }
.f-res-th { width: 32px; height: 32px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); cursor: zoom-in; flex: none; }
.cat-grid img.th, .files-grid img.th { cursor: zoom-in; }

/* Редактор и списки заказов: поля по бокам 5% ширины окна */
main.wide { max-width: none; padding-left: 5vw; padding-right: 5vw; }
/* Tables use a shared screen workspace, including settings and box service pages. */
@media screen {
  main:has(table), main.wide:has(table) { width: 95vw; max-width: none; padding-left: 0; padding-right: 0; min-width: 0; }
  main .settings:has(table), main .panel.settings:has(table), main .box-settings:has(table) { width: 100%; max-width: none; min-width: 0; }
  main :has(> table) { max-width: 100%; min-width: 0; overflow-x: auto; }
  main table { width: 100%; max-width: none; }
}
/* заголовки таблицы заказа переносятся на узких экранах — больше места фрезеровке и декору */
.ed-grid th:not(.sortable) { white-space: normal; }
.ed-grid td.tex select { min-width: 128px; }
.ed-grid td.fin select { min-width: 92px; }

/* кнопка «скопировать вид изделия и декор из предыдущей строки» — у всех строк, кроме первой */
.ed-grid td.pos button.cp { padding: 2px 3px; margin-right: 2px; vertical-align: middle; }
.ed-grid td.pos button.cp:hover { color: var(--accent); }
.ed-grid td.pos button.cp svg { display: block; }
#e-rows tr:first-child td.pos button.cp { visibility: hidden; }
/* ручное перемещение строк: «ручка» слева от позиции */
.ed-grid td.pos .drag { display: inline-block; vertical-align: middle; padding: 4px 3px; margin-right: 1px; color: var(--muted); opacity: .45;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.ed-grid td.pos .drag svg { display: block; }
.ed-grid tr:hover td.pos .drag { opacity: 1; }
.ed-grid td.pos .drag:hover { color: var(--accent); }
#e-rows tr.dragging td { background: var(--ro); }
#e-rows tr.dragging { outline: 2px solid var(--accent); outline-offset: -2px; }
#e-rows tr.dragging td.pos .drag { opacity: 1; color: var(--accent); }
body.row-dragging, body.row-dragging * { cursor: grabbing !important; user-select: none !important; -webkit-user-select: none !important; }
@media (pointer: coarse) { .ed-grid td.pos .drag { opacity: 1; padding: 8px 5px; } }

/* значок присадки в списке заказов */
.drill-ic { display: inline-block; color: #d32f2f; margin-right: 6px; vertical-align: -2px; line-height: 0; }

/* комментарий в списке заказов: коротко, по клику — полностью и в буфер обмена */
.grid.list td.cmt-cell { max-width: 280px; }
.cmt { cursor: pointer; color: var(--muted); border-bottom: 1px dashed currentColor; white-space: nowrap; }
.cmt:hover { color: var(--accent); }
.cmt.open { white-space: pre-wrap; word-break: break-word; color: inherit; border-bottom-style: dotted; }

/* документы к заказу: кнопки со стрелками в списке заказов */
/* процент оплаты: стопка монет с числом поверх */
.grid.list th.pay-col, .grid.list td.pay-col { width: 34px; text-align: center; padding-left: 2px; padding-right: 0; }
.pay-ic { position: relative; display: inline-block; width: 26px; height: 28px; vertical-align: middle; cursor: default; }
.pay-ic svg { display: block; }
.pay-ic.postpay { color: #986400; }
html[data-theme="dark"] .pay-ic.postpay { color: #ffd36b; }
.pay-n { position: absolute; left: -4px; right: -4px; top: 50%; transform: translateY(-50%); text-align: center;
  font-size: 10px; line-height: 1; font-weight: 700; letter-spacing: -.3px; color: #2a2f38; pointer-events: none;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff; }
.pay-n.long { font-size: 8.5px; }
.pay-ic:not(.part):not(.full) .pay-n { color: #59606b; }
html[data-theme="dark"] .pay-n { color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000, 0 0 3px #000; }
html[data-theme="dark"] .pay-ic:not(.part):not(.full) .pay-n { color: #c3c9d2; }
/* тип оплаты: банк (безнал) или купюра (наличные) со знаком ₽ */
.grid.list th.ptype-col, .grid.list td.ptype-col { width: 30px; text-align: center; padding-left: 0; padding-right: 2px; white-space: nowrap; }
.ptype { display: inline-flex; align-items: center; gap: 1px; vertical-align: middle; cursor: default; }
.ptype-svg { display: block; }
.ptype-svg .pt-line { stroke-width: 1.1; stroke-linejoin: round; }
.ptype-svg .pt-sign { fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ptype-svg.bank .pt-fill { fill: var(--bank-fill); } .ptype-svg.bank .pt-line, .ptype-svg.bank .pt-sign { stroke: var(--bank-line); }
.ptype-svg.cash .pt-fill { fill: var(--cash-fill); } .ptype-svg.cash .pt-line, .ptype-svg.cash .pt-sign { stroke: var(--cash-line); }
.ptype-svg.cash .pt-dot { fill: var(--cash-line); }
.grid.list th.docs-col, .grid.list td.docs-col { width: 46px; text-align: center; padding-left: 2px; padding-right: 2px; }
.doc-btn { display: inline-flex; align-items: center; gap: 3px; padding: 3px 6px; border: 1px solid var(--line-strong); border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer; line-height: 1; }
.doc-btn:hover { color: var(--text); border-color: var(--muted); }
.doc-btn.has { border: 2px solid #1e9e4a; padding: 2px 5px; color: #1e7a3c; background: #eefaf2; }
.doc-btn.has:hover { background: #dcf3e4; }
.doc-btn svg { display: block; }
.doc-n { font-size: 11px; line-height: 1; color: #1e7a3c; font-weight: 600; }
.dc-list { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow: auto; padding: 4px 0; }
.dc-it { display: flex; align-items: center; gap: 8px; }
.dc-it a { flex: 1; word-break: break-all; }
#dc-wrap { display: flex; flex-direction: column; gap: 12px; }

/* стоимость в списке заказов — без переносов строк (и строки скидок/наценки под ней) */
.grid.list td.cost, .grid.list td.cost * { white-space: nowrap; }

/* =====================================================================
   Тёмная тема: html[data-theme="dark"] — по умолчанию как на устройстве,
   переключатель в шапке (выбор запоминается в браузере)
   ===================================================================== */
html[data-theme="dark"] {
  color-scheme: dark;
  --coin-empty: #3d434d; --coin-empty-line: #7d848f; --coin-fill: #e6b800; --coin-fill-line: #ffd84d;
  --bank-fill: #1c2c45; --bank-line: #7fb0ff; --cash-fill: #17321f; --cash-line: #6fd394;
  --bg: #13161c; --panel: #1b1f27; --line: #2e3440; --line-strong: #414a58; --cell: #2a303b;
  --text: #e3e7ee; --muted: #9aa3b1; --accent: #4c8dff; --accent-d: #3a78e6; --accent-bg: #1c2b45;
  --err: #ff6b6b; --err-bg: #3a1d20; --ro: #20252e; --row-hover: #222833; --warn: #d9a93a; --ok: #4cc27a;
}
html[data-theme="dark"] header { background: #0d1015; border-bottom: 1px solid #232833; }
html[data-theme="dark"] .badge { background: #2b313c; color: #cfd6e0; }
html[data-theme="dark"] .badge.admin, html[data-theme="dark"] .badge.lock { background: #45201f; color: #ffb4ae; }
html[data-theme="dark"] .badge.user { background: #1d3354; color: #a9c8ff; }
html[data-theme="dark"] .badge.client { background: #1b3a26; color: #9fe0b3; }
html[data-theme="dark"] .badge.grp { background: #3d3314; color: #f3d27a; }
html[data-theme="dark"] .st { background: #2b313c; }
html[data-theme="dark"] .st0 { background: #1d3354; color: #a9c8ff; }
html[data-theme="dark"] .st1 { background: #3d3314; color: #f3d27a; }
html[data-theme="dark"] .st2 { background: #1b3a26; color: #9fe0b3; }
html[data-theme="dark"] .st3 { background: #2e2748; color: #c8bbf3; }
html[data-theme="dark"] .st4 { background: #2a2a2a; color: #999; }
html[data-theme="dark"] button, html[data-theme="dark"] .btn { background: #232833; color: var(--text); border-color: var(--line-strong); }
html[data-theme="dark"] button:hover, html[data-theme="dark"] .btn:hover { background: #2c3340; }
html[data-theme="dark"] button.primary, html[data-theme="dark"] .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
html[data-theme="dark"] button.primary:hover, html[data-theme="dark"] .btn.primary:hover { background: var(--accent-d); }
html[data-theme="dark"] button.icon { background: none; border-color: transparent; }
html[data-theme="dark"] button.ghost { background: transparent; border-color: transparent; color: #c9d1dc; }
html[data-theme="dark"] button.ghost:hover { background: #232833; color: #fff; }
html[data-theme="dark"] .field, html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea { background-color: #151920; color: var(--text); border-color: var(--line-strong); }
html[data-theme="dark"] .ed-grid td input:focus, html[data-theme="dark"] .ed-grid td select:focus,
html[data-theme="dark"] .cat-grid td input:focus, html[data-theme="dark"] input.combo:focus { background-color: #10141a !important; }
html[data-theme="dark"] .ed-grid td input:focus::placeholder { color: #6b7482; }
html[data-theme="dark"] table.grid th { background: #20252e; }
html[data-theme="dark"] tfoot tr.tot td, html[data-theme="dark"] .tot-box { background: #20252e; }
html[data-theme="dark"] .dd, html[data-theme="dark"] .preview, html[data-theme="dark"] .modal-box, html[data-theme="dark"] .lb-box { background: #1b1f27; box-shadow: 0 12px 40px rgba(0,0,0,.6); }
html[data-theme="dark"] .dd .dd-grp { background: #151920; }
html[data-theme="dark"] .dd-it mark { background: #6b5710; }
html[data-theme="dark"] .dd-it .th, html[data-theme="dark"] .cat-grid img.th, html[data-theme="dark"] .files-grid img.th,
html[data-theme="dark"] .preview img, html[data-theme="dark"] .cbx img.sel { background: #2a303b; }
html[data-theme="dark"] .modal { background: rgba(0,0,0,.6); }
html[data-theme="dark"] .msg { background: #2a303b; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
html[data-theme="dark"] .import-box, html[data-theme="dark"] .imp-fmt { background: #171b22; }
html[data-theme="dark"] .lb-img, html[data-theme="dark"] .logo-prev { background: repeating-conic-gradient(#232833 0% 25%, #1b1f27 0% 50%) 50% / 20px 20px; }
html[data-theme="dark"] .files-grid tr.f-big td { background: #3a3218; }
html[data-theme="dark"] .f-warn, html[data-theme="dark"] .f-res.warn { color: #e0b54a; }
html[data-theme="dark"] .f-res.ok, html[data-theme="dark"] #ci-prev td.ci-notes { color: #6fd08f; }
html[data-theme="dark"] .sv-bar { background: #2a303b; }
html[data-theme="dark"] .sv-tbl tr.sv-head td, html[data-theme="dark"] .rp-tbl tfoot td { background: #20252e; }
html[data-theme="dark"] [data-recall] button, html[data-theme="dark"] .dl-btn.on { background: #3d3314; }
html[data-theme="dark"] button.btn-prod { background: #3a414d; border-color: #555e6c; color: #e3e7ee; }
html[data-theme="dark"] button.btn-prod:hover { background: #474f5d; }
html[data-theme="dark"] button.btn-bazis { background: #2a6fd6; border-color: #2a6fd6; color: #fff; }
html[data-theme="dark"] button.btn-bazis:hover { background: #235fb8; }
html[data-theme="dark"] button.btn-1c { background: #c9a227; border-color: #c9a227; color: #1d1600; }
html[data-theme="dark"] button.btn-1c:hover { background: #d8b23a; }
html[data-theme="dark"] button.btn-drill { background: #5a2624; border-color: #7a3632; color: #ffd9d6; }
html[data-theme="dark"] button.btn-drill:hover { background: #6b2e2b; }
html[data-theme="dark"] .doc-btn { background: transparent; }
html[data-theme="dark"] .doc-btn.has { background: #16301f; border-color: #3fbf6a; color: #7fdc9f; }
html[data-theme="dark"] .doc-btn.has:hover { background: #1d4029; }
html[data-theme="dark"] .doc-n { color: #7fdc9f; }
html[data-theme="dark"] .drill-ic { color: #ff6b6b; }
html[data-theme="dark"] select.st { border-color: rgba(255,255,255,.12); }

/* кнопка темы в шапке */
.theme-btn { padding: 6px 8px; line-height: 0; }
.theme-btn svg { display: block; }
html[data-theme="dark"] .idle-bar { background: #3a3218; color: #f3d27a; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
/* цвета статусов задаёт администратор — в тёмной теме чуть приглушаются */
html[data-theme="dark"] .st[style], html[data-theme="dark"] select.st { filter: brightness(.82) saturate(.9); }

/* поле «Присадка» с лупой и окно схемы присадки */
.ed-grid .drl-cell { display: flex; align-items: center; gap: 1px; }
.ed-grid .drl { position: relative; flex: 1; min-width: 112px; }
.ed-grid .drl input { padding-right: 22px; }
.ed-grid .drl button.dp-add { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); padding: 3px; color: var(--muted); }
.ed-grid .drl button.dp-add:hover { color: #1a8f3c; }
.ed-grid .drl-cell button.zoom { flex: none; padding: 3px 2px; color: var(--muted); }
.ed-grid .drl-cell button.zoom:hover { color: var(--accent); }
.ed-grid .drl-cell button svg { display: block; }
.dp-dd .dd-it { justify-content: space-between; font-variant-numeric: tabular-nums; }
.dp-dd .dp-del { padding: 0 4px; font-size: 16px; }
.modal-box.dv-box { max-width: min(760px, 96vw); max-height: 94vh; overflow: auto; }
.dv-wrap { overflow: auto; display: flex; justify-content: center; }
.dv-svg { max-width: 100%; height: auto; font: 12px system-ui, sans-serif; }
.dv-panel { fill: var(--ro); stroke: var(--text); stroke-width: 1.5; }
.dv-hole { fill: var(--accent-bg); stroke: var(--accent); stroke-width: 1.5; }
.dv-hole.bad { fill: var(--err-bg); stroke: var(--err); }
.dv-cross { stroke: var(--accent); stroke-width: .8; stroke-dasharray: 3 2; fill: none; }
.dv-dim { stroke: var(--text); stroke-width: .9; }
.dv-ext { stroke: var(--muted); stroke-width: .7; stroke-dasharray: 3 2; }
.dv-ar { fill: var(--text); }
.dv-t { fill: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }
.dv-t.big { font-weight: 600; font-size: 13px; }
.dv-t.sm { font-size: 11px; fill: var(--muted); }
.dv-t.bad, .dv-dim.bad { fill: var(--err); }
.dv-dim.bad { stroke: var(--err); }
.dv-note { font-size: 12px; line-height: 1.45; margin: 0; }

/* настройки: права должностей */
.perm-wrap { overflow-x: auto; margin-bottom: 10px; }
.perm-grid { width: auto; min-width: 100%; }
.perm-grid th.c, .perm-grid td.c { text-align: center; }
.perm-grid th.c { font-weight: 600; font-size: 13px; max-width: 150px; white-space: normal; }
.perm-grid td:first-child { white-space: nowrap; font-weight: 500; }
.perm-grid input[type=checkbox] { width: 17px; height: 17px; cursor: pointer; }

/* подсказки к столбцам заказа */
.col-tip { position: fixed; z-index: 60; max-width: 340px; background: var(--panel); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 9px 12px; font-size: 13px; line-height: 1.45; pointer-events: none; }
.col-tip.wide { max-width: 600px; }
.col-tip-note { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); color: var(--muted); }
.dt-wrap { display: flex; gap: 12px; align-items: flex-start; }
.dt-svg { flex: none; font: 11px system-ui, sans-serif; }
.dt-txt { width: 320px; }
.dt-txt ul { margin: 4px 0 6px; padding-left: 18px; }
.dt-code { font-family: ui-monospace, Consolas, monospace; font-size: 14px; white-space: nowrap; }
.dt-side { stroke: #8e44ad; stroke-width: 3.5; }
.dt-side-t { font-weight: 700; font-size: 12px; }
.dt-hole { fill-opacity: .15; stroke-width: 1.4; }
.dt-num { font-weight: 700; font-size: 11px; }
.dt-dim { fill: var(--muted); font-size: 10.5px; }
.dt-c0.dt-fill { fill: #8e44ad; color: #8e44ad; }
.dt-c1.dt-fill, .dt-c1.dt-hole { fill: #e8590c; color: #e8590c; } .dt-c1.dt-stroke, .dt-c1.dt-hole { stroke: #e8590c; }
.dt-c2.dt-fill, .dt-c2.dt-hole { fill: #1c7ed6; color: #1c7ed6; } .dt-c2.dt-stroke, .dt-c2.dt-hole { stroke: #1c7ed6; }
.dt-c3.dt-fill, .dt-c3.dt-hole { fill: #2b8a3e; color: #2b8a3e; } .dt-c3.dt-stroke, .dt-c3.dt-hole { stroke: #2b8a3e; }
html[data-theme="dark"] .col-tip { box-shadow: 0 10px 30px rgba(0,0,0,.6); }
html[data-theme="dark"] .dt-side { stroke: #c38ae6; }
html[data-theme="dark"] .dt-c0.dt-fill { fill: #c38ae6; color: #c38ae6; }
html[data-theme="dark"] .dt-c1.dt-fill, html[data-theme="dark"] .dt-c1.dt-hole { fill: #ff8a3d; color: #ff8a3d; }
html[data-theme="dark"] .dt-c1.dt-stroke, html[data-theme="dark"] .dt-c1.dt-hole { stroke: #ff8a3d; }
html[data-theme="dark"] .dt-c2.dt-fill, html[data-theme="dark"] .dt-c2.dt-hole { fill: #5aa9ff; color: #5aa9ff; }
html[data-theme="dark"] .dt-c2.dt-stroke, html[data-theme="dark"] .dt-c2.dt-hole { stroke: #5aa9ff; }
html[data-theme="dark"] .dt-c3.dt-fill, html[data-theme="dark"] .dt-c3.dt-hole { fill: #51c26a; color: #51c26a; }
html[data-theme="dark"] .dt-c3.dt-stroke, html[data-theme="dark"] .dt-c3.dt-hole { stroke: #51c26a; }

/* список заказов: меню «⋮» и отправка в Planfix */
button.icon-more { padding: 3px 4px; line-height: 0; vertical-align: middle; }
button.icon-more svg { display: block; }
button.icon-more.open { background: var(--accent-bg); border-color: var(--accent); }
.row-menu { position: fixed; z-index: 55; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 4px; display: flex; flex-direction: column; min-width: 220px; }
.row-menu[hidden] { display: none; }
.rm-it { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; border: none; background: none;
  padding: 6px 10px; border-radius: 6px; color: var(--text); cursor: pointer; }
.rm-it:hover { background: var(--accent-bg); }
.rm-it span { font-size: 12px; color: var(--muted); }
.rm-it b::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 7px; vertical-align: 0; }
.rm-pw b::before { background: var(--accent); } .rm-del b { color: var(--err); } .rm-del b::before { background: var(--err); }
.row-menu .rm-it + .rm-del { border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; }
.rm-prod b::before { background: #b4bac3; } .rm-bazis b::before { background: #1f5fbf; } .rm-drill b::before { background: #e0a3a0; } .rm-1c b::before { background: #e0bf3e; }
.row-menu .rm-it[style] { background: var(--rm-bg); color: var(--rm-fg); }
.row-menu .rm-it[style]:hover { filter: brightness(.92); }
.row-menu .rm-it[style] b, .row-menu .rm-it[style] span { color: inherit; }
.row-menu .rm-it[style] span { opacity: .8; }
.row-menu .rm-it[style] b::before { background: currentColor; }
button.btn-pf { background: #6f42c1; border-color: #5a32a3; color: #fff; white-space: nowrap; }
button.btn-pf:hover { background: #5a32a3; }
button.btn-pf.sent::before { content: "✓ "; }
button.btn-pf.err::before { content: "! "; color: #ffd2d2; font-weight: 700; }
html[data-theme="dark"] .row-menu { box-shadow: 0 10px 30px rgba(0,0,0,.6); }
html[data-theme="dark"] button.btn-pf { background: #7c55d4; border-color: #7c55d4; }
/* пользователи: телефон и e-mail */
td.contacts { min-width: 170px; }
td.contacts input { width: 100%; font-size: 13px; padding: 3px 6px; }
td.contacts input + input { margin-top: 3px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* настройки: операции и трудоёмкость */
.ops-grid { display: grid; grid-template-columns: 2fr 1fr 2fr; gap: 10px; margin-bottom: 8px; }
.sub-h { font-size: 14px; margin: 8px 0 4px; }
.holes-grid { width: 100%; max-width: 760px; margin-bottom: 8px; }
@media (max-width: 800px) { .ops-grid, .two-col { grid-template-columns: 1fr; } }
/* настройки: интеграция с Planfix */
.pf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-bottom: 6px; }
.pf-grid .pf-wide { grid-column: 1 / -1; }
.pf-grid .pw-row input { flex: 1; }
@media (max-width: 800px) { .pf-grid { grid-template-columns: 1fr; } }
/* «Показать JSON» для Planfix */
.pj-pre { max-height: 62vh; overflow: auto; background: var(--ro); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px;
  font: 12.5px/1.45 ui-monospace, Consolas, monospace; white-space: pre; margin: 0; }
.rm-json b::before { background: #6f42c1; }
.pf-grid.pf-3 { grid-template-columns: 1fr 1fr 1fr; }
.pf-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 14px; margin-bottom: 8px; }
.pf-m { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.pf-m span { flex: 1; color: var(--muted); }
.pf-m input { width: 96px; text-align: right; }
label.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 2px 0 6px; }
@media (max-width: 800px) { .pf-grid.pf-3 { grid-template-columns: 1fr; } }
.pf-obj { display: flex; flex-direction: column; gap: 4px; }
.pf-obj label.chk { margin: 0; }

/* настройки: вкладки и поиск */
.set-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 12px; border-bottom: 1px solid var(--line); }
.set-tabs[hidden] { display: none; }
.set-tab { border: 1px solid transparent; border-bottom: none; background: none; padding: 8px 14px; border-radius: 8px 8px 0 0;
  color: var(--muted); cursor: pointer; font-weight: 500; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 6px; }
.set-tab:hover { color: var(--text); background: var(--row-hover); }
.set-tab.on { color: var(--text); background: var(--panel); border-color: var(--line); border-bottom: 1px solid var(--panel); }
.set-tab.dim { opacity: .45; }
.set-n { background: #ffe58a; color: #5c4600; border-radius: 9px; font-size: 11px; padding: 1px 6px; font-weight: 700; }
.set-tabs-on > .panel, .set-tabs-on > div:not(.head-row):not(.set-tabs) { margin-top: 0 !important; margin-bottom: 0 !important; }
.set-tabs-on > div > .panel { margin: 0 !important; }
.set-search { display: flex; align-items: center; gap: 8px; }
.set-search input { width: 260px; }
.s-hit { background: #fff3b0 !important; border-radius: 4px; box-shadow: 0 0 0 2px #fff3b0; }
.s-hit-cur { box-shadow: 0 0 0 2px #e0a800 !important; }
html[data-theme="dark"] .set-n { background: #6b5710; color: #ffe9a6; }
html[data-theme="dark"] .s-hit { background: #4a3d0c !important; box-shadow: 0 0 0 2px #4a3d0c; }
html[data-theme="dark"] .s-hit-cur { box-shadow: 0 0 0 2px #d8b23a !important; }
@media (max-width: 800px) { .set-search input { width: 100%; } .set-search { flex: 1; } }
/* настройки: столбцы списка заказов */
.oc-grid { width: auto; min-width: 420px; }
.oc-grid td.c, .oc-grid th.c { text-align: center; }
.oc-grid button.sm { padding: 1px 7px; }

@media (max-width: 800px) { .ed-head.has-client { grid-template-columns: 1fr; } }
/* поле «Клиент» с кнопкой «+» */
.cl-row { display: flex; gap: 4px; }
.cl-row select { flex: 1; min-width: 0; }
.cl-add { flex: none; width: 34px; padding: 0; font-size: 18px; line-height: 1; font-weight: 600; color: var(--accent); }
.qa-cred { margin: 8px 0; padding: 10px 12px; background: var(--ro); border-radius: 6px; font-size: 15px; line-height: 1.6; }

/* ---------- массовая замена фрезеровки / декора ---------- */
.ed-grid th button.bulk { padding: 1px 4px; margin-left: 4px; vertical-align: -2px; color: var(--muted); border-radius: 4px; }
.ed-grid th button.bulk:hover { color: var(--accent); background: var(--accent-bg); }
.modal-box.bulk-box { max-width: min(760px, 96vw); }
.bulk-wrap { max-height: 60vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.bulk-tbl { width: 100%; border-collapse: collapse; }
.bulk-tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.bulk-tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.bulk-tbl tr:last-child td { border-bottom: none; }
.bulk-tbl td:first-child { width: 48%; }
.bulk-cur { display: flex; align-items: center; gap: 8px; }
.bulk-cur .th { width: 36px; height: 36px; flex: none; border-radius: 4px; object-fit: cover; border: 1px solid var(--line); background: #f0f2f5; display: inline-block; }
.bulk-arr { color: var(--muted); text-align: center; width: 24px; }
.bulk-tbl .cbx input { width: 100%; min-width: 0; }
/* выпадающие списки и превью — поверх модальных окон */
.dd { z-index: 75; }
.preview { z-index: 76; }

/* ---------- клиент с автоподстановкой ---------- */
.cl-row #e-client-q { flex: 1; min-width: 0; }
.ac-dd .ac-none { font-style: italic; }

/* ---------- просмотр заказа, открытого в другом сеансе ---------- */
.view-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #fff8e1; border-color: #f0d58a; margin-bottom: 10px; }
html[data-theme="dark"] .view-banner { background: #3a3220; border-color: #6b5a2c; }
html[data-theme="dark"] .bulk-tbl th { background: #1b1f27; }

/* ---------- справка из Planfix ---------- */
.pfi-row { flex-wrap: wrap; }
.pfi-row #pfi-id { width: 150px; flex: none; }
.pfi-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 6px; }
.pfi-q { width: 280px; max-width: 100%; margin-left: auto; }
.pfi-wrap { max-height: 480px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.pfi-tbl { width: 100%; }
.pfi-tbl tr.pfi-used td { background: var(--accent-bg); }
button.pfi-id { border: none; background: none; padding: 0; color: var(--accent); font: inherit; font-variant-numeric: tabular-nums; cursor: copy; text-decoration: underline dotted; }
.pfi-raw { margin-top: 8px; }
.pfi-raw summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.pfi-raw pre { max-height: 360px; overflow: auto; background: #f6f7f9; border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
html[data-theme="dark"] .pfi-raw pre { background: #161a21; }
button.busy { opacity: .6; cursor: progress; }

/* ---------- входящие запросы из Planfix ---------- */
.pfh-map { width: 100%; max-width: 760px; margin-bottom: 6px; }
.pfh-map td { padding: 4px 6px; }
.pfh-map select { width: 100%; }
.pfh-help summary { cursor: pointer; color: var(--accent); margin: 6px 0; }
.pfh-help ol { margin: 4px 0 8px; padding-left: 20px; line-height: 1.6; }
.pfh-pre { background: #f6f7f9; border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin: 4px 0; font-size: 12px; max-width: 520px; }
html[data-theme="dark"] .pfh-pre { background: #161a21; }
.pfi-tbl tr.pfh-bad td { color: var(--err); }

/* ---------- скидки и акции ---------- */
.promo-grid td { vertical-align: middle; }
.promo-grid tr.pr-done td, .promo-grid tr.pr-off td { color: var(--muted); }
.badge.pr-cl { background: #eef3ff; color: #1d4fa8; }
html[data-theme="dark"] .badge.pr-cl { background: #1f2b44; color: #9cbcf5; }
.pr-st { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.pr-st-on { background: #d9f5df; color: #17692d; }
.pr-st-plan { background: #fff3c4; color: #6b5300; }
.pr-st-done, .pr-st-off { background: #eceef1; color: #5b6270; }
html[data-theme="dark"] .pr-st-on { background: #1d3b25; color: #8fe0a4; }
html[data-theme="dark"] .pr-st-plan { background: #3b3218; color: #f0d67a; }
html[data-theme="dark"] .pr-st-done, html[data-theme="dark"] .pr-st-off { background: #2a2f38; color: #a3aab6; }
.modal-box.pr-box { max-width: min(860px, 96vw); }
.pr-form { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px 12px; }
.pr-form .pr-wide { grid-column: 1 / -1; }
#pr-order-mode { display: flex; max-width: 100%; }
#pr-order-mode > button { white-space: normal; min-width: 0; }
#pr-order-mode > button:first-child { flex-shrink: 0; }
.pr-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pr-pick-h { font-weight: 600; margin-bottom: 4px; }
.pr-list { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; display: flex; flex-direction: column; gap: 2px; }
.pr-list label.chk { margin: 0; }
@media (max-width: 700px) { .pr-form, .pr-pick { grid-template-columns: 1fr; } }

/* уведомления: каналы в личных настройках */
.nm-ch { margin: 6px 0 10px; }
.nm-sub { margin: 4px 0 0 26px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.nm-sub .muted.small { flex-basis: 100%; }
.nm-ok { color: #1e7a3c; font-weight: 600; }
html[data-theme="dark"] .nm-ok { color: #7fdc9f; }

/* ---------- расширенная присадка: редактор ---------- */
.modal-box.ade-box { max-width: min(1280px, 98vw); width: 98vw; height: 94vh; padding: 14px 16px; gap: 8px; }
.ade { display: flex; flex-direction: column; gap: 8px; height: 100%; min-height: 0; }
.ade-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ade-head h2 { margin: 0; }
.ade-sp { flex: 1; }
.ade-bar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
#ade-modes { flex-wrap: wrap; gap: 3px; }
#ade-modes > button { margin: 0; border-radius: 6px; }
.seg { display: inline-flex; align-items: center; gap: 0; }
.seg > button { border-radius: 0; margin-left: -1px; padding: 6px 12px; }
.seg > button:first-of-type { border-radius: 6px 0 0 6px; margin-left: 0; }
.seg > button:last-of-type { border-radius: 0 6px 6px 0; }
.seg > button.on { background: var(--accent-bg); border-color: var(--accent); color: var(--accent-d); font-weight: 600; position: relative; z-index: 1; }
.seg > span { margin-right: 8px; }
.seg.sm > button { padding: 4px 10px; font-size: 13px; }
.lbl .seg { margin-top: 2px; }
.ade-main { flex: 1; display: flex; gap: 12px; min-height: 0; }
.ade-cv { flex: 1; min-width: 0; position: relative; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; touch-action: none; }
.ade-side { width: 340px; flex: none; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.ade-side h3 { font-size: 15px; margin: 0; }
.ade-side h4 { font-size: 14px; margin: 0; }
.ade-debug-mode .ade-side { width: 410px; }
.ade-debug-visibility { border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.ade-debug-visibility summary { cursor: pointer; font-weight: 600; }
.ade-debug-type { margin-top: 8px; }
.ade-debug-toggle { display: inline-flex; gap: 5px; align-items: center; font-size: 12px; padding: 3px 6px 3px 0; }
.ade-debug-elements { display: flex; flex-wrap: wrap; padding-left: 14px; }
.ade-debug-total { font-weight: 700; font-size: 16px; }
.ade-debug-operation { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: none; }
.ade-debug-op, .ade-debug-param { width: 100%; display: flex; justify-content: space-between; gap: 10px; text-align: left; border: 0; border-radius: 0; white-space: normal; }
.ade-debug-op { padding: 10px; background: var(--ro); }
.ade-debug-op span, .ade-debug-param b { flex: none; }
.ade-debug-rule { border-top: 1px solid var(--line); padding: 6px; }
.ade-debug-param { padding: 5px; font-size: 12px; }
.ade-debug-reason, .ade-debug-detail { padding: 4px 5px; font-size: 12px; overflow-wrap: anywhere; }
.ade-debug-reason { color: var(--muted); }
.ade-debug-rule.on, .ade-debug-op.on { background: color-mix(in srgb, var(--accent, #2563eb) 10%, var(--bg)); }
.ade-debug-rule.inactive .ade-debug-reason { font-style: italic; }
.ade-debug-detail { display: grid; gap: 5px; }
.ade-debug-hint { color: #b34c00; margin: 2px 0; }
.ade-debug-overlay { pointer-events: none; }
.ade-debug-mark { fill: none; stroke: #ef7200; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.ade-debug-mark.far { stroke-dasharray: 7 4; }
.ade-debug-mark.area, .ade-debug-mark.hole { fill: #ef720025; fill-rule: evenodd; }
.adv-svg .ade-debug-hidden { display: none; }
.ade-debug-mode .adv-svg .adv-panel, .ade-debug-mode .adv-svg [data-k] { cursor: default; }
.ade-side .lbl { font-size: 12.5px; }
.ade-side .field { padding: 5px 8px; }
.ade-new, .ade-props, .ade-corner { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.ade-props { border-color: var(--accent); }
.ade-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ade-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.ade-list { display: flex; flex-direction: column; gap: 3px; }
.ade-it { display: flex; align-items: center; gap: 8px; text-align: left; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); cursor: pointer; white-space: normal; font-size: 13px; }
.ade-it.on { border-color: var(--accent); background: var(--accent-bg); }
.ade-it.bad { border-color: var(--err); }
.ade-it.bad b { color: var(--err); }
.ade-hrow .field.sm { width: 80px; padding: 3px 6px; }
.ade-hrow .muted { flex: 1; }
.ade-btns { justify-content: flex-start !important; margin: 0 !important; }
.ade-chips, .ade-pr { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.ade-pr > .muted { width: 60px; }
.ade-presets { display: flex; flex-direction: column; gap: 4px; }
button.chip { padding: 3px 9px; font-size: 12.5px; border-radius: 12px; }
button.chip.on { background: var(--accent-bg); border-color: var(--accent); color: var(--accent-d); font-weight: 600; }
.ade-angles { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; }
.ade-angles b { width: 100%; }
.ade-foot { display: flex; gap: 4px 16px; align-items: flex-start; font-size: 13px; min-height: 22px; flex-wrap: wrap; }
.ade-errs { flex: 1; color: var(--err); }
.ade-errs .ok-text { color: var(--ok); }
.ade-cost { color: var(--muted); }
.ade.ro .ade-side input, .ade.ro .ade-side select { background: var(--ro); }
.adv-svg { display: block; user-select: none; font: 12px system-ui, sans-serif; }
.adv-svg.edit .adv-panel { cursor: crosshair; }
.adv-svg.edit [data-k] { cursor: move; }
.adv-box { fill: none; stroke: var(--muted); stroke-width: .8; stroke-dasharray: 4 3; }
.adv-panel { fill: var(--panel); stroke: var(--text); stroke-width: 1.6; }
.adv-panel.bad { stroke: var(--err); }
.adv-edge-panel { fill: var(--ro); stroke: var(--text); stroke-width: 1; }
.adv-svg.edit .adv-edge-panel { cursor: crosshair; }
.adv-edge-hole circle { fill: #ffedd5; stroke: #c2650b; stroke-width: 1.4; }
.adv-edge-hole.sel circle { stroke-width: 2.6; }
.adv-edge-hole.bad circle { fill: var(--err-bg); stroke: var(--err); }
.adv-edge-proj line { stroke: #c2650b; stroke-width: 1.7; stroke-dasharray: 4 2; }
.adv-edge-proj circle { fill: #c2650b; }
.adv-edge-proj.sel line { stroke-width: 2.6; }
.adv-edge-proj.bad line { stroke: var(--err); }
.adv-svg ellipse.hit { fill: transparent !important; stroke: transparent !important; }
.adv-dim { stroke: var(--muted); stroke-width: .8; }
.adv-t { fill: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }
.adv-t.big { font-weight: 600; }
.adv-t.sm { font-size: 11px; fill: var(--muted); }
.adv-t.sel, .adv-lead.sel { fill: var(--accent); }
.adv-t.ang { fill: #b35c00; font-weight: 600; }
.adv-lead { stroke: var(--accent); stroke-width: .9; stroke-dasharray: 4 2; fill: none; }
.adv-lead.al { stroke: var(--muted); stroke-dasharray: none; }
.adv-axis { stroke: var(--muted); stroke-width: .8; stroke-dasharray: 8 3 2 3; }
.adv-hole circle { fill: var(--accent-bg); stroke: var(--accent); stroke-width: 1.4; }
.adv-hole.far circle { stroke-dasharray: 3 2; fill: transparent; }
.adv-hole.far, .adv-groove.far { opacity: .55; }
.adv-hole.far.sel, .adv-groove.far.sel { opacity: 1; }
.adv-hole.hinge circle { stroke: #6b4fbf; }
.adv-hole.thr circle { fill: var(--accent); fill-opacity: .35; }
.adv-hole .adv-x { stroke: var(--accent); stroke-width: 1; }
.adv-hole .adv-hl { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 2 2; }
.adv-hole.sel circle { stroke-width: 2.6; }
.adv-hole.bad circle { stroke: var(--err); fill: var(--err-bg); }
.adv-svg circle.hit, .adv-svg line.hit { fill: transparent !important; stroke: transparent !important; stroke-width: 14; stroke-dasharray: none !important; }
.adv-groove polygon { fill: url(#adv-hatch); stroke: #8a5a00; stroke-width: 1.2; }
.adv-groove.far polygon { stroke-dasharray: 5 3; }
.adv-groove.sel polygon { stroke-width: 2.4; }
.adv-groove.bad polygon { stroke: var(--err); }
.adv-hatch { stroke: #c98a1a; stroke-width: 1.4; }
.adv-corner { fill: var(--panel); stroke: var(--accent); stroke-width: 1.6; }
.adv-corner.sel { fill: var(--accent); }
.adv-legend { position: absolute; left: 8px; top: 6px; display: flex; gap: 12px; font-size: 11.5px; color: var(--muted); pointer-events: none; }
.adv-legend .lg { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1.4px solid var(--accent); vertical-align: -2px; margin-right: 4px; }
.adv-legend .lg.far { border-style: dashed; opacity: .55; }
.adv-legend .lg.near { background: var(--accent-bg); }
.adv-svg.v-back .adv-panel { fill: var(--ro); }
.adv-view { position: absolute; right: 8px; top: 6px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; pointer-events: none; color: var(--accent-d); background: var(--accent-bg); }
.adv-view.back { color: #fff; background: #6b4fbf; }
.adv-legend .lg.thr { background: var(--accent); opacity: .5; }
.ed-grid .drl-cell button.adv { flex: none; padding: 3px 2px; color: var(--muted); position: relative; }
.ed-grid .drl-cell button.adv:hover { color: var(--accent); }
.ed-grid .drl-cell button.adv.has { color: var(--accent); }
.ed-grid .drl-cell .adv-n { position: absolute; top: -5px; right: -6px; font-size: 10px; line-height: 1; color: #fff; background: var(--accent); border-radius: 7px; padding: 1px 3px; font-weight: 600; }
.ed-grid .drl-cell .adv-n:empty { display: none; }
@media (max-width: 860px) {
  .modal-box.ade-box { height: auto; max-height: 96vh; overflow: auto; }
  .ade-main { flex-direction: column; }
  .ade-cv { min-height: 55vh; }
  .ade-side { width: auto; }
  .ade-debug-mode .ade-side { width: auto; }
}
/* настройки расширенной присадки */
.adv-set table { border-collapse: collapse; width: 100%; font-size: 13px; }
.adv-set th, .adv-set td { padding: 3px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.adv-set td input.field { width: 64px; padding: 4px 6px; }
.adv-set td input.wide { width: 100%; min-width: 140px; }
.adv-set fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; overflow-x: auto; }
.adv-set legend { font-weight: 600; padding: 0 4px; }
.adv-set .row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: flex-end; }
.adv-set .row .lbl .field { width: 110px; }
.adv-set .row .lbl .field.wide { width: 260px; }
.adv-set .dr { border: 1px dashed var(--line-strong); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
html[data-theme="dark"] .adv-t.ang { fill: #ffb35c; }
html[data-theme="dark"] .adv-groove polygon { stroke: #e0a640; }
html[data-theme="dark"] .adv-hole.hinge circle { stroke: #a58cf0; }
.adv-ext { stroke: var(--muted); stroke-width: .7; }
.adv-dl { stroke: var(--text); stroke-width: .8; }
.adv-arr { fill: var(--text); stroke: none; }
.adv-ext.sel, .adv-dl.sel { stroke: var(--accent); }
.adv-arr.sel { fill: var(--accent); }
.adv-dl.big { stroke-width: .9; }
.adv-lead, .adv-t, .adv-dim, .adv-axis, .adv-box, .adv-hl, .adv-x, .adv-ext, .adv-dl, .adv-arr { pointer-events: none; }
html[data-theme="dark"] .adv-edge-hole circle { fill: #513319; stroke: #ffb35c; }

/* точка отсчёта: значки углов */
.ade-refs { display: flex; gap: 6px; margin-top: 2px; }
.ade-ref { padding: 3px; line-height: 0; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--panel); }
.ade-ref svg { display: block; }
.ade-ref .r-p { fill: var(--ro); stroke: var(--muted); stroke-width: 1.2; }
.ade-ref .r-a { stroke: var(--muted); stroke-width: 1.2; fill: none; }
.ade-ref .r-d { fill: var(--muted); }
.ade-ref:hover .r-d, .ade-ref:hover .r-a { fill: var(--accent); stroke: var(--accent); }
.ade-ref:hover .r-a { fill: none; }
.ade-ref.on { border-color: var(--accent); background: var(--accent-bg); box-shadow: 0 0 0 2px var(--accent); }
.ade-ref.on .r-p { stroke: var(--accent); }
.ade-ref.on .r-a { stroke: var(--accent); stroke-width: 1.6; }
.ade-ref.on .r-d { fill: var(--accent); }
html[data-theme="dark"] .ade-ref { background: #151920; }
html[data-theme="dark"] .ade-ref.on { background: var(--accent-bg); }

/* «Сервер» → «Расчёт цен клиентами» */
.pu-cfg { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin: 10px 0; }
.pu-cfg .field { width: 110px; }
tr.pu-warm td { background: rgba(212, 167, 44, .14); }
tr.pu-hot td { background: var(--err-bg); }

/* Расчёт операций (opcalc.js) */
.opc-tabs { margin: 10px 0 12px; flex-wrap: wrap; }
.opc-t td { vertical-align: top; }
.opc-t .field.wide { width: 100%; min-width: 180px; }
.opc-n { width: 90px; text-align: right; }
.opc-u { width: 80px; }
.opc-f { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; }
.opc-f .lbl { font-size: 12px; }
.opc-kinds { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 6px 0; }
.opc-p { margin: 8px 0; }
.opc-p summary { cursor: pointer; }
.opc-pp { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0; font-size: 12px; }
.opc-rules select.wide { max-width: 320px; }
.settings.opc { max-width: 1280px; }
.settings.product-operations { max-width: 1400px; min-width: 0; }
.product-operations table.grid th { white-space: normal; }
.product-operations th.sortable { cursor: pointer; }
.product-operations td:nth-child(1) { min-width: 170px; }
.product-operations td:nth-child(2) { min-width: 180px; }
.product-operations td:nth-child(3) { min-width: 85px; }
.product-operations td:nth-child(4) { min-width: 140px; }
.product-operations td:nth-child(6) { min-width: 130px; text-align: center; }
.product-operations .field { width: 100%; }
.product-operations .pw-row { flex-wrap: wrap; }
.opc-f .lbl { flex-direction: row; align-items: center; gap: 4px; white-space: nowrap; }
.opc-f .field { padding: 3px 6px; }
.opc-f .opc-n { width: 70px; }
.opc-rules td:nth-child(3) { min-width: 380px; }
.opc-rules select.wide { max-width: 100%; width: 100%; }
.opc-gp { position: relative; min-width: 150px; }
.opc-gp summary { cursor: pointer; list-style: none; white-space: normal; max-width: 220px; }
.opc-gp summary::-webkit-details-marker { display: none; }
.opc-gp-list { display: flex; flex-direction: column; gap: 4px; padding: 6px 4px; }
.opc-gp-list label { display: flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 13px; }
.opc-flt { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin-bottom: 10px; }
.opc-flt .opc-q .field { width: 240px; }
.opc-flt select.field { max-width: 240px; }
.opc-flt #opc-cnt { align-self: center; }
.opc-t th.sortable { cursor: pointer; user-select: none; }
.opc-t th.sortable:hover { color: var(--accent); }
.opc-t .sort-ic { color: var(--accent); }
@media (max-width: 800px) {
  .opc-flt { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .opc-flt .opc-q { grid-column: 1 / -1; }
  .opc-flt .field, .opc-flt .opc-q .field, .opc-flt select.field { width: 100%; max-width: none; }
}

/* ---------- 3D просмотр панели (panel3d.js) ---------- */
.dv-head { display: flex; align-items: flex-start; gap: 12px; }
.dv-head h2 { flex: 1; }
.p3d { position: fixed; inset: 0; z-index: 78; background: rgba(20,24,33,.45); display: flex; align-items: center; justify-content: center; padding: 12px; }
html[data-theme="dark"] .p3d { background: rgba(0,0,0,.6); }
.p3d-box { background: var(--panel); color: var(--text); border-radius: 10px; width: min(1280px, 98vw); height: 94vh; display: flex; flex-direction: column;
           gap: 8px; padding: 12px 14px; box-shadow: 0 12px 40px rgba(0,0,0,.35); }
.p3d-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.p3d-head h2 { margin: 0; }
.p3d-head .err-text { min-height: 0; }
.p3d-chk { margin: 0 !important; white-space: nowrap; }
.p3d-main { flex: 1; min-height: 0; display: flex; gap: 10px; }
.p3d-side { width: 270px; flex: none; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 8px; }
.p3d-grp { display: flex; flex-direction: column; gap: 2px; }
.p3d-side button { text-align: left; white-space: normal; border-color: transparent; background: none; padding: 5px 8px; border-radius: 6px; }
.p3d-side button:hover { background: var(--row-hover); }
.p3d-side button.on { background: #fff1e5; border-color: #ff7a00; }
html[data-theme="dark"] .p3d-side button.on { background: #3a2614; }
.p3d-gh { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--line) !important; border-radius: 6px 6px 0 0 !important; }
.p3d-it { display: flex; flex-direction: column; gap: 1px; padding-left: 14px !important; }
.p3d-cv { flex: 1; min-width: 0; position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
          background: radial-gradient(circle at 50% 40%, #fbfcfd, #e3e7ec); touch-action: none; }
html[data-theme="dark"] .p3d-cv { background: radial-gradient(circle at 50% 40%, #2a303b, #13161c); }
.p3d-cv canvas { display: block; position: absolute; left: 0; top: 0; cursor: grab; }
.p3d-cv canvas:active { cursor: grabbing; }
.p3d-labels { position: absolute; inset: 0; pointer-events: none; }
.p3d-dim { position: absolute; left: 0; top: 0; font: 600 13px system-ui, sans-serif; color: var(--accent-d); background: var(--panel);
           padding: 0 4px; border-radius: 4px; opacity: .92; white-space: nowrap; font-variant-numeric: tabular-nums; }
html[data-theme="dark"] .p3d-dim { color: #9fb7ff; }
.p3d-info { position: absolute; left: 10px; bottom: 10px; max-width: calc(100% - 20px); background: var(--panel); border: 1px solid #ff7a00;
            border-radius: 8px; padding: 6px 10px; font-size: 13px; pointer-events: none; }
.p3d-hint { position: absolute; right: 10px; top: 8px; max-width: 46%; text-align: right; pointer-events: none; }
.p3d-side-lbl { position: absolute; left: 10px; top: 8px; font-size: 12px; font-weight: 600; color: var(--muted); pointer-events: none; }
@media (max-width: 760px) {
  .p3d { padding: 0; }
  .p3d-box { width: 100vw; height: 100vh; border-radius: 0; padding: 10px; }
  .p3d-main { flex-direction: column; }
  .p3d-side { width: auto; max-height: 30vh; }
  .p3d-hint { display: none; }
}
.dv-bbox { fill: none; stroke: var(--muted); stroke-width: .8; stroke-dasharray: 4 3; }
.dv-gr { fill: var(--cell); stroke: var(--text); stroke-width: .8; }
.dv-ah { fill: none; stroke: var(--text); stroke-width: 1.1; }
.dv-gr.back, .dv-ah.back { stroke-dasharray: 3 2; }
.dv-ah.thr { fill: var(--text); stroke-dasharray: none; }
.dv-edge { stroke: #c2650b; stroke-width: 1.4; stroke-dasharray: 3 2; }

/* ---------- Мобильная версия (mobile.js): экран до 760 px ---------- */
.m-burger, .m-total, .m-filt { display: none; }
@media (max-width: 760px) {
  main { padding: 8px 8px 0; }
  .head-row { gap: 6px; }
  .head-row h1 { font-size: 18px; }
  .head-row button, .head-row .btn { padding: 6px 10px; }

  /* меню ☰: шапка в одну строку, пункты — в выезжающей панели */
  header { flex-wrap: nowrap; height: 48px; min-height: 48px; padding: 0 8px; gap: 6px; }
  header .brand { margin-right: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  header .spacer { display: none; }
  .m-burger { display: inline-flex; align-items: center; color: #fff; border-color: transparent; background: none; padding: 8px; }
  header > nav, header > .theme-btn, header > .who, header > #btn-pass, header > #btn-logout { display: none; }
  header.m-open { position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 84vw); height: auto; z-index: 90;
                  flex-direction: column; align-items: stretch; padding: 8px 0 16px; gap: 2px; overflow-y: auto; }
  header.m-open::after { content: ""; position: fixed; top: 0; bottom: 0; right: 0; left: min(300px, 84vw); background: rgba(10,14,20,.45); }
  header.m-open .m-burger { align-self: flex-start; margin-left: 4px; }
  header.m-open .brand { flex: none; padding: 4px 16px 10px; white-space: normal; }
  header.m-open > nav { display: flex; flex-direction: column; align-items: stretch; gap: 0; border-top: 1px solid #2f3746; border-bottom: 1px solid #2f3746; padding: 6px 0; flex: none; }
  header.m-open nav a { padding: 11px 16px; border-radius: 0; font-size: 15px; }
  header.m-open nav a.on { box-shadow: inset 3px 0 0 var(--accent); }
  header.m-open .nav-menu-toggle { width: 100%; text-align: left; padding: 11px 16px; border-radius: 0; font-size: 15px; }
  header.m-open .nav-service-links { position: static; min-width: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: #151b27; }
  header.m-open .nav-service-links a, header.m-open .nav-service-links button { padding: 11px 16px 11px 30px; font-size: 15px; }
  header.m-open .m-burger { order: -3; }
  header.m-open .brand { order: -2; }
  header.m-open > .who { display: block; order: -1; padding: 0 16px 10px; white-space: normal; }
  header.m-open > .theme-btn::after { content: " Тема оформления"; vertical-align: 2px; }
  header.m-open > .theme-btn, header.m-open > #btn-pass, header.m-open > #btn-logout { display: block; text-align: left; border: 0; border-radius: 0; padding: 11px 16px; font-size: 15px; }
  header.m-open > .theme-btn { margin-top: auto; }
  body.m-menu { overflow: hidden; }

  /* список заказов карточками */
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; }
  .filters .lbl, .filters .chk { min-width: 0; }
  .filters .field { width: 100% !important; max-width: none !important; }
  .filters .status-filter { width: auto; }
  .filters .status-filter summary { box-sizing: border-box; }
  .filters .lbl:has(#f-q) { grid-column: 1 / -1; }
  .filters:not(.m-more) > :not(.lbl:has(#f-q)):not(.lbl:has(#f-status)):not(.m-filt) { display: none; }
  .m-filt { display: block; align-self: end; }
  .filters.m-more .m-filt { grid-column: 1 / -1; }
  table.grid.list { display: block; min-width: 0; }
  table.grid.list thead { display: none; }
  table.grid.list tbody { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
  table.grid.list tr[data-id] { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-auto-flow: row dense; column-gap: 12px; row-gap: 3px;
                                border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--panel); }
  table.grid.list tr[data-id] td { display: block; border: 0; padding: 0; background: none !important; grid-column: 1; font-size: 13px; min-width: 0; text-align: left; }
  table.grid.list tr[data-id] td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); }
  table.grid.list tr[data-id] td:empty { display: none; }
  table.grid.list tr[data-id] td[data-k="title"] { grid-row: 1; font-size: 15px; font-weight: 600; align-self: center; }
  table.grid.list tr[data-id] td[data-k="title"]::before, table.grid.list tr[data-id] td[data-k="status"]::before,
  table.grid.list tr[data-id] td[data-k="cost"]::before, table.grid.list tr[data-id] td[data-k="no"]::before { content: none !important; }
  table.grid.list tr[data-id] td[data-k="no"] { grid-column: 1 / -1; color: var(--muted); }
  table.grid.list tr[data-id] td[data-k="status"] { grid-column: 2; grid-row: 1; justify-self: end; }
  table.grid.list tr[data-id] td[data-k="status"] select { max-width: 100%; }
  table.grid.list tr[data-id] td[data-k="positions"], table.grid.list tr[data-id] td[data-k="pieces"], table.grid.list tr[data-id] td[data-k="area"] { grid-column: 2; }
  table.grid.list tr[data-id] td[data-k="comment"] { grid-column: 1 / -1; }
  table.grid.list .m-foot { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
  table.grid.list tr[data-id] .m-foot td { grid-column: auto; display: flex; align-items: center; }
  table.grid.list tr[data-id] .m-foot td.acts { flex-wrap: wrap; gap: 6px; }
  table.grid.list tr[data-id] .m-foot td.acts:has([data-more]) [data-del] { display: none; }
  table.grid.list tr[data-id] .m-foot td[data-k="cost"] { margin-left: auto; font-size: 15px; white-space: nowrap; }
  table.grid.list tr[data-id] .m-foot td[data-k="cost"] b { font-weight: 700; }
  .row-menu .rm-del { border-top: 1px solid var(--line); }
  .rm-del b { color: var(--err); }
  .rm-del b::before { background: var(--err); }
  table.grid.list tr.empty-row td { display: block; border: 0; }
  table.grid.list tfoot { display: block; }
  table.grid.list tfoot tr.tot { display: flex; justify-content: flex-end; gap: 12px; padding: 4px 12px 10px; }
  table.grid.list tfoot tr.tot td { border: 0; padding: 0; position: static; background: none; }
  table.grid.list tfoot tr.tot td:empty { display: none; }

  /* форма заказа: «Позиция» и «Стоимость», остальное — под строкой */
  #e-scroll { max-height: none !important; overflow: visible; }
  .ed-grid { min-width: 0 !important; display: block; }
  .ed-grid thead { display: none; }
  .ed-grid tbody { display: block; }
  .ed-grid tr.m-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; position: relative; padding: 10px 12px;
                      border-bottom: 1px solid var(--line); cursor: pointer; }
  .ed-grid tr.m-row::before { content: attr(data-msum1); grid-column: 1 / -1; grid-row: 1; padding-right: 104px; font-weight: 600; font-size: 14px; }
  .ed-grid tr.m-row::after { content: attr(data-msum2); grid-column: 1 / -1; grid-row: 2; margin-top: -8px; padding-right: 104px;
                             font-size: 12.5px; color: var(--muted); }
  .ed-grid tr.m-row[data-msum2=""]::after { display: none; }
  .ed-grid tr.m-row.m-drill::before { content: attr(data-msum1) "  ⦾"; }
  .ed-grid tr.m-row td { display: none; border: 0 !important; padding: 0; min-width: 0; background: none !important; box-shadow: none !important; position: static; }
  .ed-grid tr.m-row td[data-c="sum"] { display: block !important; white-space: nowrap; position: absolute !important; right: 12px; top: 10px; font-weight: 700; font-size: 14px; padding: 0; }
  .ed-grid tr.m-row:not(.m-open) td[data-c="sum"]::after { content: " ▾"; color: var(--muted); font-weight: 400; }
  .ed-grid tr.m-row:not(.m-open) td { pointer-events: none; }
  .ed-grid tr.m-row.m-empty:not(.m-open) { display: none; }
  .ed-grid tr.m-row.m-open { background: var(--accent-bg); cursor: default; }
  .ed-grid tr.m-row.m-open td[data-c="sum"]::after { content: " ▴"; color: var(--muted); font-weight: 400; }
  .ed-grid tr.m-row.m-open td { display: flex; flex-direction: column; gap: 2px; }
  .ed-grid tr.m-row.m-open td::before { font-size: 11px; color: var(--muted); }
  .ed-grid tr.m-row.m-open td:nth-child(1)::before { content: "Позиция"; }
  .ed-grid tr.m-row.m-open td:nth-child(2)::before { content: "Вид изделия"; }
  .ed-grid tr.m-row.m-open td:nth-child(3)::before { content: "Фрезеровка"; }
  .ed-grid tr.m-row.m-open td:nth-child(4)::before { content: "Декор"; }
  .ed-grid tr.m-row.m-open td:nth-child(5)::before { content: "Покрытие"; }
  .ed-grid tr.m-row.m-open td:nth-child(6)::before { content: "Текстура"; }
  .ed-grid tr.m-row.m-open td:nth-child(7)::before { content: "Двухсторонний"; }
  .ed-grid tr.m-row.m-open td:nth-child(8)::before { content: "Высота, мм"; }
  .ed-grid tr.m-row.m-open td:nth-child(9)::before { content: "Ширина, мм"; }
  .ed-grid tr.m-row.m-open td:nth-child(10)::before { content: "Толщина, мм"; }
  .ed-grid tr.m-row.m-open td:nth-child(11)::before { content: "Количество, шт."; }
  .ed-grid tr.m-row.m-open td:nth-child(12)::before { content: "Присадка под петли"; }
  .ed-grid tr.m-row.m-open td[data-c="unit"]::before { content: "Цена за шт."; }
  .ed-grid tr.m-row.m-open td:nth-child(3), .ed-grid tr.m-row.m-open td:nth-child(4),
  .ed-grid tr.m-row.m-open td:nth-child(12) { grid-column: 1 / -1; }
  .ed-grid tr.m-row.m-open td { width: auto !important; }
  .ed-grid tr.m-row.m-open td.pos { display: grid; grid-template-columns: 80px auto; justify-content: start; align-items: center; column-gap: 6px; }
  .ed-grid tr.m-row.m-open td.pos::before { grid-column: 1 / -1; }
  .ed-grid tr.m-row td.pos .drag { display: none; }
  .ed-grid tr.m-row.m-open td.pos input.posn { width: 104px; }
  .ed-grid tr.m-row.m-open td[data-c="unit"] { justify-content: flex-start; text-align: left; font-size: 14px; }
  .ed-grid tr.m-row.m-open td[data-c="unit"]:empty { display: none; }
  .ed-grid tr.m-row.m-open td:last-child { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; }
  .ed-grid tr.m-row.m-open td:last-child:empty { display: none; }
  .ed-grid tr.m-row.m-open td:last-child button[data-rm] { font-size: 13px; color: var(--err); border: 1px solid var(--err); padding: 6px 12px; }
  .ed-grid tr.m-row.m-open td:last-child button[data-rm]::after { content: " Удалить строку"; }
  .ed-grid tr.m-row.m-open:not([data-mkind="painted"]) td.fin, .ed-grid tr.m-row.m-open:not([data-mkind="facade"]) td.tex { display: none; }
  .ed-grid tr.m-row.m-open td.ds:has(input:disabled:not(:checked)) { display: none; }
  .ed-grid tr.m-row.m-open td.ds { flex-direction: row; align-items: center; gap: 8px; }
  .ed-grid tr.m-row.m-open td.ds input { width: 22px; height: 22px; }
  .ed-grid tr.m-row.m-open td input, .ed-grid tr.m-row.m-open td select { font-size: 16px; padding: 7px 8px; background-color: var(--panel); min-height: 38px; }
  .ed-grid tr.m-row.m-open td input.posn { font-size: 15px; }
  .ed-grid tr.m-row.m-open td select, .ed-grid tr.m-row.m-open td input:not([type="checkbox"]) { width: 100%; min-width: 0; }
  .ed-grid tr.m-row.m-open td.pos input.posn { width: 104px; grid-row: 2; grid-column: 1; }
  .ed-grid tr.m-row.m-open td.pos button.cp { grid-row: 2; grid-column: 2; padding: 8px; margin: 0; }
  .ed-grid tr.m-row.m-open .drl { min-width: 0; }
  .ed-grid.ro tr.m-row.m-open td input, .ed-grid.ro tr.m-row.m-open td select { background-color: transparent; background-image: none !important; border-color: transparent; padding-left: 0; min-height: 0; text-align: left; }
  .ed-grid tfoot { display: none; }

  /* итог и «+ Позиция» внизу экрана */
  .ed-foot { position: sticky; bottom: 0; z-index: 5; background: var(--panel); border-top: 1px solid var(--line);
             display: flex; align-items: center; gap: 8px; padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px)); flex-wrap: nowrap; }
  .ed-foot #e-sum, .ed-foot #e-add10, .ed-foot #e-csvin { display: none; }
  .m-total { display: flex; flex-direction: column; margin-right: auto; line-height: 1.2; }
  .m-total small { color: var(--muted); font-size: 11.5px; }
  .m-total b { font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .ed-foot #e-add1 { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; padding: 9px 14px; }
  .ed-foot #e-add1 { font-size: 0; }
  .ed-foot #e-add1::after { content: "+ Позиция"; font-size: 14px; }
  .ed-head .totals { display: none; }

  /* выпадающие списки фрезеровки и декора — во всю ширину */
  .dd { left: 8px !important; right: 8px; width: auto !important; max-width: none !important; }
  .dd-it { padding: 8px 10px; white-space: normal; }
  .msg { left: 12px; right: 12px; bottom: 76px; max-width: none; }

  /* «Заказ сейчас открыт»: кнопки друг под другом во всю ширину */
  .lock-panel { margin: 8px 0; }
  .lock-panel h2 { font-size: 17px; }
  .lock-panel .pw-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .lock-panel .pw-row > button { width: 100%; padding: 10px 12px; white-space: normal; }
  .lock-panel .pw-row > a { margin: 4px 0 0 !important; padding: 8px; text-align: center; }
}

/* ---------- Пользователи и клиенты: вкладки, фильтры, сортировка по столбцам ---------- */
.uc-tabs button .muted { font-weight: 400; }
.uc-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.uc-filters .uc-q .field { width: 260px; }
.uc-filters .field { min-width: 0; }
.uc-filters #uc-count { align-self: center; }
.uc-grid th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.uc-grid th.sortable:hover { color: var(--accent); }
.uc-grid .sort-ic { color: var(--accent); }
.uc-groups { margin-bottom: 16px; }
.uc-groups > summary { cursor: pointer; padding: 12px 14px; user-select: none; }
.uc-groups[open] > summary { border-bottom: 1px solid var(--line); }
.uc-gbar { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
@media (max-width: 760px) {
  .uc-tabs button { flex: 1; }
  .uc-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; }
  .uc-filters .uc-q { grid-column: 1 / -1; }
  .uc-filters .field, .uc-filters .uc-q .field { width: 100%; }
  .uc-filters .spacer { display: none; }
  .uc-filters #uc-count { justify-self: end; }
  .uc-tabs { gap: 6px; margin-bottom: 8px; }
  .uc-tabs button { padding: 8px 6px; white-space: nowrap; }
  .uc-groups { margin-bottom: 8px; }
  .uc-groups > summary { padding: 10px; }
  .uc-gbar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .uc-gbar .spacer { display: none; }
  .uc-grid .field { min-width: 0; }
}

/* гостевой вход и заявки на учётную запись */
.login-alt { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.login-help { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.login-help .btn { text-align: center; }
.modal-box.login-video-modal { width: 100%; max-width: 960px; max-height: calc(100dvh - 32px); overflow-y: auto; }
.login-video-modal .head-row { justify-content: space-between; }
.login-video-frame { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; background: #000; }
.modal-box.help-file-modal { width: 100%; max-width: 640px; max-height: calc(100dvh - 32px); overflow-y: auto; }
.help-file-list { display: flex; flex-direction: column; gap: 4px; min-height: 80px; max-height: 40vh; overflow-y: auto; }
.help-file-list button { text-align: left; white-space: normal; overflow-wrap: anywhere; }
.help-file-modal .pw-row { flex-wrap: wrap; }
.help-file-modal .muted { overflow-wrap: anywhere; }
button.link-btn, html[data-theme="dark"] button.link-btn { border: 0; background: none; color: var(--accent); padding: 4px; }
button.link-btn:hover, html[data-theme="dark"] button.link-btn:hover { background: none; text-decoration: underline; }
.su-form { display: flex; flex-direction: column; gap: 8px; }
.su-form textarea { resize: vertical; width: 100%; }
.su-hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.guest-banner { margin-bottom: 12px; }
.nav-badge { display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px; border-radius: 9px; background: var(--err);
  color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.nav-badge[hidden] { display: none; }

/* Файловый менеджер */
.fm-head, .fm-toolbar, .fm-breadcrumb { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fm-toolbar { margin: 14px 0; }
.fm-breadcrumb button, button.fm-name { background: transparent; border: 0; padding: 6px; text-align: left; }
.fm-filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: 12px; }
.fm-filters .field { min-width: 0; width: 100%; }
.fm-name, .fm-parent { overflow-wrap: anywhere; }
.fm-table td:first-child { min-width: 160px; max-width: 480px; }
#fm-error { white-space: pre-wrap; }
@media (max-width: 700px) {
  .fm-filters { grid-template-columns: 1fr 1fr; }
  .fm-filters .lbl:first-child { grid-column: 1 / -1; }
  .fm-table th:nth-child(2), .fm-table td:nth-child(2), .fm-table th:nth-child(4), .fm-table td:nth-child(4) { display: none; }
  .fm-table td:first-child { min-width: 100px; }
  .fm-toolbar button { min-height: 42px; }
}

/* Упаковка в картон */
.packing-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.packing-modal { max-height:94vh; overflow:auto; }
.packing-box { margin:16px 0; }
.packing-box h3 { margin:0 0 8px; }
.packing-box p { margin:6px 0; }
.packing-table { width:100%; min-width:660px; }
.packing-status { font-size:12px; white-space:normal; }
@media(max-width:600px) { .packing-fields { grid-template-columns:1fr; } }
