/* Telegram Ads — Redesign */
:root {
  --bg: #0c1014;
  --surface: #141a21;
  --surface-2: #1a2230;
  --surface-3: #222c3c;
  --border: #232c39;
  --border-strong: #2c3849;
  --text: #e6edf5;
  --text-dim: #98a4b3;
  --text-mute: #5e6b7d;
  --accent: #3b9dff;
  --accent-soft: rgba(59, 157, 255, 0.14);
  --accent-hover: #5badff;
  --success: #2dd29a;
  --success-soft: rgba(45, 210, 154, 0.12);
  --warn: #f5b340;
  --warn-soft: rgba(245, 179, 64, 0.14);
  --danger: #ff5f6d;
  --danger-soft: rgba(255, 95, 109, 0.14);
  --info: #8b8cff;
  --info-soft: rgba(139, 140, 255, 0.14);

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;

  --shadow-md: 0 8px 24px rgba(0,0,0,0.35);
  --shadow-lg: 0 24px 60px rgba(0,0,0,0.5);

  --nav-w: 232px;
  --inspector-w: 380px;

  --font: "Plus Jakarta Sans", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; color: inherit; }

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar nav ---------- */
.nav {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}
.nav-brand-logo {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, #6cb5ff 100%);
  display: grid; place-items: center;
  color: white;
}
.nav-brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.nav-brand-sub {
  font-size: 11px;
  color: var(--text-mute);
  font-weight: 500;
}
.nav-section { padding: 14px 10px 8px; }
.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  padding: 0 10px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px;
  width: 3px; background: var(--accent); border-radius: 0 3px 3px 0;
}
.nav-item .nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-family: var(--mono);
  background: var(--surface-3);
  color: var(--text-dim);
  padding: 2px 7px;
  border-radius: 10px;
}
.nav-item.active .nav-badge { background: var(--accent); color: white; }

.nav-spacer { flex: 1; }
.nav-account {
  border-top: 1px solid var(--border);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff8966, #c45d96);
  display: grid; place-items: center;
  font-weight: 700;
  color: white;
  font-size: 13px;
}
.nav-account-text { flex: 1; min-width: 0; }
.nav-account-name {
  font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-account-handle { font-size: 11px; color: var(--text-mute); }

/* ---------- Main ---------- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--text-mute); font-size: 13px; }
.crumbs strong { color: var(--text); font-weight: 600; }
.topbar-spacer { flex: 1; }
.budget-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 7px 12px 7px 10px;
  border-radius: 999px;
  font-size: 13px;
}
.budget-pill .budget-label {
  color: var(--text-mute);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.budget-pill .budget-amount {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text);
}
.budget-pill .budget-icon { color: var(--accent); }
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  transition: color 0.12s, border-color 0.12s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

/* Content area */
.content {
  padding: 24px 28px 80px;
  display: flex; flex-direction: column; gap: 20px;
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px;
}
.page-title {
  font-size: 24px; font-weight: 700; letter-spacing: -0.02em;
  margin: 0;
}
.page-sub { color: var(--text-mute); font-size: 13px; margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  font-size: 13px; font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: all 0.12s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent); color: white;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--surface); color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn-ghost { color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); background: var(--surface); }
.btn-success { background: var(--success); color: #062418; }
.btn-success:hover { filter: brightness(1.08); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { filter: brightness(1.08); }
.btn.sm { padding: 6px 10px; font-size: 12px; }

/* KPI cards */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
  overflow: hidden;
}
.kpi-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-mute); font-weight: 600;
}
.kpi-head .kpi-icon { color: var(--accent); opacity: 0.9; }
.kpi-value {
  font-family: var(--mono);
  font-size: 26px; font-weight: 600;
  letter-spacing: -0.02em;
}
.kpi-foot {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-mute);
}
.kpi-delta { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-family: var(--mono); }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }
.kpi-spark { position: absolute; right: 12px; bottom: 10px; opacity: 0.55; }

/* Toolbar (filter chips, search, actions) */
.toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.search {
  flex: 1; min-width: 240px;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  transition: border-color 0.12s;
}
.search:focus-within { border-color: var(--accent); }
.search input {
  flex: 1; background: transparent; border: none; outline: none;
  font-size: 13px; color: var(--text);
}
.search input::placeholder { color: var(--text-mute); }
.chip-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  font-size: 12px; font-weight: 600;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  transition: all 0.12s;
  cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.active {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}
