/* Birddogging Research — dashboard styles.
   Tokens match the design canvas: warm paper neutrals, hunter-green accent,
   Space Grotesk display / IBM Plex Sans body / IBM Plex Mono data. */

:root {
  --bg: #f7f5f1;
  --card: #ffffff;
  --border: #e6e1d7;
  --border-faint: #f1ede5;
  --ink: #201d18;
  --muted: #7a7468;
  --faint: #a8a196;
  --side-bg: #1b2822;
  --side-txt: #a9bdb2;
  --accent: #3e8e6a;
  --accent-dk: #2f6b52;
  --accent-soft: #e7f1eb;
  --good-t: #2f6b52; --good-b: #e7f1eb;
  --warn-t: #8a6116; --warn-b: #f6edd8;
  --bad-t:  #a04226; --bad-b:  #f7e6de;
  --track: #ece7dc;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --disp: 'Space Grotesk', 'Avenir Next', 'Trebuchet MS', sans-serif;
  --body: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--body); color: var(--ink); background: var(--bg); font-size: 14px; }
a { color: var(--accent-dk); text-decoration: none; }
a:hover { color: #1f4a38; }

#app { display: flex; min-height: 100vh; }

/* ---- sidebar ---- */
.sidebar {
  width: 216px; flex-shrink: 0; background: var(--side-bg);
  display: flex; flex-direction: column; padding: 22px 14px 18px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 22px; }
.brand-name { font-family: var(--disp); font-weight: 700; font-size: 16px; color: #fff; letter-spacing: .2px; }
.brand-sub { font-size: 10.5px; color: var(--side-txt); letter-spacing: 2px; text-transform: uppercase; }
#nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 8px; color: var(--side-txt); font-size: 13.5px; cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #dbe7e0; }
.nav-item.active { background: rgba(255,255,255,.09); color: #fff; font-weight: 600; }
.nav-item.active svg { stroke: #8fd0ae; }
.sidebar-foot {
  margin-top: auto; padding: 12px 6px 0; border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11px; color: var(--side-txt); line-height: 1.5;
}

/* ---- main ---- */
main { flex: 1; padding: 26px 32px 48px; min-width: 0; }
.loading { color: var(--muted); padding: 40px; }

.topbar { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 16px; }
.topbar h1 { font-family: var(--disp); font-weight: 600; font-size: 23px; letter-spacing: -.2px; margin: 0; }
.topbar .sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* ---- primitives ---- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 1px 2px rgba(32,29,24,.04);
}
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; gap: 10px; }
.card-title { font-family: var(--disp); font-weight: 600; font-size: 15px; }
.card-body { padding: 16px 20px 20px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.pill.good { background: var(--good-b); color: var(--good-t); }
.pill.warn { background: var(--warn-b); color: var(--warn-t); }
.pill.bad { background: var(--bad-b); color: var(--bad-t); }
.pill.neutral { background: #efece5; color: var(--muted); }

.chip {
  display: inline-block; padding: 2.5px 9px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); font-size: 11.5px; font-family: var(--mono);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; font-family: var(--body);
}
.btn.primary { background: var(--accent-dk); color: #fff; border-color: var(--accent-dk); }
.btn.primary:hover { background: #275a45; }
.btn.secondary { background: var(--card); color: var(--ink); border-color: var(--border); }
.btn.secondary:hover { border-color: #cfc8ba; }
.btn.ghost { background: transparent; color: var(--accent-dk); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 6px 12px; font-size: 12px; }

input[type="text"], input[type="number"], select, textarea {
  font-family: var(--body); font-size: 13px; color: var(--ink);
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--card);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { font-family: var(--mono); font-size: 12.5px; line-height: 1.6; resize: vertical; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 11px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); }
label.field > input, label.field > select { font-weight: 400; letter-spacing: 0; text-transform: none; }

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ---- stat tiles ---- */
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat-tile { padding: 16px 20px 18px; }
.stat-label { font-size: 11px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); }
.stat-value { font-family: var(--mono); font-size: 30px; font-weight: 500; margin-top: 8px; letter-spacing: -.5px; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- bars ---- */
.hbar { display: flex; flex-direction: column; gap: 5px; }
.hbar-top { display: flex; justify-content: space-between; font-size: 12.5px; }
.hbar-track { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.hbar-fill { height: 8px; border-radius: 4px; background: var(--accent); }

/* ---- rows / lists ---- */
.row-list > div { display: flex; align-items: center; gap: 12px; padding: 11px 20px; border-top: 1px solid var(--border-faint); }
.icon-badge {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft);
  color: var(--accent-dk); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* ---- posts / prospects split ---- */
.split { display: flex; gap: 16px; align-items: flex-start; }
.split-list { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.split-detail { width: 400px; flex-shrink: 0; position: sticky; top: 20px; }
.item-card { border: 1px solid var(--border); background: var(--card); border-radius: 10px; padding: 14px 16px; cursor: pointer; }
.item-card:hover { border-color: #cfc8ba; }
.item-card.selected { border: 1.5px solid var(--accent); background: #fbfaf6; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.engage { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 12px; color: var(--muted); }

.filters { display: flex; gap: 10px; align-items: flex-end; padding: 14px 16px; flex-wrap: wrap; }

/* ---- scrape type tiles ---- */
.type-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.type-tile { border: 1px solid var(--border); background: var(--card); border-radius: 10px; padding: 13px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.type-tile.selected { border: 1.5px solid var(--accent); background: var(--accent-soft); }
.type-tile .t-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.type-tile .t-cost { font-size: 11px; color: var(--muted); font-family: var(--mono); }

/* ---- tables ---- */
.ledger-head, .ledger-row {
  display: grid; grid-template-columns: 1.4fr 1fr .6fr .9fr .8fr .8fr .9fr 1fr;
  gap: 10px; align-items: center; padding: 11px 20px;
}
.ledger-head { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); padding-bottom: 8px; }
.ledger-row { border-top: 1px solid var(--border-faint); font-size: 12.5px; }

/* ---- callouts ---- */
.callout { background: var(--accent-soft); border-radius: 8px; padding: 12px 14px; color: var(--accent-dk); font-size: 12.5px; }
.note-box { font-size: 12px; color: var(--muted); background: #faf8f4; border: 1px solid var(--border-faint); border-radius: 8px; padding: 10px 12px; }
.error-box { background: var(--bad-b); color: var(--bad-t); border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }

/* ---- modal ---- */
#modal-root { position: fixed; inset: 0; background: rgba(32,29,24,.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--card); border-radius: 12px; padding: 24px; width: 520px; max-width: 92vw; max-height: 88vh; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal h2 { font-family: var(--disp); font-size: 17px; margin: 0; }

/* ---- assistant chat ---- */
.chat-card { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 420px; }
.chat-log { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.chat-msg { display: flex; flex-direction: column; gap: 6px; }
.chat-msg.user { align-items: flex-end; }
.chat-msg.assistant { align-items: flex-start; }
.chat-bubble {
  max-width: 76%; padding: 10px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.6;
}
.chat-msg.user .chat-bubble { background: var(--accent-dk); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.chat-msg.assistant .chat-bubble { background: #faf8f4; border: 1px solid var(--border-faint); border-bottom-left-radius: 4px; }
.chat-steps { display: flex; flex-wrap: wrap; gap: 5px; }
.chat-inputrow { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border-faint); align-items: flex-end; }
.chat-inputrow textarea { flex: 1; font-family: var(--body); font-size: 13.5px; }
.chat-hint { font-size: 11.5px; padding: 0 16px 12px; }

/* ---- markdown rendering ---- */
.md-body { font-size: 13px; line-height: 1.65; }
.md-body .md-h1, .md-body .md-h2 { font-family: var(--disp); font-weight: 600; font-size: 15px; margin: 10px 0 4px; }
.md-body .md-h3, .md-body .md-h4 { font-weight: 600; font-size: 13.5px; margin: 8px 0 3px; }
.md-body .md-gap { height: 8px; }
.md-body ul { margin: 4px 0; padding-left: 20px; }
.md-body li { margin: 2px 0; }
.md-body code { font-family: var(--mono); font-size: 12px; background: var(--track); padding: 1px 5px; border-radius: 4px; }
.md-body hr { border: 0; border-top: 1px solid var(--border-faint); margin: 10px 0; }
.modal .md-body { max-height: 52vh; overflow: auto; background: #faf8f4; border: 1px solid var(--border-faint); border-radius: 8px; padding: 14px 16px; }

/* ---- toast ---- */
#toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--side-bg); color: #fff;
  padding: 12px 18px; border-radius: 10px; font-size: 13px; z-index: 60;
  box-shadow: 0 6px 24px rgba(32,29,24,.25); max-width: 380px;
}
#toast.bad { background: #7c3013; }

@media (max-width: 1100px) {
  .split { flex-direction: column; }
  .split-detail { width: 100%; position: static; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .sidebar { display: none; }
  main { padding: 18px 14px 40px; }
  .ledger-head { display: none; }
  .ledger-row { grid-template-columns: 1fr 1fr; }
}
