:root {
  --bg: #070605;
  --bg-2: #0d0b09;
  --card: rgba(26, 23, 20, 0.66);
  --card-solid: #17140f;
  --border: rgba(240, 224, 190, 0.22);
  --border-strong: rgba(244, 207, 107, 0.46);
  /* neutral, always-visible line for inputs/fields */
  --line: rgba(245, 239, 226, 0.26);
  --line-strong: rgba(245, 239, 226, 0.45);

  /* Samurai palette: steel black / gold (kuwagata) / red (menpo) */
  --gold: #e8b84b;
  --gold-light: #f4cf6b;
  --red-s: #d8412a;
  --steel: #6f7378;

  /* TikTok neon */
  --cyan: #25f4ee;
  --pink: #fe2c55;
  --orange: #fe2c55;
  --orange-dark: #c70036;

  /* Neon purple emphasis */
  --purple: #b35cff;
  --purple-light: #d39bff;
  --glow-purple: 0 0 26px rgba(157,78,255,.55);

  --white: #f5efe2;
  --text: #f5efe2;
  --muted: #918d83;
  --green: #2bd9a3;
  --red: #fe2c55;
  --radius: 16px;

  /* Fusion gradient: TikTok cyan -> pink -> samurai gold */
  --grad: linear-gradient(135deg, #25f4ee 0%, #fe2c55 55%, #e8b84b 100%);
  --grad-soft: linear-gradient(135deg, rgba(37,244,238,.16), rgba(254,44,85,.16), rgba(232,184,75,.16));
  --glow-cyan: 0 0 24px rgba(37,244,238,.45);
  --glow-pink: 0 0 24px rgba(254,44,85,.45);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--white);
  font-family: "Segoe UI", Tahoma, "Noto Sans Thai", system-ui, sans-serif;
  font-size: 14px;
  overflow-x: hidden;
  position: relative;
}

/* Warm forge-like ambient background */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -2;
  background:
    radial-gradient(42% 42% at 16% 16%, rgba(37,244,238,.15), transparent 60%),
    radial-gradient(45% 45% at 85% 14%, rgba(254,44,85,.16), transparent 60%),
    radial-gradient(40% 40% at 60% 30%, rgba(232,184,75,.12), transparent 62%),
    radial-gradient(50% 50% at 50% 52%, rgba(157,78,255,.16), transparent 62%),
    radial-gradient(55% 55% at 80% 90%, rgba(37,244,238,.12), transparent 60%),
    radial-gradient(50% 50% at 14% 92%, rgba(254,44,85,.12), transparent 60%);
  filter: blur(34px);
  animation: aurora 20s ease-in-out infinite alternate;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(232,184,75,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232,184,75,.03) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 28%, #000 0%, transparent 80%);
}
@keyframes aurora {
  0%   { transform: translate3d(0,0,0) scale(1); }
  50%  { transform: translate3d(2%, -2%, 0) scale(1.08); }
  100% { transform: translate3d(-2%, 2%, 0) scale(1.04); }
}

a { color: inherit; text-decoration: none; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background:
    radial-gradient(circle at 28px 22px, rgba(232,184,75,.12), transparent 90px),
    linear-gradient(180deg, rgba(12,12,10,.96), rgba(9,7,8,.88));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 10;
}
.brand {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(232,184,75,.18);
  background:
    radial-gradient(circle at 18% 26%, rgba(232,184,75,.18), transparent 34%),
    linear-gradient(145deg, rgba(232,184,75,.085), rgba(37,244,238,.045) 48%, rgba(0,0,0,.20)),
    rgba(255,255,255,.018);
  position: relative;
  overflow: hidden;
}
.brand::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: 12px;
  width: 42px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(37,244,238,.32), rgba(232,184,75,.22));
}
.brand-mark {
  width: 54px; height: 54px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  overflow: hidden;
  padding: 7px;
  background:
    radial-gradient(circle at 36% 22%, rgba(255,225,142,.22), transparent 36%),
    linear-gradient(145deg, rgba(24,20,14,.96), rgba(8,7,6,.98));
  border: 1px solid rgba(232,184,75,.36);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.04),
    0 0 22px rgba(232,184,75,.12),
    0 0 18px rgba(170,48,255,.10);
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,.45));
}
.brand-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.05;
}
.brand-wrap::after {
  content: "CONTROL ROOM";
  width: fit-content;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(37,244,238,.24);
  color: rgba(245,239,226,.58);
  background: rgba(37,244,238,.055);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .8px;
}
.brand-text {
  font-size: 23px;
  font-weight: 950;
  letter-spacing: .2px;
  color: var(--gold-light);
  text-shadow: 0 0 18px rgba(232,184,75,.30);
}
.brand-sub {
  margin-top: 5px;
  color: rgba(37,244,238,.72);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .9px;
  text-transform: uppercase;
}
@keyframes floaty {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 0 8px;
  position: relative;
}
.nav::before {
  content: "";
  position: absolute;
  left: 20px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: linear-gradient(180deg, rgba(232,184,75,.22), rgba(37,244,238,.10), rgba(254,44,85,.16));
}
.nav-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 52px;
  padding: 8px 8px 8px 0;
  border-radius: 10px;
  color: var(--muted);
  transition:
    background .22s var(--ease-out-quart),
    color .22s var(--ease-out-quart),
    transform .22s var(--ease-out-quart);
  font-weight: 850;
  border: 0;
  position: relative;
  overflow: visible;
  background: transparent;
}
.nav-ico {
  width: 20px; height: 20px; flex-shrink: 0;
  justify-self: center;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round; transition: .25s;
}
.nav-item .nav-ico {
  grid-column: 1;
  grid-row: 1;
  z-index: 1;
}
.nav-item::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(245,239,226,.18);
  outline: 7px solid rgba(8,7,6,.96);
  box-shadow: 0 0 0 1px rgba(245,239,226,.12);
  transition:
    background .22s var(--ease-out-quart),
    box-shadow .22s var(--ease-out-quart);
}
.nav-txt {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.06;
  min-width: 0;
  overflow: hidden;
}
.nav-main,
.nav-sub {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-main {
  color: inherit;
  font-size: 14px;
  font-weight: 900;
}
.nav-sub {
  color: rgba(245,239,226,.48);
  font-size: 10px;
  font-weight: 750;
}
.nav-item.active .nav-sub,
.nav-item:hover .nav-sub {
  color: rgba(245,239,226,.66);
}
.nav-item::after {
  content: none;
  display: none;
}
.nav-item:nth-child(1) {
  --nav-accent: var(--gold-light);
}
.nav-item:nth-child(2) {
  --nav-accent: #caa7ff;
}
.nav-item:nth-child(3) {
  --nav-accent: var(--cyan);
}
.nav-item:nth-child(4) {
  --nav-accent: #ffb86b;
}
.nav-item:nth-child(5) {
  --nav-accent: #ff5d82;
}
.nav-item:hover .nav-ico { stroke: var(--nav-accent, var(--cyan)); }
.nav-item:hover {
  background: linear-gradient(90deg, color-mix(in srgb, var(--nav-accent, var(--cyan)) 9%, transparent), transparent 76%);
  color: var(--white);
  transform: translateX(3px);
}
.nav-item.active {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--nav-accent, var(--gold-light)) 14%, transparent), transparent 82%);
  color: var(--white);
  box-shadow: none;
}
.nav-item.active .nav-ico {
  stroke: var(--nav-accent, var(--gold-light));
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--nav-accent, var(--gold-light)) 62%, transparent));
}
.nav-item.active::before {
  background: var(--nav-accent, var(--gold-light));
  box-shadow:
    0 0 0 1px rgba(8,7,6,.96),
    0 0 16px color-mix(in srgb, var(--nav-accent, var(--gold-light)) 42%, transparent);
}
.sidebar-foot { margin-top: auto; color: var(--muted); font-size: 11px; padding: 0 6px; }
.app-version { margin-top: 6px; font-weight: 700; letter-spacing: .5px;
  color: var(--gold); opacity: .8; }

.build-version-badge {
  margin-top: auto;
  width: fit-content;
  max-width: 100%;
  padding: 6px 9px;
  border-radius: 10px;
  border: 1px solid rgba(232,184,75,.22);
  background:
    linear-gradient(135deg, rgba(232,184,75,.09), rgba(37,244,238,.035)),
    rgba(9,7,6,.66);
  color: rgba(245,239,226,.66);
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: .35px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
  pointer-events: none;
}

.login-body .build-version-badge {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 850;
  width: auto;
  margin-top: 0;
  border-radius: 999px;
  background: rgba(9,7,6,.76);
  box-shadow: 0 8px 18px rgba(0,0,0,.24);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 26px; border-bottom: 1px solid var(--border);
  background: rgba(13,11,9,.55);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 8; gap: 16px;
}
.page-title {
  font-size: 20px; margin: 0; font-weight: 800; letter-spacing: .3px;
}
.topbar-right { display: flex; gap: 10px; align-items: center; }

/* ===== Unified topbar command controls ===== */
.tb-chip {
  display: flex; align-items: center; gap: 8px; height: 40px; box-sizing: border-box;
  padding: 0 13px; border-radius: 14px 9px 14px 9px; white-space: nowrap;
  background:
    linear-gradient(135deg, rgba(255,255,255,.045), rgba(255,255,255,.018)),
    rgba(7,6,5,.7);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.055);
}
.tb-ico { width: 17px; height: 17px; flex: none; color: var(--muted); }
.tb-chip-label, .tb-chip-unit { font-size: 11px; font-weight: 700; color: var(--muted); }
.tb-meta { display: flex; flex-direction: column; line-height: 1.12; }
.tb-meta-label {
  font-size: 9px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase;
  color: var(--muted);
}
.tb-meta-val { font-size: 13.5px; font-weight: 900; color: var(--text); }
.tb-badge {
  margin-left: 2px; padding: 2px 9px; border-radius: 999px;
  font-size: 10.5px; font-weight: 800; color: var(--muted);
  background: rgba(255,255,255,.05); border: 1px solid var(--border);
}
.tb-badge:empty { display: none; }

/* sync chip — compact technical control */
.tb-chip.is-sync {
  gap: 7px;
  background:
    linear-gradient(135deg, rgba(37,244,238,.13), rgba(37,244,238,.035)),
    rgba(6,12,12,.76);
  border-color: rgba(37,244,238,.34);
}
.tb-chip.is-sync .tb-ico { color: var(--cyan); filter: drop-shadow(0 0 8px rgba(37,244,238,.32)); }
.tb-chip.is-sync .tb-chip-label { color: rgba(205,255,253,.82); }

/* expiry chip — license shield, turns red as it nears/passes the date */
.tb-chip.expiry {
  background:
    linear-gradient(135deg, rgba(232,184,75,.15), rgba(232,184,75,.035)),
    rgba(19,14,7,.78);
  border-color: rgba(232,184,75,.42);
}
.tb-chip.expiry .tb-ico { color: var(--gold-light); filter: drop-shadow(0 0 8px rgba(232,184,75,.26)); }
.tb-chip.expiry .tb-meta-val { color: var(--gold-light); }
.tb-chip.expiry .tb-badge {
  color: var(--gold-light); background: rgba(232,184,75,.12); border-color: rgba(232,184,75,.32);
}
.tb-chip.expiry.is-soon {
  background: linear-gradient(135deg, rgba(255,138,160,.14), rgba(255,138,160,.03));
  border-color: rgba(255,138,160,.45);
}
.tb-chip.expiry.is-soon .tb-ico,
.tb-chip.expiry.is-soon .tb-meta-val { color: #ff8aa0; }
.tb-chip.expiry.is-soon .tb-badge { color: #ff8aa0; background: rgba(255,138,160,.14); border-color: rgba(255,138,160,.4); }
.tb-chip.expiry.is-expired { opacity: .9; }
.tb-chip.expiry.is-expired .tb-ico,
.tb-chip.expiry.is-expired .tb-meta-val,
.tb-chip.expiry.is-expired .tb-badge { color: var(--red); }

/* compact number input inside the poll chip */
.poll-input {
  width: 48px; padding: 4px 6px; text-align: center; font-weight: 900; font-size: 13px;
  color: var(--text); background: rgba(0,0,0,.28);
  border: 1px solid var(--border); border-radius: 8px; -moz-appearance: textfield;
}
.poll-input:focus { outline: none; border-color: var(--cyan); }

.tb-action-ico { width: 17px; height: 17px; flex: none; }
.topbar-action-primary {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 15px 8px 10px;
  border-radius: 10px 16px 10px 16px;
  color: #05100f;
  background:
    linear-gradient(90deg, rgba(255,255,255,.22), transparent 34%),
    linear-gradient(135deg, var(--cyan), #ff4c73 64%, var(--gold-light));
  border-color: rgba(37,244,238,.55);
  box-shadow: 0 10px 24px rgba(37,244,238,.13), 0 8px 24px rgba(254,44,85,.16);
}
.topbar-action-primary::before,
.topbar-exit::before { display: none; }
.topbar-action-primary .tb-action-ico {
  width: 26px;
  height: 26px;
  padding: 5px;
  box-sizing: border-box;
  border-radius: 8px;
  color: #04110f;
  background: rgba(255,255,255,.28);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.topbar-action-primary:hover {
  filter: saturate(1.08) brightness(1.03);
  box-shadow: 0 12px 28px rgba(37,244,238,.2), 0 10px 30px rgba(254,44,85,.22);
}
.topbar-exit {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  border-radius: 12px;
}
.topbar-exit .tb-action-ico { color: rgba(255,210,220,.72); }

/* ===== Topbar summary: pooled totals of all accounts (today) ===== */
.topbar-summary {
  display: grid;
  grid-template-columns: 96px repeat(6, minmax(86px, 1fr)) 112px;
  align-items: center;
  gap: 8px;
  margin: 0 auto;
  width: min(1060px, 62vw);
  min-height: 74px;
  padding: 8px 10px 8px 8px;
  border-radius: 20px 9px 20px 9px;
  background:
    linear-gradient(90deg, rgba(37,244,238,.16), transparent 20%),
    linear-gradient(135deg, rgba(254,44,85,.09), rgba(232,184,75,.06) 54%, rgba(157,78,255,.08)),
    rgba(7,7,7,.78);
  border: 1px solid rgba(37,244,238,.18);
  border-left-color: rgba(37,244,238,.48);
  border-bottom-color: rgba(244,207,107,.25);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.055),
    inset 5px 0 0 rgba(37,244,238,.14),
    0 14px 34px rgba(0,0,0,.34),
    0 0 28px rgba(37,244,238,.10);
}
.topbar-summary[hidden] { display: none; }
.topbar-summary {
  position: relative;
  overflow: hidden;
}
.topbar-summary::before {
  content: "OPS\A TODAY";
  white-space: pre-line;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  min-height: 58px;
  padding: 0 12px;
  border-radius: 15px 5px 15px 5px;
  color: var(--cyan);
  font-size: 9px;
  font-weight: 950;
  line-height: 1.1;
  text-align: center;
  letter-spacing: .7px;
  background:
    linear-gradient(180deg, rgba(37,244,238,.22), rgba(37,244,238,.06)),
    rgba(0,0,0,.30);
  border: 1px solid rgba(37,244,238,.30);
  text-shadow: 0 0 10px rgba(37,244,238,.38);
}
.topbar-summary.is-loading {
  opacity: .68;
}
.topbar-summary.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 0%, rgba(37,244,238,.13) 46%, transparent 78%);
  transform: translateX(-105%);
  animation: scanSweep 1.05s var(--ease-out-quint) infinite;
  pointer-events: none;
}
.ts-cell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  justify-items: start;
  gap: 2px;
  padding: 7px 10px;
  position: relative;
  min-width: 0;
  min-height: 58px;
  border-radius: 15px 5px 15px 5px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.042), rgba(255,255,255,.014)),
    rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.065);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
  transition:
    color .18s var(--ease-out-quart),
    transform .18s var(--ease-out-quart);
}
.ts-cell:hover {
  background:
    linear-gradient(145deg, rgba(255,255,255,.058), rgba(255,255,255,.018)),
    rgba(0,0,0,.20);
  transform: translateY(-1px);
}
.ts-label {
  font-size: 9.5px;
  font-weight: 850;
  letter-spacing: 0;
  color: var(--muted);
  text-transform: none;
  white-space: nowrap;
}
.ts-val {
  font-size: 18px;
  font-weight: 950;
  line-height: 1.05;
  white-space: nowrap;
  color: var(--text);
}
.ts-sub {
  display: block;
  margin-top: -1px;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}
