:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #14202b; --muted: #5c6b7a; --line: #e2e6ea;
  --accent: #0b5fff; --accent-ink: #ffffff; --ok: #1a8f4b; --warn: #c77700; --bad: #c62828;
  --new: #0b5fff; --contacted: #6d4cd8; --engaged: #0e8a8a; --quoting: #b06a00; --quoted: #b04a00; --won: #1a8f4b; --lost: #7a7f86;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  font-family: -apple-system, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1720; --panel: #16212c; --ink: #e8edf2; --muted: #9aa8b6; --line: #273340;
    --accent: #5b8cff; --accent-ink: #0b1220; --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 10; display: flex; gap: 12px; align-items: center; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .3px; white-space: nowrap; }
.brand span { color: var(--accent); }
.search { flex: 1; }
.search input { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.nav { display: flex; gap: 14px; align-items: center; font-size: 14px; color: var(--muted); }
.nav a.active { color: var(--ink); font-weight: 600; }
.user { font-size: 12px; }

.main { padding: 16px; max-width: 1100px; margin: 0 auto; }
.banner { position: sticky; top: 54px; z-index: 9; margin: 0; padding: 14px 16px; background: var(--accent); color: var(--accent-ink); font-weight: 700; text-align: center; }
.banner a { text-decoration: underline; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; cursor: pointer; }
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
select { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); }
.btn { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; box-shadow: var(--shadow); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; box-shadow: none; }
.btn:disabled { opacity: .5; cursor: default; }

.list { display: grid; gap: 8px; }
.card { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .name { font-weight: 600; font-size: 16px; }
.card .meta { color: var(--muted); font-size: 13px; }
.card .right { text-align: right; font-size: 13px; color: var(--muted); }
.stage { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #fff; background: var(--lost); }
.stage[data-s="New"] { background: var(--new); } .stage[data-s="Contacted"] { background: var(--contacted); }
.stage[data-s="Engaged"] { background: var(--engaged); } .stage[data-s="Quoting"] { background: var(--quoting); }
.stage[data-s="Quoted"] { background: var(--quoted); } .stage[data-s="Won"] { background: var(--won); } .stage[data-s="Lost"] { background: var(--lost); }
.tag { display: inline-block; padding: 1px 6px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); font-size: 11px; margin-left: 4px; }

.detail { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; }
@media (max-width: 800px) { .detail { grid-template-columns: 1fr; } .top { flex-wrap: wrap; } .search { order: 3; flex-basis: 100%; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.panel h2 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.head { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.head h1 { margin: 0; font-size: 22px; }
.stages { display: flex; flex-wrap: wrap; gap: 6px; }
.stages button { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 13px; }
.stages button.current { color: #fff; border-color: transparent; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 10px; font-size: 14px; }
.kv .k { color: var(--muted); }
.kv input, .kv select { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.call { font-size: 20px; font-weight: 700; }
.call a { color: var(--accent); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; display: grid; grid-template-columns: 150px 1fr; gap: 8px; }
.timeline .t { color: var(--muted); font-size: 12px; }
.note { white-space: pre-wrap; }
textarea { width: 100%; min-height: 70px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.empty { color: var(--muted); padding: 30px; text-align: center; }
.consent { font-size: 13px; }
.consent .yes { color: var(--ok); font-weight: 700; } .consent .no { color: var(--bad); font-weight: 700; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { text-align: left; padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; border-top: 0; }
pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: var(--bg); padding: 8px; border-radius: 6px; }
