:root {
  --bg: #f7f8fa;
  --bg-card: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #0f172a;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --success: #059669;
  --success-light: #d1fae5;
  --warn: #d97706;
  --warn-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --pos: #047857;
  --neg: #b91c1c;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.08), 0 4px 10px rgba(15, 23, 42, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.num {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 500;
}

.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* ============ Alert banner ============ */
.alert-banner {
  background: linear-gradient(90deg, #fef3c7, #fde68a);
  border-bottom: 2px solid #f59e0b;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: #78350f;
}
.alert-banner.hidden { display: none; }
.alert-banner button {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #78350f;
  padding: 0 8px;
}

/* ============ Topbar ============ */
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 20px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: white;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
}

.brand h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand p {
  font-size: 13px;
  color: var(--text-muted);
}

.topbar-meta {
  display: flex;
  gap: 32px;
}

.meta-item {
  display: flex;
  flex-direction: column;
}

.meta-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.meta-value {
  font-size: 18px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  margin-top: 2px;
}

/* ============ Tabs ============ */
.tabs {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  font-family: inherit;
  transition: all 0.15s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ============ Main ============ */
main {
  padding: 32px;
  max-width: 1400px;
  margin: 0 auto;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.2s ease-out;
}
.tab-panel.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

h2 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}

.subtitle {
  color: var(--text-muted);
  margin-top: -16px;
  margin-bottom: 24px;
  font-size: 14px;
}

