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

:root {
  --bg: #F4F2EE;
  --surface: #FFFFFF;
  --ink: #171717;
  --ink-2: #3D3D3D;
  --ink-3: #757575;
  --border: rgba(0, 0, 0, 0.1);
  --border-md: rgba(0, 0, 0, 0.16);
  --accent: #C9A84C;
  --accent-pale: rgba(201, 168, 76, 0.11);
  --accent-glow: rgba(201, 168, 76, 0.22);
  --brand: #1B2A4A;
  --green: #00A86B;
  --danger: #D94040;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.1);
  --font-head: 'Montserrat', sans-serif;
  --font-body: 'Inter', sans-serif;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--brand);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2);
}

.app-header-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.app-brand {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.app-url {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-phase-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(201, 168, 76, 0.12);
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: 18px;
  padding: 6px 11px;
}

.notes-toggle-btn {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 13px;
  cursor: pointer;
}

.app-main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 26px 24px 44px;
}

.intro-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.intro-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}

.intro-title {
  font-family: var(--font-head);
  font-size: clamp(26px, 3.4vw, 42px);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: -0.025em;
  max-width: 700px;
}

.intro-sub {
  max-width: 350px;
  font-size: 14px;
  color: var(--ink-3);
}

.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.calc-card {
  padding: 22px;
  margin-bottom: 16px;
}

.calc-hero {
  border-radius: var(--radius-md);
  background: var(--brand);
  color: #fff;
  padding: 22px;
  margin-bottom: 16px;
}

.calc-hero-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 8px;
}

.calc-hero-value {
  font-family: var(--font-head);
  font-size: clamp(34px, 5.4vw, 58px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
  color: #00D084;
  margin-bottom: 7px;
}

.calc-hero-sub {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

.calc-controls {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.calc-control {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--bg);
}

.calc-control-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--ink-2);
  font-size: 14px;
}

.calc-control-head strong {
  font-family: var(--font-head);
  font-size: 25px;
  color: var(--brand);
  letter-spacing: -0.02em;
}

#saleSlider {
  width: 100%;
  accent-color: var(--accent);
}

.calc-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-3);
}

.calc-control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.calc-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
}

.calc-field input {
  width: 100%;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 11px 12px;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--ink);
  outline: none;
}

.calc-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.breakdown {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

.bd-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--ink-2);
}

.bd-row:last-child {
  border-bottom: none;
}

.bd-row strong {
  color: var(--ink);
}

.bd-row em {
  font-style: normal;
  font-size: 11px;
  color: var(--ink-3);
}

.bd-row-total {
  padding-top: 12px;
}

.bd-row-total strong {
  font-family: var(--font-head);
  font-size: 25px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--green);
}

.fee-toggle-row {
  margin-top: 12px;
}

.fee-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.fee-toggle-label input {
  accent-color: var(--accent);
}

.fee-compare {
  margin-top: 10px;
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.fee-compare.open {
  display: grid;
}

.fee-box {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fee-box-live {
  border-color: rgba(201, 168, 76, 0.35);
  background: var(--accent-pale);
}

.fee-box span {
  font-size: 11px;
  color: var(--ink-3);
}

.fee-box strong {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
}

.comps-card {
  padding: 18px;
}

.card-head-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-head-row h2 {
  font-family: var(--font-head);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.card-head-row p {
  font-size: 13px;
  color: var(--ink-3);
}

.comps-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x mandatory;
}

.comp-card {
  min-width: 220px;
  scroll-snap-align: start;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-align: left;
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.comp-card:hover {
  border-color: rgba(201, 168, 76, 0.4);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.comp-top {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 8px;
}

.comp-price {
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--brand);
  margin-bottom: 6px;
}

.comp-meta {
  font-size: 12px;
  color: var(--ink-3);
}

.send-row {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.send-proposal-btn {
  width: 100%;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--brand);
  color: #fff;
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  padding: 18px 22px;
  cursor: pointer;
  transition: filter 0.2s ease, transform 0.15s ease;
}

.send-proposal-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.send-success {
  display: none;
  font-size: 14px;
  color: var(--green);
  background: rgba(0, 168, 107, 0.08);
  border: 1px solid rgba(0, 168, 107, 0.2);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.send-success.show {
  display: block;
}

.notes-drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: min(420px, 92vw);
  bottom: 0;
  z-index: 120;
  background: #fff;
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 28px rgba(0, 0, 0, 0.14);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: right 0.28s ease;
}

.notes-drawer.open {
  right: 0;
}

.notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notes-header h3 {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 800;
}

.notes-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #fff;
  color: var(--ink-3);
  cursor: pointer;
}

.notes-sub {
  font-size: 13px;
  color: var(--ink-3);
  line-height: 1.5;
}

#appraisalNotesInput {
  flex: 1;
  width: 100%;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-md);
  padding: 12px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  line-height: 1.6;
  resize: none;
  outline: none;
}

#appraisalNotesInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.notes-save-btn {
  border: none;
  border-radius: var(--radius-md);
  background: var(--brand);
  color: #fff;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  padding: 12px;
  cursor: pointer;
}

.notes-status {
  min-height: 18px;
  font-size: 12px;
  color: var(--ink-3);
}

.notes-status.ok {
  color: var(--green);
}

.notes-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 110;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.notes-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.tracking-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  background: #111;
  color: #fff;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  transform: translateY(70px);
  opacity: 0;
  transition: transform 0.35s ease, opacity 0.35s ease;
  max-width: 310px;
}

.tracking-toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.toast-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 2px;
}

.toast-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.64);
}

@media (max-width: 900px) {
  .intro-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .intro-sub {
    max-width: 100%;
  }

  .calc-controls {
    grid-template-columns: 1fr;
  }

  .fee-compare {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .app-header-right {
    width: 100%;
    justify-content: space-between;
  }

  .app-main {
    padding: 18px 14px 30px;
  }

  .calc-card,
  .comps-card {
    padding: 14px;
  }

  .card-head-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .comp-card {
    min-width: 84%;
  }

  .tracking-toast {
    left: 14px;
    right: 14px;
    bottom: 14px;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
