/* ================================
   THEME TOKENS (light/dark + force)
   ================================ */
:root {
  --bg: #f6f7fb;
  --fg: #111;
  --muted: #555;
  --card: #fff;
  --panel: #fff;
  --border: #d5d9e1;
  --bg2: #f6f8fa;
  --primary: #1f6feb;
  --link: var(--primary);
  --link-visited: #a78bfa;
  --input-bg: #fff;
  --input-border: rgba(0, 0, 0, 0.18);
  --table-divider: rgba(0, 0, 0, 0.14);
  --brand-blue: #3466ff;
  --danger: #e23d3d;
  /* controls */
  --btn-h-sm: 36px;
  --btn-px-sm: 14px;
  --btn-fs-sm: 13px;
  --btn-secondary-bg: #2e3440;
  --btn-secondary-fg: #fff;
  --push-field-h: 59px;
  --select-arrow-offset: 14px;
  /* work area */
  --work-min: 740px;
  --work-max: 3000px;
  --work-width: 4000px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --fg: #e7eaf0;
    --muted: #9aa3af;
    --card: #141922;
    --panel: #141922;
    --border: #243041;
    --bg2: #14171a;
    --primary: #3466ff;
    --input-bg: #0f141c;
    --table-divider: rgba(255, 255, 255, 0.12);
    --input-border: rgba(255, 255, 255, 0.18);
    --link-visited: #a78bfa;
  }
}
body.force-light {
  --bg: #f6f7fb;
  --fg: #111;
  --muted: #555;
  --card: #fff;
  --panel: #fff;
  --border: #d5d9e1;
  --bg2: #f6f8fa;
  --primary: #1f6feb;
  --input-bg: #fff;
  --table-divider: rgba(0, 0, 0, 0.14);
  --input-border: rgba(0, 0, 0, 0.18);
}
body.force-dark {
  --bg: #0f1216;
  --fg: #e7eaf0;
  --muted: #9aa3af;
  --card: #141922;
  --panel: #141922;
  --border: #243041;
  --bg2: #14171a;
  --primary: #3466ff;
  --input-bg: #0f141c;
  --table-divider: rgba(255, 255, 255, 0.12);
  --input-border: rgba(255, 255, 255, 0.18);
}

/* ============ BASE ============ */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell,
    Noto Sans, Helvetica Neue, Arial, sans-serif;
}
a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.container {
  max-width: 2000px;
  margin: 30px auto;
  padding: 0 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.06);
  padding: 20px;
}
h1,
h2 {
  margin: 0 0 12px;
}
hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}
.footer {
  color: #888;
  font-size: 12px;
  text-align: center;
  margin-top: 10px;
}
.pageHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 10px;
  background: color-mix(in oklab, var(--primary) 12%, transparent);
  color: color-mix(in oklab, var(--fg) 65%, var(--muted));
  margin: 6px 0;
}
.label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0 4px;
}
.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (max-width: 740px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

/* Work area */
.work-shell {
  width: 100%;
  min-height: calc(100dvh - 56px);
  background: var(--bg2, transparent);
}
.work-area {
  max-width: 2000px;
  margin: 24px auto;
  padding: 0 16px;
}

/* ============ NAV ============ */
.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.nav .logo {
  font-weight: 700;
}
.topnav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============ FLASH ============ */
.flash {
  margin: 12px 0;
}
.flash-item {
  padding: 8px 12px;
  border-radius: 10px;
  margin-bottom: 6px;
  background: #16212f;
  color: #e8e8e8;
}

/* ============ FORMS / INPUTS ============ */
input,
select,
textarea,
button {
  font: inherit;
  color: var(--fg);
}
input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  outline: none;
}
textarea {
  min-height: 84px;
}
::placeholder {
  color: var(--muted);
  opacity: 1;
}
select:invalid {
  color: var(--muted);
}
select option {
  color: var(--fg);
}
label {
  display: block;
  margin: 8px 0;
}
input[type='number'] {
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.is-invalid {
  border-color: var(--danger, #ff3b30) !important;
  box-shadow: 0 0 0 2px
    color-mix(in oklab, var(--danger, #ff3b30) 100%, transparent);
}
.is-invalid::placeholder {
  opacity: 0.9;
}

/* copy / select helpers */
.no-select {
  user-select: none;
  -webkit-user-select: none;
}
.can-select,
input,
textarea,
[contenteditable='true'] {
  user-select: text !important;
  -webkit-user-select: text !important;
}

/* Date helpers */
.picker-wrap {
  position: relative;
}
.picker-wrap .has-picker {
  padding-right: 44px;
}
.picker-wrap .date-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
}
input[type='date'] {
  padding-right: 14px;
}
@media (prefers-color-scheme: dark) {
  input[type='date']::-webkit-calendar-picker-indicator {
    filter: invert(1) brightness(1.3) contrast(1.05);
    opacity: 0.95;
  }
}
body.force-dark input[type='date']::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.3) contrast(1.05);
  opacity: 0.95;
}

/* Select arrow */
select {
  appearance: none;
  padding-right: calc(var(--select-arrow-offset) + 18px);
  background-repeat: no-repeat;
  background-position: right var(--select-arrow-offset) center;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
}
@media (prefers-color-scheme: dark) {
  select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23e7eaf0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  }
}
body.force-dark select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23e7eaf0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  min-width: 180px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--brand-blue);
  background: var(--brand-blue);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s ease, transform 0.02s ease, box-shadow 0.12s ease;
}
.btn:hover {
  filter: brightness(1.05);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand-blue) 25%, transparent);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled,
.btn[disabled] {
  opacity: 0.6;
  pointer-events: none;
}

.btn-sm {
  height: var(--btn-h-sm);
  padding: 0 var(--btn-px-sm);
  font-size: var(--btn-fs-sm);
  white-space: nowrap;
}

/* Secondary palette (tokens) */
:root {
  --btn-secondary-bg: color-mix(in oklab, var(--primary) 12%, #fff);
  --btn-secondary-fg: var(--fg);
  --btn-secondary-border: color-mix(
    in oklab,
    var(--primary) 28%,
    var(--border)
  );
}
@media (prefers-color-scheme: dark) {
  :root {
    --btn-secondary-bg: #2e3440;
    --btn-secondary-fg: #fff;
    --btn-secondary-border: transparent;
  }
}
body.force-dark {
  --btn-secondary-bg: #2e3440;
  --btn-secondary-fg: #fff;
  --btn-secondary-border: transparent;
}
body.force-light {
  --btn-secondary-bg: color-mix(in oklab, var(--primary) 12%, #fff);
  --btn-secondary-fg: var(--fg);
  --btn-secondary-border: color-mix(
    in oklab,
    var(--primary) 28%,
    var(--border)
  );
}
.btn-secondary,
.secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-fg);
  border: 1px solid var(--btn-secondary-border);
  transition: filter 0.15s ease, transform 0.02s ease, box-shadow 0.12s ease;
}
.btn-secondary:hover,
.secondary:hover {
  filter: brightness(1.05);
}
.btn-secondary:active,
.secondary:active {
  transform: translateY(1px);
}

.no-wrap {
  white-space: nowrap;
}
.actions,
.actions-cell {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.inline {
  display: inline;
}
.btn-danger {
  background: #d83a3a;
  color: #fff;
  border: 1px solid transparent;
}
.btn-danger:hover {
  filter: brightness(1.05);
}
.btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

/* ============ TOOLBAR / PILLS / PUSH ============ */
.work-shell-wide {
  min-height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: var(--bg);
}
.work-area-wide {
  width: clamp(var(--work-min), var(--work-width), var(--work-max));
  margin: 24px auto;
  padding: 0 16px;
}
@media (max-width: 768px) {
  .work-area-wide {
    width: 100%;
  }
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  align-items: start;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.pill-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* pill */
.pill {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--primary) 12%, transparent);
  color: var(--fg);
  border: 1px solid color-mix(in oklab, var(--primary) 30%, var(--border));
  transition: filter 0.15s ease, transform 0.02s ease;
  white-space: nowrap;
}
.pill:hover {
  filter: brightness(1.05);
}
.pill:active {
  transform: translateY(1px);
}
.pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.topnav .pill {
  justify-content: center;
}

