/* ═══════════════════════════════════════════════════════════════
   OAKWRIGHT TRADES — OUTREACH CONSOLE
   Earth tone dark theme · IBM Plex Sans · Amber-accented (Oakwright Trades)
   ═══════════════════════════════════════════════════════════════ */

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

/* ── TOKENS ───────────────────────────────────────────────────── */
:root {
  --bg:            #08100a;
  --surface:       #0d1510;
  --card:          #111a13;
  --card-hover:    #151f16;
  --border:        #1c2b1e;
  --border-mid:    #243528;
  --border-light:  #2d4432;

  --green:         #52b788;
  --green-bright:  #74c69d;
  --green-dim:     #2a5c3f;
  --green-bg:      #0d2318;
  --green-border:  #1a4530;

  --amber:         #d4a55a;
  --amber-bg:      #1c1408;
  --amber-border:  #3a2c10;

  --red:           #c96060;
  --red-bg:        #1c0e0e;
  --red-border:    #3d1818;

  --blue:          #74a7c7;
  --blue-bg:       #0e1a22;
  --blue-border:   #1a3040;

  --sage:          #8aaf8c;

  --text:          #d0e0d0;
  --text-dim:      #5e7d62;
  --text-faint:    #2e4232;

  --font:          'IBM Plex Sans', system-ui, sans-serif;
  --mono:          'IBM Plex Mono', 'Consolas', monospace;

  --radius:        6px;
  --radius-sm:     4px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 400;
  display: flex;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── SIDEBAR ──────────────────────────────────────────────────── */
#sidebar {
  width: 210px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

#sidebar .brand {
  padding: 22px 18px 16px;
  border-bottom: 1px solid var(--border);
}

#sidebar .brand .co {
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--green-dim);
  margin-bottom: 5px;
  font-weight: 500;
}

#sidebar .brand .title {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0.2px;
}

#sidebar nav { padding: 14px 0; flex: 1; }

#sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 12px;
  font-weight: 400;
  transition: all 0.15s;
  border-left: 2px solid transparent;
  letter-spacing: 0.2px;
}

#sidebar nav a:hover {
  color: var(--text);
  background: var(--card);
  border-left-color: var(--border-light);
}

#sidebar nav a.active {
  color: var(--green-bright);
  background: var(--green-bg);
  border-left-color: var(--green);
}

#sidebar nav a .icon {
  width: 16px;
  text-align: center;
  font-size: 13px;
  flex-shrink: 0;
}

#sidebar .sandbox-badge {
  margin: 0 14px 16px;
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 9px;
  color: var(--amber);
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  font-weight: 500;
}

/* ── MAIN AREA ────────────────────────────────────────────────── */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#topbar {
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  flex-shrink: 0;
}

#topbar .page-title {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0.3px;
}

#topbar .actions { display: flex; gap: 8px; align-items: center; }
#content { flex: 1; overflow-y: auto; padding: 22px; }

/* ── DROPDOWN ─────────────────────────────────────────────────── */
.dropdown-wrap {
  position: relative;
}
.dropdown-trigger .caret {
  font-size: 10px;
  opacity: 0.6;
  margin-left: 4px;
}
.dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 200;
  background: var(--surface-2, #1e1c1a);
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  padding: 12px 14px;
  min-width: 240px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.dropdown-panel.open { display: block; }
.dropdown-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.dropdown-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.dropdown-input {
  width: 64px;
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  padding: 5px 8px;
  font-family: var(--font-mono, monospace);
  text-align: center;
}
.dropdown-input:focus {
  outline: none;
  border-color: var(--green-border);
}
.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 0;
}
.dropdown-full { width: 100%; justify-content: center; }

.search-input {
  display: block;
  width: 100%;
  max-width: 820px;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 12px;
  font-family: var(--font-mono, monospace);
  margin: 6px 0 12px;
  outline: none;
}
.search-input:focus { border-color: var(--green-border); }
.search-input::placeholder { color: #4a7a54; }

/* ── STATS BAR ────────────────────────────────────────────────── */
#stats-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.15s;
}

.stat-card:hover { border-color: var(--border-mid); }

.stat-card .val {
  font-size: 28px;
  font-weight: 300;
  color: var(--text);
  margin-bottom: 5px;
  font-family: var(--mono);
  letter-spacing: -0.5px;
}

.stat-card .lbl {
  font-size: 9px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 500;
}

/* ── PIPELINE BOARD ───────────────────────────────────────────── */
#pipeline-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.stage-col {
  min-width: 220px;
  max-width: 220px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: 600px;
}

