/* ============================================================
   2026 Annual Budget Tracker — Complete Styles
   ============================================================ */

:root {
  --bg-primary: #151e32;
  --bg-secondary: #1a2540;
  --bg-panel: #1e2a45;
  --bg-input: #162040;
  --bg-row-alt: #141d34;

  --border-color: #2a3a5e;
  --border-light: #223052;

  --text-primary: #d0e4f7;
  --text-secondary: #8ba8c7;
  --text-muted: #6a8aaa;

  --header-month-bg: #8B5CF6;
  --header-month-text: #ffffff;
  --month-cell-bg: #00E5A0;
  --month-cell-text: #151e32;
  --col-income-header: #38BDF8;
  --col-expense-header: #A78BFA;
  --col-savings-header: #2DD4A8;

  --val-income: #8BB8E8;
  --val-expense: #B794F6;
  --val-savings: #7DD3FC;

  --donut-income: #34D399;
  --donut-expense: #8B5CF6;
  --donut-savings: #22D3EE;

  --section-income-bg: #064E3B;
  --section-income-text: #2DD4A8;
  --section-expenses-bg: #4C1D95;
  --section-expenses-text: #A78BFA;

  --row-income-bg: #0F2D22;
  --row-income-alt: #0D2619;
  --row-expense-bg: #1A1A3E;
  --row-expense-alt: #16163A;

  --total-income-bg: #064E3B;
  --total-income-text: #2DD4A8;
  --total-expenses-bg: #4C1D95;
  --total-expenses-text: #A78BFA;
  --total-savings-bg: #064E3B;
  --total-savings-text: #2DD4A8;

  --annual-month-header-bg: #00E5A0;
  --annual-month-header-text: #151e32;
  --annual-category-header-bg: #1A3A5C;
  --annual-category-header-text: #2DD4A8;
  --total-col-bg: #064E3B;
  --total-col-text: #2DD4A8;

  --savings-positive: #2DD4A8;
  --savings-negative: #F87171;

  --glow-green: rgba(0, 229, 160, 0.25);
}

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

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

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
}

/* Hero */
.hero { text-align: center; margin-bottom: 1rem; padding: 0.5rem 0; }
.hero h1 {
  font-size: clamp(1rem, 3vw, 1.6rem);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  margin-bottom: 0.2rem;
}
.hero h1 .vs { color: var(--col-savings-header); font-weight: 900; }
.hero p { color: var(--text-secondary); font-size: 0.85rem; }

/* ============================================================
   Tab Navigation
   ============================================================ */
.tab-nav {
  display: flex;
  gap: 0;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.35rem;
}

.tab-btn {
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  background: transparent;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  transition: all 0.2s ease;
}
.tab-btn:hover { background: var(--bg-panel); color: var(--text-primary); }
.tab-btn.active {
  background: var(--month-cell-bg);
  color: var(--bg-primary);
  font-weight: 700;
}

.tab-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-left: auto;
}
.tab-actions button {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  background: var(--bg-panel);
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.tab-actions button:hover { background: var(--bg-input); border-color: var(--month-cell-bg); }
#save-btn { color: var(--month-cell-bg); font-weight: 700; }
#status-message { color: var(--month-cell-bg); font-size: 0.8rem; font-weight: 600; }

/* Tab panels */
.tab-panel { display: none; animation: fadeIn 0.25s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ============================================================
   Panels
   ============================================================ */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

/* ============================================================
   Summary Cards
   ============================================================ */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  text-align: center;
}
.card h3 {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}
.card .amount { font-size: 1.3rem; font-weight: 800; }
.card-income { border-color: var(--donut-income); }
.card-income .amount { color: var(--donut-income); }
.card-expenses { border-color: var(--donut-expense); }
.card-expenses .amount { color: var(--donut-expense); }
.card-savings { border-color: var(--donut-savings); }
.card-savings .amount { color: var(--donut-savings); }

/* ============================================================
   Dashboard Top Row — Table + Donut
   ============================================================ */
.dashboard-top-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

@media (min-width: 768px) {
  .dashboard-top-row {
    grid-template-columns: 1fr 300px;
  }
}

/* Donut panel */
.donut-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  min-height: 280px;
}

.donut-panel canvas {
  width: 100%;
  max-width: 340px;
  height: 280px;
  display: block;
}

