/* ===== Niches UI v3 (Figma 141:*) — accent #e81848, no green toggles ===== */
:root {
  --bg: #05040a;
  --bg-alt: #12121a;
  --panel: #181822;
  --panel-2: #12121a;
  --surface: #22222c;
  --field: #0a0a10;
  --text: #f2f2f7;
  --text-secondary: #b8bcc6;
  --muted: #8b8b9a;
  --accent: #e81848;
  --accent-soft: rgba(232, 24, 72, 0.14);
  --border: rgba(255, 255, 255, 0.08);
  --track: #2a2a38;
}

body { background: var(--bg); color: var(--text); }

.nav-item.active {
  background: var(--surface) !important;
  color: var(--text) !important;
  box-shadow: none !important;
}
.btn-accent,
.btn-accent:hover { background: var(--accent) !important; border-color: var(--accent) !important; }

/* Kill any green toggle leftovers */
.occupied-checkbox:checked,
.region-test-checkbox:checked,
.card-mode-checkbox:checked,
input[type="checkbox"].lh-switch:checked,
.lh-switch:checked {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  accent-color: var(--accent) !important;
}

/* Pill switch */
.lh-switch {
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--track);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: background 120ms ease;
  vertical-align: middle;
  flex-shrink: 0;
}
.lh-switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #c8c8d4;
  transition: transform 120ms ease, background 120ms ease;
}
.lh-switch:checked { background: var(--accent); border-color: var(--accent); }
.lh-switch:checked::after { transform: translateX(18px); background: #fff; }

/* Dense niches list */
.niches-v3 .niches-panel { padding: 20px 22px 12px; background: var(--panel); border: 1px solid var(--border); }
.niches-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.niches-head h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.niches-hint { margin: 6px 0 0; max-width: 640px; font-size: 13px; color: var(--muted); line-height: 1.4; }
.niches-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }
.niches-search { min-width: 200px; background: var(--field); border: 1px solid var(--border); color: var(--text); border-radius: 10px; height: 40px; padding: 0 12px; }

.niches-list-wrap { margin-top: 8px; }
.niches-list-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px 168px 56px 100px 56px 60px 60px 60px 48px !important;
  align-items: center;
  gap: 8px;
  padding: 0 12px 8px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.nlh-client, .nlh-card, .nlh-test, .nlh-num, .nlh-del { text-align: center; }
.niches-list { display: flex; flex-direction: column; gap: 2px; max-height: calc(100vh - 220px); overflow: auto; padding-bottom: 24px; }