.ts-cell.c-roi {
  place-items: start;
  justify-items: start;
  align-self: stretch;
  min-width: 0;
  min-height: 58px;
  padding: 7px 10px;
  border-radius: 15px 5px 15px 5px;
  background:
    radial-gradient(circle at 50% 100%, rgba(43,217,163,.24), transparent 46%),
    linear-gradient(135deg, rgba(37,244,238,.18), rgba(157,78,255,.19)),
    rgba(0,0,0,.28);
  border: 1px solid rgba(37,244,238,.28);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04), 0 0 18px rgba(37,244,238,.10);
}
.ts-cell::after {
  content: "";
  width: 100%;
  height: 2px;
  margin-top: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, currentColor, transparent 82%);
  opacity: .42;
}
.ts-cell.c-roi .ts-val { color: var(--green); text-shadow: 0 0 12px rgba(43,217,163,.35); }
.ts-cell.c-cost .ts-val { color: var(--gold-light); }
.ts-cell.c-gmv .ts-val { color: var(--cyan); }
.ts-cell.c-ord .ts-val { color: var(--gold-light); }
.ts-cell.c-balance .ts-val { color: var(--cyan); text-shadow: 0 0 12px rgba(37,244,238,.26); }
.ts-cell.c-balance[data-balance-status="low"] .ts-val,
.dash-metric.c-balance[data-balance-status="low"] b { color: var(--gold-light); }
.ts-cell.c-balance[data-balance-status="empty"] .ts-val,
.dash-metric.c-balance[data-balance-status="empty"] b { color: #ff5f7e; }
.ts-cell.c-balance[data-balance-status="unknown"] .ts-val,
.dash-metric.c-balance[data-balance-status="unknown"] b,
.ts-cell.c-balance[data-balance-status="none"] .ts-val,
.dash-metric.c-balance[data-balance-status="none"] b { color: var(--muted); }
.ts-spark { display: none; }
.ts-spark:empty { visibility: hidden; }
.ts-cell.c-roi .ts-spark { color: var(--green); }
.ts-cell.c-cost .ts-spark { color: var(--gold-light); }
.ts-cell.c-gmv .ts-spark { color: var(--cyan); }
.ts-cell.c-ord .ts-spark { color: var(--gold-light); }
.ts-cell.c-cpo .ts-spark { color: var(--steel); }
.ts-val.ts-updated { animation: tsFlash .55s var(--ease-out-quint); }
@keyframes tsFlash {
  0% { transform: translateY(-1px) scale(1.12); filter: brightness(1.45); }
  100% { transform: scale(1); filter: none; }
}
.ts-meta {
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0;
  min-width: 0;
  min-height: 58px;
  padding: 0 12px;
  border-radius: 15px 5px 15px 5px;
  font-size: 10.5px;
  font-weight: 850;
  color: var(--gold-light);
  background: rgba(232,184,75,.10);
  border: 1px solid rgba(232,184,75,.26);
  white-space: nowrap;
}
.ts-meta:empty { display: none; }

/* Header rail overflow guard for the dark neon dashboard shell. */
.topbar,
.topbar-right,
.topbar-summary,
.topbar-summary .ts-cell,
.topbar-summary .ts-meta {
  min-width: 0;
  box-sizing: border-box;
}

.topbar-summary {
  max-width: 100%;
  grid-template-columns:
    minmax(78px, 0.64fr)
    minmax(86px, 0.82fr)
    minmax(100px, 1fr)
    minmax(106px, 1fr)
    minmax(78px, 0.72fr)
    minmax(112px, 1fr)
    minmax(126px, 1.06fr)
    minmax(84px, 0.68fr);
  overflow: hidden;
}

.topbar-summary .ts-cell,
.topbar-summary .ts-meta {
  max-width: 100%;
  overflow: hidden;
}

.topbar-summary .ts-label,
.topbar-summary .ts-val,
.topbar-summary .ts-sub,
.topbar-summary .ts-meta {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-summary .ts-cell.c-balance {
  padding-inline: 9px;
}

.topbar-summary .ts-cell.c-balance .ts-val {
  font-size: clamp(15px, 1.1vw, 18px);
  letter-spacing: -0.01em;
}

@media (max-width: 1680px) and (min-width: 901px) {
  .topbar-summary {
    grid-template-columns:
      minmax(68px, 0.58fr)
      minmax(76px, 0.72fr)
      minmax(92px, 0.96fr)
      minmax(98px, 1fr)
      minmax(66px, 0.62fr)
      minmax(98px, 0.92fr)
      minmax(116px, 1.04fr);
  }

  .topbar-summary .ts-meta {
    display: none;
  }

  .topbar-summary::before {
    font-size: 8px;
    padding-inline: 8px;
  }

  .topbar-summary .ts-cell {
    padding-inline: 8px;
  }
}

.content { padding: 26px; animation: pageIn .5s cubic-bezier(.2,.8,.2,1); }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative; display: flex; align-items: center; gap: 28px;
  padding: 32px 36px; margin-bottom: 22px; overflow: hidden;
  background: linear-gradient(120deg, rgba(26,22,18,.82), rgba(12,10,8,.6));
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: 20px;
}
.hero-glow {
  position: absolute; inset: -40% 20% auto -10%; height: 340px;
  background: linear-gradient(120deg, #25f4ee, #fe2c55 45%, #e8b84b 75%, #b35cff);
  opacity: .22; filter: blur(80px); pointer-events: none;
  animation: aurora 14s ease-in-out infinite alternate;
}
.hero-logo {
  width: 130px; height: 130px; object-fit: contain; flex-shrink: 0;
  filter: drop-shadow(0 12px 38px rgba(157,78,255,.5));
  animation: floaty 5s ease-in-out infinite; z-index: 1;
}
.hero-text { z-index: 1; }
.hero-text h2 {
  margin: 0 0 8px; font-size: 30px; font-weight: 900; letter-spacing: 1px;
  color: var(--gold-light);
  text-shadow: 0 0 22px rgba(232,184,75,.24);
}
.hero-text h2 span { color: var(--white); }
.hero-text p { color: var(--muted); margin: 0 0 18px; max-width: 560px; line-height: 1.7; }
.hero-cta { display: flex; gap: 12px; }
@media (max-width: 720px) { .hero { flex-direction: column; text-align: center; } }

.cta-row { display: flex; gap: 12px; margin-bottom: 20px; }
.steps { color: var(--muted); line-height: 2; padding-left: 18px; }
.steps b { color: var(--white); }

/* ---------- Dashboard daily view ---------- */
.dash-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.dash-head h2 { margin: 0 0 4px; font-size: 22px; font-weight: 900; color: var(--white); }
.dash-head p { margin: 0; color: var(--muted); font-size: 13px; }
.dash-picker {
  display: grid;
  justify-items: end;
  gap: 9px;
  min-width: min(620px, 100%);
}
.dash-date-nav {
  display: grid;
  grid-template-columns: 44px minmax(250px, 1fr) 44px;
  gap: 8px;
  width: min(520px, 100%);
}
.dash-arrow,
.dash-date-display,
.dash-date-chip {
  border: 1px solid var(--border-strong);
  color: var(--white);
  cursor: pointer;
  transition: transform .18s, border-color .18s, box-shadow .18s, background .18s;
}
.dash-arrow {
  width: 44px;
  height: 48px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: rgba(37,244,238,.08);
  color: var(--cyan);
  font-size: 24px;
  font-weight: 900;
}
.dash-arrow:hover,
.dash-date-display:hover,
.dash-date-chip:hover {
  transform: translateY(-1px);
  border-color: var(--cyan);
  box-shadow: var(--glow-cyan);
}
.dash-arrow:disabled {
  opacity: .38;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.dash-date-display {
  min-width: 0;
  min-height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(37,244,238,.12), rgba(157,78,255,.11));
  text-align: left;
  padding: 7px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
}
.dash-date-display span {
  color: var(--cyan);
  font-size: 11px;
  font-weight: 900;
}
.dash-date-display b {
  color: var(--white);
  font-size: 15px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  width: min(620px, 100%);
}
.dash-calendar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 5px 7px 5px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.04);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.dash-date {
  width: 146px;
  min-height: 30px;
  padding: 6px 9px;
}
.dash-date-chips {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px;
  width: fit-content;
  max-width: min(620px, 100%);
  justify-self: end;
  padding: 4px;
  border: 1px solid rgba(244,207,107,.28);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255,255,255,.045), rgba(37,244,238,.035));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.dash-date-chip {
  border-radius: 10px;
  background: transparent;
  padding: 8px 13px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 900;
  color: rgba(255,255,255,.82);
}
.dash-date-chip small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}
.dash-date-chip.is-active {
  color: #10100b;
  border-color: rgba(244,207,107,.82);
  background: linear-gradient(135deg, var(--cyan), var(--pink) 58%, var(--gold));
  box-shadow: 0 8px 18px rgba(37,244,238,.16), 0 0 0 1px rgba(255,255,255,.08) inset;
}
.dash-date-chip.is-active small { color: rgba(26,13,6,.72); }
.dash-metrics {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.dash-metric {
  position: relative;
  overflow: hidden;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.035);
  min-width: 0;
  transition: transform .18s var(--ease-out-quart), border-color .18s var(--ease-out-quart), box-shadow .18s var(--ease-out-quart), background .18s var(--ease-out-quart);
}
.dash-metric::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 8%, rgba(37,244,238,.13) 42%, rgba(254,44,85,.09) 58%, transparent 88%);
  opacity: 0;
  transform: translateX(-115%);
  pointer-events: none;
}
.dash-metric:hover {
  transform: translateY(-2px);
  border-color: rgba(37,244,238,.36);
  box-shadow: 0 12px 26px rgba(0,0,0,.28), 0 0 18px rgba(37,244,238,.12);
}
.dash-metric.metric-updated::after { animation: metricSweep .62s var(--ease-out-quint); }
.dash-metric.metric-updated b { animation: metricPop .46s var(--ease-out-quint); }
.dash-metrics.is-loading .dash-metric::after {
  opacity: 1;
  animation: scanSweep 1.05s var(--ease-out-quint) infinite;
}
@keyframes scanSweep {
  from { transform: translateX(-115%); }
  to { transform: translateX(115%); }
}
@keyframes metricSweep {
  0% { opacity: 0; transform: translateX(-115%); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translateX(115%); }
}
@keyframes metricPop {
  0% { transform: translateY(-1px) scale(1.08); filter: brightness(1.35); }
  100% { transform: none; filter: none; }
}
@keyframes rowIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.dash-metric span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.dash-metric b {
  display: block;
  color: var(--white);
  font-size: 22px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.dash-metric.c-roi { background: linear-gradient(135deg, rgba(43,217,163,.15), rgba(179,92,255,.10)); }
.dash-metric.c-roi b { color: var(--green); }
.dash-metric.c-cost b,
.dash-metric.c-closed-cost b,
.dash-metric.c-cpo b { color: var(--gold-light); }
.dash-metric.c-gmv b,
.dash-metric.c-balance b { color: var(--cyan); }
.dash-metric span small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.05;
}
.dash-products-card { margin-bottom: 16px; }
.dash-channel-filter {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}
.dash-channel-card {
  min-width: 0;
  display: grid;
  gap: 4px;
  text-align: left;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(37,244,238,.08), rgba(179,92,255,.07)), rgba(255,255,255,.035);
  color: var(--white);
  padding: 12px;
  cursor: pointer;
  transition: transform .16s var(--ease-out-quart), border-color .16s var(--ease-out-quart), box-shadow .16s var(--ease-out-quart);
}
.dash-channel-card:hover,
.dash-channel-card.is-active {
  border-color: rgba(37,244,238,.62);
  box-shadow: 0 0 0 1px rgba(37,244,238,.10) inset, 0 0 22px rgba(37,244,238,.14);
}
.dash-channel-card:hover { transform: translateY(-1px); }
.dash-channel-card span {
  overflow: hidden;
  color: var(--white);
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-channel-card b {
  color: var(--cyan);
  font-size: 18px;
  line-height: 1.15;
}
.dash-channel-card small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-products {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.dash-product-card {
  min-width: 0;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(25,241,231,.08), rgba(255,51,102,.06)), rgba(255,255,255,.035);
  padding: 12px;
}
.dash-product-head {
  min-width: 0;
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
}
.dash-product-head b {
  overflow: hidden;
  color: var(--white);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-product-head span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-product-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.dash-product-kpis span {
  min-width: 0;
  display: grid;
  gap: 2px;
  border-radius: 9px;
  background: rgba(0,0,0,.18);
  padding: 7px;
}
.dash-product-kpis small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}
.dash-product-kpis b {
  color: var(--gold-light);
  font-size: 13px;
}
.dash-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
}
.dash-table-card { min-width: 0; }
.dash-count { color: var(--muted); font-size: 12px; font-weight: 800; }
.dash-balance-card {
  margin-bottom: 18px;
  border-color: rgba(37,244,238,.18);
  background:
    linear-gradient(135deg, rgba(37,244,238,.035), rgba(232,184,75,.035) 58%, rgba(179,92,255,.035)),
    var(--card);
}
.dash-balance-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding-right: 2px;
}
.dash-balance-item {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid rgba(245,239,226,.12);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255,255,255,.045), rgba(0,0,0,.16));
}
.dash-balance-item.is-ok {
  border-color: rgba(43,217,163,.32);
  background: linear-gradient(135deg, rgba(43,217,163,.10), rgba(37,244,238,.035));
}
.dash-balance-item.is-low,
.dash-balance-item.is-empty {
  border-color: rgba(232,184,75,.42);
  background: linear-gradient(135deg, rgba(232,184,75,.13), rgba(254,44,85,.045));
}
.dash-balance-item.is-warning {
  border-color: rgba(254,44,85,.34);
  background: linear-gradient(135deg, rgba(254,44,85,.10), rgba(255,255,255,.025));
}
.dash-balance-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.dash-balance-name {
  min-width: 0;
  color: var(--white);
  font-size: 14px;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-balance-main small {
  min-width: 0;
  color: var(--purple-light);
  font-size: 11px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-balance-main em {
  min-width: 0;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-balance-side {
  display: grid;
  justify-items: end;
  gap: 3px;
  min-width: 92px;
}
.dash-balance-value {
  color: var(--cyan);
  font-size: 18px;
  line-height: 1.05;
  font-weight: 950;
  white-space: nowrap;
}
.dash-balance-item.is-low .dash-balance-value,
.dash-balance-item.is-empty .dash-balance-value { color: var(--gold-light); }
.dash-balance-item.is-warning .dash-balance-value { color: #ff8aa0; }
.dash-balance-state {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-align: right;
}
.dash-balance-empty {
  padding: 14px;
  border: 1px dashed rgba(245,239,226,.18);
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.dash-table-wrap { overflow: auto; }
.dash-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 940px;
}
.dash-col-name { width: 25%; }
.dash-col-money { width: 7.5%; }
.dash-col-count { width: 6%; }
.dash-col-roi { width: 5%; }
.dash-col-created { width: 9%; }
.dash-col-status { width: 9%; }
.dash-col-action { width: 8%; }
.dash-table tbody tr.dash-row {
  animation: rowIn .22s var(--ease-out-quart) both;
  animation-delay: calc(min(var(--i, 0), 10) * 24ms);
}
.dash-table th,
.dash-table td {
  padding: 11px 8px;
  border-bottom: 1px solid rgba(245,239,226,.08);
  text-align: right;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-table th:first-child,
.dash-table td:first-child {
  text-align: left;
  white-space: normal;
}
.dash-table th {
  color: var(--muted);
  font-weight: 900;
  background: rgba(0,0,0,.18);
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.2;
  vertical-align: middle;
}
.dash-table thead th {
  min-width: 0;
  padding: 10px 7px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: break-word;
  word-break: break-word;
  line-height: 1.22;
}
.dash-table thead th:first-child {
  overflow-wrap: anywhere;
  word-break: normal;
}
.dash-table th.dash-sortable {
  cursor: pointer;
  position: relative;
  padding-right: 18px;
  user-select: none;
}
.dash-sort-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  line-height: inherit;
  text-align: inherit;
  width: 100%;
  min-height: 32px;
  padding: 0;
  cursor: pointer;
}
.dash-table th.dash-sortable::after {
  content: "↕";
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(245,239,226,.42);
  font-size: 10px;
  line-height: 1;
}
.dash-table th.dash-sortable[data-sort-dir="asc"]::after {
  content: "▲";
  color: var(--cyan);
}
.dash-table th.dash-sortable[data-sort-dir="desc"]::after {
  content: "▼";
  color: var(--cyan);
}
.dash-table th.dash-sortable:hover,
.dash-table th.dash-sortable:focus-within {
  color: var(--white);
  background: rgba(0, 245, 255, .08);
}
.dash-sort-button:focus-visible {
  outline: 2px solid rgba(37,244,238,.78);
  outline-offset: 3px;
  border-radius: 6px;
}
.dash-table th:nth-child(3),
.dash-table th:nth-child(6) {
  font-size: 11px;
}
.dash-table th:nth-last-child(-n + 2),
.dash-table td:nth-last-child(-n + 2) {
  text-align: center;
}
.dash-table th[data-col="created"],
.dash-table td.dash-created {
  text-align: center;
}
.dash-table td { color: var(--white); }
.dash-table td.dash-created {
  color: var(--muted);
  font-weight: 800;
}
.dash-bot { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dash-bot b,
.dash-bot span {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}
.dash-table .dash-bot b {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  line-height: 1.28;
}
.dash-table .dash-bot span {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  line-height: 1.28;
}
.dash-bot span { color: var(--muted); font-size: 10px; }
.dash-mobile-list { display: none; }
.dash-mobile-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(37,244,238,.36);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(37,244,238,.075), rgba(255,255,255,.028));
  animation: rowIn .24s var(--ease-out-quart) both;
  animation-delay: calc(min(var(--i, 0), 8) * 28ms);
  transition: transform .18s var(--ease-out-quart), border-color .18s var(--ease-out-quart), box-shadow .18s var(--ease-out-quart);
}
.dash-mobile-card:hover {
  transform: translateY(-2px);
  border-color: rgba(37,244,238,.48);
  box-shadow: 0 12px 26px rgba(0,0,0,.28), 0 0 16px rgba(37,244,238,.12);
}
.dash-mobile-card.is-rollup {
  border-color: rgba(232,184,75,.46);
  background: linear-gradient(135deg, rgba(232,184,75,.10), rgba(255,255,255,.025));
}
.dmc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.dmc-head .dash-bot { min-width: 0; }
.dmc-head .dash-bot b {
  color: var(--white);
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.dmc-head .dash-bot span {
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.dmc-primary,
.dmc-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.dmc-primary > div,
.dmc-grid > div {
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid rgba(245,239,226,.13);
  border-radius: 10px;
  background: rgba(0,0,0,.18);
}
.dmc-primary span,
.dmc-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}
.dmc-primary b,
.dmc-grid b {
  display: block;
  color: var(--white);
  font-size: 14px;
  line-height: 1.18;
  overflow-wrap: anywhere;
}
.dmc-primary .c-roi {
  background: linear-gradient(135deg, rgba(43,217,163,.15), rgba(179,92,255,.10));
  border-color: rgba(43,217,163,.26);
}
.dmc-primary .c-roi b { color: var(--green); }
.dmc-primary .c-cost b,
.dmc-primary .c-closed-cost b,
.dmc-grid .c-cpo b { color: var(--gold-light); }
.dmc-primary .c-gmv b { color: var(--cyan); }
.dmc-grid .c-created b {
  color: var(--muted);
  font-size: 13px;
}
.dash-mobile-empty {
  padding: 18px 12px;
  border: 1px solid rgba(245,239,226,.10);
  border-radius: 12px;
  background: rgba(0,0,0,.16);
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}
.dash-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
}
.dash-badge.ok { color: var(--green); background: rgba(43,217,163,.12); border: 1px solid rgba(43,217,163,.28); }
.dash-badge.idle { color: var(--gold-light); background: rgba(232,184,75,.12); border: 1px solid rgba(232,184,75,.28); }
.dash-badge.warn { color: var(--cyan); background: rgba(25,241,231,.10); border: 1px solid rgba(25,241,231,.28); }
.dash-badge.bad { color: #ff8aa0; background: rgba(255,88,133,.10); border: 1px solid rgba(255,88,133,.28); }
.dash-source-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 900;
  vertical-align: 1px;
}
.dash-source-badge.ok { color: var(--green); background: rgba(43,217,163,.10); }
.dash-source-badge.idle { color: var(--gold-light); background: rgba(232,184,75,.10); }
.dash-source-badge.warn { color: var(--cyan); background: rgba(25,241,231,.10); }
.dash-delete-campaign {
  min-height: 32px;
  min-width: 42px;
  padding: 6px 8px;
  font-size: 11px;
  border-radius: 9px;
  justify-content: center;
}
.dmc-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.dmc-actions .dash-delete-campaign {
  width: 100%;
  min-height: 42px;
}
.dash-empty { text-align: center !important; color: var(--muted) !important; padding: 24px !important; }
.dash-mini { display: grid; gap: 10px; }
.dash-mini > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0,0,0,.18);
  transition: transform .18s var(--ease-out-quart), border-color .18s var(--ease-out-quart), background .18s var(--ease-out-quart);
}
.dash-mini > div:hover {
  transform: translateX(2px);
  border-color: rgba(232,184,75,.32);
  background: rgba(232,184,75,.055);
}
.dash-mini span { color: var(--muted); font-size: 12px; font-weight: 700; }
.dash-mini b { color: var(--white); font-size: 16px; }
.cyan { color: var(--cyan) !important; }
.green { color: var(--green) !important; }
.gold { color: var(--gold-light) !important; }

/* ---------- Glass cards (3D) ---------- */
.card, .stat-card {
  background: var(--card);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  position: relative;
  transition: transform .3s cubic-bezier(.2,.8,.2,1), box-shadow .3s, border-color .3s;
  transform-style: preserve-3d;
  will-change: transform;
}
.card::after, .stat-card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(135deg, rgba(244,207,107,.06), transparent 40%);
}
.card:hover { border-color: rgba(157,78,255,.32); box-shadow: 0 18px 50px rgba(0,0,0,.55), 0 0 30px rgba(157,78,255,.18); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-head h3 { margin: 0; font-size: 15px; font-weight: 700; }

.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 18px; margin-bottom: 20px;
}
.stat-card {
  overflow: hidden;
}
.stat-card::before {
  content: ""; position: absolute; top: -50%; right: -30%;
  width: 160px; height: 160px; border-radius: 50%;
  background: var(--grad); opacity: .14; filter: blur(20px);
  transition: .4s; transform: translateZ(-1px);
}
.stat-card:hover {
  transform: translateY(-6px) rotateX(6deg);
  box-shadow: 0 24px 60px rgba(0,0,0,.6), 0 0 34px rgba(157,78,255,.32);
  border-color: rgba(157,78,255,.36);
}
.stat-card:hover::before { opacity: .3; transform: scale(1.3); }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat-value {
  font-size: 38px; font-weight: 800; margin-top: 8px;
  color: var(--cyan);
  text-shadow: 0 0 16px rgba(37,244,238,.28);
}
.stat-value.success { color: var(--green); text-shadow: 0 0 16px rgba(43,217,163,.28); }
.stat-value.danger { color: var(--red); text-shadow: 0 0 16px rgba(254,44,85,.25); }

