/* @ds-v23 (затвор: только токены) — Minta DS v3 · волна 3, полоса E: «Импорт выписки», «Категоризация», «Мастер распределения».
 *
 * Родные модули V2.3 (public/screens/v23/import.js, categorize.js, matchmaker.js) вместо прежних экранов островка `.ds22`.
 * Классы с префиксами imp- / cat- / mm- — свои у каждого экрана; готовые компоненты (panel, table, flag, status, tabs, modal)
 * стилей здесь не получают. Область загрузки и полоса записи — те же образцы, что в import.css (Xero / Twenty / Remote),
 * но без привязки к островку: у родного экрана предка `.ds22 .import` нет.
 */

/* ───────────── общее: колонка карточек ───────────── */
html.ds23 .imp-stack,
html.ds23 .cat-stack{display:flex;flex-direction:column;gap:var(--space-6);max-width:1180px;min-width:0;padding-bottom:var(--space-6)}
html.ds23 .imp-pad{padding:var(--space-5) var(--space-6) var(--space-6)}
html.ds23 .imp-scroll{overflow-x:auto}
html.ds23 .imp-scroll th{top:0}
/* fixed layout: the one width-less column gets what the fixed ones leave — on a phone that was 0px. Each table names its own minimum (--table-min), as .table-scroll does in the DS. */
html.ds23 .imp-scroll>.table-wrap>.table{min-width:max(var(--table-min,0px),var(--table-floor,0px))}
html.ds23 .imp-help{max-width:760px;margin:var(--space-5) 0 0;color:var(--text-muted);font:var(--type-body);line-height:1.55}
html.ds23 .imp-note{margin:var(--space-4) 0 0;color:var(--text-muted);font:var(--type-caption)}
html.ds23 .imp-sub{display:block;font:var(--type-caption);color:var(--text-muted)}
html.ds23 .imp-flags,
html.ds23 .cat-flags{display:flex;flex-direction:column;gap:var(--space-3);margin-top:var(--space-4)}
html.ds23 .imp-head-row{display:flex;align-items:center;justify-content:space-between;gap:var(--space-5);flex-wrap:wrap;margin-bottom:var(--space-4)}

/* ───────────── импорт: область загрузки ───────────── */
html.ds23 .imp-drop{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-2);min-height:180px;padding:var(--space-8);border:1.5px dashed var(--border-strong);border-radius:var(--radius-lg);background:var(--surface-sunken);cursor:pointer;text-align:center;transition:background-color .12s,border-color .12s}
html.ds23 .imp-drop:hover,
html.ds23 .imp-drop.is-over{border-color:var(--action-primary);background:var(--accent-mint-subtle)}
html.ds23 .imp-drop:focus-within{outline:var(--focus-ring-width) solid var(--focus-ring);outline-offset:var(--focus-ring-offset)}
html.ds23 .imp-drop-ic{display:flex;align-items:center;justify-content:center;width:48px;height:48px;margin-bottom:var(--space-3);border-radius:var(--radius-pill);background:var(--surface);color:var(--action-primary);box-shadow:var(--shadow-panel)}
html.ds23 .imp-drop-t{font:var(--type-body);font-weight:700;color:var(--text-primary)}
html.ds23 .imp-drop-a{color:var(--action-primary);text-decoration:underline;text-underline-offset:3px}
html.ds23 .imp-drop-s{font:var(--type-caption);color:var(--text-muted)}
html.ds23 .imp-drop-in{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer}

/* выбранный файл */
html.ds23 .imp-file{display:flex;align-items:center;gap:var(--space-5);padding:var(--space-4) var(--space-5);border-radius:var(--radius-lg);background:var(--surface-sunken)}
html.ds23 .imp-file-ic{display:flex;align-items:center;justify-content:center;width:36px;height:36px;border-radius:var(--radius-md);background:var(--surface);color:var(--text-secondary);box-shadow:var(--shadow-panel)}
html.ds23 .imp-file-n{flex:1;min-width:0;display:flex;flex-direction:column}
html.ds23 .imp-file-n b{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text-primary)}
html.ds23 .imp-file-n span{font:var(--type-caption);color:var(--text-muted)}

/* ───────────── импорт: строки выписки ───────────── */
html.ds23 .imp-acc{display:flex;align-items:center;gap:var(--space-3);flex-wrap:wrap}
html.ds23 .imp-acc .input{min-width:140px}
html.ds23 .imp-similar{margin-top:var(--space-3);display:flex;flex-direction:column;gap:var(--space-2)}
html.ds23 .imp-pos{color:var(--positive-strong)}
html.ds23 .imp-neg{color:var(--text-primary)}
html.ds23 .imp-runs-detail{margin-top:var(--space-5);padding-top:var(--space-4);border-top:1px solid var(--border)}
html.ds23 .imp-runs-detail li{padding:var(--space-2) 0}
html.ds23 .imp-list{margin:var(--space-3) 0 0;padding-left:var(--space-6);display:flex;flex-direction:column;gap:var(--space-2);font:var(--type-body)}

