/* ========= app.css =========
 */

/* ---------- Base / variables ---------- */
html { -webkit-text-size-adjust: 100%; }

:root{
  /* colors */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;

  --text: #0f172a;
  --muted: #64748b;

  --border: rgba(15,23,42,.10);
  --border-strong: rgba(15,23,42,.16);
  --row: rgba(15,23,42,.05);

  --brand: #2563eb;
  --brand-2: #1d4ed8;

  --ok: #16a34a;
  --danger: #dc2626;
  --warn: #f59e0b;

  /* sizing */
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 16px;

  --shadow: 0 10px 28px rgba(15,23,42,.07);
  --shadow-lg: 0 22px 70px rgba(15,23,42,.25);

  --container-max: 1440px;
  --container-pad: 20px;

  --topbar-h: 56px;
  --sticky-top: calc(var(--topbar-h) + 10px);
}

*{ box-sizing: border-box; }

body{
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a{ color: var(--brand); text-decoration: none; }
a:hover{ text-decoration: underline; }

/* Accessibility */
.skip-link{
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  box-shadow: var(--shadow);
}
.skip-link:focus{ left: 8px; }

.sr-only{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}

/* Icons */
.ui-icon{
  width: 18px;
  height: 18px;
  display: inline-block;
  flex: 0 0 auto;
}
.ui-icon.sm{ width: 20px; height: 20px; }
.ui-icon.lg{ width: 20px; height: 20px; }

/* ---------- App shell / navigation ---------- */
.app-topbar{
  position: sticky;
  top: 0;
  z-index: 2500;
  height: var(--topbar-h);
  background: rgba(255,255,255,.88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(10px);
}

.app-topbar__inner{
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-pad);
  height: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
}

.app-brand{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: .2px;
}
.app-brand:hover{ text-decoration:none; }
.app-brand__text{ font-size: 18px; color: var(--brand); text-transform:uppercase; font-weight:900;}

.app-nav{
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.app-nav::-webkit-scrollbar{ display:none; }

.app-nav__link{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  color: var(--text);
  border: 1px solid transparent;
  white-space: nowrap;
}
.app-nav__link:hover{ text-decoration:none; background: rgba(15,23,42,.04); }
.app-nav__link.is-active{
  background: rgba(37,99,235,.10);
  border-color: rgba(37,99,235,.25);
  color: var(--brand-2);
}

.app-topbar__right{
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-menu{
  position: relative;
}
.user-menu > summary{
  list-style: none;
  cursor: pointer;
}
.user-menu > summary::-webkit-details-marker{ display:none; }

.user-menu__summary{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.8);
  color: var(--text);
}
.user-menu__summary:hover{ background: rgba(15,23,42,.03); }
.user-menu__name{
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.user-menu__panel{
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(320px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 10px;
}

.user-menu[open] .user-menu__panel{ display:block; }
.user-menu:not([open]) .user-menu__panel{ display:none; }

.user-menu__meta{
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  margin: 0 0 8px;
}
.user-menu__meta .sub{ margin-top: 2px; }
.user-menu__title{ font-weight: 600; }

.user-menu__item{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 10px;
  border-radius: 12px;
  color: var(--text);
  text-decoration:none;
}
.user-menu__item:hover{ background: rgba(15,23,42,.04); text-decoration:none; }

/* Main container */
.app-main{ padding: var(--container-pad); }

.app-footer{ padding: 0 var(--container-pad) var(--container-pad); }
.app-footer .wrap{ display:flex; align-items:center; justify-content:space-between; }

/* legacy alias */
.wrap{ max-width: var(--container-max); margin: 0 auto; }

/* ---------- Cards / headings ---------- */
.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 14px;
  flex-wrap: wrap;
}

h1{
  font-size: 18px;
  margin: 0 0 6px;
  line-height: 1.25;
}

.sub{ color: var(--muted); font-size: 14px; }
.sub-strong{ font-weight: 800; margin: 0 0 6px; }

/* ---------- Alerts / messages ---------- */
.alert,
.msg,
.err,
.warn{
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
  margin-top: 10px;
  border: 1px solid var(--border);
  background: rgba(15,23,42,.03);
  color: var(--text);
}

.alert__title{ font-weight: 900; margin: 0 0 6px; }
.alert__list{ margin: 6px 0 0 18px; padding: 0; }
.alert__list li{ margin: 2px 0; }

.alert--info,
.msg{ background: rgba(37,99,235,.08); border-color: rgba(37,99,235,.20); color: #1e3a8a; }
.alert--error,
.err{ background: rgba(220,38,38,.08); border-color: rgba(220,38,38,.22); color: #991b1b; }
.alert--warn,
.warn{ background: rgba(245,158,11,.10); border-color: rgba(245,158,11,.25); color: #78350f; }

/* ---------- Pills / chips ---------- */
.pill{
  display:inline-flex;
  align-items:center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  background: rgba(15,23,42,.03);
  color: var(--text);
}
.pill.draft{ background: rgba(37,99,235,.10); border-color: rgba(37,99,235,.22); color: #1e3a8a; }
.pill.approved{ background: rgba(22,163,74,.10); border-color: rgba(22,163,74,.20); color: #065f46; }

/* ---------- Buttons ---------- */
.btn{
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover{ filter: brightness(.98); text-decoration:none; }
.btn:active{ transform: translateY(1px); }

.btn.secondary{ background: #334155; }
.btn.ok{ background: var(--ok); }
.btn.danger{ background: var(--danger); }

.btn.light{
  background: rgba(15,23,42,.04);
  color: var(--text);
  border-color: var(--border);
}
.btn.light:hover{ filter: brightness(.98); }

.btn.small{ padding: 8px 12px; font-size: 14px; border-radius: 12px; }
.btn:disabled{ opacity: .55; cursor: not-allowed; transform:none; }

/* aria-busy spinner (works with setButtonBusy) */
.btn[aria-busy="true"]{
  position: relative;
}
.btn[aria-busy="true"]::after{
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,.55);
  border-top-color: rgba(255,255,255,1);
  display: inline-block;
  margin-left: 8px;
  animation: ui_spin .8s linear infinite;
}
.btn.light[aria-busy="true"]::after,
.btn.secondary[aria-busy="true"]::after{
  border-color: rgba(15,23,42,.25);
  border-top-color: rgba(15,23,42,.75);
}

@keyframes ui_spin{ to{ transform: rotate(360deg); } }

.icon-btn{
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(15,23,42,.03);
  color: var(--text);
  border-radius: 999px;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn:hover{ background: rgba(15,23,42,.05); }
.icon-btn:focus-visible{ outline: 2px solid rgba(37,99,235,.35); outline-offset: 2px; }

.icon-btn.sm{ width: 32px; height: 32px; }
.icon-btn.sm .ui-icon{ width: 16px; height: 16px; }

/* ---------- Forms ---------- */
label{ font-size: 14px; color: var(--muted); }

.field{ display:flex; flex-direction:column; gap: 6px; }

.grid{ display:grid; gap: 12px; }
.grid.cols-2{ grid-template-columns: 1fr 1fr; }
@media (max-width: 900px){
  .grid.cols-2{ grid-template-columns: 1fr; }
}

.kbd{
  display:inline-block;
  font-family: ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
  font-size: 12px;
  line-height: 1.2;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(15,23,42,.04);
  border: 1px solid var(--border);
  color: var(--text);
}


input:not([type]),
input[type="text"],
input[type="search"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
input[type="week"],
select{
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 10px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}


/* Date/time inputs use native picker icons; reserve space on the right so text never overlaps. */
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
input[type="week"]{
  padding-right: 6px;
  line-height:1.4;
}
color: var(--text);
}


/* Убираем нативные украшения search-поля (иначе может быть "двойная" иконка поиска) */
input[type="search"]{
  -webkit-appearance: textfield;
  appearance: textfield;
}
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration{
  -webkit-appearance: none;
}

textarea{
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
  min-height: 60px;
  resize: vertical;
  background: #fff;
  color: var(--text);
}

.input-wrap{
  position: relative;
}
.input-wrap .ui-icon{
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  opacity: .75;
  pointer-events: none;
}
.input-wrap input{
  padding-left: 40px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible{
  outline: 2px solid rgba(37,99,235,.35);
  outline-offset: 1px;
  border-color: rgba(37,99,235,.40);
}

/* ---------- Toolbars / filters ---------- */
.toolbar{ display:flex; gap: 10px; align-items:center; flex-wrap: wrap; margin-top: 10px; }

.filters{
  display:grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr 1fr;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}
.filters .actions{ display:flex; gap: 10px; }

.inline-controls{ display:flex; gap: 10px; flex-wrap: wrap;  align-items: center;}
.inline-controls.is-end{ justify-content:flex-end; }

/* ---------- Tables ---------- */
.table-wrap{
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

table{
  border-collapse: collapse;
  width: 100%;
  min-width: 860px;
  background: #fff;
}

th,td{
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 14px;
  vertical-align: top;
}

th{
  background: rgba(15,23,42,.03);
  text-align: left;
  color: #334155;
  font-weight: 600;
  position: sticky;
  top: var(--sticky-top);
  z-index: 1;
  font-size: 15px;
}

.table-wrap th{ top: 0; }

tbody tr:hover{ background: rgba(37,99,235,.04); }

.ui-table{ width:100%; border-collapse: separate; border-spacing: 0; }
.ui-table th,.ui-table td{ vertical-align: top; }

/* Ресайз колонок (включается data-colresize="1" на таблице). */
.ui-table[data-colresize="1"] .col-resize-handle{
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 100%;
  z-index: 2;
  cursor: col-resize;
  user-select: none;
  touch-action: none;
}

.is-col-resizing,
.is-col-resizing *{
  user-select: none;
}

/* Унифицированная зебра для таблиц (включается классом is-zebra). */
/* По умолчанию: одна строка = один элемент. */
.ui-table.is-zebra:not([data-zebra]) tbody tr:nth-child(even),
.ui-table.is-zebra[data-zebra="single"] tbody tr:nth-child(even){
  background: rgba(15,23,42,.02);
}

/* Пары строк: один элемент занимает 2 строки подряд. */
.ui-table.is-zebra[data-zebra="pair2"] tbody tr:nth-child(4n+3),
.ui-table.is-zebra[data-zebra="pair2"] tbody tr:nth-child(4n+4){
  background: rgba(15,23,42,.02);
}

.muted{ color: var(--muted); }
.nowrap{ white-space: nowrap; }

/* Умное сжатие текста в 1-3 строки. */
.clamp-1{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.clamp-2,
.clamp-3{
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.clamp-2{ -webkit-line-clamp: 2; }
.clamp-3{ -webkit-line-clamp: 3; }

/* check_list: таблица проверок шире */
table.checks-table{ min-width: 1080px; }
table.checks-table tbody tr:nth-child(even){ background: rgba(15,23,42,.02); }

/* ---------- Pager ---------- */
.pager{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.pager a{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(15,23,42,.03);
  text-decoration:none;
  color: var(--text);
}
.pager a:hover{ background: rgba(15,23,42,.05); }
.pager .info{ color: var(--muted); font-size: 12px; }

/* ---------- check_view: status segments ---------- */
.seg{
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.seg input{ position:absolute; opacity:0; pointer-events:none; }
.seg label{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 10px;
  min-width: 90px;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  color: var(--text);
}
.seg label:not(:last-of-type){ border-right: 1px solid var(--border); }
.seg input:focus + label{ outline: 2px solid rgba(37,99,235,.35); outline-offset: -2px; }
.seg input:checked + label{ background: rgba(37,99,235,.10); color: var(--brand-2); }
/* Цветная активная кнопка: ОК/Риск */
.seg input[value="ok"]:checked + label{ background: rgba(22,163,74,.12); color: var(--ok); }
.seg input[value="flag"]:checked + label{ background: rgba(220,38,38,.10); color: var(--danger); }
/* Read-only: выбранная кнопка остаётся контрастной, остальные приглушаются */
.seg.is-disabled label{ cursor: default; }
.seg.is-disabled input:not(:checked) + label{ opacity: .55; }
.seg.is-disabled input:checked + label{ opacity: 1; }

/* check_view: scoring + footer */
.footer{ display:flex; align-items:center; justify-content:space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.score{ display:flex; align-items:baseline; gap: 10px; }
.score .label{ color: var(--muted); font-size: 14px; }
.score .val{ font-size: 18px; font-weight: 900; }

.btns{ display:flex; gap: 10px; flex-wrap: wrap; }
.head-right{ display:flex; align-items:center; gap: 10px; flex-wrap: wrap; }
.head-right.is-end{ justify-content:flex-end; }

/* check_view: columns */
td.icon{ width: 180px; }
td.weight{ width: 80px; white-space: nowrap; }
td.status{ width: 220px; }
td.comment{ width: 300px; }
.crit{ max-width: 650px; font-size:16px;}

.auto-cell{ display:inline-flex; align-items:center; gap: 10px; }
.auto-text{ font-size: 12px; color: var(--muted); }
.auto-cell .ui-icon{ color: rgba(15,23,42,.65); }
.auto-cell.is-ok .ui-icon{ color: var(--ok); }
.auto-cell.is-flag .ui-icon{ color: var(--danger); }
.auto-cell.is-unknown .ui-icon{ color: var(--warn); }
/* criteria: emphasize flagged criterion title cell (auto flag or expert flag)
   Требование: красный бордер не менее 7px для ячейки названия критерия.
   Реализация: псевдо-элемент слева (без влияния на layout таблицы). */
#checkCriteriaTable tbody tr.row-flag td.crit,
#checkCriteriaTable tbody tr.row-auto-flag td.crit{ position: relative; }
#checkCriteriaTable tbody tr.row-flag td.crit::before,
#checkCriteriaTable tbody tr.row-auto-flag td.crit::before{
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--danger);
}

/* draft flags */
html.is-draft .row-flag{ background: rgba(220,38,38,.06); }
html.is-draft .row-auto-flag{ background: rgba(220,38,38,.06); }
html.is-draft tbody tr.row-flag:hover,
html.is-draft tbody tr.row-auto-flag:hover{ background: rgba(220,38,38,.10); }

.row-missing{ box-shadow: inset 0 0 0 2px rgba(245,158,11,.40); background: rgba(245,158,11,.06); }

/* collapsed mode */
.table-toolbar{ display:flex; align-items:center; justify-content:space-between; gap: 10px; flex-wrap:wrap; margin: 0 0 10px; }

.mini-btn{
  appearance:none;
  border: 1px solid var(--border);
  background: rgba(15,23,42,.03);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  gap: 8px;
  color: var(--text);
  line-height: 1;
}
.mini-btn:hover{ background: rgba(15,23,42,.05); }
.mini-btn:disabled{ opacity:.55; cursor:not-allowed; }

.th-inline{ display:flex; align-items:center; justify-content:space-between; gap: 10px; }

html.is-collapsed .col-weight,
html.is-collapsed .col-explain{ display:none; }
html.is-collapsed .auto-text{ display:none; }
html.is-collapsed th.col-auto,
html.is-collapsed td.col-auto{ width: 56px !important; }

.hint{ color: var(--muted); font-size: 12px; margin-top: 10px; }

/* versions */
.versions table{ min-width: 760px; }
.versions tr.is-current{ background: rgba(37,99,235,.06); }

/* ---------- Modals ---------- */
.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 3000;
}
.modal-backdrop[hidden]{ display:none !important; }

.modal{
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}

.modal-header{ display:flex; align-items:center; justify-content:space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-title{ font-size: 16px; font-weight: 900; margin: 0; }
.modal-body{ padding: 14px 16px; }
.modal-actions{ display:flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: 14px; }

.loader{ display:flex; align-items:center; gap: 12px; }
.spinner{ width: 30px; height: 30px; border: 3px solid rgba(15,23,42,.18); border-top-color: var(--brand); border-radius: 999px; animation: ui_spin .9s linear infinite; }
.loader-title{ font-weight: 900; }
.loader-sub{ margin-top: 4px; }

/* ---------- Toasts (ui.js) ---------- */
/* Контейнер тостов: сверху по центру */
.toast-host,
#toastHost,
#toast-host {
  position: fixed;
  top: 50px;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translateX(-50%);
  z-index: 99999;

  width: min(560px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 8px;

  pointer-events: none; /* чтобы не блокировать клики по странице */
}

/* Сами тосты должны быть кликабельны (если есть кнопки/закрытие) */
.toast-host .toast,
#toastHost .toast,
#toast-host .toast {
  pointer-events: auto;
}

.toast{
  max-width: min(520px, calc(100vw - 28px));
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 12px 30px rgba(15,23,42,.16);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .18s ease, transform .18s ease;
}
.toast.is-in{ opacity: 1; transform: translateY(0); }
.toast.is-out{ opacity: 0; transform: translateY(-6px); }

.toast__msg{ flex: 1 1 auto; min-width: 0; }
.toast__close{
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(15,23,42,.04);
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.toast__close:hover{ background: rgba(15,23,42,.07); color: var(--text); }

@media (prefers-reduced-motion: reduce){
  .toast{ transition: none; }
}
.toast--error{ border-color: rgba(220,38,38,.28); background: rgba(220,38,38,.08); color: #991b1b; }
.toast--success{ border-color: rgba(22,163,74,.22); background: rgba(22,163,74,.08); color: #065f46; }

/* Унифицированные пустые состояния. */
.empty-state{
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  background: rgba(15,23,42,.02);
  padding: 14px 14px;
  color: var(--muted);
}
.empty-state .title{ color: var(--text); font-weight: 900; }
.empty-state .hint{ margin-top: 4px; }

/* Выпадающее меню (например, наборы фильтров). */
.ux-menu{ position: relative; }
.ux-menu > summary{ list-style: none; }
.ux-menu > summary::-webkit-details-marker{ display: none; }
.ux-menu__summary{ display: inline-flex; align-items: center; gap: 8px; }

.ux-menu__panel{
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 80;
  min-width: 300px;
  max-width: min(420px, calc(100vw - 24px));
  padding: 12px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 12px 30px rgba(0,0,0,.12);
}
.ux-menu[open] .ux-menu__panel{ display: block; }
.ux-menu:not([open]) .ux-menu__panel{ display: none; }
.ux-menu__title{ font-weight: 900; }

/* Окно управления колонками. */
.cols-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}
.cols-item{
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(15,23,42,.02);
  user-select: none;
}
.cols-item.is-locked{ opacity: .6; }

.cols-handle{
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: grab;
  touch-action: none;
}
.cols-handle::before{
  content: '';
  width: 12px;
  height: 12px;
  background:
    radial-gradient(circle at 2px 2px, rgba(15,23,42,.35) 1.2px, transparent 1.3px),
    radial-gradient(circle at 2px 6px, rgba(15,23,42,.35) 1.2px, transparent 1.3px),
    radial-gradient(circle at 2px 10px, rgba(15,23,42,.35) 1.2px, transparent 1.3px),
    radial-gradient(circle at 6px 2px, rgba(15,23,42,.35) 1.2px, transparent 1.3px),
    radial-gradient(circle at 6px 6px, rgba(15,23,42,.35) 1.2px, transparent 1.3px),
    radial-gradient(circle at 6px 10px, rgba(15,23,42,.35) 1.2px, transparent 1.3px);
}

.cols-drag-placeholder{
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: rgba(15,23,42,.01);
  pointer-events: none;
}

.cols-drag-ghost{
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: .92;
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
}

html.is-cols-dragging{
  cursor: grabbing;
  user-select: none;
}

/* ---------- Utilities ---------- */
.w-80{width:80px}
.w-90{width:90px}
.w-110{width:110px}
.w-120{width:120px}
.w-130{width:130px}
.w-140{width:140px}
.w-160{width:160px}
.w-180{width:180px}
.w-200{width:200px}
.w-220{width:220px}
.w-240{width:240px}
.w-300{width:300px}

.minw-120{min-width:120px}

.ta-center{text-align:center}

.m-0{margin:0}
.ml-6{margin-left:6px}

.mt-10{margin-top:10px}
.mt-12{margin-top:12px}
.mt-14{margin-top:14px}

.pl-18{padding-left:18px}

/* ---------- Responsive ---------- */
@media (max-width: 1100px){
  :root{ --container-pad: 16px; }
  .filters{ grid-template-columns: 1fr 1fr; }
  .filters .actions{ justify-content:flex-start; }
  .user-menu__name{ max-width: 170px; }
  th{ top: calc(var(--topbar-h) + 8px); }
}

@media (max-width: 720px){
  :root{ --container-pad: 14px; }
  .filters{ grid-template-columns: 1fr; }
  .app-brand__text{ display:none; }
  .user-menu__name{ max-width: 120px; }
}

@media (min-width: 1440px){
  :root{ --container-max: 1600px; --container-pad: 24px; }
  .card{ padding: 18px 22px; }
  th,td{ padding: 11px 14px; }
  h1{ font-size: 19px; }
}

@media (prefers-reduced-motion: reduce){
  *{ scroll-behavior: auto !important; }
  .btn:active{ transform:none; }
  .btn[aria-busy="true"]::after{ animation:none; }
}

/* Admin users report: compact buttons */
.admin-users-report .btn.small{ padding: 6px 10px; }
.admin-users-report .filters .actions{ align-items: flex-end; }
.admin-users-report .filters .actions .ux-menu__summary.btn{ padding: 6px 10px; }

