:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-light: #eef2ff;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.05);
  --radius: 0.75rem;
}

* {
  box-sizing: border-box;
}

/* ── Page layout: footer stays at bottom ─────────────── */

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: min(1000px, 92vw);
  margin: 0 auto;
}

/* ── Hero ─────────────────────────────────────────────── */

.hero {
  background:
    radial-gradient(ellipse 80% 60% at 70% -10%, rgba(129,140,248,0.25) 0%, transparent 60%),
    linear-gradient(160deg, #0f172a 0%, #1e1b4b 45%, #312e81 100%);
  color: #fff;
  padding: 3.25rem 0 3rem;
  position: relative;
}

.hero--compact {
  padding: 1.5rem 0 1.75rem;
}

.hero--compact .lead,
.hero--compact .hero-stats {
  display: none;
}

.hero-title-link {
  text-decoration: none;
  color: inherit;
  display: inline-block;
}

.hero-title-link:hover h1 {
  opacity: 0.88;
}

.hero h1 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  transition: opacity 0.15s;
}

.lead {
  margin: 0 0 1.75rem;
  color: #c7d2fe;
  font-size: 1.05rem;
}

/* ── Hero stats ───────────────────────────────────────── */

.hero-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  row-gap: 1rem;
  margin-bottom: 2rem;
}

.hero-stat {
  display: flex;
  flex-direction: column;
  padding-right: 2rem;
}

.hero-stat-divider {
  width: 1px;
  height: 2.5rem;
  background: rgba(165,180,252,0.35);
  margin-right: 2rem;
  flex-shrink: 0;
}

.hero-stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.1;
  color: #fff;
}

.hero-stat-label {
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #a5b4fc;
  margin-top: 0.2rem;
}

/* ── Search ───────────────────────────────────────────── */

.search-panel {
  position: relative;
  max-width: 560px;
}

.search-wrapper {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: #94a3b8;
  pointer-events: none;
}

#company-search {
  width: 100%;
  border: 0;
  border-radius: 0.6rem;
  font-size: 1rem;
  padding: 0.9rem 1rem 0.9rem 2.85rem;
  outline: none;
  color: var(--text);
  background: #fff;
  -webkit-appearance: none;
  appearance: none;
  transition: box-shadow 0.15s;
}

#company-search:focus {
  box-shadow: 0 0 0 3px rgba(99,102,241,0.45);
}

#company-search::placeholder {
  color: #94a3b8;
}

#company-search::-webkit-search-decoration,
#company-search::-webkit-search-cancel-button,
#company-search::-webkit-search-results-button,
#company-search::-webkit-search-results-decoration {
  display: none;
}

.suggestions {
  margin: 0.3rem 0 0;
  list-style: none;
  padding: 0.3rem;
  position: absolute;
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  max-height: 17rem;
  overflow-y: auto;
  z-index: 20;
  box-shadow: var(--shadow-md);
}

/* Hide the dropdown entirely when there are no results */
.suggestions:empty {
  display: none;
}

.suggestion-item {
  padding: 0.65rem 0.8rem;
  cursor: pointer;
  color: var(--text);
  border-radius: 0.4rem;
  font-size: 0.9rem;
  transition: background 0.1s;
}

.suggestion-item:hover {
  background: var(--accent-light);
  color: var(--accent);
}

/* ── Main layout ──────────────────────────────────────── */

