/**
 * styles.css — Sales Agent Engine. Design system copied from Demo Studio
 * (Fraunces display + IBM Plex Mono, amber accent, light/dark via
 * data-theme, faint grain). Token names match demo-studio so sidebar.css
 * conventions carry over unchanged.
 */
:root {
  color-scheme: light;
  --bg: #faf7f1;
  --bg-glow: radial-gradient(ellipse 900px 500px at 50% -10%, rgba(232,163,61,0.08), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f3efe4;
  --border: #e5ddcd;
  --border-soft: #eee8db;
  --text: #221e16;
  --text-dim: #6f6656;
  --text-faint: #a89d89;
  --amber: #e8a33d;
  --amber-bright: #f0af52;
  --amber-text: #9c5f12;
  --amber-dim: #c9a06a;
  --tally: #c93a2f;
  --tally-glow: rgba(201,58,47,0.45);
  --tally-text: #9c2c22;
  --tally-bg: rgba(201,58,47,0.08);
  --ok: #237a44;
  --ok-bg: rgba(35,122,68,0.10);
  --code-bg: #f4f1e6;
  --code-text: #3a3428;
  --grain-opacity: 0.02;
  --font-display: "Fraunces", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16141a;
  --bg-glow: radial-gradient(ellipse 900px 500px at 50% -10%, rgba(232,163,61,0.10), transparent 60%);
  --surface: #1e1b23;
  --surface-2: #262230;
  --border: #37323f;
  --border-soft: #2b2733;
  --text: #f1ece1;
  --text-dim: #a99fb0;
  --text-faint: #6f6779;
  --amber: #e8a33d;
  --amber-bright: #f4b955;
  --amber-text: #e8a33d;
  --amber-dim: #9c7434;
  --tally: #e0483e;
  --tally-glow: rgba(224,72,62,0.55);
  --tally-text: #ffb4ac;
  --tally-bg: rgba(224,72,62,0.12);
  --ok: #7ec78f;
  --ok-bg: rgba(126,199,143,0.12);
  --code-bg: #100e13;
  --code-text: #d8cfe0;
  --grain-opacity: 0.035;
}
* { box-sizing: border-box; }
::selection { background: var(--amber); color: #1c1608; }
html { background: var(--bg); }
body {
  font-family: var(--font-mono);
  margin: 0;
  color: var(--text);
  background: var(--bg) var(--bg-glow);
  position: relative;
  transition: background 0.15s, color 0.15s;
}
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── shell + sidebar (demo-studio conventions) ─────────────────────── */
.shell { display: flex; align-items: stretch; min-height: 100vh; }
.sidebar {
  width: 264px; flex-shrink: 0; border-right: 1px solid var(--border);
  background: var(--surface); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 2;
}
.sidebarTop { padding: 16px 16px 12px; border-bottom: 1px solid var(--border-soft); }
.sidebarBrand {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--font-display); font-weight: 600; font-size: 15px; color: var(--text); text-decoration: none;
}
.sidebarBrandMark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--amber);
  display: inline-flex; align-items: center; justify-content: center;
  color: #1c1608; font-family: var(--font-display); font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.sidebarNav { padding: 10px 8px; display: flex; flex-direction: column; gap: 1px; }
