:root {
  --bg: #06080c;
  --bg-elevated: rgba(14, 18, 26, 0.72);
  --bg-card: rgba(18, 24, 34, 0.85);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #eef3fb;
  --text-soft: #9aa8bc;
  --red: #ff3b30;
  --red-glow: rgba(255, 59, 48, 0.35);
  --amber: #ffb020;
  --green: #2ee59d;
  --green-glow: rgba(46, 229, 157, 0.28);
  --blue: #4da3ff;
  --cyan: #35d4ff;
  --mono: "JetBrains Mono", Consolas, monospace;
  --display: "Rajdhani", "Segoe UI", sans-serif;
  --body: "Inter", "Segoe UI", sans-serif;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--body);
  background: var(--bg);
  overflow-x: hidden;
}

body.is-live .bg-glow-red { opacity: 0.22; }
body.is-live .telemetry-toolbar,
body.is-live .hud { border-color: rgba(46, 229, 157, 0.18); }

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 100%);
}

.bg-glow {
  position: fixed;
  width: 42vw;
  height: 42vw;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  opacity: 0.12;
}

.bg-glow-red {
  top: -10vw;
  right: -8vw;
  background: var(--red);
}

.bg-glow-blue {
  bottom: -12vw;
  left: -10vw;
  background: var(--blue);
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 20px clamp(16px, 2.5vw, 40px) 40px;
}