.chip-dot { width: 6px; height: 6px; border-radius: 50%; }
.chip-count {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 5px;
  background: var(--surface-3);
  border-radius: 8px;
  color: var(--text-dim);
}
.chip.active .chip-count { background: var(--accent); color: white; }
.toolbar-sep {
  width: 1px; height: 22px; background: var(--border); margin: 0 4px;
}

/* Table */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; }
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 1100px;
}
.tbl thead th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  font-weight: 600;
  padding: 12px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
.tbl thead th.sortable { cursor: pointer; }
.tbl thead th.sortable:hover { color: var(--text); }
.tbl thead th .sort-arrow { display: inline-block; margin-left: 4px; opacity: 0.5; font-size: 9px; }
.tbl thead th.sorted .sort-arrow { opacity: 1; color: var(--accent); }

/* Drag-and-drop column headers */
.tbl thead th.col-drag {
  position: relative;
  user-select: none;
}
.tbl thead th.col-drag .col-grip {
  display: inline-block;
  color: var(--text-mute);
  font-weight: 700;
  font-size: 10px;
  margin-right: 6px;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.12s;
  vertical-align: middle;
}
.tbl thead th.col-drag:hover .col-grip { opacity: 0.7; }
.tbl thead th.col-drag.dragging {
  opacity: 0.4;
}
.tbl thead th.col-drag.drop-before::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.tbl thead th.col-drag.drop-after::after {
  content: ""; position: absolute; right: 0; top: 0; bottom: 0;
  width: 2px; background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* Extended-stat columns — slightly tinted header */
.tbl thead th.ext-head {
  font-family: var(--mono);
  font-size: 10px;
  border-bottom-color: rgba(59, 157, 255, 0.3);
}
.tbl thead th.ext-head:nth-child(odd) {
  background: linear-gradient(180deg, var(--surface-2) 0%, rgba(59,157,255,0.03) 100%);
}
.tbl tbody td.ext-cell {
  font-family: var(--mono);
  font-size: 12px;
}
.tbl tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl tbody tr {
  transition: background 0.1s;
  cursor: pointer;
}
.tbl tbody tr:hover { background: var(--surface-2); }

/* Status row gradient tint — like the original extension */
.tbl tbody tr.row-active   { background: linear-gradient(90deg, rgba(45, 210, 154, 0.12) 0%, transparent 55%); }
.tbl tbody tr.row-stopped  { background: linear-gradient(90deg, rgba(255, 95, 109, 0.13) 0%, transparent 55%); }
.tbl tbody tr.row-review   { background: linear-gradient(90deg, rgba(139, 140, 255, 0.13) 0%, transparent 55%); }
.tbl tbody tr.row-hold     { background: linear-gradient(90deg, rgba(245, 179, 64, 0.13) 0%, transparent 55%); }
.tbl tbody tr.row-declined { background: linear-gradient(90deg, rgba(148, 163, 184, 0.10) 0%, transparent 55%); }

.tbl tbody tr.row-active:hover   { background: linear-gradient(90deg, rgba(45, 210, 154, 0.18) 0%, var(--surface-2) 80%); }
.tbl tbody tr.row-stopped:hover  { background: linear-gradient(90deg, rgba(255, 95, 109, 0.18) 0%, var(--surface-2) 80%); }
.tbl tbody tr.row-review:hover   { background: linear-gradient(90deg, rgba(139, 140, 255, 0.18) 0%, var(--surface-2) 80%); }
.tbl tbody tr.row-hold:hover     { background: linear-gradient(90deg, rgba(245, 179, 64, 0.18) 0%, var(--surface-2) 80%); }
.tbl tbody tr.row-declined:hover { background: linear-gradient(90deg, rgba(148, 163, 184, 0.16) 0%, var(--surface-2) 80%); }

/* Selected row — semi-blue overlay + left accent bar */
.tbl tbody tr.selected,
.tbl tbody tr.selected.row-active,
.tbl tbody tr.selected.row-stopped,
.tbl tbody tr.selected.row-review,
.tbl tbody tr.selected.row-hold,
.tbl tbody tr.selected.row-declined {
  background: rgba(36, 129, 204, 0.1) !important;
  box-shadow: inset 3px 0 0 var(--accent);
}
.tbl tbody tr.selected td { border-color: rgba(59,157,255,0.25); }
.tbl tbody tr:last-child td { border-bottom: none; }

/* Drag-paint selection: change cursor across whole document while painting */
body.painting,
body.painting .tbl tbody tr {
  cursor: crosshair !important;
  user-select: none !important;
}

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.dim { color: var(--text-mute); }

.ad-cell {
  display: flex; align-items: center; gap: 12px;
  min-width: 200px;
}
.ad-mega {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--surface-3);
  display: grid; place-items: center;
  color: var(--text-dim);
  flex-shrink: 0;
}
.ad-meta { display: flex; flex-direction: column; gap: 2px; }
.ad-title { font-weight: 600; color: var(--text); }
.ad-id { font-size: 11px; font-family: var(--mono); color: var(--text-mute); }

