:root {
  --bg: #f5f6f8; --card: #fff; --ink: #1d2433; --muted: #6b7385; --line: #e3e6ec;
  --brand: #0e4c7a; --brand2: #c2410c; --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef1f5; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
h1 { font-size: 22px; margin: 0 0 .4rem; }
h1 small, h2 small { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: .3rem; }
h2 { font-size: 15px; margin: 0 0 .8rem; }
main { max-width: 1320px; margin: 0 auto; padding: 1.5rem; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: .7rem 1.5rem; background: var(--brand); color: #fff; }
.topbar .brand { color: #fff; font-weight: 700; font-size: 16px; }
.topbar .brand span { font-weight: 400; opacity: .75; }
.topbar nav a { color: #dbe8f3; margin-left: 1.2rem; }
.topbar nav a.cta { background: var(--brand2); color: #fff; padding: .35rem .8rem; border-radius: 6px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-lead { display: grid; grid-template-columns: 5fr 6fr; gap: 1rem; align-items: start; }
@media (max-width: 960px) { .grid2, .grid-lead { grid-template-columns: 1fr; } }

.pagehead { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.actions { display: flex; gap: .5rem; align-items: flex-start; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
td, th { padding: .45rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
table.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list tr:hover td { background: #fafbfc; }
tr.dnc td { opacity: .55; }
.overdue { color: var(--bad); font-weight: 600; }

.btn { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: .45rem .9rem; border-radius: 6px; cursor: pointer; font: inherit; text-decoration: none !important; }
.btn:hover { border-color: #c5cad3; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.big { padding: .7rem 1.4rem; font-size: 15px; }
.btn.busy { opacity: .7; cursor: progress; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; font: inherit; }
button.link.danger { color: var(--bad); }

input, select, textarea { font: inherit; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; width: 100%; }
textarea { resize: vertical; }
textarea.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
label { display: block; font-size: 12.5px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: .2rem; color: var(--ink); }
label.inline { display: inline-flex; align-items: center; gap: .3rem; }
label.inline input { width: auto; margin: 0; }
label.check { display: flex; align-items: center; gap: .4rem; color: var(--ink); }
label.check input { width: auto; margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem .8rem; }
.form-grid .wide { grid-column: 1 / -1; }
.inline-form { display: flex; gap: .4rem; }
.inline-form input { width: 16rem; }
.row { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; flex-wrap: wrap; }
details summary { cursor: pointer; color: var(--brand); margin: .5rem 0; }

.filters { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.filters input[name=q] { width: 18rem; }
.filters select, .filters input { width: auto; }

.pop { position: relative; }
.pop summary { list-style: none; margin: 0; color: var(--ink); }
.pop summary::-webkit-details-marker { display: none; }
.popbody { position: absolute; right: 0; z-index: 10; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; width: 22rem; display: grid; gap: .5rem; box-shadow: 0 8px 24px rgba(0,0,0,.08); }

.score { display: inline-block; min-width: 2.2em; text-align: center; font-weight: 700; border-radius: 6px; padding: 0 .35rem; font-size: 13px; }
.score.hi { background: #dcfce7; color: var(--ok); }
.score.mid { background: #fef3c7; color: var(--warn); }
.score.lo { background: #f1f5f9; color: var(--muted); }
h1 .score { font-size: 16px; vertical-align: middle; }

.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: #eef1f5; color: var(--muted); margin-right: 3px; }
.tag.gf { background: #fde7d9; color: #9a3412; }
.tag.av { background: #dbeafe; color: #1e40af; }
.tag.dnc { background: #fee2e2; color: var(--bad); }

.status { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: #eef1f5; text-transform: capitalize; }
.s-qualified { background: #e0e7ff; color: #3730a3; }
.s-contacted { background: #e0f2fe; color: #075985; }
.s-replied, .s-meeting { background: #fef3c7; color: #92400e; }
.s-quote_sent, .s-negotiating { background: #fae8ff; color: #86198f; }
.s-won, .j-done { background: #dcfce7; color: #166534; }
.s-lost, .s-disqualified, .j-error { background: #fee2e2; color: #991b1b; }
.j-running, .j-queued { background: #e0f2fe; color: #075985; }

.pipeline { display: grid; grid-template-columns: repeat(10, 1fr); gap: .5rem; margin-bottom: 1rem; }
.stage { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem; text-align: center; color: var(--ink); }
.stage:hover { border-color: var(--brand); text-decoration: none; }
.stage .n, .stats .n { font-size: 22px; font-weight: 700; }
.stage .l, .stats .l { font-size: 11.5px; color: var(--muted); text-transform: capitalize; }
@media (max-width: 960px) { .pipeline { grid-template-columns: repeat(5, 1fr); } }
.stats { display: flex; gap: 1rem; margin-bottom: 1rem; }
.stats > div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem 1.2rem; min-width: 8rem; }

.alert { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.alert.info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

.notes, .body { white-space: pre-wrap; }
.notes { font-size: 13.5px; }
.sources { font-size: 12px; word-break: break-all; padding-left: 1.2rem; }
.log { white-space: pre-wrap; font-size: 12.5px; background: #0f172a; color: #cbd5e1; padding: 1rem; border-radius: 8px; max-height: 65vh; overflow: auto; margin: 0; }

.msg { border: 1px solid var(--line); border-radius: 8px; padding: .8rem; margin-bottom: .8rem; }
.msg header { display: flex; gap: .4rem; align-items: center; margin-bottom: .5rem; flex-wrap: wrap; }
.msg.inbound { border-left: 4px solid var(--warn); }
.msg.outbound { border-left: 4px solid var(--brand); }
.msg.draft { background: #fffdf5; }
.msg.note { border-left: 4px solid #94a3b8; }
.msg input.subject { font-weight: 600; margin-bottom: .4rem; }
.msg .subject-line { font-weight: 600; margin-bottom: .3rem; }
.tips { background: #f1f5f9; border-radius: 6px; padding: .5rem .7rem; font-size: 12.5px; white-space: pre-wrap; margin: .6rem 0 0; }

.radios label, .segments label, .regions label { color: var(--ink); font-size: 13.5px; display: flex; gap: .4rem; align-items: center; margin: .25rem 0; }
.radios input, .segments input, .regions input { width: auto; margin: 0; }
.regions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin-bottom: 1rem; }
.regions fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .8rem; }
.regions legend { font-weight: 600; }
.segments { columns: 2; margin-bottom: 1rem; }
.ai-form h2 { margin-top: 1.2rem; }
.ai-form h2:first-child { margin-top: 0; }

/* v2 additions */
.center-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.card.narrow { width: 24rem; display: grid; gap: .8rem; }
.topbar nav a.muted-link { color: #9fbbd3; font-size: 12.5px; }
.subnav { display: flex; gap: 1rem; margin-bottom: 1rem; }
.actions.stack { flex-direction: column; align-items: flex-end; }
.btn.small-btn { padding: .15rem .5rem; font-size: 12px; }
.tag.k-tender { background: #dcfce7; color: #166534; }
.tag.k-award { background: #e0e7ff; color: #3730a3; }
.tag.k-pin { background: #fef3c7; color: #92400e; }
.tag.k-signal { background: #fae8ff; color: #86198f; }
.tag.dm { background: #dcfce7; color: #166534; }
.tag.inf { background: #e0f2fe; color: #075985; }
.s-new, .s-reviewing { background: #eef1f5; }
.s-bidding, .s-submitted { background: #fef3c7; color: #92400e; }
.s-ignored { background: #f1f5f9; color: var(--muted); }
.opp { padding: .9rem 1.1rem; }
.opp-head { display: flex; gap: .7rem; align-items: flex-start; }
.opp-title { flex: 1; }
.opp-summary { margin: .5rem 0; }
.opp .row { margin-top: .3rem; }
.opp .inline-form input { width: 12rem; }
.reply-row { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.draft-form label { margin-bottom: .4rem; }
.draft-form .row label.check { display: inline-flex; margin-right: .6rem; }
.section-title { margin: 1.4rem 0 .6rem; font-size: 16px; }
.growth p { margin: .4rem 0; }
.tag.imp-high { background: #fde7d9; color: #9a3412; }
.tag.imp-medium { background: #fef3c7; color: #92400e; }
.tag.imp-low { background: #eef1f5; }
.g-doing { background: #e0f2fe; color: #075985; }
.g-done { background: #dcfce7; color: #166534; }
.g-skipped { background: #f1f5f9; color: var(--muted); }
.checklist ul { list-style: none; padding: 0; margin: .6rem 0 0; columns: 2; }
.checklist li { margin: .25rem 0; }
.checklist li.done { color: var(--muted); text-decoration: line-through; }
.progress { height: 6px; background: #eef1f5; border-radius: 3px; overflow: hidden; }
.progress div { height: 100%; background: var(--ok); }
@media (max-width: 720px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: .4rem; }
  .topbar nav a { margin: 0 .8rem 0 0; display: inline-block; }
  .form-grid { grid-template-columns: 1fr; }
  .checklist ul { columns: 1; }
  .inline-form { flex-wrap: wrap; }
  .inline-form input { width: 100%; }
  .actions.stack { align-items: stretch; }
}

/* review flow */
.steps { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.step { padding: .3rem .8rem; border-radius: 999px; background: #eef1f5; color: var(--muted); font-size: 12.5px; }
.step.done { background: #dcfce7; color: #166534; }
.card.warn { border-color: #fcd34d; background: #fffbeb; }
.card.warn ul { margin: 0; padding-left: 1.2rem; }
.preview { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.pv-row { display: flex; gap: .8rem; padding: .4rem .8rem; border-bottom: 1px solid var(--line); font-size: 13px; }
.pv-row > span:first-child { width: 4.5rem; color: var(--muted); flex-shrink: 0; }
.pv-body { white-space: pre-wrap; padding: 1rem; font-family: Georgia, serif; font-size: 14.5px; line-height: 1.6; background: #fff; }
.verdict { display: flex; justify-content: space-between; align-items: center; padding: .7rem 1rem; border-radius: 8px; margin-bottom: .6rem; }
.v-ready { background: #dcfce7; color: #166534; }
.v-minor_changes { background: #fef3c7; color: #92400e; }
.v-needs_changes { background: #fee2e2; color: #991b1b; }
.verdict-chip { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; }
.score-big { font-size: 20px; font-weight: 700; }
.issues, .claims { padding-left: 1.1rem; margin: .3rem 0 .8rem; }
.issues li, .claims li { margin: .35rem 0; }
.sev-high strong { color: var(--bad); }
.sev-medium strong { color: var(--warn); }
.claims li.ok { color: #166534; }
.claims li.bad { color: var(--bad); font-weight: 600; }
.approve-form { display: grid; gap: .4rem; margin-top: .8rem; }
.body.clamp { max-height: 7.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); }
h3 { font-size: 13.5px; margin: .8rem 0 .2rem; }

/* AI switch & costs */
.ai-toggle { display: inline; margin-left: 1rem; }
.pill { border: 0; border-radius: 999px; padding: .25rem .7rem; font: inherit; font-size: 12px; cursor: pointer; font-weight: 600; }
.pill.on { background: #22c55e; color: #fff; }
.pill.off { background: #64748b; color: #fff; }
.est { font-weight: 400; font-size: 11.5px; opacity: .8; margin-left: .3rem; }
button.ai-off { opacity: .45; cursor: not-allowed; }
.free-form { margin-top: .8rem; padding-top: .8rem; border-top: 1px dashed var(--line); }
.stats.wrap { flex-wrap: wrap; }
.budgetbar { height: 10px; background: #eef1f5; border-radius: 5px; overflow: hidden; margin: .3rem 0; }
.budgetbar div { height: 100%; }
.budgetbar .ok { background: var(--ok); } .budgetbar .warn { background: #f59e0b; } .budgetbar .bad { background: var(--bad); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; margin-bottom: 1rem; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.bar div { width: 100%; background: var(--brand); border-radius: 2px 2px 0 0; min-height: 1px; }
.bar span { font-size: 9px; color: var(--muted); }
.radio-row { display: flex; gap: .5rem; align-items: flex-start; margin: .4rem 0; color: var(--ink); font-size: 13.5px; }
.radio-row input { width: auto; margin-top: .2rem; }

.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.choice > div { border: 1px solid var(--line); border-radius: 8px; padding: .8rem; }
@media (max-width: 720px) { .choice { grid-template-columns: 1fr; } }

.legend summary { cursor: pointer; }
.legend-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; margin-top: .6rem; }
.legend-grid p { margin: .35rem 0; font-size: 13px; }
@media (max-width: 960px) { .legend-grid { grid-template-columns: 1fr; } }
.opp-plain { background: #f8fafc; border-radius: 6px; padding: .5rem .7rem; margin: .5rem 0; font-size: 13.5px; }

.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin: .5rem 0 .8rem; border-bottom: 2px solid var(--line); }
.tab { padding: .5rem .9rem; border-radius: 8px 8px 0 0; color: var(--muted); text-decoration: none !important; margin-bottom: -2px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; background: #fff; }
.tab .count { display: inline-block; background: #eef1f5; border-radius: 999px; padding: 0 .45rem; font-size: 11.5px; margin-left: .2rem; color: var(--ink); }

.bulkbar { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; flex-wrap: wrap; }
.bulkbar select { width: auto; }
