:root {
  --bg: #0d0d0f; --card: #17171b; --line: #26262c; --text: #f2f2f4;
  --muted: #9a9aa3; --red: #e10600; --green: #22c55e; --amber: #f59e0b; --blue: #3b82f6;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, 'Segoe UI', Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--red); min-height: 1.2em; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 40px 32px; width: 100%; max-width: 380px; text-align: center; }
.logo { font-size: 28px; font-weight: 900; letter-spacing: 1px; }
.logo.sm { font-size: 18px; }
.login-card input { width: 100%; margin: 18px 0 12px; }

/* layout */
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 10; flex-wrap: wrap; }
#tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
#tabs button { background: none; border: none; color: var(--muted); padding: 10px 14px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600; }
#tabs button.active { background: var(--red); color: #fff; }
#view { padding: 24px 20px; max-width: 1200px; margin: 0 auto; }

/* cards + grids */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.card .num { font-size: 32px; font-weight: 900; }
.card .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin-bottom: 20px; }
.panel h3 { margin: 0 0 12px; }

/* forms */
input, textarea, select { background: #0a0a0c; border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
input:focus, textarea:focus { outline: none; border-color: var(--red); }
textarea { width: 100%; min-height: 90px; font-family: inherit; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.row input, .row select { flex: 1; min-width: 140px; }
label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; display: block; margin: 12px 0 6px; }

/* buttons */
.btn { border: none; border-radius: 10px; padding: 10px 18px; font-weight: 700; cursor: pointer; font-size: 14px; }
.btn.primary { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn.green { background: var(--green); color: #06240f; }
.btn.sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: 1px; }

/* badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; margin: 2px; }
.b-found { background: #333; color: #ccc; }
.b-drafted { background: #3b2f0b; color: var(--amber); }
.b-approved { background: #0b2f3b; color: var(--blue); }
.b-sent { background: #0f3b1e; color: var(--green); }
.b-opened { background: #123a2a; color: #4ade80; }
.b-replied { background: #3b0f2e; color: #f472b6; }
.b-won { background: var(--green); color: #06240f; }
.b-dead { background: #222; color: #666; }
.gap { display: inline-block; background: #2a1215; color: #ff8a80; border: 1px solid #5a1f24; padding: 2px 8px; border-radius: 12px; font-size: 11px; margin: 2px; }
.score { font-weight: 900; font-size: 18px; }
.score.hot { color: var(--green); } .score.warm { color: var(--amber); } .score.cold { color: var(--muted); }

/* email view */
.email-body { white-space: pre-wrap; background: #0a0a0c; border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin: 12px 0; }
.subject { font-size: 18px; font-weight: 800; }

/* pipeline */
.pipe { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.pipe .step { min-width: 130px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.pipe .step .num { font-size: 24px; font-weight: 900; }

.kbd-note { background: #141416; border: 1px dashed var(--line); border-radius: 10px; padding: 12px; color: var(--muted); font-size: 13px; margin-top: 12px; }
@media (max-width: 640px) { #view { padding: 16px 12px; } table { font-size: 12px; } }