/* small pills */
.head-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.pill-sm {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  border: 1px solid color-mix(in oklab, var(--primary) 30%, var(--border));
  background: color-mix(in oklab, var(--primary) 12%, transparent);
  color: var(--fg);
  text-decoration: none;
  transition: filter 0.15s, transform 0.02s;
  white-space: nowrap;
}
.pill-sm:hover {
  filter: brightness(1.05);
}
.pill-sm:active {
  transform: translateY(1px);
}
.pill-sm.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.pill-danger {
  background: var(--danger);
  border: 1px solid var(--danger);
  color: #fff;
}

/* PUSH inline */
.push-inline {
  display: grid;
  grid-template-columns: repeat(4, minmax(260px, 1fr));
  column-gap: 14px;
  row-gap: 0;
  align-items: start;
}
.push-inline .label {
  margin: 0 0 6px;
  font-size: 12px;
  line-height: 1.1;
  text-align: center;
}
.push-inline select,
.push-inline input[type='datetime-local'] {
  width: 100%;
  height: 60px;
}
.push-inline textarea {
  width: 100%;
  min-height: 36px;
  height: 36px;
  resize: none;
  overflow: hidden;
  line-height: 1.4;
}
.push-inline .fld > *:not(.label) {
  width: 100%;
  justify-self: stretch;
}
.push-inline .fld-btn {
  align-self: start;
}
.push-inline .fld-btn .btn {
  width: 100%;
  height: 79px;
}
.push-inline #pushSubmit {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}
.push-inline #pushSubmit:hover {
  filter: brightness(1.05);
}
.push-inline #pushSubmit:active {
  transform: translateY(1px);
}
@media (max-width: 1100px) {
  .push-inline {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    row-gap: 8px;
  }
}
@media (max-width: 640px) {
  .push-inline {
    grid-template-columns: 1fr;
  }
}

/* Scroll / decoys */
.decoy-field {
  position: absolute !important;
  left: -9999px !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.no-copy,
.no-copy * {
  user-select: none;
  -webkit-user-select: none;
}
.no-copy input,
.no-copy textarea,
.no-copy [contenteditable='true'] {
  user-select: text;
  -webkit-user-select: text;
}

textarea.auto-grow {
  overflow: hidden;
  resize: none;
  min-height: 36px;
  line-height: 1.4;
  max-height: 40vh;
}
textarea.auto-grow.is-maxed {
  overflow: auto;
}
textarea.center-ph {
  --ta-h: 60px;
  --lh: 1.4em;
  min-height: var(--ta-h);
  line-height: 1.4;
  box-sizing: border-box;
}
textarea.center-ph:placeholder-shown {
  padding-top: calc((var(--ta-h) - var(--lh)) / 2);
}

.push-inline select,
.push-inline input[type='datetime-local'],
.push-inline .fld-btn .btn {
  height: var(--push-field-h);
  min-height: var(--push-field-h);
}
.push-inline .fld-btn .btn {
  min-width: auto;
  padding: 0 16px;
  font-size: 14px;
  border-radius: 10px;
}
.push-inline textarea.comment {
  height: var(--push-field-h);
  min-height: var(--push-field-h);
  max-height: 40vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  resize: vertical;
  padding-right: 14px;
  line-height: 1.4;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in oklab, var(--fg) 30%, transparent) transparent;
}
.push-inline textarea.comment::-webkit-scrollbar {
  width: 8px;
}
.push-inline textarea.comment::-webkit-scrollbar-track {
  background: transparent;
}
.push-inline textarea.comment::-webkit-scrollbar-thumb {
  background: color-mix(in oklab, var(--fg) 25%, transparent);
  border-radius: 6px;
}
.push-inline textarea.comment:hover::-webkit-scrollbar-thumb {
  background: color-mix(in oklab, var(--fg) 40%, transparent);
}

/* ============ TABLES (base + responsive) ============ */
.table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 0;
  border-radius: 0;
  overflow-x: hidden;
}
.table-wrap {
  overflow-x: auto;
} /* горизонтальный скролл при необходимости */

/* Базовая таблица (унифицированная) */
.responsive-table {
  width: 100%;
  table-layout: auto;
  border-collapse: collapse;
  margin-top: 10px;
  color: var(--fg);
  font-size: 14px;
}
.responsive-table th,
.responsive-table td {
  padding: 10px 12px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  vertical-align: middle;
  text-align: left;
  border-bottom: 1px solid var(--table-divider);
  box-sizing: border-box;
}
.responsive-table tbody tr:last-child td {
  border-bottom: 1px solid var(--table-divider);
}
.responsive-table th {
  line-height: 1.1;
}

/* мобильная разметка */
@media (max-width: 768px) {
  .responsive-table thead {
    display: none;
  }
  .responsive-table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }
  .responsive-table tr {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 10px;
  }
  .responsive-table td {
    border: 0;
    padding: 6px 0;
  }
  .responsive-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 2px;
  }
}
@media (max-width: 1280px) {
  .responsive-table {
    font-size: 13px;
  }
  .responsive-table th,
  .responsive-table td {
    padding: 7px 8px;
  }
}

/* equal-cols + divider */
.responsive-table.eqcols {
  table-layout: fixed;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.eqcols th,
.eqcols td {
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}
.eqcols col.col-id {
  width: 8%;
}
.eqcols col.col-amo {
  width: 42%;
}
.eqcols col.col-type {
  width: 16%;
}
.eqcols col.col-status {
  width: 14%;
}
.eqcols col.col-actions {
  width: 22%;
}
.responsive-table.eqcols tbody tr td {
  border-bottom: 0 !important;
}
.responsive-table.eqcols tbody tr {
  position: relative;
}
.responsive-table.eqcols tbody tr::after {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 1px;
  background: var(--table-divider);
}
.responsive-table.eqcols th:nth-child(4),
.responsive-table.eqcols td:nth-child(4) {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.responsive-table .badge {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.eqcols .amo-link {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* helpers */
.table-col-center-1 th:nth-child(1),
.table-col-center-1 td:nth-child(1) {
  text-align: center;
}
.table-col-right-1 th:nth-child(1),
.table-col-right-1 td:nth-child(1) {
  text-align: right;
}
.table-col-center-2 th:nth-child(2),
.table-col-center-2 td:nth-child(2) {
  text-align: center;
}
.table-col-right-2 th:nth-child(2),
.table-col-right-2 td:nth-child(2) {
  text-align: right;
}
.table-col-center-3 th:nth-child(3),
.table-col-center-3 td:nth-child(3) {
  text-align: center;
}
.table-col-right-3 th:nth-child(3),
.table-col-right-3 td:nth-child(3) {
  text-align: right;
}
.table-col-center-8 th:nth-child(8),
.table-col-center-8 td:nth-child(8) {
  text-align: center;
}
.table-col-right-8 th:nth-child(8),
.table-col-right-8 td:nth-child(8) {
  text-align: right;
}
.text-right,
th.text-right,
td.text-right {
  text-align: right !important;
}

/* ============ ADMIN LAYOUT (wide) ============ */
#admin-bleed {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}
#admin-bleed .admin-inner {
  --admin-max: 1600px;
  max-width: min(var(--admin-max), 100vw - 24px);
  margin-inline: auto;
  padding-inline: 12px;
}
@media (max-width: 868px) {
  #admin-bleed .admin-inner {
    max-width: 100vw;
    padding-inline: 8px;
  }
}
#admin-bleed .card {
  max-width: none;
  width: 100%;
}
#admin-bleed .responsive-table {
  border-collapse: separate;
  border-spacing: 0;
}
#admin-bleed .responsive-table th,
#admin-bleed .responsive-table td {
  border: 0 !important;
}
#admin-bleed .responsive-table thead tr,
#admin-bleed .responsive-table tbody tr {
  background-image: linear-gradient(var(--table-divider), var(--table-divider));
  background-repeat: no-repeat;
  background-size: 100% 1px;
  background-position: left bottom;
}

