/* ═══════════════════════════════════════
   CREWAI RAG + ADSENSE DASHBOARD
   Premium Dark UI — style.css
   ═══════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── TOKENS ─── */
:root {
  --bg-base:       #070a13;
  --bg-surface:    #0d1117;
  --bg-card:       #111827;
  --bg-card-hover: #161f2e;
  --bg-input:      #0d1117;
  --border:        rgba(255,255,255,0.07);
  --border-active: rgba(0,212,255,0.4);

  --text-primary:  #f0f6ff;
  --text-secondary:#8b98b3;
  --text-muted:    #4a5568;

  --cyan:    #00d4ff;
  --purple:  #8b5cf6;
  --green:   #10b981;
  --amber:   #f59e0b;
  --red:     #ef4444;

  --sidebar-w: 240px;
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;

  --shadow-card: 0 4px 24px rgba(0,0,0,0.4);
  --glow-cyan:   0 0 20px rgba(0,212,255,0.15);

  --transition: 0.2s ease;
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.6;
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ═══════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  padding: 1.25rem 0;
  transition: var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.logo-icon {
  width: 36px; height: 36px;
  background: rgba(0,212,255,0.08);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.02em;
}
.logo-accent { color: var(--cyan); }

/* NAV */
.sidebar-nav { flex: 1; padding: 0 .75rem; }
.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-muted);
  padding: 0 .5rem .5rem;
  margin-top: .25rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: .85rem;
  transition: var(--transition);
  margin-bottom: .15rem;
  position: relative;
}
.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}
.nav-item.active {
  background: rgba(0,212,255,0.1);
  color: var(--cyan);
  border: 1px solid rgba(0,212,255,0.15);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--cyan);
  border-radius: 0 2px 2px 0;
}
.nav-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 1rem 1.25rem 0;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.status-badge {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .75rem;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 6px currentColor;
  flex-shrink: 0;
  transition: var(--transition);
}
.status-dot.connected { background: var(--green); }

/* ═══════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 1.5rem;
  gap: 0;
}

/* ─── TOPBAR ─── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: .75rem;
}
.topbar-left { flex: 1; min-width: 0; }
.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.03em;
}
.page-subtitle {
  font-size: .8rem;
  color: var(--text-secondary);
  display: block;
  margin-top: .2rem;
}
.topbar-right {
  display: flex;
  gap: .5rem;
  align-items: center;
}

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  outline: none;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  color: white;
  box-shadow: 0 2px 12px rgba(99,102,241,0.3);
}
.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(99,102,241,0.5);
  transform: translateY(-1px);
}
.btn-ghost {
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.09);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.15);
}
.btn-sm { padding: .35rem .65rem; font-size: .75rem; }
.btn-google {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  padding: .65rem 1.25rem;
  background: white;
  color: #1a1a2e;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-family: inherit;
  font-size: .85rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.btn-google:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

/* ─── CARDS ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}
.card:hover { border-color: rgba(255,255,255,0.1); }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}
.card-wide { grid-column: 1 / -1; }

.card-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
}
.card-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.card-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ─── FORMS ─── */
.form-group { margin-bottom: .85rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.form-label {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-secondary);
  margin-bottom: .35rem;
}
.form-input, .form-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: .85rem;
  padding: .55rem .8rem;
  outline: none;
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px rgba(0,212,255,0.1);
}
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20'%3E%3Cpath fill='%238b98b3' d='M5 7l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .6rem center;
  padding-right: 2rem;
  cursor: pointer;
}
.form-textarea {
  resize: vertical;
  min-height: 72px;
  font-size: .82rem;
  line-height: 1.5;
}
.input-eye-wrap {
  position: relative;
}
.input-eye-wrap .form-input { padding-right: 2.5rem; }
.eye-btn {
  position: absolute;
  right: .6rem; top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: .5;
  transition: var(--transition);
}
.eye-btn:hover { opacity: 1; }

