/*
 * Realtor Deal Desk — Global Design System
 * Loaded before all per-file <style> blocks. Defines every token, component,
 * and layout primitive. Tab-specific overrides live in their own <style> tags.
 */

/* ════════════════════════════════════════════════════════════════
   1. CSS CUSTOM PROPERTIES
   ════════════════════════════════════════════════════════════════ */

:root {
  /* Surface */
  --bg:             #f8fafc;
  --surface:        #ffffff;
  --surface-border: #e2e8f0;

  /* Brand */
  --accent:         #2563eb;
  --accent-hover:   #1d4ed8;

  /* Semantic */
  --success:        #10b981;
  --warning:        #f59e0b;
  --danger:         #ef4444;

  /* Text */
  --text:           #0f172a;
  --text-muted:     #64748b;

  /* Inputs */
  --input-bg:       #f1f5f9;
  --input-border:   #cbd5e1;

  /* Header / nav — always dark navy regardless of light/dark mode */
  --header-bg:         #0f2044;
  --header-border:     rgba(255, 255, 255, 0.08);
  --nav-bg:            #162756;
  --nav-border:        rgba(255, 255, 255, 0.10);
  --nav-tab-text:      rgba(255, 255, 255, 0.65);
  --nav-tab-hover:     rgba(255, 255, 255, 0.85);
  --nav-tab-active:    #ffffff;
  --nav-tab-active-bg: rgba(255, 255, 255, 0.10);

  /* Tinted alpha fills */
  --success-bg:     rgba(16,  185, 129, 0.10);
  --success-border: rgba(16,  185, 129, 0.25);
  --warning-bg:     rgba(245, 158,  11, 0.10);
  --warning-border: rgba(245, 158,  11, 0.25);
  --danger-bg:      rgba(239,  68,  68, 0.10);
  --danger-border:  rgba(239,  68,  68, 0.20);
  --accent-bg:      rgba( 37,  99, 235, 0.08);
  --accent-border:  rgba( 37,  99, 235, 0.20);

  /* Shape */
  --radius-card:    12px;
  --radius-input:   8px;
  --radius-btn:     8px;

  /* Shadow */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);

  /* Transitions */
  --t-color: 0.2s ease;
  --t-fast:  0.15s ease;
}

html.dark {
  --bg:             #0f1117;
  --surface:        #1a1d27;
  --surface-border: #2d3148;
  --accent:         #3b82f6;
  --accent-hover:   #2563eb;
  --text:           #f1f5f9;
  --text-muted:     #64748b;
  --input-bg:       #1e2235;
  --input-border:   #2d3148;

  --header-bg: #07101f;
  --nav-bg:    #0c1830;

  --accent-bg:     rgba(59, 130, 246, 0.10);
  --accent-border: rgba(59, 130, 246, 0.22);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.30), 0 1px 2px rgba(0, 0, 0, 0.20);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.40);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.60);
}


/* ════════════════════════════════════════════════════════════════
   2. RESET & BASE
   ════════════════════════════════════════════════════════════════ */

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

html {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background var(--t-color), color var(--t-color);
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }


/* ════════════════════════════════════════════════════════════════
   3. TYPOGRAPHY
   ════════════════════════════════════════════════════════════════ */

.font-serif {
  font-family: var(--font-numbers);
}

/* Section headings: 13px all-caps */
.section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
  transition: color var(--t-color);
}

/* Form field labels: 12px */
.field-label,
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
  transition: color var(--t-color);
}


/* ════════════════════════════════════════════════════════════════
   4. SITE HEADER
   ════════════════════════════════════════════════════════════════ */

.site-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background var(--t-color);
}

.site-header__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.site-header__brand       { flex: 0 0 auto; display: flex; align-items: center; }
.site-header__logo        { max-height: 50px; width: auto; object-fit: contain; }
.site-header__brand-text  { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: -0.01em; white-space: nowrap; }

.site-header__center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.site-header__realtor {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.site-header__brokerage-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--nav-tab-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  margin-top: 1px;
}

