/* PSC-1 rack test drive. Scoped under .td so site-wide form and table styles don't leak in.
   Colours follow the G12 brand: blue = steady grid load, orange = stored energy and calls to action. */
.td {
  --td-bg: #0F1621;
  --td-panel: #162030;
  --td-panel-2: #1E2A3D;
  --td-line: #2A3850;
  --td-fg: #F5F1E8;
  --td-muted: #B4B8BE;
  --td-dim: #8A94A3;
  --td-psc: #5B8DEF;
  --td-gpu: #C792EA;
  --td-none: #2BB585;
  --td-store: #F0883E;
  --td-burn: #EF5B4B;
  --td-demand: #C9C4B8;
  --td-ok: #4CC38A; --td-ok-bg: #12301F;
  --td-warn: #F2A44E; --td-warn-bg: #3A2710;
  --td-crit: #F4857A; --td-crit-bg: #3D1714;
  --td-num: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
  padding: clamp(32px, 5vw, 56px) 0 clamp(48px, 7vw, 80px);
}
.td [hidden] { display: none !important; }
.td-wrap { display: flex; flex-direction: column; gap: 20px; }

/* Hero */
.td-hero { display: flex; flex-wrap: wrap; gap: 20px 32px; align-items: flex-end; justify-content: space-between; margin-bottom: 8px; }
.td-hero > div:first-child { flex: 1 1 560px; min-width: 0; }
.td-hero h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); max-width: 20ch; }
.td-hero h1 em { font-style: normal; color: var(--td-store); }
.td-hero .lede { max-width: 66ch; font-size: 1.05rem; margin: 0; }
.td-cta { display: flex; flex-wrap: wrap; gap: 10px; }
.td .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* Small buttons inside panels */
.td-btn {
  appearance: none; font: inherit; font-weight: 600; font-size: 13.5px; border-radius: 8px;
  padding: 7px 12px; min-height: 40px; cursor: pointer; border: 1px solid var(--td-line);
  background: rgba(22, 32, 48, .92); color: var(--td-fg); display: inline-flex; align-items: center; gap: 6px;
}
.td-btn:hover { border-color: var(--td-muted); }
.td-btn[aria-pressed="true"] { box-shadow: inset 0 -2px 0 var(--td-store); }

/* 3D stage */
.td-stage {
  position: relative; height: clamp(460px, 70vh, 760px); border: 1px solid var(--td-line); border-radius: 14px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 20%, #1A2A40 0%, var(--td-bg) 70%);
}
.td-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.td-fallback {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 10px; padding: 120px 24px;
  color: var(--td-muted); font-size: 15px;
}
.td-fallback b { color: var(--td-fg); font-size: 17px; }
.td-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.td-lbl {
  position: absolute; transform: translate(-50%, -100%); font-size: 12px; line-height: 1.3; color: var(--td-fg);
  background: rgba(15, 22, 33, .82); border: 1px solid var(--td-line); border-radius: 6px; padding: 3px 7px; white-space: nowrap;
}
.td-lbl::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 1px; height: 6px; background: var(--td-line); }
.td-lbl.store { border-color: var(--td-store); color: var(--td-store); }
.td-hud { position: absolute; left: 14px; top: 14px; display: flex; flex-direction: column; gap: 8px; max-width: calc(100% - 28px); }
.td-seg {
  position: relative; display: inline-flex; flex-wrap: wrap; width: fit-content; max-width: 100%;
  border: 1px solid var(--td-line); border-radius: 9px; overflow: hidden; background: rgba(22, 32, 48, .92);
}
.td .td-seg input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; min-height: 0; padding: 0; margin: 0; }
.td .td-seg label {
  padding: 9px 12px; cursor: pointer; color: var(--td-muted); font-weight: 500; font-size: 13.5px;
  border-right: 1px solid var(--td-line); min-height: 40px; display: inline-flex; align-items: center; gap: 7px;
}
.td .td-seg label:last-of-type { border-right: 0; }
.td-seg label i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.td .td-seg input:checked + label { background: var(--td-panel-2); color: var(--td-fg); box-shadow: inset 0 -2px 0 var(--td-store); }
.td .td-seg input:focus-visible + label { outline: 2px solid var(--td-store); outline-offset: -2px; }
.td-readouts {
  display: grid; grid-template-columns: repeat(4, minmax(0, auto)); gap: 1px; width: fit-content; max-width: 100%;
  background: var(--td-line); border: 1px solid var(--td-line); border-radius: 9px; overflow: hidden;
}
.td-ro { background: rgba(22, 32, 48, .94); padding: 7px 12px; display: flex; flex-direction: column; min-width: 0; }
.td-ro .k { font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--td-muted); font-weight: 600; white-space: nowrap; }
.td-ro .v { font-family: var(--td-num); font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 500; white-space: nowrap; }
.td-ro .v small { font-size: 12px; color: var(--td-muted); margin-left: 3px; }
.td-views { position: absolute; right: 14px; top: 14px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 46%; }
.td-views .td-btn { min-height: 36px; font-size: 13px; padding: 6px 11px; }
.td-status { position: absolute; left: 14px; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.td-phase { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; font-size: 13px; color: var(--td-muted); }
.td-phase b { color: var(--td-fg); font-weight: 600; }
.td-track { position: relative; height: 8px; border-radius: 4px; background: rgba(42, 56, 80, .9); overflow: hidden; }
.td-track .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--td-store); }
.td-track .mk { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(245, 241, 232, .35); }
.td-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--td-panel-2); color: var(--td-muted); width: fit-content; white-space: nowrap;
}
.td-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.td-pill.ok { background: var(--td-ok-bg); color: var(--td-ok); }
.td-pill.warn { background: var(--td-warn-bg); color: var(--td-warn); }
.td-pill.crit { background: var(--td-crit-bg); color: var(--td-crit); }

