/* @ds-v23 (затвор: только токены) — полоса A: справочники (public/screens/ref.js), 20.11.2026.
 *
 * Таблицы справочников (счета, юрлица, группы, проекты, контрагенты), дерево статей, общая выдвижная панель справа
 * и окна по центру — на токенах v3. Значения из данных (колонки сетки, высота строки, цвет суммы) приходят
 * присвоением --переменных в `style="--cols:…"`, свойство берётся здесь. Подписи колонок — как у таблиц v3/legacy.css
 * (капитель, --type-micro), строки 52 px, сумма прижата вправо, tabular-nums, «₽» не отрывается (nowrap).
 */

/* ───────── таблица-сетка ───────── */
html .ds22 .ref-grid{display:grid;grid-template-columns:var(--cols);align-items:center}
html .ds22 .ref-head{position:sticky;top:0;z-index:var(--z-sticky);min-height:var(--control-md);background:var(--surface);border-bottom:1px solid var(--border);color:var(--text-muted);font:var(--type-micro);letter-spacing:var(--type-micro-tracking);text-transform:uppercase}
html .ds22 .ref-th{padding:0 var(--space-5);text-align:left;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
html .ds22 .ref-th--r{text-align:right}
html .ds22 .ref-row{height:var(--h,52px);border-bottom:1px solid var(--surface-muted);cursor:pointer;background:transparent}
html .ds22 .ref-row:hover{background:var(--row-hover)}
html .ds22 .ref-row--open,html .ds22 .ref-row--open:hover{background:var(--row-selected)}
html .ds22 .ref-row--closed{opacity:.55}
html .ds22 .ref-row:focus-visible{outline:var(--focus-ring-width) solid var(--focus-ring);outline-offset:calc(var(--focus-ring-width) * -1)}
html .ds22 .ref-cell{padding:0 var(--space-5);min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--c,inherit)}
html .ds22 .ref-cell--r{text-align:right;font-variant-numeric:tabular-nums}
html .ds22 .ref-cell--b{font-weight:600}
html .ds22 .ref-two{padding:0 var(--space-5);min-width:0;overflow:hidden}
html .ds22 .ref-two > *{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
html .ds22 .ref-two__sub{color:var(--text-muted);font:var(--type-caption)}
html .ds22 .ref-money{font-variant-numeric:tabular-nums;font-weight:600;white-space:nowrap;color:var(--c,inherit)}
html .ds22 .ref-num{font-variant-numeric:tabular-nums;white-space:nowrap;color:var(--c,inherit)}
html .ds22 .ref-money--neg,html .ds22 .ref-num.ref-money--neg{color:var(--negative-strong)}
html .ds22 .ref-money--pos,html .ds22 .ref-num.ref-money--pos{color:var(--positive-strong)}
html .ds22 .ref-check{display:grid;place-items:center;min-width:var(--control-touch);min-height:var(--control-touch);cursor:pointer}
html .ds22 .ref-check--off{cursor:not-allowed}
html .ds22 .ref-check--off input{cursor:not-allowed;opacity:.45}
html .ds22 .ref-check input{cursor:pointer;accent-color:var(--action-primary)}
html .ds22 .ref-gh{display:flex;align-items:center;height:var(--control-touch);padding:0 var(--space-5) 0 calc(var(--lead, 57px) + var(--space-5));font-weight:700;color:var(--text-primary)}
html .ds22 .ref-total{height:var(--control-touch);border-top:1px solid var(--border);font-weight:600}
html .ds22 .ref-scroll{padding:0 var(--space-6)}

/* листание: две кнопки-стрелки */
html .ds22 .ref-pgbtn{width:var(--control-sm);height:var(--control-sm);border:1px solid var(--border-control);border-radius:var(--radius-md);background:var(--surface);color:var(--text-secondary);font:inherit;cursor:pointer}
html .ds22 .ref-pgbtn:disabled{cursor:not-allowed;opacity:.45}

/* ───────── панель выделения (счета, контрагенты) ───────── */
html .ds22 .ref-selbar{display:flex;flex-wrap:wrap;align-items:center;gap:var(--space-4);padding:var(--space-4) var(--space-8);background:var(--selected-accent-subtle,var(--surface-muted));border-bottom:1px solid var(--border)}
html .ds22 .ref-selbar .ds-select{width:auto;min-width:160px}

/* ───────── плашки: ошибка и пояснение в окнах ───────── */
html .ds22 .ref-note{margin:var(--space-6) 0 0}

/* ───────── дерево статей ───────── */
html .ds22 .ref-tree{border:1px solid var(--border);border-radius:var(--radius-md);overflow:hidden;background:var(--surface)}
html .ds22 .ref-node{display:flex;align-items:center;gap:var(--space-4);min-height:var(--control-md);padding:0 var(--space-4) 0 var(--ind,10px);border-bottom:1px solid var(--surface-muted);cursor:pointer}
html .ds22 .ref-node:hover{background:var(--row-hover)}
html .ds22 .ref-node--open{background:var(--row-selected)}
html .ds22 .ref-node--arch{opacity:.55}
html .ds22 .ref-node__name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
html .ds22 .ref-node__name--grp{font-weight:600}
html .ds22 .ref-node__n{color:var(--text-muted);font:var(--type-caption);font-variant-numeric:tabular-nums}
html .ds22 .ref-folder{flex:none;color:var(--text-secondary)}
html .ds22 .ref-folder--arch{color:var(--text-muted)}
html .ds22 .ref-dot{width:var(--space-4);height:var(--space-4);border-radius:var(--radius-xs);background:var(--c)}
html .ds22 .ref-menu{position:fixed;z-index:45;top:130px;left:50%;transform:translateX(-50%);min-width:230px;padding:var(--space-2) 0;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-overlay)}
html .ds22 .ref-menu button{display:block;width:100%;padding:var(--space-4) var(--space-7);border:0;background:transparent;text-align:left;font:inherit;color:var(--text-primary);cursor:pointer}
html .ds22 .ref-menu button:hover{background:var(--row-hover)}

