/* =========================================================
   VK Ads Control — CSS (Inter + Material-ish / clean SaaS)
   Goals:
   - Fresh typography (Inter), calmer weights (no 900/950 everywhere)
   - Cleaner “tiles” after logo (Account / Mode+Goal / KPI)
   - Readable settings width + aligned grids
   - Keep tree/table UX, improve density + hover + focus
   ========================================================= */

/* ---------- Reset / Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

:root{
  /* Fonts */
  --sans: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";

  /* Weights */
  --w-regular: 450;
  --w-medium: 550;
  --w-semibold: 650;
  --w-bold: 750;

  /* Surfaces */
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #fbfcff;

  /* Text */
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;

  /* Borders / Shadows */
  --border: #e5e7eb;
  --border-2: #eef2f7;
  --shadow-1: 0 1px 2px rgba(15,23,42,.06), 0 10px 28px rgba(15,23,42,.08);
  --shadow-2: 0 12px 34px rgba(15,23,42,.14);

  /* Accent (Google-ish) */
  --accent: #1a73e8;
  --accent-2: #e8f0fe;
  --accent-3: #d2e3fc;

  /* Status */
  --good: #12b76a;
  --good-bg: #e8f5ee;

  --warn: #b06000;
  --warn-bg: #fef7e0;

  --bad: #e8453c;
  --bad-bg: #fce8e6;

  /* Radius / Spacing */
  --radius: 16px;
  --radius-sm: 12px;

  --pad: 16px;
  --pad-lg: 20px;
  --gap: 14px;

  /* Settings page width */
  --settings-max: 820px;

  /* Rec colors */
  --rec-up: var(--good);
  --rec-hold: var(--accent);
  --rec-down: var(--bad);
  --rec-low: var(--muted-2);

  --rec-up-bg: var(--good-bg);
  --rec-hold-bg: var(--accent-2);
  --rec-down-bg: var(--bad-bg);
  --rec-low-bg: #f3f4f6;

  /* Tree visuals */
  --tree-line: rgba(15,23,42,0.10);
  --tree-dot: rgba(15,23,42,0.35);
  --tree-dot-strong: rgba(15,23,42,0.55);

  /* Focus ring */
  --ring: 0 0 0 4px rgba(26,115,232,0.18);

  /* Density controls */
  --row-pad-y: 9px;
  --row-pad-x: 10px;
}

html, body { height: 100%; }

