/* Shared by the board (index.html), the agent portal (agent.html) and the info pages.
   Colours meet WCAG 2.2 AAA: 7:1 for text, 3:1 for control borders, on every background they're used on. */
:root{
  --bg:#F6F7F9;
  --surface:#FFFFFF;
  --surface-raised:#FFFFFF;
  --ink:#1B2430;
  --ink-muted:#434C58;
  --ink-faint:#465060;
  --line:#E3E7EC;          /* decorative dividers only */
  --line-strong:#7D8794;   /* control borders: 3.4:1 or more */
  --accent:#165440;
  --accent-soft:#E6F0EC;
  --on-accent:#FFFFFF;
  --gold:#5A440C;
  --gold-soft:#F6EFDD;
  --danger:#8C1D17;
  --danger-soft:#FBEBEA;
  --focus:#165440;
  --shadow: 0 1px 2px rgba(20,30,40,.04), 0 8px 24px rgba(20,30,40,.05);
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#121620;
    --surface:#191E29;
    --surface-raised:#1E2430;
    --ink:#EDEFF2;
    --ink-muted:#B9C0CB;
    --ink-faint:#AEB5C0;
    --line:#2A313E;
    --line-strong:#6B7483;
    --accent:#6FCBA5;
    --accent-soft:#14291F;
    --on-accent:#121620;
    --gold:#E2C77E;
    --gold-soft:#332A14;
    --danger:#F2B8B5;
    --danger-soft:#3A1E1D;
    --focus:#6FCBA5;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"]{
  --bg:#121620;
  --surface:#191E29;
  --surface-raised:#1E2430;
  --ink:#EDEFF2;
  --ink-muted:#B9C0CB;
  --ink-faint:#AEB5C0;
  --line:#2A313E;
  --line-strong:#6B7483;
  --accent:#6FCBA5;
  --accent-soft:#14291F;
  --on-accent:#121620;
  --gold:#E2C77E;
  --gold-soft:#332A14;
  --danger:#F2B8B5;
  --danger-soft:#3A1E1D;
  --focus:#6FCBA5;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
}

*{box-sizing:border-box;}
[hidden]{display:none !important;}
body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font-family:'Inter',system-ui,-apple-system,Segoe UI,sans-serif;
  line-height:1.5;
  padding:28px 16px 48px;
}
.wrap{max-width:980px;margin:0 auto;}

h1,h2{font-family:'Fraunces',Georgia,serif;line-height:1.25;}

/* One focus style everywhere: 3 px, high contrast against both the control and the page. */
:focus-visible{outline:3px solid var(--focus);outline-offset:2px;}

.visually-hidden{
  position:absolute !important;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0 0 0 0);
  white-space:nowrap;
  border:0;
}
.skip-link{
  position:absolute;
  left:16px;
  top:-200px;
  z-index:100;
  background:var(--accent);
  color:var(--on-accent);
  font-weight:600;
  padding:12px 18px;
  border-radius:8px;
  text-decoration:none;
}
.skip-link:focus{top:12px;}

.test-banner{
  max-width:980px;
  margin:0 auto 18px;
  padding:10px 14px;
  border:1px solid var(--gold);
  border-radius:8px;
  background:var(--gold-soft);
  color:var(--gold);
  font-size:14px;
  font-weight:600;
  text-align:center;
}

header.page{
  display:flex;
  flex-wrap:wrap;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  margin-bottom:24px;
}
.title-block h1{
  font-size:30px;
  font-weight:600;
  letter-spacing:-0.01em;
  margin:0;
}
.header-right{display:flex;flex-direction:column;align-items:flex-end;gap:10px;}

.account{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-end;font-size:14px;color:var(--ink-muted);}
.account .who{font-weight:600;color:var(--ink);}
.role-chip{
  font-size:13px;
  font-weight:700;
  letter-spacing:.02em;
  color:var(--accent);
  background:var(--accent-soft);
  border-radius:5px;
  padding:2px 8px;
}
.role-chip.warn{color:var(--gold);background:var(--gold-soft);}
.role-chip.bad{color:var(--danger);background:var(--danger-soft);}

.status-line{
  font-size:14px;
  color:var(--ink-muted);
  background:var(--surface);
  border:1px solid var(--line-strong);
  border-radius:8px;
  padding:12px 14px;
  margin:0 0 18px;
}
.status-line .btn-ghost{margin-left:10px;}

/* Toggles: the selected option is bold with a bar underneath, so it never relies on colour alone. */
.seg{
  display:flex;
  background:var(--surface);
  border:1px solid var(--line-strong);
  border-radius:8px;
  overflow:hidden;
}
.seg button{
  font-family:inherit;
  font-size:14px;
  font-weight:500;
  color:var(--ink-muted);
  background:transparent;
  border:none;
  min-height:44px;
  min-width:44px;
  padding:8px 14px;
  cursor:pointer;
}
.seg button + button{border-left:1px solid var(--line);}
.seg button.active, .seg button[aria-pressed="true"]{
  background:var(--accent-soft);
  color:var(--accent);
  font-weight:700;
  box-shadow:inset 0 -3px 0 var(--accent);
}
.seg button:focus-visible{outline-offset:-4px;}

