:root {
  --blue: #2563eb;
  --blue-light: #dbeafe;
  --green: #16a34a;
  --green-light: #dcfce7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --amber-light: #fef3c7;
  --amber: #b45309;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, Arial, sans-serif;
  margin: 0;
  padding: 0 24px 40px;
  color: var(--text);
  background: #f4f6f9;
}

#app-header {
  padding: 20px 0 12px;
}
#app-header h1 {
  margin: 0;
  font-size: 1.7em;
  letter-spacing: -0.02em;
}
.privacy {
  color: var(--text-muted);
  font-size: 0.9em;
  margin: 4px 0 0;
}
#status { color: var(--text-muted); font-style: italic; }

h2 { margin: 0 0 10px; font-size: 1.15em; color: #0f172a; }
h3 { margin: 0 0 4px; font-size: 1em; color: #0f172a; }
.section-title { margin: 28px 0 12px; font-size: 1.3em; }

.hint { color: var(--text-muted); font-size: 0.88em; margin: 0 0 12px; line-height: 1.5; }
.hint-inline { color: var(--text-muted); font-size: 0.85em; font-weight: normal; margin-left: 8px; }

/* Card containers */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

table {
  border-collapse: collapse;
  margin-bottom: 8px;
  background: #fff;
  font-size: 0.92em;
}
.card table { margin-bottom: 0; }
td, th {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: right;
}
th, td:first-child {
  text-align: left;
}
th {
  background: #f8fafc;
  font-weight: 600;
  color: #334155;
}
tbody tr:nth-child(even) { background: #fbfcfe; }
tbody tr:hover { background: #eff4ff; }

input[type=number], input[type=date], input[type=text] {
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 0.95em;
}
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
input[type=date] { width: 90px; }
.numfmt-input { width: 90px; text-align: right; font-variant-numeric: tabular-nums; }
#global-inputs-table .numfmt-input { width: 160px; }
.breakdown-table .numfmt-input { width: 100px; }
select {
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 3px;
}
.outputs td { font-variant-numeric: tabular-nums; }

.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 0.95em;
  cursor: pointer;
}
.btn-primary:hover { background: #1d4ed8; }

.toggle-row { display: flex; align-items: center; gap: 6px; }

#recommendation {
  font-weight: 700;
  font-size: 1.15em;
  padding: 14px 18px;
  background: linear-gradient(90deg, #fff7ed, #fefce8);
  border: 1px solid #fde68a;
  border-radius: 10px;
  margin: 6px 0 18px;
}

/* Badges / status pills */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.85em;
  font-weight: 600;
}
.badge-pass { background: var(--green-light); color: #15803d; }
.badge-warn { background: var(--red-light); color: #b91c1c; }
.badge-m { background: #e0e7ff; color: #3730a3; }
.badge-r { background: #fce7f3; color: #9d174d; }
.badge-y { background: var(--green-light); color: #15803d; }
.badge-n { background: #f1f5f9; color: #475569; }

/* KPI cards */
#kpi-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 8px;
}
.kpi-card {
  flex: 1 1 160px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}
.kpi-value {
  font-size: 1.6em;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: -0.01em;
}
.kpi-label {
  color: var(--text-muted);
  font-size: 0.78em;
  margin-top: 6px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.kpi-sub {
  color: #94a3b8;
  font-size: 0.78em;
  margin-top: 1px;
}

/* Dashboard */
.dashboard-head { margin-bottom: 14px; }
.dashboard-head .hint { margin: 4px 0 0; }
.dashboard-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.chart-row .card { min-width: 0; }
.chart-row canvas { max-height: 320px; }
@media (max-width: 900px) {
  .chart-row { grid-template-columns: 1fr; }
}

/* Top-level page navigation */
#top-nav {
  margin-bottom: 20px;
  border-bottom: 2px solid #0f172a;
  display: flex;
  gap: 3px;
}
#top-nav button {
  padding: 10px 20px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  font-size: 14px;
  font-weight: 500;
  color: #334155;
  transition: background 0.15s;
}
#top-nav button.nav-input { background: var(--blue-light); }
#top-nav button.nav-result { background: var(--green-light); }
#top-nav button.active {
  font-weight: 700;
  background: #fff;
  color: #0f172a;
  box-shadow: 0 -1px 0 #fff inset;
}
.page { display: none; }
.page.active { display: block; animation: fadein 0.15s ease-in; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.page-input .card:first-of-type h2:first-child,
.page-result .card:first-of-type h2:first-child { margin-top: 0; }

/* Scenario sub-tabs (within a page) */
.scenario-tabs { margin-bottom: 10px; display: flex; gap: 3px; }
.scenario-tabs button {
  padding: 7px 16px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 6px 6px 0 0;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.9em;
}
.scenario-tabs button.active {
  background: #fff;
  font-weight: 700;
  color: #0f172a;
  border-bottom: 2px solid var(--blue);
}
.breakdown-panel, .cashflow-panel { display: none; }
.breakdown-panel.active, .cashflow-panel.active { display: block; }
.breakdown-table h3 { margin: 14px 0 6px; }
.breakdown-table table { margin-bottom: 6px; }
.breakdown-table input[type=text] { width: 160px; }
.breakdown-table input[type=number] { width: 90px; }
.breakdown-table select { width: 60px; }
tr.total-row, tr.bold-row { font-weight: 700; background: #f1f5f9 !important; }

/* Rent roll formatted view */
#rentroll-table-wrap {
  max-height: 520px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.rentroll-view select { width: 74px; }
.rentroll-view th { position: sticky; top: 0; z-index: 1; }
