/* ─────────────────────────────────────────────────────────────
   styles.css — Waterfall Config Dashboard
   ───────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Theme A — Dark Professional (default) ── */
:root {
  --bg:        #0b0e1a;
  --panel:     #131729;
  --surface:   #1a1f35;
  --border:    #252d4a;
  --border2:   #2e3860;
  --text:      #e8ecf4;
  --muted:     #5d6a8a;
  --accent:    #4f8ef7;
  --accent2:   #7c5cfc;
  --green:     #22c55e;
  --yellow:    #f59e0b;
  --red:       #ef4444;
  --mono:      'IBM Plex Mono', monospace;
  --sans:      'IBM Plex Sans', sans-serif;
  --radius:    8px;
  --sidebar-w: 280px;
  --shadow:    0 4px 24px rgba(0,0,0,0.5);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.4);
}

/* ── Theme B — Clean White SaaS ── */
[data-theme="B"] {
  --bg:       #f4f6fb;
  --panel:    #edf0f7;
  --surface:  #ffffff;
  --border:   #e2e8f0;
  --border2:  #cbd5e1;
  --text:     #0f172a;
  --muted:    #64748b;
  --accent:   #2563eb;
  --accent2:  #7c3aed;
  --green:    #16a34a;
  --yellow:   #d97706;
  --red:      #dc2626;
  --radius:   10px;
  --shadow:    0 1px 4px rgba(15,23,42,0.08), 0 4px 16px rgba(15,23,42,0.04);
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.06);
}