main.main-content {
  flex: 1;
  padding: 1.75rem 0 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Cards ────────────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem 1.85rem;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 0.9rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.company-name {
  font-size: clamp(1.15rem, 2.5vw, 1.5rem) !important;
  font-weight: 700 !important;
  letter-spacing: -0.02em !important;
}

/* ── Warning card ─────────────────────────────────────── */

.warning {
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  background: #fffbeb;
}

.warning h2 {
  color: #92400e;
  margin-bottom: 0.4rem;
}

.warning p {
  color: #78350f;
  margin: 0;
  font-size: 0.95rem;
}

/* ── About section ────────────────────────────────────── */

.about-body p {
  margin: 0 0 0.65rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.about-body p:last-child {
  margin-bottom: 0;
}

.about-body a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.about-body a:hover {
  text-decoration: underline;
}

.update-stamp {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.85rem 0 0;
  padding: 0.55rem 0.85rem;
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  border-radius: 0 0.4rem 0.4rem 0;
}

.update-stamp strong {
  color: var(--text);
  font-weight: 600;
}

.update-ago {
  color: var(--muted);
  font-style: italic;
}

.recent-updates-table-wrap {
  max-height: 29rem;
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.most-viewed-table-wrap {
  max-height: none;
  overflow-y: visible;
}

.recent-updates-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.recent-updates-table th,
.recent-updates-table td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.recent-updates-table th {
  background: var(--bg);
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

.recent-updates-table tbody tr:last-child td {
  border-bottom: none;
}

.recent-updates-table tbody tr:hover td {
  background: #f8fafc;
}

.recent-updates-company {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.recent-updates-company:hover {
  text-decoration: underline;
}

.recent-updates-ago {
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── Company metadata grid ────────────────────────────── */

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1.1rem 2rem;
  margin-top: 0.25rem;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.meta-item--full {
  grid-column: 1 / -1;
}

.meta-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.meta-value {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 500;
}

.year-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.1rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.badge--late {
  border-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
}

/* ── Gov.uk external link ─────────────────────────────── */

.govuk-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}

.govuk-link:hover {
  text-decoration: underline;
}

.ext-icon {
  width: 0.9rem;
  height: 0.9rem;
  flex-shrink: 0;
}

/* ── Quartile legend ─────────────────────────────────── */

.quartile-legend {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.1rem;
  align-items: center;
}

.quartile-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.quartile-legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Chart ────────────────────────────────────────────── */

.chart-description {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.chart-no-data {
  color: var(--muted);
  font-size: 0.875rem;
  font-style: italic;
  padding: 1.5rem 0;
  margin: 0;
  text-align: center;
}

/* ── Company header card ──────────────────────────────── */

.company-summary {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0.1rem 0 1.25rem;
  line-height: 1.5;
}

.company-summary--late {
  color: #b45309;
}

.company-last-submission {
  margin: -0.65rem 0 1.15rem;
  font-size: 0.86rem;
  color: var(--muted);
}

.company-last-submission strong {
  color: var(--text);
  font-weight: 600;
}

/* ── Stats bar ────────────────────────────────────────── */

.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.stat-item {
  display: flex;
  flex-direction: column;
  padding: 0.85rem 1.25rem;
  border-right: 1px solid var(--border);
  flex: 1;
  min-width: 130px;
}

.stat-item:last-child {
  border-right: none;
}

.stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.stat-value--warn {
  color: #dc2626;
}

.stat-value--good {
  color: #16a34a;
}

/* ── Quartile grid ────────────────────────────────────── */

.quartile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem 2rem;
}

.quartile-chart-wrap {
  min-width: 0;
}

.quartile-label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.5rem;
}

.quartile-sub {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.75rem;
  margin-left: 0.3rem;
}

/* ── Bonus grid ───────────────────────────────────────── */

.bonus-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem 2rem;
}

.bonus-grid > div {
  min-width: 0;
}

/* ── Footer ───────────────────────────────────────────── */

.site-footer {
  background: #2d2d32;
  color: #9a9aa0;
  padding: 1.5rem 0 1.75rem;
  font-size: 0.875rem;
  text-align: center;
  flex-shrink: 0;
}

.footer-brand {
  margin: 0 0 0.4rem;
  color: #c4c4c8;
  font-weight: 500;
}

.footer-meta {
  margin: 0;
  font-size: 0.8rem;
  color: #9a9aa0;
}

.site-footer a {
  color: #eeb346;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-footer a:hover {
  color: #f5cf6a;
}

.site-footer a.footer-link-muted {
  color: #9a9aa0;
}

.site-footer a.footer-link-muted:hover {
  color: #c4c4c8;
}

/* ── Cookie banner ────────────────────────────────────── */

.cookie-banner {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(940px, calc(100% - 2rem));
  z-index: 1000;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-left: 5px solid #94a3b8;
  border-radius: 0.75rem;
  box-shadow: var(--shadow-md);
  padding: 0.95rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem 1rem;
}

.cookie-banner-text {
  margin: 0;
  color: #334155;
  font-size: 0.93rem;
  font-weight: 500;
}

.cookie-banner-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.cookie-btn {
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cookie-btn--accept {
  background: #334155;
  color: #fff;
}

.cookie-btn--accept:hover {
  background: #1e293b;
}

.cookie-btn--reject {
  background: #fff;
  border-color: #cbd5e1;
  color: #334155;
}

.cookie-btn--reject:hover {
  background: #f1f5f9;
}

.cookie-banner--hidden {
  display: none !important;
}

/* ── Year-by-year fold-outs ──────────────────────────── */

.year-reports {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

details.year-report {
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--bg);
  overflow: hidden;
}

details.year-report summary {
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  gap: 0.75rem;
}

details.year-report summary::-webkit-details-marker {
  display: none;
}

details.year-report[open] summary {
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

details.year-report[open] .year-report-chevron {
  transform: rotate(180deg);
}

.year-report-summary-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.year-report-summary-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.year-report-year {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.year-report-hint {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

.year-report-chevron {
  color: var(--muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.late-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  white-space: nowrap;
}

.year-report-body {
  padding: 1.1rem 1.25rem 1.25rem;
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.year-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem 1.5rem;
}

.year-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.year-stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.year-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.year-stat-value--warn {
  color: #dc2626;
}

.year-stat-value--good {
  color: #16a34a;
}

.year-text-summary {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.85rem 1.1rem;
}

.year-text-summary p {
  margin: 0 0 0.35rem;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.55;
}

.year-text-summary p:last-child {
  margin-bottom: 0;
}

.year-submitted-at {
  font-size: 0.8rem !important;
  color: var(--muted) !important;
  margin-bottom: 0.6rem !important;
  padding-bottom: 0.55rem;
  border-bottom: 1px dashed var(--border);
}

.year-text-summary strong {
  font-weight: 700;
}

.year-quartile-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.7rem;
}

.year-quartile-header-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.year-quartile-bar-spacer {
  flex: 1;
}

.year-quartile-pct-header {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  width: 45px;
  text-align: center;
  flex-shrink: 0;
}

.year-quartile-pct-header--women {
  color: #6366f1;
}

.year-quartile-pct-header--men {
  color: #1e293b;
}

.year-quartile-rows {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.year-quartile-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.year-quartile-name {
  font-size: 0.78rem;
  color: var(--muted);
  width: 105px;
  flex-shrink: 0;
}

.year-quartile-bar {
  flex: 1;
  height: 14px;
  display: flex;
  align-items: center;
}

.year-quartile-half {
  flex: 1;
  height: 100%;
  overflow: hidden;
  background: #f1f5f9;
}

.year-quartile-half--left {
  display: flex;
  justify-content: flex-end;
  border-radius: 7px 0 0 7px;
}

.year-quartile-half--right {
  border-radius: 0 7px 7px 0;
}

.year-quartile-fill-women {
  height: 100%;
  background: #6366f1;
}

.year-quartile-fill-men {
  height: 100%;
  background: #1e293b;
}

.year-quartile-center-mark {
  width: 2px;
  height: 20px;
  background: var(--text);
  opacity: 0.35;
  flex-shrink: 0;
  border-radius: 1px;
}

.year-quartile-pct {
  font-size: 0.78rem;
  font-weight: 600;
  width: 45px;
  text-align: center;
  flex-shrink: 0;
}

.year-quartile-pct--women {
  color: #6366f1;
}

.year-quartile-pct--men {
  color: #1e293b;
}

/* ── Utility ──────────────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ── Responsive: tablet (≤768px) ─────────────────────── */

@media (max-width: 768px) {
  .hero {
    padding: 2.5rem 0 2.5rem;
  }

  .hero-stat-value {
    font-size: 1.45rem;
  }

  .card {
    padding: 1.25rem 1.35rem;
  }

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

  .quartile-grid,
  .bonus-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .stats-bar {
    flex-wrap: wrap;
  }

  .stat-item {
    min-width: 45%;
    border-bottom: 1px solid var(--border);
  }

  .cookie-banner {
    width: calc(100% - 1.25rem);
    bottom: 0.6rem;
    padding: 0.8rem 0.85rem;
  }

  .cookie-banner-text {
    font-size: 0.88rem;
  }
}

/* ── Responsive: mobile (≤480px) ─────────────────────── */

@media (max-width: 480px) {
  .hero {
    padding: 2rem 0 2.25rem;
  }

  .lead {
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
  }

  .hero-stats {
    margin-bottom: 1.5rem;
    row-gap: 0.75rem;
    column-gap: 1.5rem;
  }

  .hero-stat-divider {
    display: none;
  }

  .hero-stat {
    padding-right: 0;
  }

  .hero-stat-value {
    font-size: 1.3rem;
  }

  .hero-stat-label {
    font-size: 0.68rem;
  }

  .card {
    padding: 1.1rem 1rem;
    border-radius: 0.6rem;
  }

  .card h2 {
    font-size: 1rem;
  }

  .meta-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem 1rem;
  }

  main.main-content {
    padding: 1.25rem 0 2rem;
    gap: 1rem;
  }

  .stat-item {
    min-width: 100%;
    border-right: none;
  }

  .quartile-grid,
  .bonus-grid {
    grid-template-columns: 1fr;
  }

  .cookie-banner {
    left: 0.6rem;
    right: 0.6rem;
    transform: none;
    width: auto;
    align-items: flex-start;
    flex-direction: column;
  }

  .cookie-banner-actions {
    width: 100%;
  }

  .cookie-btn {
    flex: 1;
    min-width: 130px;
  }
}