.rate{font-size:16px;font-weight:600;color:var(--ink);}
.apr{display:block;font-size:13px;color:var(--ink-faint);margin-top:2px;font-weight:400;}

/* Rate history: hover card on the board, panel in the agent portal. */
.hc-title{margin:0;font-size:15px;font-weight:600;}
.hc-sub{margin:2px 0 8px;font-size:13px;color:var(--ink-muted);}
.history svg{display:block;width:100%;height:auto;}
.hc-grid{stroke:var(--line);stroke-width:1;}
.hc-axis{font:11.5px 'IBM Plex Mono',monospace;fill:var(--ink-faint);}
.hc-line{fill:none;stroke:var(--accent);stroke-width:2;stroke-linejoin:round;stroke-linecap:round;}
.hc-dot{fill:var(--accent);stroke:var(--surface);stroke-width:2;}
.hc-end{font:600 12px 'IBM Plex Mono',monospace;fill:var(--ink);}
.hc-rba{stroke:var(--gold);stroke-width:1.5;}
.hc-rba-label{font:600 11px 'IBM Plex Mono',monospace;fill:var(--ink-muted);}
.hc-legend{display:flex;flex-wrap:wrap;gap:4px 14px;margin-top:4px;font-size:13px;color:var(--ink-muted);}
.hc-key-line{display:inline-block;width:14px;height:2px;margin-right:5px;vertical-align:middle;background:var(--accent);border-radius:1px;}
.hc-key-rba{display:inline-block;width:2px;height:12px;margin-right:6px;vertical-align:middle;background:var(--gold);}
.hc-empty{margin:4px 0 0;font-size:13px;color:var(--ink-muted);}
.history table{width:100%;min-width:0;border-collapse:collapse;margin-top:8px;}
.history td{
  padding:5px 8px 5px 0;
  border-bottom:none;
  border-top:1px solid var(--line);
  font:13px 'Inter',sans-serif;
  color:var(--ink);
  white-space:nowrap;
  vertical-align:top;
  background:none !important;
}
.history td:last-child{padding-right:0;}
.history .num{font-family:'IBM Plex Mono',monospace;font-variant-numeric:tabular-nums;}
.history .delta{color:var(--ink-muted);text-align:right;}
.hc-note{display:block;margin-top:1px;font-size:13px;color:var(--ink-faint);white-space:normal;}
.history .num .hc-note{white-space:nowrap;}
.hc-foot{margin:8px 0 0;font-size:13px;line-height:1.5;color:var(--ink-faint);}

/* Agent rates listed under a lender rate. */
.ar-head{display:flex;justify-content:space-between;align-items:baseline;gap:8px;margin:14px 0 6px;padding-top:12px;border-top:1px solid var(--line);}
.ar-head h3{margin:0;font:600 14px 'Inter',sans-serif;}
.ar-head span{font-size:13px;color:var(--ink-faint);}
.ar-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px;}
.ar-item{border:1px solid var(--line-strong);border-radius:10px;padding:10px 11px;background:var(--bg);}
.ar-item.mine{border-color:var(--accent);border-width:2px;}
.ar-top{display:flex;gap:10px;align-items:flex-start;}
.ar-photo{width:36px;height:36px;border-radius:50%;object-fit:cover;flex:none;background:var(--accent-soft);color:var(--accent);display:flex;align-items:center;justify-content:center;font:700 13px 'Inter',sans-serif;}
.ar-main{flex:1;min-width:0;}
.ar-rates{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap;}
.ar-rate{font:600 17px 'IBM Plex Mono',monospace;color:var(--accent);}
.ar-comp{font:13px 'IBM Plex Mono',monospace;color:var(--ink-faint);}
.ar-below{font-size:13px;font-weight:600;color:var(--accent);}
.ar-who{margin-top:2px;font-size:14px;font-weight:600;color:var(--ink);}
.ar-who span{font-weight:400;color:var(--ink-muted);}
.ar-meta{margin-top:3px;font-size:13px;line-height:1.5;color:var(--ink-muted);}
.ar-actions{display:flex;flex-wrap:wrap;gap:6px;margin-top:9px;}
.ar-actions a, .ar-actions button{font:600 13px 'Inter',sans-serif;}
.ar-contact{margin-top:8px;font-size:14px;}
.ar-contact a{color:var(--accent);font-weight:600;display:inline-flex;align-items:center;min-height:44px;}
.ar-more{margin-top:8px;}
.ar-disclaimer{margin:10px 0 0;font-size:13px;line-height:1.5;color:var(--ink-faint);}

