:root {
  color-scheme: light;
  --ink: #241f18;
  --muted: #6f675c;
  --paper: #f7f3ea;
  --card: rgba(255, 255, 255, 0.88);
  --line: rgba(68, 57, 43, 0.13);
  --gold: #b8862d;
  --silver: #66717e;
  --positive: #24734d;
  --negative: #a33f34;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -10%, rgba(214, 174, 88, 0.2), transparent 34rem),
    radial-gradient(circle at 96% 14%, rgba(146, 156, 168, 0.18), transparent 28rem),
    var(--paper);
}

.toolbar {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.user { font-weight: 650; }
.logout {
  color: inherit;
  text-underline-offset: 3px;
  border: 0;
  background: none;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
  min-height: 44px;
}
.logout:hover { color: var(--ink); }
.value-link { color: #745117; font-weight: 750; text-underline-offset: 3px; }
.value-link:hover { color: var(--ink); }
.site-version { margin: 0 auto 14px; width: min(1440px, calc(100% - 40px)); color: var(--muted); font-size: 0.68rem; text-align: right; font-variant-numeric: tabular-nums; }

.shell {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 12px 0 48px;
}

.demo-banner {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 13px 16px;
  margin-bottom: 18px;
  border: 1px solid rgba(184, 134, 45, 0.3);
  border-radius: 14px;
  background: rgba(255, 247, 218, 0.78);
  color: #6f4c0e;
  font-size: 0.9rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.metric,
.chart-card,
.asset-card {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: 0 18px 50px rgba(49, 40, 28, 0.07);
  backdrop-filter: blur(14px);
}

.metric {
  display: flex;
  flex-direction: column;
  min-height: 122px;
  padding: 22px 24px;
  border-radius: 18px;
}

.metric-total {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(130deg, #2c2822, #544736);
}
.metric-total .eyebrow,
.metric-total span:last-child { color: rgba(255, 255, 255, 0.69); }

.eyebrow {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.metric strong {
  margin: 8px 0 5px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 3vw, 2.3rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.metric span:last-child { color: var(--muted); font-size: 0.82rem; }

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

.status {
  min-height: 28px;
  padding: 3px 2px 10px;
  color: var(--muted);
  font-size: 0.82rem;
}
.status-ready { color: var(--muted); }
.status-error { color: var(--negative); font-weight: 650; }

.charts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.chart-card {
  min-width: 0;
  overflow: hidden;
  border-radius: 22px;
}
.chart-card-gold { border-top: 3px solid rgba(184, 134, 45, 0.72); }
.chart-card-silver { border-top: 3px solid rgba(102, 113, 126, 0.72); }

.chart-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 26px 10px;
}
.chart-heading h2 {
  margin: 4px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.7rem;
  font-weight: 600;
}
.metal-value { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.metal-value strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.metal-value span { color: var(--muted); font-size: 0.8rem; }

.chart-wrap { position: relative; width: 100%; padding: 0 10px; }
.chart { display: block; width: 100%; height: auto; min-height: 270px; touch-action: pan-y; }
.grid-line { stroke: rgba(64, 53, 41, 0.1); stroke-width: 1; }
.axis-label { fill: #82786d; font-family: inherit; font-size: 11px; }
.line-path { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.area-path { opacity: 0.45; }
.focus-line { stroke: rgba(45, 38, 30, 0.28); stroke-width: 1; stroke-dasharray: 3 4; }
.focus-dot { stroke: white; stroke-width: 2; }
.focus-line[hidden],
.focus-dot[hidden],
.comparison-focus-dot[hidden],
.asset-focus-dot[hidden] { display: none; }
.purchase-marker { stroke: white; stroke-width: 2; cursor: help; }
.empty-label { fill: var(--muted); font-family: inherit; font-size: 14px; }

.tooltip {
  position: absolute;
  z-index: 2;
  transform: translateX(-50%);
  min-width: 132px;
  padding: 9px 11px;
  border-radius: 10px;
  color: #fff;
  background: rgba(38, 33, 27, 0.94);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  pointer-events: none;
  text-align: center;
  font-size: 0.76rem;
}
.tooltip strong,
.tooltip span { display: block; }
.tooltip span { margin-top: 3px; color: rgba(255, 255, 255, 0.7); }

.chart-summary {
  min-height: 48px;
  padding: 12px 26px 17px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.view-controls {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin: 2px 0 20px;
  padding: 17px 20px;
  border: 1px solid rgba(184, 134, 45, 0.22);
  border-radius: 16px;
  background: rgba(255, 250, 237, 0.66);
}
.view-controls > div { min-width: 0; }
.view-controls h2 {
  margin: 4px 0 3px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  font-weight: 600;
}
.view-controls p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}
.view-controls .reference-selector { flex: 0 0 min(220px, 34vw); }

.reference-section { margin-top: 34px; }
.reference-heading { align-items: flex-end; }
.reference-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 3px solid rgba(184, 134, 45, 0.72);
  border-radius: 22px;
  background: var(--card);
  box-shadow: 0 18px 50px rgba(49, 40, 28, 0.07);
  backdrop-filter: blur(14px);
}
.reference-controls {
  padding: 22px 26px 12px;
}
.reference-selector {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.reference-selector select {
  width: 100%;
  min-height: 42px;
  padding: 9px 36px 9px 12px;
  border: 1px solid rgba(184, 134, 45, 0.28);
  border-radius: 11px;
  color: var(--ink);
  background: rgba(255, 250, 237, 0.9);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
}
.reference-selector select:focus-visible,
.series-toggles input:focus-visible {
  outline: 3px solid rgba(184, 134, 45, 0.24);
  outline-offset: 2px;
}
.series-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.series-toggles legend {
  width: 100%;
  margin-bottom: 1px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.series-toggles label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(249, 247, 242, 0.72);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 750;
  user-select: none;
}
.series-toggles label.series-reference {
  border-color: rgba(184, 134, 45, 0.46);
  background: rgba(244, 223, 170, 0.42);
  cursor: default;
}
.series-toggles input { margin: 0; accent-color: var(--gold); }
.series-toggles input:disabled { opacity: 0.72; }
.series-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #777;
  transition: opacity 120ms ease;
}
.series-toggles input:not(:checked) + .series-dot { opacity: 0.25; }
.series-toggles input[data-series="gold"] + .series-dot { background: #b8862d; }
.series-toggles input[data-series="silver"] + .series-dot { background: #66717e; }
.series-toggles input[data-series="EUR"] + .series-dot { background: #1769aa; }
.series-toggles input[data-series="USD"] + .series-dot { background: #24734d; }
.series-toggles input[data-series="GBP"] + .series-dot { background: #7a4e9f; }
.series-toggles input[data-series="CHF"] + .series-dot { background: #b7473d; }
.series-toggles input[data-series="JPY"] + .series-dot { background: #d9781f; }
.series-toggles input[data-series="CNY"] + .series-dot { background: #157c83; }
.series-note {
  width: 100%;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.45;
}
.reference-chart-wrap { position: relative; width: 100%; padding: 0 10px; }
.currency-chart {
  display: block;
  width: 100%;
  height: auto;
  min-height: 300px;
  touch-action: pan-y;
}
.comparison-reference-label {
  font-family: inherit;
  font-size: 11px;
  font-weight: 750;
}
.comparison-series-line,
.asset-series-line {
  fill: none;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.comparison-reference-series,
.asset-reference-series {
  stroke-width: 2.8;
}
.comparison-focus-dot,
.asset-focus-dot { stroke: #fff; stroke-width: 2; }
.currency-tooltip,
.comparison-tooltip { min-width: 190px; text-align: left; }
.tooltip .tooltip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 4px;
}
.tooltip .tooltip-row span { margin: 0; color: rgba(255, 255, 255, 0.75); }
.reference-summary {
  min-height: 48px;
  padding: 12px 26px 17px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

@media (max-width: 590px) {
  .view-controls { align-items: stretch; flex-direction: column; gap: 14px; padding: 16px; }
  .view-controls .reference-selector { flex: none; }
  .reference-controls { padding: 18px 16px 10px; }
  .reference-heading { align-items: flex-start; }
  .currency-chart { min-height: 245px; }
  .reference-summary { padding-inline: 16px; }
}

.assets-section { margin-top: 34px; }
.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 0 3px 15px;
}
.section-heading h2 {
  margin: 5px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 600;
}
.section-heading p {
  max-width: 610px;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.55;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.asset-card {
  min-width: 0;
  overflow: hidden;
  border-radius: 22px;
}
.asset-card-gold { border-top: 3px solid rgba(184, 134, 45, 0.72); }
.asset-card-silver { border-top: 3px solid rgba(102, 113, 126, 0.72); }
.asset-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 15px;
}
.asset-title { min-width: 0; }
.asset-title h3 {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.15;
}
.weight-chip {
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid rgba(184, 134, 45, 0.25);
  border-radius: 999px;
  color: #6f4c0e;
  background: rgba(244, 223, 170, 0.46);
  font-size: 0.78rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.asset-card-silver .weight-chip {
  border-color: rgba(102, 113, 126, 0.26);
  color: #3f4a56;
  background: rgba(223, 229, 234, 0.6);
}
.asset-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 24px 10px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(249, 247, 242, 0.68);
}
.asset-stat {
  min-width: 0;
  padding: 13px 14px 12px;
}
.asset-stat + .asset-stat { border-left: 1px solid var(--line); }
.asset-stat-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.asset-stat strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}
.asset-stat small {
  display: block;
  min-height: 2.4em;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.25;
}
.asset-stat small.positive { color: var(--positive); }
.asset-stat small.negative { color: var(--negative); }
.asset-chart-wrap {
  position: relative;
  width: 100%;
  padding: 0 9px;
}
.asset-chart {
  display: block;
  width: 100%;
  height: auto;
  touch-action: pan-y;
}
.asset-series-line {
  stroke-width: 2.15;
}
.asset-reference-series {
  stroke-dasharray: 7 4;
}
.purchase-gap-line {
  stroke: var(--negative);
  stroke-width: 1.5;
  stroke-dasharray: 2 3;
}
.market-start-dot,
.paid-purchase-dot { stroke: white; stroke-width: 2; }
.paid-purchase-dot {
  fill: #312b24;
  stroke-width: 2.5;
}
.asset-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  min-height: 46px;
  padding: 10px 24px 15px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
}
.asset-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.legend-line {
  display: inline-block;
  width: 22px;
  height: 0;
  border-top: 2px solid;
}
.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.legend-paid-dot { background: #312b24; }
.legend-gold { border-color: var(--gold); }
.legend-silver { border-color: var(--silver); }
.legend-series { border-color: var(--series-color, #555); }
.legend-series-dashed { border-top-style: dashed; }
.asset-baseline-note {
  margin: -7px 24px 16px;
  color: var(--muted);
  font-size: 0.69rem;
  line-height: 1.45;
}
.asset-empty,
.asset-unavailable {
  margin: 0;
  padding: 24px;
  color: var(--muted);
  font-size: 0.85rem;
}
.asset-empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 18px;
  text-align: center;
}

.source-note {
  max-width: 900px;
  margin: 18px 2px 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.55;
}

.login-page { display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(430px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  box-shadow: 0 24px 70px rgba(49, 40, 28, 0.12);
}
.login-card h1 { margin: 8px 0 14px; font-family: Georgia, "Times New Roman", serif; font-size: 2rem; }
.login-form { display: grid; gap: 10px; }
.login-form label { font-size: 0.88rem; }
.login-form input { width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: white; font: inherit; }
.login-form input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.login-form button { margin-top: 10px; border: 0; min-height: 44px; font: inherit; cursor: pointer; }
.login-form button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.error-message { margin: 0 0 24px; color: var(--negative); line-height: 1.5; }
.primary-button {
  display: inline-block;
  padding: 11px 15px;
  border-radius: 10px;
  color: white;
  background: #3c352d;
  text-decoration: none;
  font-weight: 650;
}

@media (max-width: 920px) {
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .metric-total { grid-column: 1 / -1; }
  .charts,
  .asset-grid { grid-template-columns: 1fr; }
}

@media (max-width: 590px) {
  .toolbar,
  .shell { width: min(100% - 24px, 1440px); }
  .toolbar { min-height: 54px; }
  .summary-grid { grid-template-columns: 1fr; }
  .metric-total { grid-column: auto; }
  .metric { min-height: 104px; padding: 18px; }
  .demo-banner { align-items: flex-start; flex-direction: column; gap: 4px; }
  .chart-heading { padding: 20px 18px 8px; }
  .chart-summary { padding-inline: 18px; }
  .chart { min-height: 230px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 7px; }
  .asset-heading { padding: 19px 16px 13px; }
  .asset-title h3 { font-size: 1.3rem; }
  .asset-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0 14px 6px;
  }
  .asset-stat { padding: 12px 10px; }
  .asset-stat-current {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    border-left: 0 !important;
  }
  .asset-legend { padding-inline: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