.niche-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px 168px 56px 100px 56px 60px 60px 60px 48px !important;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  height: 52px;
  padding: 0 12px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 120ms ease;
}
.niche-row:hover { background: rgba(255,255,255,0.03); }
.niche-row.is-active { background: rgba(255,255,255,0.045); border-color: var(--border); }
/* removed */
/* removed */
/* removed */
/* removed */
/* removed */
.region-chip {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 8px; border-radius: 999px;
  background: var(--surface); color: var(--text-secondary);
  font-size: 11px; white-space: nowrap; border: 1px solid var(--border);
}
.region-chip.plus { color: var(--muted); }
/* removed */
.niche-row-cell { display: flex; align-items: center; justify-content: center; height: 100%; }
.niche-row-num { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text); text-align: center; }
.card-seg {
  display: inline-flex; align-items: center; gap: 0;
  font-size: 12px; color: var(--muted); user-select: none;
  background: var(--field); border: 1px solid var(--border); border-radius: 8px; padding: 2px;
}
.card-seg .seg-opt {
  cursor: pointer; padding: 5px 10px; border-radius: 6px;
  color: #6e6e7a; font-weight: 500; background: transparent;
}
.card-seg .seg-opt.is-on {
  color: #fff; font-weight: 700;
  background: #2a2a38;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
}
.niche-more {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1;
}
.niche-more:hover { background: var(--surface); color: var(--text); border-color: var(--border); }
.niche-row-menu {
  position: absolute; right: 16px; z-index: 20;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px; min-width: 140px; box-shadow: 0 12px 40px rgba(0,0,0,.45);
}
.niche-row-menu button {
  display: block; width: 100%; text-align: left; background: transparent; border: 0;
  color: var(--text); padding: 8px 10px; border-radius: 8px; cursor: pointer; font: inherit;
}
.niche-row-menu button:hover { background: var(--surface); }
.niche-row-menu button.danger { color: #ff6b8a; }

/* Drawer */
.niche-drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px); z-index: 80;
  opacity: 1; transition: opacity 200ms ease;
}
.niche-drawer-backdrop.hidden { display: none; }
.niche-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw);
  z-index: 90; background: var(--panel-2);
  border-left: 1px solid var(--border);
  transform: translateX(0);
  transition: transform 220ms ease-out;
  display: flex; flex-direction: column;
}
.niche-drawer.hidden { display: none; }
.niche-drawer-inner { display: flex; flex-direction: column; height: 100%; position: relative; }
.niche-drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 20px 22px 12px; border-bottom: 1px solid var(--border);
}
.niche-drawer-title { margin: 0; font-size: 22px; font-weight: 600; }
.niche-drawer-meta { margin-top: 4px; font-size: 12px; color: var(--muted); font-family: var(--font-mono); }
.niche-drawer-body { flex: 1; overflow: auto; padding: 16px 22px 32px; display: flex; flex-direction: column; gap: 16px; }
.niche-drawer-close {
  /* v5.1: absolute removed — see block at file end */
  border-radius: 8px; border: 1px solid var(--border); background: var(--panel);
  color: var(--muted); cursor: pointer;
}
.nd-label {
  display: block; font-size: 11px; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.nd-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.nd-label-row .nd-label { margin: 0; }
.nd-chrome {
  background: var(--field); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; color: var(--text); font-size: 13px; line-height: 1.4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 40px;
  display: flex; align-items: center; gap: 6px;
}
.nd-chrome-flex { flex: 1; min-width: 0; flex-wrap: wrap; white-space: normal; height: auto; min-height: 40px; }
.nd-region-row { display: flex; align-items: center; gap: 12px; }
.nd-test-wrap { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.nd-test-label { font-size: 12px; color: var(--muted); }
.nd-helper { margin: 6px 0 0; font-size: 11px; color: var(--muted); }
.btn-ghost {
  background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit;
}
.btn-ghost:hover { color: var(--text); border-color: rgba(255,255,255,.16); }
.btn-sm { font-size: 12px; padding: 5px 10px; height: auto; }
.nd-counters { display: flex; gap: 18px; align-items: center; }
.nd-counter { display: flex; flex-direction: column; gap: 4px; }
.nd-counter-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* Boards panel */
.boards-panel { background: transparent; }
.boards-filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
/* boards-filter-row reset */
/* */
/* */
/* */
.boards-search { width: 100%; background: var(--field); border: 1px solid var(--border); border-radius: 10px; height: 36px; padding: 0 12px; color: var(--text); }
/* boards-filter-row reset */
.boards-dd { position: relative; }
.boards-dd-btn {
  height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-secondary); cursor: pointer; font: inherit; font-size: 12px;
}
.boards-dd-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 5;
  min-width: 180px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.boards-dd-menu label {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
  font-size: 12px; color: var(--text); cursor: pointer;
}
.boards-dd-menu label:hover { background: var(--surface); }
.seg { display: inline-flex; background: var(--field); border: 1px solid var(--border); border-radius: 8px; padding: 2px; gap: 2px; }
.seg-btn {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px;
  padding: 5px 10px; border-radius: 6px; cursor: pointer;
}
.seg-btn.active { background: var(--surface); color: var(--text); }
.boards-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; color: var(--muted);
}
.boards-list { display: flex; flex-direction: column; gap: 4px; }
.boards-group { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: rgba(255,255,255,0.015); }
.boards-group-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; cursor: pointer; user-select: none; color: var(--text-secondary); font-size: 13px; font-weight: 500;
}
.boards-group-head:hover { background: rgba(255,255,255,0.03); }
.boards-group-body { display: none; border-top: 1px solid var(--border); }
.boards-group.is-open .boards-group-body { display: block; }
.board-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.4fr) auto minmax(48px, auto) 44px 44px;
  align-items: center; gap: 8px;
  min-height: 42px; padding: 6px 12px;
  border-top: 1px solid rgba(255,255,255,0.04);
}
.board-row:first-child { border-top: 0; }
.board-name { font-size: 13px; font-weight: 600; color: var(--text); }
.board-domain { font-size: 11px; color: var(--muted); font-family: var(--font-mono); }
.board-chip {
  display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: 999px;
  font-size: 10px; border: 1px solid var(--border); color: var(--muted); background: var(--field);
}
.board-chip.labor { color: #ffb4c4; border-color: rgba(232,24,72,.35); }
.board-stat { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.board-params-btn { font-size: 11px; }
.board-params {
  display: none; padding: 10px 12px 14px; background: var(--field);
  border-top: 1px solid var(--border); font-size: 12px;
}
.board-row.is-expanded + .board-params,
.board-params.is-open { display: block; }
.board-params-grid { display: grid; gap: 10px; }
.board-params .nd-label { margin-bottom: 4px; }
.paid-seg, .route-seg { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.chip-toggle {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary);
  border-radius: 999px; padding: 4px 10px; font-size: 11px; cursor: pointer;
}
.chip-toggle.is-on { border-color: rgba(232,24,72,.45); color: var(--text); background: var(--accent-soft); }
.board-skip-notes { width: 100%; min-height: 48px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 8px; font: inherit; resize: vertical; }

/* Modals v3 */
.niche-modal .modal-content,
.modal-content-lg {
  width: min(840px, calc(100vw - 32px));
  max-height: min(780px, calc(100vh - 40px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  animation: nicheModalIn 180ms ease-out;
}
@keyframes nicheModalIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}
.modal { background: rgba(0,0,0,.55); backdrop-filter: blur(3px); }
.modal-textarea {
  background: var(--field) !important; border: 1px solid var(--border) !important;
  color: var(--text) !important; font-family: var(--font-mono) !important; font-size: 13px !important;
  border-radius: 12px !important; min-height: 420px;
}
.keyword-dual-editor {
  /* side-by-side via v53 field-dual-editor */
}
.keyword-editor-pane { display: flex; flex-direction: column; gap: 6px; }
.keyword-editor-pane > span {
  font-size: 11px !important; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted) !important;
}
.keyword-textarea { min-height: 160px !important; }
.modal-footer-split { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.region-tags-box {
  background: var(--field); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; min-height: 220px; max-height: 360px; overflow: auto;
}
.region-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.region-tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font-size: 12px;
}
.region-tag button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; padding: 0;
}
.region-tag-input {
  width: 100%; background: transparent; border: 0; outline: none; color: var(--text);
  font: inherit; font-size: 13px; padding: 4px 0;
}
.region-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.region-quick button {
  height: 28px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text-secondary); cursor: pointer; font: inherit; font-size: 12px;
}
.region-quick button:hover { color: var(--text); border-color: rgba(255,255,255,.18); }
.muted { color: var(--muted); font-size: 13px; }

@media (max-width: 1100px) {
  .niches-list-head, .niche-row {
    grid-template-columns: minmax(0, 1fr) 160px 168px 56px 100px 56px 60px 60px 60px 48px !important;
  }
  .niche-drawer { width: min(100vw, 520px); }
}