.toncoin {
  display: inline-flex; align-items: baseline; gap: 4px;
}
.toncoin::before {
  content: ""; display: inline-block;
  width: 10px; height: 10px;
  background: var(--text-mute);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2L2 7l10 15L22 7 12 2zm0 2.3l7.2 3.6L12 18.8 4.8 7.9 12 4.3z'/></svg>") center/contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2L2 7l10 15L22 7 12 2zm0 2.3l7.2 3.6L12 18.8 4.8 7.9 12 4.3z'/></svg>") center/contain no-repeat;
  transform: translateY(1px);
}

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; }
.status-active { background: var(--success-soft); color: var(--success); }
.status-active .status-dot { background: var(--success); box-shadow: 0 0 0 3px rgba(45,210,154,0.18); }
.status-stopped { background: var(--danger-soft); color: var(--danger); }
.status-stopped .status-dot { background: var(--danger); }
.status-review { background: var(--info-soft); color: var(--info); }
.status-review .status-dot { background: var(--info); }
.status-hold { background: var(--warn-soft); color: var(--warn); }
.status-hold .status-dot { background: var(--warn); }
.status-declined { background: var(--surface-3); color: var(--text-mute); }
.status-declined .status-dot { background: var(--text-mute); }

.rec {
  font-size: 11.5px;
  color: var(--text-mute);
  font-weight: 500;
  margin-top: 3px;
}

.row-action {
  width: 28px; height: 28px; border-radius: 6px;
  display: grid; place-items: center;
  color: var(--text-mute);
}
.row-action:hover { background: var(--surface-3); color: var(--text); }