/* ---------- Bot cards (Accounts) ---------- */
.bots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 20px;
  perspective: 1200px;
}
.bot-card {
  background: var(--card);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  transition: transform .3s cubic-bezier(.2,.8,.2,1), box-shadow .3s, border-color .3s;
  transform-style: preserve-3d;
}
.bot-card::before {
  content: ""; position: absolute; top: -40%; right: -30%;
  width: 180px; height: 180px; border-radius: 50%;
  background: var(--grad); opacity: .12; filter: blur(26px); transition: .4s;
}
.bot-card:hover {
  border-color: rgba(157,78,255,.35);
  box-shadow: 0 22px 55px rgba(0,0,0,.55), 0 0 34px rgba(157,78,255,.22);
}
.bot-card:hover::before { opacity: .26; transform: scale(1.25); }

/* running cards get a glowing accent */
.bot-card.is-running { border-color: rgba(43,217,163,.4); }
.bot-card.is-running::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--green), var(--cyan));
  box-shadow: 0 0 14px rgba(43,217,163,.6);
}

.bot-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; position: relative; }
.bot-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bot-id-text { min-width: 0; }
.bot-avatar {
  position: relative; flex: none;
  width: 42px; height: 42px; border-radius: 12px;
  background: rgba(0,0,0,.4); border: 1px solid var(--border-strong);
  display: grid; place-items: center; overflow: visible;
  box-shadow: 0 6px 18px rgba(216,65,42,.3);
}
.bot-avatar img { width: 78%; height: 78%; object-fit: contain; border-radius: 9px; }
.live-dot {
  position: absolute; right: -3px; top: -3px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--green); border: 2px solid var(--card-solid);
  box-shadow: 0 0 8px var(--green); animation: livePulse 1.4s infinite;
}
@keyframes livePulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.25); opacity: .7; } }