.site-header__actions { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }

.btn-signout {
  font-size: 13px;
  font-weight: 500;
  color: var(--nav-tab-text);
  padding: 6px 14px;
  border-radius: var(--radius-btn);
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
}
.btn-signout:hover { color: #fff; background: rgba(255,255,255,0.10); border-color: rgba(255,255,255,0.35); }

/* Hamburger (mobile) */
.site-header__hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-btn);
  background: transparent;
  padding: 9px 8px;
  transition: background var(--t-fast), border-color var(--t-fast);
  flex-shrink: 0;
}
.site-header__hamburger:hover { background: rgba(255,255,255,0.10); border-color: rgba(255,255,255,0.35); }
.site-header__hamburger span {
  display: block;
  height: 2px;
  background: rgba(255, 255, 255, 0.80);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.site-header__hamburger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.site-header__hamburger.is-open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.site-header__hamburger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }


/* ════════════════════════════════════════════════════════════════
   5. TAB NAVIGATION
   ════════════════════════════════════════════════════════════════ */

.site-nav {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  transition: background var(--t-color);
}

.site-nav__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: stretch;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.site-nav__inner::-webkit-scrollbar { display: none; }

.nav-tab {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--nav-tab-text);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
  letter-spacing: 0.01em;
}
.nav-tab:hover {
  color: var(--nav-tab-hover);
  background: rgba(255, 255, 255, 0.05);
}
.nav-tab--active {
  color: var(--nav-tab-active);
  border-bottom-color: var(--accent);
  background: var(--nav-tab-active-bg);
}


/* ════════════════════════════════════════════════════════════════
   6. IMPERSONATION BANNER
   ════════════════════════════════════════════════════════════════ */

.impersonation-banner {
  background: #7c3aed;
  color: #fff;
  padding: 10px 24px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.impersonation-banner a { color: #fff; font-weight: 700; text-decoration: underline; transition: opacity var(--t-fast); }
.impersonation-banner a:hover { opacity: 0.75; }


/* ════════════════════════════════════════════════════════════════
   7. LAYOUT SHELL
   ════════════════════════════════════════════════════════════════ */

.site-main {
  flex: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px;
  width: 100%;
}

.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--surface-border);
  padding: 28px 24px;
  transition: background var(--t-color), border-color var(--t-color);
}

.site-footer__inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.site-footer__copyright {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: color var(--t-color);
}

.site-footer__disclaimer {
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-muted);
  max-width: 680px;
  transition: color var(--t-color);
}
.site-footer__disclaimer strong { font-weight: 600; color: var(--text); transition: color var(--t-color); }

.site-footer__legal { font-size: 11px; color: var(--text-muted); }
.site-footer__legal a { color: var(--accent); font-weight: 500; transition: opacity var(--t-fast); }
.site-footer__legal a:hover { opacity: 0.75; }

.site-footer__powered { font-size: 11px; color: var(--text-muted); }
.site-footer__powered a { color: var(--accent); font-weight: 500; transition: opacity var(--t-fast); }
.site-footer__powered a:hover { opacity: 0.75; }


/* ════════════════════════════════════════════════════════════════
   8. CARD
   ════════════════════════════════════════════════════════════════ */

.card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-card);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: background var(--t-color), border-color var(--t-color), box-shadow var(--t-color);
}

.card + .card { margin-top: 16px; }

.card__header {
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  transition: border-color var(--t-color);
}

.card__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  transition: color var(--t-color);
}


/* ════════════════════════════════════════════════════════════════
   9. RESULT HERO  (Net to Seller / loan totals / etc.)
   ════════════════════════════════════════════════════════════════ */

/* The large number itself */
.result-hero {
  font-family: var(--font-numbers);
  font-size: 48px;
  letter-spacing: -0.02em;
  color: var(--success);
  line-height: 1;
  transition: color var(--t-color);
}

/* Card that wraps the hero number */
.result-hero-box {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-card);
  padding: 28px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition:
    background var(--t-color),
    border-color var(--t-color),
    box-shadow var(--t-color);
}