.sidebarNavLabel {
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-faint); padding: 8px 10px 5px;
}
.sidebarNavLink {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 7px;
  font-size: 12.5px; font-weight: 500; color: var(--text-dim); text-decoration: none;
  cursor: pointer; border: none; background: transparent; font-family: var(--font-mono); text-align: left;
  transition: background 0.13s, color 0.13s; width: 100%;
}
.sidebarNavLink:hover { background: var(--surface-2); color: var(--text); }
.sidebarNavLink.active { background: var(--tally-bg); color: var(--tally-text); font-weight: 600; }
.sidebarNavLink .cnt {
  margin-left: auto; font-size: 10px; color: var(--text-faint);
  background: var(--surface-2); border-radius: 20px; padding: 2px 7px;
}
.sidebarNavLink.active .cnt { background: transparent; color: inherit; }
.sidebarNavIcon { width: 15px; height: 15px; flex-shrink: 0; display: inline-flex; }
.sidebarNavIcon svg { width: 100%; height: 100%; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebarFoot { margin-top: auto; padding: 14px 16px; border-top: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: 10px; }
.sidebarStat { font-size: 10.5px; color: var(--text-faint); line-height: 1.7; }
.sidebarStat strong { color: var(--amber-text); font-weight: 600; }

.main { flex: 1; min-width: 0; position: relative; z-index: 1; padding: 40px 48px 100px; max-width: 1160px; }

/* ── headings ──────────────────────────────────────────────────────── */
.topRow { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--amber-text); margin-bottom: 10px; display: flex; align-items: center; gap: 8px;
}
.eyebrow::before { content: "●"; font-size: 8px; color: var(--tally); text-shadow: 0 0 8px var(--tally-glow); }
h1 { font-family: var(--font-display); font-weight: 600; font-size: 30px; letter-spacing: -0.01em; margin: 0 0 6px; }
.subtitle { color: var(--text-dim); font-size: 12.5px; margin-bottom: 28px; line-height: 1.6; max-width: 70ch; }
.subtitle strong { color: var(--amber-text); font-weight: 600; }
h2 { font-family: var(--font-display); font-weight: 600; font-size: 18px; margin: 0 0 4px; }