.bot-name {
  font-size: 15px; font-weight: 800; position: relative;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bot-sub { font-size: 11px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.bot-meta { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; position: relative;
  padding: 10px 12px; border-radius: 12px; background: rgba(0,0,0,.22); border: 1px solid var(--border); }
.bot-meta .bm-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; }
.bot-meta span { color: var(--muted); }
.bot-meta b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }
.bot-meta b.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 11px; }

.bot-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 12px; position: relative; }
.bot-chip { display: flex; flex-direction: column; gap: 2px; align-items: center; text-align: center;
  padding: 8px 6px; border-radius: 10px; background: rgba(255,255,255,.035); border: 1px solid var(--border); }
.bot-chip span { font-size: 9.5px; color: var(--muted); }
.bot-chip b { font-size: 13px; font-weight: 800; }

/* campaign bound to the card (1 card = 1 campaign) */
.bot-camp { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; position: relative;
  padding: 9px 11px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(43,217,163,.10), rgba(37,244,238,.06));
  border: 1px solid rgba(43,217,163,.3); }
.bot-camp.empty { background: rgba(254,44,85,.06); border: 1px dashed rgba(254,44,85,.4); }
.bc-ico { flex: none; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  font-size: 14px; background: rgba(0,0,0,.3); border: 1px solid var(--border); }
.bot-camp.empty .bc-ico { color: var(--pink); }
.bc-text { min-width: 0; flex: 1; }

/* identity merged into the campaign block (compact, on the right) */
.bc-idn { flex: none; display: flex; align-items: center; gap: 6px; max-width: 42%;
  padding: 4px 8px 4px 4px; border-radius: 999px;
  background: rgba(179,92,255,.10); border: 1px solid rgba(179,92,255,.28); }
