/* ── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green-dark:   #1B4332;
  --green-mid:    #2D6A4F;
  --green-light:  #52B788;
  --green-pale:   #D8F3DC;
  --gold:         #D4A017;
  --gold-light:   #F9E4A0;
  --bg:           #F0F4F1;
  --card:         #FFFFFF;
  --text:         #1A1A1A;
  --text-muted:   #6C757D;
  --border:       #D1D9D4;
  --shadow:       0 2px 8px rgba(0,0,0,0.08);
  --radius:       8px;
  --sidebar-w:    260px;
  --header-h:     56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--green-mid); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Login Page ───────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
}

.login-container {
  background: var(--card);
  border-radius: 12px;
  padding: 40px 44px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}

.logo-mark {
  width: 52px; height: 52px;
  background: var(--green-dark);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.5px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.logo-text { display: flex; flex-direction: column; gap: 2px; }
.logo-main { font-weight: 700; font-size: 17px; color: var(--green-dark); }
.logo-sub  { font-size: 13px; color: var(--text-muted); }

.login-form { display: flex; flex-direction: column; gap: 18px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }

input[type="text"], input[type="password"] {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 15px;
  font-family: var(--font);
  transition: border-color 0.15s;
  outline: none;
  width: 100%;
}
input[type="text"]:focus, input[type="password"]:focus {
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.12);
}

.login-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 24px;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--green-dark);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 11px 22px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-primary:hover:not(:disabled) { background: var(--green-mid); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-full { width: 100%; }

.btn-secondary {
  background: var(--bg);
  color: var(--green-dark);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--green-pale); border-color: var(--green-light); }

.btn-outline {
  background: transparent;
  color: var(--green-dark);
  border: 1.5px solid var(--green-mid);
  border-radius: var(--radius);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex; align-items: center; gap: 4px;
}
.btn-outline:hover { background: var(--green-pale); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: rgba(255,255,255,0.8);
  border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-ghost:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* ── Error message ────────────────────────────────────────────────────── */
.error-msg {
  color: #C0392B;
  background: #FEF0EE;
  border: 1px solid #F5C6C6;
  border-radius: 6px;
  padding: 9px 13px;
  font-size: 14px;
}

/* ── App Header ───────────────────────────────────────────────────────── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: var(--green-dark);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.header-brand { display: flex; align-items: center; gap: 12px; }
.logo-mark-sm {
  width: 34px; height: 34px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.5px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.header-title { display: block; font-size: 15px; font-weight: 700; color: #fff; line-height: 1.2; }
.header-sub   { display: block; font-size: 11px; color: rgba(255,255,255,0.6); }

/* ── App Layout ───────────────────────────────────────────────────────── */
.app-page { min-height: 100vh; }

.app-layout {
  display: flex;
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
}

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--green-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: var(--header-h);
  bottom: 0;
  left: 0;
  overflow-y: auto;
}

.sidebar-header {
  padding: 16px 16px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255,255,255,0.5);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.history-list { flex: 1; padding: 8px 0; }

.history-empty {
  padding: 20px 16px;
  font-size: 13px;
  color: rgba(255,255,255,0.35);
  text-align: center;
}

.history-item {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  transition: background 0.12s;
}
.history-item:hover { background: rgba(255,255,255,0.08); }
.history-item.active { background: rgba(82,183,136,0.25); }

.history-addr {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.history-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.history-date { font-size: 11px; color: rgba(255,255,255,0.4); }
.history-arv  { font-size: 11px; color: rgba(255,255,255,0.55); }
.history-mao  { font-size: 11px; color: var(--green-light); font-weight: 600; }

/* ── Main Content ─────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 32px;
  max-width: 900px;
}

/* ── Input Panel ──────────────────────────────────────────────────────── */
.input-panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.panel-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 6px;
}

.panel-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.input-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.address-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: 15px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}
.address-input:focus {
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.12);
}