/* Extra polish / overrides over prod styles.css */
.kw-help { display:block; font-size:11px; color:var(--muted); font-weight:400; letter-spacing:0; text-transform:none; margin-top:2px; }
.keyword-dual-editor { /* dual via v53 */ }
.keyword-editor-pane > span {
  font-size:11px !important; font-weight:500; letter-spacing:0.08em;
  text-transform:uppercase; color:var(--muted) !important;
}
.niche-drawer { width: min(620px, 100vw); }
.boards-hint { font-size:12px; color:var(--muted); margin:0 0 8px; }
.card-seg { gap: 0; padding: 2px; }
.card-seg .seg-opt { padding: 5px 10px; }
.card-seg .seg-opt.is-on { color: #fff; background: #2a2a38; font-weight: 700; }
/* removed */
/* Force accent over legacy pink/green checkbox skins */
.occupied-checkbox:checked,
.region-test-checkbox:checked,
.card-mode-checkbox:checked,
.lh-switch:checked {
  background: #e81848 !important;
  border-color: #e81848 !important;
  box-shadow: none !important;
}
input[type="checkbox"].occupied-checkbox,
input[type="checkbox"].region-test-checkbox,
input[type="checkbox"].card-mode-checkbox {
  accent-color: #e81848;
}
/* Hide legacy green if any inline */
.niches-v3 .occupied-checkbox:checked { background:#e81848 !important; }

/* Modals must sit above drawer (z=90) */
.modal, .niche-modal {
  z-index: 200 !important;
}
.niche-drawer { z-index: 90; }
.niche-drawer-backdrop { z-index: 80; }

/* lh-switch wins over legacy square checkbox skin */
input.lh-switch.occupied-checkbox,
input.lh-switch.board-enable,
input.lh-switch#regionDrawerRegionTest,
input.lh-switch#drawerRegionTest,
input.lh-switch {
  width: 40px !important;
  height: 22px !important;
  min-width: 40px !important;
  border-radius: 999px !important;
  background: var(--track) !important;
  border: 1px solid var(--border) !important;
  background-image: none !important;
  position: relative;
}
input.lh-switch:checked {
  background: #e81848 !important;
  border-color: #e81848 !important;
  background-image: none !important;
}

.niche-drawer-close {
  /* v5.1: absolute removed — see block at file end */
}
.niche-drawer-head { /* padding-right was for absolute close */ }
.niche-row-sub .region-chip { flex-shrink: 0; }
/* removed */


/* LeadHook brand (Figma 141:2) */
.sidebar-brand-toggle .logo { display: none !important; }
.sidebar .brand-title {
  font-family: "Unbounded", system-ui, sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: var(--text);
}
.sidebar .brand-title .brand-hook { color: var(--accent); }
.sidebar .brand-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.sidebar-footer .btn {
  font-size: 13px;
  padding: 10px 12px;
}
/* removed */

/* Keywords: side-by-side (v53) */
.keyword-dual-editor.hidden { display: none !important; }
.keyword-editor-pane > span,
.keyword-editor-pane .kw-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}


/* ===== v3g fixed identity axes 180/140/120 ===== */
.niches-list-head,
.niche-row {
  grid-template-columns: minmax(0, 1fr) 160px 168px 56px 100px 56px 60px 60px 60px 48px !important;
}
.nlh-name, .nlh-region, .nlh-id {
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.niche-row-name {
  min-width: 0;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.niche-row-regions {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}
.niche-row-regions .region-chip {
  flex: 0 0 auto;
}
.niche-row-id {
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Boards filters: search full width; controls one horizontal row, left-aligned */
.boards-filters {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 10px !important;
  margin: 0 0 10px 0 !important;
  padding: 0 !important;
}
.boards-search {
  box-sizing: border-box !important;
  margin: 0 !important;
}
.boards-filter-row {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 8px !important;
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
}
.boards-filter-row > * {
  margin: 0 !important;
}
.boards-filter-row > *:not(.boards-search) {
  flex: 0 0 auto !important;
}
.boards-dd {
  position: relative;
  flex: 0 0 auto !important;
}
.boards-dd-btn {
  white-space: nowrap;
}
.boards-filter-row .seg {
  display: inline-flex !important;
  flex: 0 0 auto !important;
}

/* Drawer fields: no accidental indent staircase */
.nd-boards-field,
.boards-panel,
.nd-field {
  margin-left: 0 !important;
  padding-left: 0 !important;
}
.nd-chrome,
.nd-label-row {
  margin-left: 0 !important;
}

/* Drawer vertical rhythm / shared left edge */
.niche-drawer-body { padding-left: 22px; padding-right: 22px; }
.nd-field { width: 100%; }
.nd-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; }
.nd-chrome { width: 100%; box-sizing: border-box; }
.boards-summary {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  width: 100% !important;
  margin: 0 !important;
}


/* v3g name/region/id fixed axes */
.niche-row-name, .nlh-name { min-width: 0; max-width: none; width: auto; box-sizing: border-box; }
.niche-row-regions, .nlh-region { min-width: 0; max-width: none; width: auto; box-sizing: border-box; }
.niche-row-id, .nlh-id { min-width: 0; max-width: none; width: auto; box-sizing: border-box; }


/* ===== niches UX v4 ===== */
.niches-list-head,
.niche-row {
  grid-template-columns: minmax(0, 1fr) 160px 168px 56px 100px 56px 60px 60px 60px 48px !important;
}

.niche-del-btn {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
.niche-del-btn:hover {
  background: rgba(232, 24, 72, 0.12);
  color: #ff6b8a;
  border-color: rgba(232, 24, 72, 0.35);
}
.niche-del-btn svg { width: 16px; height: 16px; display: block; }

/* Clickable chrome fields (no «Открыть») */
.nd-field-open {
  position: relative;
  display: block;
  cursor: pointer;
  width: 100%;
}
.nd-field-open .nd-chrome {
  padding-right: 28px;
  transition: border-color 120ms ease;
  pointer-events: none;
}
.nd-field-open:hover .nd-chrome {
  border-color: rgba(255, 255, 255, 0.22);
}
.nd-field-open:focus {
  outline: none;
}
.nd-field-open:focus .nd-chrome {
  border-color: rgba(232, 24, 72, 0.45);
}
.nd-chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  pointer-events: none;
  font-weight: 300;
}

/* Drawer sticky footer + dirty */
.niche-drawer-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 22px 16px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
}
.nd-dirty-badge {
  font-size: 12px;
  color: var(--muted);
  margin-right: auto;
}
.nd-dirty-badge:not(.hidden)::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  margin-right: 7px;
  vertical-align: middle;
}
.niche-drawer-head-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding-top: 4px;
}
.nd-test-header {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--field);
}
.niche-drawer-body {
  padding-bottom: 16px;
}