/* managers table widths + actions */
.responsive-table.admin-table-managers {
  table-layout: fixed;
  width: 100%;
}
.responsive-table.admin-table-managers th:nth-child(1),
.responsive-table.admin-table-managers td:nth-child(1) {
  width: 60px !important;
  text-align: center;
  padding: 0 8px !important;
}
.responsive-table.admin-table-managers th:nth-child(5),
.responsive-table.admin-table-managers td:nth-child(5) {
  width: 120px !important;
  text-align: center;
  padding: 0 8px !important;
}
.responsive-table.admin-table-managers th:nth-child(6),
.responsive-table.admin-table-managers td:nth-child(6) {
  width: 110px !important;
  text-align: right;
  padding: 0 8px !important;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  text-overflow: ellipsis;
}
.responsive-table.admin-table-managers th:last-child,
.responsive-table.admin-table-managers td:last-child {
  min-width: 220px !important;
  white-space: normal !important;
  text-align: left !important;
}
.responsive-table.admin-table-managers td:last-child {
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: flex-start !important;
  gap: 8px !important;
  padding-left: 14px !important;
  padding-right: 0 !important;
  box-sizing: border-box;
}
.responsive-table.admin-table-managers td:last-child .btn {
  min-width: 170px;
  width: 170px;
  justify-content: center;
  text-align: center;
}
@media (max-width: 720px) {
  .responsive-table.admin-table-managers td:last-child {
    justify-content: stretch;
    align-items: stretch;
  }
  .responsive-table.admin-table-managers td:last-child .btn {
    width: 100%;
    min-width: 0;
  }
}
.admin-table-managers col.col-actions {
  width: 260px;
}
@media (max-width: 900px) {
  .admin-table-managers col.col-actions {
    width: 1%;
  }
}
.admin-table-managers .td-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
}
.admin-table-managers .td-actions .btn {
  border-radius: 12px;
  padding: 10px 16px;
}
.admin-table-managers .td-actions .btn-danger {
  background: #d64a4a;
  border-color: #d64a4a;
  color: #fff;
}
.admin-table-managers .td-actions .btn-danger:hover {
  filter: brightness(0.95);
}
.admin-table-managers .td-actions form {
  display: inline;
  margin: 0;
}

/* Group blocks */
#admin-bleed .group-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: var(--card);
  margin-top: 12px;
}
#admin-bleed .group-sep {
  border: 0;
  height: 0;
  margin: 12px 0;
  box-shadow: inset 0 1px 0 var(--border);
}
#admin-bleed .group-card .table-wrap {
  margin-top: 12px;
}
#admin-bleed .badge {
  white-space: nowrap;
}
#admin-bleed .mt-2 {
  margin-top: 12px;
}
#admin-bleed .text-right {
  text-align: right;
}

/* ===== Form editor (scoped) ===== */
body.page-wide-form-editor {
  --admin-max: 1880px;
  --work-max: 2200px;
  --col-name: 2fr;
  --col-form: 2fr;
  --col-ph: 2fr;
  --col-req: 42px;
  --col-drag: 28px;
  --col-type: 150px;
}
body.page-wide-form-editor.page-ultra-wide {
  --admin-max: 2000px;
  --work-max: 2600px;
}
body.page-wide-form-editor .container,
body.page-wide-form-editor main,
body.page-wide-form-editor .content {
  max-width: min(var(--admin-max), 98vw) !important;
  padding-inline: 20px;
}
body.page-wide-form-editor #admin-bleed .admin-inner {
  max-width: min(var(--admin-max), 100vw - 24px);
}
body.page-wide-form-editor .qf-name {
  white-space: normal !important;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.25;
}
body.page-wide-form-editor .qf-name .qf-title,
body.page-wide-form-editor .qf-name:not(:has(.qf-title)) {
  white-space: normal !important;
  word-break: normal;
  overflow-wrap: break-word;
}
body.page-wide-form-editor .qf-name .type-badge {
  display: block;
  margin-top: 6px;
}
body.page-wide-form-editor .map-head,
body.page-wide-form-editor .map-row {
  display: grid;
  grid-template-columns: var(--col-name) var(--col-form) var(--col-ph) var(
      --col-req
    );
  gap: 12px;
  align-items: center;
  padding-inline: 12px;
  box-sizing: border-box;
  width: 100%;
}
body.page-wide-form-editor .map-row {
  padding-block: 10px;
  background: var(--card);
  border: 1px solid var(--table-divider);
  border-radius: 12px;
}
body.page-wide-form-editor .map-head {
  margin: 6px 0 8px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-width: 0;
}
body.page-wide-form-editor .map-head > *,
body.page-wide-form-editor .map-row > * {
  min-width: 0;
}
body.page-wide-form-editor .map-row .req {
  justify-self: start;
}
body.page-wide-form-editor .map-row .field-row {
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}
body.page-wide-form-editor .map-row .field-row input {
  height: 42px;
  border: 1px solid var(--input-border);
  border-radius: 10px;
}
body.page-wide-form-editor .grid-main input,
body.page-wide-form-editor .grid-main select {
  height: auto;
  min-height: 40px;
  padding-block: 8px;
  line-height: 1.3;
}
body.page-wide-form-editor .grid-main .field-row {
  padding: 8px 10px;
}
body.page-wide-form-editor .grid-main select {
  -webkit-appearance: none;
  appearance: none;
}

.grid-main {
  display: grid;
  grid-template-columns: 1.2fr 2fr auto;
  gap: 12px 16px;
  align-items: end;
}
.grid-main label {
  margin: 0 !important;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.grid-main input,
.grid-main select {
  height: 38px;
}
.grid-main .actions {
  margin: 0 !important;
  align-self: end;
  display: flex;
  align-items: flex-end;
}
.grid-main .actions .btn {
  height: 38px;
  min-height: 38px !important;
  line-height: 38px;
  padding-inline: 16px;
  position: relative;
  top: -1px;
}

/* Container queries */
.two-cols {
  display: grid;
  gap: 16px;
  align-items: start;
  grid-template-columns: minmax(500px, 0.9fr) minmax(500px, 1fr);
  container-type: inline-size;
}
@container (max-width:2000px) {
  .two-cols {
    grid-template-columns: minmax(0, 1fr);
  }
}

.panel {
  border: 1px solid var(--table-divider);
  border-radius: 16px;
  padding: 12px;
  background: var(--card);
}
.panel h3 {
  margin: 0 0 10px;
  font-size: 16px;
}
.q-list {
  display: grid;
  gap: 8px;
}
.q-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px dashed var(--table-divider);
  border-radius: 12px;
  padding: 8px 10px;
  background: var(--card);
}
.q-item-name {
  font-weight: 600;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-width: 0;
}
.badge-type {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--table-divider);
  white-space: nowrap;
}
.panel--ff .btn {
  min-width: unset;
}
.panel--ff .toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.panel--ff .toolbar h3 {
  margin: 0;
}
.f-list {
  display: grid;
  gap: 8px;
}
.f-item {
  display: grid;
  align-items: center;
  gap: 10px;
  grid-template-columns:
    var(--col-drag) var(--col-name) var(--col-ph) var(--col-type)
    var(--col-req);
  border: 1px solid var(--table-divider);
  border-radius: 12px;
  padding: 8px 10px;
  background: var(--card);
  box-sizing: border-box;
}
.f-item > * {
  min-width: 0;
}
.f-item .drag {
  cursor: grab;
  text-align: center;
  user-select: none;
}
.f-name {
  font-weight: 600;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.f-ph {
  width: 100%;
}
.f-req {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  justify-self: end;
}
.f-req input {
  margin: 0;
}
.panel--ff input[type='text'] {
  background: var(--card);
  color: var(--fg);
  -webkit-text-fill-color: var(--fg);
  caret-color: var(--fg);
  width: 100%;
}
.panel--ff #ff-list .ff-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.ff-drag {
  cursor: grab;
  user-select: none;
  text-align: center;
  line-height: 1;
  font-size: 18px;
  opacity: 0.8;
}
.ff-item.dragging {
  opacity: 0.7;
}
.panel--ff #ff-list input[name='ff_label[]'] {
  width: 100%;
}
.panel--ff #ff-list .btn-delete {
  min-width: unset;
}
.panel--ff .toolbar--form {
  display: grid;
  row-gap: 10px;
}
.panel--ff .toolbar--form h3 {
  margin: 0;
}
.panel--ff .toolbar--form .btn-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.panel--ff .toolbar--form .btn-row .btn {
  height: 38px;
  min-width: unset;
}

