/* ─── RESET & BASE ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #080814;
  --bg-card:      #0F0F23;
  --bg-input:     #16163A;
  --border:       rgba(120, 100, 255, 0.18);
  --border-hover: rgba(120, 100, 255, 0.4);
  --purple:       #7C5CFC;
  --purple-dim:   rgba(124, 92, 252, 0.15);
  --cyan:         #00D4FF;
  --green:        #22C55E;
  --yellow:       #EAB308;
  --red:          #EF4444;
  --text:         #E8E8F0;
  --text-dim:     #8888AA;
  --font:         'Outfit', -apple-system, sans-serif;
}

body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; height: 100vh; overflow: hidden; }
.hidden { display: none !important; }
.screen { width: 100vw; height: 100vh; }

/* ─── LOGIN ──────────────────────────────────────────────────────────────────── */
#loginScreen { display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 30% 50%, rgba(124,92,252,0.08) 0%, transparent 60%); }
.login-box { width: 380px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 32px; }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-title { font-size: 18px; font-weight: 700; }
.login-sub   { font-size: 12px; color: var(--text-dim); }

/* ─── LAYOUT ─────────────────────────────────────────────────────────────────── */
#appScreen { display: flex; overflow: hidden; }

.sidebar { width: 220px; flex-shrink: 0; background: var(--bg-card); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 20px 0; height: 100vh; }
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 0 20px 24px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.sidebar-brand { font-size: 14px; font-weight: 700; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.sidebar-footer { padding: 16px 20px 0; border-top: 1px solid var(--border); }

.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--text-dim); font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s; text-decoration: none; }
.nav-item:hover { background: var(--purple-dim); color: var(--text); }
.nav-item.active { background: var(--purple-dim); color: var(--text); border-left: 2px solid var(--purple); }
.nav-icon { font-size: 15px; }

.main { flex: 1; overflow-y: auto; padding: 32px; height: 100vh; }
.page-header { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.page-header h1 { font-size: 22px; font-weight: 700; flex: 1; }

/* ─── STATS ──────────────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.stat-card.green  { border-color: rgba(34,197,94,0.3); }
.stat-card.yellow { border-color: rgba(234,179,8,0.3); }
.stat-card.gray   { border-color: rgba(100,100,120,0.3); }
.stat-label { font-size: 12px; color: var(--text-dim); font-weight: 500; margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 700; }

/* ─── TABLE ──────────────────────────────────────────────────────────────────── */
.section-title { font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }
.broker-table-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.broker-table { width: 100%; border-collapse: collapse; }
.broker-table th { text-align: left; padding: 12px 16px; font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,0.02); }
.broker-table td { padding: 11px 16px; border-bottom: 1px solid rgba(120,100,255,0.08); font-size: 13px; vertical-align: middle; }
.broker-table tr:last-child td { border-bottom: none; }
.broker-table tr:hover td { background: rgba(124,92,252,0.04); }
.loading-row { text-align: center; color: var(--text-dim); padding: 24px !important; }

