/* RE Deal Analyzer — Professional Dashboard */

:root {
  --sidebar-bg:    #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active:#1d4ed8;
  --main-bg:       #f1f5f9;
  --card-bg:       #ffffff;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --border:        #e2e8f0;
  --pass-bg:       #dcfce7;
  --pass-text:     #15803d;
  --fail-bg:       #fee2e2;
  --fail-text:     #dc2626;
  --cond-bg:       #fef3c7;
  --cond-text:     #b45309;
  --btn-bg:        #2563eb;
  --btn-hover:     #1d4ed8;
  --shadow:        0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:     0 4px 8px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.05);
}

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

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

/* ── Layout ─────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────── */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-logo {
  padding: 1.4rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: #2563eb;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.logo-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.25;
}

.logo-sub {
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: 2px;
}

.sidebar-nav {
  list-style: none;
  margin: 0.75rem 0;
  padding: 0 0.75rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: 7px;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.845rem;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 2px;
  user-select: none;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #ffffff;
}

.nav-icon { font-size: 1rem; width: 20px; text-align: center; }

/* ── Main ───────────────────────────────────────── */
.main {
  margin-left: 240px;
  flex: 1;
  padding: 2rem 2.25rem;
  min-height: 100vh;
}

.page-header { margin-bottom: 1.75rem; }
.page-header h1 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.25rem;
}
.page-header p {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.845rem;
}

/* ── Views ──────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Cards ──────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

/* ── Hero ───────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 2.5rem 1rem 1rem;
  max-width: 700px;
  margin: 0 auto;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #dbeafe;
  color: #1d4ed8;
  border-radius: 9999px;
  padding: 0.3rem 0.9rem;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}
.hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 0.85rem;
  letter-spacing: -0.4px;
  line-height: 1.15;
}
.hero p {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.65;
  max-width: 520px;
  margin: 0 auto;
}

/* ── Form card ──────────────────────────────────── */
.form-card {
  max-width: 620px;
  margin: 1.5rem auto 1.75rem;
}
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.input-wrap {
  position: relative;
  margin-bottom: 0.35rem;
}
.input-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.input-wrap input[type=text] { padding-left: 2.25rem; }
.input-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0 0 0.85rem;
}
.btn-analyze {
  width: 100%;
  padding: 0.7rem 1.4rem;
  background: var(--btn-bg);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 0.85rem;
}
.btn-analyze:hover   { background: var(--btn-hover); }
.btn-analyze:disabled { opacity: 0.55; cursor: not-allowed; }

.form-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.input-address { flex: 1; }

.form-row-optional {
  display: flex;
  gap: 0.75rem;
}

.claude-agents-section {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
}
.claude-agents-header {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.55rem;
}
.claude-agents-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 1rem;
}
.agent-claude-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  user-select: none;
}
.agent-claude-toggle input[type=checkbox] {
  width: 15px;
  height: 15px;
  accent-color: var(--btn-bg);
  cursor: pointer;
  flex-shrink: 0;
}
.toggle-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}
.toggle-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