@media (max-width: 920px) {
  .grid-main {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 1050px) {
  .f-item {
    grid-template-columns: var(--col-drag) 1fr;
    grid-auto-rows: auto;
  }
}

/* ===== FILTERS (cards/admin) ===== */
.filters.tight {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  grid-template-areas: 'manager queue statuses statuses' 'date_from date_to presets presets' 'qfield qfield qfield qfield' 'actions actions actions actions';
  column-gap: 16px;
  row-gap: 8px;
  align-items: start;
  margin: 10px 0 14px;
  position: sticky;
  top: 48px;
  z-index: 4;
  background: transparent !important;
  border: 1px solid var(--table-divider);
  border-radius: 14px;
  padding: 12px;
}
.filters.tight label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}
.filters.tight select,
.filters.tight input[type='date'],
.filters.tight input[type='text'] {
  margin: 0;
}
.filters-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
}
.date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
@media (prefers-color-scheme: dark) {
  .filters.tight {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  }
}
@media (max-width: 960px) {
  .filters.tight {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    grid-template-areas: 'manager queue' 'date_from date_to' 'presets presets' 'statuses statuses' 'qfield qfield' 'actions actions';
  }
}
@media (max-width: 560px) {
  .filters.tight {
    grid-template-columns: 1fr;
    grid-template-areas: 'manager' 'queue' 'date_from' 'date_to' 'presets' 'statuses' 'qfield' 'actions';
  }
}

/* chips */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  row-gap: 6px;
  align-items: flex-start;
}
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.chip span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  line-height: 1;
  padding: 7px 12px;
  border-radius: 9999px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--fg);
  font-size: 12px;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease,
    filter 0.15s ease, transform 0.02s ease, box-shadow 0.15s ease;
}
.chip:hover span {
  filter: brightness(1.05);
}
.chip:active span {
  transform: translateY(1px);
}
.chip.is-active span,
.chip:has(input:checked) span {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--primary) 55%, transparent);
}

/* active filters summary */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
}
.af-chip {
  font-size: 12px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--table-divider);
  background: color-mix(in oklab, var(--bg) 92%, var(--primary) 8%);
}

/* cards filters (admin page) */
.cards-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  grid-template-areas: 'manager queue statuses statuses' 'datef datet presets presets' 'actions actions actions actions';
  column-gap: 16px;
  row-gap: 8px;
  align-items: start;
  margin: 8px 0 14px;
}
.cards-filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}
.cards-filters .filters-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
}
@media (max-width: 960px) {
  .cards-filters {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    grid-template-areas: 'manager queue' 'datef datet' 'presets presets' 'statuses statuses' 'actions actions';
  }
}
@media (max-width: 560px) {
  .cards-filters {
    grid-template-columns: 1fr;
    grid-template-areas: 'manager' 'queue' 'datef' 'datet' 'presets' 'statuses' 'actions';
  }
}

/* Misc */
.status-badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--table-divider);
  background: color-mix(in oklab, var(--primary) 10%, transparent);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}
.td-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.select-compact {
  font-size: 12px;
  line-height: 1.2;
  padding: 4px 8px;
  min-height: 28px;
  min-width: 56px;
  border-radius: 8px;
}

/* ===============================
   GLOBAL NAV PILLS
   =============================== */
:root {
  --pill-bg: color-mix(in oklab, var(--primary) 12%, #fff);
  --pill-border: color-mix(in oklab, var(--primary) 28%, var(--border));
  --pill-active-bg: var(--primary);
  --pill-active-fg: #fff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --pill-bg: color-mix(in oklab, var(--primary) 12%, #0f141c);
    --pill-border: color-mix(in oklab, var(--primary) 28%, var(--border));
  }
}
body.force-light {
  --pill-bg: color-mix(in oklab, var(--primary) 12%, #fff);
  --pill-border: color-mix(in oklab, var(--primary) 28%, var(--border));
}
body.force-dark {
  --pill-bg: color-mix(in oklab, var(--primary) 12%, #0f141c);
  --pill-border: color-mix(in oklab, var(--primary) 28%, var(--border));
}
.topnav,
.pill-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.topnav .pill,
.pill-nav .pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--pill-border);
  background: var(--pill-bg);
  color: var(--fg);
  line-height: 1;
  font-size: 14px;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease,
    filter 0.15s ease, transform 0.02s ease;
  box-shadow: none;
}
.topnav .pill:hover,
.pill-nav .pill:hover {
  filter: brightness(1.05);
}
.topnav .pill:active,
.pill-nav .pill:active {
  transform: translateY(1px);
}
.topnav .pill.active,
.pill-nav .pill.active,
.topnav .pill[aria-current='page'],
.pill-nav .pill[aria-current='page'] {
  background: var(--pill-active-bg);
  color: var(--pill-active-fg);
  border-color: var(--pill-active-bg);
}

/* --- Dashboard fixes: запрещаем внутренние скроллы у карточек --- */
.card,
.work-shell,
.work-area,
.container,
main,
.content {
  overflow: visible;
}

/* sticky reset */
.pageHeader,
.filters.tight {
  position: static;
  top: auto;
  z-index: auto;
}

/* Итоговые блоки */
.blocks {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}
.block {
  border: 1px solid color-mix(in oklab, var(--fg) 10%, var(--table-divider));
  background: var(--card);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 1px 0 color-mix(in oklab, var(--fg) 6%, transparent) inset;
}
.block h4 {
  margin: 0 0 8px;
}
.block ul {
  margin: 0;
  padding-left: 18px;
  max-height: 320px;
  overflow: auto;
}
@media (max-width: 960px) {
  .blocks {
    grid-template-columns: 1fr;
  }
}

/* Users list */
.user-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 10px 14px;
}
.user-line {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  text-align: left;
  background: color-mix(in oklab, var(--primary) 12%, var(--card));
  border: 1px solid color-mix(in oklab, var(--primary) 28%, var(--border));
  color: var(--fg);
  transition: filter 0.15s ease, transform 0.02s ease;
}
.user-line:hover {
  filter: brightness(1.05);
}
.user-line:active {
  transform: translateY(1px);
}
.user-line input[type='checkbox'] {
  margin: 0;
}
.user-ava {
  width: 24px;
  height: 24px;
  line-height: 24px;
  border-radius: 50%;
  display: inline-block;
  text-align: center;
  font-weight: 600;
  font-size: 12px;
  user-select: none;
  background: color-mix(in oklab, var(--primary) 20%, transparent);
  border: 1px solid color-mix(in oklab, var(--primary) 60%, transparent);
  color: var(--fg);
}
.user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-line .badge {
  line-height: 1;
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--table-divider);
  background: color-mix(in oklab, var(--primary) 10%, transparent);
  color: var(--fg);
}
@media (max-width: 720px) {
  .user-list {
    grid-template-columns: 1fr;
  }
}

/* Заголовки таблиц по левому краю */
.responsive-table thead th {
  text-align: left !important;
}

/* colspan rows */
.responsive-table tbody td[colspan] {
  display: table-cell !important;
  text-align: center;
  padding: 14px 10px;
  white-space: normal;
}
.responsive-table.eqcols tbody tr:has(td[colspan])::after {
  display: none;
}
@media (max-width: 768px) {
  .responsive-table tbody tr:has(td[colspan]) {
    display: table-row;
  }
  .responsive-table tbody tr:has(td[colspan]) td {
    display: table-cell;
    width: auto;
  }
}

/* Пагинация одной строкой */
.pager-wrap.compact .pager-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.pager-wrap.compact .pager-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pager-wrap.compact .pager-actions .sep {
  width: 1px;
  height: 22px;
  background: var(--table-divider);
  display: inline-block;
  margin: 0 2px;
  border-radius: 1px;
}
.pager-wrap.compact .total-chip {
  white-space: nowrap;
}

/* only-desktop/mobile helpers */
.only-desktop {
  display: none;
}
.only-mobile {
  display: block;
}
@media (min-width: 961px) {
  .only-desktop {
    display: flex;
  }
  .only-mobile {
    display: none;
  }
}

/* Header actions compact */
.pageHeader {
  gap: 8px;
}
.pageHeader .head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.pageHeader .head-actions > * {
  flex: 0 0 auto;
}

/* field compact/inline + select-like-btn */
.field-compact {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
}
.field-compact .label {
  margin: 0;
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
}
.field-compact select {
  height: var(--btn-h-sm);
}
.field-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
}
.field-inline .label {
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  white-space: nowrap;
}
.field-inline select {
  height: var(--btn-h-sm);
}
.select-like-btn {
  height: var(--btn-h-sm);
  padding: 0 var(--btn-px-sm);
  font-size: var(--btn-fs-sm);
  border-radius: 10px;
  min-width: 220px;
}
.select-like-btn.is-secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-fg);
  border: 1px solid var(--btn-secondary-border);
}

