/* ==========================================================================
   Binom & Keitaro Style Pro Affiliate Tracker Design System
   Color Palette: Deep Navy Slate (#0f141d, #161e2e, #1f293d, #2a374f)
   High Data Density, Pro Table Views, Visual Flow Stream Builder
   ========================================================================== */

:root {
  --bg-dark: #0d1117;
  --bg-topbar: #161b26;
  --bg-panel: #161e2e;
  --bg-panel-header: #1f293d;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --border-color: #26334a;
  --border-subtle: rgba(255, 255, 255, 0.08);

  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, 0.3);
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-cyan: #06b6d4;
  --accent-amber: #f59e0b;
  --accent-purple: #8b5cf6;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-size: 13px;
  line-height: 1.4;
  overflow-x: hidden;
}

/* ==========================================================================
   Binom Top Navigation Bar
   ========================================================================== */
.binom-topbar {
  background-color: var(--bg-topbar);
  border-bottom: 1px solid var(--border-color);
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 20px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.4);
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #fff;
}

.brand-badge {
  font-size: 10px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* Main Horizontal Tabs */
.binom-nav-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 100%;
}

.binom-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 0 14px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.binom-tab i {
  width: 15px;
  height: 15px;
}

.binom-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.03);
}

.binom-tab.active {
  color: #fff;
  background: var(--bg-panel);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.topbar-utilities {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sys-metrics {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

.sys-metric-item span {
  color: var(--accent-green);
  font-weight: 600;
}

/* Buttons & Controls */
.btn-binom {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-binom i {
  width: 14px;
  height: 14px;
}

.btn-binom-primary {
  background: var(--primary);
  color: white;
  border-color: #2563eb;
}

.btn-binom-primary:hover {
  background: #2563eb;
}

.btn-binom-success {
  background: #059669;
  color: white;
}

.btn-binom-secondary {
  background: #1e2736;
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-binom-secondary:hover {
  background: #283448;
}

/* ==========================================================================
   Main Content Container
   ========================================================================== */
.binom-body {
  padding: 16px;
  max-width: 1800px;
  margin: 0 auto;
}

/* Toolbar Control Header above Tables */
.binom-toolbar {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 6px 6px 0 0;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-pill-group {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  padding: 2px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

.pill-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}

.pill-btn.active {
  background: var(--primary);
  color: white;
}

.binom-input, .binom-select {
  background: #0f141d;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
  font-family: inherit;
}

.binom-input:focus, .binom-select:focus {
  border-color: var(--primary);
}

/* High Density Binom Data Tables */
.table-container {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 6px 6px;
  overflow-x: auto;
}

.binom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.binom-table th {
  background: var(--bg-panel-header);
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.binom-table td {
  padding: 7px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

.binom-table tbody tr:hover {
  background: var(--bg-hover);
}

.binom-table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.15);
}

/* Metric Colors */
.val-positive { color: var(--accent-green); font-weight: 600; }
.val-negative { color: var(--accent-red); font-weight: 600; }
.val-neutral { color: var(--text-muted); }
.val-highlight { color: var(--accent-cyan); font-weight: 600; }
.val-amber { color: var(--accent-amber); }

.code-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.status-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-active { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); border: 1px solid rgba(16, 185, 129, 0.3); }
.status-paused { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); border: 1px solid rgba(245, 158, 11, 0.3); }

/* ==========================================================================
   Binom Real-Time KPI Cards (CLH, LLH, PLH)
   ========================================================================== */
.binom-kpi-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.binom-kpi-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.kpi-num {
  font-size: 20px;
  font-weight: 700;
  margin-top: 2px;
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-dim);
}

/* ==========================================================================
   Binom Campaign / Flow Streams Builder
   ========================================================================== */
.streams-builder {
  background: #0f141d;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 16px;
  margin-top: 14px;
}

.stream-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 12px;
}

.stream-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.stream-title {
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stream-rules-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px dashed var(--border-color);
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 10px;
  font-size: 11px;
}

.rule-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent-purple);
  border: 1px solid rgba(139, 92, 246, 0.3);
  padding: 2px 6px;
  border-radius: 3px;
  margin-right: 6px;
}

.path-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.02);
  padding: 8px 12px;
  border-radius: 4px;
  margin-top: 6px;
}

.weight-input {
  width: 60px;
  text-align: center;
}

/* Modals */
.binom-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.binom-modal-overlay.open {
  display: flex;
}

.binom-modal {
  background: var(--bg-topbar);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 100%;
  max-width: 640px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  max-height: 90vh;
  overflow-y: auto;
}

.binom-modal-header {
  padding: 14px 18px;
  background: var(--bg-panel-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.binom-modal-header h3 {
  font-size: 14px;
  font-weight: 700;
}

.modal-close {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted, #94a3b8);
  font-size: 18px;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  padding: 0;
  outline: none;
}

.modal-close:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
  transform: scale(1.08);
}

.binom-modal-body {
  padding: 18px;
}

.binom-modal-footer {
  padding: 12px 18px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row-group {
  margin-bottom: 12px;
}

.form-row-group label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.tab-page { display: none; }
.tab-page.active { display: block; }
