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

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --accent: #00d4a0;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --border: #30363d;
  --positive: #3fb950;
  --negative: #f85149;
  --cash: #4a9eff;
  --taxable: #a371f7;
  --retirement: #f78166;
  --realestate: #ffa657;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  font-size: 14px;
}

/* ── HEADER ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.brand-icon {
  background: var(--accent);
  color: #0d1117;
  font-weight: 700;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.brand-name { font-size: 16px; font-weight: 600; }

.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn-outline {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-outline:hover { background: var(--border); }

.btn-primary {
  background: var(--accent);
  color: #0d1117;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.btn-primary:hover { opacity: 0.85; }

/* ── LAYOUT ── */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── TOTAL CARD ── */
.total-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  position: relative;
  overflow: hidden;
}
.total-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #00a8e0);
}
.total-card-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 8px;
}
.total-amount {
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
}
.total-date { color: var(--text-muted); font-size: 13px; }
.total-mom { font-size: 14px; margin-top: 4px; min-height: 20px; }

/* ── CATEGORY GRID ── */
.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: border-color 0.15s;
}
.category-card:hover { border-color: var(--accent); }

.category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.category-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.cash-icon       { background: rgba(74,158,255,0.15); }
.taxable-icon    { background: rgba(163,113,247,0.15); }
.retirement-icon { background: rgba(247,129,102,0.15); }
.realestate-icon { background: rgba(255,166,87,0.15); }

.category-name { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.category-value { font-size: 26px; font-weight: 700; margin-bottom: 8px; }

.category-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.portfolio-pct { font-size: 12px; color: var(--text-muted); }

.mom-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.mom-badge.positive { background: rgba(63,185,80,0.15);  color: var(--positive); }
.mom-badge.negative { background: rgba(248,81,73,0.15);  color: var(--negative); }
.mom-badge.neutral  { background: rgba(139,148,158,0.15); color: var(--text-muted); }

/* ── CHARTS ROW ── */
.charts-row {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 16px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.chart-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.chart-container { position: relative; height: 280px; }
.chart-container canvas { width: 100% !important; }
.chart-empty {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  pointer-events: none;
}

/* ── SECTION CARDS (History, Patch Notes) ── */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
}
.section-header:hover { background: var(--surface2); }
.section-header h3 { font-size: 15px; font-weight: 600; }

.section-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-danger-sm {
  background: none;
  border: 1px solid var(--negative, #e05c5c);
  color: var(--negative, #e05c5c);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  pointer-events: all;
  transition: background 0.15s, color 0.15s;
}
.btn-danger-sm:hover {
  background: var(--negative, #e05c5c);
  color: #fff;
}

.collapse-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  pointer-events: none;
  transition: background 0.15s;
}

.section-content { padding: 0 20px 20px; }

/* ── SNAPSHOT TABLE ── */
.snapshot-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.snapshot-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.snapshot-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--surface2);
}
.snapshot-table tr:hover td { background: var(--surface2); }
.snapshot-table tr:last-child td { border-bottom: none; }

.delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 15px;
  transition: color 0.15s;
}
.delete-btn:hover { color: var(--negative); }

/* ── PATCH NOTES ── */
.patch-notes-content { font-size: 13px; line-height: 1.6; }
.patch-version { margin-bottom: 18px; }
.patch-version:last-child { margin-bottom: 0; }
.patch-version h4 { color: var(--accent); font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.patch-version ul { list-style: none; padding: 0; }
.patch-version ul li {
  color: var(--text-muted);
  padding: 2px 0 2px 16px;
  position: relative;
}
.patch-version ul li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 11px;
  top: 3px;
}
.patch-version code {
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  color: var(--accent);
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header { padding: 24px 24px 0; position: relative; }
.modal-header h2 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.modal-header p  { color: var(--text-muted); font-size: 13px; margin-bottom: 16px; }
.modal-close {
  position: absolute;
  top: 20px; right: 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  line-height: 1;
}
.modal-close:hover { background: var(--surface2); color: var(--text); }

.modal-body {
  padding: 0 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.form-group label { font-size: 13px; font-weight: 500; }
.form-row { display: flex; gap: 12px; }

.form-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
  transition: border-color 0.15s;
  font-family: inherit;
}
.form-input:focus { outline: none; border-color: var(--accent); }

.date-input {
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
}
.date-input::-webkit-calendar-picker-indicator { filter: invert(0.5); cursor: pointer; }

textarea.form-input { resize: vertical; min-height: 120px; }

.btn-save {
  background: var(--accent);
  color: #0d1117;
  border: none;
  padding: 14px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: opacity 0.15s;
  margin-top: 4px;
}
.btn-save:hover { opacity: 0.85; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
  font-size: 14px;
}

/* ── INACTIVITY MODAL ── */
.inactivity-modal { max-width: 420px; }

.inactivity-icon {
  font-size: 36px;
  margin-bottom: 10px;
  display: block;
}

.inactivity-tip {
  background: rgba(0,212,160,0.08);
  border: 1px solid rgba(0,212,160,0.25);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 14px;
  line-height: 1.5;
}

.btn-dismiss {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 11px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
  margin-top: 8px;
  transition: background 0.15s, color 0.15s;
}
.btn-dismiss:hover { background: var(--border); color: var(--text); }

.inactivity-account-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--surface2);
  line-height: 1.5;
}
.inactivity-account-hint a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  opacity: 0.85;
  transition: opacity 0.15s;
}
.inactivity-account-hint a:hover { opacity: 1; text-decoration: underline; }