/* Trend chart */
.trend-panel canvas {
  width: 100%;
  display: block;
}

/* ============================================================
   Chart titles
   ============================================================ */
.chart-title-centered {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--col-savings-header);
  margin-bottom: 0.4rem;
  letter-spacing: 0.01em;
}

/* ============================================================
   Dashboard Table
   ============================================================ */
.dashboard-table-panel h2 {
  text-align: center;
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
  color: var(--text-primary);
}
.dashboard-table-panel h2 .vs {
  color: var(--col-savings-header);
  font-weight: 900;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table { width: 100%; border-collapse: collapse; }

thead th {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.55rem 0.5rem;
  text-align: right;
  border-bottom: 1px solid var(--border-color);
}
thead th.col-month {
  background: var(--header-month-bg);
  color: var(--header-month-text);
  text-align: center;
  border-radius: 5px 0 0 0;
}
thead th:nth-child(2) { color: var(--col-income-header); }
thead th:nth-child(3) { color: var(--col-expense-header); }
thead th:nth-child(4) { color: var(--col-savings-header); }

tbody td {
  padding: 0.35rem 0.5rem;
  text-align: right;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border-light);
}

tbody td:first-child {
  text-align: center;
  font-weight: 700;
  background: var(--month-cell-bg);
  color: var(--bg-primary);
  border-radius: 4px;
  min-width: 75px;
}

tbody td:nth-child(2) { color: var(--val-income); }
tbody td:nth-child(3) { color: var(--val-expense); }
tbody td:nth-child(4) { color: var(--val-savings); }

.amount-input {
  width: 100%;
  min-width: 80px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--val-income);
  padding: 0.25rem 0.3rem;
  font-size: 0.8rem;
  text-align: right;
  font-family: inherit;
}
tbody td:nth-child(3) .amount-input { color: var(--val-expense); }
.amount-input:focus { outline: none; background: var(--bg-input); border-color: var(--month-cell-bg); }
.amount-input:hover { background: rgba(255,255,255,0.03); }

.savings-positive { color: var(--savings-positive); font-weight: 700; }
.savings-negative { color: var(--savings-negative); font-weight: 700; }

/* ============================================================
   Annual Overview
   ============================================================ */
.section-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 0.75rem;
}
.section-title .year { color: var(--col-savings-header); }

.annual-section { padding: 0; overflow: hidden; }

.section-header {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.5rem 1rem;
  margin: 0;
}
.header-income {
  background: linear-gradient(90deg, var(--section-income-bg), transparent);
  color: var(--section-income-text);
  border-left: 3px solid var(--section-income-text);
}
.header-expenses {
  background: linear-gradient(90deg, var(--section-expenses-bg), transparent);
  color: var(--section-expenses-text);
  border-left: 3px solid var(--section-expenses-text);
}

.annual-table { min-width: 800px; }

.annual-table thead th {
  font-size: 0.68rem;
  padding: 0.45rem 0.3rem;
  white-space: nowrap;
  text-align: center;
  background: var(--bg-secondary);
}
.annual-table thead th.col-category {
  background: var(--annual-category-header-bg);
  color: var(--annual-category-header-text);
  text-align: left;
  min-width: 140px;
}
.annual-table thead th:not(.col-category):not(.col-total) {
  background: var(--annual-month-header-bg);
  color: var(--annual-month-header-text);
}
.annual-table thead th.col-total {
  background: var(--total-col-bg);
  color: var(--total-col-text);
}

.annual-table tbody td {
  font-size: 0.76rem;
  padding: 0.3rem 0.25rem;
  text-align: center;
  border-bottom: 1px solid var(--border-light);
}
.annual-table tbody td:first-child {
  text-align: left;
  font-weight: 600;
  padding-left: 0.7rem;
}

.row-income td { background: var(--row-income-bg); color: var(--val-income); }
.row-income:nth-child(even) td { background: var(--row-income-alt); }
.row-income td:first-child { color: var(--val-income); }

.row-expense td { background: var(--row-expense-bg); color: var(--val-expense); }
.row-expense:nth-child(even) td { background: var(--row-expense-alt); }
.row-expense td:first-child { color: var(--val-expense); }