/* Delete confirm */
.modal-content-sm {
  width: min(420px, calc(100vw - 32px));
  max-height: none;
}
.niche-delete-modal .modal-header { padding-bottom: 8px; }
.niche-delete-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  width: 100%;
}
.btn-danger {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}
.btn-danger:hover { filter: brightness(1.06); }

@media (max-width: 1100px) {
  .niches-list-head, .niche-row {
    grid-template-columns: minmax(0, 1fr) 160px 168px 56px 100px 56px 60px 60px 60px 48px !important;
  }
}


/* ===== v4.1 polish lock ===== */
.niches-list-wrap { width: 100%; }
.niches-list-head,
.niche-row {
  width: 100% !important;
  box-sizing: border-box !important;
  grid-template-columns: minmax(0, 1fr) 160px 168px 56px 100px 56px 60px 60px 60px 48px !important;
  gap: 10px !important;
  padding-left: 12px !important;
  padding-right: 20px !important;
}
.niche-row {
  min-height: 56px !important;
  height: 56px !important;
}
.niche-row-name {
  font-size: 15px !important;
  font-weight: 600 !important;
}
.niche-row-regions .region-chip {
  font-size: 12px !important;
  height: 22px !important;
  padding: 0 9px !important;
}
.niche-row-id {
  font-size: 12px !important;
}
.niche-row-num {
  font-size: 13px !important;
}
.nlh-name, .nlh-region, .nlh-id, .nlh-client, .nlh-card, .nlh-test, .nlh-num, .nlh-del {
  font-size: 11px !important;
}
.niche-row-cell.niche-del-cell,
.niche-row .niche-del {
  justify-self: end;
}
.niche-del {
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.niche-del:hover { color: #ff6b8a; background: rgba(232,24,72,.08); border-color: rgba(232,24,72,.2); }

/* B: boards filters one row, search flex 1 */
.boards-filters {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  width: 100% !important;
}
.boards-filter-row {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 10px !important;
  width: 100% !important;
  margin: 0 !important;
}
.boards-filter-row .boards-search {
  flex: 1 1 auto !important;
  width: auto !important;
  min-width: 120px !important;
  height: 38px !important;
  font-size: 13px !important;
  margin: 0 !important;
}
.boards-filter-row .boards-dd,
.boards-filter-row .seg {
  flex: 0 0 auto !important;
}
.boards-dd-btn,
.boards-filter-row .seg-btn {
  height: 38px !important;
  font-size: 13px !important;
  padding: 0 12px !important;
}
.boards-filter-row .seg {
  height: 38px !important;
  align-items: center !important;
}
.boards-summary {
  width: 100% !important;
}

/* C: delete modal calm confirm */
.niche-delete-modal.modal-content,
.modal-content.niche-delete-modal,
.niche-delete-modal {
  width: min(440px, calc(100vw - 32px)) !important;
  max-width: 440px !important;
  padding: 30px !important;
  border: 1px solid rgba(255,255,255,.08) !important;
  border-radius: 16px !important;
  box-shadow: 0 24px 64px rgba(0,0,0,.55) !important;
  background: var(--panel) !important;
  outline: none !important;
}
.niche-delete-modal .modal-title {
  font-size: 19px !important;
  font-weight: 600 !important;
  color: var(--text) !important;
}
.niche-delete-modal .modal-help,
#nicheDeleteBody {
  font-size: 14px !important;
  line-height: 1.45 !important;
  color: var(--muted) !important;
  margin-top: 10px !important;
}
.niche-delete-actions {
  display: flex !important;
  justify-content: flex-end !important;
  gap: 12px !important;
  margin-top: 22px !important;
  width: 100% !important;
}
.niche-delete-actions .btn,
.niche-delete-actions .btn-soft,
.niche-delete-actions .btn-danger {
  height: 44px !important;
  min-width: 120px !important;
  padding: 0 18px !important;
  border-radius: 11px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
}
.btn-soft {
  background: var(--surface) !important;
  border: 1px solid rgba(255,255,255,.10) !important;
  color: var(--text) !important;
}
.btn-soft:hover {
  background: #2a2a36 !important;
  border-color: rgba(255,255,255,.16) !important;
}
.niche-delete-actions .btn-danger {
  background: #e81848 !important;
  border: 1px solid #e81848 !important;
  color: #fff !important;
}

/* D: region chips air */
.region-tags {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 10px 10px !important;
  margin-bottom: 10px !important;
}
.region-tag {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  height: 32px !important;
  padding: 8px 12px !important;
  border-radius: 8px !important;
  font-size: 13px !important;
  box-sizing: border-box !important;
}
.region-quick {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  margin-bottom: 14px !important;
}
#regionModal .modal-content,
.region-modal .modal-content {
  width: min(640px, calc(100vw - 32px)) !important;
}
.region-tags-box {
  max-height: 360px !important;
}


/* v4.1c: boards filters = CSS grid, search takes leftover */
.boards-filters {
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  min-width: 0 !important;
}
.boards-filter-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto auto auto !important;
  align-items: center !important;
  gap: 10px !important;
  width: 100% !important;
  min-width: 0 !important;
  flex-wrap: unset !important;
  flex-direction: unset !important;
}
.boards-filter-row > * {
  margin: 0 !important;
  min-width: 0 !important;
}
.boards-filter-row input#boardsSearch,
.boards-filter-row input.boards-search,
.boards-filter-row .boards-search,
.boards-filter-row .input-search.boards-search {
  grid-column: 1 !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  flex: unset !important;
  display: block !important;
  height: 38px !important;
  font-size: 13px !important;
  box-sizing: border-box !important;
}
.boards-filter-row .boards-dd { grid-column: 2 !important; }
.boards-filter-row #boardsAccessSeg,
.boards-filter-row .seg#boardsAccessSeg { grid-column: 3 !important; }
.boards-filter-row #boardsStatusSeg,
.boards-filter-row .seg#boardsStatusSeg { grid-column: 4 !important; }
.boards-filter-row .boards-dd,
.boards-filter-row .seg {
  flex: unset !important;
  width: auto !important;
  justify-self: start !important;
}
.boards-dd-btn,
.boards-filter-row .seg-btn {
  height: 38px !important;
  font-size: 13px !important;
  white-space: nowrap !important;
}