/* ── AUTH MODAL ── */
.auth-modal { max-width: 400px; }

.oauth-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  font-family: inherit;
}
.oauth-btn:hover  { opacity: 0.88; transform: translateY(-1px); }
.oauth-btn:active { transform: translateY(0); }

.google-btn {
  background: #ffffff;
  color: #1f1f1f;
  border: 1px solid #dadce0;
}
.apple-btn {
  background: #000000;
  color: #ffffff;
  border: 1px solid #000000;
}
.x-btn {
  background: #000000;
  color: #ffffff;
  border: 1px solid #2f2f2f;
}

.or-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 12px;
  margin: 2px 0;
}
.or-divider::before,
.or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-footer-link {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.auth-footer-link a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.auth-footer-link a:hover { text-decoration: underline; }

/* ── PRINT STYLES — pure black/white for monochrome laser printer compatibility ── */
.print-report { display: none; }

@media print {
  @page { size: letter portrait; margin: 0.4in; }

  body {
    background: white !important;
    color: black !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .no-print { display: none !important; }

  .print-report {
    display: block !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #000000;
    font-weight: 700;
    line-height: 1.5;
  }

  .pr-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 3px solid #000000;
  }
  .pr-header h1 {
    font-size: 24px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 6px;
    color: #000000;
  }
  .pr-header .pr-date {
    font-size: 12px;
    font-weight: 700;
    color: #000000;
  }

  .pr-kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 18px;
  }
  .pr-kpi {
    border: 2px solid #000000;
    border-radius: 5px;
    padding: 12px 14px;
    text-align: center;
    background: #ffffff;
  }
  .pr-kpi-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #000000;
    font-weight: 700;
    margin-bottom: 6px;
  }
  .pr-kpi-value {
    font-size: 16px;
    font-weight: 900;
    color: #000000;
    line-height: 1.3;
  }
  .pr-kpi-change {
    font-size: 11px;
    margin-top: 4px;
    color: #000000;
    font-weight: 700;
  }

  .pr-chart-box {
    border: 2px solid #000000;
    border-radius: 5px;
    padding: 12px;
    margin-bottom: 16px;
    background: #ffffff;
  }
  .pr-chart-box h4 {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    color: #000000;
    font-weight: 700;
  }
  .pr-chart-full img {
    width: 100%;
    height: auto;
    display: block;
  }

  .pr-history h4 {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    color: #000000;
    font-weight: 700;
  }
  .pr-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    line-height: 1.6;
  }
  .pr-history-table th {
    background: #ffffff;
    padding: 8px 10px;
    text-align: left;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #000000;
    border: 2px solid #000000;
    font-weight: 700;
  }
  .pr-history-table td {
    padding: 8px 10px;
    border: 1px solid #000000;
    color: #000000;
    font-weight: 700;
  }
  .pr-history-table tr:nth-child(even) td { background: #ffffff; }
  .pr-history-table tr:nth-child(odd) td { background: #ffffff; }
}

/* ── FOOTER ── */
.site-footer {
  text-align: center;
  padding: 20px 24px;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.site-footer a {
  color: var(--accent);
  text-decoration: none;
}
.site-footer a:hover { text-decoration: underline; }

/* ── SUPPORT BUTTON ── */
.btn-support {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

/* ── NAV ACTIVE STATE ── */
.btn-nav-active {
  color: var(--accent);
  border-color: var(--accent);
}