/* TOGGLE */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .4rem 0;
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle {
  position: relative;
  width: 36px; height: 20px;
  display: inline-block;
  cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 20px;
  transition: var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.toggle input:checked + .toggle-slider {
  background: linear-gradient(135deg, var(--cyan), var(--purple));
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

/* ─── TAB PANELS ─── */
.tab-panel { display: none; animation: fadeIn .25s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ─── CODE PREVIEW ─── */
.code-preview {
  background: #050810;
  border: 1px solid rgba(0,212,255,0.1);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: .75rem;
  color: #a8d8ff;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.6;
  max-height: 260px;
  overflow-y: auto;
}
.code-preview.small-code { font-size: .7rem; max-height: 180px; }

/* ─── SOURCES ─── */
.source-list {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin-bottom: .75rem;
}
.source-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .45rem .7rem;
  transition: var(--transition);
}
.source-item:hover { border-color: rgba(255,255,255,0.12); background: rgba(255,255,255,0.05); }
.source-type-badge {
  font-size: .65rem;
  font-weight: 700;
  padding: .15rem .5rem;
  border-radius: 4px;
  flex-shrink: 0;
  letter-spacing: .05em;
}
.badge-pdf { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.badge-web { background: rgba(59,130,246,0.15); color: #60a5fa; border: 1px solid rgba(59,130,246,0.2); }
.badge-csv { background: rgba(16,185,129,0.15); color: #34d399; border: 1px solid rgba(16,185,129,0.2); }
.badge-txt { background: rgba(245,158,11,0.15); color: #fcd34d; border: 1px solid rgba(245,158,11,0.2); }
.source-path {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: .72rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.remove-source {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .8rem;
  padding: .2rem .3rem;
  border-radius: 4px;
  transition: var(--transition);
  flex-shrink: 0;
}
.remove-source:hover { color: var(--red); background: rgba(239,68,68,0.1); }
.add-source-row { display: flex; gap: .5rem; align-items: center; }

/* ═══════════════════════════════════════
   CONSOLE TAB
   ═══════════════════════════════════════ */
.console-container {
  background: #050810;
  border: 1px solid rgba(0,212,255,0.15);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0,212,255,0.05);
}
.console-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
  flex-wrap: wrap;
  gap: .5rem;
}
.console-filters { display: flex; gap: .3rem; }
.filter-btn {
  padding: .25rem .6rem;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .05em;
  cursor: pointer;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
  transition: var(--transition);
  font-family: inherit;
}
.filter-btn:hover, .filter-btn.active {
  background: rgba(0,212,255,0.1);
  color: var(--cyan);
  border-color: rgba(0,212,255,0.2);
}
.console-count { font-size: .7rem; color: var(--text-muted); }
.console-output {
  flex: 1;
  overflow-y: auto;
  padding: .75rem 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: .75rem;
  line-height: 1.7;
}
.log-line {
  display: flex;
  gap: .75rem;
  padding: .15rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.025);
  animation: slideIn .15s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
.log-ts { color: var(--text-muted); flex-shrink: 0; font-size: .68rem; margin-top: .05rem; }
.log-tag {
  font-size: .65rem;
  font-weight: 700;
  padding: .05rem .4rem;
  border-radius: 3px;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: .1rem;
  letter-spacing: .04em;
}
.tag-info    { background: rgba(59,130,246,0.15); color: #60a5fa; }
.tag-success { background: rgba(16,185,129,0.15); color: #34d399; }
.tag-warn    { background: rgba(245,158,11,0.15); color: #fcd34d; }
.tag-error   { background: rgba(239,68,68,0.15);  color: #f87171; }
.log-msg { color: var(--text-secondary); flex: 1; }
.log-msg.msg-success { color: #34d399; }
.log-msg.msg-warn    { color: #fcd34d; }
.log-msg.msg-error   { color: #f87171; }

.console-input-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
}
.console-prompt { color: var(--cyan); font-family: 'JetBrains Mono', monospace; font-weight: 700; flex-shrink: 0; }
.console-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: .82rem;
  caret-color: var(--cyan);
}

/* ═══════════════════════════════════════
   ADSENSE BIND TAB
   ═══════════════════════════════════════ */

/* Gmail account bar */
.gmail-account-bar {
  display: flex;
  align-items: center;
  gap: .9rem;
  background: var(--bg-card);
  border: 1px solid rgba(0,212,255,0.15);
  border-radius: var(--radius-lg);
  padding: .85rem 1.2rem;
  margin-bottom: 1rem;
  box-shadow: 0 0 24px rgba(0,212,255,0.06);
}
.gmail-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285F4, #34A853);
  color: white;
  font-size: .95rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(66,133,244,0.4);
}
.gmail-info { flex-shrink: 0; }
.gmail-name  { font-size: .82rem; font-weight: 700; color: var(--text-primary); }
.gmail-email { font-size: .72rem; color: var(--text-secondary); font-family: 'JetBrains Mono', monospace; }
.gmail-badge {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: rgba(52,168,83,0.12);
  color: #34d399;
  border: 1px solid rgba(52,168,83,0.2);
  padding: .25rem .65rem;
  border-radius: 20px;
}

/* Publisher tabs */
.pub-tabs {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.pub-tab {
  display: flex;
  flex-direction: column;
  padding: .6rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  text-align: left;
}
.pub-tab:hover { border-color: rgba(0,212,255,0.25); background: var(--bg-card-hover); }
.pub-tab.active {
  border-color: rgba(0,212,255,0.4);
  background: rgba(0,212,255,0.07);
  box-shadow: 0 0 16px rgba(0,212,255,0.08);
}
.pub-tab-id   { font-family: 'JetBrains Mono', monospace; font-size: .72rem; color: var(--cyan); font-weight: 600; }
.pub-tab-label{ font-size: .65rem; color: var(--text-muted); margin-top: .15rem; }
.pub-tab-add  {
  flex-direction: row;
  align-items: center;
  gap: .5rem;
  color: var(--text-muted);
  border-style: dashed;
  font-size: .78rem;
  font-weight: 500;
}
.pub-tab-add:hover { color: var(--cyan); border-color: rgba(0,212,255,0.3); }

/* Per-account status dot */
.pub-status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  flex-shrink: 0;
  transition: var(--transition);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.05);
}
.pub-status-dot.connected {
  background: var(--green);
  box-shadow: 0 0 8px rgba(16,185,129,0.5);
  animation: dotPulse 2s ease infinite;
}
@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(16,185,129,0.4); }
  50%       { box-shadow: 0 0 14px rgba(16,185,129,0.8); }
}

.bind-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.25rem;
}
@media (max-width: 900px) { .bind-layout { grid-template-columns: 1fr; } }
.bind-form-card { }
.bind-status-card { }


.oauth-flow { display: flex; flex-direction: column; gap: 1rem; }
.oauth-step {
  display: flex;
  gap: .9rem;
  padding: .9rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  transition: var(--transition);
  opacity: .6;
}
.oauth-step.active { opacity: 1; border-color: rgba(0,212,255,0.2); background: rgba(0,212,255,0.03); }
.step-number {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(0,212,255,0.1);
  border: 1px solid rgba(0,212,255,0.25);
  color: var(--cyan);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: .1rem;
}
.step-content { flex: 1; }
.step-title { font-weight: 600; font-size: .85rem; margin-bottom: .1rem; }

.scope-list { display: flex; flex-direction: column; gap: .5rem; margin-top: .5rem; }
.scope-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .8rem;
  cursor: pointer;
  padding: .4rem .5rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.scope-item:hover { background: rgba(255,255,255,0.04); }
.scope-item input { accent-color: var(--cyan); width: 14px; height: 14px; cursor: pointer; }
.scope-item span:nth-child(2) { flex: 1; font-family: 'JetBrains Mono', monospace; font-size: .7rem; color: var(--text-secondary); }
.scope-desc { font-size: .7rem; color: var(--text-muted); }

.account-info { min-height: 120px; }
.account-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: .8rem;
  text-align: center;
  line-height: 1.5;
}
.account-connected {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.account-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .8rem;
  padding: .35rem 0;
  border-bottom: 1px solid var(--border);
}
.account-row:last-child { border-bottom: none; }
.account-row-key { color: var(--text-muted); }
.account-row-val { color: var(--text-primary); font-weight: 500; }
.account-row-val.green { color: var(--green); }

/* ═══════════════════════════════════════
   LEDGER TAB
   ═══════════════════════════════════════ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  opacity: .5;
}
.stat-card:hover { border-color: rgba(255,255,255,0.12); transform: translateY(-2px); }
.stat-label { font-size: .7rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .4rem; }
.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.03em;
}
.stat-value.green { color: var(--green); }
.stat-delta { font-size: .7rem; margin-top: .25rem; font-weight: 500; }
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }

.table-wrap { overflow-x: auto; margin: 0 -1.25rem; padding: 0 1.25rem; }
.ledger-table { width: 100%; border-collapse: collapse; }
.ledger-table th {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: .55rem .75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.ledger-table td {
  padding: .65rem .75rem;
  font-size: .8rem;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.03);
  white-space: nowrap;
}
.ledger-table tr:hover td { background: rgba(255,255,255,0.025); }
.text-right { text-align: right; }
.ledger-table td.earn { color: var(--green); font-weight: 600; text-align: right; }

.ledger-status {
  display: inline-block;
  font-size: .65rem;
  font-weight: 700;
  padding: .15rem .5rem;
  border-radius: 4px;
  letter-spacing: .04em;
}
.status-finalized  { background: rgba(16,185,129,0.12); color: #34d399; border: 1px solid rgba(16,185,129,0.2); }
.status-estimated  { background: rgba(245,158,11,0.12); color: #fcd34d; border: 1px solid rgba(245,158,11,0.2); }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 0 0;
  font-size: .75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: .5rem;
}
.pagination { display: flex; gap: .3rem; }
.page-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: .75rem;
  transition: var(--transition);
  font-family: inherit;
}
.page-btn:hover { border-color: rgba(0,212,255,0.3); color: var(--cyan); }
.page-btn.active { background: rgba(0,212,255,0.1); border-color: rgba(0,212,255,0.3); color: var(--cyan); }

/* ─── AGENT CARDS ─── */
.agent-avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.agent-role-tag {
  font-size: .65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  display: block;
}

/* ─── TOAST ─── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1.1rem;
  font-size: .82rem;
  color: var(--text-primary);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 9999;
  transform: translateY(calc(100% + 2rem));
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: .6rem;
  pointer-events: none;
}
.toast.show { transform: translateY(0); }
.toast.toast-success { border-left: 3px solid var(--green); }
.toast.toast-error   { border-left: 3px solid var(--red); }
.toast.toast-info    { border-left: 3px solid var(--cyan); }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .logo-text, .nav-group-label, .nav-item span { display: none; }
  .nav-item { justify-content: center; padding: .6rem; }
  .nav-icon { width: 20px; height: 20px; }
  .main-content { margin-left: 60px; padding: 1rem; }
}

/* ═══════════════════════════════════════
   PIPELINE FLOW BANNER
   ═══════════════════════════════════════ */
.pipeline-flow-banner {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  flex-wrap: nowrap;
}
.pf-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  min-width: 96px;
  opacity: .38;
  transition: var(--transition);
  cursor: default;
}
.pf-step.active { opacity: 1; }
.pf-step:hover  { opacity: .85; }
.pf-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 18px rgba(0,0,0,0.4);
  position: relative;
  transition: var(--transition);
}
.pf-step.active .pf-icon {
  box-shadow: 0 6px 24px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.08);
  transform: scale(1.06);
}
/* pulse ring on active step */
.pf-step.active .pf-icon::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 16px;
  border: 1.5px solid rgba(255,255,255,0.15);
  animation: pfPulse 2s ease infinite;
}
@keyframes pfPulse {
  0%, 100% { opacity: .5; transform: scale(1); }
  50%       { opacity: 1;  transform: scale(1.05); }
}
.pf-label    { font-size: .78rem; font-weight: 700; color: var(--text-primary); }
.pf-sublabel { font-size: .65rem; color: var(--text-muted); text-align: center; }

