/* Growth Desk — internal operations UI. Logical Knight palette, tuned for density. */
@font-face { font-family: "Instrument Sans"; src: url("instrument-sans.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("jetbrains-mono.woff2") format("woff2"); font-weight: 400 500; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #0b0b0c; --bg-2: #101012; --surface: #151517; --surface-2: #1b1b1e; --surface-3: #232327;
  --line: rgba(255,255,255,.08); --line-2: rgba(255,255,255,.14);
  --text: #f0ede6; --text-2: #aeaaa2; --text-3: #8e8a83;
  --gold: #d8b36c; --gold-hi: #ecd09a; --gold-ink: #1a1408; --gold-wash: rgba(216,179,108,.1); --gold-line: rgba(216,179,108,.4);
  --ok: #8fc79a; --warn: #e3b35c; --bad: #e0837a; --info: #8fb4e3;
  --sans: "Instrument Sans", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --r: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--gold-hi); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 1px; }
h1 { font-size: 22px; letter-spacing: -.02em; margin: 0; font-weight: 600; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 600; }
.mono, code { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--text-2); } .dim { color: var(--text-3); }
.hide { display: none !important; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 200px minmax(0, 1fr); min-height: 100vh; }
.side { border-right: 1px solid var(--line); background: var(--bg-2); padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 14px; font-weight: 600; letter-spacing: -.01em; }
.brand img { width: 22px; height: 22px; }
.brand small { display: block; font: 500 10px var(--mono); letter-spacing: .12em; color: var(--gold); text-transform: uppercase; }
.side a.nav { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: 6px; color: var(--text-2); font-weight: 500; }
.side a.nav:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.side a.nav.on { background: var(--surface-2); color: var(--text); box-shadow: inset 2px 0 0 var(--gold); }
.side .foot { margin-top: auto; padding: 8px; font-size: 12px; color: var(--text-3); display: grid; gap: 6px; }
.main { min-width: 0; padding: 18px 22px 40px; }
.topline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.topline .spacer { flex: 1; }
.env { font: 500 10px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); border: 1px dashed var(--line-2); border-radius: 4px; padding: 2px 6px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font: 500 13px var(--sans); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: rgba(255,255,255,.24); text-decoration: none; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.primary:hover { background: var(--gold-hi); }
.btn.danger { border-color: rgba(224,131,122,.5); color: var(--bad); background: transparent; }
.btn.small { height: 24px; padding: 0 8px; font-size: 12px; }
.btn.link { border: 0; background: none; color: var(--gold-hi); padding: 0; height: auto; }
input, select, textarea { font: 13px var(--sans); color: var(--text); background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 5px 8px; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--gold-line); outline: none; box-shadow: 0 0 0 2px var(--gold-wash); }
textarea { width: 100%; min-height: 70px; resize: vertical; }
label { display: grid; gap: 3px; font-size: 12px; color: var(--text-2); }
.row { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.checks label { display: inline-flex; flex-direction: row; align-items: center; gap: 5px; color: var(--text); }
.inline { display: inline; }

.flash { border-radius: 6px; padding: 8px 12px; margin-bottom: 12px; border: 1px solid; }
.flash.error { border-color: rgba(224,131,122,.45); background: rgba(224,131,122,.08); color: #f3c1bb; }
.flash.ok { border-color: rgba(143,199,154,.4); background: rgba(143,199,154,.07); color: #c5e6cb; }

/* ---------- status pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: 4px; font: 500 10.5px var(--mono); letter-spacing: .06em; text-transform: uppercase; border: 1px solid var(--line-2); color: var(--text-2); white-space: nowrap; }
.pill.s-NEW, .pill.s-REVIEW { color: var(--info); border-color: rgba(143,180,227,.35); }
.pill.s-PROSPECT { color: var(--text); }
.pill.s-CONTACTED, .pill.s-INTERESTED { color: var(--warn); border-color: rgba(227,179,92,.35); }
.pill.s-TRIAL { color: var(--gold-hi); border-color: var(--gold-line); }
.pill.s-CUSTOMER { color: var(--gold-ink); background: var(--gold); border-color: var(--gold); }
.pill.s-PAUSED { color: var(--text-3); }
.pill.s-LOST { color: var(--bad); border-color: rgba(224,131,122,.35); }
.pill.r-HIGH { color: var(--gold-hi); border-color: var(--gold-line); }
.pill.flag { color: var(--warn); border-color: rgba(227,179,92,.35); text-transform: none; letter-spacing: 0; }
.pill.bad { color: var(--bad); border-color: rgba(224,131,122,.4); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); display: inline-block; }
.dot.on { background: var(--gold); }

/* ---------- cards / sections ---------- */
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; min-width: 0; }
.card + .card { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.count { font: 500 11px var(--mono); color: var(--text-3); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 12px; align-items: start; }
.cols > .card + .card { margin-top: 0; }
.empty { color: var(--text-3); font-size: 13px; padding: 6px 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .what { min-width: 0; }
.list .what small { display: block; color: var(--text-3); font-size: 12px; }
.list .acts { display: flex; gap: 6px; flex: none; }

/* ---------- counters ---------- */
.counters { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); margin-bottom: 14px; overflow: hidden; }
.counters div { padding: 12px 14px; border-left: 1px solid var(--line); min-width: 0; }
.counters div:first-child { border-left: 0; }
.counters b { display: block; font-size: 22px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.counters span { font: 500 10.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); }
.counters .gold b { color: var(--gold-hi); }

/* ---------- data tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font: 500 10.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); padding: 6px 8px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.data td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* ---------- companies grid ---------- */
.stagebar { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.stagebar button { background: none; border: 0; color: var(--text-2); font: 500 13px var(--sans); padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.stagebar button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--gold); }
.stagebar .n { font: 11px var(--mono); color: var(--text-3); margin-left: 4px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar input[type=search] { width: 240px; }
.bulkbar { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--gold-line); background: var(--gold-wash); border-radius: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.gridwrap { position: relative; border: 1px solid var(--line); border-radius: var(--r); overflow: auto; max-height: calc(100vh - 230px); background: var(--bg-2); }
table.grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 13px; }
table.grid th { position: sticky; top: 0; z-index: 2; background: var(--surface); text-align: left; font: 500 10.5px var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line); padding: 0; user-select: none; }
table.grid th .h { display: flex; align-items: center; gap: 4px; padding: 8px; height: 32px; cursor: pointer; overflow: hidden; white-space: nowrap; }
table.grid th .h:hover { color: var(--text); }
table.grid th .h .arrow { color: var(--gold); }
table.grid th .rz { position: absolute; top: 0; right: -3px; width: 7px; height: 100%; cursor: col-resize; z-index: 3; }
table.grid th .rz:hover, table.grid th .rz.on { background: var(--gold-line); }
table.grid th:first-child, table.grid td:first-child { position: sticky; left: 0; z-index: 1; background: var(--bg-2); }
table.grid th:first-child { z-index: 3; background: var(--surface); }
table.grid th:nth-child(2), table.grid td:nth-child(2) { position: sticky; left: 36px; z-index: 1; background: var(--bg-2); box-shadow: 1px 0 0 var(--line-2); }
table.grid th:nth-child(2) { z-index: 3; background: var(--surface); }
table.grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0 8px; height: 34px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.grid td:focus { outline: 2px solid var(--gold); outline-offset: -2px; }
table.grid tr:hover td { background: #141416; }
table.grid tr.sel td { background: rgba(216,179,108,.07); }
table.grid td.edit { cursor: text; }
table.grid td.editing { padding: 0; overflow: visible; }
table.grid td.editing input, table.grid td.editing select { width: 100%; height: 33px; border-radius: 0; border-color: var(--gold); }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.saving { opacity: .55; }
table.grid td.err { box-shadow: inset 0 0 0 1px var(--bad); }
table.grid td .open { color: var(--text); font-weight: 500; background: none; border: 0; padding: 0; cursor: pointer; font: inherit; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
table.grid td .open:hover { color: var(--gold-hi); text-decoration: underline; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 8px; font-size: 12px; color: var(--text-2); }
.gridmsg { padding: 30px; text-align: center; color: var(--text-3); }

/* ---------- side panel ---------- */
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100vw); background: var(--bg); border-left: 1px solid var(--line-2); box-shadow: -30px 0 60px rgba(0,0,0,.5); z-index: 50; overflow-y: auto; transform: translateX(100%); transition: transform .2s ease; }
.panel.open { transform: none; }
.panel-top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.panel-top .spacer { flex: 1; }
.panel-body { padding: 16px; }

/* ---------- company detail ---------- */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.detail-head .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; color: var(--text-2); font-size: 13px; }
.detail { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.panel .detail { grid-template-columns: minmax(0, 1fr); }
dl.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--text-3); font: 11px var(--mono); padding-top: 2px; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.prov { font: 10px var(--mono); color: var(--text-3); margin-left: 6px; }
.why { border-left: 2px solid var(--gold); padding: 2px 0 2px 10px; margin: 0 0 10px; }
.why b { display: block; font: 500 10.5px var(--mono); letter-spacing: .1em; color: var(--gold); text-transform: uppercase; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 116px 1fr; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; }
.timeline li:first-child { border-top: 0; }
.timeline time { font: 11px var(--mono); color: var(--text-3); }
.timeline .t { font: 500 10.5px var(--mono); letter-spacing: .06em; color: var(--gold); margin-right: 6px; }
.signal { border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin-bottom: 8px; }
.signal blockquote { margin: 6px 0; padding-left: 10px; border-left: 2px solid var(--gold); color: var(--text-2); font-style: italic; }
.draft { border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin-bottom: 8px; }
.draft.approved { border-color: var(--gold-line); }
details.fold summary { cursor: pointer; color: var(--text-2); font-size: 13px; }
details.fold[open] summary { margin-bottom: 8px; }
.danger-zone { border-color: rgba(224,131,122,.35); }
.token { font: 13px var(--mono); background: var(--surface-2); border: 1px solid var(--gold-line); padding: 10px; border-radius: 6px; overflow-wrap: anywhere; user-select: all; }
.audit td { font-size: 12px; }
.audit code { color: var(--text-2); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: min(360px, 100%); display: grid; gap: 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.login input { height: 36px; }

/* ---------- mobile ---------- */
@media (max-width: 1100px) {
  .counters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .counters div:nth-child(5) { border-left: 0; }
  .counters div:nth-child(n+5) { border-top: 1px solid var(--line); }
  .detail { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; z-index: 40; height: auto; flex-direction: row; overflow-x: auto; padding: 6px; border-right: 0; border-bottom: 1px solid var(--line); gap: 2px; }
  .brand { padding: 4px 8px; }
  .brand span, .side .foot { display: none; }
  .side a.nav { padding: 6px 9px; white-space: nowrap; }
  .main { padding: 12px 12px 30px; }
  .counters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .counters div:nth-child(odd) { border-left: 0; }
  .counters div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
  .cols { grid-template-columns: minmax(0, 1fr); }
  dl.kv { grid-template-columns: minmax(0, 1fr); gap: 0 0; }
  dl.kv dd { margin-bottom: 8px; }
  .toolbar input[type=search] { width: 100%; }
  .gridwrap { max-height: none; }
}
#toast { position: fixed; right: 16px; bottom: 16px; z-index: 100; max-width: 420px; box-shadow: 0 10px 30px rgba(0,0,0,.5); background: var(--surface-2); }
.setup { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; margin: 10px 0 16px; }
.setup .qr { background: #fff; border-radius: 8px; padding: 6px; width: 220px; height: 220px; }
.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; list-style: none; padding: 0; margin: 10px 0 16px; }
.codes li { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 8px 10px; text-align: center; font-size: 14px; user-select: all; }
.review-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.review-card dl.kv { grid-template-columns: 150px minmax(0, 1fr); margin: 8px 0; }
.review-card .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.blocked { color: var(--bad); font-size: 12px; }
.sysbar { display: flex; flex-wrap: wrap; gap: 6px 22px; align-items: center; padding: 8px 12px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); font-size: 12.5px; color: var(--text-2); }
.dot.bad { background: var(--bad); }
.jobs td, .jobs th { white-space: nowrap; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.opp { border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; margin-top: 12px; }
.opp:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