/* Panels and charts */
.td-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.td-panel { background: var(--td-panel); border: 1px solid var(--td-line); border-radius: 14px; padding: 18px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.td-ph { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 14px; }
.td-ph h2 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--td-muted); }
.td-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--td-muted); }
.td-legend span { display: inline-flex; align-items: center; gap: 6px; }
.td-sw { display: inline-block; width: 16px; height: 0; border-top: 2px solid; }
.td-chart { position: relative; }
.td-chart canvas { display: block; width: 100%; }
.td-tip {
  position: absolute; pointer-events: none; background: var(--td-panel-2); border: 1px solid var(--td-line); border-radius: 8px;
  padding: 6px 9px; font-size: 12.5px; line-height: 1.45; white-space: nowrap;
}
.td-tip .n { font-family: var(--td-num); font-variant-numeric: tabular-nums; }

/* Controls */
.td-controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.td-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.td-field .row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.td .td-field > label, .td .td-field .row label { font-weight: 500; font-size: 14px; }
.td-field output { font-family: var(--td-num); font-variant-numeric: tabular-nums; font-size: 13px; }
.td-field .help { font-size: 12px; color: var(--td-dim); }
.td input[type="range"] { width: 100%; accent-color: var(--td-store); min-height: 28px; margin: 0; padding: 0; background: none; border: 0; }
.td input[type="range"]:focus { outline: none; }
.td input[type="range"]:focus-visible { outline: 2px solid var(--td-store); outline-offset: 2px; }
.td select { font-size: 14px; padding: 8px 10px; min-height: 40px; background: var(--td-panel-2); border-color: var(--td-line); }
.td-events { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.td-events .td-seg { margin-left: auto; }

/* Report */
.td-report table { width: 100%; min-width: 680px; border-collapse: collapse; font-size: 14px; }
.td-report th, .td-report td { padding: 10px 8px; border-bottom: 1px solid var(--td-line); text-align: left; vertical-align: top; background: none; }
.td-report th { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--td-muted); font-weight: 600; }
.td-report td.n { font-family: var(--td-num); font-variant-numeric: tabular-nums; }
.td-report th.n, .td-report td.n { text-align: right; }
.td-report td .sub { display: block; font-size: 12px; color: var(--td-dim); }
.td-report .who { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.td-report .who i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.td-tablebox { overflow-x: auto; }
.td-callout { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.td-callout div { background: var(--td-panel-2); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.td-callout .k { font-size: 12px; color: var(--td-muted); }
.td-callout .v { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; color: var(--td-store); }
.td-callout .d { font-size: 12.5px; color: var(--td-muted); }
.td-note { margin: 0; color: var(--td-dim); font-size: 12.5px; }

/* How it works */
.td-how { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.td-how h3 { margin: 0 0 4px; font-size: 1.05rem; }
.td-how p { margin: 0; color: var(--td-muted); font-size: 14.5px; }
.td-how .n { font-family: var(--td-num); color: var(--td-store); font-size: 12px; letter-spacing: .08em; }
.td-how .td-panel.psc { border-color: rgba(240, 136, 62, .5); }

/* Disclaimer */
.td-disclaimer { color: var(--td-dim); font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; max-width: 110ch; border-top: 1px solid var(--td-line); padding-top: 18px; }
.td-disclaimer p { margin: 0; }
.td-disclaimer b { color: var(--td-muted); }

@media (max-width: 1000px) { .td-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .td-grid2, .td-how, .td-callout, .td-controls { grid-template-columns: minmax(0, 1fr); }
  .td-readouts { grid-template-columns: repeat(2, minmax(0, auto)); }

  .td-lbl { font-size: 11px; }
  .td-events .td-seg { margin-left: 0; }
}

/* The canvas, fallback and labels share one positioned box. On desktop it fills the stage
   and the HUD floats over it; on phones the HUD stacks above and below so the rack stays visible. */
.td-viewport { position: absolute; inset: 0; }
@media (max-width: 760px) {
  .td-stage { height: auto; display: flex; flex-direction: column; }
  .td-viewport { position: relative; inset: auto; height: clamp(320px, 58vh, 440px); order: 2; }
  .td-hud { position: static; order: 1; padding: 12px 12px 0; max-width: none; }
  .td-views { position: static; order: 3; padding: 0 12px; max-width: none; justify-content: flex-start; }
  .td-status { position: static; order: 4; padding: 10px 12px 12px; }
  .td-hud .td-seg { width: 100%; }
  .td .td-hud .td-seg label { flex: 1 1 auto; justify-content: center; }
  .td-readouts { width: 100%; }
}