.stage-col .stage-header {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.stage-col .stage-header .sname {
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 500;
}

.stage-col .stage-header .scount {
  font-size: 11px;
  color: var(--text-faint);
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 10px;
  font-family: var(--mono);
}

.stage-col .leads-list { overflow-y: auto; flex: 1; }

.lead-card {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.lead-card:hover { background: var(--card-hover); }

.lead-card .biz {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.lead-card .meta { font-size: 11px; color: var(--text-dim); }
.lead-card .score { font-size: 10px; color: var(--green); float: right; font-family: var(--mono); }
.overdue { color: var(--red) !important; }
.due-today { color: var(--amber) !important; }

/* ── REVIEW QUEUE ─────────────────────────────────────────────── */
.review-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
  overflow: hidden;
}

.review-item .ri-header {
  padding: 13px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.review-item .ri-header .biz { font-size: 13px; color: var(--text); font-weight: 500; }

.review-item .ri-header .touch-badge {
  font-size: 9px;
  letter-spacing: 1.5px;
  background: var(--green-bg);
  color: var(--green);
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid var(--green-border);
  font-weight: 500;
}

.review-item .ri-body { padding: 18px; }

.review-item .subject input {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  width: 100%;
  font-size: 13px;
  outline: none;
  font-family: var(--font);
  margin-bottom: 12px;
  transition: border-color 0.15s;
}

.review-item .subject input:focus { border-color: var(--green-dim); }

.review-item .body textarea {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px;
  width: 100%;
  font-size: 13px;
  min-height: 200px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  font-family: var(--font);
  transition: border-color 0.15s;
}

.review-item .body textarea:focus { border-color: var(--green-dim); }

.review-item .ri-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── ACTIVITY FEED ────────────────────────────────────────────── */
#activity-feed {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 100%;
  overflow-y: auto;
  padding: 14px;
  font-family: var(--mono);
}

.activity-line {
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}

.activity-line .ts {
  color: var(--text-faint);
  font-size: 10px;
  margin-right: 8px;
}

.activity-line .agent {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 3px;
  margin-right: 7px;
  font-weight: 500;
}

.agent-orchestrator       { background: #0e1a22; color: #74a7c7; }
.agent-lead_discovery     { background: #0e2318; color: #52b788; }
.agent-contact_finder     { background: #1c1408; color: #c8a46a; }
.agent-email_writer       { background: #1a1028; color: #a07cc8; }
.agent-conversation_manager { background: #1c0e0e; color: #c87070; }
.agent-review_queue       { background: #0e1e22; color: #5bbfcc; }
.agent-handoff            { background: #1c1408; color: #d4a55a; }
.agent-knowledge          { background: #0e2318; color: var(--sage); }
.agent-peptide_expert     { background: #0e1a22; color: #74a7c7; }

.activity-line .msg { font-size: 12px; color: var(--text-dim); }
.event-error .msg   { color: var(--red); }
.event-send .msg    { color: var(--green); }
.event-handoff .msg { color: var(--amber); }
.event-review .msg  { color: var(--blue); }

/* ── BUTTONS ──────────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 15px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.3px;
  font-family: var(--font);
  font-weight: 500;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary   { background: var(--green-dim); color: var(--green-bright); border: 1px solid var(--green-border); }
.btn-primary:hover:not(:disabled) { background: #32724e; border-color: var(--green); }

.btn-danger    { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.btn-danger:hover:not(:disabled) { background: #28100e; }

.btn-ghost     { background: transparent; color: var(--text-dim); border: 1px solid var(--border-mid); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--border-light); }

.btn-approve   { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.btn-approve:hover:not(:disabled) { background: #102c1e; }

.btn-reject    { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.btn-reject:hover:not(:disabled) { background: #261010; }

/* ── TABS ─────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab {
  padding: 9px 18px;
  font-size: 12px;
  color: var(--text-faint);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
  font-weight: 400;
  letter-spacing: 0.2px;
}

.tab:hover { color: var(--text-dim); }
.tab.active { color: var(--green-bright); border-bottom-color: var(--green); }

/* ── LEAD DETAIL MODAL ────────────────────────────────────────── */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 100;
  backdrop-filter: blur(2px);
}

#modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  width: 720px;
  max-height: 82vh;
  overflow-y: auto;
  z-index: 101;
  padding: 26px;
}

#modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
}

#modal .modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 3px;
  transition: color 0.15s;
}

#modal .modal-close:hover { color: var(--text); }

.thread-item {
  padding: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.thread-lido      { background: var(--amber-bg); border-left: 3px solid var(--amber); }
.thread-oakwright { background: var(--amber-bg); border-left: 3px solid var(--amber); }
.thread-prospect  { background: var(--blue-bg); border-left: 3px solid var(--blue); }

.thread-item .from {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 500;
}

.thread-item .body { font-size: 12px; color: var(--text); line-height: 1.7; white-space: pre-wrap; }

/* ── KB ACCORDION ─────────────────────────────────────────────── */
.kb-card { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }

.kb-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--card);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.kb-card-header:hover { background: var(--card-hover); }

.kb-card-left { display: flex; align-items: center; gap: 10px; min-width: 0; }

.kb-card-accent { width: 3px; height: 16px; border-radius: 2px; flex-shrink: 0; }

.kb-card-title {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.kb-card-stat {
  font-size: 11px;
  color: var(--text-dim);
  padding-left: 10px;
  border-left: 1px solid var(--border-mid);
  margin-left: 2px;
  white-space: nowrap;
  font-family: var(--mono);
}

.kb-chevron { color: var(--text-faint); font-size: 16px; transition: transform 0.2s; line-height: 1; flex-shrink: 0; }
.kb-chevron.open { transform: rotate(90deg); color: var(--text-dim); }
.kb-card-body { border-top: 1px solid var(--border); padding: 18px; background: var(--surface); }

/* ── MISC ─────────────────────────────────────────────────────── */
.section-title {
  font-size: 9px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 14px;
  font-weight: 600;
}

.empty { text-align: center; padding: 40px 20px; color: var(--text-faint); font-size: 12px; }

.badge { display: inline-block; font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.badge-green { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.badge-blue  { background: var(--blue-bg);  color: var(--blue);  border: 1px solid var(--blue-border); }
.badge-red   { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red-border); }

.review-count {
  background: var(--red);
  color: #fff;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 10px;
  margin-left: 6px;
  font-family: var(--mono);
}

/* ── INPUTS (global) ──────────────────────────────────────────── */
input, textarea, select {
  font-family: var(--font);
  background: var(--surface);
  border: 1px solid var(--border-mid);
  color: var(--text);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus { border-color: var(--green-dim); }

select option { background: var(--surface); color: var(--text); }

code { font-family: var(--mono); color: var(--text-dim); font-size: 12px; }

/* ── SCROLLBAR ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