/* ── Loading ──────────────────────────────────────────────────────────── */
.loading-panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 60px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--green-pale);
  border-top-color: var(--green-mid);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-text { font-size: 16px; font-weight: 600; color: var(--green-dark); margin-bottom: 6px; }
.loading-sub  { font-size: 13px; color: var(--text-muted); }

.loading-dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}
@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

/* ── Results Toolbar ──────────────────────────────────────────────────── */
.results-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ── Result Cards ─────────────────────────────────────────────────────── */
.result-cards { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  background: var(--green-dark);
  color: #fff;
  padding: 11px 20px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 18px 20px; }

/* Subject property grid */
.prop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.prop-item { display: flex; flex-direction: column; gap: 2px; }
.prop-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); }
.prop-value { font-size: 16px; font-weight: 700; color: var(--green-dark); }
.prop-value.price { color: var(--green-dark); }

/* ARV band */
.arv-band {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.arv-main { font-size: 28px; font-weight: 800; color: var(--green-dark); }
.arv-range { font-size: 13px; color: var(--text-muted); }
.arv-confidence { font-size: 12px; color: var(--text-muted); }
.conf-dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.conf-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--border);
  display: inline-block;
}
.conf-dot.filled { background: var(--green-light); }

/* Comps table */
.comps-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.comps-table th {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 2px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}
.comps-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--bg);
  vertical-align: middle;
}
.comps-table tr:last-child td { border-bottom: none; }
.comps-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.comps-table .addr { font-weight: 500; }
.relaxation-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--gold-light);
  border-radius: 4px;
  padding: 6px 10px;
}

/* Cost lines */
.cost-lines { display: flex; flex-direction: column; gap: 6px; }
.cost-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  padding: 4px 0;
  border-bottom: 1px solid var(--bg);
}
.cost-line:last-child { border-bottom: none; }
.cost-line .label { color: var(--text-muted); }
.cost-line .amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.cost-line.total {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 2px solid var(--border);
  border-bottom: none;
  font-weight: 700;
  font-size: 15px;
}
.cost-line.total .label { color: var(--text); }
.cost-line.total .amount { color: var(--green-dark); }

/* Summary */
.summary-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.summary-line {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  padding: 6px 0;
  border-bottom: 1px solid var(--bg);
}
.summary-line:last-child { border-bottom: none; }
.summary-line .label { color: var(--text-muted); }
.summary-line .amount { font-weight: 600; font-variant-numeric: tabular-nums; }

.mao-box {
  background: var(--green-dark);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.mao-label { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.75; }
.mao-value { font-size: 32px; font-weight: 800; letter-spacing: -1px; }

/* Grade badge */
.grade-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
.grade-badge {
  width: 56px; height: 56px;
  border-radius: 50%;
  font-size: 22px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.grade-A { background: #28A745; color: #fff; }
.grade-B { background: #17A2B8; color: #fff; }
.grade-C { background: #FFC107; color: #1a1a1a; }
.grade-D { background: #FD7E14; color: #fff; }
.grade-F { background: #DC3545; color: #fff; }

.grade-detail { display: flex; flex-direction: column; gap: 3px; }
.grade-label { font-size: 15px; font-weight: 700; }
.grade-flags { font-size: 13px; color: var(--text-muted); }

/* XLeads / Lead Intel */
.intel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.intel-item { display: flex; flex-direction: column; gap: 2px; }
.intel-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); }
.intel-value { font-size: 15px; font-weight: 600; color: var(--text); }
.score-bar-wrap { display: flex; align-items: center; gap: 8px; }
.score-bar { height: 8px; background: var(--border); border-radius: 4px; flex: 1; overflow: hidden; }
.score-fill { height: 100%; background: var(--green-light); border-radius: 4px; }

/* History item grade badge (small) */
.grade-pip {
  width: 20px; height: 20px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Responsive */
@media (max-width: 700px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px; }
  .input-row { flex-direction: column; }
}