.bc-idn-av { flex: none; width: 24px; height: 24px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; font-size: 13px; background: rgba(0,0,0,.3); }
.bc-idn-av img { width: 100%; height: 100%; object-fit: cover; }
.bc-idn-name { font-size: 11px; font-weight: 700; color: var(--purple-light);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* compact info strip: auto-budget settings + condition flags in one row */
.bot-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; position: relative; }
.chip-mini { font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  color: var(--cyan); background: rgba(37,244,238,.08); border: 1px solid rgba(37,244,238,.25); }
.chip-mini.gold { color: var(--gold-light); background: rgba(232,184,75,.12); border-color: rgba(232,184,75,.32); }
.chip-mini.red { color: #ff8aa0; background: rgba(254,44,85,.12); border-color: rgba(254,44,85,.35); }
.bot-wallet {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  padding: 9px 11px;
  border-radius: 12px;
  border: 1px solid rgba(37,244,238,.28);
  background: linear-gradient(135deg, rgba(37,244,238,.08), rgba(0,0,0,.18));
}
.bot-wallet.is-ok { border-color: rgba(43,217,163,.34); }
.bot-wallet.is-low,
.bot-wallet.is-empty {
  border-color: rgba(232,184,75,.42);
  background: linear-gradient(135deg, rgba(232,184,75,.12), rgba(254,44,85,.045));
}
.bot-wallet.is-warning,
.bot-wallet.is-missing {
  border-color: rgba(254,44,85,.26);
  background: linear-gradient(135deg, rgba(254,44,85,.08), rgba(0,0,0,.18));
}
.bot-wallet-main,
.bot-wallet-meta {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.bot-wallet-main span,
.bot-wallet-meta span,
.bot-wallet-meta small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bot-wallet-main span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}
.bot-wallet-main b {
  color: var(--cyan);
  font-size: 17px;
  line-height: 1.08;
  font-weight: 950;
}
.bot-wallet.is-low .bot-wallet-main b,
.bot-wallet.is-empty .bot-wallet-main b { color: var(--gold-light); }
.bot-wallet.is-warning .bot-wallet-main b,
.bot-wallet.is-missing .bot-wallet-main b { color: #ff8aa0; }
.bot-wallet-meta {
  justify-items: end;
  max-width: 138px;
}
.bot-wallet-meta span {
  color: var(--white);
  opacity: .82;
  font-size: 10px;
  font-weight: 800;
}
.bot-wallet-meta small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}
.bc-name { font-size: 13px; font-weight: 800; display: flex; align-items: center; gap: 6px; min-width: 0; }
.bc-name > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-meta { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-meta .bc-budget { color: var(--green); font-weight: 800; font-size: 11px; }
.bc-refresh { flex: none; cursor: pointer; font-size: 11px; line-height: 1;
  padding: 2px 6px; border-radius: 7px; color: var(--cyan);
  background: rgba(37,244,238,.10); border: 1px solid rgba(37,244,238,.3); transition: .15s; }
.bc-refresh:hover { background: rgba(37,244,238,.22); transform: rotate(90deg); }

/* identity used by the campaign */
.bot-idn { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; position: relative;
  padding: 8px 12px; border-radius: 12px; background: rgba(179,92,255,.08);
  border: 1px solid rgba(179,92,255,.28); }
.bi-avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; font-size: 16px; background: rgba(0,0,0,.3);
  border: 1px solid var(--border); }
.bi-avatar img { width: 100%; height: 100%; object-fit: cover; }
.bi-label { font-size: 9.5px; color: var(--purple-light); font-weight: 700; }
.bi-name { font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.bot-cond-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; position: relative; }
.ctag { font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  color: var(--gold-light); background: rgba(232,184,75,.12); border: 1px solid rgba(232,184,75,.32); }
.ctag.bad { color: #ff8aa0; background: rgba(254,44,85,.12); border-color: rgba(254,44,85,.35); }

/* cooldown / countdown bar */
.bot-live { position: relative; margin-bottom: 10px; }
.bot-live-stopped { margin-top: 4px; }
.bot-stopped-note {
  margin: 0 0 8px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid rgba(232,184,75,.28);
  background: rgba(232,184,75,.08);
  color: var(--gold-light);
  font-size: 11px;
  font-weight: 800;
}
.cooldown { margin-bottom: 7px; }
.cd-info { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--muted); margin-bottom: 4px; }
.cd-ico { color: var(--cyan); animation: spin 2.4s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.cd-info b { color: var(--cyan); font-weight: 800; }
.cd-bar { height: 4px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.cd-fill { height: 100%; width: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  transform-origin: left center;
  transition: transform 1s linear;
  will-change: transform;
}

/* recreate cooldown block (loop is waiting to rebuild a campaign) */
.bot-recreate { position: relative; margin-bottom: 14px; padding: 12px;
  border-radius: 14px; border: 1px solid rgba(232,184,75,.35);
  background: linear-gradient(135deg, rgba(232,184,75,.10), rgba(254,44,85,.06)); }
.rc-title { font-size: 12px; font-weight: 800; color: var(--gold-light); margin-bottom: 4px; }
.rc-time { font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.rc-time b { color: var(--gold-light); font-size: 14px; }
.rc-fill {
  background: linear-gradient(90deg, var(--gold), var(--pink));
  transform-origin: left center;
  transition: transform 1s linear;
  will-change: transform;
}
.bot-recreate.is-failed {
  border-color: rgba(254,44,85,.55);
  background: linear-gradient(135deg, rgba(254,44,85,.13), rgba(232,184,75,.06));
}
.bot-recreate.is-failed .rc-title { color: #ff8aa0; }
.bot-recreate .rc-detail {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}
.rc-error {
  margin-bottom: 8px; font-size: 11px; line-height: 1.45; color: #ffd7df;
  max-height: 48px; overflow: auto;
}
.rc-retry { width: 100%; margin: 2px 0 9px; }

.bot-actions { display: flex; gap: 8px; align-items: center; position: relative; flex-wrap: wrap; }
.bot-actions .btn { flex: 1 1 auto; text-align: center; }
.bot-actions .btn[data-cond], .bot-actions .btn[data-edit],
.bot-actions .btn[data-del], .bot-actions .btn[data-curl] {
  flex: 0 0 auto; min-width: 38px; padding-left: 10px; padding-right: 10px; }
.bot-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex: none; }

/* account card compact */
.bots-grid { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.bot-card {
  min-width: 0;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(37,244,238,.045), rgba(254,44,85,.035) 52%, rgba(232,184,75,.045)),
    var(--card);
}
.bot-card::before {
  top: 0; right: auto; bottom: 0; left: 0;
  width: 4px; height: auto; border-radius: 0;
  background: linear-gradient(180deg, var(--green), var(--cyan));
  opacity: 1; filter: none;
  box-shadow: 0 0 18px rgba(37,244,238,.55);
}
.bot-card:hover::before { opacity: 1; transform: none; }
.bot-card.is-running::after { display: none; }
.bot-top {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.bot-identity {
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 17px;
  border: 1px solid rgba(179,92,255,.38);
  background: rgba(179,92,255,.13);
}
.bi-face {
  position: relative;
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--grad);
  color: #1a0d06;
  font-size: 12px;
  font-weight: 950;
}
.bi-initial {
  position: relative;
  z-index: 0;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
}
.bi-face img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.bi-face.is-avatar-missing {
  background:
    radial-gradient(circle at 30% 25%, rgba(37,244,238,.42), transparent 38%),
    linear-gradient(135deg, rgba(37,244,238,.78), rgba(254,44,85,.82) 62%, rgba(232,184,75,.72));
  color: #120a08;
}
.bot-id {
  display: flex;
  align-items: center;
  min-width: 0;
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.bot-id-text { min-width: 0; }
.bot-name {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-size: 15px;
  line-height: 1.15;
  font-weight: 950;
}
.bot-name-main {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bot-name-edit {
  flex: none;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}
.bot-channel {
  margin-top: 2px;
  min-width: 0;
  max-width: 100%;
  color: var(--purple-light);
  font-size: 10.5px;
  line-height: 1.25;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bot-channel b {
  color: #ffd6ff;
  font-weight: 900;
}
.bot-sub {
  margin-top: 2px;
  font-size: 10px;
  line-height: 1.25;
}
.bot-badges {
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  max-width: 132px;
}
.badge {
  min-height: 25px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 950;
  white-space: nowrap;
}
.badge.pause {
  color: var(--gold-light);
  background: rgba(232,184,75,.13);
  box-shadow: 0 0 18px rgba(232,184,75,.14);
}
.bot-camp {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 42px;
  gap: 9px;
  align-items: center;
  min-width: 0;
  margin-bottom: 11px;
  padding: 10px;
  border-radius: 13px;
}
.bc-ico {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  color: var(--pink);
  font-size: 13px;
  font-weight: 950;
}
.bc-text { min-width: 0; }
.bc-name { font-size: 15px; line-height: 1.2; font-weight: 950; }
.bc-meta { margin-top: 2px; font-size: 10px; line-height: 1.25; }
.bc-refresh {
  justify-self: end;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 950;
}
.bot-camp.empty {
  grid-template-columns: 36px minmax(0, 1fr);
}
.bot-strip {
  gap: 6px;
  margin-bottom: 12px;
}
.chip-mini {
  min-height: 25px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  font-size: 10px;
  line-height: 1;
  font-weight: 950;
  white-space: nowrap;
}
.bot-sched-paused {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  margin: 0 0 12px;
  padding: 12px;
  border-radius: 13px;
  border: 1px solid rgba(232,184,75,.34);
  background: linear-gradient(135deg, rgba(232,184,75,.13), rgba(254,44,85,.055));
}
.notice-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: rgba(232,184,75,.12);
  color: var(--gold-light);
  font-size: 14px;
  font-weight: 950;
}
.notice-text { min-width: 0; }
.notice-text b {
  display: block;
  color: var(--gold-light);
  font-size: 14px;
  line-height: 1.25;
  font-weight: 950;
  overflow-wrap: anywhere;
}
.notice-text span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.bot-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}
.bot-actions .btn[data-delcamp] {
  grid-column: span 2;
}
.bot-actions .btn,
.bot-actions .btn[data-cond],
.bot-actions .btn[data-edit],
.bot-actions .btn[data-del],
.bot-actions .btn[data-curl],
.bot-actions .btn[data-delcamp],
.bot-actions .btn[data-logs] {
  min-width: 0;
  min-height: 44px;
  flex: initial;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 9px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 950;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  isolation: isolate;
}
.bot-actions .btn > * {
  position: relative;
  z-index: 1;
}
.bot-actions .btn-ico,
.bot-actions .btn-text {
  min-width: 0;
}
.bot-actions .btn-text {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}
.bot-actions .btn-ico {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 17px;
  min-width: 17px;
  height: 17px;
  font-size: 15px;
  line-height: 1;
}

/* live stats inside a running bot card */
.bot-stats {
  position: relative; padding: 10px;
  border: 1px solid var(--border); border-radius: 12px;
  background: linear-gradient(135deg, rgba(43,217,163,.06), rgba(157,78,255,.05));
}
.bot-stats-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.bs-title { font-size: 11px; font-weight: 800; letter-spacing: .4px; color: var(--white); opacity: .85; }
.bs-tag {
  font-size: 9px; font-weight: 800; letter-spacing: .5px; color: var(--purple-light);
  padding: 2px 8px; border-radius: 999px; border: 1px solid rgba(179,92,255,.35);
  background: rgba(179,92,255,.12);
}
.bs-camp { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px;
  padding: 8px 10px; border-radius: 10px; background: rgba(0,0,0,.25); border: 1px solid var(--border); }
.bs-camp-name { font-size: 12px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bs-camp-id { font-size: 10px; color: var(--muted); }
.bs-camp-id b { color: var(--cyan); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

.bs-refresh { cursor: pointer; font-size: 9.5px; font-weight: 800; letter-spacing: .3px;
  min-width: 44px; min-height: 44px; padding: 3px 9px; border-radius: 999px; color: var(--cyan);
  background: rgba(37,244,238,.10); border: 1px solid rgba(37,244,238,.35); transition: .15s; }
.bs-refresh:hover { background: rgba(37,244,238,.22); }

.bs-budget { display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  padding: 8px 11px; border-radius: 10px;
  background: linear-gradient(135deg, rgba(43,217,163,.14), rgba(232,184,75,.06));
  border: 1px solid rgba(43,217,163,.32); }
.bsb-label { font-size: 10px; font-weight: 700; color: var(--muted); }
.bsb-val { font-size: 15px; font-weight: 900; color: var(--green); margin-left: auto; }
.bsb-eff { font-size: 9.5px; font-weight: 800; color: var(--gold-light);
  padding: 2px 7px; border-radius: 999px; background: rgba(232,184,75,.12);
  border: 1px solid rgba(232,184,75,.3); }

/* cost / budget usage panel + bar (compact, single row) */
.bs-usage { margin-bottom: 8px; padding: 7px 10px; border-radius: 10px;
  background: rgba(0,0,0,.28); border: 1px solid var(--border); }
.bsu-head { font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 4px; }
.bsu-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.bsu-val { font-size: 12px; font-weight: 800; color: var(--white); }
.bsu-val b { color: var(--cyan); font-size: 14px; }
.bsu-pct { margin-left: auto; font-size: 13px; font-weight: 900; color: var(--cyan); }
.bsu-bar { height: 7px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.bsu-fill { height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--green), var(--cyan)); }
.bs-usage.lvl-mid .bsu-fill { background: linear-gradient(90deg, var(--gold), #ffcf5a); }
.bs-usage.lvl-mid .bsu-pct { color: var(--gold-light); }
.bs-usage.lvl-high .bsu-fill { background: linear-gradient(90deg, var(--gold), var(--red)); }
.bs-usage.lvl-high .bsu-pct { color: #ff8aa0; }

.live-notice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  align-items: center;
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(232,184,75,.15), rgba(255,43,92,.08));
  border: 1px solid rgba(232,184,75,.38);
  color: var(--gold-light);
}
.live-notice span { grid-row: 1 / span 2; font-size: 14px; }
.live-notice b { font-size: 11px; line-height: 1.2; color: var(--gold-light); }
.live-notice small { font-size: 10px; line-height: 1.25; color: var(--muted); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stat-cell {
  display: flex; flex-direction: column; gap: 1px; padding: 6px 9px; border-radius: 9px;
  background: rgba(255,255,255,.035); border: 1px solid var(--border);
  transition: transform .12s ease, border-color .12s ease;
}
.stat-cell:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.sc-label { font-size: 9.5px; color: var(--muted); font-weight: 600; }
.sc-val { font-size: 15px; font-weight: 800; line-height: 1.15; }
/* ROI tile highlighted (compact, not full width) */
.c-roi {
  background: linear-gradient(135deg, rgba(43,217,163,.16), rgba(179,92,255,.12));
  border-color: rgba(43,217,163,.35);
}
.c-roi .sc-val { font-size: 17px; color: var(--green); text-shadow: 0 0 12px rgba(43,217,163,.4); }
.c-cost .sc-val { color: var(--gold-light); }
.c-gmv .sc-val { color: var(--cyan); }

/* poll interval control in topbar (uses .tb-chip base) */
.poll-ctl { gap: 7px; }

/* on indicator dot on the conditions button */
.dot-on { display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 6px var(--green); vertical-align: middle; }

/* ---- conditions modal: reset + rule builder ---- */
.switch-row { display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 10px 0; font-weight: 600; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--green); cursor: pointer; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.logic-toggle { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.radio-pill { position: relative; cursor: pointer; }
.radio-pill input { position: absolute; opacity: 0; }
.radio-pill span { display: inline-block; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); font-size: 12px; font-weight: 600; color: var(--muted);
  transition: all .15s ease; }
.radio-pill input:checked + span { color: #fff; border-color: var(--purple);
  background: linear-gradient(135deg, var(--purple), var(--pink)); box-shadow: 0 0 10px rgba(157,78,255,.4); }

.cond-rules { display: flex; flex-direction: column; gap: 6px; }
.rule-row { display: grid; grid-template-columns: 22px 1.4fr 1.2fr .9fr auto; gap: 8px; align-items: center; }
.rule-idx { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(157,78,255,.18); color: var(--purple); font-size: 11px; font-weight: 800; }
.rule-row .input { padding: 8px 10px; }
.rule-del { padding: 6px 10px; }
.rule-joiner { display: flex; justify-content: center; padding: 2px 0; }
.rule-join { width: auto; min-width: 120px; padding: 5px 12px; text-align: center;
  font-size: 11.5px; font-weight: 800; letter-spacing: .3px; color: var(--gold);
  background: rgba(232,184,75,.08); border-color: rgba(232,184,75,.3); border-radius: 999px; }
.rule-join:focus { outline: none; border-color: var(--gold); }

.cond-preview { margin-top: 12px; padding: 11px 14px; border-radius: 12px; line-height: 1.7;
  font-size: 13px; color: var(--white); background: rgba(157,78,255,.10);
  border: 1px solid rgba(157,78,255,.28); }
.cond-preview b { color: var(--gold); font-weight: 800; padding: 0 2px; }

/* Rule rows styled as soft cards (prettier than plain grid) */
.rule-row { background: rgba(255,255,255,.025); border: 1px solid rgba(245,239,226,.07);
  border-radius: 12px; padding: 8px 10px; transition: border-color .15s; }
.rule-row:hover { border-color: rgba(157,78,255,.35); }

/* Template picker inside the conditions modal */
.cond-tpl-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.cond-tpl-bar select { flex: 1 1 240px; min-width: 0; }
.cond-tpl-bar .btn { white-space: nowrap; }
.cond-tpl-saverow { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.cond-tpl-saverow input { flex: 1; }

.work-grid {
  width: 100%;
  overflow-x: auto;
  border: 1px solid rgba(245,239,226,.12);
  border-radius: 12px;
  user-select: none;
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.015)),
    rgba(7,6,5,.42);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.work-grid-row {
  display: grid;
  grid-template-columns: 136px repeat(48, minmax(18px, 1fr));
  min-width: 1180px;
}
.work-grid-row > * {
  border-right: 1px solid rgba(245,239,226,.07);
  border-bottom: 1px solid rgba(245,239,226,.07);
}
.work-grid-row > *:last-child { border-right: 0; }
.work-grid-row:last-child > * { border-bottom: 0; }
.work-grid-bands {
  background: linear-gradient(90deg, rgba(37,244,238,.06), rgba(254,44,85,.06), rgba(232,184,75,.06));
}
.work-grid-day-head,
.work-grid-band {
  min-height: 31px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 12px;
  font-weight: 800;
}
.work-grid-day-head {
  color: var(--gold);
  background: rgba(232,184,75,.08);
}
.work-grid-hours > div {
  min-height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 10px;
  background: rgba(0,0,0,.16);
}
.work-grid-hours > div.half {
  color: rgba(245,239,226,.18);
  background: rgba(0,0,0,.10);
}
.work-grid-day {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  background: rgba(255,255,255,.025);
}
.work-grid.dragging {
  cursor: crosshair;
}
.work-grid.dragging .work-grid-cell {
  transition: none;
}
.work-grid-day input {
  width: 14px;
  height: 14px;
  accent-color: var(--cyan);
}
.work-grid-cell {
  min-height: 34px;
  padding: 0;
  border: 0;
  background: rgba(255,255,255,.012);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  transition: background .12s ease, box-shadow .12s ease;
}
.work-grid-cell:hover {
  background: rgba(37,244,238,.10);
}
.work-grid-cell.active {
  background: linear-gradient(135deg, rgba(37,244,238,.45), rgba(254,44,85,.38), rgba(232,184,75,.42));
  box-shadow: inset 0 0 0 1px rgba(245,239,226,.22), 0 0 12px rgba(37,244,238,.12);
}
.work-grid-cell.anchor {
  box-shadow: inset 0 0 0 2px var(--gold), 0 0 16px rgba(232,184,75,.34);
}
.work-grid-float {
  position: absolute;
  z-index: 8;
  min-width: 126px;
  pointer-events: none;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid rgba(37,244,238,.45);
  background: rgba(21, 23, 31, .94);
  color: var(--white);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 10px 24px rgba(0,0,0,.36), 0 0 18px rgba(37,244,238,.14);
  opacity: 0;
  transition: opacity .08s ease;
}
.work-grid-float.show { opacity: 1; }

/* Templates ("สูตร") manager page */
.tpl-intro { color: var(--muted); margin-bottom: 18px; font-size: 14px; line-height: 1.6; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.tpl-card { background: var(--card); border: 1px solid rgba(245,239,226,.08); border-radius: 16px;
  padding: 16px; display: flex; flex-direction: column; gap: 12px; transition: .16s; }
.tpl-card:hover { border-color: rgba(157,78,255,.42); transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.tpl-card-top { display: flex; align-items: center; gap: 10px; }
.tpl-card-ico { width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: rgba(157,78,255,.16); color: var(--purple-light); font-size: 16px; }
.tpl-card-name { font-weight: 800; flex: 1; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--white); }
.tpl-act { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; flex: none; }
.tpl-act.del { color: var(--red); background: rgba(254,44,85,.12); }
.tpl-act.pause { color: var(--gold); background: rgba(232,184,75,.12); }
.tpl-card-rule { font-size: 13px; line-height: 1.65; color: var(--white); padding: 10px 12px;
  background: rgba(157,78,255,.08); border: 1px solid rgba(157,78,255,.2); border-radius: 10px;
  min-height: 42px; display: flex; align-items: center; }
.tpl-card-rule b { color: var(--gold); padding: 0 2px; }
.tpl-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tpl-card-actions { display: flex; gap: 6px; }
.tpl-empty { grid-column: 1/-1; text-align: center; padding: 54px 20px; color: var(--muted); }
.tpl-empty-ico { font-size: 42px; margin-bottom: 10px; opacity: .85; }
.tpl-empty-title { font-weight: 800; font-size: 16px; color: var(--white); }
.tpl-empty-sub { margin-top: 4px; font-size: 13px; }

@media (max-width: 640px) {
  .row-2 { grid-template-columns: 1fr; }
  .rule-row { grid-template-columns: 22px 1fr 1fr; grid-template-areas: "idx metric metric" "op op val" "del del del"; }
  .rule-row .rule-idx { grid-area: idx; }
  .rule-row .rule-metric { grid-area: metric; }
  .rule-row .rule-op { grid-area: op; }
  .rule-row .rule-val { grid-area: val; }
  .rule-row .rule-del { grid-area: del; width: 100%; }
}

@media (max-width: 900px) {
  .dash-table-wrap { display: none; }
  .dash-mobile-list { display: grid; gap: 10px; }
  body::before {
    filter: blur(18px);
    animation: none;
  }
  body::after {
    background-image: none;
  }
  .sidebar,
  .topbar,
  .card,
  .bot-card,
  .toast,
  .modal {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .card:hover,
  .bot-card:hover,
  .dash-mobile-card:hover {
    transform: none;
  }
}

/* Add tile */
.bot-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; cursor: pointer; border-style: dashed; min-height: 240px;
  border-color: var(--border-strong);
}
.bot-add:hover { border-color: var(--cyan); box-shadow: var(--glow-cyan); }
.bot-add-plus {
  width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center;
  font-size: 34px; font-weight: 300; color: #1a0d06; background: var(--grad);
  box-shadow: var(--glow-pink);
}
.bot-add-text { font-size: 15px; font-weight: 700; }

/* ---------- Account info line (create campaign) ---------- */
.acct-info { background: rgba(0,0,0,.28); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; }
.acct-info b { color: var(--text); word-break: break-all; }

/* ---------- Info grid (manage modal) ---------- */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.info-grid > div { display: flex; flex-direction: column; gap: 3px;
  background: rgba(0,0,0,.3); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; }
.info-grid span { color: var(--muted); font-size: 11px; }
.info-grid b { font-size: 13px; word-break: break-all; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border-strong); border-radius: 12px; padding: 10px 18px;
  font-size: 13px; font-weight: 700; cursor: pointer;
  transition: transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s, filter .2s;
  background: rgba(232,184,75,.05); color: var(--white); white-space: nowrap;
  position: relative; overflow: hidden;
}
.btn::before {
  content: ""; position: absolute; top: 0; left: -120%; width: 60%; height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255,255,255,.3), transparent);
  transition: .5s; transform: skewX(-20deg);
}
.btn:hover::before { left: 130%; }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn:disabled::before { display: none; }

.btn-primary {
  background: var(--grad); color: #1a0d06; border-color: transparent;
  box-shadow: 0 8px 24px rgba(216,65,42,.35);
}
.btn-primary:hover { box-shadow: 0 12px 32px rgba(216,65,42,.5), var(--glow-purple); }
.btn-outline {
  background: transparent; border-color: var(--cyan); color: var(--cyan);
}
.btn-outline:hover { box-shadow: var(--glow-cyan); }
.btn-ghost { background: rgba(255,255,255,.03); border-color: var(--border); color: var(--muted); }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover { box-shadow: var(--glow-pink); }
.btn-sm { min-height: 36px; padding: 7px 12px; font-size: 12px; border-radius: 9px; }

/* ---------- Forms ---------- */
.field-label { display: block; color: var(--white); font-size: 12px; margin: 14px 0 6px; font-weight: 600; opacity: .85; }
.input {
  width: 100%; background: rgba(255,255,255,.05); border: 1.5px solid var(--line);
  color: var(--white); padding: 11px 14px; border-radius: 11px; font-size: 13px;
  transition: .2s;
}
.input::placeholder { color: #847d70; }
.input:hover { border-color: var(--line-strong); background: rgba(255,255,255,.07); }
.input:focus {
  outline: none; border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(37,244,238,.2), 0 0 18px rgba(37,244,238,.3);
  background: rgba(0,0,0,.5);
}
select.input { cursor: pointer; }
select.input option { background: #17140f; color: var(--white); }
.row { display: flex; gap: 10px; align-items: center; }
.row .input { flex: 1; }
.col { flex: 1; }
.mt { margin-top: 14px; }
.divider { height: 1px; background: linear-gradient(90deg, transparent, var(--border-strong), transparent); margin: 20px 0; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td {
  text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th { color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; }
.table tbody tr { transition: .2s; }
.table tbody tr:hover td { background: rgba(37,244,238,.05); }
.table tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--cyan); }

.badge { padding: 4px 11px; border-radius: 20px; font-size: 11px; font-weight: 800; letter-spacing: .3px; }
.badge.ok { background: rgba(87,192,138,.15); color: var(--green); box-shadow: 0 0 12px rgba(87,192,138,.22); }
.badge.bad { background: rgba(224,67,42,.15); color: var(--red); box-shadow: 0 0 12px rgba(224,67,42,.25); }
.badge.warn { background: rgba(232,184,75,.15); color: var(--gold); box-shadow: 0 0 12px rgba(232,184,75,.25); }

/* ---------- Chips / identity ---------- */
.chip-list { display: flex; flex-wrap: wrap; gap: 12px; }
.chip {
  border: 1px solid var(--border); border-radius: 13px; padding: 12px 16px;
  cursor: pointer; transition: .25s cubic-bezier(.2,.8,.2,1); background: rgba(0,0,0,.3);
  transform-style: preserve-3d;
}
.chip:hover { border-color: var(--cyan); transform: translateY(-3px); box-shadow: var(--glow-cyan); }
.chip.selected {
  border-color: var(--pink); background: var(--grad-soft);
  box-shadow: var(--glow-pink);
}
.chip b { display: block; }
.chip span { color: var(--muted); font-size: 11px; }

/* chip with avatar */
.chip.has-avatar { display: flex; align-items: center; gap: 11px; max-width: 280px; }
.chip-avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: 0 0 40px;
  border: 1px solid var(--border-strong); background: rgba(255,255,255,.05);
}
.chip-info { min-width: 0; }
.chip-info b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }

/* identity toolbar (search) */
.id-toolbar { gap: 10px; align-items: center; margin: 4px 0 10px; }
.id-toolbar .input { flex: 1; }
.id-toolbar.hidden { display: none; }
.id-lock {
  font-size: 10px; font-weight: 700; color: var(--gold);
  background: rgba(232,184,75,.14); border-radius: 6px; padding: 1px 6px; margin-left: 6px;
}
.chip-disabled { opacity: .55; }
.chip-disabled:hover { border-color: var(--border); transform: none; box-shadow: none; }

/* ---------- Video grid ---------- */
.video-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 14px; margin-top: 6px; perspective: 1000px;
}
.video-card {
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  cursor: pointer; transition: .3s cubic-bezier(.2,.8,.2,1); background: rgba(0,0,0,.35);
  transform-style: preserve-3d; position: relative;
}
.video-card:hover {
  border-color: var(--cyan); transform: translateY(-6px) scale(1.03);
  box-shadow: 0 16px 40px rgba(0,0,0,.6), var(--glow-cyan);
}
.video-card.selected {
  border-color: var(--pink);
  box-shadow: 0 0 0 2px var(--pink), var(--glow-pink);
}
.video-card.selected::after {
  content: "✓"; position: absolute; top: 8px; right: 8px;
  width: 24px; height: 24px; border-radius: 50%; background: var(--grad);
  color: #1a0d06; display: grid; place-items: center; font-weight: 900; font-size: 13px;
  box-shadow: var(--glow-pink); animation: pop .24s var(--ease-out-quint);
}
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
.video-cover { width: 100%; aspect-ratio: 9/16; object-fit: cover; background: #000; display: block; }
.video-meta { padding: 9px; }
.video-meta .vtext { font-size: 11px; line-height: 1.4; max-height: 30px; overflow: hidden; }
.video-meta .vid { font-size: 10px; color: var(--muted); margin-top: 4px; }

/* ---------- Toast ---------- */
.toast-container {
  position: fixed; top: 20px; right: 20px; display: flex;
  flex-direction: column; gap: 12px; z-index: 1000;
}
.toast {
  background: rgba(24,20,16,.88);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(232,184,75,.5);
  padding: 13px 18px; border-radius: 13px; min-width: 270px; max-width: 380px;
  animation: toastIn .24s var(--ease-out-quint);
  box-shadow: 0 12px 40px rgba(0,0,0,.55);
}
.toast.ok { border-color: rgba(43,217,163,.55); box-shadow: 0 12px 40px rgba(0,0,0,.5), 0 0 20px rgba(87,192,138,.2); }
.toast.bad { border-color: rgba(254,44,85,.58); box-shadow: 0 12px 40px rgba(0,0,0,.5), 0 0 20px rgba(224,67,42,.22); }
.toast.warn { border-color: rgba(232,184,75,.56); }
.toast.is-leaving {
  animation: toastOut .16s ease-in forwards;
}
.toast .t-title { font-weight: 800; margin-bottom: 2px; }
.toast .t-msg { color: var(--muted); font-size: 12px; word-break: break-word; }
@keyframes toastIn {
  from { transform: translateX(28px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes toastOut {
  to { transform: translateX(18px); opacity: 0; }
}

/* ---------- Modal (3D entrance) ---------- */
.modal-root { position: fixed; inset: 0; z-index: 900; display: grid; place-items: center; perspective: 1400px; }
.modal-root.hidden { display: none; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(5,3,2,.74);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fadeIn .3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative; background: linear-gradient(160deg, rgba(30,25,20,.93), rgba(16,13,10,.93));
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-strong);
  border-radius: 20px; width: min(700px, 92vw); max-height: 86vh;
  display: flex; flex-direction: column;
  box-shadow: 0 40px 100px rgba(0,0,0,.72), 0 0 70px rgba(157,78,255,.16);
  animation: modalIn .5s cubic-bezier(.2,1,.3,1);
  overflow: hidden;
}
.modal:has(.work-grid) { width: min(1040px, 94vw); }
.modal::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--red-s) 55%, var(--purple));
  box-shadow: var(--glow-purple);
}
@keyframes modalIn {
  from { transform: translateY(40px) rotateX(18deg) scale(.92); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.modal-head { display: flex; justify-content: space-between; align-items: center;
  padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 800; }
.modal-x { background: none; border: none; color: var(--muted); font-size: 26px; cursor: pointer; transition: .2s; line-height: 1; }
.modal-x:hover { color: var(--pink); transform: rotate(90deg); }
.modal-body { padding: 20px; overflow: auto; }
.modal-body h4 { margin: 16px 0 8px; font-size: 13px; color: var(--cyan); }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Modal content building blocks ---------- */
.m-head {
  display: flex; align-items: center; gap: 14px; padding: 15px 16px;
  border-radius: 14px; margin-bottom: 20px;
  background: linear-gradient(135deg, rgba(232,184,75,.12), rgba(157,78,255,.10));
  border: 1px solid var(--border-strong);
}
.m-head-avatar {
  width: 54px; height: 54px; border-radius: 14px; overflow: hidden; flex: 0 0 54px;
  border: 1px solid var(--border-strong); background: rgba(0,0,0,.35);
  display: grid; place-items: center;
}
.m-head-avatar img { width: 100%; height: 100%; object-fit: contain; }
.m-head-info { min-width: 0; flex: 1; }
.m-head-name { font-size: 18px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-head-sub { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }

.m-section { margin-bottom: 20px; }
.m-section:last-child { margin-bottom: 0; }
.m-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.m-section-title {
  font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
  color: var(--gold); display: flex; align-items: center; gap: 9px; margin: 0;
}
.m-section-title::before { content: ""; width: 3px; height: 15px; border-radius: 3px; background: var(--grad); }

.m-kv { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.m-kv-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px; background: rgba(0,0,0,.26);
}
.m-kv-row + .m-kv-row { border-top: 1px solid var(--border); }
.m-kv-row:nth-child(even) { background: rgba(255,255,255,.022); }
.m-kv-key { color: var(--muted); font-size: 12px; flex: 0 0 auto; }
.m-kv-val { font-weight: 700; font-size: 13px; text-align: right; word-break: break-all; min-width: 0; }
.m-kv-val.mono { font-family: "Cascadia Code", "Consolas", monospace; color: var(--cyan); font-weight: 600; }
.m-kv-val.empty { color: var(--muted); font-weight: 500; }

.m-note {
  background: rgba(37,244,238,.06); border: 1px solid rgba(37,244,238,.22);
  border-radius: 12px; padding: 12px 14px; font-size: 12px; color: var(--white);
  line-height: 1.7; margin-bottom: 16px;
}
.m-note b { color: var(--cyan); }
.m-note code { background: rgba(0,0,0,.35); border: 1px solid var(--border); border-radius: 6px;
  padding: 1px 6px; font-size: 11px; color: var(--gold-light); }
.m-note.small { font-size: 11px; padding: 8px 12px; margin-bottom: 0; line-height: 1.5; }
.m-note.m-note-warn {
  background: rgba(255,138,160,.08); border-color: rgba(255,138,160,.4); color: #ffd2dc;
}
.m-note.m-note-warn b { color: #ff8aa0; }
.m-result { margin-top: 12px; font-size: 12px; }

/* pulse the cURL/key button when an account's cookie is invalid */
.btn-warn-pulse { animation: warnPulse 1.4s ease-in-out infinite;
  border-color: rgba(255,138,160,.6) !important; }
@keyframes warnPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,88,133,.0); }
  50% { box-shadow: 0 0 0 4px rgba(255,88,133,.28); }
}

pre.code {
  background: rgba(0,0,0,.55); border: 1px solid var(--border); border-radius: 11px;
  padding: 15px; overflow: auto; font-size: 12px; max-height: 50vh;
  color: #f3dca6; white-space: pre-wrap; word-break: break-word;
  font-family: "Cascadia Code", "Consolas", monospace;
}

/* ---------- Loading ---------- */
.loading { position: fixed; inset: 0; background: rgba(5,3,2,.62);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: grid; place-items: center; z-index: 1100; }
.loading.hidden { display: none; }
.spinner {
  width: 52px; height: 52px; border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--gold); border-right-color: var(--purple);
  animation: spin .7s linear infinite;
  box-shadow: 0 0 26px rgba(157,78,255,.5);
}
.spinner::after {
  content: ""; position: absolute; inset: -8px; border-radius: 50%;
  border: 2px solid transparent; border-bottom-color: rgba(216,65,42,.55);
  animation: spin 1.4s linear infinite reverse;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(157,78,255,.28); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, var(--gold), var(--purple)); }

/* Keep the campaign table inside the card before the right rail steals space. */
@media (max-width: 1280px) {
  .dash-split {
    grid-template-columns: 1fr;
  }

  .dash-side {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .dash-side .card-head,
  .dash-side .dash-mini {
    grid-column: 1 / -1;
  }
}

/* ---------- Responsive: tablet ---------- */
@media (max-width: 980px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-head { align-items: stretch; flex-direction: column; }
  .dash-picker,
  .dash-controls { justify-items: stretch; justify-content: flex-start; width: 100%; }
  .dash-date-chips { justify-content: flex-start; width: fit-content; max-width: 100%; justify-self: end; }
  .dash-date-nav { width: 100%; }
  .dash-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-products { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-split { grid-template-columns: 1fr; }
  .sidebar { width: 76px; }
  .brand-wrap, .nav-txt { display: none; }
  .brand { align-items: center; padding: 10px; }
  .brand::after { display: none; }
  .nav { padding-left: 8px; }
  .nav::before { left: 20px; transform: none; }
  .nav-item {
    grid-template-columns: 34px;
    justify-content: center;
    justify-items: center;
    padding: 12px 0;
  }
  .content { padding: 20px; }
}

/* ---------- Responsive: phone (top nav bar) ---------- */
@media (max-width: 640px) {
  body::before {
    filter: blur(22px);
    animation-duration: 36s;
  }
  body::after {
    opacity: .38;
  }
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0;
    flex-direction: row; align-items: center; gap: 6px;
    padding: 8px 10px; border-right: none;
    border-bottom: 1px solid var(--border-strong);
  }
  .brand { margin: 0; padding: 0 6px 0 0; border-bottom: none; flex-shrink: 0; }
  .brand-mark { width: 34px; height: 34px; }
  .nav {
    flex-direction: row; gap: 4px; flex: 1;
    overflow-x: auto; scrollbar-width: none;
  }
  .nav::before { display: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item {
    grid-template-columns: 1fr;
    grid-template-rows: 26px auto;
    gap: 4px;
    min-width: 66px;
    padding: 7px 10px;
    flex-shrink: 0;
    justify-items: center;
  }
  .nav-item:hover { transform: none; }
  .nav-txt { display: flex; align-items: center; gap: 1px; }
  .nav-main { font-size: 10.5px; line-height: 1; }
  .nav-sub { font-size: 8px; line-height: 1; }
  .nav-item::before { display: none; }
  .sidebar-foot { display: none; }
  .sidebar .build-version-badge { display: none; }

  .topbar { padding: 14px 16px; flex-wrap: wrap; }
  .page-title { font-size: 17px; }
  .topbar-right { width: 100%; flex-wrap: wrap; }
  .topbar-right .btn { flex: 1; min-height: 44px; }
  .tb-chip { flex: 1; min-width: 0; justify-content: center; }
  .tb-chip.expiry, .user-menu { flex: 1 1 100%; }
  .user-menu { justify-content: space-between; }
  .user-menu .btn,
  .topbar-right .btn-sm {
    min-height: 44px;
  }
  .topbar-summary {
    order: 3;
    width: 100%;
    margin: 10px 0 0;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .topbar-summary::-webkit-scrollbar { display: none; }
  .topbar-summary::before { min-height: 44px; padding: 0 10px; }
  .topbar-summary .ts-cell,
  .topbar-summary .ts-cell.c-roi { flex: initial; padding: 6px 8px; min-width: 84px; }
  .ts-label { font-size: 8.5px; letter-spacing: 0; }
  .ts-val { font-size: 15px; }
  .ts-meta { display: none; }
  .content { padding: 16px 13px; }

  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .dash-head { gap: 12px; margin-bottom: 14px; }
  .dash-head h2 { font-size: 20px; }
  .dash-head p { font-size: 12px; line-height: 1.45; }
  .dash-picker { gap: 10px; min-width: 0; }
  .dash-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-bottom: 14px; }
  .dash-metric { padding: 10px 12px; border-radius: 11px; }
  .dash-metric span { margin-bottom: 4px; font-size: 10px; }
  .dash-metric b { font-size: 18px; line-height: 1.15; }
  .dash-metric.c-roi { grid-column: span 2; }
  .dash-date-nav { grid-template-columns: 42px minmax(0, 1fr) 42px; gap: 6px; }
  .dash-arrow { width: 42px; height: 46px; border-radius: 12px; }
  .dash-date-display { padding: 7px 12px; border-radius: 12px; }
  .dash-date-display b { font-size: 13px; white-space: normal; }
  .dash-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .dash-controls .btn { width: 100%; min-height: 44px; }
  .dash-calendar-wrap { grid-column: 1 / -1; width: 100%; justify-content: space-between; }
  .dash-date { width: 100%; }
  .dash-date-chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .dash-date-chip { width: 100%; min-height: 44px; justify-content: center; padding: 9px 8px; }
  .dash-table-card { padding: 14px; }
  .dash-products { grid-template-columns: 1fr; }
  .dash-channel-filter { grid-template-columns: 1fr; }
  .dash-channel-card {
    min-height: 72px;
    padding: 12px 14px;
  }
  .dash-channel-card b { font-size: 17px; }
  .dash-table-wrap { display: none; }
  .dash-mobile-list { display: grid; gap: 10px; }
  .dmc-primary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-side { padding: 14px; }
  .dash-mini { gap: 8px; }
  .dash-mini > div { padding: 9px 10px; }
  .info-grid { grid-template-columns: 1fr; }
  .bots-grid { grid-template-columns: 1fr; }
  .bot-meta b { max-width: 60vw; }
  .bot-top {
    grid-template-columns: 58px minmax(0, 1fr);
    grid-template-areas:
      "avatar identity"
      "badges badges";
    align-items: start;
    column-gap: 10px;
    row-gap: 8px;
  }
  .bot-identity {
    width: 52px;
    height: 52px;
    padding: 3px;
  }
  .bi-face {
    width: 44px;
    height: 44px;
  }
  .bot-identity { grid-area: avatar; }
  .bot-id { grid-area: identity; align-self: center; width: 100%; min-height: 52px; }
  .bot-name { font-size: 17px; gap: 6px; }
  .bot-name-edit { font-size: 11px; }
  .bot-channel { font-size: 12px; line-height: 1.35; }
  .bot-sub { font-size: 11px; }
  .bot-badges {
    grid-area: badges;
    justify-content: flex-start;
    max-width: none;
    align-self: start;
    width: 100%;
  }
  .badge { min-height: 30px; padding: 6px 10px; }
  .bot-camp { grid-template-columns: 38px minmax(0, 1fr) 46px; padding: 11px; }
  .bc-refresh { width: 46px; height: 46px; }
  .bot-strip { gap: 7px; }
  .chip-mini { min-height: 32px; padding: 6px 10px; font-size: 10.5px; }
  .bot-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .bot-actions .btn:nth-child(1),
  .bot-actions .btn:nth-child(2) { grid-column: span 2; }
  .bot-actions .btn { min-height: 46px; }
  .bsu-top { flex-wrap: wrap; }
  .bsu-val { flex: 1 1 100%; font-size: 13px; }
  .bsu-pct { margin-left: 0; }
  .bs-refresh { margin-left: auto; min-height: 44px; }

  .row { flex-wrap: wrap; }
  .row .btn { flex: 1 1 auto; }

  .chip.has-avatar { max-width: 100%; width: 100%; }
  .chip-info b { max-width: 100%; }

  .hero { padding: 22px; gap: 18px; }
  .hero-logo { width: 92px; height: 92px; }
  .hero-text h2 { font-size: 22px; }

  .video-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 11px; }

  .toast-container { left: 12px; right: 12px; top: 12px; }
  .toast { min-width: 0; max-width: none; }

  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; min-height: 44px; }
}

@media (max-width: 380px) {
  .stat-grid { grid-template-columns: 1fr; }
  .dash-metrics { grid-template-columns: 1fr; }
  .dash-metric.c-roi { grid-column: auto; }
  .dmc-primary,
  .dmc-grid { grid-template-columns: 1fr 1fr; }
  .topbar-summary .ts-cell,
  .topbar-summary .ts-cell.c-roi { flex: initial; min-width: 82px; }
  .bot-card { padding: 12px; }
  .bot-actions { gap: 6px; }
  .bot-actions .btn { font-size: 10.5px; padding-inline: 6px; }
}

/* ===================== Auth: login page ===================== */
.login-body {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(1100px 540px at 12% -8%, rgba(157,78,255,.16), transparent 60%),
    radial-gradient(900px 460px at 100% 0%, rgba(37,244,238,.12), transparent 55%),
    radial-gradient(820px 520px at 50% 120%, rgba(254,44,85,.12), transparent 60%),
    var(--bg);
}
.login-wrap { width: 100%; max-width: 400px; }
.login-card {
  position: relative; overflow: hidden;
  background: var(--card); backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong); border-radius: 20px; padding: 30px 26px;
  box-shadow: 0 30px 70px rgba(0,0,0,.6), 0 0 40px rgba(157,78,255,.18);
}
.login-card::before {
  content: ""; position: absolute; left: 0; top: 0; right: 0; height: 3px;
  background: var(--grad);
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.login-mark {
  flex: none; width: 54px; height: 54px; border-radius: 14px; overflow: hidden;
  display: grid; place-items: center;
  padding: 6px;
  background:
    radial-gradient(circle at 38% 20%, rgba(255,225,142,.20), transparent 38%),
    linear-gradient(145deg, rgba(24,20,14,.96), rgba(8,7,6,.98));
  border: 1px solid rgba(232,184,75,.36);
  box-shadow: 0 12px 24px rgba(0,0,0,.38), 0 0 20px rgba(232,184,75,.12);
}
.login-mark img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 12px rgba(0,0,0,.45)); }
.login-title { font-size: 22px; font-weight: 900; letter-spacing: 3px;
  color: var(--gold-light); text-shadow: 0 0 18px rgba(232,184,75,.24); }
.login-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.login-form { display: flex; flex-direction: column; }
.login-form .field-label { margin-top: 14px; }
.login-submit { width: 100%; min-height: 44px; margin-top: 22px; }
.login-error {
  margin-top: 14px; padding: 9px 12px; border-radius: 10px; font-size: 12.5px;
  color: #ff9bad; background: rgba(254,44,85,.12); border: 1px solid rgba(254,44,85,.4);
}
.login-foot { margin-top: 22px; text-align: center; color: var(--muted); font-size: 11px; }
.login-foot p { margin: 3px 0; }

/* ===================== Auth: topbar user menu ===================== */
.user-menu { display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 8px; height: 40px; box-sizing: border-box;
  padding: 0 12px 0 5px;
  border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--border); }
.user-ava { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; font-size: 13px; color: #1a1714;
  background: linear-gradient(135deg, var(--cyan), var(--purple)); }
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-name { font-size: 12.5px; font-weight: 800; }
.user-role { font-size: 9.5px; color: var(--purple-light); text-transform: uppercase; letter-spacing: .5px; }

/* ===================== Auth: members page ===================== */
.users-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.user-card { position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px;
  transition: transform .2s, border-color .2s; }
.user-card:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.uc-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.uc-ava { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 900; font-size: 18px; color: #1a1714;
  background: linear-gradient(135deg, var(--cyan), var(--purple)); }
.uc-name { font-size: 15px; font-weight: 800; }
.uc-you { font-size: 11px; color: var(--cyan); font-weight: 700; }
.uc-badges { display: flex; gap: 6px; margin-top: 5px; flex-wrap: wrap; }
.uc-meta { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px;
  padding: 10px 12px; border-radius: 10px; background: rgba(0,0,0,.22); border: 1px solid var(--border); }
.uc-row { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; }
.uc-row span { color: var(--muted); }
.uc-row b { font-weight: 700; }
.uc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.uc-actions .btn { flex: 1 1 auto; text-align: center; }

/* ---- create-campaign: mode tabs + adopt-existing picker ---- */
.mode-tabs { display: flex; gap: 8px; margin: 14px 0; }
.mode-tab {
  flex: 1 1 0; padding: 12px 14px; border-radius: 12px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line);
  color: var(--muted); font-weight: 700; font-size: 14px;
  transition: all .15s ease;
}
.mode-tab:hover { color: var(--white); border-color: var(--line-strong); }
.mode-tab.active {
  color: var(--white); border-color: rgba(232,184,75,.55);
  background: rgba(232,184,75,.10);
  box-shadow: 0 0 0 1px rgba(232,184,75,.25) inset;
}