dialog.modal{
  border:1px solid var(--line-strong);
  border-radius:14px;
  padding:0;
  background:var(--surface);
  color:var(--ink);
  box-shadow:var(--shadow);
  max-width:440px;
  width:calc(100% - 32px);
  max-height:calc(100% - 32px);
}
dialog.modal.wide{max-width:580px;}
dialog.modal::backdrop{background:rgba(20,24,32,.55);}
dialog.modal form, dialog.modal .modal-body{padding:22px;display:flex;flex-direction:column;gap:14px;}
dialog.modal h2{margin:0;font-size:21px;font-weight:600;}
dialog.modal h3{margin:6px 0 0;font:600 15px 'Inter',sans-serif;}
.modal-sub{margin:-6px 0 0;font-size:14px;color:var(--ink-muted);line-height:1.5;}
.field{display:flex;flex-direction:column;gap:5px;font-size:14px;font-weight:600;color:var(--ink-muted);}
.field-hint{font-weight:400;color:var(--ink-faint);font-size:13px;}
.field input, .field textarea, .field select{
  font:15px 'Inter',sans-serif;
  font-weight:400;
  color:var(--ink);
  background:var(--bg);
  border:1px solid var(--line-strong);
  border-radius:7px;
  min-height:44px;
  padding:9px 10px;
  resize:vertical;
}
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"]{border:2px solid var(--danger);}
.field-row{display:grid;grid-template-columns:1fr 1fr;gap:12px;align-items:end;}
.check-row{display:flex;align-items:flex-start;gap:10px;font-size:14px;line-height:1.5;color:var(--ink);font-weight:400;min-height:44px;padding:4px 0;}
.check-row input{margin-top:3px;width:20px;height:20px;flex:none;accent-color:var(--accent);}
.pw-wrap{position:relative;display:flex;}
.pw-wrap input{flex:1;padding-right:72px;}
.pw-toggle{
  position:absolute;
  right:2px;
  top:50%;
  transform:translateY(-50%);
  font:14px 'Inter',sans-serif;
  font-weight:600;
  color:var(--accent);
  background:none;
  border:none;
  border-radius:5px;
  min-height:40px;
  min-width:56px;
  padding:5px 8px;
  cursor:pointer;
}
.pw-toggle:hover{background:var(--accent-soft);}
.form-msg{margin:0;font-size:14px;line-height:1.5;}
.form-msg.error{color:var(--danger);font-weight:600;}
.form-msg.ok{color:var(--accent);font-weight:600;}
.form-links{display:flex;justify-content:space-between;flex-wrap:wrap;gap:8px;font-size:14px;color:var(--ink-muted);}
.link-btn{
  background:none;
  border:none;
  padding:0;
  font:inherit;
  color:var(--accent);
  cursor:pointer;
  text-decoration:underline;
  text-underline-offset:2px;
}
/* Standalone link buttons (not inside a sentence) get a full-size tap target. */
.link-btn.solo{display:inline-flex;align-items:center;min-height:44px;font-weight:600;}
.dialog-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:4px;flex-wrap:wrap;}
.btn-ghost, .btn-primary, .btn-danger{
  font:14px 'Inter',sans-serif;
  font-weight:600;
  border-radius:7px;
  min-height:44px;
  min-width:44px;
  padding:8px 16px;
  cursor:pointer;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
}
.btn-sm{padding:8px 12px;font-size:14px;}
.btn-ghost{background:var(--surface);border:1px solid var(--line-strong);color:var(--ink-muted);}
.btn-primary{background:var(--accent);border:1px solid var(--accent);color:var(--on-accent);}
.btn-danger{background:none;border:1px solid var(--danger);color:var(--danger);}
.btn-primary:disabled, .btn-ghost:disabled, .btn-danger:disabled{opacity:.6;cursor:not-allowed;}

footer{
  margin-top:28px;
  padding-top:16px;
  border-top:1px solid var(--line);
  font-size:14px;
  color:var(--ink-faint);
  display:flex;
  justify-content:space-between;
  align-items:center;
  flex-wrap:wrap;
  gap:8px 16px;
}
footer a{color:var(--accent);}
footer nav{display:flex;flex-wrap:wrap;gap:4px 16px;}
footer nav a{display:inline-flex;align-items:center;justify-content:center;min-height:44px;min-width:44px;}

@media (max-width:640px){
  body{padding:20px 16px 40px;}
  .seg{width:100%;}
  .seg button{flex:1 1 0;padding:10px 6px;}
  .field-row{grid-template-columns:1fr;}
  .ar-actions .btn-ghost, .ar-actions .btn-primary{flex:1 1 auto;}
}

@media (max-width:560px){
  .title-block h1{font-size:24px;}
  header.page{flex-direction:column;align-items:flex-start;}
  .header-right{align-items:flex-start;}
  .account{justify-content:flex-start;}
}

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{animation:none !important;transition:none !important;scroll-behavior:auto !important;}
}

/* Windows High Contrast and other forced-colour modes: keep every boundary and the selection visible. */
@media (forced-colors: active){
  .seg, .btn-ghost, .btn-primary, .btn-danger, .ar-item, dialog.modal, .status-line{border:1px solid CanvasText;}
  .seg button[aria-pressed="true"]{outline:3px solid Highlight;outline-offset:-5px;}
  :focus-visible{outline:3px solid Highlight !important;}
  .role-chip{border:1px solid CanvasText;}
}