/* actions area */
.pf-row {
  padding: 10px;
}
.actions .btn {
  min-width: 0;
}
@media (max-width: 480px) {
  .actions {
    justify-content: stretch;
  }
  .actions .btn {
    width: 100%;
  }
}

/* Autosave badge */
.as-badge {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--primary);
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}
.field-row.saved .as-badge,
.ff-item.saved .as-badge {
  opacity: 1;
}

/* FF form rows (padding for delete button width) */
.ff-item {
  position: relative;
  --delW: 80px;
}
.ff-item input[name='ff_label[]'] {
  padding-right: calc(var(--delW, 80px) + 56px);
}
.ff-item .as-badge {
  right: calc(var(--delW, 80px) + 16px);
}

/* ===== Common panels / forms (cards) ===== */
.card-form {
  display: grid;
  gap: 16px;
  grid-template-columns: 1.1fr 1.6fr;
  align-items: start;
}
.card-form .col {
  display: grid;
  gap: 16px;
}
@media (max-width: 960px) {
  .card-form {
    grid-template-columns: 1fr;
  }
}
.grid-info {
  display: grid;
  gap: 10px 16px;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 720px) {
  .grid-info {
    grid-template-columns: 1fr;
  }
}
.fields-list {
  display: grid;
  gap: 8px;
}
.field-row {
  border: 1px solid var(--table-divider);
  border-radius: 12px;
  padding: 10px;
  background: var(--card);
  display: grid;
  gap: 8px;
  position: relative;
}
.field-title {
  font-weight: 600;
  line-height: 1.25;
}
.muted {
  color: var(--muted);
}
.docs-list {
  display: grid;
  gap: 8px;
}
.doc-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--table-divider);
  border-radius: 12px;
  padding: 10px;
}
.subgrid-2 {
  display: grid;
  gap: 10px 16px;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 720px) {
  .subgrid-2 {
    grid-template-columns: 1fr;
  }
}
.links-list {
  display: grid;
  gap: 8px;
}
.link-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--table-divider);
  border-radius: 12px;
  padding: 10px;
}
.nowrap {
  white-space: nowrap;
}
.copy-btn {
  min-width: auto;
  padding: 6px 10px;
}

/* file chips */
.file-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border, #333);
  background: var(--chip-bg, #171a1f);
  color: var(--chip-fg, #fff);
  max-width: 100%;
}
.file-ico {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  flex: 0 0 auto;
}
.file-name {
  min-width: 0;
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  color: inherit;
}
.file-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}
:root[data-theme='light'] .file-chip {
  --chip-bg: #f2f4f7;
  --chip-fg: #111;
}
:root[data-theme='dark'] .file-chip {
  --chip-bg: #171a1f;
  --chip-fg: #f7f8fa;
}
@media (prefers-color-scheme: light) {
  .file-chip {
    --chip-bg: #f2f4f7;
    --chip-fg: #111;
  }
}
@media (prefers-color-scheme: dark) {
  .file-chip {
    --chip-bg: #171a1f;
    --chip-fg: #f7f8fa;
  }
}

/* Public form (wrapper + controls) */
:root {
  --wrap-max: 1200px;
  --ctrl-h: 48px;
  --ctrl-radius: 12px;
  --ctrl-px: 14px;
  --ta-min: 220px;
  --row-radius: 16px;
  --row-pad: 14px;
  --row-gap: 8px;
  --panel-bg: var(--card, #fff);
  --panel-br: var(--table-divider, #e7e7ea);
  --input-fg: #111;
  --accent: var(--primary, #2563eb);
  --accent-weak: rgba(37, 99, 235, 0.15);
  --file-bg: #f3f4f6;
  --file-fg: #111;
  --file-br: rgba(0, 0, 0, 0.08);
  --file-hover: #e9ecf2;
}
@media (prefers-color-scheme: dark) {
  :root {
    --panel-bg: #14181f;
    --panel-br: rgba(255, 255, 255, 0.06);
    --input-bg: #0f1319;
    --input-fg: #e9eef8;
    --muted: #98a2b3;
    --file-bg: #1a1f27;
    --file-fg: #e9eef8;
    --file-br: rgba(255, 255, 255, 0.08);
    --file-hover: #222936;
    --accent-weak: rgba(99, 135, 255, 0.18);
  }
}
.form--compact {
  --ctrl-h: 40px;
  --ctrl-radius: 10px;
  --ctrl-px: 12px;
  --ta-min: 90px;
  --row-pad: 12px;
}
.form--cozy {
  --ctrl-h: 48px;
  --ctrl-radius: 12px;
  --ctrl-px: 14px;
  --ta-min: 120px;
  --row-pad: 14px;
}
.form--spacious {
  --ctrl-h: 56px;
  --ctrl-radius: 14px;
  --ctrl-px: 16px;
  --ta-min: 160px;
  --row-pad: 16px;
}
body.public-form-page header.nav,
body.public-form-page .toolbar {
  display: none !important;
}
.public-wrap {
  max-width: var(--wrap-max);
  margin: 0 auto;
  padding: 0 16px;
}
.title-card {
  padding: 18px;
  border: 1px solid var(--panel-br);
  border-radius: 16px;
  background: var(--panel-bg);
}
.title-card h2 {
  margin: 0;
  text-align: center;
}
.public-form {
  display: grid;
  gap: 14px;
}
.pf-row {
  border: 1px solid var(--panel-br);
  border-radius: var(--row-radius);
  padding: var(--row-pad);
  background: var(--panel-bg);
  display: grid;
  gap: var(--row-gap);
}
.pf-title {
  font-weight: 600;
  color: var(--input-fg);
}
.public-form input,
.public-form select {
  width: 100%;
  box-sizing: border-box;
  height: var(--ctrl-h);
  padding: 0 var(--ctrl-px);
  background: var(--input-bg);
  color: var(--input-fg);
  border: 1px solid var(--panel-br);
  border-radius: var(--ctrl-radius);
  outline: none;
}
.public-form textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: var(--ta-min);
  padding: 12px var(--ctrl-px);
  background: var(--input-bg);
  color: var(--input-fg);
  border: 1px solid var(--panel-br);
  border-radius: var(--ctrl-radius);
  outline: none;
  resize: vertical;
}
.public-form input:focus,
.public-form select:focus,
.public-form textarea:focus {
  box-shadow: 0 0 0 3px var(--accent-weak);
  border-color: var(--accent);
}
.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.btn {
  gap: 8px;
}
.btn-secondary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}
.btn:hover {
  filter: brightness(1.03);
}
.btn:active {
  transform: translateY(1px);
}
.pf-file {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.file-input {
  display: none;
}
.file-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--file-bg);
  border: 1px solid var(--file-br);
  border-radius: 14px;
  color: var(--file-fg);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease,
    transform 0.05s ease;
}
.file-btn:hover {
  background: var(--file-hover);
}
.file-btn:active {
  transform: translateY(1px);
}
.file-ico {
  width: 18px;
  height: 18px;
  display: inline-block;
  line-height: 0;
  color: var(--file-fg);
}
.file-name {
  color: var(--muted);
}
.file-clear {
  margin-left: auto;
}
@media (max-width: 640px) {
  html,
  body {
    overflow-x: hidden;
  }
  .public-wrap {
    padding: 0 8px;
  }
  .title-card {
    padding: 14px;
  }
  .actions .btn {
    width: 100%;
  }
}
.public-form .pf-row {
  align-items: flex-start;
}
.public-form .pf-row input[type='text'],
.public-form .pf-row select,
.public-form .pf-row textarea {
  width: 100%;
}
.public-form .pf-title {
  min-width: 180px;
}
.public-form textarea {
  min-height: 120px;
}

/* checkline (picker) */
.checkline {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border-radius: 8px;
}
.checkline:hover {
  background: var(--bg-soft);
}
.checkline-title {
  flex: 1;
  line-height: 1.3;
}
.checkline input[type='checkbox'] {
  width: 16px;
  height: 16px;
  margin-left: 12px;
}