/* ===== niches UX v5 ===== */

/* denser shared list grid */
.niches-list-head,
.niche-row {
  grid-template-columns: minmax(0, 1fr) 160px 168px 56px 100px 56px 60px 60px 60px 48px !important;
  gap: 8px !important;
  padding-left: 12px !important;
  padding-right: 16px !important;
}
@media (max-width: 1100px) {
  .niches-list-head, .niche-row {
    grid-template-columns: minmax(0, 1fr) 160px 168px 56px 100px 56px 60px 60px 60px 48px !important;
  }
}

.niches-hint { display: none !important; }

.niches-search {
  min-width: 300px !important;
  width: min(360px, 42vw) !important;
  flex: 1 1 280px;
}

.nlh-name, .nlh-region, .nlh-id,
.niche-row-name, .niche-row-regions, .niche-row-id {
  justify-self: start;
  text-align: left;
}
.nlh-client, .nlh-card, .nlh-test, .nlh-num, .nlh-del,
.niche-row-cell, .niche-row-num {
  justify-self: center;
  text-align: center;
}
.nlh-test { text-align: center !important; }
.niche-row-cell { display: flex; align-items: center; justify-content: center; width: 100%; }

/* trash Lucide */
.niche-del-btn {
  width: 36px !important;
  height: 36px !important;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: #8b8b9a !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.niche-del-btn:hover {
  color: #e81848 !important;
  background: rgba(232, 24, 72, 0.12);
  border-color: rgba(232, 24, 72, 0.35);
}
.niche-del-btn svg {
  width: 18px !important;
  height: 18px !important;
  display: block;
}

/* custom region checkboxes */
.boards-dd-menu {
  min-width: 220px !important;
  padding: 8px !important;
}
.boards-dd-menu label.lh-check,
label.lh-check {
  position: relative;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  height: 36px !important;
  padding: 0 10px !important;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  margin: 0;
  box-sizing: border-box;
}
.boards-dd-menu label.lh-check:hover,
label.lh-check:hover {
  background: var(--surface);
}
.lh-check > input[type="checkbox"] {
  position: absolute !important;
  opacity: 0 !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  pointer-events: none;
}
.lh-check-box {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  background: var(--field);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
}
.lh-check-box svg {
  width: 12px;
  height: 12px;
  display: block;
  opacity: 0;
}
.lh-check > input[type="checkbox"]:checked + .lh-check-box {
  background: #e81848;
  border-color: #e81848;
  color: #fff;
}
.lh-check > input[type="checkbox"]:checked + .lh-check-box svg {
  opacity: 1;
  stroke: #fff;
  color: #fff;
}
.lh-check > input[type="checkbox"]:focus-visible + .lh-check-box {
  outline: 2px solid rgba(232, 24, 72, 0.55);
  outline-offset: 2px;
}
.lh-check-text {
  flex: 1;
  min-width: 0;
  text-align: left;
  color: var(--text);
}

/* custom counter steppers — one horizontal row */
.nd-counters {
  display: flex !important;
  flex-direction: row !important;
  align-items: stretch !important;
  gap: 12px !important;
  width: 100%;
  max-width: 420px;
}
.nd-counter {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.nd-counter-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.nd-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 40px;
  padding: 0 8px 0 12px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-sizing: border-box;
}
.nd-stepper .count-value {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--text);
  min-width: 2ch;
}
.nd-stepper-btns {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  flex-shrink: 0;
}
.nd-step {
  width: 22px;
  height: 16px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}
.nd-step:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}
.nd-step img {
  display: block;
  width: 14px;
  height: 14px;
  opacity: 0.75;
  filter: invert(1) brightness(0.85);
}
.nd-step:hover img { opacity: 1; }
.nd-stepper-ro {
  justify-content: flex-start;
  padding-right: 12px;
  cursor: default;
}

/* free / PRO chips + access filter */
.board-chip-free {
  color: #8b8b9a !important;
  background: var(--field) !important;
  border-color: rgba(255, 255, 255, 0.10) !important;
}
.board-chip-pro {
  background: rgba(232, 24, 72, 0.12) !important;
  color: #e81848 !important;
  border-color: rgba(232, 24, 72, 0.35) !important;
}
#boardsAccessSeg .seg-btn[data-access="PRO"].active {
  background: rgba(232, 24, 72, 0.14) !important;
  color: #e81848 !important;
}
#boardsAccessSeg .seg-btn[data-access="free"].active {
  background: var(--surface) !important;
  color: var(--text-secondary) !important;
}

.board-params-btn.btn-icon,
.btn-icon.board-params-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon.board-params-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border);
}
.btn-icon.board-params-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}
.board-row {
  grid-template-columns: minmax(140px, 1.4fr) auto minmax(48px, auto) 44px 44px !important;
}
.board-en, .board-params-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* modals larger + icon close never overlaps title */
.niche-modal .modal-content,
.modal-content-lg,
#regionModal .modal-content,
.region-modal .modal-content {
  width: min(720px, calc(100vw - 32px)) !important;
  min-width: min(640px, calc(100vw - 32px)) !important;
  max-height: min(820px, calc(100vh - 40px));
}
.niche-modal .modal-header {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.niche-modal .modal-header-text {
  flex: 1;
  min-width: 0;
  padding-right: 48px;
}
.modal-icon-close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modal-icon-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border);
}
.modal-icon-close img {
  display: block;
  width: 18px;
  height: 18px;
  filter: invert(1) brightness(0.75);
  opacity: 0.9;
}
.modal-icon-close:hover img { opacity: 1; filter: invert(1); }

.niche-drawer-close {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
}
.niche-drawer-close img {
  display: block;
  width: 18px;
  height: 18px;
  filter: invert(1) brightness(0.75);
}
.nd-chevron img {
  display: block;
  width: 16px;
  height: 16px;
  filter: invert(1) brightness(0.65);
  opacity: 0.85;
}

