@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@600;700;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --navy: #0E1A2B; --navy-2: #1A2940; --line-dark: #2A3A52;
  --ground: #F5F4EF; --card: #FFFFFF; --line: #E2E0D8; --line-2: #ECEAE3;
  --ink: #0E1A2B; --muted: #4A5568; --faint: #6B7280;
  --gold: #E2B33C; --gold-ink: #6B5310;
  --ok: #17663A; --ok-bg: #E3F2E8; --bad: #A12A1C; --bad-bg: #FBE7E3; --warn: #7A4B00; --warn-bg: #FCF0D5;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'IBM Plex Sans', system-ui, sans-serif; background: var(--ground); color: var(--ink); font-size: 15px; line-height: 1.5; }
h1, h2, h3 { font-family: Archivo, sans-serif; margin: 0; letter-spacing: -0.005em; }
h1 { font-size: 28px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
a { color: var(--ink); }
code, pre, .mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 13px; }
pre { background: var(--navy); color: #E6EAF0; padding: 16px; border-radius: var(--radius); overflow-x: auto; margin: 0; line-height: 1.55; }
.hidden { display: none !important; }

/* layout */
.shell { display: flex; min-height: 100vh; flex-wrap: wrap; }
.side { background: var(--navy); color: #D6DAE2; width: 232px; flex: 0 0 232px; padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; color: #F5F4EF; font-family: Archivo, sans-serif; font-weight: 800; letter-spacing: .08em; font-size: 15px; padding: 0 10px 18px; }
.brand-mark { width: 28px; height: 28px; border: 2px solid var(--gold); border-radius: 4px; display: grid; place-items: center; color: var(--gold); font-size: 13px; }
.brand small { display: block; font-family: 'IBM Plex Sans'; font-weight: 500; letter-spacing: 0; color: #A9B2C1; font-size: 12px; }
.side a { color: #C3CAD6; text-decoration: none; padding: 10px 12px; border-radius: 6px; font-weight: 500; min-height: 40px; display: flex; align-items: center; }
.side a:hover { background: var(--navy-2); color: #fff; }
.side a.active { background: var(--navy-2); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.side .spacer { flex: 1; }
.side .who { font-size: 13px; color: #A9B2C1; padding: 10px 12px; border-top: 1px solid var(--line-dark); margin-top: 8px; word-break: break-all; }
.side button.linkish { background: none; border: 0; color: #C3CAD6; font: inherit; text-align: left; padding: 10px 12px; cursor: pointer; border-radius: 6px; min-height: 40px; }
.side button.linkish:hover { background: var(--navy-2); color: #fff; }
main { flex: 999 1 560px; min-width: 0; padding: 32px 36px 64px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head p { margin: 6px 0 0; color: var(--muted); }

@media (max-width: 760px) {
  .side { width: 100%; flex-basis: 100%; flex-direction: row; flex-wrap: wrap; padding: 12px; }
  .brand { width: 100%; padding-bottom: 8px; }
  .side .spacer { display: none; }
  .side .who { width: 100%; }
  main { padding: 20px 16px 48px; }
}

/* cards, grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi .v { font-family: Archivo, sans-serif; font-size: 26px; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* forms */
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink); min-width: 0; }
label.f.grow { flex: 1 1 220px; }
label.check { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 500; min-height: 40px; }
input, select, textarea { font: inherit; font-weight: 400; border: 1px solid #B8BEC8; border-radius: 6px; padding: 9px 11px; background: #fff; color: var(--ink); min-height: 40px; width: 100%; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.btn { font: inherit; font-weight: 600; border: 1px solid var(--navy); background: var(--navy); color: #F5F4EF; border-radius: 6px; padding: 9px 16px; cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--navy-2); }
.btn.secondary { background: #fff; color: var(--ink); border-color: #B8BEC8; }
.btn.secondary:hover { background: var(--ground); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--navy); }
.btn.danger { background: #fff; color: var(--bad); border-color: #E5B4AC; }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: wait; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #FAFAF7; border-bottom: 1px solid var(--line); padding: 10px 12px; white-space: nowrap; }
td { border-bottom: 1px solid var(--line-2); padding: 10px 12px; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* badges */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.neutral { background: #ECEEF2; color: #374151; }
.reasons { margin: 0; padding-left: 16px; font-size: 13px; color: var(--bad); }

/* chart */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 160px; padding-top: 8px; border-bottom: 1px solid var(--line); }
.bars .b { flex: 1 1 0; display: flex; flex-direction: column-reverse; min-width: 4px; height: 100%; }
.bars .b span { display: block; width: 100%; }
.bars .acc { background: var(--navy); border-radius: 2px 2px 0 0; }
.bars .rej { background: #C9CED8; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend .acc { background: var(--navy); } .legend .rej { background: #C9CED8; }
.axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); margin-top: 4px; }

/* misc */
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 8px; max-width: 420px; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.toast.err { background: var(--bad); }
.callout { background: var(--warn-bg); border: 1px solid #EBD199; color: #4A3200; border-radius: var(--radius); padding: 14px 16px; }
.callout.ok { background: var(--ok-bg); border-color: #B9DEC6; color: #0E3F23; }
.secret { font-family: 'IBM Plex Mono', monospace; background: #fff; border: 1px dashed var(--gold-ink); padding: 10px; border-radius: 6px; word-break: break-all; margin-top: 8px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; font: inherit; font-weight: 600; color: var(--muted); padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; min-height: 44px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--gold); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.cond-row { display: grid; grid-template-columns: 1.2fr 0.8fr 1.2fr 1.4fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
@media (max-width: 760px) { .cond-row { grid-template-columns: 1fr 1fr; } }
dialog { border: 0; border-radius: 10px; padding: 0; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog::backdrop { background: rgba(14,26,43,.5); }
dialog .dlg-body { padding: 24px; overflow-y: auto; max-height: calc(100vh - 140px); }
dialog .dlg-foot { padding: 14px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; background: #FAFAF7; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0 0 16px; }
legend { font-weight: 700; font-family: Archivo, sans-serif; padding: 0 6px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--navy); }
.login-card { background: var(--ground); border-radius: 12px; padding: 36px; width: min(420px, 100%); display: flex; flex-direction: column; gap: 16px; }
.login-card .brand { color: var(--navy); padding: 0 0 6px; }

/* docs */
.docs main { max-width: 980px; margin: 0 auto; }
.docs section { margin-bottom: 40px; }
.docs p, .docs li { max-width: 760px; }
.endpoint { display: inline-flex; gap: 8px; align-items: center; font-family: 'IBM Plex Mono', monospace; font-size: 14px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; margin: 6px 0 12px; }
.method { font-weight: 600; color: var(--gold-ink); }
.grid > .card + .card, .grid-2 > .card + .card { margin-top: 0; }

/* ---------- buyer portal ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--ink); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; text-align: left; min-height: 24px; }
.linkbtn:hover { color: var(--navy-2); }
.due { color: var(--bad); font-weight: 600; }
.pos { color: var(--ok); font-weight: 600; }
.side-balance { display: flex; flex-direction: column; padding: 10px 12px; margin: 0 0 6px; border: 1px solid var(--line-dark); border-radius: 6px; color: #fff; }
.side-balance b { font-family: Archivo, sans-serif; font-size: 20px; }
.side-balance .muted { color: #A9B2C1; }
.badge.stage-new { background: #E6ECF7; color: #1F3A68; }
.badge.stage-contacted { background: #EDE7F6; color: #4A2B7A; }
.badge.stage-qualified { background: #E2F1F3; color: #12525C; }
.badge.stage-appointment { background: var(--warn-bg); color: var(--warn); }
.badge.stage-won { background: var(--ok-bg); color: var(--ok); }
.badge.stage-lost { background: #ECEEF2; color: #4B5563; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.col { background: #ECEAE3; border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.col header { display: flex; justify-content: space-between; align-items: center; padding: 2px 2px 4px; }
.lead-card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.lead-card select { min-height: 34px; padding: 4px 8px; margin-top: 4px; font-size: 13px; }
.empty-col { padding: 8px 4px; margin: 0; }
.kpis.compact { margin: 4px 0 8px; }
.kpis.compact .kpi { padding: 12px; }
.kpis.compact .kpi .v { font-size: 20px; }
.inline-bid input { width: 110px; }
.inline-bid .f { flex-direction: row; align-items: center; gap: 6px; }
dialog.wide { width: min(980px, calc(100vw - 32px)); }
.dlg-foot .spacer-f { flex: 1; }
.grid-2.tight { gap: 20px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.lead-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; }
.lead-head > div:first-child { display: flex; gap: 8px; flex-wrap: wrap; }
.timeline { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow-y: auto; }
.timeline li { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; }
.timeline li.note { border-left-color: var(--navy); }
.timeline li.stage { border-left-color: var(--gold); }
.kv dd { word-break: break-word; }
.bid-list { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.bid-list li { display: flex; gap: 8px; justify-content: space-between; border-bottom: 1px dashed var(--line-2); padding: 3px 0; }
