/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0f1117;
  --bg-card:     #1a1d27;
  --bg-card2:    #20243a;
  --border:      #2a2e42;
  --text:        #e2e8f0;
  --text-muted:  #8892a4;
  --accent:      #6c8ef5;
  --green:       #34d399;
  --red:         #f87171;
  --font:        'Inter', system-ui, -apple-system, sans-serif;
  --radius:      12px;
  --radius-sm:   8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

.container {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Header ───────────────────────────────────────────────── */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 18px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.site-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.header-title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header-title-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.site-tagline {
  font-size: 11px;
  font-style: italic;
  color: var(--text-muted);
  opacity: 0.7;
}

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

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.portfolio-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.portfolio-total {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.card:hover {
  transform: scale(1.02);
  border-color: rgba(108, 142, 245, 0.4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.holdings-card:hover,
.modal-card:hover {
  transform: none;
  border-color: var(--border);
  box-shadow: none;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  letter-spacing: -0.1px;
}

/* ── Quote Banner ─────────────────────────────────────────── */
.quote-banner {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}

.quote-banner .container {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.quote-text {
  font-style: italic;
  font-size: 13px;
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
}

.quote-text::before { content: '"'; }
.quote-text::after  { content: '"'; }

.quote-author {
  font-size: 12px;
  color: var(--accent);
  white-space: nowrap;
  opacity: 0.8;
}

.quote-author::before { content: '— '; }

/* ── Summary Cards ────────────────────────────────────────── */
main.container { padding: 28px 24px; }

.summary-cards {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 1200px) {
  .summary-cards { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .summary-cards { grid-template-columns: 1fr; }
}

.summary-card {
  padding: 18px 20px;
}

.card-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.card-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
}

.card-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Charts Row ───────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 1000px) {
  .charts-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .charts-row { grid-template-columns: 1fr; }
}

.chart-card {
  display: flex;
  flex-direction: column;
}

.chart-wrap {
  position: relative;
  width: 100%;
  max-width: 260px;
  margin: 0 auto 16px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: auto !important;
}

/* ── Legend ───────────────────────────────────────────────── */
.legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

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

.legend-label {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-pct {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

.legend-value {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Performance Chart ────────────────────────────────────── */
.performance-card {
  margin-bottom: 24px;
}

.performance-chart-wrap {
  position: relative;
  height: 260px;
}

.currency-note {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  background: rgba(251,191,36,0.12);
  color: #fbbf24;
  border-radius: 3px;
  padding: 1px 4px;
  margin-left: 5px;
  vertical-align: middle;
}

/* ── Holdings Table ───────────────────────────────────────── */
.holdings-card {
  padding: 20px 0;
}

.holdings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.holdings-title-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.holdings-title-row .card-title {
  margin-bottom: 0;
}

.prices-updated-label {
  font-size: 11px;
  color: var(--text-muted);
}

.table-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.table-wrap {
  overflow-x: auto;
}

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

.holdings-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.holdings-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}

.holdings-table th.sortable:hover {
  color: var(--text);
}

.holdings-table th.sort-active {
  color: var(--accent);
}

.sort-ind {
  font-size: 9px;
  opacity: 0.8;
}

.holdings-table th.num,
.holdings-table td.num {
  text-align: right;
}

.holdings-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.holdings-table tbody tr:last-child td {
  border-bottom: none;
}

.holdings-table tbody tr {
  transition: background 0.1s;
}

.holdings-table tbody tr:hover {
  background: var(--bg-card2);
}

.holding-name {
  font-weight: 500;
  color: var(--text);
}

.holding-ticker {
  display: inline-block;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.badge {
  display: inline-block;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}

.badge-equity     { background: rgba(108,142,245,0.12); color: #6c8ef5; }
.badge-fixed      { background: rgba(251,191,36,0.12);  color: #fbbf24; }
.badge-alt        { background: rgba(167,139,250,0.12); color: #a78bfa; }
.badge-cash       { background: rgba(52,211,153,0.12);  color: #34d399; }

.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral  { color: var(--text-muted); }

.alloc-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.alloc-bar {
  width: 60px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.alloc-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
}

.alloc-pct {
  font-size: 12px;
  color: var(--text-muted);
  width: 40px;
  text-align: right;
}


/* ── Language Toggle ──────────────────────────────────────── */
.lang-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  cursor: pointer;
  font-family: var(--font);
  transition: color 0.15s, border-color 0.15s;
}

.lang-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Dividends by Year ────────────────────────────────────── */
.dividends-card {
  margin-bottom: 24px;
}

.dividends-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.dividends-header .card-title {
  margin-bottom: 0;
}

.div-year-totals {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.div-year-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.div-year {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
}

.div-total {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.dividends-chart-wrap {
  position: relative;
  height: 260px;
}

/* ── Dividends Detail View ────────────────────────────────── */
.dividends-detail { display: none; }

.dividends-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.dividends-detail-year {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.dividends-detail-body {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.dividends-detail-chart-wrap {
  width: 220px;
  flex-shrink: 0;
}

.dividends-detail-chart-wrap canvas {
  width: 100% !important;
  height: auto !important;
}

.back-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font);
  transition: color 0.15s, border-color 0.15s;
}

.back-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Dividend Year Modal ──────────────────────────────────── */
.div-year-item {
  cursor: pointer;
  transition: opacity 0.15s;
}
.div-year-item:hover { opacity: 0.7; }

.div-year-grand-total {
  border-left: 1px solid var(--border);
  padding-left: 20px;
  margin-left: 4px;
  cursor: default;
}
.div-year-grand-total:hover { opacity: 1; }
.div-year-grand-total .div-total { color: var(--accent); }

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 16px 0;
  margin-top: 32px;
}

.footer-disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.6;
  text-align: center;
  margin: 0;
  line-height: 1.5;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.open { display: flex; }

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  font-family: var(--font);
}
.modal-close:hover { color: var(--text); }

.modal-chart-wrap {
  max-width: 220px;
  margin: 0 auto 20px;
}

.modal-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Utility ──────────────────────────────────────────────── */
.hidden { display: none !important; }