/* ─── BADGES ─────────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-live    { background: rgba(34,197,94,0.15);  color: #22C55E; }
.badge-sandbox { background: rgba(234,179,8,0.15);  color: #EAB308; }
.badge-off     { background: rgba(100,100,120,0.15); color: #8888AA; }
.channel-pill { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 500; margin-right: 3px; }
.channel-on  { background: rgba(124,92,252,0.2); color: var(--purple); }
.channel-off { background: rgba(100,100,120,0.1); color: #555566; }

/* ─── CHECKLIST ──────────────────────────────────────────────────────────────── */
.checklist-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.checklist-title { font-size: 13px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 14px; }
.checklist-items { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.checklist-item { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.checklist-item.done    { background: rgba(34,197,94,0.12);  color: #22C55E; border: 1px solid rgba(34,197,94,0.2); }
.checklist-item.pending { background: rgba(234,179,8,0.1);   color: #EAB308; border: 1px solid rgba(234,179,8,0.2); }
.checklist-actions { display: flex; gap: 10px; }

/* ─── DETAIL PAGE ────────────────────────────────────────────────────────────── */
.btn-back { background: none; border: none; color: var(--text-dim); font-size: 13px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.btn-back:hover { color: var(--text); background: var(--purple-dim); }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.detail-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.detail-section-title { font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 16px; }
.field-row { margin-bottom: 12px; }
.field-row label { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 4px; font-weight: 500; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(120,100,255,0.08); }
.toggle-row:last-of-type { border-bottom: none; }
.toggle-label { font-size: 13px; font-weight: 500; }
.toggle-sub   { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.status-display { margin-top: 16px; padding: 10px 12px; background: rgba(255,255,255,0.03); border-radius: 8px; font-size: 13px; font-weight: 600; text-align: center; }
.detail-actions { display: flex; align-items: center; gap: 16px; }
.save-msg { font-size: 13px; color: var(--green); }

/* ─── ONBOARD ────────────────────────────────────────────────────────────────── */
.onboard-form { max-width: 800px; }
.form-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 24px; margin-bottom: 16px; }
.form-section-title { font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 20px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.form-row:last-child { margin-bottom: 0; }
.field-hint { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.onboard-actions { display: flex; align-items: center; gap: 16px; margin-top: 8px; }
.onboard-error { font-size: 13px; color: var(--red); }

/* ─── PROGRESS ───────────────────────────────────────────────────────────────── */
.progress-overlay { position: fixed; inset: 0; background: rgba(8,8,20,0.85); display: flex; align-items: center; justify-content: center; z-index: 100; }
.progress-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 32px; width: 460px; }
.progress-title { font-size: 16px; font-weight: 600; margin-bottom: 20px; }
.progress-steps { display: flex; flex-direction: column; gap: 10px; }
.progress-step { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-dim); }
.progress-step.done   { color: var(--green); }
.progress-step.failed { color: var(--red); }
.progress-step.warning { color: var(--yellow); }
.step-icon { font-size: 16px; width: 20px; }

/* ─── KB MANAGER ─────────────────────────────────────────────────────────────── */
.kb-list { width: 260px; flex-shrink: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; overflow-y: auto; padding: 8px; }
.kb-item { padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 12px; color: var(--text-dim); transition: all 0.15s; margin-bottom: 2px; }
.kb-item:hover { background: var(--purple-dim); color: var(--text); }
.kb-item.active { background: var(--purple-dim); color: var(--text); border-left: 2px solid var(--purple); }
.kb-item-id { font-weight: 600; font-size: 11px; }
.kb-item-name { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.kb-editor { flex: 1; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; }
.kb-placeholder { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-dim); font-size: 14px; }
.kb-editor-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.kb-editor-title { font-size: 14px; font-weight: 600; }
.kb-editor-body { flex: 1; overflow: hidden; }
.kb-textarea { width: 100%; height: 100%; background: transparent; border: none; color: var(--text); font-size: 12px; font-family: 'Courier New', monospace; padding: 16px 20px; resize: none; outline: none; line-height: 1.6; }

/* ─── FORMS ──────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; }
.form-group label { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
select {
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
select:focus { border-color: var(--purple); }

input[type="text"], input[type="email"], input[type="password"] { background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 13px; font-family: var(--font); padding: 9px 12px; outline: none; transition: border-color 0.2s; width: 100%; }
input:focus { border-color: var(--purple); }
input[readonly] { opacity: 0.6; cursor: default; }
input::placeholder { color: var(--text-dim); }

/* ─── TOGGLE ─────────────────────────────────────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #2a2a4a; border-radius: 24px; cursor: pointer; transition: 0.2s; }
.slider::before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.2s; }
.toggle input:checked + .slider { background: var(--purple); }
.toggle input:checked + .slider::before { transform: translateX(20px); }

/* Mini toggle for table */
.mini-toggle { position: relative; display: inline-block; width: 36px; height: 20px; }
.mini-toggle input { opacity: 0; width: 0; height: 0; }
.mini-slider { position: absolute; inset: 0; background: #2a2a4a; border-radius: 20px; cursor: pointer; transition: 0.2s; }
.mini-slider::before { content: ''; position: absolute; height: 14px; width: 14px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.2s; }
.mini-toggle input:checked + .mini-slider { background: var(--purple); }
.mini-toggle input:checked + .mini-slider::before { transform: translateX(16px); }

/* ─── BUTTONS ────────────────────────────────────────────────────────────────── */
.btn { padding: 10px 20px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; font-family: var(--font); cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.btn-primary { background: linear-gradient(135deg, var(--purple), #5B3FD4); color: white; box-shadow: 0 4px 12px rgba(124,92,252,0.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(124,92,252,0.4); }
.btn-secondary { background: var(--bg-input); color: var(--text-dim); border: 1px solid var(--border); }
.btn-secondary:hover { color: var(--text); border-color: var(--border-hover); }
.btn-success { background: linear-gradient(135deg, #16a34a, #15803d); color: white; }
.btn-danger  { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.btn-sm  { padding: 7px 14px; font-size: 12px; }
.btn-lg  { padding: 12px 28px; font-size: 15px; }
.btn-ghost-sm { background: none; border: 1px solid var(--border); color: var(--text-dim); font-size: 12px; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-family: var(--font); width: 100%; transition: all 0.15s; }
.btn-ghost-sm:hover { color: var(--text); border-color: var(--border-hover); }
.copy-btn { background: none; border: 1px solid var(--border); color: var(--text-dim); border-radius: 4px; padding: 2px 6px; font-size: 12px; cursor: pointer; transition: all 0.15s; font-family: var(--font); }
.copy-btn:hover { color: var(--purple); border-color: var(--purple); }
.table-link { color: var(--purple); cursor: pointer; font-size: 12px; text-decoration: none; background: none; border: none; font-family: var(--font); padding: 0; }
.table-link:hover { text-decoration: underline; }
.error-msg { margin-top: 10px; font-size: 12px; color: var(--red); display: none; }

/* ─── LOGO ───────────────────────────────────────────────────────────────────── */
.logo-img { width: 40px; height: 40px; object-fit: contain; flex-shrink: 0; }

/* ─── SCROLLBAR ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(124,92,252,0.3); border-radius: 2px; }