/* cols picker specifics */
.cols-picker .box .checkline {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  width: 100%;
  text-align: left !important;
}
.cols-picker .box .checkline:hover {
  background: var(--bg-soft);
}
.cols-picker .box .checkline .checkline-title {
  flex: 1 1 auto !important;
  line-height: 1.3;
  text-align: left !important;
  margin: 0 !important;
}
.cols-picker .box .checkline input[type='checkbox'] {
  display: inline-block !important;
  width: auto !important;
  height: auto !important;
  margin: 0 0 0 12px !important;
  flex: 0 0 auto !important;
}
.cols-picker .box {
  max-height: 32vh;
  overflow: auto;
  padding: 8px;
}
.cols-picker .box > input[type='search'] {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: -8px -8px 8px;
  padding: 6px 10px;
  background: var(--bg, #111);
  border-bottom: 1px solid var(--border, #2a2a2a);
}
.cols-picker .box .checkline {
  padding: 4px 6px !important;
  gap: 8px !important;
  min-height: 28px;
}
.cols-picker .box .checkline-title {
  font-size: 0.92rem;
  line-height: 1.2 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cols-picker .box .checkline input[type='checkbox'] {
  transform: scale(0.95);
  margin-left: 8px !important;
}
.cols-picker .box::-webkit-scrollbar {
  width: 8px;
}
.cols-picker .box::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 6px;
}
.cols-picker .box::-webkit-scrollbar-track {
  background: transparent;
}
details.cols-picker > summary {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 28px;
  text-align: center;
}
details.cols-picker > summary::-webkit-details-marker {
  display: none;
}
details.cols-picker > summary::marker {
  content: '';
}
details.cols-picker > summary::before {
  content: '▸';
  position: absolute;
  left: 12px;
  font-size: 12px;
  line-height: 1;
  opacity: 0.9;
}
details.cols-picker[open] > summary::before {
  content: '▾';
}

/* Refund calc local bits */
#refund-calc .calc-grid {
  display: grid;
  gap: 10px 16px;
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 960px) {
  #refund-calc .calc-grid {
    grid-template-columns: 1fr;
  }
}
#refund-calc .result-grid {
  display: grid;
  gap: 10px 16px;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 720px) {
  #refund-calc .result-grid {
    grid-template-columns: 1fr;
  }
}
#refund-calc .hint {
  color: var(--muted);
  font-size: 12px;
}
#refund-calc .error {
  color: #c94343;
  font-size: 13px;
  margin: 6px 0 0;
  display: none;
}
#refund-calc details {
  margin-top: 10px;
}
#refund-calc summary {
  cursor: pointer;
}

/* ===== Templates page (wide) ===== */
:root {
  --tmpl-max: 2200px;
}
body.page-wide-tmpl .container,
body.page-wide-tmpl main,
body.page-wide-tmpl .content,
body.page-wide-tmpl #admin-bleed .admin-inner,
body.page-wide-tmpl-main,
body.page-wide-tmpl main.page-wide-tmpl-main {
  width: 100% !important;
  max-width: min(var(--tmpl-max), 98vw) !important;
  padding-inline: 20px !important;
  margin-inline: auto !important;
  box-sizing: border-box !important;
}

.template-form {
  display: grid;
  gap: 16px;
}
.panel {
  border: 1px solid var(--table-divider);
  border-radius: 14px;
  padding: 12px;
  background: var(--card-bg, var(--bg));
}
.panel h3 {
  margin: 0;
}
.two-cols {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(360px, 0.9fr) minmax(520px, 1.1fr);
  align-items: start;
}
@media (max-width: 1080px) {
  .two-cols {
    grid-template-columns: 1fr;
  }
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
}
.toolbar--tmpl {
  margin-bottom: 8px;
}
.toolbar .btn-row {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.toolbar .btn-row .btn {
  min-width: auto;
  padding: 6px 12px;
}
.btn-full {
  flex: 1 1 100%;
  width: 100%;
  display: block;
}

.fields-list {
  border: 1px dashed var(--table-divider);
  border-radius: 12px;
  padding: 10px;
  min-height: 120px;
  background: var(--card);
}
.field-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 8px;
  border: 1px solid var(--table-divider);
  border-radius: 10px;
  background: var(--card);
  margin-bottom: 8px;
}
.field-item .fi-drag {
  cursor: grab;
  font-size: 18px;
  line-height: 1;
  user-select: none;
}
.field-item .fi-text {
  min-width: 0;
}
.field-item .fi-text > div {
  white-space: normal;
  word-break: break-word;
  line-height: 1.25;
}
.field-item .fi-title {
  font-weight: 700;
}
.field-item .fi-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  opacity: 0.8;
}
.field-item .fi-type {
  font-size: 12px;
  opacity: 0.75;
}
.field-item .fi-actions .btn {
  padding: 0 10px;
  min-width: auto;
  line-height: 1.2;
}

.top-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 2fr;
}
.top-grid textarea,
.top-grid input[type='text'] {
  height: 38px;
  padding-block: 8px;
  resize: none;
}
.top-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#f_type {
  min-width: 150px;
}

.admin-templates {
  table-layout: fixed;
  width: 100%;
}
.admin-templates col.col-id {
  width: 84px;
}
.admin-templates col.col-actions {
  width: clamp(180px, 22vw, 260px);
}
.admin-templates th.th-actions {
  text-align: left !important;
  padding-left: 0;
}

/* ===== Autofill neutral styling (не меняет дизайн) ===== */
input:-webkit-autofill,
select:-webkit-autofill,
textarea:-webkit-autofill {
  -webkit-box-shadow: 0 0 0px 1000px var(--input-bg) inset !important;
  -webkit-text-fill-color: var(--fg) !important;
  transition: background-color 5000s ease-in-out 0s !important;
}

/* ширина колонки из <col class="col-actions"> */
.responsive-table col.col-actions {
  width: clamp(180px, 22vw, 260px);
}

/* заголовок колонки */
.responsive-table th.th-actions {
  text-align: left !important;
  padding-left: 0;
}

/* сами действия — вертикальный стек с зазором */
.responsive-table td.td-actions {
  display: flex !important;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding-left: 0;
}

/* форма удаления/и т.п. не ломает gap */
.responsive-table td.td-actions form {
  display: contents;
  margin: 0;
}

/* одинаковая ширина кнопок по умолчанию */
.responsive-table td.td-actions .btn {
  width: 190px;
  min-width: 190px;
  justify-content: center;
}

/* мобильный: на всю ширину */
@media (max-width: 720px) {
  .responsive-table td.td-actions {
    align-items: stretch;
  }
  .responsive-table td.td-actions .btn {
    width: 100%;
    min-width: 0;
  }
}
/* ===== Softer buttons palette ===== */
:root {
  --btn-radius: 10px;
  --btn-h: 40px;

  /* приглушённые тона */
  --btn-primary-bg: color-mix(in oklab, var(--primary) 82%, var(--panel) 18%);
  --btn-primary-br: color-mix(in oklab, var(--primary) 86%, var(--panel) 14%);
  --btn-primary-fg: #fff;

  --btn-soft-bg: color-mix(in oklab, var(--primary) 14%, var(--panel) 86%);
  --btn-soft-br: color-mix(in oklab, var(--primary) 28%, var(--border));
  --btn-soft-fg: var(--fg);

  --btn-outline-br: color-mix(in oklab, var(--primary) 50%, var(--border));
  --btn-outline-fg: var(--primary);

  --btn-ghost-fg: var(--primary);
  --btn-ghost-bg: transparent;

  --btn-danger-bg: color-mix(in oklab, var(--danger) 85%, var(--panel) 15%);
  --btn-danger-br: color-mix(in oklab, var(--danger) 90%, var(--panel) 10%);
}

.btn {
  min-width: 140px;
  min-height: var(--btn-h);
  border-radius: var(--btn-radius);
  background: var(--btn-primary-bg);
  border: 1px solid var(--btn-primary-br);
  color: var(--btn-primary-fg);
  box-shadow: 0 1px 0 color-mix(in oklab, var(--fg) 8%, transparent);
  transition: background 0.15s ease, border-color 0.15s ease,
    transform 0.02s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.btn:hover {
  filter: none;
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--primary) 25%, transparent);
}
.btn:active {
  transform: translateY(1px);
}
.btn-secondary {
  background: var(--btn-soft-bg);
  border: 1px solid var(--btn-soft-br);
  color: var(--btn-soft-fg);
}
.btn-danger {
  background: var(--btn-danger-bg);
  border-color: var(--btn-danger-br);
  color: #fff;
}
.btn-danger:hover {
  filter: brightness(1.02);
}
.btn-sm {
  min-width: 0;
  height: var(--btn-h-sm);
  border-radius: calc(var(--btn-radius) - 2px);
}

