/* LoanKwest internal pricing — a quiet ledger with one loud thing: the rate board. */
:root {
  --paper: #f4f7f6;
  --surface: #ffffff;
  --ink: #16302b;
  --muted: #5d706b;
  --rule: #d3ddd9;
  --spruce: #1e5b4f;
  --spruce-dark: #164539;
  --tint: #e3eeea;
  --credit: #1f7a5c;
  --cost: #8e3b62;
  --warn-ink: #7a5600;
  --warn-bg: #fff4d6;
  --error-ink: #8f2424;
  --error-bg: #fbe9e7;
  --bar: #16302b;
  --bar-ink: #c9d6d1;
  --bar-strong: #ffffff;
  --bar-accent: #7fc1ad;
  --on-accent: #ffffff;
  --scale-mid: #f1f4f3;
  --info-ink: #234a7a;
  --info-bg: #e4ecf7;
  --quiet-bg: #eceeed;
  --radius-sm: 4px;
  --radius: 8px;
  font-family: "Public Sans", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1a18; --surface: #16231f; --ink: #dfe9e5; --muted: #93a7a1; --rule: #2b3d38;
    --spruce: #6cc0a6; --spruce-dark: #8fd3bd; --tint: #1d3530; --credit: #63c69f; --cost: #e294bc;
    --warn-ink: #f0cd7a; --warn-bg: #3a3017; --error-ink: #f2a39b; --error-bg: #3d1f1c;
    --bar: #0a1311; --bar-ink: #a9bcb6; --bar-strong: #f2f7f5; --bar-accent: #6cc0a6; --on-accent: #0b1714;
    --scale-mid: #22312d; --info-ink: #a9c8f0; --info-bg: #1c2a3d; --quiet-bg: #22302c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1a18; --surface: #16231f; --ink: #dfe9e5; --muted: #93a7a1; --rule: #2b3d38;
  --spruce: #6cc0a6; --spruce-dark: #8fd3bd; --tint: #1d3530; --credit: #63c69f; --cost: #e294bc;
  --warn-ink: #f0cd7a; --warn-bg: #3a3017; --error-ink: #f2a39b; --error-bg: #3d1f1c;
  --bar: #0a1311; --bar-ink: #a9bcb6; --bar-strong: #f2f7f5; --bar-accent: #6cc0a6; --on-accent: #0b1714;
  --scale-mid: #22312d; --info-ink: #a9c8f0; --info-bg: #1c2a3d; --quiet-bg: #22302c;
  color-scheme: dark;
}
body { background: var(--paper); color: var(--ink); }
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--spruce); text-underline-offset: 2px; }
a:hover { color: var(--spruce-dark); }
h1, h2 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; font-weight: 600; }
h2.inline { display: inline; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: .85rem; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--spruce) 55%, transparent); outline-offset: 2px; }

/* ---------- chrome */
.topbar {
  display: flex; align-items: center; gap: 2rem;
  padding: .75rem clamp(1rem, 3vw, 2rem);
  background: var(--bar); color: var(--bar-ink);
}
.brand { color: var(--bar-strong); font-weight: 700; text-decoration: none; font-size: 1.05rem; }
.brand span, .login h1 span { font-weight: 400; opacity: .7; }
.topbar nav { display: flex; gap: 1.25rem; flex: 1; }
.topbar nav a { color: var(--bar-ink); text-decoration: none; padding: .25rem 0; border-bottom: 2px solid transparent; }
.topbar nav a:hover { color: var(--bar-strong); }
.topbar nav a[aria-current="page"] { color: var(--bar-strong); border-bottom-color: var(--bar-accent); }
.topbar .who { display: flex; align-items: center; gap: .75rem; font-size: .9rem; color: var(--bar-ink); }
.topbar .who .link { color: var(--bar-strong); }
.page { max-width: 1240px; margin: 0 auto; padding: 1.75rem clamp(1rem, 3vw, 2rem) 4rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.crumb { margin-bottom: .25rem; font-size: .9rem; }
section { margin: 2rem 0; }

/* ---------- forms */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 500; color: var(--muted); margin-bottom: .85rem; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: var(--radius-sm);
  padding: .55rem .65rem; min-width: 0; width: 100%;
}
input:focus, select:focus { border-color: var(--spruce); }
input[type="checkbox"] { width: auto; }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--ink); }
input[type="file"] { padding: .45rem; }
button { font: inherit; cursor: pointer; border-radius: var(--radius-sm); }
.primary { background: var(--spruce); color: var(--on-accent); border: 0; padding: .65rem 1.1rem; font-weight: 600; }
.primary:hover { background: var(--spruce-dark); }
.ghost { background: transparent; border: 1px solid var(--rule); color: var(--ink); padding: .5rem .9rem; }
.ghost:hover { border-color: var(--spruce); }
.link { background: none; border: 0; padding: 0; color: var(--spruce); text-decoration: underline; text-underline-offset: 2px; }
.danger { color: var(--error-ink); }
.ghost.danger:hover { border-color: var(--error-ink); }
.row2, .row3 { display: grid; gap: 0 .75rem; }
.row2 { grid-template-columns: 1fr 1fr; }
.row3 { grid-template-columns: 1fr 1fr 1fr; }
.alert { padding: .65rem .85rem; border-radius: var(--radius-sm); margin-bottom: 1rem; }
.alert ul { margin: 0; padding-left: 1.1rem; }
.alert.error { background: var(--error-bg); color: var(--error-ink); }
.alert.ok { background: var(--tint); color: var(--spruce-dark); }
.error-text { color: var(--error-ink); }