/* Dark mode: success-tinted glow around hero box */
html.dark .result-hero-box {
  border-color: rgba(16, 185, 129, 0.22);
  box-shadow:
    0 0 0 1px rgba(16, 185, 129, 0.20),
    0 0 28px rgba(16, 185, 129, 0.10),
    var(--shadow-md);
}

/* Subtle green gradient wash in top-left of hero box */
.result-hero-box::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-card);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.06) 0%, transparent 55%);
  pointer-events: none;
}

.result-hero-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--text-muted);
  margin-bottom: 10px;
  transition: color var(--t-color);
}

.result-hero-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
  transition: color var(--t-color);
}

/* ── Result rows ─────────────────────────────────────────────────────── */

.result-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--surface-border);
  font-size: 14px;
  transition: border-color var(--t-color);
}
.result-line:last-child { border-bottom: none; }

.result-line__label {
  color: var(--text-muted);
  font-weight: 500;
  transition: color var(--t-color);
}

.result-line__value {
  font-family: var(--font-numbers);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  transition: color var(--t-color);
}

.result-line__value--positive { color: var(--success); }
.result-line__value--negative { color: var(--danger); }
.result-line__value--muted    { color: var(--text-muted); }

.result-line--total {
  border-top: 2px solid var(--surface-border);
  border-bottom: none;
  margin-top: 4px;
  padding-top: 14px;
  font-weight: 700;
}
.result-line--total .result-line__label { color: var(--text); font-size: 15px; }
.result-line--total .result-line__value { font-size: 18px; }

/* Fade-in animation — triggered by JS by toggling class */
.result-fade {
  transition: opacity 0.25s ease;
}
.result-fade.is-updating {
  opacity: 0;
}


/* ════════════════════════════════════════════════════════════════
   10. FORM ELEMENTS
   ════════════════════════════════════════════════════════════════ */

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Base input styles — apply to both .input class and bare elements */
.input,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-input);
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition:
    background var(--t-color),
    border-color var(--t-fast),
    box-shadow var(--t-fast),
    color var(--t-color);
}

.input:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

html.dark .input:focus,
html.dark input:focus,
html.dark select:focus,
html.dark textarea:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.20);
}

/* Custom select arrow */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

textarea { resize: vertical; min-height: 100px; }

/* Input with $ or % symbol */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-symbol {
  position: absolute;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--t-color);
  z-index: 1;
}
.input-symbol--prefix { left: 12px; }
.input-symbol--suffix { right: 12px; }
.input-wrap--prefix .input { padding-left: 24px; }
.input-wrap--suffix .input { padding-right: 30px; }


/* ════════════════════════════════════════════════════════════════
   11. BUTTONS
   ════════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-btn);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background var(--t-fast),
    color var(--t-fast),
    border-color var(--t-fast),
    transform var(--t-fast),
    box-shadow var(--t-fast);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn-secondary:hover:not(:disabled) { background: var(--accent-bg); }

.btn-ghost {
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--input-border);
  transition:
    background var(--t-color),
    color var(--t-color),
    border-color var(--t-color),
    transform var(--t-fast);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-border); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #0ea472; }

.btn-sm  { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.btn-lg  { padding: 13px 28px; font-size: 15px; }
.btn-full { width: 100%; }


/* ════════════════════════════════════════════════════════════════
   12. BADGES
   ════════════════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
  transition: background var(--t-color), color var(--t-color), border-color var(--t-color);
}

.badge--active,
.badge--success  { background: var(--success-bg);  color: var(--success); border: 1px solid var(--success-border); }

.badge--trial,
.badge--accent   { background: var(--accent-bg);   color: var(--accent);  border: 1px solid var(--accent-border); }

.badge--past-due,
.badge--danger   { background: var(--danger-bg);   color: var(--danger);  border: 1px solid var(--danger-border); }

.badge--cancelled,
.badge--muted    { background: var(--input-bg);    color: var(--text-muted); border: 1px solid var(--input-border); }

.badge--warning  { background: var(--warning-bg);  color: var(--warning); border: 1px solid var(--warning-border); }


/* ════════════════════════════════════════════════════════════════
   13. ALERTS
   ════════════════════════════════════════════════════════════════ */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-input);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
  transition: background var(--t-color), border-color var(--t-color), color var(--t-color);
}
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-border); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }


/* ════════════════════════════════════════════════════════════════
   14. DARK MODE TOGGLE
   ════════════════════════════════════════════════════════════════ */

.theme-toggle,
.dark-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-btn);
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    background var(--t-fast),
    border-color var(--t-fast),
    color var(--t-fast);
}
.theme-toggle:hover,
.dark-toggle:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}
.theme-toggle svg,
.dark-toggle svg { display: block; flex-shrink: 0; }

/* Icon visibility swap — fast so the toggle feels snappy */
.icon-sun  { display: none; }
.icon-moon { display: block; }
html.dark .icon-sun  { display: block; }
html.dark .icon-moon { display: none; }


/* ════════════════════════════════════════════════════════════════
   15. TOGGLE BUTTON GROUP  (Yes / No, % / $, term buttons)
   ════════════════════════════════════════════════════════════════ */

.toggle-group {
  display: inline-flex;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-input);
  overflow: hidden;
  transition: border-color var(--t-color);
}

.toggle-btn {
  padding: 8px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--input-bg);
  border: none;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.toggle-btn + .toggle-btn {
  border-left: 1px solid var(--input-border);
}
.toggle-btn.active {
  background: var(--accent);
  color: #ffffff;
}
.toggle-btn:hover:not(.active) {
  background: var(--surface-border);
  color: var(--text);
}


/* ════════════════════════════════════════════════════════════════
   16. STRENGTH BAR  (offer comparison score)
   ════════════════════════════════════════════════════════════════ */

.strength-bar {
  height: 6px;
  background: var(--input-bg);
  border-radius: 3px;
  overflow: hidden;
  transition: background var(--t-color);
}

.strength-bar__fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease, background 0.3s ease;
}

.strength-bar--green  .strength-bar__fill { background: var(--success); }
.strength-bar--yellow .strength-bar__fill { background: var(--warning); }
.strength-bar--red    .strength-bar__fill { background: var(--danger); }

.strength-score         { font-size: 13px; font-weight: 700; min-width: 36px; text-align: right; }
.strength-score--green  { color: var(--success); }
.strength-score--yellow { color: var(--warning); }
.strength-score--red    { color: var(--danger); }


/* ════════════════════════════════════════════════════════════════
   17. AMORTIZATION TABLE
   ════════════════════════════════════════════════════════════════ */

.amort-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 380px;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-input);
  transition: border-color var(--t-color);
}

.amort-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 12px;
}

.amort-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--input-bg);
  border-bottom: 1px solid var(--surface-border);
  padding: 8px 12px;
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
  transition:
    background var(--t-color),
    border-color var(--t-color),
    color var(--t-color);
}
.amort-table thead th:first-child { text-align: left; }

.amort-table tbody td {
  padding: 7px 12px;
  text-align: right;
  border-bottom: 1px solid var(--surface-border);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  transition:
    background var(--t-color),
    border-color var(--t-color),
    color var(--t-color);
}
.amort-table tbody td:first-child {
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
}
.amort-table tbody tr:last-child td { border-bottom: none; }

.amort-table tbody tr:nth-child(even) td { background: rgba(0, 0, 0, 0.018); }
html.dark .amort-table tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.025); }

.amort-table tbody tr:hover td {
  background: rgba(37, 99, 235, 0.04);
}
html.dark .amort-table tbody tr:hover td {
  background: rgba(59, 130, 246, 0.07);
}


/* ════════════════════════════════════════════════════════════════
   18. CALCULATOR LAYOUT
   ════════════════════════════════════════════════════════════════ */

.calc-grid {
  display: grid;
  gap: 24px;
  align-items: start;
}