.btn-soft {
  background: var(--btn-soft-bg);
  border: 1px solid var(--btn-soft-br);
  color: var(--btn-soft-fg);
}
.btn-outline {
  background: transparent;
  color: var(--btn-outline-fg);
  border: 1px solid var(--btn-outline-br);
}
.btn-ghost {
  background: var(--btn-ghost-bg);
  border: 1px solid transparent;
  color: var(--btn-ghost-fg);
}
.btn-outline:hover,
.btn-ghost:hover {
  background: color-mix(in oklab, var(--primary) 10%, transparent);
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 18%, transparent);
}
body.page-wide-form-editor .map-row {
  gap: 16px;
}
body.page-wide-form-editor .map-row + .map-row {
  margin-top: 10px;
}
body.page-wide-form-editor .map-row .req input[type='checkbox'] {
  margin: 0;
  width: 16px;
  height: 16px;
}
/* единая линия для заголовка формы */
.pageHeader .titlebar,
.pageHeader h2.titlebar {
  display: flex;
  align-items: center; /* вертикальное выравнивание по центру */
  gap: 10px;
  margin: 0; /* чтобы не тянул вниз */
}

/* бейдж «Режим…» — компактный */
.titlebar .mode-badge {
  display: inline-flex;
  align-items: center;
  height: 24px; /* фиксируем высоту */
  padding: 0 10px; /* вместо больших вертикальных паддингов */
  line-height: 1; /* без влияния шрифта на высоту */
  border-radius: 999px;
  border: 1px solid var(--table-divider);
  background: color-mix(in oklab, var(--primary) 10%, transparent);
  font-size: 12px;
  white-space: nowrap;
}

/* точка статуса */
.titlebar .save-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa3af; /* меняется скриптом */
  flex: 0 0 auto;
}
/* Инлайн-блок «Документы и ссылки…» в одну строку */
.doc-inline {
  display: grid;
  grid-template-columns: 1.8fr 0.9fr auto 24px 2.4fr auto; /* лейаут, как на скрине */
  gap: 12px;
  align-items: end; /* низ всех контролов по одной линии */
}
.doc-inline label {
  margin: 0;
} /* убираем внешние отступы у label */
.doc-inline .actions {
  margin: 0;
} /* перебиваем inline-styles */
.doc-inline .sep {
  text-align: center;
  align-self: center;
  color: var(--muted);
  user-select: none;
}

/* важный трюк: поля из форм участвуют в гриде родителя */
.doc-inline form {
  display: contents;
}

@media (max-width: 980px) {
  .doc-inline {
    grid-template-columns: 1fr; /* на узких — стекаем */
    gap: 8px 12px;
  }
  .doc-inline .sep {
    display: none;
  }
}
/* вариант 2: без внешнего кольца (ничего не будет обрезаться) */
.responsive-table td.td-actions .btn:hover {
  box-shadow: inset 0 0 0 2px
    color-mix(in oklab, var(--primary) 35%, transparent);
}
/* =========================
   DPO Fields (page layout)
   ========================= */
.page-dpo-fields .stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.page-dpo-fields .stack .label {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}
.page-dpo-fields .check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: start;
}

/* Верхняя полоса: Название | Код | Тип | [Сохранить] [Удалить] */
.page-dpo-fields .grid-top {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto auto;
  gap: 12px 16px;
  align-items: end;
  margin-bottom: 14px;
}
.page-dpo-fields .grid-top .actions.right {
  justify-self: end;
}

/* Нижняя панель «Добавить поле» — карточка */
.page-dpo-fields .add-panel {
  border: 1px solid var(--table-divider);
  border-radius: 14px;
  padding: 12px;
  background: var(--card);
}
.page-dpo-fields .add-panel .add-title {
  font-weight: 600;
  margin: 0 0 8px;
  color: color-mix(in oklab, var(--fg) 85%, var(--muted));
}

/* Сетка внутри панели добавления */
.page-dpo-fields .grid-add {
  display: grid;
  grid-template-columns: 1.6fr 1.2fr 1fr 140px auto auto auto; /* name | code | type | order | req | active | btn */
  gap: 12px 16px;
  align-items: end;
}
.page-dpo-fields .grid-add .short input {
  max-width: 120px;
}
.page-dpo-fields .grid-add .actions.right {
  justify-self: end;
}

/* Мелочи */
.page-dpo-fields .no-wrap {
  white-space: nowrap;
}
.page-dpo-fields .hidden {
  display: none !important;
}

/* Адаптив */
@media (max-width: 1100px) {
  .page-dpo-fields .grid-top {
    grid-template-columns: 1fr 1fr; /* поля в две колонки */
  }
  .page-dpo-fields .grid-top .actions.right {
    grid-column: 1 / -1;
    justify-self: start; /* кнопки на своей строке слева */
  }
  .page-dpo-fields .grid-add {
    grid-template-columns: 1fr 1fr; /* компактная сетка панели добавления */
  }
}
/* убираем подчёркивание у табов */
.tabs a.btn {
  text-decoration: none !important;
}
.tabs a.btn:hover,
.tabs a.btn:focus,
.tabs a.btn:active {
  text-decoration: none !important;
}
/* Сбрасываем агрессивные line-height и даём адекватные размеры */
.field-compact input[type='text'],
.field-compact textarea,
.field-compact select {
  box-sizing: border-box;
  width: 100%;
  font-size: 14px; /* 14–16px: безопасно для платформ */
  line-height: normal; /* критично для Chrome: не режет нижние дольки */
  height: 44px; /* единая высота для инпута/селекта */
  padding: 10px 12px; /* вертикальные паддинги — центрируют текст */
  border-radius: 10px;
}

/* textarea выше, но без линейной высоты, чтобы не клипало */
.field-compact textarea {
  height: auto;
  min-height: 140px;
  padding: 12px;
  line-height: 1.45;
}

/* Отступы между подписью и полем + между полями */
.field-compact {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}
.field-compact .label {
  line-height: 1.25;
}
a.btn,
a.btn:visited,
a.btn:hover,
a.btn:focus {
  text-decoration: none !important;
}

/* на всякий: повышенная специфичность для панелей действий/табов */
.pageHeader .head-actions a.btn,
.pageHeader .head-actions a.btn:hover,
.tabs a.btn,
.tabs a.btn:hover {
  text-decoration: none !important;
}
.pageHeader .head-actions {
  display: flex;
  align-items: center; /* выравниваем по одной линии */
  gap: 12px;
  flex-wrap: wrap;
}
.pageHeader .head-actions .actions {
  /* форма с селектом */
  display: flex;
  align-items: center;
  margin: 0;
}
.pageHeader .head-actions .field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0; /* убираем внешний отступ */
}
.pageHeader .head-actions .field-inline > .label {
  margin: 0; /* подпись в строку, не сверху */
  line-height: 1;
}
/* чтобы селект был как кнопки по высоте */
.pageHeader .head-actions .select-like-btn {
  height: 44px;
  line-height: 44px;
  padding: 0 14px;
}
/* === Toasts (глобально) === */
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none; /* клики проходят сквозь пустое место */
}
.toast {
  pointer-events: auto; /* по самому тосту клики разрешены */
  min-width: 160px;
  max-width: 420px;
  padding: 8px 12px;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  background: #265e33; /* success по умолчанию */
  color: #fff;
  font-size: 14px;
  line-height: 1.35;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.error {
  background: #7a1e1e;
}
.toast.info {
  background: #2d4d7a;
}
.toast.warning {
  background: #6b5b1e;
}
.toast .x {
  margin-left: 10px;
  opacity: 0.85;
  cursor: pointer;
}
.fix-overflow {
  overflow: visible;
}
.select-fix {
  box-sizing: border-box;
  height: auto;
  min-height: 38px;
  line-height: 1.35;
  padding-top: 8px;
  padding-bottom: 8px;
}
.td-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
td .field-compact {
  margin: 0;
}
.status-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-head .grow {
  flex: 1;
}
.status-head .cols-pill {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  overflow: visible;
}
.cols-picker {
  display: block;
  width: 100%;
  max-width: 520px;
  position: relative;
  box-sizing: border-box;
}
.cols-picker > summary.select-like-btn {
  display: inline-flex;
  align-items: center;
  position: relative;
  width: 100%;
  min-height: 38px;
  padding: 6px 12px 6px 32px;
  cursor: pointer;
  border-radius: 10px;
}
.cols-picker > summary::-webkit-details-marker {
  display: none;
}
.cols-picker > summary::marker {
  content: '';
}
.cols-picker > summary::before {
  content: '▸';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.8;
  transition: transform 0.2s ease;
}
.cols-picker[open] > summary::before {
  transform: translateY(-50%) rotate(90deg);
}
.cols-picker[open] > summary {
  margin-bottom: 0;
}
.cols-picker > .cols-body {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 40;
  width: min(700px, 70vw);
  height: clamp(300px, 52vh, 560px);
  max-height: 60vh;

  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--panel, #fff);
  border: 1px solid var(--table-divider, rgba(0, 0, 0, 0.12));
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.cols-body .cols-list {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  padding-right: 8px;
  scrollbar-gutter: stable both-edges;
  scrollbar-width: thin;
}

.cols-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.45) rgba(255, 255, 255, 0.12);
}
.cols-list::-webkit-scrollbar {
  width: 12px;
}
.cols-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}
.cols-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
.cols-list:hover::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.65);
}

