/* perf.jessehaynes.com. Styled to Tractor Supply's brand tokens, taken from
   the TSC prototype design system (lifeisbeta/tsc, extracted from the live
   site): TSC red #a02817, ink #222, cream #f9f6f2, Zilla Slab display,
   Roboto body, full-pill primary CTAs. Title Case, no emoji. */
:root {
  --bg: #ffffff;          /* the camera demo skin: white page, cream cards */
  --surface: #ffffff;
  --surface-2: #f6f4f0;   /* tsc-surface */
  --cream: #fbf7f1;
  --line: #e3dfd8;        /* tsc-line */
  --ink: #222222;         /* tsc-ink */
  --ink-2: #6b6b6b;       /* tsc-muted */
  --ink-3: #8a8a8a;
  --accent: #a02817;      /* tsc-red: CTA, logo, footer */
  --accent-dark: #7a1f12; /* pressed */
  --accent-ink: #ffffff;
  --good: #468254;        /* tsc-success */
  --critical: #b5121b;
  --warning: #d4a017;     /* tsc-gold */
  --navy: #27455c;
  /* categorical series: TSC red leads as the focus site; the rest are the
     validated dataviz order minus anything that reads as TSC red */
  --s1: #a02817; --s2: #27455c; --s3: #1baf7a; --s4: #d4a017; --s5: #2a78d6; --s6: #e87ba4; --s7: #4a3aa7; --s8: #eb6834;
  /* sequential ramp for magnitude: cream -> TSC red */
  --q1: #f6e4e0; --q2: #ecc6bf; --q3: #e0a69c; --q4: #d0837a; --q5: #c05d51; --q6: #a02817; --q7: #7a1f12;
  --radius: 12px;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
  --sans: "Roboto", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --serif: "Zilla Slab", Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button { font: inherit; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 24px 64px; }

/* red announcement bar + white brand header, same shape as jessehaynes.com/camera-demo */
.topbar { background: var(--accent); color: #fff; font: 500 14px/1 var(--sans); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 40px; padding-block: 0; }
.topbar-right { flex: none; opacity: 0.9; }
header.brand { border-bottom: 1px solid var(--line); background: #fff; }
.brand-in { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-block: 16px; }
.brand-logo img { height: 52px; width: auto; display: block; }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hero-copy { padding: 40px 0 8px; max-width: 760px; }
.eyebrow { font: 700 12px/1 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin: 0 0 12px; }
.hero-copy h1 { font: 700 clamp(36px, 5vw, 56px)/1.02 var(--serif); letter-spacing: -0.01em; margin: 0; color: var(--ink); }
.hero-copy .lede { font-size: 17px; line-height: 1.6; color: var(--ink-2); margin: 20px 0 0; }

.controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; padding: 28px 0 18px; }
.ctl { display: flex; flex-direction: column; gap: 6px; }
.ctl label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); }
/* every single-line control shares .field so selects match inputs */
.field, .seg button { height: 38px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 0 12px; }
select.field { appearance: none; -webkit-appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2352514e' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; min-width: 180px; }
input.field { min-width: 220px; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; cursor: pointer; color: var(--ink-2); }
.seg button:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); position: relative; z-index: 1; }
.btn { height: 38px; padding: 0 18px; border-radius: 100px; font-weight: 700; font-size: 14px; text-decoration: none; border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--ink); display: inline-flex; align-items: center; gap: 8px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.secondary { color: var(--accent); border-color: var(--accent); background: #fff; }
.btn.secondary:hover { background: var(--cream); }
.btn.danger { color: var(--critical); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--ink-2); font-size: 13px; padding: 2px 0 14px; }
.legend .note { color: var(--ink-3); }