/* Used for results column to stick while user scrolls inputs */
.calc-results {
  /* sticky top set in responsive block */
}

.calc-section-header {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--surface-border);
  margin-bottom: 20px;
  transition: color var(--t-color), border-color var(--t-color);
}

/* Field grids inside cards */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.field-grid--3 { grid-template-columns: repeat(3, 1fr); }
.field-grid--1 { grid-template-columns: 1fr; }


/* ════════════════════════════════════════════════════════════════
   19. OFFER COMPARISON GRID
   ════════════════════════════════════════════════════════════════ */

.oc-grid {
  display: grid;
  gap: 16px;
  align-items: start;
  transition: grid-template-columns 0.2s ease;
}
.oc-grid[data-count="1"] { grid-template-columns: minmax(0, 500px); }
.oc-grid[data-count="2"] { grid-template-columns: repeat(2, 1fr); }
.oc-grid[data-count="3"] { grid-template-columns: repeat(3, 1fr); }
.oc-grid[data-count="4"] { grid-template-columns: repeat(4, 1fr); }

/* Score bars in offer cards */
.oc-score-bar {
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--input-bg);
  transition: background var(--t-color);
}
.oc-score-bar__fill { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.oc-score-bar--green  .oc-score-bar__fill { background: var(--success); }
.oc-score-bar--yellow .oc-score-bar__fill { background: var(--warning); }
.oc-score-bar--red    .oc-score-bar__fill { background: var(--danger); }


/* ════════════════════════════════════════════════════════════════
   20. ADMIN STAT CARDS
   ════════════════════════════════════════════════════════════════ */

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.admin-stat-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-card);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  transition:
    background var(--t-color),
    border-color var(--t-color),
    box-shadow var(--t-color);
}

.admin-stat-card__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
  transition: color var(--t-color);
}

.admin-stat-card__value {
  font-size: 36px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  transition: color var(--t-color);
}

.admin-stat-card__value--accent  { color: var(--accent); }
.admin-stat-card__value--success { color: var(--success); }
.admin-stat-card__value--warning { color: var(--warning); }
.admin-stat-card__value--danger  { color: var(--danger); }


/* ════════════════════════════════════════════════════════════════
   21. UTILITIES
   ════════════════════════════════════════════════════════════════ */

/* Screen reader only */
.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;
}

/* Text colors */
.text-muted   { color: var(--text-muted) !important; }
.text-accent  { color: var(--accent)     !important; }
.text-success { color: var(--success)    !important; }
.text-warning { color: var(--warning)    !important; }
.text-danger  { color: var(--danger)     !important; }