.annual-table .amount-input {
  min-width: 70px;
  font-size: 0.76rem;
  padding: 0.25rem 0.3rem;
  text-align: center;
  background: rgba(15, 45, 34, 0.5);
}
.row-expense .amount-input { background: rgba(26, 26, 62, 0.5); }

.row-total { font-weight: 800; font-size: 0.82rem; }
.row-income-total td {
  background: var(--total-income-bg);
  color: var(--total-income-text);
  border-top: 2px solid var(--total-income-text);
}
.row-expenses-total td {
  background: var(--total-expenses-bg);
  color: var(--total-expenses-text);
  border-top: 2px solid var(--total-expenses-text);
}
.row-savings td {
  background: var(--total-savings-bg);
  color: var(--total-savings-text);
  font-weight: 800;
  font-size: 0.82rem;
}

.total-label { text-align: left !important; font-weight: 800 !important; padding-left: 1rem !important; }
.col-total { min-width: 90px; }
.grand-total { font-weight: 900; font-size: 0.85rem; background: var(--total-col-bg); color: var(--total-col-text); }

/* Annual charts side by side */
.annual-charts-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
@media (min-width: 768px) {
  .annual-charts-row {
    grid-template-columns: 1fr 1fr;
  }
}
.annual-chart-panel canvas {
  width: 100%;
  display: block;
}

/* ============================================================
   Instructions
   ============================================================ */
.instructions-panel { max-width: 800px; margin: 0 auto; }
.instructions-content h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--col-savings-header);
  margin: 1.25rem 0 0.5rem;
}
.instructions-content h3:first-child { margin-top: 0; }
.instructions-content p { color: var(--text-secondary); margin-bottom: 0.6rem; line-height: 1.6; }
.instructions-content ul, .instructions-content ol {
  color: var(--text-secondary);
  padding-left: 1.25rem;
  margin-bottom: 0.75rem;
}
.instructions-content li { margin-bottom: 0.3rem; line-height: 1.5; }
.instructions-content li strong { color: var(--text-primary); }
.motivational { color: var(--month-cell-bg) !important; font-weight: 600; font-size: 0.95rem; }

/* ============================================================
   Responsive — Mobile
   ============================================================ */
@media (max-width: 767px) {
  .app { padding: 0.6rem 0.4rem 2rem; }

  .tab-nav {
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    border-radius: 8px;
    overflow: hidden;
  }

  .tab-btn {
    text-align: center;
    padding: 0.65rem 0.4rem;
    font-size: 0.78rem;
    border-radius: 0;
    border-bottom: 1px solid var(--border-light);
  }
  .tab-btn:last-of-type { border-bottom: none; }
  .tab-btn.active { box-shadow: none; }

  .tab-actions {
    margin-left: 0;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0;
    border-top: 2px solid var(--border-color);
    background: var(--bg-primary);
  }
  .tab-actions button {
    border: none;
    border-right: 1px solid var(--border-light);
    border-radius: 0;
    padding: 0.6rem 0.3rem;
    font-size: 0.72rem;
    background: var(--bg-secondary);
  }
  .tab-actions button:last-of-type { border-right: none; }

  #status-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 0.35rem;
    background: var(--bg-primary);
    font-size: 0.75rem;
    border-top: 1px solid var(--border-light);
  }

  .summary-cards { grid-template-columns: 1fr; }
  .dashboard-top-row { grid-template-columns: 1fr; }
  .annual-charts-row { grid-template-columns: 1fr; }

  .hero h1 { font-size: 0.95rem; }
  .hero p { font-size: 0.75rem; }

  .card .amount { font-size: 1.15rem; }

  .panel { padding: 0.6rem 0.7rem; }

  .donut-panel canvas { max-width: 260px; }

  .dashboard-table-panel h2 { font-size: 0.82rem; }
  .chart-title-centered { font-size: 0.75rem; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 0.85rem; }
  .tab-btn { font-size: 0.72rem; padding: 0.6rem 0.3rem; }
  .tab-actions button { font-size: 0.68rem; padding: 0.55rem 0.25rem; }
  .amount-input { min-width: 65px; font-size: 0.75rem; }
  .card .amount { font-size: 1.05rem; }
}

/* Scrollbar */
.table-scroll::-webkit-scrollbar { height: 5px; }
.table-scroll::-webkit-scrollbar-track { background: var(--bg-secondary); border-radius: 3px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
