/* ConPDS house style, adapted from the Container Inspection demo
   (https://inspection.conpds.com/demo) for the Gate Analytics reporting app. */

:root {
  /* Tells the browser to paint native form-control chrome (select dropdown
     popups, checkboxes, scrollbars) with its dark palette. Without this,
     Chrome/Edge render <option> popups with the OS light-mode background
     regardless of our CSS, making light theme text (var(--text)) nearly
     invisible against it. */
  color-scheme: dark;
  --navy: #062a52;
  --bg: #0b1220;
  --teal: #2dd4bf;
  --gold: #fbbf24;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-strong: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.12);
  /* Solid (non-translucent) fills for form controls so <select>/<input>
     chrome and the native option popup share one color instead of bleeding
     the page gradient through a translucent surface. */
  --field-bg: #10223d;
  --field-bg-hover: #16294a;
  --field-border: rgba(148, 163, 184, 0.28);
  --radius: 16px;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --slate: #64748b;
  --topbar-offset: 96px;
}

* { box-sizing: border-box; }

html {
  height: 100%;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(circle at 15% 0%, rgba(45, 212, 191, 0.16), transparent 45%),
    radial-gradient(circle at 85% 10%, rgba(6, 42, 82, 0.55), transparent 55%),
    linear-gradient(180deg, #071427 0%, var(--bg) 45%);
  background-attachment: fixed;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 24px 24px;
}

.app-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 300;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.brand-eyebrow {
  color: var(--teal);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.14em;
  font-weight: 600;
  margin: 0 0 4px;
}

.brand-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.topbar-nav a, .topbar-nav .navlink {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.topbar-nav a.active, .topbar-nav a:hover, .topbar-nav .navlink-active { color: var(--text); text-decoration: none; }

.customer-switcher select {
  min-width: 160px;
}

.form-input,
.form-select,
.filter-bar input,
.filter-bar select,
.customer-switcher select,
.login-wrap input {
  background-color: var(--field-bg);
  border: 1px solid var(--field-border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-select,
.filter-bar select,
.customer-switcher select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 34px;
  cursor: pointer;
}

.form-select-preset {
  min-width: 200px;
}

.date-field {
  position: relative;
}

.form-input-date {
  min-width: 147px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.date-field-value {
  color: var(--text);
}

.date-field-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  background-color: var(--teal);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E") center / contain no-repeat;
}

.date-field-trigger[aria-expanded="true"] {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.18);
}

.date-popover {
  position: fixed;
  z-index: 500;
  width: 260px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--field-border);
  background: var(--field-bg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.date-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.date-popover-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.date-popover-nav {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--field-border);
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}

.date-popover-nav:hover:not(:disabled) {
  border-color: var(--teal);
  color: var(--teal);
}

.date-popover-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.date-popover-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.date-popover-weekday {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding-bottom: 4px;
}

.date-popover-day {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.date-popover-day:hover:not(:disabled) {
  background: rgba(45, 212, 191, 0.16);
  color: var(--teal);
}

.date-popover-day--blank {
  cursor: default;
}

.date-popover-day--disabled {
  color: rgba(148, 163, 184, 0.28);
  cursor: not-allowed;
}

.date-popover-day--selected {
  background: var(--teal);
  color: #04201c;
  font-weight: 700;
}

.date-popover-day--selected:hover:not(:disabled) {
  background: var(--teal);
  color: #04201c;
}

.date-popover-footer {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.date-popover-quick-btn {
  width: 100%;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background: rgba(45, 212, 191, 0.08);
  color: var(--teal);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  padding: 8px 10px;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}

.date-popover-quick-btn:hover:not(:disabled) {
  background: rgba(45, 212, 191, 0.16);
  border-color: var(--teal);
}

.date-popover-quick-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.form-input:focus,
.form-select:focus,
.filter-bar input:focus,
.filter-bar select:focus,
.customer-switcher select:focus,
.login-wrap input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.18);
}

.form-input:hover,
.form-select:hover,
.filter-bar input:hover,
.filter-bar select:hover,
.customer-switcher select:hover {
  background-color: var(--field-bg-hover);
  border-color: rgba(45, 212, 191, 0.35);
}

/* Native option/optgroup popups ignore translucent backgrounds - paint the
   same solid field color so the open list matches the closed control. */
.form-select option,
.filter-bar select option,
.customer-switcher select option {
  background-color: var(--field-bg);
  color: var(--text);
}

.form-select optgroup,
.filter-bar select optgroup {
  background-color: var(--field-bg);
  color: var(--teal);
  font-style: normal;
  font-weight: 600;
}

.demo-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  margin-bottom: 22px;
}

.demo-panel h2, .demo-panel h3 { margin-top: 0; }

a.demo-panel {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

a.demo-panel:hover {
  text-decoration: none;
  border-color: rgba(45, 212, 191, 0.5);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
  transform: translateY(-2px);
}

a.demo-panel h3 {
  color: var(--teal);
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.panel-grid--cards {
  grid-template-columns: repeat(auto-fill, minmax(260px, 320px));
}

.panel-grid--explained {
  grid-template-columns: repeat(auto-fill, minmax(280px, 360px));
}

.panel-grid--cards > .demo-panel {
  margin-bottom: 0;
}

.demo-survey-stat {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}
.demo-survey-stat .stat-label {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 8px;
}
.demo-survey-stat .stat-value { font-size: 30px; font-weight: 700; }
.demo-survey-stat .stat-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

.demo-survey-stat .stat-headline {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.demo-survey-stat .stat-headline .stat-value {
  line-height: 1;
}

.demo-survey-stat:not(.demo-survey-stat-explained) .stat-headline .stat-sub {
  margin-top: 0;
  font-size: 18px;
  font-weight: 600;
}

.demo-survey-stat-explained {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.error-card-fold-details-wrap {
  display: block;
}

.error-card-fold-summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  user-select: none;
}

.error-card-fold-summary::-webkit-details-marker {
  display: none;
}

.error-card-fold-summary::marker {
  content: "";
}

.error-card-fold-summary:hover {
  background: rgba(255, 255, 255, 0.03);
}

.error-card-fold-summary:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
}

.error-card-fold-compact {
  flex: 1;
  min-width: 0;
}

.error-card-fold-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 4px;
  border-radius: 4px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  transition: transform 0.15s ease;
}

.error-card-fold-details-wrap[open] .error-card-fold-icon {
  transform: rotate(45deg);
}

.error-card-fold-details-wrap[open] .error-card-fold-summary {
  border-bottom: 1px solid var(--border);
}

.error-card-fold-details-wrap .stat-explainer {
  padding: 12px 16px 14px;
  margin: 0;
}

/* Big number first, at a fixed position at the top of every card, so the
   numbers line up across all cards regardless of how long the title is. */
.demo-survey-stat-explained .stat-headline {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.demo-survey-stat-explained .stat-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.demo-survey-stat-explained .stat-sub {
  margin-top: 0;
  font-size: 18px;
  font-weight: 600;
}

.demo-survey-stat-explained .stat-label {
  text-transform: none;
  letter-spacing: 0.01em;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  margin-top: 6px;
  padding-bottom: 0;
  border-bottom: none;
}

.error-card-fold-icon::before {
  content: "+";
}

.error-card-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  margin-bottom: 22px;
  align-items: start;
}

.error-group-title {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 600;
  color: var(--teal);
}

.error-group-title:first-child {
  margin-top: 0;
}

.stat-explainer {
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.stat-explainer > div {
  margin: 0;
}

.stat-explainer dt {
  margin: 0 0 2px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  color: var(--teal);
}

.stat-explainer dd {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.resolution-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
}

.resolution-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  line-height: 1.35;
}

.resolution-label {
  color: var(--text);
}

.resolution-count {
  color: var(--muted);
  white-space: nowrap;
}

.resolution-list--errors li {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.resolution-error-text {
  color: var(--text);
  word-break: break-word;
}

.panel-grid--cards > .demo-survey-stat {
  margin-bottom: 0;
}

.section-intro {
  font-size: 14px;
  line-height: 1.5;
  margin: -8px 0 18px;
  max-width: 72ch;
}

table.findings {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.findings th {
  text-align: left;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
table.findings td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
table.findings tr:hover td { background: rgba(255, 255, 255, 0.03); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
}
.pill.active { border-color: var(--teal); color: var(--teal); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge.good { background: rgba(34, 197, 94, 0.16); color: var(--good); }
.badge.warn { background: rgba(245, 158, 11, 0.16); color: var(--warn); }
.badge.bad { background: rgba(239, 68, 68, 0.16); color: var(--bad); }
.badge.slate { background: rgba(100, 116, 139, 0.2); color: var(--slate); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary {
  background: linear-gradient(135deg, var(--teal), #14b8a6);
  color: #04231d;
}
.btn-primary:hover { filter: brightness(1.08); text-decoration: none; }
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--teal); color: var(--teal); text-decoration: none; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 22px;
  position: sticky;
  top: var(--topbar-offset);
  z-index: 200;
  background: rgba(11, 18, 32, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}
.filter-bar.is-loading {
  opacity: 0.72;
  pointer-events: none;
}

.filter-bar.is-loading .btn-primary {
  position: relative;
}

.filter-bar.is-loading .btn-primary::after {
  content: "...";
}

#reportContent[aria-busy="true"] {
  opacity: 0.55;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.filter-bar label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}
.filter-bar .gate-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  min-height: 38px;
  align-items: center;
}
.filter-bar .gate-checkboxes label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-transform: none;
  font-size: 14px;
  color: var(--text);
  letter-spacing: normal;
  margin-bottom: 0;
  white-space: nowrap;
}

.flash {
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 14px;
}
.flash.success { background: rgba(34, 197, 94, 0.14); border: 1px solid var(--good); }
.flash.error { background: rgba(239, 68, 68, 0.14); border: 1px solid var(--bad); }

.login-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 24px 0;
}

.login-card {
  width: 100%;
  max-width: 400px;
  flex: 0 0 auto;
  margin-bottom: 0;
}

.login-card.demo-panel {
  margin-bottom: 0;
}

.login-form {
  margin-top: 4px;
}

.login-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}

.login-wrap input {
  width: 100%;
  margin-bottom: 14px;
}

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.login-remember {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.login-remember input {
  width: auto;
  margin: 0;
  accent-color: var(--teal);
}

.login-forgot {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.login-submit {
  width: 100%;
  justify-content: center;
}

.login-back-link {
  margin: 18px 0 0;
  font-size: 14px;
  text-align: center;
}

.muted { color: var(--muted); }
.section-title {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  color: var(--teal);
  font-weight: 700;
  margin: 34px 0 12px;
}

.chart-wrap { position: relative; height: 260px; }

.timing-panel-note--chart {
  margin-bottom: 0;
}

.timing-chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.timing-chart-header h3 {
  margin-bottom: 6px;
}

.timing-chart-mode {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.timing-chart-mode-btn {
  border: none;
  border-radius: 0;
  margin: 0;
}

.timing-chart-mode-btn + .timing-chart-mode-btn {
  border-left: 1px solid var(--border);
}

.timing-chart-mode-btn.is-active {
  background: rgba(45, 212, 191, 0.18);
  color: var(--teal);
}

.panel-grid--timing-charts {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.timing-panel h3 {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 14px;
}

.timing-heatmap-second-title {
  margin-top: 22px;
}

.timing-gate-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.timing-gate-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  min-width: 120px;
}

.timing-gate-tab.is-active {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 1px var(--teal);
}

.trends-gate-tabs .timing-gate-tab.is-active::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
}

.trends-gate-tabs .timing-gate-tab {
  position: relative;
}

.timing-gate-tabs--multiselect .timing-gate-tab {
  position: relative;
}

.timing-gate-tabs--multiselect .timing-gate-tab.is-active::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
}

.timing-gate-tab-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--teal);
}

.timing-gate-tab-meta {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

.timing-gate-panel h3 {
  margin-top: 0;
}

.timing-gate-panel:not([hidden]) + .timing-gate-panel:not([hidden]) {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.timing-legend-swatch--total,
.timing-legend-gradient {
  --heat-scale: linear-gradient(
    to right,
    hsl(205, 18%, 11%) 0%,
    hsl(187, 32%, 18%) 16.67%,
    hsl(170, 46%, 25%) 33.33%,
    hsl(152, 60%, 33%) 50%,
    hsl(135, 74%, 40%) 66.67%,
    hsl(117, 88%, 48%) 83.33%,
    hsl(35, 90%, 52%) 100%
  );
  background-color: hsl(205, 18%, 11%);
  background-image: var(--heat-scale);
}

.timing-legend-gradient {
  display: inline-block;
  width: 88px;
  height: 12px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
  vertical-align: middle;
}

@supports (background: linear-gradient(in oklch, #000, #fff)) {
  .timing-legend-swatch--total,
  .timing-legend-gradient {
    --heat-scale: linear-gradient(
      to right in oklch,
      hsl(205, 18%, 11%) 0%,
      hsl(187, 32%, 18%) 16.67%,
      hsl(170, 46%, 25%) 33.33%,
      hsl(152, 60%, 33%) 50%,
      hsl(135, 74%, 40%) 66.67%,
      hsl(117, 88%, 48%) 83.33%,
      hsl(35, 90%, 52%) 100%
    );
  }
}

.timing-heatmap--combined .timing-combined-cell:not(.timing-combined-cell--empty) {
  --heat-h: calc(205 - var(--total-intensity) * 170);
  --heat-s: calc(18% + var(--total-intensity) * 72%);
  --heat-l: calc(11% + var(--total-intensity) * 41%);
  background: hsl(var(--heat-h), var(--heat-s), var(--heat-l));
  border-color: hsl(
    var(--heat-h),
    calc(var(--heat-s) + 8%),
    calc(var(--heat-l) + 10%)
  );
}

.timing-heatmap--combined .timing-combined-cell {
  position: relative;
  min-height: 34px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px;
  overflow: hidden;
  cursor: default;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.timing-combined-cell:not(.timing-combined-cell--empty):hover,
.timing-combined-cell.timing-combined-cell--hover {
  z-index: 20;
  border-color: var(--teal);
  box-shadow: 0 0 0 1px var(--teal), 0 8px 20px rgba(0, 0, 0, 0.35);
}

.timing-cell-popover {
  position: fixed;
  z-index: 500;
  min-width: 220px;
  max-width: 320px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--teal);
  background: rgba(11, 18, 32, 0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.timing-cell-popover-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--teal);
  margin-bottom: 8px;
}

.timing-cell-popover-total {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  margin-bottom: 4px;
}

.timing-cell-popover-sub {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.timing-cell-popover-stack {
  display: flex;
  width: 100%;
  height: 10px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
  background: rgba(0, 0, 0, 0.25);
}

.timing-cell-popover-stack .timing-stack-success,
.timing-cell-popover-stack .timing-stack-override {
  height: 100%;
}

.timing-cell-popover-breakdown {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.timing-cell-popover-breakdown-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.timing-cell-popover-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
}

.timing-cell-popover-row span:last-child {
  font-weight: 600;
  white-space: nowrap;
}

.timing-cell-popover-row--success span:first-child::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: rgba(34, 197, 94, 0.9);
  margin-right: 6px;
  vertical-align: middle;
}

.timing-cell-popover-row--override span:first-child::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: rgba(45, 212, 191, 0.9);
  margin-right: 6px;
  vertical-align: middle;
}

.timing-cell-popover-bucket {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
  padding-left: 14px;
}

.timing-cell-popover-bucket span:last-child {
  color: var(--text);
  font-weight: 600;
}

.timing-combined-cell--empty {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.06);
}

.timing-stack-success {
  background: rgba(34, 197, 94, 0.9);
  min-width: 1px;
}

.timing-stack-override {
  background: rgba(45, 212, 191, 0.9);
  min-width: 1px;
}

.timing-combined-numbers {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
  width: 100%;
}

.timing-combined-total {
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  text-shadow:
    -1px -1px 0 rgba(0, 0, 0, 0.85),
    1px -1px 0 rgba(0, 0, 0, 0.85),
    -1px 1px 0 rgba(0, 0, 0, 0.85),
    1px 1px 0 rgba(0, 0, 0, 0.85),
    0 2px 3px rgba(0, 0, 0, 0.7);
}

.timing-combined-split {
  font-size: 8px;
  font-weight: 600;
  color: #ffffff;
  text-shadow:
    -1px -1px 0 rgba(0, 0, 0, 0.8),
    1px -1px 0 rgba(0, 0, 0, 0.8),
    -1px 1px 0 rgba(0, 0, 0, 0.8),
    1px 1px 0 rgba(0, 0, 0, 0.8);
}

.timing-cell-overlays {
  position: absolute;
  top: 1px;
  right: 1px;
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  max-width: 70%;
  justify-content: flex-end;
}

.timing-cell-badge {
  font-size: 7px;
  font-weight: 700;
  line-height: 1;
  padding: 1px 2px;
  border-radius: 2px;
  color: #fff;
  background: hsl(var(--layer-hue) 55% 38%);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.timing-layer-controls {
  margin-bottom: 18px;
}

.timing-mode-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.timing-mode-btn {
  border: none;
  border-radius: 0;
  margin: 0;
}

.timing-mode-btn + .timing-mode-btn {
  border-left: 1px solid var(--border);
}

.timing-mode-btn.is-active {
  background: rgba(45, 212, 191, 0.18);
  color: var(--teal);
}

.timing-toggle-title {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  color: var(--teal);
}

.timing-toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.timing-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.timing-toggle input {
  margin: 0;
  accent-color: var(--teal);
}

.timing-toggle-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: hsl(var(--layer-hue) 55% 45%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

.timing-toggle-label {
  line-height: 1.2;
}

.timing-toggle-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.timing-heatmap-block--spaced {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.timing-heatmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--muted);
}

.timing-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.timing-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.timing-legend-swatch--success {
  background: rgba(34, 197, 94, 0.75);
}

.timing-legend-swatch--override {
  background: rgba(45, 212, 191, 0.75);
}

.timing-panel-note {
  margin: 0 0 14px;
  font-size: 12px;
}

.timing-heatmap {
  display: grid;
  grid-template-columns: 36px repeat(24, minmax(0, 1fr));
  gap: 3px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.timing-heatmap-corner {
  min-height: 18px;
}

.timing-heatmap-hour {
  font-size: 9px;
  color: var(--muted);
  text-align: center;
  line-height: 1;
}

.timing-heatmap-day {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  cursor: default;
  border-radius: 4px;
  padding: 0 2px;
  transition: color 0.12s ease, background 0.12s ease;
}

.timing-heatmap-day:hover,
.timing-heatmap-day.timing-heatmap-day--hover {
  color: var(--teal);
  background: rgba(45, 212, 191, 0.08);
}

.timing-heatmap-cell {
  min-height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timing-heatmap-cell--layer {
  background: hsl(var(--layer-hue) 55% 42% / calc(var(--intensity, 0) * 0.85 + 0.06));
  border: 1px solid hsl(var(--layer-hue) 55% 42% / calc(var(--intensity, 0) * 0.4 + 0.08));
}

.timing-heatmap-cell--success {
  background: rgba(34, 197, 94, calc(var(--intensity, 0) * 0.85 + 0.06));
  border: 1px solid rgba(34, 197, 94, calc(var(--intensity, 0) * 0.4 + 0.08));
}

.timing-heatmap-cell--override {
  background: rgba(45, 212, 191, calc(var(--intensity, 0) * 0.85 + 0.06));
  border: 1px solid rgba(45, 212, 191, calc(var(--intensity, 0) * 0.4 + 0.08));
}

.timing-heatmap-cell--empty {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.06);
}

.timing-heatmap-count {
  font-size: 9px;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

.app-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.app-footer a { color: var(--muted); margin-left: 14px; }

/* Print/PDF override - matches the demo's light-mode export pattern
   (see html_export.py / pdf_export.py). */
body.demo-pdf-rendering {
  background: #ffffff !important;
  color: #0f172a !important;
}

.trends-kpi-grid {
  margin-bottom: 24px;
}

.trends-verdict-panel {
  margin-bottom: 20px;
}

.trends-verdict-panel h3 {
  margin: 0 0 14px;
  color: var(--teal);
  font-size: 14px;
}

.trends-verdict-window {
  font-weight: 400;
  font-size: 12px;
}

.trends-verdict-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.trends-verdict-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--surface);
}

.trends-verdict-card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.trends-verdict-card-headline {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.trends-verdict-card-detail {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

.trends-verdict-overall {
  margin-bottom: 4px;
}

.trends-verdict-card--better {
  border-color: rgba(34, 197, 94, 0.45);
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.15);
}

.trends-verdict-card--better .trends-verdict-card-headline {
  color: #22c55e;
}

.trends-verdict-card--worse {
  border-color: rgba(248, 113, 113, 0.45);
  box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.15);
}

.trends-verdict-card--worse .trends-verdict-card-headline {
  color: #f87171;
}

.trends-verdict-card--neutral .trends-verdict-card-headline {
  color: var(--muted);
}

.trends-kpi-compact {
  font-size: 22px;
}

.trends-direction {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.trends-direction--improving {
  color: #22c55e;
}

.trends-direction--regressing {
  color: #f87171;
}

.trends-direction--flat {
  color: var(--muted);
}

.trends-chart-panel {
  position: relative;
}

.trends-chart-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.trends-chart-panel-heading {
  flex: 1;
  min-width: 0;
}

.trends-chart-panel h3 {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 14px;
}

.trends-chart-note {
  margin: 0;
  font-size: 13px;
}

.trends-chart-verdict {
  flex-shrink: 0;
  width: min(100%, 260px);
  padding: 10px 12px;
  border-radius: 10px;
  text-align: right;
}

.trends-chart-verdict-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.trends-chart-verdict-headline {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 4px;
}

.trends-chart-verdict-detail {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}

.trends-chart-verdict.trends-verdict-card--better .trends-chart-verdict-headline {
  color: #22c55e;
}

.trends-chart-verdict.trends-verdict-card--worse .trends-chart-verdict-headline {
  color: #f87171;
}

.trends-chart-verdict.trends-verdict-card--neutral .trends-chart-verdict-headline {
  color: var(--muted);
}

.trends-charts {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.trends-gate-tabs {
  margin-top: 4px;
  margin-bottom: 14px;
}

.trends-chart-wrap {
  position: relative;
  min-height: 260px;
  padding-bottom: 12px;
}

body.demo-pdf-rendering .demo-panel {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}
body.demo-pdf-rendering table.findings th { color: #475569 !important; }
body.demo-pdf-rendering table.findings td { border-color: #e2e8f0 !important; }
body.demo-pdf-rendering .topbar, body.demo-pdf-rendering .app-footer,
body.demo-pdf-rendering .filter-bar, body.demo-pdf-rendering .no-print {
  display: none !important;
}