/* Excel: сетка сопоставления колонок */
html.ds23 .imp-map-head{display:flex;align-items:center;gap:var(--space-6);flex-wrap:wrap;margin-bottom:var(--space-4)}
html.ds23 .imp-map .select-wrap{min-width:180px}
html.ds23 .imp-map td{max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* полоса записи — внизу области, одна главная кнопка */
html.ds23 .imp-bar,
html.ds23 .cat-bar{position:sticky;bottom:0;z-index:2;display:flex;align-items:center;gap:var(--space-5);flex-wrap:wrap;background:var(--surface);border-radius:var(--radius-xl);box-shadow:var(--shadow-raised);padding:var(--space-4) var(--space-6)}
html.ds23 .imp-bar-grow,
html.ds23 .cat-bar-grow{flex:1;min-width:0}
html.ds23 .imp-bar-note,
html.ds23 .cat-bar-note{font:var(--type-caption);color:var(--text-muted)}

/* ───────────── категоризация ───────────── */
html.ds23 .cat-period{display:flex;align-items:flex-end;gap:var(--space-5);flex-wrap:wrap}
html.ds23 .cat-period .field{min-width:160px}
html.ds23 .cat-pos{color:var(--positive-strong)}
html.ds23 .cat-muted{color:var(--text-muted)}
html.ds23 .cat-next-text{margin:0 0 var(--space-4);color:var(--text-secondary)}
html.ds23 .cat-next-actions{display:flex;flex-wrap:wrap;gap:var(--space-3)}
html.ds23 .cat-result{font:var(--type-caption);color:var(--text-secondary)}

/* ───────────── мастер распределения ───────────── */
html.ds23 .mm{display:flex;flex-direction:column;gap:var(--space-6);max-width:900px;min-width:0;margin:0 auto;padding-bottom:var(--space-6)}
html.ds23 .mm-top{display:flex;align-items:center;gap:var(--space-5);flex-wrap:wrap}
html.ds23 .mm-top-grow{flex:1;min-width:0}
html.ds23 .mm-cap{font:var(--type-caption);color:var(--text-muted)}
html.ds23 .mm-stage{display:flex;align-items:center;gap:var(--space-5)}
html.ds23 .mm-card-wrap{flex:1;min-width:0;position:relative}
html.ds23 .mm-card{position:relative;z-index:1;display:flex;flex-direction:column;gap:var(--space-4);padding:var(--space-6) var(--space-7);border-radius:var(--radius-xl);background:var(--surface);box-shadow:var(--shadow-panel)}
html.ds23 .mm-stack-1,
html.ds23 .mm-stack-2{height:var(--space-3);margin:0 var(--space-5);border-radius:0 0 var(--radius-lg) var(--radius-lg);background:var(--surface-sunken);box-shadow:var(--shadow-panel)}
html.ds23 .mm-stack-2{margin:0 var(--space-8)}
html.ds23 .mm-meta{display:flex;align-items:center;gap:var(--space-4);flex-wrap:wrap;color:var(--text-secondary);font:var(--type-caption)}
html.ds23 .mm-meta-grow{flex:1 1 120px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
html.ds23 .mm-tools{display:flex;gap:var(--space-2);margin-left:auto}
html.ds23 .mm-amount{font:var(--type-section-title);font-weight:800;letter-spacing:var(--type-section-title-tracking)}
html.ds23 .mm-amount--in{color:var(--positive-strong)}
html.ds23 .mm-amount--out{color:var(--text-primary)}
html.ds23 .mm-cp{position:relative}
html.ds23 .mm-cp > .iconbtn{position:absolute;right:var(--space-3);top:var(--space-3)}
html.ds23 .mm-nav--off{visibility:hidden}
html.ds23 .mm-pop{position:absolute;left:0;right:0;top:100%;z-index:5;margin-top:var(--space-2);display:flex;flex-direction:column;padding:var(--space-3);border-radius:var(--radius-lg);background:var(--surface);box-shadow:var(--shadow-raised)}
html.ds23 .mm-pop-note{padding:var(--space-3) var(--space-4);font:var(--type-caption);color:var(--text-muted)}
html.ds23 .mm-pop-pick{display:flex;align-items:center;justify-content:space-between;gap:var(--space-4);padding:var(--space-3) var(--space-4);border:0;border-radius:var(--radius-md);background:transparent;color:var(--text-primary);font:var(--type-body);text-align:left;cursor:pointer}
html.ds23 .mm-pop-pick:hover,
html.ds23 .mm-pop-pick:focus-visible{background:var(--surface-sunken)}
html.ds23 .mm-pop-mark{font:var(--type-caption);color:var(--text-muted)}
html.ds23 .mm-lower{display:flex;flex-direction:column;gap:var(--space-4);max-width:750px;width:100%;margin:0 auto}
html.ds23 .mm-q-row{display:flex;align-items:center;gap:var(--space-5);flex-wrap:wrap}
html.ds23 .mm-q{font:var(--type-body);font-weight:800;color:var(--text-primary)}
html.ds23 .mm-btns{display:flex;flex-wrap:wrap;gap:var(--space-3)}
html.ds23 .mm-note{font:var(--type-caption);color:var(--text-muted)}
html.ds23 .mm-skipped-list{display:flex;flex-direction:column;gap:var(--space-2)}
html.ds23 .mm-row{display:flex;align-items:center;gap:var(--space-5);padding:var(--space-3) 0;border-bottom:1px solid var(--surface-muted)}
html.ds23 .mm-row-grow{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
html.ds23 .mm-actions-center{display:flex;gap:var(--space-4);justify-content:center;flex-wrap:wrap}
html.ds23 .mm-form{display:flex;flex-direction:column;gap:var(--space-4)}
html.ds23 .mm-list{display:flex;flex-direction:column;max-height:320px;overflow-y:auto}
html.ds23 .mm-rule .rule-cond{display:flex;flex-direction:column;gap:var(--space-2)}

/* телефон: карточка во всю ширину, стрелки уходят под неё */
@media (max-width:767px){
  html.ds23 .mm-stage{flex-wrap:wrap}
  html.ds23 .mm-card-wrap{order:-1;flex-basis:100%}
  html.ds23 .mm-card{padding:var(--space-5)}
  html.ds23 .imp-bar,
  html.ds23 .cat-bar{border-radius:var(--radius-lg);padding:var(--space-4)}
}
