/* Canadian Mortgage Pro — Professional UI */

:root {
  --red:    #c0392b;
  --red-dk: #922b21;
  --white:  #ffffff;
  --bg:     #f4f5f7;
  --card:   #ffffff;
  --border: #dde1e7;
  --text:   #1a1a2e;
  --muted:  #6b7280;
  --success: #16a34a;
  --warn:    #ca8a04;
  --danger:  #dc2626;
  --radius:  8px;
  --shadow:  0 1px 4px rgba(0,0,0,.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Header ─────────────────────────────────────────────────────────── */
header {
  background: var(--red);
  color: var(--white);
  padding: 0 1.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.logo { display: flex; align-items: center; gap: .75rem; }
.logo-icon {
  background: var(--white);
  color: var(--red);
  font-weight: 800;
  font-size: 1rem;
  border-radius: 6px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-title { font-weight: 700; font-size: 1rem; }
.logo-sub   { font-size: .75rem; opacity: .85; }

nav { display: flex; gap: .25rem; }
.nav-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.85);
  padding: .5rem .9rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: .85rem;
  transition: background .15s;
}
.nav-btn:hover  { background: rgba(255,255,255,.15); }
.nav-btn.active { background: rgba(255,255,255,.25); color: var(--white); font-weight: 600; }

/* ── Main / Tabs ─────────────────────────────────────────────────────── */
main {
  max-width: 1200px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
}
.tab { display: none; }
.tab.active { display: block; }

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.card h2 { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; color: var(--text); }
.card h3 { font-size: .9rem; font-weight: 600; margin-bottom: .5rem; }
.hint { font-size: .8rem; color: var(--muted); margin-bottom: 1rem; margin-top: -.5rem; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
@media (max-width: 768px) { .two-col { grid-template-columns: 1fr; } }

/* ── Forms ───────────────────────────────────────────────────────────── */
.form-row { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; }
.form-row label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.form-row input, .form-row select {
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--text);
  background: var(--white);
  transition: border-color .15s;
  width: 100%;
}
.form-row input:focus, .form-row select:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(192,57,43,.15);
}
.checkbox-row { flex-direction: row; align-items: center; }
.checkbox-row label { font-size: .85rem; color: var(--text); font-weight: 500; }
.checkbox-row input[type=checkbox] { width: auto; margin-right: .4rem; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary {
  padding: .6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  transition: background .15s, transform .1s;
  margin-right: .5rem;
  margin-top: .25rem;
}
.btn-primary {
  background: var(--red);
  color: var(--white);
}
.btn-primary:hover  { background: var(--red-dk); }
.btn-primary:active { transform: scale(.98); }
.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: var(--bg); }

/* ── Result Grid ─────────────────────────────────────────────────────── */
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.result-item { padding: .75rem 1rem; background: var(--bg); border-radius: var(--radius); }
.result-label { font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.result-value { font-size: 1.1rem; font-weight: 700; margin-top: .1rem; }
.result-value.big { font-size: 1.4rem; color: var(--red); }
.result-value.pass { color: var(--success); }
.result-value.fail { color: var(--danger); }

/* ── Tables ─────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th {
  background: var(--bg);
  text-align: left;
  padding: .6rem .75rem;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
td {
  padding: .55rem .75rem;
  border-bottom: 1px solid var(--border);
}
tr:hover td { background: #fef9f9; }
.highlight td { background: #fff0f0; font-weight: 600; }

/* ── LTT Result ──────────────────────────────────────────────────────── */
.ltt-row { display: flex; justify-content: space-between; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.ltt-row:last-child { border: none; font-weight: 700; font-size: 1rem; }
.ltt-label { color: var(--muted); font-size: .85rem; }
.ltt-amount { font-weight: 600; }
.ltt-notes { margin-top: .75rem; font-size: .8rem; color: var(--muted); }

/* ── Insurance ───────────────────────────────────────────────────────── */
.ins-provider {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: .75rem;
}
.ins-provider.eligible { border-left: 4px solid var(--success); }
.ins-provider.ineligible { border-left: 4px solid var(--danger); opacity: .7; }
.ins-name { font-weight: 700; margin-bottom: .4rem; }
.ins-detail { font-size: .82rem; color: var(--muted); }
.ins-premium { font-size: 1.1rem; font-weight: 700; color: var(--red); }

/* ── Stress Test ─────────────────────────────────────────────────────── */
.stress-gauge {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .75rem;
  padding: .75rem 1rem;
  background: var(--bg);
  border-radius: var(--radius);
}
.gauge-label { font-size: .8rem; font-weight: 600; color: var(--muted); flex: 1; }
.gauge-value { font-size: 1.1rem; font-weight: 700; }
.gauge-bar-wrap { flex: 2; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.gauge-bar { height: 100%; border-radius: 4px; transition: width .4s; }
.gauge-bar.pass { background: var(--success); }
.gauge-bar.warn { background: var(--warn); }
.gauge-bar.fail { background: var(--danger); }
.status-badge {
  display: inline-block;
  padding: .25rem .75rem;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 700;
}
.status-badge.approved { background: #dcfce7; color: var(--success); }
.status-badge.declined { background: #fee2e2; color: var(--danger); }

/* ── AI Advisor ───────────────────────────────────────────────────────── */
.advisor-card { max-width: 900px; margin: 0 auto; }
.badge {
  font-size: .72rem;
  font-weight: 600;
  padding: .15rem .5rem;
  border-radius: 20px;
  margin-left: .5rem;
}
.badge.ready    { background: #dcfce7; color: var(--success); }
.badge.offline  { background: #fee2e2; color: var(--danger); }
.badge.checking { background: #fef9c3; color: var(--warn); }

#chat-history {
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: .5rem 0;
}
.chat-msg {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  line-height: 1.6;
  max-width: 90%;
  white-space: pre-wrap;
}
.chat-msg.user {
  background: var(--red);
  color: var(--white);
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}
.chat-msg.advisor {
  background: var(--bg);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}
.chat-meta { font-size: .72rem; color: var(--muted); margin-top: .3rem; }

.chat-input-row { display: flex; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
#chat-input {
  flex: 1;
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  resize: vertical;
  font-family: inherit;
}
#chat-input:focus { outline: none; border-color: var(--red); }

.chip-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .3rem .75rem;
  font-size: .78rem;
  cursor: pointer;
  transition: background .15s;
}
.chip:hover { background: #fce9e9; border-color: var(--red); color: var(--red); }

/* ── Loading ────────────────────────────────────────────────────────── */
#loading {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.spinner {
  width: 40px; height: 40px;
  border: 4px solid rgba(255,255,255,.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Rate Banner ─────────────────────────────────────────────────── */
#rate-banner {
  background: #1a1a2e;
  color: rgba(255,255,255,.9);
  font-size: .78rem;
  padding: .35rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
#rate-banner-inner {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.rate-pill {
  display: flex;
  align-items: center;
  gap: .3rem;
}
.rate-pill-label { opacity: .65; }
.rate-pill-value { font-weight: 700; font-family: monospace; font-size: .82rem; }
.rate-pill-value.up   { color: #f87171; }
.rate-pill-value.down { color: #4ade80; }
.rate-stale { opacity: .5; font-style: italic; }
#btn-refresh-rates {
  background: none;
  border: 1px solid rgba(255,255,255,.3);
  color: white;
  border-radius: 4px;
  padding: .15rem .5rem;
  cursor: pointer;
  font-size: .9rem;
  flex-shrink: 0;
}
#btn-refresh-rates:hover { background: rgba(255,255,255,.1); }

/* ── Live Rates Grid ──────────────────────────────────────────────── */
.rate-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
}
.rate-row:last-child { border: none; }
.rate-row-label { font-size: .85rem; color: var(--muted); }
.rate-row-value { font-weight: 700; font-size: 1rem; }
.rate-row-sub   { font-size: .72rem; color: var(--muted); }

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert-severity-warning  { color: var(--warn);   font-weight: 700; }
.alert-severity-critical { color: var(--danger); font-weight: 700; }
.alert-severity-info     { color: #2563eb;       font-weight: 700; }

/* ── Policy panel ─────────────────────────────────────────────────── */
.policy-item {
  background: var(--bg);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin-bottom: .6rem;
  font-size: .85rem;
}
.policy-item h4 { font-size: .8rem; color: var(--muted); font-weight: 600; margin-bottom: .3rem; }
.policy-stale { background: #fefce8; border-left: 3px solid var(--warn); }
.policy-ok    { border-left: 3px solid var(--success); }

/* ── Spread controls ──────────────────────────────────────────────── */
.spread-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .5rem;
}
.spread-row label { width: 200px; font-size: .85rem; }
.spread-row input { width: 100px; padding: .3rem .5rem; border: 1px solid var(--border); border-radius: 4px; }
.spread-row button { padding: .3rem .6rem; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; }
.spread-row button:hover { background: #fce9e9; border-color: var(--red); }

/* ── Footer ────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1.5rem;
  font-size: .78rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* ── Advanced Calculator Tab ────────────────────────────────────────── */
.adv-tier-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 960px) {
  .adv-tier-grid { grid-template-columns: 1fr; }
}

.tier-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--border);
}
.tier-card.qualify  { border-top-color: var(--success); }
.tier-card.partial  { border-top-color: var(--warn); }
.tier-card.declined { border-top-color: var(--danger); opacity: .85; }

.tier-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .75rem;
}
.tier-label { font-weight: 700; font-size: 1rem; }
.tier-status-badge {
  font-size: .72rem;
  font-weight: 700;
  padding: .2rem .6rem;
  border-radius: 12px;
}
.tier-status-badge.qualify  { background: #dcfce7; color: var(--success); }
.tier-status-badge.partial  { background: #fef9c3; color: var(--warn); }
.tier-status-badge.declined { background: #fee2e2; color: var(--danger); }

.tier-rate    { font-size: 2rem; font-weight: 800; color: var(--red); margin-bottom: .15rem; }
.tier-payment { font-size: 1.05rem; font-weight: 700; color: var(--text); margin-bottom: .75rem; }

.tier-row {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  padding: .3rem 0;
  border-bottom: 1px solid var(--border);
}
.tier-row:last-of-type { border: none; }
.tier-row-label { color: var(--muted); }
.tier-row-value { font-weight: 600; }
.tier-row-value.pass { color: var(--success); }
.tier-row-value.fail { color: var(--danger); }
.tier-row-value.warn { color: var(--warn); }

.tier-decline-reasons {
  margin-top: .65rem;
  font-size: .8rem;
  color: var(--danger);
  background: #fee2e2;
  border-radius: var(--radius);
  padding: .5rem .75rem;
}
.tier-decline-reasons ul { padding-left: 1.1rem; margin-top: .2rem; }
.tier-decline-reasons li { margin-bottom: .2rem; }

.tier-lenders {
  margin-top: .75rem;
  font-size: .8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: .6rem;
}
.tier-lenders strong { color: var(--text); }

.tier-recommendation {
  margin-top: .65rem;
  font-size: .8rem;
  font-style: italic;
  color: var(--muted);
  border-left: 3px solid var(--border);
  padding-left: .6rem;
  line-height: 1.5;
}

.tier-flags { margin-top: .5rem; }
.tier-flag {
  font-size: .77rem;
  background: #fef9c3;
  border-left: 3px solid var(--warn);
  border-radius: 4px;
  padding: .3rem .6rem;
  margin-bottom: .3rem;
  line-height: 1.4;
  color: #78350f;
}

.adv-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
  margin-bottom: .85rem;
}
@media (max-width: 768px) { .adv-summary-grid { grid-template-columns: 1fr 1fr; } }

.adv-insurance-flag {
  background: #fefce8;
  border: 1px solid #fde047;
  border-radius: var(--radius);
  padding: .5rem .85rem;
  font-size: .85rem;
  margin-bottom: .65rem;
  color: #713f12;
}

.adv-client-summary {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: var(--radius);
  padding: .9rem 1rem;
  font-size: .88rem;
  line-height: 1.65;
  margin-bottom: .75rem;
}
.adv-client-summary.not-qualified {
  background: #fef2f2;
  border-color: #fca5a5;
}

.adv-recommended-path {
  font-size: .92rem;
  font-weight: 700;
  margin-top: .25rem;
}

.adv-note {
  font-size: .82rem;
  color: var(--muted);
  padding: .4rem 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}
.adv-note:last-child { border: none; }

.adv-section-title {
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--red);
  margin: 1.1rem 0 .6rem;
  padding-bottom: .3rem;
  border-bottom: 2px solid #fce9e9;
}

/* nav wraps on small screens now that there are 7 buttons */
nav { flex-wrap: wrap; }

/* Down Payment Tier Table */
.adv-dp-tiers {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .75rem;
  margin-top: .4rem;
}
.adv-dp-tier-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: .75rem;
  font-size: .8rem;
  padding: .3rem 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.adv-dp-tier-row:last-child { border: none; }
.adv-dp-tier-row .pass { color: var(--success); font-weight: 600; }
.adv-dp-tier-row .fail { color: var(--danger); font-weight: 600; }

/* ── Advanced: Rate Override Panel ─────────────────────────────────── */
#adv-rate-overrides summary {
  cursor: pointer;
  font-size: .82rem;
  color: var(--muted);
  padding: .35rem 0;
  user-select: none;
}
#adv-rate-overrides summary:hover { color: var(--text); }

/* ── Advanced: Enhancements (amort chart, cash-to-close, max mortgage) */
#adv-chart-card canvas { max-height: 280px; }
.adv-closing-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .5rem;
  padding: .35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
  align-items: center;
}
.adv-closing-row:last-child { border: none; font-weight: 700; }
.adv-max-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .75rem;
  margin-top: .5rem;
}
.adv-max-cell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .75rem;
  text-align: center;
}
.adv-max-cell .label { font-size: .76rem; color: var(--muted); }
.adv-max-cell .value { font-size: 1.1rem; font-weight: 700; margin-top: .2rem; }

/* ── Rental Worksheet ──────────────────────────────────────────────── */
.rent-unit-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: .5rem;
  align-items: center;
  padding: .3rem 0;
  border-bottom: 1px solid var(--border);
}
.rent-unit-row:last-child { border: none; }
.rent-unit-row input { font-size: .85rem; padding: .3rem .5rem; }
.rent-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .75rem;
  margin-top: .5rem;
}
.rent-metric-cell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .75rem;
  text-align: center;
}
.rent-metric-cell .label { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.rent-metric-cell .value { font-size: 1.05rem; font-weight: 700; margin-top: .25rem; }
.rent-metric-cell .rating { font-size: .72rem; margin-top: .15rem; font-weight: 600; }
.rating-below   { color: var(--danger); }
.rating-average { color: var(--warn); }
.rating-good    { color: var(--success); }
.rating-excellent { color: #0284c7; }
.rating-poor    { color: var(--danger); }
.rating-acceptable { color: var(--warn); }
.rating-strong  { color: #0284c7; }
.rating-na      { color: var(--muted); }

.rent-qual-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: .75rem;
}
@media (max-width: 800px) {
  .rent-qual-grid { grid-template-columns: 1fr; }
}
.rent-qual-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem;
  background: var(--card);
}
.rent-qual-card.qualify  { border-color: var(--success); }
.rent-qual-card.partial  { border-color: var(--warn); }
.rent-qual-card.declined { border-color: var(--danger); }
.rent-qual-title {
  font-weight: 700;
  font-size: .88rem;
  margin-bottom: .4rem;
  line-height: 1.3;
}
.rent-qual-row {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  padding: .2rem 0;
  border-bottom: 1px solid var(--border);
}
.rent-qual-row:last-child { border: none; }
.rent-explanation {
  font-size: .78rem;
  color: var(--muted);
  margin-top: .5rem;
  line-height: 1.45;
}
.rent-doc-list { list-style: none; padding: 0; }
.rent-doc-list li {
  padding: .3rem 0 .3rem 1.25rem;
  position: relative;
  font-size: .85rem;
  border-bottom: 1px solid var(--border);
}
.rent-doc-list li:last-child { border: none; }
.rent-doc-list li::before { content: '✓'; position: absolute; left: 0; color: var(--success); font-weight: 700; }
.rent-lender-note {
  background: #fffbeb;
  border-left: 3px solid var(--warn);
  padding: .5rem .75rem;
  font-size: .83rem;
  margin-bottom: .4rem;
  border-radius: 0 4px 4px 0;
}

/* ── Renewal Calculator ────────────────────────────────────────────── */
.renewal-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: .75rem;
}
@media (max-width: 600px) { .renewal-compare-grid { grid-template-columns: 1fr; } }
.renewal-col {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
}
.renewal-col-title { font-weight: 700; font-size: .88rem; margin-bottom: .4rem; }
.renewal-col-pmt   { font-size: 1.4rem; font-weight: 800; }
.renewal-savings-badge {
  display: inline-block;
  padding: .35rem .75rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: .95rem;
  margin: .5rem 0;
}
.renewal-savings-badge.positive { background: #dcfce7; color: var(--success); }
.renewal-savings-badge.negative { background: #fee2e2; color: var(--danger); }
.renewal-rec-card {
  border-radius: var(--radius);
  padding: .9rem 1rem;
  margin-top: .75rem;
  font-weight: 600;
}
.renewal-rec-card.switch { background: #dcfce7; border: 1px solid var(--success); color: #15803d; }
.renewal-rec-card.stay   { background: #fef9c3; border: 1px solid var(--warn); color: #92400e; }
.renewal-rec-card.renew  { background: #e0f2fe; border: 1px solid #0284c7; color: #0c4a6e; }
.renewal-detail { font-size: .84rem; margin-top: .4rem; font-weight: 400; line-height: 1.5; }
.renewal-penalty-row {
  display: flex;
  justify-content: space-between;
  font-size: .85rem;
  padding: .3rem 0;
  border-bottom: 1px solid var(--border);
}
.renewal-penalty-row:last-child { border: none; }

/* ── Tooltips ──────────────────────────────────────────────────────── */
.tip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #94a3b8;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  cursor: help;
  margin-left: 5px;
  flex-shrink: 0;
  vertical-align: middle;
  transition: background .15s;
  user-select: none;
}
.tip-icon:hover { background: var(--red); }
#tip-bubble {
  display: none;
  position: fixed;
  background: #1e293b;
  color: #f1f5f9;
  padding: 10px 14px;
  border-radius: 9px;
  font-size: .8rem;
  line-height: 1.55;
  max-width: 280px;
  z-index: 9999;
  box-shadow: 0 8px 28px rgba(0,0,0,.35);
  pointer-events: none;
  border: 1px solid rgba(255,255,255,.08);
}
#tip-bubble.visible { display: block; }
#tip-bubble strong { color: #93c5fd; }

/* ── Field-level error states ──────────────────────────────────────── */
.form-row.has-error input,
.form-row.has-error select,
.form-row.has-error textarea {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(220,38,38,.12) !important;
}
.field-error-msg {
  font-size: .75rem;
  color: var(--danger);
  font-weight: 500;
  margin-top: .2rem;
  display: none;
  line-height: 1.4;
}
.form-row.has-error .field-error-msg { display: block; }

/* ── Toast notifications ────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 1.1rem;
  right: 1.1rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: 380px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .85rem 1rem;
  border-radius: 9px;
  font-size: .85rem;
  line-height: 1.5;
  box-shadow: 0 6px 20px rgba(0,0,0,.28);
  animation: toastSlideIn .22s ease;
  pointer-events: all;
  color: #fff;
}
.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: .05rem; }
.toast-body { flex: 1; }
.toast-title { font-weight: 700; margin-bottom: .15rem; }
.toast-msg   { opacity: .9; font-size: .82rem; }
.toast-close { cursor: pointer; opacity: .65; flex-shrink: 0; font-size: 1rem; margin-left: .25rem; padding: 0 .1rem; }
.toast-close:hover { opacity: 1; }
.toast-error   { background: #7f1d1d; border-left: 4px solid #ef4444; }
.toast-success { background: #14532d; border-left: 4px solid #22c55e; }
.toast-warn    { background: #78350f; border-left: 4px solid #f59e0b; }
.toast-info    { background: #1e3a5f; border-left: 4px solid #60a5fa; }
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Guide / Policies tab ───────────────────────────────────────────── */
.guide-layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 700px) {
  .guide-layout { grid-template-columns: 1fr; }
  .guide-sidebar { position: static; }
}
.guide-sidebar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem 0 .75rem;
  position: sticky;
  top: 76px;
  box-shadow: var(--shadow);
}
.guide-sidebar-section {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  padding: .85rem 1rem .3rem;
}
.guide-sidebar-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: .5rem 1rem;
  font-size: .83rem;
  cursor: pointer;
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--text);
  transition: all .15s;
  line-height: 1.35;
}
.guide-sidebar-item:hover  { background: var(--bg); color: var(--red); }
.guide-sidebar-item.active { border-left-color: var(--red); color: var(--red); font-weight: 600; background: #fff5f5; }
.guide-content .card { margin-bottom: 0; }
.guide-topic { display: none; }
.guide-topic.active { display: block; }
.guide-topic h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: .35rem; }
.guide-topic .guide-subtitle { color: var(--muted); font-size: .88rem; margin-bottom: 1.1rem; }
.guide-topic h3 { font-size: .95rem; font-weight: 700; color: var(--red); margin: 1.3rem 0 .4rem; }
.guide-topic p  { font-size: .88rem; line-height: 1.75; margin-bottom: .7rem; color: var(--text); }
.guide-topic ul, .guide-topic ol { font-size: .88rem; line-height: 1.75; padding-left: 1.4rem; margin-bottom: .75rem; }
.guide-topic li { margin-bottom: .3rem; }
.guide-callout {
  border-radius: 7px;
  padding: .8rem 1rem;
  font-size: .855rem;
  line-height: 1.65;
  margin: .85rem 0;
  border-left: 4px solid;
}
.guide-callout.info    { background: #eff6ff; border-color: #2563eb; color: #1e3a5f; }
.guide-callout.warn    { background: #fffbeb; border-color: #d97706; color: #78350f; }
.guide-callout.success { background: #f0fdf4; border-color: #16a34a; color: #14532d; }
.guide-callout.danger  { background: #fef2f2; border-color: #dc2626; color: #7f1d1d; }
.guide-table { width: 100%; border-collapse: collapse; font-size: .84rem; margin: .85rem 0; }
.guide-table th { background: var(--bg); padding: .5rem .7rem; text-align: left; border: 1px solid var(--border); font-weight: 700; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.guide-table td { padding: .5rem .7rem; border: 1px solid var(--border); vertical-align: top; }
.guide-table tr:nth-child(even) td { background: var(--bg); }
.guide-tag { display: inline-block; padding: .15em .55em; border-radius: 4px; font-size: .75rem; font-weight: 600; margin-right: .25rem; }
.guide-tag.green { background: #dcfce7; color: #166534; }
.guide-tag.yellow{ background: #fef9c3; color: #854d0e; }
.guide-tag.orange{ background: #ffedd5; color: #9a3412; }
.guide-tag.red   { background: #fee2e2; color: #991b1b; }
.guide-tag.blue  { background: #dbeafe; color: #1e40af; }

/* ── Print Media Query ─────────────────────────────────────────────── */
@media print {
  #rate-banner, header nav, .nav-btn, #adv-form, #adv-reset,
  #adv-print-btn, footer, .btn-primary, .btn-secondary,
  #adv-rate-overrides { display: none !important; }
  .tab { display: block !important; }
  section:not(#tab-advanced) { display: none !important; }
  .tier-card { break-inside: avoid; }
  body { font-size: 12px; }
  main { padding: 0; max-width: 100%; }
  .card { box-shadow: none; border: 1px solid #ccc; margin-bottom: .5rem; }
}
