/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3247;
  --accent: #6c63ff;
  --accent2: #00d4aa;
  --text: #e8eaf0;
  --text-muted: #8b90a7;
  --income: #00d4aa;
  --expense: #ff6584;
  --emi: #ffa94d;
  --investment: #6c63ff;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0,0,0,.45);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===== SCREENS ===== */
.screen { width: 100%; }
.hidden { display: none !important; }

/* ===== UPLOAD SCREEN ===== */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px 80px;
  max-width: 640px;
  margin: 0 auto;
  gap: 28px;
}

.hero-icon { font-size: 3rem; }

h1 {
  font-size: 2.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  text-align: center;
  font-size: 1rem;
}

/* Upload Card */
/* Home description */
.home-desc {
  font-size: .95rem;
  color: var(--text-muted);
  line-height: 1.75;
  text-align: center;
}
.home-desc strong { color: var(--text); }

/* Home option cards */
.home-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
}

@media (max-width: 540px) {
  .home-options { grid-template-columns: 1fr; }
}

.home-option-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .2s;
}
.home-option-card:hover { border-color: var(--accent); }
.home-option-card--active { border-color: var(--accent); }

.home-option-icon { font-size: 1.8rem; }

.home-option-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.home-option-desc {
  font-size: .85rem;
  color: var(--text-muted);
  line-height: 1.6;
  flex: 1;
}

.home-option-btn { margin-top: 8px; align-self: flex-start; }

#upload-section { width: 100%; display: flex; flex-direction: column; gap: 16px; }

.upload-card {
  width: 100%;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 48px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}

.upload-card:hover,
.upload-card.drag-over {
  border-color: var(--accent);
  background: var(--surface2);
}

.upload-icon { font-size: 2.5rem; }
.upload-label { font-size: 1rem; font-weight: 600; }
.upload-hint { color: var(--text-muted); font-size: .875rem; }

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border: none;
  padding: 10px 28px;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity .2s;
}
.btn-primary:hover { opacity: .85; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  padding: 8px 20px;
  border-radius: 8px;
  font-size: .875rem;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.btn-outline:hover { border-color: var(--accent); color: var(--text); }

/* Format Guide */
.format-guide {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 24px;
  border: 1px solid var(--border);
}
.format-guide h3 { font-size: .875rem; color: var(--text-muted); margin-bottom: 12px; }
.columns-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.col-tag {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .8rem;
  font-family: monospace;
}
.format-note { font-size: .8rem; color: var(--text-muted); }

/* Error */
.error-banner {
  width: 100%;
  background: rgba(255,101,132,.15);
  border: 1px solid var(--expense);
  color: var(--expense);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .875rem;
}

/* ===== DASHBOARD ===== */
.dash-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.dash-brand { display: flex; align-items: center; gap: 8px; }
.dash-icon { font-size: 1.4rem; }
.dash-title { font-size: 1.1rem; font-weight: 700; }
.dash-meta { margin-left: auto; color: var(--text-muted); font-size: .85rem; }

/* Summary Strip */
.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  padding: 24px 32px 0;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.summary-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.summary-card.income::before { background: var(--income); }
.summary-card.expense::before { background: var(--expense); }
.summary-card.emi::before { background: var(--emi); }
.summary-card.investment::before { background: var(--investment); }

.summary-label { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.summary-value { font-size: 1.4rem; font-weight: 700; }
.summary-card.income .summary-value { color: var(--income); }
.summary-card.expense .summary-value { color: var(--expense); }
.summary-card.emi .summary-value { color: var(--emi); }
.summary-card.investment .summary-value { color: var(--investment); }
.summary-sub { font-size: .75rem; color: var(--text-muted); }

/* Insight Note */
.insight-card {
  margin: 20px 32px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  font-size: .95rem;
  line-height: 1.7;
  color: var(--text-muted);
}
.insight-card strong { color: var(--text); }
.insight-card .tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: .85rem;
}
.insight-card .tag.positive { background: rgba(0,212,170,.15); color: var(--income); }
.insight-card .tag.negative { background: rgba(255,101,132,.15); color: var(--expense); }

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 20px;
  padding: 20px 32px 40px;
}

@media (max-width: 900px) {
  .main-grid { grid-template-columns: 1fr; }
  .summary-strip { padding: 16px 16px 0; }
  .insight-card { margin: 16px 16px 0; }
  .main-grid { padding: 16px 16px 32px; }
  .dash-header { padding: 12px 16px; }
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

/* Chart */
.chart-wrap {
  position: relative;
  width: 100%;
  max-width: 280px;
  margin: 0 auto 20px;
}

.custom-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .85rem;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-label { color: var(--text-muted); flex: 1; }
.legend-value { font-weight: 600; }
.legend-pct { color: var(--text-muted); font-size: .8rem; width: 42px; text-align: right; }

/* Table */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

th {
  text-align: left;
  padding: 10px 14px;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }

td.positive { color: var(--income); }
td.negative { color: var(--expense); }

tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--border);
  border-bottom: none;
  color: var(--text);
}

/* ===== PLANNER SCREEN ===== */
.planner-body {
  padding: 24px 32px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.planner-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .planner-two-col { grid-template-columns: 1fr; }
  .planner-body { padding: 16px 16px 40px; }
}

/* Form elements */
.form-inline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row label {
  font-size: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.form-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: .95rem;
  width: 100%;
}

.form-input:focus { outline: none; border-color: var(--accent); }

/* Statement snapshot strip */
.statement-mini-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.statement-mini-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.statement-mini-label {
  font-size: .7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.statement-mini-value {
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: 4px;
}

.statement-mini-sub {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.snapshot-income-input,
.snapshot-expense-input,
.snapshot-emi-input {
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--border);
  font-size: 1.05rem;
  font-weight: 700;
  width: 100%;
  padding: 2px 0;
  margin-top: 4px;
  outline: none;
}
.snapshot-income-input  { color: var(--income); }
.snapshot-expense-input { color: var(--expense); }
.snapshot-emi-input     { color: var(--emi); }
.snapshot-income-input:focus,
.snapshot-expense-input:focus,
.snapshot-emi-input:focus { border-bottom-color: var(--accent); }

.emi-tenure-row {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 4px;
}

.emi-years-input {
  width: 42px;
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: .75rem;
  text-align: center;
  outline: none;
  padding: 0 2px;
}
.emi-years-input:focus { border-bottom-color: var(--accent); }

/* Corpus table */
.num-col { text-align: right !important; }

.corpus-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: .875rem;
  text-align: right;
  width: 140px;
}

.corpus-input:focus { outline: none; border-color: var(--accent); }
.return-input { width: 65px; }

.cat-row td {
  background: rgba(108, 99, 255, .08);
  color: var(--accent);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
}

.card-hint {
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  margin-top: -12px;
}

/* Planner actions */
.planner-actions {
  display: flex;
  justify-content: center;
  padding: 8px 0;
}

.btn-large {
  padding: 14px 48px;
  font-size: 1rem;
  border-radius: 10px;
}

/* Projection tables */
.projection-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.out-of-money td { color: var(--expense) !important; }

.badge-ok {
  background: rgba(0,212,170,.12);
  color: var(--income);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .8rem;
  font-weight: 600;
}

.badge-warn {
  background: rgba(255,101,132,.12);
  color: var(--expense);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .8rem;
  font-weight: 600;
}