.glass {
  background: var(--bg-elevated);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* Full-width HUD: backdrop blur on ~2000px+ is very expensive — use solid fill */
.hud.glass {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: rgba(12, 16, 24, 0.94);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  contain: layout style;
}

.header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  padding: 18px 22px;
  border-radius: var(--radius);
  margin-bottom: 18px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.header-session {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 2px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.header-session-main {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.header-session-label {
  flex: 0 0 auto;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.header-session-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  font-family: var(--display);
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 700;
  line-height: 1.1;
}

.header-session-title .sep {
  color: var(--red);
}

.header-session-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.header-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-agents {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.nav-agents-label {
  flex: 0 0 auto;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-agents-list {
  display: flex;
  flex: 1;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.nav-agents-empty {
  color: var(--text-soft);
  font-size: 12px;
  padding: 6px 0;
}

.nav-agent {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-soft);
  font-family: var(--body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s ease;
}

.nav-agent:hover,
.nav-agent.active {
  color: #fff;
  border-color: rgba(255, 59, 48, 0.28);
  background: rgba(255, 59, 48, 0.1);
}

.nav-agent.live .nav-agent-dot {
  background: #2ee59d;
  box-shadow: 0 0 10px rgba(46, 229, 157, 0.45);
}

.nav-agent-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.nav-agent-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 0 2px 2px;
  margin: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.app-nav a {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: 0.2s ease;
}

.app-nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.08em;
  color: #fff;
  background: linear-gradient(145deg, #ff3b30, #b8140f);
  box-shadow: 0 10px 30px var(--red-glow);
}

.brand-kicker {
  margin: 0 0 2px;
  color: var(--red);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.header-meta {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.logout-btn {
  padding: 8px 14px;
  font-size: 11px;
}

.btn-ghost {
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
}

.client-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.client-picker label {
  color: var(--text-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.client-select {
  min-width: 220px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-family: var(--body);
  font-size: 13px;
}

.client-count {
  color: var(--text-soft);
  font-size: 11px;
  font-family: var(--mono);
}

.agents-empty {
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  color: var(--text-soft);
  font-size: 13px;
}

.agent-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: 0.2s ease;
}

.agent-card:hover,
.agent-card.active {
  border-color: rgba(77, 163, 255, 0.35);
  background: rgba(77, 163, 255, 0.08);
}

.agent-card.live {
  border-color: rgba(46, 229, 157, 0.25);
}

.agent-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.agent-card-head strong {
  font-family: var(--display);
  font-size: 18px;
}

.agent-status {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
}

.agent-status.is-live {
  color: var(--green);
  background: rgba(46, 229, 157, 0.12);
}

.agent-status.is-idle {
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.06);
}

.agent-card-meta {
  color: var(--text-soft);
  font-size: 13px;
}

.agent-card-id {
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 11px;
}

.host-config-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.host-config-note span {
  color: var(--text-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.host-config-note strong {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--cyan);
}

.form-section {
  padding: 18px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.form-section h3 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.field span {
  color: var(--text-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field input,
.field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: rgba(77, 163, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.12);
}

.field-hint {
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
}

.btn-disabled {
  pointer-events: none;
  opacity: 0.45;
}

.download-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #ff3b30, #c51610);
  box-shadow: 0 8px 24px var(--red-glow);
}

.btn-secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-strong);
}

.download-files {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.download-files a {
  color: var(--cyan);
  font-size: 13px;
  font-family: var(--mono);
  text-decoration: none;
}

.download-files a:hover {
  text-decoration: underline;
}

.agent-steps {
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.setup-item-remote {
  opacity: 0.92;
}

.setup-remote-tag {
  color: var(--text-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.header-time {
  margin-top: 8px;
  color: var(--text-soft);
  font-size: 12px;
  font-family: var(--mono);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-live {
  color: #042117;
  background: linear-gradient(90deg, #2ee59d, #7dffb8);
  box-shadow: 0 0 24px var(--green-glow);
}

.status-live .status-dot {
  animation: pulse 1.2s ease-in-out infinite;
}

.status-idle {
  color: #2a1800;
  background: linear-gradient(90deg, #ffb020, #ffd074);
}

.status-offline {
  color: #fff;
  background: #334155;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.65; }
}

.alert {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 176, 32, 0.28);
  background: rgba(255, 176, 32, 0.08);
  color: #ffdca0;
}

.hidden { display: none !important; }

.hero-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 22px 28px;
  border-radius: calc(var(--radius) + 4px);
  min-height: 100%;
  text-align: center;
}

.hero-primary {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(32px, 8vw, 120px);
  flex-wrap: wrap;
  width: 100%;
  max-width: none;
  margin: 0 auto;
}

.speed-block,
.gear-block,
.pos-block {
  min-width: 88px;
  text-align: center;
}

.speed-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  font-size: clamp(42px, 5vw, 58px);
  color: #fff;
}

.hero-rpm {
  width: min(100%, 820px);
  margin: 0 auto;
}

.hero-secondary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(18px, 3vw, 48px);
  width: min(100%, 960px);
  margin: 0 auto;
}

.label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero-title {
  font-family: var(--display);
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 700;
  line-height: 1.05;
}

.hero-title .sep {
  color: var(--red);
  margin: 0 8px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 500;
}

.chip-accent {
  color: #fff;
  border-color: rgba(255, 59, 48, 0.25);
  background: rgba(255, 59, 48, 0.1);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.speed-value,
.rpm-value,
.pos-value,
.gear-value {
  font-family: var(--mono);
  font-weight: 700;
  line-height: 1;
}

.speed-value small,
.rpm-value small {
  font-size: 14px;
  color: var(--text-soft);
  font-weight: 500;
}

.gear-value {
  font-family: var(--display);
  font-size: 56px;
  color: var(--cyan);
  text-shadow: 0 0 24px rgba(53, 212, 255, 0.25);
}

.rpm-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  font-size: 28px;
}

.pos-value {
  font-family: var(--display);
  font-size: 42px;
  color: var(--amber);
}

.rpm-track,
.fuel-track,
.bar {
  height: 10px;
  margin-top: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  overflow: hidden;
}

.rpm-fill,
.fuel-fill,
.bar-fill {
  height: 100%;
  width: 0;
  transition: width 0.12s linear;
  border-radius: 999px;
}

.rpm-fill {
  background: linear-gradient(90deg, #2ee59d, #ffb020, #ff3b30);
}

.fuel-fill {
  background: linear-gradient(90deg, #ff3b30, #ffb020);
}

.bar-gas { background: linear-gradient(90deg, #2ee59d, #7dffb8); }
.bar-brake { background: linear-gradient(90deg, #ff3b30, #ff7a70); }
.bar-clutch { background: linear-gradient(90deg, #4da3ff, #9fd0ff); }

.hero-inputs,
.hero-fuel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.input-row {
  display: grid;
  grid-template-columns: 52px 1fr 42px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: var(--text-soft);
}

.input-row strong {
  font-family: var(--mono);
  color: var(--text);
  font-size: 12px;
}

.fuel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.fuel-head strong {
  font-family: var(--mono);
  font-size: 18px;
}

.fuel-meta {
  display: flex;
  justify-content: space-between;
  color: var(--text-soft);
  font-size: 12px;
  font-family: var(--mono);
}

.section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sections {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.app > details.panel,
.app > .sections {
  margin-bottom: 16px;
}

.summary-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

details.panel summary .panel-sub {
  margin: 0;
}

.hero-panel .panel-body {
  padding: 0;
}

.hero-panel summary {
  padding-left: clamp(16px, 2.5vw, 28px);
  padding-right: clamp(16px, 2.5vw, 28px);
}

.hero-panel .hero-center {
  padding: 20px clamp(12px, 3vw, 48px);
  margin-bottom: 0;
  border-radius: 0;
}

.hero-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr) minmax(280px, 360px);
  gap: clamp(16px, 2vw, 32px);
  align-items: stretch;
  width: 100%;
}

.hero-layout::after {
  content: "";
  grid-column: 3;
  pointer-events: none;
}

.lap-log-widget {
  grid-column: 1;
  grid-row: 1;
}

.hero-center {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  justify-self: stretch;
  width: 100%;
  max-width: none;
}

.lap-log-widget {
  border-radius: calc(var(--radius) + 2px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.28);
}

.lap-log-head {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.lap-log-best {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(90deg, #5b2d82, #7a3eb0);
  color: #fff;
}

.lap-log-best-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.9;
}

.lap-log-best strong {
  font-family: var(--mono);
  font-size: clamp(22px, 2.5vw, 30px);
  font-weight: 700;
  line-height: 1;
}

.lap-log-best-temp {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 13px;
  opacity: 0.95;
}

.lap-log-table-wrap {
  max-height: 320px;
  overflow-y: auto;
}

.lap-log-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 13px;
}

.lap-log-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ffd24a;
  background: #111;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.lap-log-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.lap-log-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.lap-log-table tbody tr:nth-child(odd) td {
  background: rgba(255, 255, 255, 0.05);
}

.lap-log-empty {
  text-align: center;
  color: var(--text-soft);
  font-family: var(--body);
  font-size: 12px;
}

.lap-log-table .delta-fast {
  color: #2ee59d;
}

.lap-log-table .delta-slow {
  color: #ff6b63;
}

.lap-log-table .delta-neutral {
  color: var(--text-soft);
}

.agents-panel .panel-lead,
.agent-panel .panel-lead,
.agent-form {
  padding-left: 0;
  padding-right: 0;
}

.agents-panel .panel-body .panel-lead {
  margin: 0 0 12px;
}

.agent-panel .panel-body .panel-lead {
  margin: 0 0 12px;
}

.agent-panel .agent-form {
  padding: 0;
}

.agents-list {
  display: grid;
  gap: 10px;
  padding: 0;
}

.setup-list {
  padding: 0;
}

details.panel .panel-body .setup-list {
  padding-bottom: 0;
}

.panel {
  border-radius: var(--radius);
}

details.panel {
  overflow: visible;
}

.panel,
details.panel {
  margin-bottom: 0;
}

details.panel {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  backdrop-filter: blur(14px);
}

details.panel[open] {
  border-color: rgba(255, 59, 48, 0.18);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 0;
}

.panel-head > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(255, 59, 48, 0.12);
  color: var(--red);
  font-size: 16px;
}

.panel-head h2,
summary h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.panel-sub {
  color: var(--text-soft);
  font-size: 12px;
  max-width: 420px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-lead {
  margin: 10px 20px 0;
  color: var(--text-soft);
  font-size: 13px;
}

.panel-body {
  padding: 16px clamp(16px, 2.5vw, 28px) 20px;
}

summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  user-select: none;
}

summary * {
  pointer-events: none;
}

summary::-webkit-details-marker { display: none; }

.summary-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.summary-chevron {
  color: var(--text-soft);
  transition: transform 0.2s ease;
  font-family: var(--mono);
}

details[open] .summary-chevron {
  transform: rotate(90deg);
  color: var(--red);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.metric-cell {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.metric-cell:hover {
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.metric-cell span {
  display: block;
  margin-bottom: 6px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.metric-cell strong {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.tyre-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.tyre-card {
  position: relative;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015));
  border: 1px solid var(--border);
  overflow: hidden;
}

.tyre-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent, var(--red));
}

.tyre-card.fl { --accent: #ff3b30; }
.tyre-card.fr { --accent: #ffb020; }
.tyre-card.rl { --accent: #4da3ff; }
.tyre-card.rr { --accent: #2ee59d; }

.tyre-card h3 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 0.08em;
}

.tyre-metric {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  font-size: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.tyre-metric:last-child { border-bottom: 0; }

.tyre-metric span { color: var(--text-soft); }

.tyre-metric strong {
  font-family: var(--mono);
  font-size: 12px;
}

.temp-hot { color: #ff7a70 !important; }
.temp-warm { color: #ffb020 !important; }
.temp-cool { color: #4da3ff !important; }

.wheel-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.wheel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.wheel-table th,
.wheel-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  text-align: left;
}

.wheel-table th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-soft);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.wheel-table td {
  font-family: var(--mono);
}

.wheel-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.damage-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.damage-grid,
.suspension-grid {
  display: grid;
  gap: 10px;
}

.damage-zone {
  display: grid;
  grid-template-columns: 64px 1fr 48px;
  gap: 10px;
  align-items: center;
}

.damage-zone span {
  color: var(--text-soft);
  font-size: 12px;
}

.damage-zone strong {
  font-family: var(--mono);
  font-size: 12px;
}

.meter {
  height: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffb020, #ff3b30);
  transition: width 0.15s linear;
}

.car-diagram {
  display: grid;
  place-items: center;
  min-height: 180px;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.18);
  position: relative;
}

.car-shell {
  width: 84px;
  height: 164px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 28px 28px 16px 16px;
  position: relative;
}

.car-zone {
  position: absolute;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-soft);
}

.car-zone.front { top: 8px; left: 50%; transform: translateX(-50%); }
.car-zone.rear { bottom: 8px; left: 50%; transform: translateX(-50%); }
.car-zone.left { top: 50%; left: -28px; transform: translateY(-50%); }
.car-zone.right { top: 50%; right: -30px; transform: translateY(-50%); }

.setup-list {
  display: grid;
  gap: 10px;
  padding: 0 20px 20px;
}

.setup-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  transition: 0.2s ease;
}

.setup-item:hover {
  border-color: rgba(255, 59, 48, 0.22);
  background: rgba(255, 59, 48, 0.05);
  transform: translateX(2px);
}

.setup-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.setup-item span {
  color: var(--text-soft);
  font-size: 12px;
}

.setup-item a {
  color: #fff;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #ff3b30, #c51610);
  box-shadow: 0 8px 24px var(--red-glow);
  transition: transform 0.15s ease;
}

.setup-item a:hover { transform: scale(1.03); }

.setup-empty,
.note-list {
  color: var(--text-soft);
  font-size: 13px;
}

.note-list {
  margin: 0;
  padding-left: 18px;
}

.note-list li { margin: 8px 0; }

.footer {
  margin-top: 24px;
  text-align: center;
  color: var(--text-soft);
  font-size: 12px;
}

code {
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  font-family: var(--mono);
  font-size: 11px;
}

@media (max-width: 1080px) {
  .hero-layout {
    grid-template-columns: 1fr;
  }

  .hero-layout::after {
    display: none;
  }

  .lap-log-widget,
  .hero-center {
    grid-column: 1;
  }

  .hero-center {
    max-width: none;
  }

  .hero-secondary {
    grid-template-columns: 1fr;
    width: 100%;
  }
}

@media (max-width: 760px) {
  .header-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-meta {
    text-align: left;
    align-items: flex-start;
  }

  .client-picker {
    justify-content: flex-start;
  }

  .hero-primary {
    gap: 20px;
  }

  .hero-secondary {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .tyre-grid {
    grid-template-columns: 1fr;
  }

  .damage-layout {
    grid-template-columns: 1fr;
  }

  .panel-sub {
    display: none;
  }
}

/* ============================ RACE HUD ============================ */

.hud {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px clamp(14px, 2vw, 22px) 18px;
  border-radius: calc(var(--radius) + 4px);
  margin-bottom: 16px;
}

.hud-card-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hud-card {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  min-width: 0;
  contain: layout style paint;
}

.hud-idle .shift-lights,
.hud-idle .hud-graphs {
  opacity: 0.45;
  pointer-events: none;
}

.hud-session {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-family: var(--display);
  font-size: clamp(14px, 1.6vw, 18px);
  font-weight: 600;
  line-height: 1.2;
}

.hud-session-sep {
  color: var(--red);
}

.chip-sm {
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 600;
}

/* --- driver / flag strip --- */
.hud-driver {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hud-driver-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.hud-driver-dot.live {
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(46, 229, 157, 0.6);
  animation: live-pulse 1.4s ease-out infinite;
}

@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(46, 229, 157, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(46, 229, 157, 0); }
  100% { box-shadow: 0 0 0 0 rgba(46, 229, 157, 0); }
}

.hud-driver-name {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 700;
}

.hud-driver-state {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.hud-flags {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

.hud-flag,
.hud-light {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  border: 1px solid var(--border);
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.03);
}

.hud-light.on { color: #06080c; }
.hud-light.tc.on { background: var(--amber); border-color: var(--amber); }
.hud-light.abs.on { background: var(--blue); border-color: var(--blue); }
.hud-light.pit.on { background: #fff; border-color: #fff; }
.hud-flag.flag-green { background: rgba(46, 229, 157, 0.18); color: var(--green); border-color: rgba(46, 229, 157, 0.4); }
.hud-flag.flag-yellow { background: rgba(255, 209, 74, 0.18); color: var(--amber); border-color: rgba(255, 209, 74, 0.4); }
.hud-flag.flag-red { background: rgba(255, 59, 48, 0.2); color: #ff6a60; border-color: rgba(255, 59, 48, 0.45); }
.hud-flag.flag-white,
.hud-flag.flag-chequered { background: rgba(255, 255, 255, 0.16); color: #fff; }

/* --- shift lights --- */
.shift-lights {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  gap: 4px;
  height: 16px;
}

.shift-led {
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.05s linear, box-shadow 0.05s linear;
}

.shift-led.on-green { background: #2ee59d; box-shadow: 0 0 8px rgba(46, 229, 157, 0.6); }
.shift-led.on-red { background: #ff3b30; box-shadow: 0 0 8px rgba(255, 59, 48, 0.6); }
.shift-led.on-blue { background: #4da3ff; box-shadow: 0 0 10px rgba(77, 163, 255, 0.8); }
.shift-lights.flash .shift-led { background: #4da3ff; box-shadow: 0 0 10px rgba(77, 163, 255, 0.85); }

/* --- main grid --- */
.hud-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 14px;
}

/* timing card */
.hud-timing {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 14px;
}

.hud-pos {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.hud-pos strong {
  font-family: var(--display);
  font-size: clamp(34px, 4vw, 48px);
  color: var(--amber);
  line-height: 1;
}

.hud-delta strong {
  font-family: var(--mono);
  font-size: clamp(22px, 2.6vw, 30px);
  font-weight: 700;
}

.hud-delta .delta-fast { color: var(--green); }
.hud-delta .delta-slow { color: #ff6a60; }
.hud-delta .delta-neutral { color: var(--text-soft); }

.delta-bar {
  position: relative;
  height: 8px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.delta-bar::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.25);
}

.delta-bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
  border-radius: 999px;
  transition: 0.15s ease;
}

.hud-times {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.hud-time span {
  display: block;
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hud-time strong {
  font-family: var(--mono);
  font-size: 16px;
}

.hud-time .time-best { color: #b98bff; }

/* core card */
.hud-core {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hud-core-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.hud-speed,
.hud-rpm {
  text-align: center;
}

.hud-rpm { text-align: right; }
.hud-speed { text-align: left; }

.hud-speed strong,
.hud-rpm strong {
  display: block;
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1;
  color: #fff;
}

.hud-speed small,
.hud-rpm small {
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 500;
  margin-left: 4px;
}

.hud-gear .gear-value {
  font-family: var(--display);
  font-size: clamp(64px, 9vw, 104px);
  font-weight: 700;
  color: var(--cyan);
  line-height: 0.9;
}

.hud-core .rpm-track {
  height: 10px;
  margin: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.hud-core .rpm-fill {
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
  border-radius: 999px;
  background: linear-gradient(90deg, #2ee59d, #ffd24a 70%, #ff3b30);
}

/* pedals */
.pedals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-items: end;
}

.pedal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.pedal-track {
  position: relative;
  width: 100%;
  max-width: 70px;
  height: 80px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

.pedal-fill {
  width: 100%;
  height: 100%;
  transform: scaleY(0);
  transform-origin: bottom center;
  will-change: transform;
  border-radius: 8px 8px 0 0;
}

.pedal-gas { background: linear-gradient(0deg, #1c8f5e, #2ee59d); }
.pedal-brake { background: linear-gradient(0deg, #b8140f, #ff3b30); }
.pedal-clutch { background: linear-gradient(0deg, #2d6fb8, #4da3ff); }

.pedal-label {
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.pedal strong {
  font-family: var(--mono);
  font-size: 13px;
}

/* graphs card */
.hud-graphs {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 14px;
}

.hud-graph { min-width: 0; }

.trace-canvas {
  width: 100%;
  height: 110px;
  display: block;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.4);
}

.hud-gforce {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 4px 12px;
}

.hud-gforce .hud-card-label { grid-column: 1 / -1; margin-bottom: 0; }

.gforce-canvas {
  width: 96px;
  height: 96px;
  display: block;
}

.gforce-value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--cyan);
}

/* --- secondary grid --- */
.hud-secondary {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

/* tyres */
.tyre-diagram {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.tyre-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.tyre-cell .tyre-pos {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-soft);
}

.tyre-block {
  width: 100%;
  height: 30px;
  border-radius: 6px;
  background: #2a3140;
}

.tyre-block.t-cold { background: #2d6fb8; }
.tyre-block.t-low { background: #35d4ff; }
.tyre-block.t-ok { background: #2ee59d; }
.tyre-block.t-warm { background: #ffd24a; }
.tyre-block.t-hot { background: #ff3b30; }

.tyre-cell .tyre-temp {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
}

.tyre-cell .tyre-press {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-soft);
}

/* fuel */
.hud-fuel { display: flex; flex-direction: column; gap: 10px; }

.fuel-big {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.fuel-big strong {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
}

.fuel-big span {
  font-family: var(--mono);
  color: var(--text-soft);
  font-size: 14px;
}

.hud-fuel .fuel-track {
  height: 12px;
  margin: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.hud-fuel .fuel-fill {
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff3b30, #ffd24a 35%, #2ee59d);
}

.fuel-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 4px;
}

.fuel-grid span {
  display: block;
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fuel-grid strong {
  font-family: var(--mono);
  font-size: 16px;
}

/* lap log inside hud */
.hud .lap-log-widget {
  padding: 0;
  overflow: hidden;
}

.hud .lap-log-table-wrap { max-height: 230px; }

/* live pulse for nav agents */
.nav-agent.live .nav-agent-dot {
  animation: live-pulse 1.4s ease-out infinite;
}

/* HUD responsive */
@media (max-width: 1080px) {
  .hud-main { grid-template-columns: 1fr 1fr; }
  .hud-graphs { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; grid-template-rows: none; }
  .hud-secondary { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .hud-main,
  .hud-graphs,
  .hud-secondary { grid-template-columns: 1fr; }
  .hud-flags { margin-left: 0; }
}

/* ============================ PIT CALCULATOR ============================ */

.pit-calc {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px clamp(14px, 2vw, 22px) 20px;
  border-radius: calc(var(--radius) + 4px);
  margin-bottom: 16px;
}

.pit-calc-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 24px;
}

.pit-calc-kicker {
  margin: 0 0 4px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.pit-calc-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(22px, 2.5vw, 28px);
  font-weight: 700;
}

.pit-calc-note {
  margin: 0;
  max-width: 420px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.45;
}

.pit-calc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.pit-calc-card {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  min-width: 0;
}

.pit-calc-card-title {
  margin: 0 0 12px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pit-calc-dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.pit-calc-dl > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.pit-calc-dl dt {
  margin: 0;
  color: var(--text-soft);
  font-size: 12px;
}

.pit-calc-dl dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
}

.pit-calc-dl-results dd.pc-highlight {
  font-size: 18px;
  color: var(--cyan);
}

.pit-calc-form {
  display: grid;
  gap: 10px;
}

.pit-calc-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pit-calc-field > span:first-child {
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pit-calc-field input,
.pit-calc-field select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

.pit-calc-field input:focus,
.pit-calc-field select:focus {
  outline: none;
  border-color: var(--cyan);
}

.pit-calc-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.pit-calc-check input {
  width: auto;
}

.pit-calc-check span {
  color: var(--text);
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
}

.pit-calc-status {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  font-size: 13px;
  line-height: 1.4;
}

.pit-calc-status.pc-ok { border-color: rgba(46, 229, 157, 0.35); color: #9ef0c8; }
.pit-calc-status.pc-soon { border-color: rgba(255, 210, 74, 0.4); color: #ffe08a; }
.pit-calc-status.pc-critical { border-color: rgba(255, 59, 48, 0.45); color: #ff9a94; }
.pit-calc-status.pc-warn { border-color: rgba(255, 210, 74, 0.4); color: #ffe08a; }
.pit-calc-status.pc-idle { color: var(--text-soft); }

.pc-highlight.pc-critical { color: var(--red) !important; }
.pc-highlight.pc-soon { color: #ffd24a !important; }
.pc-highlight.pc-warn { color: #ffd24a !important; }

#pcResMfdDiff.pc-match { color: var(--green); }
#pcResMfdDiff.pc-over { color: #ffd24a; }
#pcResMfdDiff.pc-under { color: var(--red); }

#pcLivePitWindow.pc-window-open { color: var(--green); }
#pcLivePitWindow.pc-window-pending { color: #ffd24a; }
#pcLivePitWindow.pc-window-closed { color: var(--red); }

.pit-calc-hints {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 6px;
}

.pit-calc-hints:empty {
  display: none;
}

.pc-hint {
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.pc-hint-info { border-color: rgba(53, 212, 255, 0.25); color: #a8e8ff; }
.pc-hint-warn { border-color: rgba(255, 210, 74, 0.35); color: #ffe08a; }
.pc-hint-critical { border-color: rgba(255, 59, 48, 0.4); color: #ff9a94; }

@media (max-width: 1080px) {
  .pit-calc-grid { grid-template-columns: 1fr 1fr; }
  .pit-calc-card-results { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .pit-calc-grid { grid-template-columns: 1fr; }
  .pit-calc-card-results { grid-column: auto; }
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 440px);
}

.login-card {
  padding: 28px 28px 24px;
  border-radius: var(--radius);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.login-brand .brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fff;
  background: linear-gradient(135deg, #ff3b30, #8b1210);
  box-shadow: 0 10px 30px var(--red-glow);
}

.login-brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-brand .brand-kicker {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--text-soft);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-lead {
  margin: 0 0 22px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.5;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-field {
  display: grid;
  gap: 8px;
}

.login-field span {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.login-field input {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-field input:focus {
  border-color: rgba(255, 59, 48, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.12);
}

.login-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 59, 48, 0.35);
  background: rgba(255, 59, 48, 0.08);
  color: #ff9a94;
  font-size: 13px;
}

.login-submit {
  width: 100%;
  margin-top: 4px;
}

.login-submit:disabled {
  opacity: 0.7;
  cursor: wait;
}

.login-footnote {
  margin: 16px 0 0;
  text-align: center;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.5;
}

.login-links {
  margin: 18px 0 0;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
}

.login-links a {
  color: var(--cyan);
  text-decoration: none;
}

.login-links a:hover {
  text-decoration: underline;
}

.team-panel-grid {
  display: grid;
  gap: 16px;
}

.team-switcher {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.team-switcher select {
  min-width: 180px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font: inherit;
}

.team-members-list,
.invite-list {
  display: grid;
  gap: 8px;
}

.team-member-row,
.invite-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.agent-secret-box {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 210, 74, 0.35);
  background: rgba(255, 210, 74, 0.08);
  color: #ffe08a;
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
}

.app-telemetry {
  padding-top: 12px;
}

.telemetry-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 10px;
}

.telemetry-toolbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.telemetry-toolbar .status-pill {
  padding: 5px 10px;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.telemetry-toolbar .status-dot {
  width: 7px;
  height: 7px;
}

.telemetry-time {
  color: var(--text-soft);
  font-size: 11px;
  font-family: var(--mono);
  white-space: nowrap;
}

.telemetry-toolbar .nav-agents {
  flex: 1;
  min-width: 0;
  margin-left: auto;
  justify-content: flex-end;
}

.section-nav-compact {
  gap: 4px;
  padding: 0;
}

.section-nav-compact a {
  padding: 5px 10px;
  font-size: 11px;
}

.app-topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.app-topnav-compact {
  padding: 6px 12px;
  margin-bottom: 6px;
  gap: 10px;
}

.app-topnav-compact .app-topnav-link {
  padding: 5px 11px;
  font-size: 11px;
  letter-spacing: 0.06em;
}

.app-topnav-compact .app-topnav-team > span:first-child {
  display: none;
}

.app-topnav-compact .app-topnav-team select {
  min-width: 120px;
  padding: 5px 10px;
  font-size: 12px;
}

.app-topnav-compact .app-topnav-user {
  font-size: 12px;
}

.app-topnav-compact .logout-btn {
  padding: 5px 10px;
  font-size: 11px;
}

.app-topnav-brand-compact {
  gap: 0;
}

.app-topnav-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-mark-sm {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(135deg, #ff3b30, #8b1210);
}

.app-topnav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.app-topnav-link {
  padding: 10px 16px;
  border-radius: 999px;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.app-topnav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.app-topnav-link.is-active {
  color: #fff;
  background: rgba(255, 59, 48, 0.18);
  border-color: rgba(255, 59, 48, 0.35);
}

.app-topnav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.app-topnav-team {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.app-topnav-team select {
  min-width: 150px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font: inherit;
}

.app-topnav-user {
  color: var(--text-soft);
  font-size: 13px;
}

.manage-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px clamp(22px, 3vw, 32px);
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.manage-header h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(28px, 4vw, 38px);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.manage-lead {
  margin: 0;
  color: var(--text-soft);
  max-width: 720px;
  line-height: 1.6;
  font-size: 14px;
}

.manage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.manage-card {
  padding: 24px clamp(20px, 2.5vw, 28px);
  border-radius: var(--radius);
}

.manage-card-wide {
  grid-column: 1 / -1;
}

.manage-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.manage-card-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.manage-card .panel-lead {
  margin: 0 0 18px;
  line-height: 1.55;
  max-width: 72ch;
}

.manage-card .download-actions {
  margin: 0 0 18px;
}

.manage-card .download-actions:last-child {
  margin-bottom: 0;
}

.manage-card .teams-list,
.manage-card .team-members-list,
.manage-card .invite-list {
  gap: 10px;
}

.manage-card .team-member-row,
.manage-card .invite-row {
  padding: 12px 14px;
}

.manage-card .setup-empty {
  margin: 4px 0 0;
  padding: 14px 16px;
}

.manage-dl {
  display: grid;
  gap: 0;
  margin: 8px 0 0;
}

.manage-dl > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.manage-dl > div:first-child {
  padding-top: 6px;
}

.manage-dl > div:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.manage-dl dt {
  margin: 0;
  color: var(--text-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.manage-dl dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

.manage-card .agent-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 2px;
}

.manage-card .agent-form .host-config-note {
  margin-bottom: 0;
}

.manage-card .agent-form .download-actions {
  margin-bottom: 0;
}

.manage-steps {
  margin: 0;
  padding-left: 1.25rem;
  list-style: decimal;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.manage-steps li {
  padding-left: 6px;
}

body[data-active-page="manage"] .footer {
  margin-top: 36px;
  padding-top: 12px;
}

body[data-active-page="manage"] .app-topnav {
  margin-bottom: 20px;
}

.teams-list .is-active-team {
  border-color: rgba(46, 229, 157, 0.35);
  background: rgba(46, 229, 157, 0.06);
}

.footer a {
  color: var(--cyan);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .manage-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .manage-header {
    padding: 22px 20px;
    margin-bottom: 20px;
  }

  .manage-card {
    padding: 20px 18px;
  }

  .manage-dl > div {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .manage-dl dd {
    text-align: left;
  }

  .app-topnav-links {
    order: 3;
    width: 100%;
    justify-content: flex-start;
  }
}
