:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #fcfcfb;
  --surface-2: #f0ede6;
  --line: #e2ded4;
  --grid: #ebe8e0;
  --text: #1b1a18;
  --text-2: #52514e;
  --text-3: #7a786f;
  --accent: #856b3a;
  --s1: #2a78d6; /* platinum */
  --s2: #eb6834; /* rose gold */
  --s3: #1baf7a; /* other golds */
  --m-white: #1baf7a; /* white gold (production strips) */
  --m-yellow: #6250d6; /* yellow gold (production strips) */
  --median: #1b1a18;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
}
/* Night series steps, shared by every dark scheme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #33322f; --grid: #2a2927;
    --text: #f0efec; --text-2: #c3c2b7; --text-3: #8f8d85; --accent: #c9a96a;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --median: #f0efec;
    --m-white: #199e70; --m-yellow: #9085e9;
  }
}
:root[data-theme="dark"], :root[data-theme="slate"], :root[data-theme="forest"] {
  color-scheme: dark;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70;
  --m-white: #199e70; --m-yellow: #9085e9;
}
/* Color schemes chosen in Settings (saved as p5101-theme). "light" is the default Ivory. */
:root[data-theme="dark"] {
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #33322f; --grid: #2a2927;
  --text: #f0efec; --text-2: #c3c2b7; --text-3: #8f8d85; --accent: #c9a96a; --median: #f0efec;
}
:root[data-theme="enamel"] {
  --bg: #f3f4f6; --surface: #ffffff; --surface-2: #eceef2; --line: #dce0e6; --grid: #e8ebef;
  --text: #141820; --text-2: #5a616d; --text-3: #767c87; --accent: #7a6230; --median: #141820;
}
:root[data-theme="salmon"] {
  --bg: #f6ebe4; --surface: #fdf6f1; --surface-2: #f3e4db; --line: #e8d4c9; --grid: #efe0d7;
  --text: #2a1c17; --text-2: #765c53; --text-3: #8e756c; --accent: #85601f; --median: #2a1c17;
}
:root[data-theme="slate"] {
  --bg: #11151b; --surface: #191f27; --surface-2: #212833; --line: #29313c; --grid: #232a34;
  --text: #e3e8ee; --text-2: #b4bcc6; --text-3: #8893a1; --accent: #d4b57a; --median: #e3e8ee;
}
:root[data-theme="forest"] {
  --bg: #0f1512; --surface: #16201b; --surface-2: #1e2a24; --line: #26332c; --grid: #212c26;
  --text: #e5ebe3; --text-2: #b7c0b8; --text-3: #8a9a8e; --accent: #d8bb7c; --median: #e5ebe3;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); }
a { color: inherit; text-decoration-color: var(--text-3); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--accent); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

.masthead { border-bottom: 1px solid var(--line); padding: 48px 0 32px; }
.masthead .wrap { position: relative; }
.settings { position: absolute; top: -28px; right: 16px; z-index: 5; }
.gear { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text-2); cursor: pointer; padding: 0; }
.gear:hover, .gear[aria-expanded="true"] { color: var(--text); }
.gear:focus-visible, .settings-panel select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.settings-panel { position: absolute; right: 0; top: 46px; width: 260px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: 0 8px 24px rgb(0 0 0 / .14); font-size: 14px; }
.settings-panel[hidden] { display: none; }
.settings-panel .field { display: grid; gap: 6px; font-weight: 500; }
.settings-panel select { font: 400 14px var(--sans); color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; }
.swatches { display: flex; gap: 4px; margin-top: 10px; }
.swatches span { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line); }
.eyebrow { margin: 0 0 8px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
h1 { margin: 0; font: 600 clamp(36px, 6vw, 56px)/1.05 var(--serif); letter-spacing: -.01em; }
.lede { margin: 12px 0 0; color: var(--text-2); max-width: 640px; }
#asof { color: var(--text-3); }
h2 { margin: 0; font: 600 26px/1.2 var(--serif); }
.sub { margin: 4px 0 0; color: var(--text-2); font-size: 14px; max-width: 640px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 24px 0; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.kpi .label { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }
.kpi .value { font: 600 32px/1.1 var(--serif); margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .note { font-size: 13px; color: var(--text-3); margin-top: 2px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.panel-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: 500 13px var(--sans); color: var(--text-2); background: transparent; border: 0; padding: 7px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }

.legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 16px 0 4px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend i.ring { background: transparent !important; border: 2px solid var(--text-3); }
.legend i.line { width: 16px; height: 2px; border-radius: 1px; background: var(--median); }

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--text-3); font: 12px var(--sans); font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .dot { cursor: pointer; }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; box-shadow: 0 4px 16px rgb(0 0 0 / .12); max-width: 260px; z-index: 2; }
.tip b { font-variant-numeric: tabular-nums; }
.tip .muted { color: var(--text-2); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 16px; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: var(--bg); }
.card .when { font-size: 12px; color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.card .house { font: 600 20px/1.2 var(--serif); margin: 4px 0 2px; }
.card .meta { font-size: 13px; color: var(--text-2); }
.card .est { margin-top: 8px; font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px -4px 16px; overflow-x: auto; }
.tabs button { font: 600 15px var(--sans); color: var(--text-2); background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 12px; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.count { font-weight: 500; color: var(--text-3); font-size: 13px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select { font: 14px var(--sans); color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.filters input { flex: 1 1 260px; min-width: 0; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
th[aria-sort="ascending"]::after { content: " ↑"; }
th[aria-sort="descending"]::after { content: " ↓"; }
td { padding: 9px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
tbody tr.row { cursor: pointer; }
tbody tr.row:hover td { background: var(--surface-2); }
td.mono { font-variant-numeric: tabular-nums; white-space: nowrap; }
td:has(> .swatch:first-child) { white-space: nowrap; }
.swatch { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-2); white-space: nowrap; }
.pill.sold { color: var(--text); }
.pill.upcoming { border-color: var(--accent); color: var(--accent); }
.muted { color: var(--text-3); }
tr.detail td { background: var(--bg); padding: 14px 16px 18px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 20px; margin-bottom: 12px; font-size: 13px; }
.detail-grid dt { color: var(--text-3); font-size: 12px; }
.detail-grid dd { margin: 0; }
.history { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.history li { padding: 6px 0; border-top: 1px dashed var(--line); display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; }
.history li .p { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 24px; text-align: center; color: var(--text-3); }

.prod-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 16px 0 4px; }
.hero .big { font: 600 48px/1 var(--serif); font-variant-numeric: tabular-nums; }
.hero .cap { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.prod-top .legend { margin: 0; }
.diamond-key { width: 10px; height: 10px; fill: var(--text-2); flex: none; }
td .diamond-key { margin-right: 6px; vertical-align: -1px; }
#runs { margin-top: 8px; }
#runs .track { fill: var(--surface-2); }
#runs .ext { fill: none; stroke: var(--text-3); stroke-dasharray: 3 3; stroke-width: 1; }
#runs .lbl { fill: var(--text); font: 600 13px var(--sans); }
#runs .lbl2 { fill: var(--text-2); font: 12px var(--sans); font-variant-numeric: tabular-nums; }
.prod-table { margin-top: 12px; }
.prod-table th { cursor: default; }
.prod-table tr.sub td { color: var(--text-2); font-size: 13px; padding-top: 5px; padding-bottom: 5px; }
.prod-table tr.sub td:first-child { padding-left: 26px; }
.prod-table tr.total td { font-weight: 600; border-bottom: 0; }
.caveats { margin: 14px 0 0; padding-left: 18px; color: var(--text-2); font-size: 13px; }
.caveats li + li { margin-top: 4px; }

.foot { color: var(--text-3); font-size: 13px; padding-bottom: 40px; }

@media (max-width: 720px) {
  .masthead { padding: 32px 0 24px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi .value { font-size: 26px; }
  .panel { padding: 16px 12px; }
  .history li { grid-template-columns: 84px 1fr; }
  .history li .p { grid-column: 2; text-align: left; }
  .hide-sm { display: none; }
  .settings { top: -20px; right: 12px; }
  .masthead .eyebrow { padding-right: 48px; }
  .prod-table th, .prod-table td { padding-left: 6px; padding-right: 6px; }
  .prod-table th { letter-spacing: 0; }
  .prod-table td:has(> .swatch:first-child) { white-space: normal; }
  .prod-table tr.sub td:first-child { padding-left: 18px; }
  .hero .big { font-size: 40px; }
}