/* keep boards filter one-row FILL search grid from v4.1b */
.boards-filter-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto auto auto !important;
}


/* ===== niches UX v5.1 — drawer header + modals + list axes ===== */
.niche-drawer {
  width: min(700px, 100vw) !important;
  min-width: min(700px, 100vw) !important;
}
.niche-drawer-head {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  padding: 16px 20px !important;
  flex-shrink: 0;
}
.niche-drawer-title-block {
  flex: 1 1 auto !important;
  min-width: 0 !important;
}
.niche-drawer-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.niche-drawer-head-actions {
  display: flex !important;
  align-items: center !important;
  gap: 16px !important;
  flex: 0 0 auto !important;
  flex-shrink: 0 !important;
  padding-top: 0 !important;
  position: static !important;
}
.nd-test-header { flex-shrink: 0; margin: 0; }
.niche-drawer-close {
  /* niche-drawer-close-gap */
  margin-left: 2px !important;
  position: static !important;
  top: auto !important;
  right: auto !important;
  left: auto !important;
  inset: auto !important;
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  min-height: 40px !important;
  margin: 0 !important;
  padding: 0 !important;
  z-index: auto !important;
  flex-shrink: 0 !important;
  border-radius: 10px !important;
  border: 1px solid var(--border) !important;
  background: var(--field) !important;
  color: var(--muted) !important;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.niche-drawer-close:hover {
  color: var(--text) !important;
  background: rgba(255, 255, 255, 0.06) !important;
}
.niche-drawer-close img {
  display: block;
  width: 18px;
  height: 18px;
  filter: invert(1) brightness(0.75);
}

.niche-modal .modal-content,
.modal-content-lg,
#regionModal .modal-content,
.region-modal .modal-content,
#editModal .modal-content {
  width: min(840px, calc(100vw - 32px)) !important;
  min-width: min(840px, calc(100vw - 32px)) !important;
  max-width: min(840px, calc(100vw - 32px)) !important;
  height: min(720px, calc(100vh - 48px)) !important;
  min-height: min(720px, calc(100vh - 48px)) !important;
  max-height: min(720px, calc(100vh - 48px)) !important;
  padding: 28px 32px !important;
  box-sizing: border-box !important;
  display: flex !important;
  flex-direction: column !important;
}
.niche-modal .modal-body,
#regionModal .modal-body,
#editModal .modal-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: auto !important;
}
.niche-modal .modal-header {
  position: relative !important;
  display: flex !important;
  align-items: flex-start !important;
  justify-content: space-between !important;
  gap: 16px !important;
  flex-shrink: 0 !important;
}
.niche-modal .modal-header-text {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  padding-right: 8px !important;
}
.niche-modal .modal-icon-close,
.modal-icon-close {
  position: static !important;
  flex-shrink: 0 !important;
  width: 40px !important;
  height: 40px !important;
}
.niche-modal .modal-footer,
#regionModal .modal-footer,
#editModal .modal-footer {
  flex-shrink: 0 !important;
  margin-top: 16px;
  padding-top: 12px;
}
.modal-content-sm,
.niche-delete-modal.modal-content,
.modal-content.niche-delete-modal {
  width: min(420px, calc(100vw - 32px)) !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-height: none !important;
  height: auto !important;
  padding: 24px !important;
}

/* C/D/E list axes */
.niches-list-head,
.niche-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 160px 168px 56px 100px 56px 60px 60px 60px 48px !important;
  column-gap: 10px !important;
  align-items: center !important;
  padding-left: 12px !important;
  padding-right: 16px !important;
  box-sizing: border-box !important;
}
.niches-list-head {
  align-items: center !important;
}
.nlh-name, .niche-row-name {
  min-width: 0 !important;
  justify-self: start !important;
  text-align: left !important;
}
.nlh-region, .niche-row-regions {
  width: 160px !important;
  max-width: 160px !important;
  min-width: 0 !important;
  justify-self: start !important;
  overflow: hidden !important;
}
.niche-row-regions {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  justify-content: flex-start !important;
}
.niche-row-regions .region-chip {
  flex: 0 1 auto !important;
  max-width: 100% !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
.nlh-id, .niche-row-id {
  width: 168px !important;
  max-width: 168px !important;
  justify-self: start !important;
  text-align: left !important;
  font-family: var(--font-mono) !important;
  font-variant-numeric: tabular-nums !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
.nlh-client, .nlh-card, .nlh-test, .nlh-del,
.niche-row-cell {
  justify-self: center !important;
  text-align: center !important;
}
.nlh-num, .niche-row-num {
  justify-self: end !important;
  text-align: right !important;
  font-variant-numeric: tabular-nums !important;
  padding-right: 8px !important;
  box-sizing: border-box !important;
}
.nlh-del, .niche-row-cell.niche-del-cell, .niche-row .niche-del {
  justify-self: center !important;
  padding-left: 4px !important;
}


/* ===== niches UX v5.2 — one baseline ===== */

/* Page head: title + search/create on ONE line */
.niches-head {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px !important;
}
.niches-head-text { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.niches-actions {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  flex-shrink: 0 !important;
}
.niches-search,
.niches-actions .input-search {
  height: 40px !important;
  min-height: 40px !important;
  max-height: 40px !important;
  padding: 0 12px !important;
  line-height: 40px !important;
  box-sizing: border-box !important;
  margin: 0 !important;
}
.niches-actions .btn,
.niches-actions .btn-accent,
#toggleCreateForm {
  height: 40px !important;
  min-height: 40px !important;
  max-height: 40px !important;
  padding: 0 16px !important;
  line-height: 1 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
  margin: 0 !important;
}

/* List row: every cell on the same vertical center */
.niches-list-head,
.niche-row {
  align-items: center !important;
}
.niche-row {
  height: 52px !important;
  min-height: 52px !important;
  max-height: 52px !important;
}
.niche-row > * {
  display: flex !important;
  align-items: center !important;
  align-self: center !important;
  height: 52px !important;
  min-height: 52px !important;
  max-height: 52px !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  line-height: 1.15 !important;
}
.niche-row-name {
  font-size: 14px !important;
  font-weight: 600 !important;
  line-height: 1.15 !important;
}
.niche-row-id {
  font-size: 12px !important;
  line-height: 1.15 !important;
  display: flex !important;
  align-items: center !important;
}
.niche-row-regions {
  display: flex !important;
  align-items: center !important;
  height: 52px !important;
}
.niche-row-regions .region-chip {
  height: 22px !important;
  line-height: 22px !important;
  display: inline-flex !important;
  align-items: center !important;
  padding: 0 8px !important;
}
.niche-row-num {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  height: 52px !important;
  line-height: 1 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}
.niche-row-cell {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 52px !important;
}
.card-seg {
  height: 28px !important;
  display: inline-flex !important;
  align-items: center !important;
  padding: 2px !important;
  box-sizing: border-box !important;
}
.card-seg .seg-opt {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 24px !important;
  padding: 0 10px !important;
  line-height: 1 !important;
  box-sizing: border-box !important;
}
.niche-row input.lh-switch {
  margin: 0 !important;
  align-self: center !important;
}
.niche-del-btn {
  width: 36px !important;
  height: 36px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.niches-list-head > * {
  display: flex !important;
  align-items: center !important;
  height: 28px !important;
  line-height: 1 !important;
}

/* Region modal: no giant empty void; footer on one line */
#regionModal .modal-content,
.region-modal-content {
  width: min(840px, calc(100vw - 32px)) !important;
  min-width: min(720px, calc(100vw - 32px)) !important;
  max-width: min(840px, calc(100vw - 32px)) !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: min(720px, calc(100vh - 48px)) !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 24px 28px !important;
  box-sizing: border-box !important;
}
.region-modal-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: auto !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
}
#regionModal .region-tags-box,
.region-modal-content .region-tags-box {
  flex: 1 1 auto !important;
  min-height: 120px !important;
  max-height: none !important;
  display: flex !important;
  flex-direction: column !important;
}
.region-quick-label { margin-top: 4px !important; margin-bottom: 0 !important; }
.region-modal-footer,
#regionModal .modal-footer.modal-footer-split {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px !important;
  flex-shrink: 0 !important;
  margin-top: 16px !important;
  padding-top: 16px !important;
  border-top: 1px solid var(--border) !important;
  min-height: 48px !important;
}
.region-count-label,
#regionModal #regionCountLabel {
  display: inline-flex !important;
  align-items: center !important;
  height: 40px !important;
  margin: 0 !important;
  line-height: 1 !important;
  font-size: 13px !important;
}
#regionModal #regionModalSave,
.region-modal-footer .btn-accent {
  height: 40px !important;
  min-height: 40px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0 !important;
  padding: 0 18px !important;
  line-height: 1 !important;
  box-sizing: border-box !important;
}