.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.exist-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px; margin-top: 12px;
}
.exist-list.muted { display: block; padding: 20px 4px; }
.exist-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px;
}
.exist-card.is-adopted { opacity: .6; }
.exist-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.exist-name {
  font-weight: 800; color: var(--white); font-size: 14.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.exist-meta {
  display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted);
}
.exist-meta b { color: var(--white); font-weight: 700; }
.exist-foot { margin-top: 4px; display: flex; justify-content: flex-end; }
.exist-foot .btn { width: 100%; text-align: center; }

/* ===== Bot activity log (card 📜) ===== */
.log-tools {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0 0 12px;
}
.log-tools .btn {
  flex: 1 1 180px;
  justify-content: center;
}
.log-list {
  max-height: 56vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding-right: 4px;
}
.log-row {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}
.log-row.log-budget { border-color: rgba(43,217,163,.38); box-shadow: inset 0 0 0 1px rgba(43,217,163,.08); }
.log-row.log-stop { border-color: rgba(254,44,85,.42); box-shadow: inset 0 0 0 1px rgba(254,44,85,.08); }
.log-row.log-recreate { border-color: rgba(179,92,255,.42); box-shadow: inset 0 0 0 1px rgba(179,92,255,.08); }
.log-row.log-reset { border-color: rgba(232,184,75,.4); box-shadow: inset 0 0 0 1px rgba(232,184,75,.08); }
.log-row.log-auth { border-color: rgba(254,44,85,.34); box-shadow: inset 0 0 0 1px rgba(254,44,85,.06); }
.log-ico { font-size: 17px; line-height: 1.3; flex: none; }
.log-main { flex: 1; min-width: 0; }
.log-msg { color: var(--white); font-size: 13px; line-height: 1.45; word-break: break-word; }
.log-detail { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.log-detail summary { cursor: pointer; color: var(--cyan); user-select: none; }
.log-detail div { margin-top: 4px; word-break: break-word; opacity: .9; }
.log-time { color: var(--muted); font-size: 11px; margin-top: 3px; }
.log-budget {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-weight: 800; font-size: 13px;
  background: rgba(43, 217, 163, 0.12);
}
.log-budget.down { background: rgba(254, 44, 85, 0.12); }
.log-budget .lb-from { color: var(--muted); }
.log-budget .lb-arrow { color: var(--white); opacity: .7; }
.log-budget .lb-to { color: var(--green); }
.log-budget.down .lb-to { color: var(--red); }

/* ===================== Hardening pass: accessibility, overflow, mobile ===================== */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(37,244,238,.72);
  outline-offset: 3px;
  box-shadow: 0 0 0 1px rgba(7,6,5,.95), 0 0 18px rgba(37,244,238,.32);
}