input[type=text], input[type=number] {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s;
  outline: none;
}
input::placeholder { color: #b0bec5; }
input:focus { border-color: var(--btn-bg); }

.btn-primary {
  padding: 0.6rem 1.4rem;
  background: var(--btn-bg);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--btn-hover); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-outline {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s;
}
.btn-outline:hover { border-color: var(--btn-bg); color: var(--btn-bg); }

/* ── Status card ────────────────────────────────── */
.status-card { text-align: center; padding: 2.5rem 1.5rem; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--btn-bg);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

#status-text  { font-weight: 600; margin: 0 0 0.25rem; font-size: 0.9rem; }
.status-sub   { color: var(--text-muted); font-size: 0.8rem; margin: 0; }

.btn-stop {
  margin-top: 1.1rem;
  padding: 0.42rem 1.1rem;
  background: #fff;
  color: #dc2626;
  border: 1.5px solid #fca5a5;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-stop:hover { background: #fee2e2; border-color: #dc2626; }

/* ── Verdict banner ─────────────────────────────── */
.verdict-banner {
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
}
.verdict-banner.pass { background: #f0fdf4; border: 1.5px solid #86efac; }
.verdict-banner.fail { background: #fef2f2; border: 1.5px solid #fca5a5; }
.verdict-banner.conditional { background: #fffbeb; border: 1.5px solid #fcd34d; }

.verdict-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 800;
  flex-shrink: 0;
}
.verdict-banner.pass        .verdict-icon { background: #dcfce7; color: #15803d; }
.verdict-banner.fail        .verdict-icon { background: #fee2e2; color: #dc2626; }
.verdict-banner.conditional .verdict-icon { background: #fef3c7; color: #b45309; }

.verdict-label { font-size: 1.1rem; font-weight: 700; }
.verdict-banner.pass        .verdict-label { color: #15803d; }
.verdict-banner.fail        .verdict-label { color: #dc2626; }
.verdict-banner.conditional .verdict-label { color: #b45309; }

.verdict-rec  { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.verdict-conf { margin-left: auto; font-size: 1.1rem; font-weight: 700; color: var(--text-muted); }

/* ── Agent grid ─────────────────────────────────── */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.agent-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  border-left: 4px solid var(--border);
  box-shadow: var(--shadow);
}
.agent-card.pass        { border-left-color: #16a34a; }
.agent-card.fail        { border-left-color: #dc2626; }
.agent-card.conditional { border-left-color: #d97706; }
.agent-card.error       { border-left-color: #94a3b8; }

.agent-name {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.3rem;
}
.agent-verdict {
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.agent-card.pass        .agent-verdict { color: #16a34a; }
.agent-card.fail        .agent-verdict { color: #dc2626; }
.agent-card.conditional .agent-verdict { color: #d97706; }
.agent-card.error       .agent-verdict { color: #94a3b8; }

.agent-summary { font-size: 0.77rem; color: var(--text-muted); line-height: 1.5; }
.agent-flags   { margin-top: 0.5rem; font-size: 0.72rem; color: #d97706; font-weight: 500; }

.result-actions { margin-bottom: 1.5rem; }

/* ── Section headers ────────────────────────────── */
.section-header { margin-bottom: 1rem; }
.section-header h2 { font-size: 1rem; font-weight: 600; color: var(--text); margin: 0; }

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

.filter-bar { display: flex; gap: 0.35rem; }

.filter-btn {
  padding: 0.28rem 0.7rem;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.filter-btn:hover { border-color: #94a3b8; color: var(--text); }
.filter-btn.active      { border-color: var(--btn-bg); background: var(--btn-bg); color: #fff; }
.filter-btn.pass.active { border-color: #16a34a;       background: #16a34a;       color: #fff; }
.filter-btn.cond.active { border-color: #d97706;       background: #d97706;       color: #fff; }
.filter-btn.fail.active { border-color: #dc2626;       background: #dc2626;       color: #fff; }

.filter-empty {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  background: var(--card-bg);
  border-radius: 10px;
  box-shadow: var(--shadow);
  margin-bottom: 1.75rem;
}

/* ── Recent analyses grid ───────────────────────── */
.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.recent-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow 0.15s;
  border-top: 3px solid var(--border);
}
.recent-card:hover { box-shadow: var(--shadow-md); }
.recent-card.v-pass        { border-top-color: #16a34a; }
.recent-card.v-fail        { border-top-color: #dc2626; }
.recent-card.v-conditional { border-top-color: #d97706; }

.recent-address {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.3rem; }
.recent-detail-link {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--btn-bg);
  margin-top: 0.35rem;
  font-weight: 500;
  text-decoration: none;
}
.recent-detail-link:hover { text-decoration: underline; }

.empty-state {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 3rem 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.75rem;
}
.empty-state svg { display: block; margin: 0 auto 0.75rem; }
.empty-state p   { font-size: 0.9rem; font-weight: 600; color: var(--text); margin: 0 0 0.25rem; }
.empty-state span { font-size: 0.78rem; }

/* ── Verdict badges ─────────────────────────────── */
.badge, .recent-badge, .report-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.badge-pass        { background: var(--pass-bg); color: var(--pass-text); }
.badge-fail        { background: var(--fail-bg); color: var(--fail-text); }
.badge-conditional { background: var(--cond-bg); color: var(--cond-text); }

/* ── How It Works ───────────────────────────────── */
.how-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.how-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.how-icon-svg {
  width: 38px;
  height: 38px;
  background: #f1f5f9;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  color: #475569;
}
.how-card h3 { font-size: 0.875rem; font-weight: 600; margin: 0 0 0.4rem; }
.how-card p  { font-size: 0.77rem; color: var(--text-muted); margin: 0; line-height: 1.55; }

/* ── Investment Criteria ────────────────────────── */
.criteria-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  margin-bottom: 1.75rem;
  background: var(--card-bg);
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.criteria-col + .criteria-col {
  border-left: 1px solid var(--border);
  padding-left: 1.5rem;
  margin-left: 1.5rem;
}
.criteria-header {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}
.criteria-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}
.crit-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  width: 4.25rem;
  flex-shrink: 0;
}
.crit-chip {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}
.crit-chip.pass { background: var(--pass-bg); color: var(--pass-text); }
.crit-chip.cond { background: var(--cond-bg); color: var(--cond-text); }
.crit-chip.fail { background: var(--fail-bg); color: var(--fail-text); }

/* ── Stats row ──────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.stat-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-num {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}
.stat-num.pass-text { color: #16a34a; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }

/* ── Reports grid ───────────────────────────────── */
.reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
  gap: 1rem;
}

.report-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 1px solid var(--border);
  transition: box-shadow 0.15s, transform 0.12s;
}
.report-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.report-address {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e40af;
  margin-bottom: 0.5rem;
}
.report-badge-row { margin-bottom: 0.3rem; }
.report-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.report-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0.35rem 0 0.75rem;
}
.report-metrics {
  display: flex;
  gap: 2rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}
.rm-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}
.rm-val { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.report-link-row {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
}
.report-link {
  display: inline-block;
  font-size: 0.77rem;
  color: var(--btn-bg);
  font-weight: 500;
}
.report-card:hover .report-link { text-decoration: underline; }

.loading-reports {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ── Run-count badge (Recent Analyses dedup) ────── */
.run-count-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.15rem 0.5rem;
  margin-left: 0.4rem;
  vertical-align: middle;
  letter-spacing: 0.03em;
}

/* ── Property map ───────────────────────────────── */
.map-panel {
  background: var(--card-bg);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.map-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0.7rem 1.25rem 0.5rem;
}
#property-map { height: 280px; width: 100%; }

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