/* CRM – Opportunity Engine. One stylesheet, light + dark, no external assets.
   Colour rule: neutrals everywhere; the orange "action" colour appears only
   where the owner has to act (primary buttons, the current step, "your move"). */
:root {
  color-scheme: light;
  --bg: #f3f1ed; --surface: #ffffff; --surface-2: #f8f6f3; --inset: #f1eee9;
  --border: #e3ded6; --border-strong: #cdc6bb;
  --text: #1d1a16; --muted: #6a6359; --faint: #988f84; --ink-2: #5a544c;
  --action: #d9480f; --action-ink: #ffffff; --action-soft: #fff0e6; --action-line: #f4b28c;
  --ok: #1d7a3e; --ok-soft: #e5f3e9; --warn: #946200; --warn-soft: #fbf1d3;
  --bad: #b42318; --bad-soft: #fde8e6;
  --a: #6a46d0; --b1: #0d7a69; --b2: #b42d76;
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(40, 30, 20, .05), 0 2px 8px rgba(40, 30, 20, .05);
  --shadow-current: 0 0 0 1px var(--action-line), 0 6px 20px rgba(217, 72, 15, .12);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%236a6359' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121110; --surface: #1c1a18; --surface-2: #211f1c; --inset: #171614;
    --border: #34302b; --border-strong: #4b463f;
    --text: #f2eee8; --muted: #b1a99d; --faint: #80786d; --ink-2: #d2cabf;
    --action: #ff7a3d; --action-ink: #1b0e06; --action-soft: #33190c; --action-line: #8a3d17;
    --ok: #62d18c; --ok-soft: #15301f; --warn: #f0c04e; --warn-soft: #362c10;
    --bad: #ff8b80; --bad-soft: #3c1916;
    --a: #b29bff; --b1: #3fd0b8; --b2: #f584bd;
    --shadow: none; --shadow-current: 0 0 0 1px var(--action-line);
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23b1a99d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121110; --surface: #1c1a18; --surface-2: #211f1c; --inset: #171614;
  --border: #34302b; --border-strong: #4b463f;
  --text: #f2eee8; --muted: #b1a99d; --faint: #80786d; --ink-2: #d2cabf;
  --action: #ff7a3d; --action-ink: #1b0e06; --action-soft: #33190c; --action-line: #8a3d17;
  --ok: #62d18c; --ok-soft: #15301f; --warn: #f0c04e; --warn-soft: #362c10;
  --bad: #ff8b80; --bad-soft: #3c1916;
  --a: #b29bff; --b1: #3fd0b8; --b2: #f584bd;
  --shadow: none; --shadow-current: 0 0 0 1px var(--action-line);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23b1a99d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--action); }
h1 { font-size: 1.6rem; margin: 0 0 .2rem; line-height: 1.2; letter-spacing: -.01em; }
h2 { font-size: 1.08rem; margin: 0 0 .75rem; letter-spacing: -.005em; }
h3 { font-size: .8rem; margin: 1rem 0 .45rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
h3:first-child { margin-top: 0; }
p { margin: 0 0 .6rem; }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }
code, .mono { font-family: var(--mono); font-size: .85em; }