/* Checkbox */
.cb {
  appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: transparent;
  position: relative;
  cursor: pointer;
  transition: all 0.12s;
  display: inline-block;
  vertical-align: middle;
}
.cb:hover { border-color: var(--accent); }
.cb:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.cb:checked::after {
  content: "";
  position: absolute;
  left: 4px; top: 1px;
  width: 4px; height: 8px;
  border: solid white; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.cb.indeterminate {
  background: var(--accent);
  border-color: var(--accent);
}
.cb.indeterminate::after {
  content: "";
  position: absolute;
  left: 3px; top: 6px;
  width: 8px; height: 2px;
  background: white;
}

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-dim);
}
.page-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: inline-grid; place-items: center;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
}
.page-btn:hover { background: var(--surface-2); color: var(--text); }
.page-btn.active { background: var(--accent); color: white; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Inspector drawer */
.inspector {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: var(--inspector-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 20;
  box-shadow: var(--shadow-lg);
}
.inspector.open { transform: translateX(0); }
.inspector-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.inspector-head-title { font-weight: 600; font-size: 15px; flex: 1; }
.inspector-head-sub { color: var(--text-mute); font-size: 12px; }
.inspector-close { color: var(--text-mute); width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; }
.inspector-close:hover { background: var(--surface-2); color: var(--text); }
.inspector-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 24px;
  display: flex; flex-direction: column; gap: 22px;
}
.insp-section { display: flex; flex-direction: column; gap: 10px; }
.insp-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-mute); font-weight: 600;
}
.insp-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.stat-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-box-label {
  font-size: 11px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.stat-box-value {
  font-family: var(--mono); font-size: 16px; font-weight: 600;
}
.stat-box.success .stat-box-value { color: var(--success); }
.stat-box.warn .stat-box-value { color: var(--warn); }
.stat-box.info .stat-box-value { color: var(--info); }
.stat-box.danger .stat-box-value { color: var(--danger); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-input {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  transition: border-color 0.12s;
}
.field-input:focus-within { border-color: var(--accent); }
.field-input input {
  flex: 1; background: transparent; border: none; outline: none;
  font-family: var(--mono); font-size: 14px; color: var(--text);
}
.field-input input::placeholder { color: var(--text-mute); }
.field-row { display: flex; gap: 8px; }
.field-row > * { flex: 1; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Filters panel (slide from right) */
.filters {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 360px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 19;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.filters.open { transform: translateX(0); }
.filter-body {
  flex: 1; overflow-y: auto;
  padding: 18px 20px 24px;
  display: flex; flex-direction: column; gap: 18px;
}
.filter-group {
  display: flex; flex-direction: column; gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.filter-group:last-child { border-bottom: none; }
.filter-group-head { display: flex; align-items: center; justify-content: space-between; }
.filter-group-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text); }
.range-tabs { display: flex; gap: 4px; }
.range-tab {
  font-size: 10.5px; font-family: var(--mono); font-weight: 600;
  padding: 3px 7px; border-radius: 4px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text-mute);
}
.range-tab:hover { color: var(--text); }
.range-tab.active { background: var(--accent); border-color: var(--accent); color: white; }

.scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 18;
}
.scrim.open { opacity: 1; pointer-events: auto; }

/* Bulk action bar at bottom */
.bulkbar {
  position: fixed;
  left: calc(var(--nav-w) + 28px); right: 28px; bottom: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 15;
  transform: translateY(120%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.bulkbar.open { transform: translateY(0); }
.bulkbar-count {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 13px;
}
.bulkbar-count .num-bubble {
  background: var(--accent); color: white;
  padding: 2px 8px; border-radius: 999px;
  font-family: var(--mono); font-size: 11px;
}
.bulkbar-actions { display: flex; gap: 8px; margin-left: auto; }

/* Misc */
.divider { height: 1px; background: var(--border); }
.spinner-line {
  height: 2px; background: var(--accent);
  width: 30%; border-radius: 999px;
  animation: indeterminate 1.4s ease-in-out infinite;
}
@keyframes indeterminate {
  0% { transform: translateX(-100%); width: 30%; }
  50% { width: 50%; }
  100% { transform: translateX(360%); width: 30%; }
}

/* Density */
body[data-density="compact"] .tbl tbody td { padding: 8px 14px; }
body[data-density="compact"] .kpi { padding: 12px 14px; }
body[data-density="comfortable"] .tbl tbody td { padding: 16px 14px; }

/* Accent palettes */
body[data-accent="blue"] { --accent: #3b9dff; --accent-soft: rgba(59,157,255,0.14); --accent-hover: #5badff; }
body[data-accent="teal"] { --accent: #2dd2c2; --accent-soft: rgba(45,210,194,0.14); --accent-hover: #4ee0d2; }
body[data-accent="violet"] { --accent: #8b8cff; --accent-soft: rgba(139,140,255,0.16); --accent-hover: #a3a4ff; }
body[data-accent="amber"] { --accent: #f5b340; --accent-soft: rgba(245,179,64,0.14); --accent-hover: #ffc15c; }

/* Bg palette */
body[data-bg="ink"] { --bg: #0c1014; --surface: #141a21; --surface-2: #1a2230; --surface-3: #222c3c; --border: #232c39; --border-strong: #2c3849; }
body[data-bg="slate"] { --bg: #0e1116; --surface: #161b22; --surface-2: #1d242e; --surface-3: #262f3c; --border: #232a36; --border-strong: #2f3946; }
body[data-bg="charcoal"] { --bg: #131313; --surface: #1c1c1d; --surface-2: #232325; --surface-3: #2c2c2e; --border: #2a2a2c; --border-strong: #36363a; }

/* ---------- Page tabs ---------- */
.ptabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.ptab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mute);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.12s;
}
.ptab:hover { color: var(--text); }
.ptab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Form layout ---------- */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  display: flex; flex-direction: column; gap: 18px;
}
.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}
.form-section { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label.fl {
  font-size: 12px; font-weight: 600;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 6px;
}
.form-row .hint { font-size: 11.5px; color: var(--text-mute); margin-top: 2px; }
.tinput {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.12s;
  width: 100%;
}
.tinput:focus { border-color: var(--accent); }
.tinput::placeholder { color: var(--text-mute); }
textarea.tinput { resize: vertical; min-height: 80px; line-height: 1.5; }
.input-prefix {
  display: flex; align-items: stretch;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.12s;
}
.input-prefix:focus-within { border-color: var(--accent); }
.input-prefix .pfx {
  display: flex; align-items: center; padding: 0 12px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12px;
  border-right: 1px solid var(--border);
}
.input-prefix .tinput {
  border: none; background: transparent; border-radius: 0;
}

/* Radio / segment / toggle */
.seg {
  display: inline-flex;
  background: var(--bg);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border);
  gap: 2px;
}
.seg-item {
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mute);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.seg-item:hover { color: var(--text); }
.seg-item.active {
  background: var(--surface-3);
  color: var(--text);
}

.target-tabs {
  display: flex; gap: 8px;
}
.target-tab {
  flex: 1;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.12s;
}
.target-tab:hover { color: var(--text); border-color: var(--border-strong); }
.target-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Preview card */
.preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  position: sticky; top: 80px;
  display: flex; flex-direction: column; gap: 14px;
}
.preview-title {
  font-size: 12px; font-weight: 600; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.tg-bubble {
  background: linear-gradient(180deg, #182531 0%, #14202b 100%);
  border-radius: 12px;
  padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
  border-left: 3px solid var(--accent);
}
.tg-bubble .tg-sitename {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--accent); font-weight: 600;
}
.tg-bubble .tg-ad-badge {
  display: inline-block;
  background: var(--surface-3);
  color: var(--text-mute);
  font-size: 10px; padding: 1px 6px; border-radius: 4px;
}
.tg-bubble .tg-channel { font-weight: 600; font-size: 14px; }
.tg-bubble .tg-text { font-size: 13px; color: var(--text-dim); line-height: 1.5; }
.tg-bubble .tg-btn {
  margin-top: 4px;
  background: var(--accent);
  color: white;
  text-align: center;
  padding: 8px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
}
.tg-bubble-empty {
  color: var(--text-mute);
  font-size: 12.5px;
  text-align: center;
  padding: 30px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
}

/* Chart container */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 24px;
}
.chart-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 16px;
}
.chart-head h4 {
  font-size: 14px; font-weight: 600; margin: 0;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-mute);
}
.chart-svg { width: 100%; height: 220px; }

/* Stat tiles row */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.stat-tile-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-mute); font-weight: 600;
}
.stat-tile-value {
  font-family: var(--mono); font-size: 20px; font-weight: 600; margin-top: 6px;
}
.stat-tile.accent .stat-tile-value { color: var(--accent); }

/* Transactions table */
.tx-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tx-table th {
  text-align: left;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-mute); font-weight: 600;
  padding: 12px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.tx-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.tx-table tr:last-child td { border-bottom: none; }
.tx-amount { font-family: var(--mono); font-weight: 600; }
.tx-amount.in { color: var(--success); }
.tx-amount.out { color: var(--text); }

/* Account header */
.acct-card {
  display: flex; align-items: center; gap: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
}
.acct-avatar {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ff8966, #c45d96);
  display: grid; place-items: center;
  font-size: 24px; font-weight: 700; color: white;
}
.acct-info { flex: 1; }
.acct-name { font-size: 18px; font-weight: 700; }
.acct-handle { color: var(--text-mute); font-size: 13px; }
.acct-actions { display: flex; gap: 8px; }

/* Big budget balance card */
.balance-card {
  background:
    radial-gradient(circle at 90% 10%, rgba(59,157,255,0.15), transparent 50%),
    linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
}
.balance-label {
  text-transform: uppercase; letter-spacing: 0.08em;
  font-size: 11px; color: var(--text-mute); font-weight: 600;
}
.balance-amount {
  font-family: var(--mono); font-size: 42px; font-weight: 600;
  letter-spacing: -0.02em; margin-top: 8px;
  display: flex; align-items: baseline; gap: 12px;
}
.balance-amount .frac { font-size: 24px; color: var(--text-mute); }
.balance-amount .ccy { font-size: 18px; color: var(--accent); font-weight: 700; }
.balance-actions { display: flex; flex-direction: column; gap: 8px; }

/* Mini calendar for ad schedule */
.schedule-grid {
  display: grid;
  grid-template-columns: 28px repeat(24, 1fr);
  gap: 2px;
}
.schedule-cell {
  height: 16px;
  background: var(--surface-2);
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.1s;
}
.schedule-cell:hover { background: var(--surface-3); }
.schedule-cell.on { background: var(--accent); }
.schedule-day {
  font-size: 10px; color: var(--text-mute);
  font-weight: 600;
  display: grid; place-items: center;
}

/* Mobile responsive — collapse nav on small screens */
@media (max-width: 1100px) {
  .app { grid-template-columns: 64px 1fr; }
  .nav-brand-name, .nav-brand-sub, .nav-item span, .nav-section-label, .nav-account-text, .nav-account button { display: none; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .nav-account { justify-content: center; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-tiles { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Modal ---------- */
.modal-scrim {
  position: fixed; inset: 0;
  background: rgba(2, 6, 14, 0.55);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  z-index: 40;
  animation: scrim-in 0.18s ease-out;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  width: 420px; max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 600; font-size: 15px; }
.modal-sub { color: var(--text-mute); font-size: 12px; margin-top: 2px; }
.modal-body {
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 14px;
}
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ---------- Pre-auth pages (Auth / Choose account / New org) ---------- */
.preauth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  position: relative;
  isolation: isolate;
}
.preauth-bg {
  position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(59,157,255,0.10) 0%, transparent 70%),
    radial-gradient(80% 60% at 100% 100%, rgba(139,140,255,0.08) 0%, transparent 70%),
    var(--bg);
}
.preauth-content {
  display: flex; flex-direction: column; gap: 20px;
  align-items: stretch;
  width: 100%;
  max-width: 460px;
}
.preauth-content > .preauth-card.wide { max-width: none; }
.preauth-brand {
  display: flex; align-items: center; gap: 12px;
  justify-content: center;
  flex-direction: column;
  margin-bottom: 4px;
}
.preauth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 26px 28px;
  box-shadow: var(--shadow-md);
}
.preauth-card.wide { width: 100%; max-width: 560px; }
.preauth-title {
  font-size: 20px; font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.preauth-text { color: var(--text-dim); font-size: 13.5px; line-height: 1.5; margin: 0; }
.preauth-text a { color: var(--accent); }
.preauth-section {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-mute); margin: 18px 0 10px;
}
.preauth-foot {
  font-size: 11.5px; color: var(--text-mute); text-align: center; max-width: 460px;
}
.preauth-foot a { color: var(--accent); }
.preauth-dots {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-mute);
  display: inline-flex; align-items: center; gap: 4px;
}
.preauth-dots span {
  display: inline-block;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
  animation: dot-pulse 1.2s infinite ease-in-out;
}
.preauth-dots span:nth-child(2) { animation-delay: 0.2s; }
.preauth-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-pulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
  40%           { opacity: 1;    transform: scale(1); }
}

.account-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.account-pick {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, transform 0.12s;
}
.account-pick:hover { border-color: var(--accent); background: rgba(59,157,255,0.05); }
.account-pick:active { transform: translateY(1px); }
.account-pick.new { border-style: dashed; }
.account-pick-avatar {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 700; color: white; font-size: 13px;
  flex-shrink: 0;
}
.account-pick-avatar.new { background: var(--surface-3); color: var(--text-mute); }
.account-pick-meta { flex: 1; min-width: 0; }
.account-pick-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-pick-desc { font-size: 12px; color: var(--text-mute); margin-top: 2px; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
::-webkit-scrollbar-track { background: transparent; }