/* Spacing */
.mt-8  { margin-top:  8px; }
.mt-16 { margin-top:  16px; }
.mt-24 { margin-top:  24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

/* Divider */
.divider {
  height: 1px;
  background: var(--surface-border);
  margin: 20px 0;
  transition: background var(--t-color);
}

/* Hidden */
.hidden { display: none !important; }

/* Print-only elements hidden on screen */
.print-header,
.print-footer { display: none; }


/* ════════════════════════════════════════════════════════════════
   22. RESPONSIVE BREAKPOINTS
   ════════════════════════════════════════════════════════════════ */

/* ── Two-column layout: inputs | results ─────────────────────── */
@media (min-width: 900px) {
  .calc-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Wider inputs column for content-heavy calculators */
  .calc-grid--wide {
    grid-template-columns: 7fr 5fr;
  }

  /* Results column sticks while scrolling through inputs */
  .calc-results {
    position: sticky;
    top: calc(64px + 49px + 32px); /* header height + nav height + page padding */
  }
}

/* ── Tablet: single column, full-width ───────────────────────── */
@media (min-width: 600px) and (max-width: 899px) {
  .calc-grid,
  .calc-grid--wide {
    grid-template-columns: 1fr;
  }

  .calc-results {
    position: static;
  }

  /* Offer comparison: 3-4 cols collapse to 2 cols horizontal scroll */
  .oc-grid[data-count="3"],
  .oc-grid[data-count="4"] {
    grid-template-columns: repeat(2, 1fr);
  }

  .field-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .site-header__inner { padding: 0 16px; }
  .site-header__center { display: none; }
  .btn-signout { display: none; }
  .site-header__hamburger { display: flex; }
  .site-nav { display: none; }
  .site-nav.is-open { display: block; }
  .site-nav__inner {
    flex-direction: column;
    padding: 6px 0;
    gap: 0;
  }
  .nav-tab {
    padding: 14px 20px;
    border-bottom-color: transparent;
    border-left: 3px solid transparent;
  }
  .nav-tab--active {
    border-bottom-color: transparent;
    border-left-color: var(--accent);
  }
  .site-main { padding: 20px 16px; }
}

@media (max-width: 599px) {
  /* Enforce 44px minimum touch targets */
  .btn         { min-height: 44px; }
  .toggle-btn  { min-height: 40px; padding: 10px 14px; }
  .input,
  input,
  select       { min-height: 44px; }

  .card { padding: 16px; }

  .calc-grid,
  .calc-grid--wide { grid-template-columns: 1fr; gap: 16px; }

  .field-grid    { grid-template-columns: 1fr; }
  .field-grid--3 { grid-template-columns: 1fr 1fr; }

  .result-hero { font-size: 36px; }

  /* Offer comparison: horizontal scroll snap, max 2 visible */
  .oc-grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 12px;
    padding-bottom: 8px;
    /* remove grid constraints */
    grid-template-columns: none;
  }
  .oc-grid > * {
    flex: 0 0 88vw;
    max-width: 360px;
    scroll-snap-align: start;
  }

  /* Admin stat grid: 2 columns on small screens */
  .admin-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .admin-stat-card { padding: 14px 16px; }
  .admin-stat-card__value { font-size: 28px; }
}


/* ════════════════════════════════════════════════════════════════
   23. DRAG-TO-REORDER
   ════════════════════════════════════════════════════════════════ */

/* All draggable cards need a positioning context */
[data-card-id] { position: relative; }

/* Grip handle — shared base */
.rdd-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: grab;
  opacity: 0;
  transition: opacity .15s ease, background .15s ease;
  user-select: none;
  flex-shrink: 0;
}
.rdd-drag-handle:hover  { background: var(--input-bg); opacity: 1 !important; }
.rdd-drag-handle:active { cursor: grabbing; }

/* Absolute variant — top-right corner of panel cards */
.rdd-drag-handle--abs {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 2;
}

/* Inline variant — inside offer-compare column header */
.rdd-drag-handle--col {
  width: 20px;
  height: 20px;
}

/* Show handle at low opacity on card hover */
[data-card-id]:hover .rdd-drag-handle { opacity: .45; }

/* Card being dragged: dim it so the drop target is obvious */
[data-card-id].rdd-dragging { opacity: .35; }

/* Hide handles on print */
@media print { .rdd-drag-handle { display: none !important; } }


/* ════════════════════════════════════════════════════════════════
   24. PRINT STYLES
   ════════════════════════════════════════════════════════════════ */