/* ============ Cards & Grid ============ */
.grid {
  display: grid;
  gap: 20px;
  margin-bottom: 24px;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .topbar-meta { gap: 16px; }
  main { padding: 16px; }
  .tabs { padding: 0 16px; }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card h3 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.card.highlight {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border-color: #86efac;
}
.card.highlight h3 { color: #166534; }

.card.warn-card {
  background: var(--warn-light);
  border-color: #fbbf24;
}

/* ============ Tables ============ */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table tr {
  border-bottom: 1px solid var(--border);
}
table tr:last-child { border-bottom: none; }

table td, table th {
  padding: 10px 0;
  text-align: left;
}

table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}

table tr.total {
  border-top: 2px solid var(--text);
  border-bottom: none;
  font-weight: 700;
}

table tr.total td {
  padding-top: 12px;
  padding-bottom: 0;
}

table tr.negative td:last-child { color: var(--neg); }

/* Inflows table */
.inflows-table tr.active-row { background: #f0fdf4; }
.inflows-table tr.big { background: #eff6ff; font-weight: 600; }
.inflows-table tr.grand {
  background: linear-gradient(90deg, #f0fdf4, #dcfce7);
  font-weight: 700;
  border-top: 3px solid var(--success);
}

/* ============ Health Checks ============ */
.health {
  list-style: none;
}
.health li {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 14px;
}
.health li.warn {
  background: var(--warn-light);
  border-left: 3px solid var(--warn);
}
.health li.ok {
  background: var(--success-light);
  border-left: 3px solid var(--success);
}

.note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
  font-style: italic;
}

/* ============ Phases ============ */
.phase {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--accent);
}

.phase-1 { border-left-color: #f59e0b; }
.phase-2 { border-left-color: #3b82f6; }
.phase-3 { border-left-color: #8b5cf6; }
.phase-4 { border-left-color: #ec4899; }
.phase-5 { border-left-color: #10b981; }

.phase-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.phase-num {
  width: 48px;
  height: 48px;
  background: var(--text);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
}
.phase-1 .phase-num { background: #f59e0b; }
.phase-2 .phase-num { background: #3b82f6; }
.phase-3 .phase-num { background: #8b5cf6; }
.phase-4 .phase-num { background: #ec4899; }
.phase-5 .phase-num { background: #10b981; }

.phase h3 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.phase-time {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.phase p {
  margin: 16px 0;
}

.phase table {
  margin: 16px 0;
}

.sip-mix {
  background: #f8fafc;
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-top: 16px;
}
.sip-mix h4 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.sip-mix ul {
  list-style: none;
}
.sip-mix li {
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px dashed var(--border);
}
.sip-mix li:last-child { border-bottom: none; }

.callout {
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-top: 16px;
  font-size: 14px;
}

/* ============ Monthly Tracker ============ */
.month-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.month-header {
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.month-header:hover {
  background: #f1f5f9;
}

.month-card.is-current .month-header {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  border-bottom: 2px solid var(--accent);
}

.month-card.is-complete .month-header {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
}

.month-title {
  font-size: 16px;
  font-weight: 700;
}

.month-progress {
  font-size: 13px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.month-card.is-complete .month-progress {
  color: var(--success);
  font-weight: 700;
}

.month-body {
  padding: 20px 24px;
  display: none;
}
.month-card.expanded .month-body {
  display: block;
}

.checklist {
  list-style: none;
}

.checklist li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.checklist li:last-child { border-bottom: none; }

.checklist input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--success);
}

.checklist label {
  flex: 1;
  cursor: pointer;
  font-size: 14px;
}

.checklist .item-amt {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
}

.checklist li.done label {
  text-decoration: line-through;
  color: var(--text-muted);
}

.month-notes {
  margin-top: 16px;
}

.month-notes textarea {
  width: 100%;
  min-height: 60px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}

/* ============ Goals ============ */
.goal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.goal-checkbox {
  width: 22px;
  height: 22px;
  accent-color: var(--success);
  cursor: pointer;
  flex-shrink: 0;
}

.goal-content { flex: 1; }

.goal-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}
.goal.done .goal-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.goal-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 16px;
}

.goal-progress {
  width: 200px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.goal-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
}

@media (max-width: 768px) {
  .goal { flex-wrap: wrap; }
  .goal-progress { width: 100%; }
}

/* ============ Buttons ============ */
.btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-right: 8px;
  margin-top: 8px;
  transition: all 0.15s;
}
.btn:hover { border-color: var(--text); }

.btn-primary {
  background: var(--text);
  color: white;
  border-color: var(--text);
}
.btn-primary:hover { background: #1e293b; }

input[type="file"] {
  font-size: 13px;
  margin-top: 12px;
}

/* ============ Footer ============ */
footer {
  text-align: center;
  padding: 32px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ============ Forms ============ */
.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form label > span {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.form input[type="number"],
.form input[type="date"],
.form input[type="text"],
.form select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  background: white;
  font-variant-numeric: tabular-nums;
}
.form input:focus,
.form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ============ Tax Calculator ============ */
.tax-table th:nth-child(2),
.tax-table th:nth-child(3),
.tax-table td:nth-child(2),
.tax-table td:nth-child(3) {
  text-align: right;
  width: 35%;
}

.recommend {
  margin-top: 20px;
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  border-left: 4px solid;
}
.recommend.old {
  background: #eff6ff;
  border-left-color: #2563eb;
}
.recommend.new {
  background: #f0fdf4;
  border-left-color: var(--success);
}
.recommend-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}
.recommend-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ============ Net Worth ============ */
.big-number {
  font-size: 36px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 8px;
}

.section-label {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 8px;
}

.nw-chart {
  width: 100%;
  height: auto;
  max-height: 180px;
  margin-top: 12px;
}

/* ============ Code & misc ============ */
code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}

/* ============ Net Worth Projection ============ */
.projection-card {
  background: linear-gradient(135deg, #fefce8, #fef3c7);
  border: 1px solid #fbbf24;
  margin-top: 24px;
}
.projection-card h3 {
  color: #78350f;
  font-size: 18px;
  text-transform: none;
  letter-spacing: -0.01em;
}

.projection-table {
  margin-top: 16px;
}
.projection-table th {
  background: rgba(255, 255, 255, 0.5);
  padding: 12px;
  font-size: 12px;
}
.projection-table td {
  padding: 14px 12px;
  vertical-align: top;
  background: rgba(255, 255, 255, 0.4);
}
.projection-table .num {
  font-size: 16px;
  font-weight: 700;
  color: #78350f;
}
.projection-table .sub {
  font-size: 11px;
  color: #92400e;
  font-weight: 400;
  display: block;
  margin-top: 2px;
}

.projection-breakdown {
  margin-top: 24px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-sm);
}
.projection-breakdown h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: #78350f;
  margin-bottom: 12px;
}
.projection-breakdown table tr:not(.total) td {
  padding: 6px 0;
  border-bottom: 1px solid #fde68a;
}