/* ── Theme C — Dark Teal ── */
[data-theme="C"] {
  --bg:       #080f0f;
  --panel:    #0f1a1a;
  --surface:  #162020;
  --border:   #1e3030;
  --border2:  #274040;
  --text:     #e2f0ee;
  --muted:    #4d7070;
  --accent:   #0ea5a5;
  --accent2:  #10b981;
  --green:    #10b981;
  --yellow:   #f59e0b;
  --red:      #f87171;
  --radius:   8px;
  --shadow:    0 4px 24px rgba(0,0,0,0.6);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.5);
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Login ─────────────────────────────────────────────────── */
#loginScreen {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  width: 380px;
  background: var(--panel);
  border: 1px solid var(--border2);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 32px 80px rgba(0,0,0,.7);
}
.login-head {
  padding: 28px 28px 20px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.login-logo {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .1em;
  text-transform: uppercase;
  border: 1px solid var(--border2);
  background: var(--surface);
  padding: 4px 12px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 14px;
}
.login-title    { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.login-subtitle { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.login-body     { padding: 24px 28px; }
.login-error {
  display: none;
  background: var(--surface);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 9px 12px;
  margin-bottom: 14px;
  font-size: 11px;
  color: var(--red);
  font-family: var(--mono);
  line-height: 1.5;
}
.login-error.show { display: block; }
.login-footer { padding: 12px 28px 24px; text-align: center; font-family: var(--mono); font-size: 10px; color: var(--muted); }

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  height: 48px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-logo {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .08em;
  text-transform: uppercase;
  border: 1px solid #3a1a14;
  background: #fff3f0;
  padding: 3px 8px;
  border-radius: 4px;
}
.topbar-title       { font-size: 13px; color: var(--muted); flex: 1; }
.topbar-title span  { color: var(--text); font-weight: 500; }
.db-status          { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 10px; color: var(--muted); }
.db-dot             { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.db-dot.connected   { background: var(--green); box-shadow: 0 0 6px var(--green); }
.db-dot.error       { background: var(--red); }

/* ── User menu ─────────────────────────────────────────────── */
.user-menu { position: relative; }
.user-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 5px 10px;
  cursor: pointer;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text);
  transition: background .15s;
}
.user-btn:hover { background: var(--panel); }
.user-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  background: #fff3f0;
  color: var(--accent);
}
.role-badge {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
  font-family: var(--mono);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.role-admin { background: #fff0f0; color: var(--accent);  border: 1px solid #fca5a5; }
.role-user  { background: #dbeafe; color: var(--accent2); border: 1px solid #93c5fd; }

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--panel);
  border: 1px solid var(--border2);
  border-radius: 8px;
  min-width: 190px;
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity .15s, transform .15s;
}
.user-dropdown.open { opacity: 1; pointer-events: all; transform: translateY(0); }
.dd-info { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.dd-name  { font-size: 12px; font-weight: 500; color: var(--text); }
.dd-email { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 2px; }
.dd-item  {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.dd-item:hover         { background: var(--surface); color: var(--text); }
.dd-item.danger:hover  { color: var(--red); }

/* ── Layout ────────────────────────────────────────────────── */
.layout { display: flex; flex: 1; overflow: hidden; height: calc(100vh - 48px); }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-label { font-family: var(--mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.btn-add-site {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--accent2);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 11px;
  font-family: var(--mono);
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn-add-site:hover    { background: var(--panel); border-color: var(--accent2); }
.btn-add-site:disabled { opacity: .4; cursor: not-allowed; }

.site-list { flex: 1; overflow-y: auto; padding: 8px; }
.site-list::-webkit-scrollbar       { width: 4px; }
.site-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.site-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 4px;
  transition: background .12s, border-color .12s;
  position: relative;
}
.site-item:hover  { background: var(--surface); }
.site-item.active { background: var(--surface); border-color: var(--accent); }
.site-dot   { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.site-info  { flex: 1; min-width: 0; }
.site-name  { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-domain{ font-family: var(--mono); font-size: 10px; color: var(--muted); }
.site-badge { font-family: var(--mono); font-size: 9px; color: var(--muted); background: var(--border); padding: 2px 6px; border-radius: 10px; flex-shrink: 0; }
.site-del   {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 2px 4px; border-radius: 3px;
  opacity: 0; transition: opacity .12s, color .12s;
}
.site-item:hover .site-del { opacity: 1; }
.site-del:hover { color: var(--accent); }

.sidebar-empty { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.8; }
.sidebar-empty-icon { font-size: 28px; margin-bottom: 10px; }

/* ── Main area ─────────────────────────────────────────────── */
.main { flex: 1; display: flex; overflow: hidden; }
.editor-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.panel-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--panel);
}
.panel-title    { font-size: 14px; font-weight: 600; color: var(--text); }
.panel-subtitle { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.panel-actions  { display: flex; gap: 8px; }
.config-body    { flex: 1; overflow-y: auto; padding: 20px; }
.config-body::-webkit-scrollbar       { width: 4px; }
.config-body::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 12px; color: var(--muted); text-align: center; }
.empty-state-icon { font-size: 48px; opacity: .4; }
.empty-state h3   { font-size: 16px; color: var(--text); font-weight: 500; }
.empty-state p    { font-size: 12px; max-width: 280px; line-height: 1.7; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px; border-radius: var(--radius);
  font-size: 12px; font-family: var(--mono); font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  transition: all .15s; white-space: nowrap;
}
.btn:disabled                  { opacity: .4; cursor: not-allowed; }
.btn-ghost                     { background: transparent; border-color: var(--border2); color: var(--muted); }
.btn-ghost:hover:not(:disabled){ background: var(--surface); color: var(--text); }
.btn-primary                   { background: var(--accent); color: #ffffff; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover:not(:disabled){ filter: brightness(1.15); }
.btn-blue                      { background: transparent; border-color: var(--accent2); color: var(--accent2); }
.btn-blue:hover:not(:disabled) { background: var(--surface); }
.btn-green                     { background: var(--green); color: #ffffff; border-color: var(--green); font-weight: 600; }
.btn-green:hover:not(:disabled){ filter: brightness(1.15); }
.btn-danger                    { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover:not(:disabled){ background: var(--surface); }

/* ── Sections ──────────────────────────────────────────────── */
.section { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 16px; overflow: hidden; }
.section-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
}
.section-title {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: var(--accent2); text-transform: uppercase; letter-spacing: .08em;
}
.section-body { padding: 16px; }
.section-body.wf-collapsed { display: none; }
.wf-section-toggle {
  background: none; border: 1px solid var(--border); border-radius: 50%;
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer;
  transition: border-color .15s, color .15s; flex-shrink: 0;
}
.wf-section-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ── Tag Input ──────────────────────────────────────────────── */
.wf-tag-input {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  min-height: 36px; padding: 4px 8px; cursor: text;
  background: var(--input-bg, var(--surface)); border: 1px solid var(--border);
  border-radius: var(--radius); transition: border-color .15s;
}
.wf-tag-input:focus-within { border-color: var(--accent); }
.wf-tag-input input {
  flex: 1; min-width: 120px; border: none; background: transparent;
  color: var(--text); font-size: 13px; font-family: inherit; outline: none; padding: 0;
}
.wf-tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent); color: #fff; border-radius: 4px;
  font-size: 11px; font-family: var(--mono); padding: 2px 8px; white-space: nowrap;
}
.wf-tag-remove {
  cursor: pointer; font-size: 14px; line-height: 1; opacity: .75;
  background: none; border: none; color: inherit; padding: 0;
}
.wf-tag-remove:hover { opacity: 1; }
.field-row        { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.field-row.three  { grid-template-columns: 1fr 1fr 1fr; }
.field-row.single { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-family: var(--mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.field input,
.field select,
.field textarea {
  background: var(--bg); border: 1px solid var(--border2); color: var(--text);
  border-radius: var(--radius); padding: 7px 10px;
  font-family: var(--mono); font-size: 12px; outline: none;
  transition: border-color .15s; width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--accent2); }
.field textarea { resize: vertical; min-height: 70px; }
.field select option { background: var(--surface); }
.field-hint { font-size: 10px; color: var(--muted); line-height: 1.5; }

.field.has-error input,
.field.has-error select,
.field.has-error textarea { border-color: var(--accent) !important; background: #fff5f5; animation: shake .3s ease; }
.field.has-error label { color: var(--accent); }
.field-error-msg { display: none; font-family: var(--mono); font-size: 10px; color: var(--accent); line-height: 1.5; }
.field.has-error .field-error-msg { display: flex; align-items: flex-start; gap: 4px; }
.field-error-msg::before {
  content: '!'; background: var(--accent); color: #ffffff;
  border-radius: 50%; width: 12px; height: 12px; font-size: 9px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
@keyframes shake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-4px); }
  40%  { transform: translateX(4px); }
  60%  { transform: translateX(-3px); }
  80%  { transform: translateX(3px); }
  100% { transform: translateX(0); }
}
.modal-error-banner {
  display: none; background: var(--surface); border: 1px solid var(--red);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px;
  font-size: 12px; color: var(--red); font-family: var(--mono); line-height: 1.6;
}
.modal-error-banner.show { display: block; }
.modal-error-banner strong { display: block; font-size: 10px; margin-bottom: 4px; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }

/* ── Slot card ─────────────────────────────────────────────── */
.slot-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; overflow: hidden; transition: border-color .15s; }
.slot-card:hover { border-color: var(--border2); }
.slot-card-head {
  padding: 10px 14px; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
.slot-toggle  { font-size: 10px; color: var(--muted); transition: transform .2s; }
.slot-toggle.open { transform: rotate(90deg); }
.slot-divid   { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--accent2); flex: 1; }
.slot-meta    { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.slot-body    { padding: 14px; display: none; }
.slot-body.open { display: block; }

/* ── Waterfall items ───────────────────────────────────────── */
.wf-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px;
  transition: border-color .15s, box-shadow .15s, opacity .15s;
  user-select: none;
}
.wf-item.dragging {
  opacity: .45; border-color: var(--accent2);
  box-shadow: 0 0 0 1px var(--accent2);
}
.wf-item.drag-over {
  border-color: var(--accent2);
  box-shadow: 0 -2px 0 0 var(--accent2);
}
.wf-drag-handle {
  display: flex; flex-direction: column; justify-content: center;
  gap: 3px; padding: 2px 2px 2px 0; cursor: grab; flex-shrink: 0;
  opacity: .35; transition: opacity .15s;
}
.wf-drag-handle:active { cursor: grabbing; }
.wf-item:hover .wf-drag-handle { opacity: .7; }
.wf-drag-handle span {
  display: block; width: 12px; height: 2px;
  background: var(--muted); border-radius: 1px;
}
.wf-priority { font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--accent); min-width: 20px; margin-top: 2px; }
.wf-content  { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.wf-type-badge {
  display: inline-flex; align-items: center;
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 7px; border-radius: 10px; width: fit-content;
}
.badge-gam        { background: #dbeafe; color: var(--accent2); border: 1px solid #93c5fd; }
.badge-bannerjs   { background: #1a1208; color: var(--yellow);  border: 1px solid #3a2a10; }
.badge-direct     { background: #0f2016; color: var(--green);   border: 1px solid #1a3a22; }
.badge-house      { background: #fef2f2; color: var(--red);     border: 1px solid #3a1818; }
.badge-vast       { background: rgba(14,165,165,0.12); color: #0ea5a5; border: 1px solid rgba(14,165,165,0.3); }
.badge-vidplayer  { background: rgba(225,112,85,0.12); color: #e17055; border: 1px solid rgba(225,112,85,0.3); }
.badge-adsense    { background: rgba(162,155,254,0.12); color: #a29bfe; border: 1px solid rgba(162,155,254,0.3); }
.wf-detail {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px;
}
.wf-actions { display: flex; gap: 4px; flex-shrink: 0; }
.wf-btn { background: none; border: none; cursor: pointer; font-size: 11px; padding: 2px 7px; border-radius: 3px; line-height: 1; font-family: var(--mono); transition: color .12s, background .12s; }
.wf-btn.edit   { color: var(--accent2); } .wf-btn.edit:hover   { background: #dbeafe; }
.wf-btn.remove { color: var(--muted);   } .wf-btn.remove:hover { color: var(--red); }

/* ── JSON panel ────────────────────────────────────────────── */
.json-panel { width: 340px; border-left: 1px solid var(--border); display: flex; flex-direction: column; background: var(--panel); flex-shrink: 0; }
.json-panel-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.json-panel-title { font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.json-pre  { flex: 1; overflow: auto; padding: 14px; font-family: var(--mono); font-size: 11px; line-height: 1.7; color: #adbac7; white-space: pre; }
.json-pre::-webkit-scrollbar       { width: 4px; height: 4px; }
.json-pre::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
.json-key  { color: #79c0ff; } .json-str  { color: #a5d6ff; }
.json-num  { color: #f69d50; } .json-bool { color: var(--green); } .json-null { color: var(--muted); }
.json-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(3px);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--panel); border: 1px solid var(--border2); border-radius: 10px;
  width: var(--modal-width, 820px); max-width: calc(100vw - 32px); max-height: 95vh; overflow-y: auto;
  transform: translateY(12px); transition: transform .2s;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal::-webkit-scrollbar       { width: 4px; }
.modal::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 14px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px 6px; border-radius: 4px; line-height: 1; transition: color .12s; }
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.type-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.type-option {
  padding: 10px 12px; border: 1px solid var(--border2); border-radius: var(--radius);
  cursor: pointer; text-align: center; transition: all .15s;
}
.type-option:hover    { border-color: var(--accent2); background: var(--surface); }
.type-option.selected { border-color: var(--accent2); background: #dbeafe; }
.type-option-label    { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--text); }
.type-option-desc     { font-size: 11px; color: var(--muted); margin-top: 3px; }
.field-group          { display: none; }
.field-group.active   { display: block; }

/* ── Users panel ───────────────────────────────────────────── */
.users-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(3px);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.users-overlay.open { opacity: 1; pointer-events: all; }
.users-box {
  background: var(--panel); border: 1px solid var(--border2); border-radius: 10px;
  width: 700px; max-height: 82vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
  transform: translateY(12px); transition: transform .2s;
}
.users-overlay.open .users-box { transform: translateY(0); }
.users-box-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.users-box-title { font-size: 14px; font-weight: 600; }
.users-grid-head {
  display: grid; grid-template-columns: 1fr 1.5fr 90px 80px 130px; gap: 12px;
  padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 600; flex-shrink: 0;
}
.users-scroll { flex: 1; overflow-y: auto; }
.users-scroll::-webkit-scrollbar       { width: 4px; }
.users-scroll::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
.user-row {
  display: grid; grid-template-columns: 1fr 1.5fr 90px 80px 130px;
  gap: 12px; padding: 11px 20px; border-bottom: 1px solid var(--border);
  align-items: center; font-size: 12px; transition: background .1s;
}
.user-row:hover { background: var(--surface); }
.user-name-text  { font-weight: 500; }
.user-sub  { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 2px; }
.user-email-text { font-family: var(--mono); font-size: 11px; color: var(--muted); word-break: break-all; }
.users-empty { padding: 32px; text-align: center; color: var(--muted); font-size: 12px; }
.users-footer {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; flex-shrink: 0;
}

/* ── Loading / spinner / toast / op overlay ─────────────────── */
.loading-spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border2); border-top-color: var(--accent2);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--surface); border: 1px solid var(--green); color: var(--green);
  font-family: var(--mono); font-size: 12px; padding: 10px 16px;
  border-radius: var(--radius); z-index: 999;
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none; max-width: 320px;
}
.toast.show  { opacity: 1; transform: translateY(0); }
.toast.error { border-color: var(--accent); color: var(--accent); }

.op-overlay { position: fixed; inset: 0; z-index: 400; display: none; align-items: center; justify-content: center; }
.op-overlay.show { display: flex; }
.op-pill {
  background: var(--surface); border: 1px solid var(--border2); border-radius: 20px;
  padding: 8px 16px; display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}

/* ── Reports overlay ───────────────────────────────────────── */
.rpt-range.selected { border-color: var(--accent2); color: var(--accent2); background: #dbeafe; }
.rpt-stat {
  padding: 14px 20px;
  border-right: 1px solid var(--border);
  text-align: center;
}
.rpt-stat:last-child { border-right: none; }
.rpt-stat-val { font-family: var(--mono); font-size: 18px; font-weight: 600; color: var(--text); }
.rpt-stat-lbl { font-family: var(--mono); font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: 3px; }
.rpt-grid-head {
  display: grid;
  grid-template-columns: 1.4fr 1fr 80px 1.4fr 70px 80px 60px 60px;
  gap: 12px; padding: 8px 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
  flex-shrink: 0;
}
.rpt-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 80px 1.4fr 70px 80px 60px 60px;
  gap: 12px; padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 12px; transition: background .1s; align-items: center;
}
.rpt-row:hover { background: var(--surface); }
.rpt-mono { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.rpt-badge-filled   { font-family: var(--mono); font-size: 9px; font-weight: 600; padding: 2px 7px; border-radius: 10px; background: #0f2016; color: var(--green); border: 1px solid #1a3a22; }
.rpt-badge-unfilled { font-family: var(--mono); font-size: 9px; font-weight: 600; padding: 2px 7px; border-radius: 10px; background: #fef2f2; color: var(--red);   border: 1px solid #3a1818; }

/* ── Refresh toggle in Global Settings ─────────────────────── */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }
.toggle-switch {
  position: relative; width: 38px; height: 20px; flex-shrink: 0; cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0; border-radius: 10px;
  background: var(--border2); transition: background .2s;
}
.toggle-track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--muted); transition: left .2s, background .2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--green); }
.toggle-switch input:checked + .toggle-track::after { left: 21px; background: #fff; }

/* ── Popup slot badge ──────────────────────────────────────── */
.badge-popup { background: rgba(124,92,252,0.12); color: #a78bfa; border: 1px solid rgba(124,92,252,0.3); }

/* ── Popup freq-cap checkboxes ────────────────────────────── */
.freq-cap-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 4px;
}
.freq-cap-item {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s;
}
.freq-cap-item:hover { border-color: var(--border2); }
.freq-cap-item input[type=checkbox] { accent-color: var(--accent2); width: 13px; height: 13px; cursor: pointer; }
.freq-cap-item.active { border-color: var(--accent2); background: rgba(121,192,255,.07); }

/* ── Intrusive Ad Sequencing list (v2.3.19) ─────────────────────────── */
.intrusive-seq-list { margin-top: 8px; }
.intrusive-seq-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 6px;
  transition: border-color .15s, box-shadow .15s, opacity .15s;
  user-select: none;
}
.intrusive-seq-item.dragging { opacity: .45; border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2); }
.intrusive-seq-item.drag-over { border-color: var(--accent2); box-shadow: 0 -2px 0 0 var(--accent2); }
.intrusive-seq-item:hover .wf-drag-handle { opacity: .7; }

/* ── Sync status indicator (§2.4) ─────────────────────────────── */
.sync-status{position:relative;display:flex;align-items:center;gap:6px;cursor:pointer;
  font-size:12px;color:var(--muted);margin-right:14px;user-select:none}
.sync-dot{width:8px;height:8px;border-radius:50%;background:var(--muted);transition:background .2s}
.sync-dot.green{background:var(--green)}
.sync-dot.yellow{background:var(--yellow)}
.sync-dot.red{background:var(--red)}
.sync-popover{position:absolute;top:26px;right:0;min-width:240px;background:var(--panel);
  border:1px solid var(--border);border-radius:8px;padding:12px;z-index:1000;display:none;
  box-shadow:0 8px 24px rgba(0,0,0,.4);font-size:12px;color:var(--text);cursor:default}
.sync-popover.open{display:block}
.sync-popover .row{display:flex;justify-content:space-between;gap:12px;margin-bottom:6px}
.sync-popover .k{color:var(--muted)}
.sync-popover .sync-err{color:var(--red);word-break:break-word;margin:8px 0;
  font-family:var(--mono);font-size:11px;line-height:1.4}