.bot-card,
.bot-id,
.bot-id-text,
.bot-name,
.bot-channel,
.bot-sub,
.bc-text,
.bc-name,
.bc-meta,
.stat-cell,
.sc-label,
.sc-val {
  min-width: 0;
}

.bot-name,
.bc-name,
.bot-channel,
.bc-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sc-val,
.bsu-val,
.log-msg,
.rc-error,
.m-note,
.cond-preview {
  overflow-wrap: anywhere;
}

.bc-refresh,
.bs-refresh,
.modal-x,
.bot-actions .btn[data-cond],
.bot-actions .btn[data-edit],
.bot-actions .btn[data-del],
.bot-actions .btn[data-curl],
.bot-actions .btn[data-logs],
.work-grid-day input {
  min-width: 42px;
  min-height: 42px;
}

.modal {
  outline: none;
}

.modal-x {
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  min-width: 44px;
  min-height: 44px;
}

.work-grid-cell:focus-visible {
  position: relative;
  z-index: 4;
  outline-offset: -2px;
}

.toast-container {
  pointer-events: none;
}

.toast {
  pointer-events: auto;
}

@media (max-width: 760px) {
  .bot-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .bot-actions .btn {
    min-height: 44px;
    padding-inline: 8px;
  }
  .bot-actions .btn[data-cond],
  .bot-actions .btn[data-edit],
  .bot-actions .btn[data-del],
  .bot-actions .btn[data-curl],
  .bot-actions .btn[data-logs] {
    min-height: 44px;
  }

  .bot-actions .btn:nth-child(1),
  .bot-actions .btn:nth-child(2) {
    grid-column: span 2;
  }

  .work-grid-cell {
    min-width: 34px;
    min-height: 42px;
  }

  .modal {
    width: min(100vw - 16px, 1040px);
    max-height: calc(100dvh - 24px);
  }

  .modal-body {
    max-height: calc(100dvh - 132px);
  }
}