/* ---------- login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login { width: min(380px, 100%); background: var(--surface); padding: 2rem; border-radius: var(--radius); border: 1px solid var(--rule); }
.login .primary { width: 100%; margin-top: .25rem; }

/* ---------- quote */
.quote-layout { display: grid; grid-template-columns: 340px 1fr; gap: 2.5rem; align-items: start; }
.scenario { position: sticky; top: 1rem; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.25rem; }
.scenario h1 { font-size: 1.25rem; margin-bottom: 1rem; }
.scenario .primary { width: 100%; margin: .25rem 0 .75rem; padding: .75rem; }
details.more { margin: 0 0 1rem; }
details.more summary { cursor: pointer; color: var(--spruce); font-size: .9rem; margin-bottom: .75rem; }

.results-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .75rem; }
.results-head h2 { font-size: 1.25rem; }
.empty-state { padding: 3rem 0; max-width: 34rem; }
.empty-state h2 { font-size: 1.4rem; }
.empty-state p, .empty { color: var(--muted); }

/* The rate board: big rates, a price scale around par. */
.board { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.board > li { border-bottom: 1px solid var(--rule); }
.board details[open] { background: var(--surface); }
.quote-row {
  display: grid; grid-template-columns: 7.5rem 1fr 13rem auto; align-items: center; gap: 1.25rem;
  padding: .9rem .75rem; cursor: pointer; list-style: none;
}
.quote-row::-webkit-details-marker { display: none; }
.quote-row:hover { background: var(--tint); }
.rate { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.rate small { font-size: 1rem; font-weight: 500; margin-left: 1px; color: var(--muted); }
.board li:first-child .rate { color: var(--spruce); }
.quote-row .prod { display: flex; flex-direction: column; gap: .1rem; }
.price { display: grid; grid-template-columns: auto 1fr; column-gap: .6rem; align-items: baseline; }
.price-figure { font-weight: 600; font-size: 1.05rem; }
.price-figure.cost { color: var(--cost); }
.price-figure.credit { color: var(--credit); }
.scale {
  grid-column: 1 / -1; position: relative; height: 6px; margin-top: .45rem; border-radius: 3px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--cost) 30%, var(--scale-mid)), var(--scale-mid) 50%, color-mix(in srgb, var(--credit) 30%, var(--scale-mid)));
}
.scale::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--muted); }
.scale i { position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); border: 2px solid var(--surface); transform: translate(-50%, -50%); box-shadow: 0 0 0 1px var(--ink); }
.flag { font-size: .78rem; font-weight: 600; color: var(--warn-ink); background: var(--warn-bg); padding: .15rem .5rem; border-radius: 999px; white-space: nowrap; }

