* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #0d1117; color: #e6edf3; }
h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; color: #c9d1d9; }
a { color: #58a6ff; }

.topbar {
  display: flex; align-items: center; padding: 14px 24px; background: #161b22;
  border-bottom: 1px solid #30363d; position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; margin-right: 24px; }
.tabs { display: flex; gap: 4px; margin-right: auto; }
.tabs .tab { background: transparent; border: 1px solid transparent; color: #8b949e;
  font-size: 13px; padding: 6px 14px; border-radius: 6px; cursor: pointer; }
.tabs .tab:hover { color: #c9d1d9; background: #21262d; }
.tabs .tab.active { color: #c9d1d9; background: #21262d; border-color: #30363d; font-weight: 600; }
.digest-feed { padding: 8px 20px 40px; max-width: 860px; }
.digest-day { border: 1px solid #21262d; border-radius: 8px; background: #0d1117;
  padding: 14px 18px; margin-bottom: 12px; }
.digest-day.quiet { opacity: 0.55; }
.digest-day h3 { margin: 0 0 10px; font-size: 14px; color: #c9d1d9; }
.digest-day ul { margin: 0; padding: 0; list-style: none; }
.digest-day li { display: flex; align-items: baseline; gap: 8px; padding: 4px 0;
  font-size: 13px; line-height: 1.5; color: #adbac7; }
.sev-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; position: relative; top: -1px; }
.sev-badge { font-size: 10px; font-weight: 700; color: #e3b341; border: 1px solid #e3b34155;
  border-radius: 4px; padding: 0 5px; flex-shrink: 0; }
.sev-badge.trend { color: #8250df; border-color: #8250df55; }
.sev-badge.outlook { color: #3fb950; border-color: #3fb95055; }
.digest-bias { font-size: 12px; line-height: 1.45; color: #c9d1d9; padding: 6px 10px;
  margin-bottom: 10px; border-radius: 6px; background: #161b22; border-left: 3px solid #6e7681; }
.digest-bias.constructive { border-left-color: #3fb950; }
.digest-bias.distribution { border-left-color: #f85149; }
.digest-day.quiet .digest-bias { opacity: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; vertical-align: middle; }
.dot.green { background: #3fb950; }
.dot.yellow { background: #d29922; }
.dot.red { background: #f85149; }

/* Collapsible Data Health dropdown */
.health-dropdown { position: relative; margin-left: 16px; font-size: 12px; color: #8b949e; }
.health-dropdown summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border: 1px solid #30363d; border-radius: 6px; background: #0d1117;
  user-select: none; white-space: nowrap;
}
.health-dropdown summary::-webkit-details-marker { display: none; }
.health-dropdown summary::after {
  content: "▾"; font-size: 10px; color: #6e7681; margin-left: 2px;
}
.health-dropdown[open] summary::after { content: "▴"; }
.health-panel {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 20;
  background: #161b22; border: 1px solid #30363d; border-radius: 8px;
  padding: 8px; min-width: 260px; max-width: 320px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.health-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px;
  border-radius: 4px; font-size: 12px; color: #c9d1d9; cursor: help; }
.health-row:hover { background: #0d1117; }
.health-row .name { flex: 1; }
.health-row .age { color: #6e7681; font-size: 11px; }
.refresh { display: flex; align-items: center; gap: 10px; }
.asof { font-size: 12px; color: #8b949e; }
#refresh-btn {
  background: #238636; color: white; border: none; padding: 6px 14px;
  border-radius: 6px; cursor: pointer; font-size: 13px;
}
#refresh-btn:hover { background: #2ea043; }
#refresh-btn:disabled { background: #484f58; cursor: not-allowed; }

.cards { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 16px; padding: 20px; }
.card { background: #161b22; border: 1px solid #30363d; border-radius: 10px; padding: 16px; }
.card.wide { grid-column: span 1; }
.card .label { font-size: 11px; text-transform: uppercase; color: #8b949e; letter-spacing: 0.5px; margin-bottom: 8px; }
.price { font-size: 34px; font-weight: 700; }
.change { font-size: 13px; margin-top: 4px; }
.change.up { color: #3fb950; }
.change.down { color: #f85149; }
.supply { margin-top: 10px; font-size: 12px; color: #8b949e; display: flex; gap: 16px; }
.big { font-size: 26px; font-weight: 700; }
.sub { font-size: 12px; color: #8b949e; margin-top: 2px; }

.supply-bar {
  display: flex; height: 28px; border-radius: 6px; overflow: hidden; margin-top: 6px;
  background: #0d1117; border: 1px solid #30363d;
}
.supply-bar .seg { display: flex; align-items: center; justify-content: center; font-size: 11px; color: #fff; }
.supply-bar .escrow { background: #1f6feb; }
.supply-bar .custody { background: #8250df; }
.supply-bar .circulating { background: #3fb950; }
.supply-legend { margin-top: 10px; font-size: 12px; color: #c9d1d9; display: flex; gap: 18px; flex-wrap: wrap; }
.supply-legend .swatch { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: middle; border-radius: 2px; }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 0 20px 20px; }
.chart-card { background: #161b22; border: 1px solid #30363d; border-radius: 10px; padding: 16px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.chart-head h3 { margin: 0; }
.chart-head label { font-size: 12px; color: #8b949e; }
.chart-card canvas { display: block; width: 100% !important; height: 260px !important; max-height: 260px; }
.chart-card .hint { font-size: 11px; color: #6e7681; margin-top: 8px; font-style: italic; }
.chart-card.pro-gated { position: relative; }
.chart-card.pro-gated canvas { opacity: 0.4; }
.pro-badge {
  display: inline-block; background: #8250df; color: white; font-size: 10px;
  padding: 2px 6px; border-radius: 3px; margin-left: 6px; vertical-align: middle;
  font-weight: 600; letter-spacing: 0.3px;
}
.pro-badge.sm { font-size: 9px; padding: 1px 4px; margin-left: 4px; }
td.muted { color: #484f58; }

tr.totals-row td {
  border-top: 2px solid #30363d;
  background: #0d1117;
  font-weight: 600;
  color: #e6edf3;
}
tr.totals-row td .sub { color: #8b949e; font-weight: 400; font-size: 10px; margin-left: 2px; }

/* Supply-shock section */
.section-header { padding: 28px 20px 8px; }
.section-header h2 { margin: 0; font-size: 18px; color: #c9d1d9; font-weight: 600; }
.section-header p { margin: 4px 0 0; font-size: 13px; color: #8b949e; }

.supply-grid { padding: 0 20px 8px; }
.supply-multi-bar {
  display: flex; height: 32px; border-radius: 6px; overflow: hidden; margin-top: 8px;
  background: #0d1117; border: 1px solid #30363d;
}
.supply-multi-bar .seg { display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #fff; font-weight: 600; min-width: 1px; }
.supply-multi-legend { margin-top: 14px; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; font-size: 12px; }
.supply-multi-legend .row {
  background: #0d1117; border: 1px solid #21262d; border-radius: 6px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 5px;
  min-width: 0;
}
.supply-multi-legend .row .head { display: flex; align-items: center; gap: 8px; color: #c9d1d9;
  font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.supply-multi-legend .row .swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.supply-multi-legend .row .val { color: #e6edf3; font-size: 14px; font-weight: 600; }
.supply-multi-legend .row .val .pct { color: #8b949e; font-weight: 400; font-size: 12px; margin-left: 4px; }
.supply-multi-legend .row .meta { display: flex; justify-content: space-between;
  font-size: 11px; color: #6e7681; }
.supply-multi-legend .row .up { color: #3fb950; }
.supply-multi-legend .row .down { color: #f85149; }

.top-wallet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  grid-auto-flow: column;   /* fill top-to-bottom, then next column */
  gap: 16px;
  margin-top: 12px;
}
.top-wallet-grid h4 { margin: 0 0 8px; font-size: 12px; color: #8b949e; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.mini-table { width: 100%; border-collapse: collapse; background: #161b22; border: 1px solid #30363d; border-radius: 8px; overflow: hidden; }
.mini-table td { padding: 6px 10px; font-size: 12px; border-bottom: 1px solid #21262d; }
.mini-table tr:last-child td { border-bottom: none; }
.mini-table td.name { color: #c9d1d9; }
.mini-table .up { color: #3fb950; }
.mini-table .down { color: #f85149; }
.mini-table .muted { color: #6e7681; font-style: italic; }

.empty { padding: 20px; color: #6e7681; font-style: italic; text-align: center; }

.chart-card.wide-span { grid-column: 1 / -1; }
.chart-card.wide-span canvas { height: 320px !important; max-height: 320px; }
.pinned-badge {
  display: inline-block; background: #d29922; color: #0d1117; font-size: 10px;
  padding: 2px 6px; border-radius: 3px; margin-left: 8px; vertical-align: middle;
  font-weight: 700; letter-spacing: 0.3px;
}

.table-section { padding: 0 20px 40px; }
table { width: 100%; border-collapse: collapse; background: #161b22; border: 1px solid #30363d; border-radius: 10px; overflow: hidden; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid #21262d; font-size: 13px; }
th { background: #0d1117; color: #8b949e; font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

footer { text-align: center; padding: 20px; color: #6e7681; font-size: 12px; border-top: 1px solid #21262d; }
footer .disclaimer { max-width: 860px; margin: 10px auto 0; font-size: 11px; line-height: 1.5; color: #57606a; }

/* Let the Fund-comparison table scroll horizontally inside its container if needed */
.table-section:has(#holdings) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#holdings { min-width: 720px; }

/* Mini-tables in top-wallets grid: don't clip cell content, but DO allow
   them to size to their container on narrow screens. */
.mini-table { overflow: visible; table-layout: auto; width: 100%; }
.mini-table td { white-space: nowrap; }

/* Chart canvas: height via wrapper style on mobile so Chart.js resizes cleanly */
@media (max-width: 900px) {
  .cards { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .charts { grid-template-columns: 1fr; padding: 0 12px 20px; gap: 12px; }
  .chart-card { padding: 12px; }
  .chart-card canvas { height: 240px !important; max-height: 240px; }
  .chart-card.wide-span canvas { height: 280px !important; max-height: 280px; }
  .supply-grid { padding: 0 12px 8px; }
  .table-section { padding: 0 12px 30px; }
  .section-header { padding: 20px 12px 4px; }
  .section-header h2 { font-size: 16px; }
  .section-header p { font-size: 12px; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .brand { font-size: 15px; margin-right: 8px; flex-shrink: 0; }
  .health-dropdown { margin-left: 8px; }
  .health-dropdown summary span:not(.dot) { display: none; }   /* just the dot on mobile */
  .refresh { margin-left: auto; }
  .price { font-size: 28px; }
  .big { font-size: 22px; }
  .supply-multi-legend { grid-template-columns: 1fr; }
  .top-wallet-grid { grid-template-columns: 1fr; grid-auto-flow: row; }
  .mini-table td { font-size: 11px; padding: 5px 8px; white-space: normal; }
}

/* Extra-tight phones */
@media (max-width: 480px) {
  .chart-card canvas { height: 210px !important; max-height: 210px; }
  .chart-card.wide-span canvas { height: 240px !important; max-height: 240px; }
  .price { font-size: 24px; }
  .supply-bar, .supply-multi-bar { height: 24px; }
  .supply-bar .seg, .supply-multi-bar .seg { font-size: 9px; }
  th, td { padding: 8px 10px; font-size: 12px; }
  th { font-size: 10px; }
}