/* layout */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 18px; height: 58px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 750; color: var(--text); white-space: nowrap; text-decoration: none; }
.brand img { width: 26px; height: 26px; display: block; }
.brand span { color: var(--muted); font-weight: 500; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; }
.nav a { color: var(--muted); padding: 7px 12px; border-radius: 999px; white-space: nowrap; font-weight: 600; text-decoration: none; }
.nav a:hover { background: var(--inset); color: var(--text); }
.nav a.active { background: var(--text); color: var(--surface); }
.top-tools { display: flex; align-items: center; gap: 6px; }
.theme-toggle, .logout button { background: none; border: 1px solid transparent; color: var(--muted); cursor: pointer; font: inherit; font-size: .9rem; padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.theme-toggle:hover, .logout button:hover { color: var(--text); border-color: var(--border); }
@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 8px 16px; gap: 6px 10px; }
  .brand span { display: none; }
  .top-tools { margin-left: auto; }
  .nav { order: 3; flex-basis: 100%; padding-bottom: 2px; }
}
main.page { max-width: 1240px; margin: 0 auto; padding: 26px 16px 72px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 960px) { .grid-3, .grid-2, .grid-main { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 18px; }
.stack.tight > * + * { margin-top: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card.tight { padding: 12px 14px; }
.card h2 { display: flex; align-items: center; gap: 8px; }
.card.quiet { background: var(--surface-2); box-shadow: none; }
.card.quiet h2 { font-size: .95rem; color: var(--ink-2); }

/* workflow steps on the opportunity card */
.step { position: relative; padding-top: 0; overflow: hidden; scroll-margin-top: 76px; }
.step-head { display: flex; align-items: center; gap: 12px; margin: 0 -20px 16px; padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.step-head h2 { margin: 0; flex: 1; }
.step-no { flex: none; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .9rem; border: 2px solid var(--border-strong); color: var(--muted); background: var(--surface); }
.step.done .step-no { border-color: var(--ok); background: var(--ok); color: var(--surface); font-size: 0; }
.step.done .step-no::before { content: "✓"; font-size: .9rem; }
.step.current { border-color: var(--action); box-shadow: var(--shadow-current); }
.step.current .step-head { background: var(--action-soft); border-bottom-color: var(--action-line); }
.step.current .step-no { border-color: var(--action); background: var(--action); color: var(--action-ink); }
.step-foot { margin: 18px -20px -20px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.step.current .step-foot { background: color-mix(in srgb, var(--action-soft) 55%, var(--surface)); border-top-color: var(--action-line); }
.next-step { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 14px 18px; margin-bottom: 18px; border-radius: var(--radius); border: 1px solid var(--action-line); border-left: 5px solid var(--action); background: var(--action-soft); }
.next-step .label { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--action); }
.next-step .text { font-weight: 650; font-size: 1.02rem; }
.next-step.calm { border-color: var(--border); border-left-color: var(--border-strong); background: var(--surface-2); }
.next-step.calm .label { color: var(--muted); }

/* today slots */
.slot { display: flex; flex-direction: column; min-height: 270px; border-top: 4px solid var(--border-strong); }
.slot.A { border-top-color: var(--a); } .slot.B1 { border-top-color: var(--b1); } .slot.B2 { border-top-color: var(--b2); }
.slot.yours { box-shadow: var(--shadow-current); }
.slot-empty { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 8px; color: var(--muted); }
.slot .company { display: block; font-size: 1.12rem; font-weight: 700; margin: 8px 0 2px; color: var(--text); text-decoration: none; }
.slot .company:hover { color: var(--action); }
.slot .reason { color: var(--muted); font-size: .9rem; margin: 6px 0 10px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.slot .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }

/* badges & chips */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 10px; font-size: .78rem; font-weight: 650; background: var(--inset); color: var(--muted); white-space: nowrap; border: 1px solid transparent; }
.badge.A { background: color-mix(in srgb, var(--a) 13%, transparent); color: var(--a); }
.badge.B1 { background: color-mix(in srgb, var(--b1) 13%, transparent); color: var(--b1); }
.badge.B2 { background: color-mix(in srgb, var(--b2) 13%, transparent); color: var(--b2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent, .badge.info { background: transparent; border-color: var(--border-strong); color: var(--ink-2); }
.badge.action { background: var(--action); color: var(--action-ink); }
.badge.wait { background: transparent; border-color: var(--border-strong); color: var(--muted); }
.badge.wait::before { content: "◷"; font-size: .85em; }
.move { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; color: var(--muted); }
.move::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.move.yours { color: var(--action); }
.move.yours::before { background: var(--action); box-shadow: 0 0 0 3px color-mix(in srgb, var(--action) 25%, transparent); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--faint); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.cls { font-size: .7rem; font-weight: 750; letter-spacing: .03em; padding: 1px 7px; border-radius: 5px; }
.cls.VERIFIED { background: var(--ok-soft); color: var(--ok); }
.cls.INFERRED { background: var(--inset); color: var(--ink-2); border: 1px solid var(--border-strong); }
.cls.HYPOTHESIS { background: var(--warn-soft); color: var(--warn); }
.cls.UNKNOWN, .cls.CONTRADICTED { background: var(--bad-soft); color: var(--bad); }

/* metrics */
.metrics { display: flex; gap: 6px; flex-wrap: wrap; }
.metric { min-width: 84px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.metric b { display: block; font-size: 1.2rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.metric span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }
.slot .metric, .card .metric { background: var(--surface-2); }
.bar { height: 7px; background: var(--inset); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.bar > i { display: block; height: 100%; background: var(--ink-2); border-radius: 999px; }
.bar.warn > i { background: var(--warn); } .bar.bad > i { background: var(--bad); }

/* status strip */
.status-strip { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; padding: 13px 18px; }
.status-strip .item { display: flex; gap: 8px; align-items: center; font-size: .9rem; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
td a b { text-decoration: none; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 650; cursor: pointer; text-decoration: none; white-space: nowrap; transition: border-color .12s, filter .12s; }
.btn:hover { background: var(--inset); border-color: var(--muted); }
.btn.primary { background: var(--action); border-color: var(--action); color: var(--action-ink); }
.btn.primary:hover { filter: brightness(1.06); background: var(--action); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { padding: 5px 11px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn.link { border: 0; background: none; padding: 0; color: var(--text); text-decoration: underline; }
.btn.is-active { background: var(--text); border-color: var(--text); color: var(--surface); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--action) 55%, transparent); outline-offset: 2px; }

/* forms */
form.inline { display: inline; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 5px; font-weight: 650; }
input[type=text], input[type=number], input[type=email], input[type=url], input[type=search], input[type=password], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; transition: border-color .12s, box-shadow .12s; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px color-mix(in srgb, var(--action) 22%, transparent); }
input::placeholder, textarea::placeholder { color: var(--faint); }
select { appearance: none; -webkit-appearance: none; background-image: var(--chevron); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; cursor: pointer; font-weight: 550; }
select[multiple] { min-height: 140px; background-image: none; padding-right: 11px; }
select option { background: var(--surface); color: var(--text); }
input[type=checkbox], input[type=radio] { accent-color: var(--action); width: 16px; height: 16px; }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr) auto; gap: 8px; align-items: end; margin-bottom: 14px; }
@media (max-width: 960px) { .filters { grid-template-columns: 1fr 1fr; } }
details.action { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0; background: var(--surface); }
details.action > summary { cursor: pointer; padding: 9px 12px; font-weight: 650; list-style: none; display: flex; align-items: center; gap: 8px; }
details.action > summary::before { content: "▸"; color: var(--faint); transition: transform .12s; display: inline-block; }
details.action[open] > summary::before { transform: rotate(90deg); }
details.action > summary::-webkit-details-marker { display: none; }
details.action > summary:hover { background: var(--surface-2); }
details.action[open] > summary { border-bottom: 1px solid var(--border); }
details.action > div { padding: 12px; }
details.action.danger > summary { color: var(--bad); }

/* flash & notes */
.flash { padding: 11px 15px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 550; border: 1px solid transparent; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.flash.err { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.note { padding: 11px 13px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); font-size: .9rem; border: 1px solid var(--border); }
.note.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }

/* card detail */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 7px 14px; font-size: .9rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; } }
.message { white-space: pre-wrap; background: var(--inset); border-radius: var(--radius-sm); padding: 13px 14px; font-size: .94rem; border: 1px solid var(--border); border-left: 3px solid var(--border-strong); }
.msg-block + .msg-block { margin-top: 16px; }
.msg-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.msg-head h3 { margin: 0; }
.msg-head h3 small { text-transform: none; letter-spacing: 0; font-weight: 500; margin-left: 4px; }
.evidence li { margin-bottom: 12px; }
.evidence .excerpt { color: var(--muted); font-size: .85rem; border-left: 3px solid var(--border-strong); padding-left: 9px; margin-top: 4px; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.bullets { padding-left: 18px; margin: 0 0 .5rem; }
.person { padding: 12px 0; border-bottom: 1px solid var(--border); }
.person:last-child { border-bottom: 0; }
.person.primary { padding: 12px 14px; margin-bottom: 6px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); }
.score-row { display: grid; grid-template-columns: 1fr 70px 50px; gap: 10px; align-items: center; font-size: .85rem; margin-bottom: 7px; }
.timeline li { font-size: .85rem; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.pagination { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 650; text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--action); }
.tabs a:hover { color: var(--text); }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { margin-bottom: 14px; font-size: 1.1rem; }