/* ── cards, buttons, inputs ────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px 22px; margin-bottom: 16px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 12px 32px -20px rgba(0,0,0,0.25);
}
label {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-faint); margin: 14px 0 6px;
}
input[type=text], input[type=number], input[type=date], textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 13px; font-family: var(--font-mono); background: var(--bg); color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--amber-dim); box-shadow: 0 0 0 3px rgba(232,163,61,0.14); }
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.hint { font-size: 11px; color: var(--text-faint); margin-top: 6px; line-height: 1.5; }
.hint code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; color: var(--amber-text); }

button, .btn {
  background: var(--amber); color: #1c1608; border: none; border-radius: 7px;
  padding: 10px 18px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: var(--font-mono);
  box-shadow: 0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 14px -6px rgba(232,163,61,0.5);
  transition: background 0.15s, transform 0.05s;
}
button:hover { background: var(--amber-bright); }
button:active { transform: translateY(1px); }
button:disabled { background: var(--surface-2); color: var(--text-faint); cursor: default; box-shadow: none; }
button.secondary {
  background: transparent; color: var(--text-dim); border: 1px solid var(--border);
  padding: 6px 12px; font-size: 11px; font-weight: 500; box-shadow: none;
}
button.secondary:hover { background: var(--surface-2); color: var(--text); }
button.tiny { padding: 4px 9px; font-size: 10.5px; }

/* ── pills / badges ────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 600; line-height: 1;
  border-radius: 20px; padding: 4px 9px; white-space: nowrap; border: 1px solid var(--border);
  color: var(--text-dim); background: var(--surface-2);
}
.pill.stage-new { color: var(--text-dim); }
.pill.stage-contacted { color: var(--amber-text); border-color: var(--amber-dim); background: rgba(232,163,61,0.10); }
.pill.stage-replied { color: var(--tally-text); border-color: var(--tally); background: var(--tally-bg); }
.pill.stage-meeting { color: var(--ok); border-color: var(--ok); background: var(--ok-bg); }
.pill.stage-proposal { color: var(--ok); border-color: var(--ok); background: var(--ok-bg); }
.pill.stage-won { color: #fff; background: var(--ok); border-color: var(--ok); }
.pill.stage-lost { color: var(--text-faint); text-decoration: line-through; }
.pill.stage-dormant { color: var(--text-faint); }
.pill.type-client { color: var(--amber-text); border-color: var(--amber-dim); }

/* ── focus queue ───────────────────────────────────────────────────── */
.focusCard { display: flex; flex-direction: column; gap: 10px; }
.focusHead { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.focusRank { font-family: var(--font-display); font-size: 20px; font-weight: 600; color: var(--amber-text); min-width: 34px; }
.focusName { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.focusCompany { color: var(--text-dim); font-size: 12px; }
.focusScore { margin-left: auto; font-size: 10.5px; color: var(--text-faint); }
.focusScore strong { color: var(--tally-text); font-size: 13px; }
.focusWhy { font-size: 12px; color: var(--text-dim); line-height: 1.55; }
.focusNext { font-size: 12.5px; color: var(--text); line-height: 1.55; }
.focusNext::before { content: "→ "; color: var(--amber-text); font-weight: 600; }
.focusDraft {
  background: var(--code-bg); color: var(--code-text); border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 10px 12px; font-size: 12px; line-height: 1.6; white-space: pre-wrap;
}
.focusActions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── tables ────────────────────────────────────────────────────────── */
.tableWrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th {
  text-align: left; font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-faint); padding: 8px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap; cursor: pointer; user-select: none;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tr:hover td { background: var(--surface-2); }
td .leadName { font-weight: 600; cursor: pointer; }
td .leadName:hover { color: var(--amber-text); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.filterRow { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.filterRow input, .filterRow select { width: auto; min-width: 140px; }

/* ── pipeline board ────────────────────────────────────────────────── */
.board { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; padding-bottom: 8px; }
.boardCol { min-width: 200px; flex: 1; }
.boardColHead {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-faint); padding: 4px 4px 8px;
}
.boardColHead .n { color: var(--amber-text); font-size: 13px; }
.boardCard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 12px; margin-bottom: 8px; cursor: pointer; transition: border-color 0.13s;
}
.boardCard:hover { border-color: var(--amber-dim); }
.boardCardName { font-weight: 600; font-size: 12px; }
.boardCardMeta { font-size: 10.5px; color: var(--text-faint); margin-top: 3px; }

/* ── stats: tiles + bars (single-hue, direct-labeled) ──────────────── */
.tileRow { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.tileLabel { font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }
.tileValue { font-family: var(--font-display); font-size: 30px; font-weight: 600; margin-top: 4px; line-height: 1; }
.tileSub { font-size: 10.5px; color: var(--text-dim); margin-top: 6px; }

.barRow { display: grid; grid-template-columns: 110px 1fr 44px; gap: 10px; align-items: center; margin-bottom: 8px; }
.barLabel { font-size: 11px; color: var(--text-dim); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barTrack { height: 18px; position: relative; }
.barFill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--amber); border-radius: 0 4px 4px 0; min-width: 2px;
  transition: width 0.3s ease;
}
.barVal { font-size: 11px; color: var(--text); font-variant-numeric: tabular-nums; }

/* ── drawer (lead detail) ──────────────────────────────────────────── */
.drawerScrim { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 94vw); z-index: 41;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -18px 0 50px -20px rgba(0,0,0,0.4);
  padding: 24px 26px; overflow-y: auto;
}
.drawerHead { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 4px; }
.drawerGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.historyItem { display: flex; gap: 10px; font-size: 11.5px; padding: 7px 0; border-bottom: 1px solid var(--border-soft); }
.historyDate { color: var(--text-faint); white-space: nowrap; }
.historyNote { color: var(--text-dim); }

/* ── login overlay ─────────────────────────────────────────────────── */
.loginOverlay {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.loginBox { width: min(360px, 90vw); text-align: center; }
.loginBox h1 { font-size: 24px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90;
  background: var(--text); color: var(--bg); font-size: 12px; border-radius: 8px;
  padding: 10px 16px; box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
}

.empty { padding: 30px 10px; text-align: center; color: var(--text-faint); font-size: 12px; }
.view { display: none; }
.view.active { display: block; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--amber-dim); }

@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebarNav { flex-direction: row; flex-wrap: wrap; }
  .sidebarNavLabel, .sidebarFoot { display: none; }
  .main { padding: 24px 18px 80px; }
}