/* edit/prompt modals: same idea — max not forced empty */
#editModal .modal-content {
  height: auto !important;
  min-height: min(520px, calc(100vh - 48px)) !important;
  max-height: min(720px, calc(100vh - 48px)) !important;
}

/* v52c optical baseline for mono/nums vs name */
.niche-row-id,
.niche-row-num {
  transform: translateY(-1px);
}
.niche-row-name {
  transform: translateY(1px);
}


/* ===== niches UX v5.3 — dual panes + ВСЕГО baseline + sticky save ===== */

/* ВСЕГО same box metrics as ЦЕЛ/НЕЦЕЛ steppers */
.nd-total-ro {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 12px !important;
  background: var(--field) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  box-sizing: border-box !important;
  cursor: default !important;
}
.nd-total-ro .count-value,
.nd-stepper .count-value {
  font-variant-numeric: tabular-nums !important;
  font-size: 14px !important;
  line-height: 1 !important;
  color: var(--text) !important;
  display: inline-flex !important;
  align-items: center !important;
  height: 100% !important;
}
.nd-total-ro .count-value { color: var(--muted) !important; }
.nd-counters {
  align-items: stretch !important;
}
.nd-counter {
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
}

/* Edit modal: wide, body scroll, footer sticky with Save */
#editModal .edit-modal-content,
#editModal .modal-content {
  width: min(1280px, calc(100vw - 24px)) !important;
  min-width: min(960px, calc(100vw - 24px)) !important;
  max-width: min(1280px, calc(100vw - 24px)) !important;
  height: min(860px, calc(100vh - 32px)) !important;
  min-height: min(640px, calc(100vh - 32px)) !important;
  max-height: min(860px, calc(100vh - 32px)) !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 20px 24px 16px !important;
  box-sizing: border-box !important;
}
.edit-modal-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
}
.edit-modal-footer,
#editModal .modal-footer {
  flex-shrink: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 12px !important;
  margin-top: 12px !important;
  padding-top: 12px !important;
  border-top: 1px solid var(--border) !important;
  min-height: 52px !important;
}
#editModal #modalSave {
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 20px !important;
  display: inline-flex !important;
  align-items: center !important;
  margin: 0 !important;
}

/* Dual panes: left | right, large fonts */

/* dual panes must respect .hidden */
.field-dual-editor.hidden,
#promptQualifierDual.hidden,
#editModal .keyword-dual-editor.hidden,
#keywordDualEditor.hidden {
  display: none !important;
}

.field-dual-editor:not(.hidden),
#editModal .keyword-dual-editor:not(.hidden),
#promptQualifierDual:not(.hidden) {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  gap: 16px !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: 100% !important;
}
.field-editor-pane,
#editModal .keyword-editor-pane {
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  height: 100% !important;
}
.field-editor-pane > span,
#editModal .keyword-editor-pane > span {
  font-size: 12px !important;
  font-weight: 600 !important;
  letter-spacing: 0.06em !important;
  text-transform: uppercase !important;
  color: var(--muted) !important;
}
.field-dual-textarea,
#editModal .modal-textarea,
#editModal .keyword-textarea,
#modalPrompt,
#modalQualifier,
#modalKeywords,
#modalKeywordsExact {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: 100% !important;
  width: 100% !important;
  font-size: 16px !important;
  line-height: 1.55 !important;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif !important;
  padding: 14px 16px !important;
  box-sizing: border-box !important;
  resize: none !important;
}
#modalPrompt,
#modalQualifier {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
  font-size: 15px !important;
  line-height: 1.5 !important;
}
#editModal #modalTextarea.modal-textarea:not(.hidden) {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: 100% !important;
  font-size: 16px !important;
  line-height: 1.55 !important;
}