/* ===================== Adaptation pass: phone-first task surfaces ===================== */
@media (max-width: 640px) {
  body {
    font-size: 13px;
  }

  .sidebar {
    z-index: 24;
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .topbar {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px 12px;
  }

  .page-title {
    display: none;
  }

  .topbar-summary {
    order: 0;
    width: 100%;
    min-height: 54px;
    margin: 0;
    padding: 5px;
    border-radius: 12px;
    scroll-padding-inline: 6px;
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 24px), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 24px), transparent 100%);
  }

  .topbar-summary-dashboard {
    display: none;
  }

  .topbar-summary .ts-cell,
  .topbar-summary .ts-cell.c-roi {
    flex: initial;
    min-width: 84px;
    padding: 5px 6px;
  }

  .ts-label {
    font-size: 8.5px;
  }

  .ts-val {
    font-size: 15px;
  }

  .ts-spark {
    height: 10px;
    margin-top: 2px;
  }

  .topbar-right {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    width: 100%;
  }

  .topbar-right > * {
    min-width: 0;
  }

  .poll-ctl {
    grid-column: 1;
    min-height: 44px;
    padding-inline: 8px;
  }

  .poll-input {
    width: 42px;
    min-height: 30px;
    font-size: 14px;
  }

  #btn-import-curl {
    grid-column: 2;
    min-width: 0;
    min-height: 44px;
    padding-inline: 9px 10px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #btn-import-curl .tb-action-ico {
    width: 24px;
    height: 24px;
    padding: 5px;
  }

  .tb-chip.expiry {
    grid-column: 1;
    min-height: 44px;
    padding-inline: 9px;
  }

  .tb-chip-label,
  .tb-chip-unit {
    font-size: 10px;
  }

  .tb-meta {
    min-width: 0;
  }

  .tb-meta-label {
    font-size: 8px;
  }

  .tb-meta-val {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
  }

  .tb-badge {
    padding-inline: 6px;
    font-size: 9px;
  }

  .user-menu {
    grid-column: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    width: 100%;
  }

  .user-chip {
    min-width: 0;
    padding-right: 8px;
  }

  .user-meta {
    min-width: 0;
  }

  .user-name,
  .user-role {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #btn-logout {
    min-width: 48px;
    padding-inline: 10px;
    font-size: 0;
  }

  #btn-logout .tb-action-ico,
  #btn-logout span {
    display: none;
  }

  #btn-logout::after {
    content: "ออกระบบ";
    font-size: 12px;
  }

  .content {
    padding: 14px 12px max(18px, env(safe-area-inset-bottom));
  }

  .dash-head {
    gap: 10px;
    margin-bottom: 12px;
  }

  .dash-head h2 {
    font-size: 21px;
    line-height: 1.18;
  }

  .dash-head p {
    max-width: 34rem;
    font-size: 12px;
  }

  .dash-picker {
    gap: 7px;
  }

  .dash-date-nav {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    gap: 7px;
  }

  .dash-arrow {
    width: 40px;
    height: 42px;
    border-radius: 12px;
    font-size: 20px;
  }

  .dash-date-display {
    min-height: 42px;
    padding: 6px 12px;
  }

  .dash-date-display b {
    font-size: 13px;
    line-height: 1.25;
  }

  .dash-date-display span {
    font-size: 10px;
  }

  .dash-controls {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 0;
  }

  .dash-calendar-wrap {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    opacity: .01;
    clip-path: inset(50%);
    pointer-events: none;
  }

  .dash-controls .btn {
    width: 100%;
    min-width: 52px;
    min-height: 42px;
    padding-inline: 10px;
  }

  #dash-today {
    display: none;
  }

  #dash-refresh {
    grid-column: 1 / -1;
  }

  .dash-date-chips {
    display: flex;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 3px 1px 5px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    scrollbar-width: none;
    mask-image: none;
    -webkit-mask-image: none;
  }

  .dash-date-chips::-webkit-scrollbar {
    display: none;
  }

  .dash-date-chip {
    flex: 0 0 auto;
    width: auto;
    min-width: max-content;
    min-height: 34px;
    padding: 7px 12px;
    border-radius: 999px;
    justify-content: center;
    font-size: 11px;
  }

  .dash-date-chip.is-active {
    color: var(--white);
    border-color: rgba(37,244,238,.62);
    background: rgba(37,244,238,.14);
    box-shadow: 0 0 0 1px rgba(37,244,238,.08) inset;
  }

  .dash-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .dash-metric {
    min-height: 86px;
    padding: 11px 12px;
  }

  .dash-metric.c-roi {
    grid-column: span 2;
  }

  .dash-metric b {
    font-size: 20px;
  }

  .dash-table-card,
  .dash-side {
    padding: 14px 12px;
    border-radius: 14px;
  }

  .dash-mobile-card {
    padding: 12px;
    border-radius: 13px;
  }

  .dmc-head {
    align-items: center;
  }

  .dash-badge {
    min-width: 0;
    padding-inline: 9px;
  }

  .dmc-primary,
  .dmc-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .dmc-primary > div,
  .dmc-grid > div {
    padding: 10px;
  }

  .dmc-primary b,
  .dmc-grid b {
    font-size: 15px;
  }

  .dash-side {
    margin-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .bots-grid {
    gap: 14px;
  }

  .bot-card {
    padding: 14px 12px 16px;
    border-radius: 16px;
  }

  .bot-top {
    grid-template-columns: 62px minmax(0, 1fr);
    column-gap: 12px;
  }

  .bot-identity {
    width: 58px;
    height: 58px;
  }

  .bi-face {
    width: 50px;
    height: 50px;
  }

  .bot-id {
    min-height: 58px;
    align-self: stretch;
    justify-content: flex-start;
  }

  .bot-id-text {
    width: 100%;
  }

  .bot-name {
    font-size: 18px;
    line-height: 1.18;
  }

  .bot-channel,
  .bot-sub {
    white-space: normal;
  }

  .bot-channel {
    font-size: 12px;
  }

  .bot-badges {
    display: flex;
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    scroll-padding-inline: 2px;
    scrollbar-width: none;
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 20px), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 20px), transparent 100%);
  }

  .bot-badges::-webkit-scrollbar {
    display: none;
  }

  .badge {
    flex: 0 0 auto;
    min-height: 32px;
  }

  .bot-camp {
    grid-template-columns: 42px minmax(0, 1fr) 48px;
    gap: 10px;
    padding: 11px;
  }

  .bc-ico {
    width: 40px;
    height: 40px;
  }

  .bc-meta {
    white-space: normal;
  }

  .bc-refresh {
    width: 48px;
    height: 48px;
  }

  .bot-strip {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-padding-inline: 2px;
    scrollbar-width: none;
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 22px), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 22px), transparent 100%);
  }

  .bot-strip::-webkit-scrollbar {
    display: none;
  }

  .chip-mini {
    flex: 0 0 auto;
    min-height: 34px;
  }

  .bot-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .bot-actions .btn:nth-child(1),
  .bot-actions .btn:nth-child(2) {
    grid-column: span 3;
  }

  .bot-actions .btn,
  .bot-actions .btn[data-cond],
  .bot-actions .btn[data-edit],
  .bot-actions .btn[data-del],
  .bot-actions .btn[data-curl],
  .bot-actions .btn[data-delcamp],
  .bot-actions .btn[data-logs] {
    min-height: 44px;
    padding-inline: 8px;
  }

  .bot-actions .btn-text {
    display: inline;
  }
}

/* Mobile action row: money-sensitive controls must remain readable and tappable. */
@media (max-width: 640px) {
  .bot-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .bot-actions .btn:nth-child(1) {
    grid-column: span 1;
  }

  .bot-actions .btn:nth-child(2) {
    grid-column: auto;
  }

  .bot-actions .btn[data-delcamp] {
    grid-column: span 2;
  }

  .bot-actions .btn,
  .bot-actions .btn[data-cond],
  .bot-actions .btn[data-edit],
  .bot-actions .btn[data-del],
  .bot-actions .btn[data-curl],
  .bot-actions .btn[data-delcamp],
  .bot-actions .btn[data-logs] {
    min-width: 0;
    min-height: 46px;
    padding: 8px 9px;
    gap: 6px;
    font-size: 12px;
    line-height: 1.15;
    overflow: hidden;
    text-overflow: clip;
  }

  .bot-actions .btn-ico {
    width: 19px;
    min-width: 19px;
    height: 19px;
    font-size: 17px;
  }

  .bot-actions .btn-text {
    display: inline-block;
    min-width: 0;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
  }

  .bot-actions .dot-on {
    flex: 0 0 auto;
  }
}

@media (max-width: 380px) {
  .bot-actions {
    gap: 8px;
  }

  .bot-actions .btn,
  .bot-actions .btn[data-cond],
  .bot-actions .btn[data-edit],
  .bot-actions .btn[data-del],
  .bot-actions .btn[data-curl],
  .bot-actions .btn[data-delcamp],
  .bot-actions .btn[data-logs] {
    min-height: 44px;
    padding-inline: 8px;
    font-size: 11.5px;
  }

  .bot-actions .btn-ico {
    width: 18px;
    min-width: 18px;
    height: 18px;
    font-size: 16px;
  }
}

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

  .poll-ctl,
  #btn-import-curl,
  .tb-chip.expiry,
  .user-menu {
    grid-column: 1;
  }

  .topbar-summary .ts-cell,
  .topbar-summary .ts-cell.c-roi {
    flex: initial;
    min-width: 82px;
  }

  .dash-metrics {
    grid-template-columns: 1fr;
  }

  .dash-metric.c-roi {
    grid-column: auto;
  }

  .dmc-primary,
  .dmc-grid {
    grid-template-columns: 1fr;
  }
}

/* Top summary HUD: force the redesigned rail to win over older responsive rules. */
@media (max-width: 980px) {
  .topbar-summary {
    width: 100%;
    grid-template-columns: 78px repeat(5, minmax(92px, 1fr));
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .topbar-summary::-webkit-scrollbar { display: none; }
  .topbar-summary::before { min-width: 72px; }
  .topbar-summary .ts-cell,
  .topbar-summary .ts-cell.c-roi {
    min-width: 0;
    flex: initial;
  }

  .topbar-summary .ts-meta { display: none; }
}

@media (max-width: 640px) {
  .topbar-summary {
    grid-template-columns: 70px repeat(5, 86px);
    min-height: 62px;
    padding: 6px;
    border-radius: 16px 7px 16px 7px;
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 26px), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 26px), transparent 100%);
  }

  .topbar-summary::before {
    min-width: 70px;
    min-height: 48px;
    font-size: 8.5px;
    padding: 0 8px;
  }

  .topbar-summary .ts-cell,
  .topbar-summary .ts-cell.c-roi {
    min-height: 48px;
    padding: 5px 6px;
  }

  .ts-val { font-size: 15px; }
  .ts-label { font-size: 8.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }

  .brand-mark,
  .cd-ico,
  .spinner,
  .btn-warn-pulse {
    animation: none !important;
  }
}

/* V1 topbar fit guard: this must stay last so older responsive blocks cannot re-expand the rail. */
.topbar {
  min-width: 0;
}

.topbar .page-title,
.topbar-right {
  flex: 0 0 auto;
}

.topbar-summary:not([hidden]) {
  flex: 1 1 720px;
  width: auto;
  max-width: 930px;
  min-width: 0;
  box-sizing: border-box;
  grid-template-columns:
    minmax(62px, 0.52fr)
    minmax(58px, 0.58fr)
    minmax(78px, 0.82fr)
    minmax(92px, 1fr)
    minmax(58px, 0.54fr)
    minmax(92px, 0.9fr)
    minmax(104px, 1fr);
  gap: 7px;
  overflow: hidden;
}

.topbar-summary .ts-meta {
  display: none;
}

.topbar-summary .ts-cell,
.topbar-summary .ts-cell.c-roi,
.topbar-summary .ts-meta {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.topbar-summary .ts-label,
.topbar-summary .ts-val,
.topbar-summary .ts-sub,
.topbar-summary .ts-meta {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-summary .ts-cell {
  padding-inline: 8px;
}

.topbar-summary .ts-cell.c-balance {
  padding-inline: 7px;
}

.topbar-summary .ts-cell.c-balance .ts-val,
.topbar-summary .ts-cell.c-cpo .ts-val {
  font-size: clamp(13px, 0.95vw, 17px);
  letter-spacing: -0.01em;
}

@media (max-width: 1500px) and (min-width: 981px) {
  .topbar-summary:not([hidden]) {
    flex-basis: 620px;
    max-width: 820px;
    grid-template-columns:
      minmax(56px, 0.48fr)
      minmax(52px, 0.56fr)
      minmax(72px, 0.82fr)
      minmax(84px, 1fr)
      minmax(52px, 0.52fr)
      minmax(82px, 0.86fr)
      minmax(94px, 0.96fr);
    gap: 6px;
    padding-inline: 7px;
  }

  .topbar-summary::before {
    font-size: 7.5px;
    padding-inline: 6px;
  }

  .topbar-summary .ts-cell {
    padding-inline: 6px;
  }

  .topbar-summary .ts-cell.c-balance .ts-val,
  .topbar-summary .ts-cell.c-cpo .ts-val {
    font-size: clamp(12px, 0.9vw, 15px);
  }
}