body{
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: var(--w-regular);
  line-height: 1.45;
  letter-spacing: -0.1px;
  color: var(--text);
  background:
	radial-gradient(1200px 520px at 10% -10%, rgba(232,240,254,0.95) 0%, rgba(232,240,254,0) 55%),
	radial-gradient(980px 520px at 95% -15%, rgba(252,232,230,0.85) 0%, rgba(252,232,230,0) 55%),
	var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

.right{ text-align: right; }
.nowrap{ white-space: nowrap; }

.mono{ font-family: var(--mono); }
.mono, .tabular { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1, "lnum" 1; }

.ellipsis{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.iconSvg{ display:block; }

:focus-visible{
  outline: none;
  box-shadow: var(--ring);
  border-radius: 10px;
}

/* Screen-reader only */
.srOnly{
  position:absolute !important;
  width:1px; height:1px;
  padding:0; margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}

/* ---------- Layout ---------- */
.app{
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px 14px 44px;
}

.grid{
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: var(--gap);
  align-items: start;
}

.stack{
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  align-items: start;
}

.rulesFull{ display: block; }

@media (max-width: 980px){
  .grid{ grid-template-columns: 1fr; }
}

/* highlight row from JS (sim focus) */
.rowHL {
  outline: 2px solid rgba(255, 193, 7, .7);
  outline-offset: -2px;
}

/* ---------- Typography ---------- */
.headline{
  margin: 0;
  font-size: 20px;
  font-weight: var(--w-bold);
  letter-spacing: -0.25px;
}

.subhead{
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 1060px;
}

.h2{
  margin: 0;
  font-size: 15px;
  font-weight: var(--w-semibold);
  letter-spacing: -0.15px;
}

.h3{
  margin: 0;
  font-size: 14px;
  font-weight: var(--w-semibold);
  letter-spacing: -0.12px;
}

.rulesTitle{
  font-size: 18px;
  font-weight: var(--w-bold);
  letter-spacing: -0.35px;
}

.muted{ color: var(--muted); font-size: 12.5px; }

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

/* ---------- Cards ---------- */
.card{
  background: rgba(255,255,255,0.88);
  backdrop-filter: saturate(140%) blur(10px);
  border: 1px solid rgba(15,23,42,0.10);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.panel{ padding: var(--pad-lg); }
.panelLarge{ padding: 22px 22px; }

/* Settings page: keep form readable */
#tab_rules .panelLarge{ margin: 0 auto; max-width: var(--settings-max); }

.cardHead{
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

/* ---------- Topbar ---------- */
.topbar{
  padding: var(--pad-lg);
  border: 1px solid rgba(15,23,42,0.10);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.88);
  backdrop-filter: saturate(140%) blur(10px);
  box-shadow: var(--shadow-1);
  margin-bottom: 14px;
}

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

/* Brand */
.brandHeader{
  display:flex;
  align-items:flex-start;
  gap: 14px;
}

.brandLogo{
  width:120px;
  height:40px;
  display:flex;
  align-items:center;
  justify-content:flex-start;
  flex: 0 0 auto;
}

.brandLogo img{
  height:30px;
  display:block;
}

.brandText{ min-width: 0; }

/* --- 3 tiles after logo (Account / Mode+Goal / KPI) --- */
.topbarControls{
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1.45fr 1fr 1.05fr;
  gap: 12px;
  align-items: stretch;
}

.topbarControls.compact .controlGroup{
  padding: 14px 14px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(15,23,42,0.10);
  box-shadow: 0 1px 1px rgba(15,23,42,.05), 0 10px 26px rgba(15,23,42,.06);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 122px;
}

/* focus-within ring for groups */
.topbarControls.compact .controlGroup:focus-within{
  border-color: rgba(26,115,232,0.45);
  box-shadow: 0 0 0 4px rgba(26,115,232,0.14), 0 10px 26px rgba(15,23,42,.06);
}

/* Tile title */
.controlTitle{
  font-size: 11px;
  font-weight: var(--w-semibold);
  letter-spacing: .3px;
  text-transform: none;
  color: var(--muted);
  margin: 0 0 10px;
}

/* Account tile: select + button */
.accountRow{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}
.accountRow .select{ min-width: 0; }

/* VK status line */
#vkStatusLine{
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.35;
}

/* Mode+Goal tile */
.modeGoalGroup{ align-items: flex-start; }

.modeGoalGrid{
  display:grid;
  grid-template-columns: 64px 1fr;
  gap: 10px 12px;
  align-items: center;
  width: 100%;
}

.mgLabel{
  font-size: 11px;
  font-weight: var(--w-semibold);
  color: var(--muted);
  text-align: left;
}

.mgValue{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap: 8px;
  min-width: 0;
  font-size: 14px;
}

.mgPill{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(251,252,255,0.92);
  font-size: 12.5px;
  color: #0f172a;
  white-space: nowrap;
}

.modeSaveStatus{
  grid-column: 1 / -1;
  margin-top: 6px;
  white-space: nowrap;
  min-width: 140px;
  font-size: 12.5px;
}
.modeSaveStatus.ok{ color: var(--good); }
.modeSaveStatus.err{ color: var(--bad); }
.modeSaveStatus.pending{ color: var(--muted); }

/* KPI tile */
.kpiGroup{ align-items: flex-start; }

.kpiTiles{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  min-width: 260px;
}

.kpiTile{
  border: 1px solid rgba(15,23,42,0.08);
  border-radius: 12px;
  background: rgba(251,252,255,0.92);
  padding: 10px 12px;
}

.kpiLabel{
  font-size: 11px;
  font-weight: var(--w-semibold);
  color: var(--muted);
  margin-bottom: 4px;
}

.kpiVal{
  font-weight: var(--w-bold);
  font-size: 15px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* Responsive */
@media (max-width: 980px){
  .topbarTitle{ flex-direction: column; }
  .topbarControls{ grid-template-columns: 1fr; }
  .accountRow{ grid-template-columns: 1fr; }
  #simulateBtnTop{ width: 100%; height: 40px; }
}

/* ---------- Banner ---------- */
.banner{
  border: 1px dashed rgba(15,23,42,0.14);
  background: rgba(251,252,255,0.92);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12.8px;
}

/* ---------- Tabs ---------- */
.tabs{
  display: inline-flex;
  gap: 8px;
  margin: 14px 0;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(10px);
}

.tab{
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: var(--w-semibold);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.tab:hover{
  background: rgba(26,115,232,0.08);
  color: #174ea6;
}

.tab.active{
  background: var(--accent-2);
  color: #174ea6;
  border: 1px solid var(--accent-3);
}

/* ---------- Forms (global) ---------- */
.label{
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
  font-weight: var(--w-semibold);
}

.kicker{
  font-size: 15px;
  font-weight: var(--w-semibold);
  letter-spacing: .2px;
  color: var(--muted);
}

.hint{
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
}

.field{ display: grid; gap: 6px; }
.inlineField{ min-width: 220px; }

.input,
.select{
  width: 100%;
  height: 40px;
  border: 1px solid rgba(15,23,42,0.10);
  border-radius: 12px;
  padding: 0 12px;
  background: rgba(255,255,255,0.92);
  color: var(--text);
  font-size: 14px;
  font-weight: var(--w-regular);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.input::placeholder{ color: rgba(100,116,139,0.75); }

.select{
  padding-right: 36px;
  background-image:
	linear-gradient(45deg, transparent 50%, var(--muted) 50%),
	linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
	calc(100% - 16px) 17px,
	calc(100% - 11px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  appearance: none;
}

.selectCompact{ height: 38px; }

.input:focus,
.select:focus{
  border-color: rgba(26,115,232,0.65);
  box-shadow: var(--ring);
  background: #fff;
}

/* ---------- Buttons ---------- */
.btn{
  appearance: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: var(--w-semibold);
  cursor: pointer;
  transition: transform .04s ease, filter .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
  box-shadow: 0 1px 0 rgba(15,23,42,.02);
}

.btn:hover{
  filter: brightness(0.99);
  box-shadow: 0 12px 28px rgba(26,115,232,0.18);
}

.btn:active{ transform: translateY(1px); }

.btn.secondary{
  background: rgba(255,255,255,0.92);
  color: #174ea6;
  border-color: var(--accent-3);
}

.btn.secondary:hover{
  background: rgba(26,115,232,0.06);
  box-shadow: 0 12px 24px rgba(26,115,232,0.10);
}

.btn.primary{
  background: var(--accent);
  border-color: var(--accent);
}

/* IMPORTANT: "Выбрать" = такой же secondary как "Применить" */
#applyModeBtn,
#simulateBtnTop{
  height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  white-space: nowrap;
}

/* Loading state (shared with .action too) */
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }

.btn.isLoading{
  position: relative;
  cursor: progress;
  padding-right: 28px;
}
.btn.isLoading::after{
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(15,23,42,.18);
  border-top-color: currentColor;
  animation: spin .8s linear infinite;
  transform: translateY(-50%);
}

.btn:disabled{
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none !important;
  transform: none !important;
}

/* Sticky save footer */
.actionFooter{ display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.actionFooterSticky{
  position: sticky;
  bottom: 12px;
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(15,23,42,0.10);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(10px);
  z-index: 2;
}

/* ---------- Callouts / Lists ---------- */
.callout{
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(251,252,255,0.92);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.calloutTitle{
  font-weight: var(--w-semibold);
  font-size: 13px;
  color: var(--muted);
}
.list{ display: grid; gap: 10px; }

/* ---------- Details (Advanced wrapper) ---------- */
.details{
  border: 1px solid rgba(15,23,42,0.10);
  border-radius: var(--radius);
  background: rgba(251,252,255,0.92);
  overflow: hidden;
  max-width: var(--settings-max);
}

.detailsSummary{
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-weight: var(--w-semibold);
  font-size: 13px;
  border-bottom: 1px solid rgba(15,23,42,0.10);
  user-select: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.detailsTitle{ font-weight: var(--w-bold); font-size: 16px; }
.detailsSummary::-webkit-details-marker{ display: none; }

.detailsSummary::after{
  content: "▾";
  color: var(--muted);
  font-weight: var(--w-bold);
  margin-left: 8px;
  transition: transform .15s ease;
}
details[open] > .detailsSummary::after{ transform: rotate(-180deg); }

/* =========================================================
   SETTINGS PAGE
   ========================================================= */
.settingsHeader{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.settingsForm{
  display: grid;
  gap: 18px;
}

.settingsSection{
  padding-top: 18px;
  border-top: 1px solid rgba(15,23,42,0.08);
}
.settingsSection:first-of-type{
  padding-top: 0;
  border-top: 0;
}

.settingsSectionHead{ margin-bottom: 12px; }

.settingsPrimary .callout{
  background: rgba(255,255,255,0.92);
}

/* Inline inputs */
.settingsInlineInputs{
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

/* Grids */
.settingsGrid{
  display: grid;
  gap: var(--gap);
  align-items: start;
}

.settingsGridPrimary{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
.settingsGrid3{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
.settingsGrid2{ grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 980px){
  .settingsGridPrimary{ grid-template-columns: 1fr; }
  .settingsGrid3{ grid-template-columns: 1fr; }
  .settingsGrid2{ grid-template-columns: 1fr; }
}

.settingsDivider{
  height: 1px;
  background: rgba(15,23,42,0.10);
  margin: 14px 0;
}

.settingsStack{
  display: grid;
  gap: 12px;
}

.switchRow{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 12px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.92);
  border-radius: 14px;
}

.switchMeta .label{ margin-bottom: 4px; }
.switchMeta .hint{ margin-top: 0; }

.advancedBlock{
  padding: 14px;
  border-bottom: 1px solid rgba(15,23,42,0.08);
  background: rgba(251,252,255,0.92);
}
.advancedBlock:last-child{ border-bottom: 0; }

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

.advancedBlockActions{
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: flex-end;
}

@media (max-width: 980px){
  .advancedBlockHead{ flex-direction: column; }
  .advancedBlockActions{ justify-content: flex-start; }
}

.advancedBlockTitle{ margin-bottom: 10px; }

/* Make primary settings slightly stronger */
.settingsPrimary .kicker{
  color: rgba(71,85,105,0.98);
}

/* ---------- Toggle ---------- */
.toggle{
  display: inline-flex;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  user-select: none;
  position: relative;
}
.toggle input{
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggleUi{
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #e5e7eb;
  border: 1px solid rgba(15,23,42,0.10);
  position: relative;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.toggleUi::after{
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15,23,42,.20);
  transition: transform .15s ease;
}

.toggle input:checked + .toggleUi{
  background: var(--accent-2);
  border-color: var(--accent-3);
}
.toggle input:checked + .toggleUi::after{ transform: translateX(20px); }

.toggleText{
  font-size: 13px;
  color: var(--muted);
  font-weight: var(--w-semibold);
}

/* =========================================================
   TABLE
   ========================================================= */
.tableWrap{
  overflow: hidden;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  border: 1px solid rgba(15,23,42,0.10);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.92);
}

.tableWrap.roomy{ border-radius: calc(var(--radius) + 2px); }

@media (max-width: 980px){
  .tableWrap{ overflow: auto; }
}

.table{
  width: 100%;
  border-collapse: collapse;
}

.tableFit{
  min-width: 0 !important;
  table-layout: fixed;
}

.table thead th{
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(251,252,255,0.98);
  border-bottom: 1px solid rgba(15,23,42,0.10);
  color: var(--muted);
  font-size: 12px;
  font-weight: var(--w-semibold);
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
}

.table tbody td{
  padding: var(--row-pad-y) var(--row-pad-x);
  border-bottom: 1px solid rgba(15,23,42,0.06);
  vertical-align: middle;
  font-size: 13px;
}

.table tbody tr:hover{
  background: rgba(26,115,232,0.035);
}

.table td.right{ white-space: nowrap; }

/* Make numeric columns tabular (JS already uses .mono on many cells) */
.table tbody td.right.mono{
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* Row highlight for search/focus */
.rowHighlight{
  background: rgba(26,115,232,0.08) !important;
  outline: 2px solid rgba(26,115,232,0.16);
  outline-offset: -2px;
}

.cellObject{ overflow: hidden; }

/* ---------- Tree: clean hierarchy ---------- */
.nameCell{
  display: flex;
  align-items: center;
  min-width: 0;
  position: relative;
}

.treeIndent{
  display: inline-block;
  width: 0;
  height: 28px;
  flex: 0 0 auto;
  position: relative;
}

.nameCell.indent-0 .treeIndent{ width: 0px; }
.nameCell.indent-1 .treeIndent{ width: 18px; }
.nameCell.indent-2 .treeIndent{ width: 36px; }

.nameCell.indent-1 .treeIndent::before,
.nameCell.indent-2 .treeIndent::before{
  content: "";
  position: absolute;
  left: 9px;
  top: -14px;
  bottom: -14px;
  width: 1px;
  background: linear-gradient(to bottom,
	rgba(15,23,42,0) 0%,
	var(--tree-line) 18%,
	var(--tree-line) 82%,
	rgba(15,23,42,0) 100%);
}

.nameCell.indent-2 .treeIndent::after{
  content: "";
  position: absolute;
  left: 27px;
  top: -14px;
  bottom: -14px;
  width: 1px;
  background: linear-gradient(to bottom,
	rgba(15,23,42,0) 0%,
	var(--tree-line) 18%,
	var(--tree-line) 82%,
	rgba(15,23,42,0) 100%);
}

.nameCell.indent-1::after{
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 999px;
  background: var(--tree-dot);
}
.nameCell.indent-1::before{
  content: "";
  position: absolute;
  left: 9px;
  top: 50%;
  width: 10px;
  height: 1px;
  background: var(--tree-line);
}

.nameCell.indent-2::after{
}
.nameCell.indent-2::before{
  content: "";
  position: absolute;
  left: 27px;
  top: 50%;
  width: 10px;
  height: 1px;
  background: var(--tree-line);
}

/* Expander */
.expander{
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.92);
  color: var(--muted);
  cursor: pointer;
  margin-right: 8px;
  flex: 0 0 auto;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .04s ease, box-shadow .15s ease;
}
.expander:hover{
  background: rgba(26,115,232,0.06);
  border-color: var(--accent-3);
  color: #174ea6;
  box-shadow: 0 10px 18px rgba(15,23,42,0.08);
}
.expander:active{ transform: translateY(1px); }

.expSpacer{
  display: inline-block;
  width: 28px;
  height: 28px;
  margin-right: 8px;
  flex: 0 0 auto;
}

.nameBlock{
  display: grid;
  gap: 0px;
  min-width: 0;
  overflow: hidden;
}

.name{
  font-weight: var(--w-semibold);
  letter-spacing: -0.1px;
  min-width: 0;
}

.meta{
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
}

/* =========================
   RecDot — modern look
   ========================= */

/* ===========================
	  Minimal recDot (override)
	  =========================== */
   
   .recDot{
	 width: 8px;
	 height: 8px;
	 display: inline-block;
	 vertical-align: middle;
	 border-radius: 999px;
	 margin-right: 8px;
	 flex: 0 0 8px;
   
	 /* простая “матовая” точка */
	 background: var(--rec, #9aa0a6);
	 opacity: .9;
   
	 /* без украшательств */
	 box-shadow: none !important;
	 filter: none !important;
	 outline: none;
   }
   
   .recDot:hover{ opacity: 1; }
   
   .recDot.recUp   { --rec: #1e8e3e; } /* зелёный (Google-ish) */
   .recDot.recDown { --rec: #d93025; } /* красный */
   .recDot.recHold { --rec: #9aa0a6; } /* нейтральный серый */
   .recDot.recLow  { --rec: #5f6368; } /* тёмно-серый */
   
   /* если где-то были “обводки/кольца” — убираем */
   .name .recDot,
   .recLine .recDot{
	 border: 0 !important;
   }
   
   /* под Inter выглядит лучше, если точка чуть “тоньше” визуально */
   @media (min-resolution: 2dppx){
	 .recDot{ width: 7px; height: 7px; flex-basis: 7px; }
   }
.recLegendItem{
	 display:inline-flex;
	 align-items:center;
	 gap:8px;
	 margin-right:12px;
	 white-space:nowrap;
   }
.nameCell:hover .recDot.recLow{
  box-shadow:
	inset 0 0 0 1px rgba(255,255,255,0.40),
	inset 0 -6px 12px rgba(0,0,0,0.10),
	0 10px 22px rgba(15,23,42,0.10);
}

.nameCell:hover .recDot{
  box-shadow:
	0 1px 0 rgba(255,255,255,0.7) inset,
	0 10px 18px rgba(15,23,42,0.10);
}

.nameBlock .name{
  display: inline-flex;
  align-items: center;
  gap: 0;
  min-width: 0;
}
.nameBlock .name .ellipsis{ min-width: 0; }

.recLegend{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.92);
  font-size: 12px;
  margin-left: 8px;
  white-space: nowrap;
}
.recLegend::before{
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,0.12);
  box-shadow: 0 1px 0 rgba(255,255,255,0.7) inset;
}

.recLegend.recUp{ background: var(--rec-up-bg); border-color: #cde7d3; color: #0f6a3b; }
.recLegend.recUp::before{ background: var(--rec-up); }

.recLegend.recHold{ background: var(--rec-hold-bg); border-color: var(--accent-3); color: #174ea6; }
.recLegend.recHold::before{ background: var(--rec-hold); }

.recLegend.recDown{ background: var(--rec-down-bg); border-color: #f2c2be; color: #b3261e; }
.recLegend.recDown::before{ background: var(--rec-down); }

.recLegend.recLow{ background: var(--rec-low-bg); border-color: rgba(15,23,42,0.10); color: var(--muted); }
.recLegend.recLow::before{ background: var(--rec-low); }

/* ---------- Tags & KPI badges ---------- */
.tag{
  display: inline-flex;
  align-items: center;
  padding: 3px 5px;
  border-radius: 8px;
  font-size: 12px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.92);
  color: var(--muted);
  white-space: nowrap;
  font-weight: var(--w-medium);
}

.tag.good{ background: var(--good-bg); border-color: #cde7d3; color: var(--good); font-weight: 100;}
.tag.warn{ background: var(--warn-bg); border-color: #f1e1a6; color: #7a4a00; font-weight: 100;}
.tag.neutral{ background: var(--accent-2); border-color: var(--accent-3); color: #174ea6; font-weight: 100;}
.tag.danger{ background: var(--bad-bg); border-color: #f2c2be; color: var(--bad); font-weight: 100;}

.kpiBadge{
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 56px;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,0.10);
  font-size: 12px;
  font-weight: var(--w-semibold);
  letter-spacing: -0.1px;
  background: rgba(255,255,255,0.92);
  white-space: nowrap;
}

.kpiBadge.good{ background: var(--good-bg); border-color: #cde7d3; color: var(--good); }
.kpiBadge.warn{ background: var(--warn-bg); border-color: #f1e1a6; color: #7a4a00; }
.kpiBadge.bad{ background: var(--bad-bg); border-color: #f2c2be; color: var(--bad); }
.kpiBadge.neutral{ background: #f3f4f6; border-color: rgba(15,23,42,0.10); color: var(--muted); }

/* ---------- Actions (table + sim) ---------- */
.actions{
  display: inline-flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: nowrap;
  align-items: center;
}

.action{
  appearance: none;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.92);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 9px;
  font-size: 12px;
  font-weight: var(--w-semibold);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .04s ease, color .15s ease;
}

.action:hover{
  background: rgba(15,23,42,0.03);
  box-shadow: 0 12px 24px rgba(15,23,42,.06);
}

.action:active{ transform: translateY(1px); }

.action.ghost{ background: transparent; }

.action.good{
  border-color: #cde7d3;
  background: var(--good-bg);
  color: var(--good);
}

.action.danger{
  border-color: #f2c2be;
  background: var(--bad-bg);
  color: var(--bad);
}

.actionToggle{
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
}

.action:disabled{
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none !important;
  transform: none !important;
}

/* Loading state for .action (JS uses isLoading) */
.action.isLoading{
  position: relative;
  cursor: progress;
  padding-right: 28px;
}
.action.isLoading::after{
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(15,23,42,.18);
  border-top-color: currentColor;
  animation: spin .8s linear infinite;
  transform: translateY(-50%);
}

/* Empty state */
.rowEmpty td{ padding: 0 !important; }

.emptyState{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 56px 16px;
  text-align: center;
}
.emptyStateIcon{
  width: 80px;
  height: 80px;
  display: block;
  opacity: .85;
}
.emptyStateText{
  font-size: 13px;
  color: rgba(100,116,139,0.95);
}

/* Icon-only action */
.iconAction{
  padding: 7px 8px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.iconAction .iconSvg{ color: var(--muted); }
.iconAction:hover .iconSvg{ color: #174ea6; }

/* ---------- Simulation cards ---------- */
.actionCard{
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.92);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 10px 26px rgba(15,23,42,0.06);
}

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

.actionTitle{
  font-weight: var(--w-semibold);
  font-size: 13px;
  min-width: 0;
}

.actionWhy{
  margin-top: 8px;
  color: var(--muted);
  font-size: 12.8px;
  line-height: 1.45;
}

.actionBar{
  margin-top: 10px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ---------- Activity log ---------- */
.logItem{
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.92);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 10px 26px rgba(15,23,42,0.06);
}

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

.logTitle{
  font-weight: var(--w-semibold);
  font-size: 13px;
}

.logWhy{
  margin-top: 8px;
  color: var(--muted);
  font-size: 12.8px;
  line-height: 1.45;
}

.logMeta{
  margin-top: 6px;
  color: var(--muted-2);
  font-size: 12.2px;
}

/* ---------- Dialog ---------- */
.dialog{
  border: 0;
  padding: 0;
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(15,23,42,.28);
  background: transparent;
  max-width: 720px;
  width: calc(100% - 24px);
}

.dialog::backdrop{
  background: rgba(15,23,42,0.40);
  backdrop-filter: blur(2px);
}

.dialogInner{
  background: rgba(255,255,255,0.95);
  border: 1px solid rgba(15,23,42,0.10);
  border-radius: 18px;
  overflow: hidden;
}

.dialogHead{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(15,23,42,0.10);
  background: rgba(251,252,255,0.95);
}

.dlgTitle{
  font-weight: var(--w-bold);
  font-size: 14px;
  letter-spacing: -0.12px;
}

.dlgBody{ padding: 14px 16px; }

.dialogFoot{
  padding: 12px 16px;
  border-top: 1px solid rgba(15,23,42,0.10);
  background: rgba(251,252,255,0.95);
  display: flex;
  justify-content: flex-end;
}

.iconBtn{
  appearance: none;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.92);
  border-radius: 10px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  color: var(--muted);
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .04s ease, box-shadow .15s ease;
}

.iconBtn:hover{
  background: rgba(26,115,232,0.06);
  border-color: var(--accent-3);
  color: #174ea6;
  box-shadow: 0 10px 18px rgba(15,23,42,0.08);
}

.iconBtn:active{ transform: translateY(1px); }

.kv{
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px 12px;
  align-items: center;
}

@media (max-width: 720px){
  .kv{ grid-template-columns: 1fr; }
}

.kv .k{ color: var(--muted); font-size: 12.5px; }
.kv .v{ font-size: 13px; }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar{ height: 10px; width: 10px; }
::-webkit-scrollbar-thumb{
  background: rgba(15,23,42,0.16);
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.65);
}
::-webkit-scrollbar-track{ background: transparent; }

/* ---------- Mobile tweaks ---------- */
@media (max-width: 720px){
  .topbar{ padding: 16px; }
  .panel, .panelLarge{ padding: 16px; }
  .tableWrap{ overflow: auto; }
  #tab_rules .panelLarge{ max-width: 100%; }
}

/* ---------- Fancy tooltip (recDot) ---------- */
.recTip{
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: max-content;
  max-width: 340px;

  padding: 10px 12px;
  border-radius: 14px;

  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(15,23,42,0.12);
  box-shadow: 0 18px 60px rgba(15,23,42,0.18);

  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;

  transition: opacity .12s ease, transform .12s ease;
  display: none;
}

.recTip.isOpen{ display: block; }

.recTipTitle{
  font-size: 12.5px;
  font-weight: 650;
  color: #0f172a;
  letter-spacing: -0.1px;
}

.recTipBody{
  margin-top: 6px;
  font-size: 12.5px;
  color: #475569;
  line-height: 1.45;
}

.recTip::after{
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  background: rgba(255,255,255,0.92);
  border-left: 1px solid rgba(15,23,42,0.12);
  border-top: 1px solid rgba(15,23,42,0.12);
  transform: rotate(45deg);
  left: 50%;
  margin-left: -5px;
}

.recTip[data-place="top"]::after{
  bottom: -6px;
}

.recTip[data-place="bottom"]::after{
  top: -6px;
  transform: rotate(225deg);
}

.recDot:focus-visible{
  box-shadow: 0 0 0 4px rgba(26,115,232,0.18);
  outline: none;
}
.tagStatus .tag{
  padding: 1px 5px;
  border-radius: 999px;
  letter-spacing: -0.3px;
  opacity: 0.7;
}
.tagStatus.isActive .tag::before{
  content: "▶";
  display: inline-block;
  margin-right: 6px;
  font-size: 11px;
  line-height: 1;
  transform: translateY(-0.5px);
}
.tagStatus.isPaused .tag::before{
  content: "⏸";
  display: inline-block;
  margin-right: 6px;
  font-size: 11px;
  line-height: 1;
  transform: translateY(-0.5px);
}
.tagStatus.isDeleted .tag::before{
  content: "🗑";
  display: inline-block;
  margin-right: 6px;
  font-size: 11px;
  line-height: 1;
  transform: translateY(-0.5px);
}
.table td.cellRevenue{
  color: var(--good);
}
.table td.cellSpend{
  color: var(--bad);
}
.actionBar{ justify-content: flex-end; align-items: center; }
.actionBar .iconAction{ background: transparent; }
.actionBar .iconAction:hover{ background: rgba(26,115,232,0.06); }