@media (max-width: 900px) {
  .field-dual-editor,
  #editModal .keyword-dual-editor,
  #promptQualifierDual {
    grid-template-columns: 1fr !important;
  }
}


/* ===== niches UX v5.4 — boards name=link, no domain col; single prompt/qualifier ===== */
.board-row {
  display: grid !important;
  grid-template-columns: minmax(140px, 1.4fr) auto minmax(48px, auto) 44px 44px !important;
  align-items: center !important;
  column-gap: 10px !important;
}
.board-domain { display: none !important; }
.board-name-cell {
  min-width: 0 !important;
  display: flex !important;
  align-items: center !important;
}
.board-name-link {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: var(--text) !important;
  text-decoration: none !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 100% !important;
}
.board-name-link:hover {
  color: #ff5a7a !important;
  text-decoration: underline !important;
}
.board-chips {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex-wrap: nowrap !important;
  justify-self: start !important;
}
.board-stat {
  justify-self: end !important;
  text-align: right !important;
  font-variant-numeric: tabular-nums !important;
}
.board-en,
.board-params-cell {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Single-field prompt/qualifier still large */
#editModal .edit-modal-content:has(#modalTextarea:not(.hidden)) #modalTextarea {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: 100% !important;
  font-size: 16px !important;
  line-height: 1.55 !important;
}
#editModal textarea {
  spellcheck: false;
}


/* nichesv55 — only live board params */
.board-params-grid--live { grid-template-columns: 1fr; gap: 8px; }
.board-params-help { margin: 8px 0 0; font-size: 12px; line-height: 1.35; color: var(--text, #e8e8e8); opacity: 0.85; }
.board-params-help.muted { opacity: 0.55; margin-top: 4px; }

.board-chip-dead { background: rgba(239,68,68,0.18); color: #fca5a5; }
.board-chip-sick { background: rgba(245,158,11,0.18); color: #fcd34d; }
.board-row:has(.board-chip-dead) { opacity: 0.72; }


/* ===== nichesv60 — hairline under head, labels left, list to panel edge ===== */
.niches-v3 .niches-panel {
  padding: 20px 22px 0 !important;
  overflow: hidden;
  min-height: 0;
}
.niches-list-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 4px;
  padding-top: 0;
  padding-bottom: 0;
  border-top: none;
}
.niches-list-head {
  flex: 0 0 auto;
  scrollbar-gutter: stable;
  padding-top: 2px !important;
  padding-bottom: 8px !important;
  margin-bottom: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.niches-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none !important;
  overflow: auto !important;
  padding-bottom: 0 !important;
  padding-top: 6px;
  scrollbar-gutter: stable;
}
.nlh-client,
.nlh-card,
.nlh-test {
  justify-content: center !important;
  text-align: center !important;
  width: 100%;
  transform: translateX(-8px);
}
.nlh-del {
  justify-content: center !important;
  text-align: center !important;
  width: 100%;
}
.nlh-num {
  justify-content: flex-end !important;
  text-align: right !important;
  width: 100%;
}
.niche-row-cell {
  justify-content: center !important;
}


/* ===== nichesv61 — board topic field ===== */
.nd-topic-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.nd-topic-label {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.nd-topic-input {
  width: 148px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--field);
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}
.nd-topic-input::placeholder {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
}
.nd-topic-input:focus {
  outline: none;
  border-color: rgba(255,255,255,0.22);
}


/* ===== drawerSave motion ===== */
#drawerSave {
  position: relative;
  min-width: 132px;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease, opacity 0.18s ease;
}
#drawerSave:not(:disabled) {
  animation: drawerSavePulse 1.8s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(232, 24, 72, 0.45);
}
#drawerSave:not(:disabled):hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}
#drawerSave:not(:disabled):active {
  transform: translateY(0) scale(0.98);
}
#drawerSave.is-saving,
#drawerSave.is-saved {
  animation: none;
  box-shadow: none;
}
#drawerSave.is-saving {
  pointer-events: none;
  opacity: 0.92;
}
#drawerSave.is-saving::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -2px;
  animation: drawerSaveSpin 0.7s linear infinite;
}
#drawerSave.is-saved {
  background: #16a34a !important;
  border-color: #16a34a !important;
  animation: drawerSavePop 0.45s ease;
}
@keyframes drawerSavePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 24, 72, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(232, 24, 72, 0); }
}
@keyframes drawerSaveSpin {
  to { transform: rotate(360deg); }
}
@keyframes drawerSavePop {
  0% { transform: scale(0.96); }
  40% { transform: scale(1.04); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  #drawerSave:not(:disabled),
  #drawerSave.is-saved,
  #drawerSave.is-saving::after {
    animation: none;
  }
}


/* Topics */
.nd-topic-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nd-topic-status { font-size: 11px; color: var(--muted); padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,0.04); border: 1px solid var(--border); }
.nd-topic-status.is-on { color: #86efac; border-color: rgba(134,239,172,0.35); }
.nd-topic-find { white-space: nowrap; }
.topic-badge { display: inline-block; margin-left: 8px; font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 999px; vertical-align: middle; }
.topic-badge.is-on { color: #86efac; background: rgba(134,239,172,0.12); border: 1px solid rgba(134,239,172,0.28); }
.topic-badge.is-miss { color: #fbbf24; background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,0.28); }
.niches-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.boards-bulk-hint { font-size: 11px; color: var(--muted); }
#boardsBulkSeg .seg-btn { cursor: pointer; }


/* Manual group_id in drawer head */
.nd-gid-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted, #9aa3af);
}
.nd-gid-label {
  flex: 0 0 auto;
  white-space: nowrap;
}
.nd-gid-input {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 220px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.25);
  color: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.nd-gid-input:focus {
  outline: none;
  border-color: rgba(255,80,80,0.45);
}