/* the matrix */
.matrix { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.matrix th, .matrix td { padding: 0; vertical-align: top; text-align: left; }
.matrix thead th { padding: 12px 14px; font: 700 12px/1.3 var(--sans); text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-2); border-bottom: 2px solid var(--accent); background: var(--surface-2); }
.matrix thead th small { display: block; text-transform: none; letter-spacing: 0; font-weight: 400; margin-top: 2px; }
.matrix tbody th { padding: 14px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); min-width: 190px; font-weight: 600; }
.matrix tbody tr:last-child th, .matrix tbody tr:last-child td { border-bottom: none; }
.site { display: flex; align-items: center; gap: 10px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.site .dom { display: block; color: var(--ink-3); font-size: 12px; font-weight: 400; }
.site .you { display: inline-block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: #fff; background: var(--accent); border-radius: 100px; padding: 2px 7px; margin-left: 6px; vertical-align: middle; }
.matrix td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); width: 20%; }
.matrix td:last-child { border-right: none; }
.cell { display: block; width: 100%; height: 100%; min-height: 92px; padding: 12px 14px; background: none; border: 0; text-align: left; cursor: pointer; color: inherit; position: relative; }
.cell:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.cell .v { font: 600 26px/1 var(--sans); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.cell .u { font-size: 13px; color: var(--ink-2); margin-left: 2px; }
.cell .meta { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-size: 12px; color: var(--ink-3); }
.cell .rank { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; border-radius: 6px; font-weight: 600; color: var(--ink); background: var(--surface-2); }
.cell .rank.r1 { background: var(--accent); color: #fff; }
.cell .empty { color: var(--ink-3); font-size: 13px; }
.cell .flag { color: var(--warning); }
.cell .bar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--q4); }
.cell .strip { display: flex; gap: 2px; margin-top: 10px; }
.cell .strip img { height: 26px; width: auto; border-radius: 2px; border: 1px solid var(--line); background: #fff; }

.panel-tabs { display: flex; gap: 4px; margin: 28px 0 12px; border-bottom: 1px solid var(--line); }
.panel-tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.panel-tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* trend chart */
.chart-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.chart-card h3 { margin: 0 0 4px; font: 600 18px/1.2 var(--serif); }
.chart-card .hint { color: var(--ink-3); font-size: 13px; margin: 0 0 12px; }
.chart { width: 100%; height: 320px; display: block; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--ink-3); font-size: 11px; font-family: var(--sans); }
.chart .series path { fill: none; stroke-width: 2; }
.chart .series circle { stroke: var(--surface); stroke-width: 2; }
.chart .label { font-size: 12px; fill: var(--ink-2); font-family: var(--sans); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); margin-top: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tip { position: fixed; pointer-events: none; background: var(--ink); color: #fff; padding: 6px 10px; border-radius: 6px; font-size: 12px; z-index: 40; display: none; white-space: nowrap; }

/* runs */
.runs { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 14px; }
.runs th, .runs td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; }
.runs th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); background: var(--surface-2); }
.runs tr:last-child td { border-bottom: none; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--surface-2); color: var(--ink-2); }
.pill.done { background: #e4efe6; color: #2f5e3b; }
.pill.failed { background: #f6e4e0; color: #7a1f12; }
.pill.running { background: #fff7d6; color: #6b5205; }

/* drawer */
.drawer { position: fixed; inset: 0 0 0 auto; width: min(720px, 100vw); background: var(--surface); border-left: 1px solid var(--line); box-shadow: -12px 0 40px rgba(0,0,0,0.12); transform: translateX(100%); transition: transform 0.22s ease; z-index: 30; overflow: auto; }
.drawer.open { transform: none; }
.drawer .inner { padding: 20px 24px 40px; }
.drawer h2 { margin: 0; font: 700 26px/1.15 var(--serif); }
.drawer .close { position: absolute; top: 14px; right: 14px; }
.drawer .k { color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.drawer .url { font-family: var(--mono); font-size: 12px; word-break: break-all; color: var(--ink-2); margin: 6px 0 14px; }
.hero { display: flex; gap: 20px; flex-wrap: wrap; margin: 12px 0 18px; }
.hero .stat { min-width: 140px; }
.hero .stat b { display: block; font: 600 30px/1 var(--sans); letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.hero .stat small { color: var(--ink-3); }
.film { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 12px; }
.film figure { margin: 0; flex: none; text-align: center; }
.film img { height: 150px; width: auto; border: 1px solid var(--line); border-radius: 4px; background: #fff; display: block; }
.film figure.atf img { outline: 3px solid var(--accent); outline-offset: -3px; }
.film figcaption { font: 11px var(--mono); color: var(--ink-2); margin-top: 4px; }
.film figure.atf figcaption { color: var(--accent); font-weight: 600; }
table.kv { width: 100%; border-collapse: collapse; font-size: 14px; margin: 10px 0 18px; }
table.kv td { padding: 7px 0; border-bottom: 1px solid var(--line); }
table.kv td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 13px; }
table.kv tr.section td { padding-top: 16px; border-bottom: 2px solid var(--accent); color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.spark { width: 100%; height: 120px; display: block; }
.overlay { position: fixed; inset: 0; background: rgba(20,19,17,0.28); z-index: 20; display: none; }
.overlay.show { display: block; }

/* admin */
.admin { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-top: 16px; }
.admin h3 { margin: 0 0 10px; font: 600 18px/1.2 var(--serif); }
.admin .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.admin .row.four { grid-template-columns: repeat(2, 1fr); }
.admin .field { width: 100%; min-width: 0; }
.admin .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.site-list { display: grid; gap: 8px; margin: 12px 0; }
.site-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.site-row .grow { flex: 1; }
.site-row .dom { color: var(--ink-3); font-size: 13px; }
.muted { color: var(--ink-3); }
.err { color: var(--critical); }
code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
pre { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 12px; border-radius: 8px; overflow: auto; }

@media (max-width: 900px) {
  .matrix tbody th { min-width: 140px; }
  .cell .v { font-size: 20px; }
  .cell .strip { display: none; }
  .admin .row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding: 16px 12px 48px; }
  .topbar-right { display: none; }
  .brand-logo img { height: 40px; }
  .btn.secondary { display: none; }
  .hero-copy { padding-top: 24px; }
  .matrix-scroll { overflow-x: auto; }
  .matrix { min-width: 640px; }
}