.pf-arrow {
  font-size: 1.3rem;
  color: var(--text-muted);
  padding: 0 .5rem;
  flex-shrink: 0;
  margin-bottom: 1.5rem;
  opacity: .4;
}

/* ═══════════════════════════════════════
   SETTINGS TAB
   ═══════════════════════════════════════ */
.settings-section-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  margin: 1.1rem 0 .6rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
}

/* History stats */
.history-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
  margin-bottom: 1rem;
}
@media (max-width: 700px) { .history-stats-row { grid-template-columns: repeat(2, 1fr); } }

.history-stat {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem .9rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.history-stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  opacity: .4;
}
.history-stat-val {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: -.03em;
}
.history-stat-label {
  font-size: .68rem;
  color: var(--text-muted);
  margin-top: .2rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* Checkbox group */
.checkbox-group {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: .3rem;
}

/* Danger Zone */
.danger-zone {
  margin-top: 1.25rem;
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius);
  background: rgba(239,68,68,0.04);
  padding: 1rem;
}
.danger-zone-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #ef4444;
  margin-bottom: .85rem;
}
.danger-actions { display: flex; flex-direction: column; gap: .65rem; }
.danger-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem .9rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(239,68,68,0.12);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.danger-item:hover { background: rgba(239,68,68,0.06); border-color: rgba(239,68,68,0.25); }
.danger-item-title { font-size: .82rem; font-weight: 600; color: var(--text-primary); }
.danger-item-desc  { font-size: .73rem; color: var(--text-muted); margin-top: .15rem; }