@media print {

  /* ── Page geometry ──────────────────────────────────────────── */
  @page {
    size: letter;
    margin: 16mm 18mm 28mm 18mm; /* extra bottom for footer */
  }

  /* ── Colour reset: white page, black ink ────────────────────── */
  * {
    background: #ffffff !important;
    color: #000000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    transition: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* ── Hide placeholder text — empty fields print blank ───────── */
  input::placeholder,
  textarea::placeholder {
    color: transparent !important;
  }

  html, body {
    font-size: 10pt;
    background: #ffffff !important;
    min-height: 0;
  }

  /* ── Hide chrome ────────────────────────────────────────────── */
  .site-header,
  .site-nav,
  .site-footer,
  .theme-toggle,
  .dark-toggle,
  .btn,
  .btn-primary,
  .btn-secondary,
  .btn-ghost,
  .btn-danger,
  .btn-success,
  button,
  [class*="btn-"],
  input[type="submit"],
  input[type="button"],
  input[type="reset"],
  .toggle-group,
  .toggle-btn,
  .impersonation-banner,
  .print-hide {
    display: none !important;
  }

  /* ── Show print-only header ─────────────────────────────────── */
  .print-header {
    display: block !important;
    margin-bottom: 20pt;
    padding-bottom: 10pt;
    border-bottom: 1.5pt solid #000000;
    overflow: hidden; /* clear float */
  }

  .print-header__logo {
    max-height: 44pt;
    width: auto;
    float: left;
    margin-right: 12pt;
    margin-bottom: 4pt;
  }

  .print-header__name {
    font-size: 14pt;
    font-weight: 700;
    margin-bottom: 2pt;
  }

  .print-header__brokerage {
    font-size: 9.5pt;
    margin-bottom: 1pt;
  }

  .print-header__phone {
    font-size: 9.5pt;
    margin-bottom: 8pt;
  }

  .print-header__prepared {
    font-size: 9pt;
    font-style: italic;
    clear: both;
    border-top: 0.5pt solid #aaaaaa;
    padding-top: 6pt;
    margin-top: 6pt;
  }

  .print-header__date {
    float: right;
    font-size: 9pt;
  }

  /* ── Repeating footer on every page ────────────────────────── */
  .print-footer {
    display: block !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    font-size: 7pt;
    line-height: 1.5;
    text-align: center;
    padding: 4pt 12pt;
    border-top: 0.5pt solid #cccccc;
  }

  /* ── Layout ─────────────────────────────────────────────────── */
  .site-main {
    padding: 0;
    max-width: 100%;
  }

  /* Two-column grids stay two columns on letter paper */
  .calc-grid,
  .calc-grid--wide {
    grid-template-columns: 1fr 1fr;
    gap: 14pt;
  }

  /* Results column no longer sticky */
  .calc-results { position: static; }

  /* ── Cards ──────────────────────────────────────────────────── */
  .card {
    border: 0.5pt solid #cccccc !important;
    border-radius: 4pt;
    padding: 10pt;
    margin-bottom: 10pt;
    box-shadow: none !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* ── Result displays ────────────────────────────────────────── */
  .result-hero {
    font-size: 26pt;
    font-family: var(--font-numbers);
  }

  .result-hero-box {
    border: 1.5pt solid #000000 !important;
    border-radius: 4pt;
    padding: 10pt 12pt;
    text-align: center;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .result-hero-box::before { display: none; } /* remove gradient in print */

  .result-line {
    border-bottom: 0.25pt solid #cccccc !important;
    padding: 4pt 0;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .result-line__value {
    font-family: var(--font-numbers);
    font-size: 11pt;
  }

  .result-line--total {
    border-top: 1pt solid #000000 !important;
    font-weight: 700;
  }

  /* ── Amortization table ─────────────────────────────────────── */
  .amort-wrap {
    max-height: none;
    overflow: visible;
    border: 0.5pt solid #cccccc !important;
  }

  .amort-table thead th {
    background: #f0f0f0 !important;
    border-bottom: 0.5pt solid #000000 !important;
    font-size: 8pt;
    padding: 4pt 8pt;
  }

  .amort-table tbody td {
    font-size: 8pt;
    padding: 3pt 8pt;
    border-bottom: 0.25pt solid #dddddd !important;
  }

  .amort-table tbody tr:nth-child(even) td {
    background: #f8f8f8 !important;
  }

  /* ── Sections stay together ─────────────────────────────────── */
  section,
  .result-hero-box,
  .amort-wrap,
  table,
  thead { page-break-inside: avoid; break-inside: avoid; }

  h2, h3, h4 { page-break-after: avoid; break-after: avoid; }

  /* ── Badges become plain text boxes ────────────────────────── */
  .badge {
    border: 0.5pt solid #999999 !important;
    border-radius: 2pt;
    padding: 1pt 4pt;
    font-size: 8pt;
  }
}