/* ───────── выдвижная панель справа и окно по центру: шапка · тело · подвал ───────── */
html .ds22 .ref-scrim{position:fixed;inset:0;z-index:40;background:var(--scrim)}
html .ds22 .ref-panel{position:fixed;z-index:41;top:0;right:0;bottom:0;width:min(520px,100vw);display:flex;flex-direction:column;min-height:0;background:var(--surface);border-left:1px solid var(--border);box-shadow:var(--shadow-overlay)}
html .ds22 .ref-panel__head{flex:none;display:flex;align-items:center;gap:var(--space-4);padding:var(--space-6) var(--space-8);border-bottom:1px solid var(--border)}
html .ds22 .ref-panel__title{flex:1;min-width:0;margin:0;font:var(--type-body-large);font-weight:700}
html .ds22 .ref-panel__body{flex:1;min-height:0;overflow:auto;padding:var(--space-8)}
html .ds22 .ref-panel__foot{flex:none;display:flex;flex-wrap:wrap;align-items:center;gap:var(--space-4);padding:var(--space-6) var(--space-8);border-top:1px solid var(--border)}
html .ds22 .ref-win{position:fixed;z-index:41;inset:0;display:flex;align-items:flex-start;justify-content:center;padding:var(--space-12) var(--space-8);pointer-events:none}
html .ds22 .ref-win__box{pointer-events:auto;width:min(760px,100%);max-height:100%;display:flex;flex-direction:column;background:var(--surface);border-radius:var(--radius-xl);box-shadow:var(--shadow-overlay)}
html .ds22 .ref-win__box--sm{width:min(520px,100%)}
html .ds22 .ref-modal{position:fixed;z-index:calc(var(--z-modal) + 1);left:50%;top:50%;transform:translate(-50%,-50%);max-height:calc(100vh - var(--space-9));overflow:auto;background:var(--surface);border-radius:var(--radius-xl);box-shadow:var(--shadow-overlay)}
html .ds22 .ref-panel--wide{width:min(560px,100vw);z-index:calc(var(--z-modal) + 1)}
html .ds22 .ref-scrim--modal{z-index:var(--z-modal)}
html .ds22 .ref-modal{padding:var(--space-8);width:min(var(--w,520px),92vw)}
html .ds22 .ref-modal--tall{max-height:80vh;overflow:auto}
html .ds22 .ref-lab{text-transform:none}
html .ds22 .ref-grow{flex:1}
html .ds22 .ref-two-col{display:grid;grid-template-columns:1fr 1fr;gap:var(--space-6)}
html .ds22 .ref-opt{display:flex;align-items:flex-start;gap:var(--space-4);cursor:pointer}
html .ds22 .ref-opt--off{cursor:not-allowed;opacity:.55}
html .ds22 .ref-opt-hint{margin:var(--space-1) 0 0 var(--space-9);color:var(--text-muted);font:var(--type-caption)}
html .ds22 .ref-danger{color:var(--negative-strong);border-color:var(--negative-border)}
html .ds22 .ref-req{color:var(--negative-strong);font-weight:700}
html .ds22 .ref-hidden{display:none}
html .ds22 .ref-typebtn{flex:1;min-height:var(--control-touch)}
html .ds22 .ref-link{border:0;background:transparent;padding:0;font:inherit;color:var(--text-secondary);cursor:pointer;text-decoration:underline dashed}
html .ds22 .ref-link--neg{color:var(--negative-strong);text-decoration:none}
html .ds22 .ref-tab{border:0;background:transparent;cursor:pointer;font:var(--type-body);padding:var(--space-4) var(--space-5);margin-bottom:-1px;color:var(--text-muted);border-bottom:2px solid transparent}
html .ds22 .ref-tab--on{color:var(--text-primary);border-bottom-color:var(--action-primary)}
html .ds22 .ref-inline{width:auto;min-width:140px}
html .ds22 .ref-qty{text-align:right;min-height:var(--control-sm);font-variant-numeric:tabular-nums}
html .ds22 .ref-typebtn{flex-direction:column;align-items:flex-start;gap:var(--space-1);height:auto;min-height:var(--control-touch);padding:var(--space-3) var(--space-6);text-align:left}
html .ds22 .ref-typebtn__sub{font:var(--type-caption);opacity:.8}
html .ds22 .ref-sth{font:var(--type-micro);font-weight:600;color:var(--text-muted)}
html .ds22 a.ds-btn{text-decoration:none}
html .ds22 .ref-muted{color:var(--text-muted)}
html .ds22 .ref-sec{color:var(--text-secondary)}
html .ds22 .ref-neg{color:var(--negative-strong)}
html .ds22 .ref-cap{font:var(--type-caption)}
html .ds22 .ref-meta{font:var(--type-meta)}
html .ds22 .ref-h{font:var(--type-body-large);font-weight:700}
html .ds22 .ref-strong{font-weight:600}
html .ds22 .ref-bold{font-weight:700}
html .ds22 .ref-lh{line-height:1.5}
html .ds22 .ref-caps{font:var(--type-micro);letter-spacing:var(--type-micro-tracking);text-transform:uppercase;color:var(--text-muted)}
html .ds22 .ref-pg-n{color:var(--text-secondary)}
@media (max-width:767px){html .ds22 .ref-two-col{grid-template-columns:1fr}}