@media (prefers-color-scheme: light) {
  .cols-body .cols-list {
    scrollbar-color: rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.1); /* Firefox: thumb track */
  }
  .cols-body .cols-list::-webkit-scrollbar {
    width: 12px;
  }
  .cols-body .cols-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
  }
  .cols-body .cols-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: content-box;
  }
  .cols-body .cols-list:hover::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.6);
  }
}
@media (prefers-color-scheme: dark) {
  .cols-body .cols-list {
    scrollbar-color: rgba(255, 255, 255, 0.45) rgba(255, 255, 255, 0.12);
  }
  .cols-body .cols-list::-webkit-scrollbar {
    width: 12px;
  }
  .cols-body .cols-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 8px;
  }
  .cols-body .cols-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.45);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: content-box;
  }
  .cols-body .cols-list:hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.65);
  }
}
/* ===== Документы/Ссылки — раскладка в две колонки ===== */
.doc-grid {
  display: grid;
  grid-template-columns: 1fr 28px 1fr; /* левая — разделитель — правая */
  gap: 12px 16px;
  align-items: start;
}
.doc-sep {
  align-self: center;
  text-align: center;
  color: var(--muted);
  user-select: none;
}
/* строки с полями и кнопкой в одну линию */
.doc-row {
  display: grid;
  grid-template-columns: 1.6fr 0.9fr auto; /* шаблон, тип, кнопка */
  gap: 12px;
  align-items: end; /* выровнять по нижней линии */
}
.doc-row label {
  margin: 0;
}
.doc-row .actions {
  margin: 0;
}
/* правая форма: у неё только селект + кнопка */
.doc-row--right {
  grid-template-columns: 1fr auto;
}
/* подзаголовки списков */
.doc-subtitle {
  margin: 12px 0 6px;
}

/* адаптив */
@media (max-width: 980px) {
  .doc-grid {
    grid-template-columns: 1fr;
  }
  .doc-sep {
    display: none;
  }
  .doc-row,
  .doc-row--right {
    grid-template-columns: 1fr;
  }
}
/* Активная вкладка: белый текст гарантирован */
.card-tabs a.btn.active,
.card-tabs a.btn.active:link,
.card-tabs a.btn.active:visited,
.card-tabs .btn.active,
.card-tabs .tab.active,
.card-tabs [aria-current='page'],
.card-tabs [data-active='1'] {
  color: #fff !important;
}

/* Иконки/эмодзи внутри активной вкладки тоже белые */
.card-tabs .btn.active svg,
.card-tabs .btn.active i,
.card-tabs .btn.active .emoji,
.card-tabs [aria-current='page'] svg,
.card-tabs [data-active='1'] svg {
  fill: currentColor !important;
  stroke: currentColor !important;
  color: currentColor !important;
}
.new-field-panel {
  padding: 12px;
  border: 1px solid var(--table-divider);
  border-radius: 16px;
  background: var(--panel);
}
/* сетка формы как на скрине */
.nf-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr auto auto; /* Название | Тип | +поле | +значение */
  grid-template-areas:
    'nameL  typeL  addField addOpt'
    'nameI  typeI  addField addOpt'
    'opts   opts   opts     opts';
  gap: 8px 12px;
  align-items: end;
}
.nf-opts {
  display: grid;
  gap: 10px;
}
/* строка значения: input | кнопка удалить */
.nf-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}
.nf-row .btn {
  min-width: auto;
}
@media (max-width: 980px) {
  .nf-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      'nameL' 'nameI'
      'typeL' 'typeI'
      'addField' 'addOpt'
      'opts';
  }
}
/* мелкие дотюны под общий гайд */
.user-line input[type='checkbox'] {
  width: 16px;
  height: 16px;
  margin: 0;
}

.fields-list .badge {
  margin: 0;
}
.field-row {
  display: grid;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--table-divider);
  border-radius: 12px;
  padding: 10px;
  background: var(--card);
  grid-template-columns: 1fr auto;
}

/* сетка формы «новое поле» */
.new-field-panel .nf-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr auto auto;
  grid-template-areas:
    'nameL  typeL  addField addOpt'
    'nameI  typeI  addField addOpt'
    'opts   opts   opts     opts';
  gap: 8px 12px;
  align-items: end;
}
.new-field-panel label[for='nf_name'] {
  grid-area: nameL;
}
.new-field-panel #nf_name {
  grid-area: nameI;
}
.new-field-panel label[for='nf_type'] {
  grid-area: typeL;
}
.new-field-panel #nf_type {
  grid-area: typeI;
}

.nf-opts {
  display: grid;
  gap: 10px;
}
.nf-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}
.nf-row .btn {
  min-width: auto;
}

@media (max-width: 980px) {
  .new-field-panel .nf-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      'nameL' 'nameI'
      'typeL' 'typeI'
      'addField' 'addOpt'
      'opts';
  }
}
.user-list .user-line {
  border-radius: 12px !important; /* было 999px или 0 — теперь аккуратно */
}

/* === Fix: align actions buttons in template fields list === */
.fields-list .row {
  align-items: center;
}
.fields-list .row .col {
  display: flex;
  align-items: center;
}
.fields-list .row .col.actions {
  justify-content: flex-end;
  gap: 8px;
}
.fields-list .row .btn {
  vertical-align: middle;
}

/* === Fix: filters alignment unified === */
.filters.tight {
  align-items: end;
} /* bottom align controls in compact filter rows */
.filters .quick-periods {
  margin-top: 0;
} /* remove manual offset */
.filters .label {
  margin: 0 0 6px;
} /* consistent label spacing */

/* === Fix: DPO Fields editor — keep compact fields bottom-aligned === */
.form-grid .field-compact {
  align-self: end;
}
.field-compact .inline-actions {
  margin-top: 6px;
}
/* Templates list: action buttons */
.col-actions {
  width: 210px;
}
.tmpl-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  min-width: 200px;
}
.tmpl-actions .btn {
  width: 100%;
}

td[class*='action'],
td[class*='actions'],
.actions-cell {
  vertical-align: top;
}
td[class*='action'] .btn + .btn,
td[class*='actions'] .btn + .btn,
.actions-cell .btn + .btn {
  margin-top: 8px;
}

/* DPO fields editor */
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  align-items: end;
}
.form-row-3 .form-cell label {
  display: block;
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted, #98a3b3);
}
.with-right {
  display: flex;
  gap: 8px;
  align-items: center;
}
.with-right .btn,
.with-right .btn-icon {
  height: 40px;
  padding: 0 10px;
  min-width: 40px;
}

/* Filters alignment */
.filters-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  align-items: end;
}
.filter-cell label {
  display: block;
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted, #98a3b3);
}
.quick-range .quick-range-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn.btn-chip {
  border-radius: 12px;
  padding: 8px 12px;
}

/* DPO concat fields visual */
.queue-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}
.queue-fields .qf-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(34, 111, 255, 0.12);
  border: 1px solid rgba(34, 111, 255, 0.25);
  font-size: 13px;
  line-height: 1;
}
.queue-fields .qf-pill button {
  all: unset;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
}
.queue-fields .empty-hint {
  color: var(--muted, #8aa);
  font-size: 13px;
}