.btn-danger {
  background: rgba(239,68,68,0.12);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.25);
  padding: .4rem .9rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-danger:hover {
  background: rgba(239,68,68,0.22);
  border-color: rgba(239,68,68,0.45);
  color: #fca5a5;
  transform: translateY(-1px);
}

/* ═══════════════════════════════════════
   CONFIRMATION MODAL
   ═══════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--bg-card);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 420px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.7);
  transform: scale(.94);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-icon {
  width: 60px; height: 60px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.modal-title { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.modal-body  { font-size: .83rem; color: var(--text-secondary); line-height: 1.6; }
.modal-actions { display: flex; gap: .75rem; margin-top: .5rem; }

/* ═══════════════════════════════════════
   CHAT WINDOW (CrewAI)
   ═══════════════════════════════════════ */
.chat-window {
  display: flex;
  flex-direction: column;
  gap: .8rem;
  padding: 1.5rem;
  background: rgba(0,0,0,0.15);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: var(--radius);
  min-height: 250px;
  max-height: 400px;
  overflow-y: auto;
  margin-top: 1rem;
}
.chat-msg { display: flex; flex-direction: column; max-width: 80%; }
.chat-msg.system { align-self: center; text-align: center; max-width: 90%; }
.chat-msg.system .chat-bubble { background: transparent; border: 1px dashed rgba(255,255,255,0.2); color: var(--text-muted); font-size: .75rem; font-family: monospace; }
.chat-msg.user { align-self: flex-end; }
.chat-msg.user .chat-bubble { background: var(--cyan); color: #000; border-bottom-right-radius: 4px; }
.chat-msg.bot { align-self: flex-start; }
.chat-msg.bot .chat-bubble { background: var(--bg-card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-bubble {
  padding: .75rem 1rem;
  border-radius: 12px;
  font-size: .85rem;
  line-height: 1.4;
  word-wrap: break-word;
}
.chat-input-row {
  display: flex;
  gap: .75rem;
  margin-top: 1rem;
}
.chat-input { flex: 1; }