.quote-detail { padding: .25rem .75rem 1.25rem; }
.notes { margin: 0 0 1rem; padding: .6rem .85rem .6rem 1.8rem; background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--radius-sm); }
.detail-cols { display: grid; grid-template-columns: minmax(14rem, 1fr) 2fr; gap: 1.5rem; margin-bottom: .75rem; }
.detail-cols table, table.list, table.matrix { width: 100%; border-collapse: collapse; font-size: .9rem; }
caption { text-align: left; font-weight: 600; padding-bottom: .4rem; }
th { text-align: left; font-weight: 500; color: var(--muted); }
th, td { padding: .4rem .55rem; border-bottom: 1px solid var(--rule); }
td:not(:first-child), th:not(:first-child) { text-align: right; }
tfoot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--ink); }
tr.chosen td { background: var(--tint); font-weight: 600; }

details.dropped { margin-top: 1.5rem; }
details.dropped > summary { cursor: pointer; color: var(--muted); font-weight: 500; }
details.dropped > ul { list-style: none; padding: 0; margin: .75rem 0 0; }
details.dropped > ul > li { padding: .5rem 0; border-bottom: 1px solid var(--rule); }
details.dropped ul ul { margin: .25rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: .9rem; }
.disclaimer { margin-top: 2rem; font-size: .8rem; color: var(--muted); }

/* ---------- rate sheets */
.upload { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 0 1rem; align-items: end; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.1rem 1.25rem .4rem; margin-bottom: 1rem; }
.upload > h2, .upload > p { grid-column: 1 / -1; }
.upload .primary { margin-bottom: .85rem; }
table.list td, table.list th { text-align: left; }
table.list { background: var(--surface); }
tr.off td { color: var(--muted); }
.status { display: inline-block; font-size: .78rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; background: var(--tint); color: var(--spruce-dark); white-space: nowrap; }
.s-draft, .s-queued { background: var(--warn-bg); color: var(--warn-ink); }
.s-running { background: var(--info-bg); color: var(--info-ink); }
.s-failed { background: var(--error-bg); color: var(--error-ink); }
.s-suspended, .s-archived { background: var(--quiet-bg); color: var(--muted); }
details > summary h2 { cursor: pointer; }

/* ---------- product review */
.product-head .actions { display: flex; align-items: center; gap: .75rem; }
.product-head .actions form { margin: 0; }
.review-notes { background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--radius); padding: 1rem 1.25rem; margin: 1rem 0; }
.review-notes h2 { color: var(--warn-ink); }
.review-notes ul { margin: 0; padding-left: 1.2rem; }
.review-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 42%); gap: 2rem; align-items: start; }
.review-split:not(:has(.original)) { grid-template-columns: 1fr; }
.original { position: sticky; top: 1rem; margin: 2rem 0; }
.original iframe, .original img { width: 100%; height: 78vh; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--surface); object-fit: contain; }
.scroll { overflow-x: auto; }
table.matrix { background: var(--surface); }
table.matrix th, table.matrix td { white-space: nowrap; text-align: center; }
table.matrix tbody th { text-align: left; color: var(--ink); font-weight: 600; }
table.matrix td small { display: block; color: var(--muted); font-size: .78rem; }
.na { color: var(--error-ink); font-weight: 600; }
.ladders { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.ladders table { width: auto; min-width: 12rem; }
table.compact td, table.compact th { padding: .3rem .5rem; }
.rules { list-style: none; padding: 0; margin: 0; }
.rules li { display: grid; grid-template-columns: 7.5rem 1fr; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--rule); }
.rules li.off { opacity: .55; }
.rules p { margin: 0; }
.rules .source { color: var(--muted); font-size: .85rem; margin-top: .2rem; }
.rule-type { font-size: .78rem; font-weight: 600; padding: .15rem .5rem; border-radius: var(--radius-sm); align-self: start; text-align: center; }
.t-hard_stop { background: var(--error-bg); color: var(--error-ink); }
.t-cap_value, .t-floor_value { background: var(--info-bg); color: var(--info-ink); }
.t-adjustment { background: var(--tint); color: var(--spruce-dark); }
.t-warning { background: var(--warn-bg); color: var(--warn-ink); }

/* ---------- small screens */
@media (max-width: 900px) {
  .quote-layout, .review-split, .detail-cols { grid-template-columns: 1fr; }
  .scenario, .original { position: static; }
  .quote-row { grid-template-columns: 6rem 1fr; }
  .quote-row .price { grid-column: 1 / -1; }
  .upload { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: .75rem 1.25rem; }
  .topbar nav { order: 3; flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.settings-form { grid-template-columns: 1fr auto; max-width: 46rem; }
@media (max-width: 900px) { .settings-form { grid-template-columns: 1fr; } }
