:root {
  color-scheme: light;
  --text: #172033;
  --text-strong: #101828;
  --muted: #667085;
  --subtle: #98a2b3;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --soft: #f2f4f7;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --blue: #0a66ff;
  --blue-soft: #edf4ff;
  --green: #137a4f;
  --green-soft: #ecf8f2;
  --amber: #a15c00;
  --amber-soft: #fff7e8;
  --red: #d92d20;
  --red-soft: #fff1f0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(10, 102, 255, 0.24);
  outline-offset: 2px;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

h1,
h2,
p,
dl,
dd {
  margin-top: 0;
}

h1,
h2 {
  color: var(--text-strong);
}

.hidden {
  display: none !important;
}

.insights-shell {
  width: min(1440px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 28px 56px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 248, 250, 0.96);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand-cluster,
.topbar-actions,
.brand,
.project-context,
.quiet-link,
.heading-tools {
  display: flex;
  align-items: center;
}

.brand-cluster,
.topbar-actions {
  gap: 14px;
}

.brand {
  gap: 10px;
  color: var(--text-strong);
  font-size: 1.05rem;
  font-weight: 720;
  text-decoration: none;
}

.brand img {
  width: 28px;
  height: 28px;
}

.project-context {
  min-height: 38px;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.project-context strong {
  color: var(--text-strong);
  font-size: 0.9rem;
}

.project-context small {
  color: var(--muted);
  font-size: 0.75rem;
}

.freshness-pill {
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 720;
}

.freshness-pill.is-live {
  border-color: #cfe9dc;
  color: var(--green);
  background: var(--green-soft);
}

.freshness-pill.is-preview {
  border-color: #f1d7aa;
  color: var(--amber);
  background: var(--amber-soft);
}

.quiet-link {
  min-height: 38px;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 680;
  text-decoration: none;
}

.quiet-link:hover {
  background: var(--soft);
}

.quiet-link svg {
  width: 17px;
  height: 17px;
}

.access-gate {
  width: min(520px, 100%);
  margin: 12vh auto 0;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(16, 24, 40, 0.08);
}

.access-gate h1 {
  margin-bottom: 12px;
  font-size: 2.25rem;
  line-height: 1.08;
}

.access-gate > p:not(.eyebrow, .form-error) {
  margin-bottom: 24px;
  color: var(--muted);
  line-height: 1.5;
}

.access-gate form {
  display: grid;
  gap: 10px;
}

.access-gate label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 680;
}

.access-gate input {
  min-height: 50px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--text-strong);
  background: var(--surface);
}

.primary-button {
  min-height: 48px;
  margin-top: 8px;
  padding: 0 18px;
  border: 1px solid var(--blue);
  border-radius: 7px;
  color: #ffffff;
  background: var(--blue);
  font-weight: 720;
}

.primary-button:hover {
  background: #0758dc;
}

.form-error {
  margin: 12px 0 0;
  color: var(--red);
  font-size: 0.88rem;
  font-weight: 680;
}

.workspace {
  padding-top: 42px;
}

.workspace-heading,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
}

.workspace-heading {
  padding-bottom: 28px;
}

.workspace-heading > div:first-child {
  max-width: 760px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
  text-transform: uppercase;
}

.workspace-heading h1 {
  margin-bottom: 10px;
  font-size: clamp(2.2rem, 4.4vw, 4.1rem);
  font-weight: 720;
  line-height: 1.04;
}

.workspace-heading p:not(.eyebrow),
.section-heading p:not(.eyebrow) {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.heading-tools {
  flex: 0 0 auto;
  gap: 10px;
}

.range-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(64px, 1fr));
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
}

.range-control button {
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  font-size: 0.84rem;
  font-weight: 680;
}

.range-control button[aria-pressed="true"] {
  color: var(--text-strong);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface);
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--soft);
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.icon-button.is-loading svg {
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.workspace-status {
  display: block;
  min-height: 24px;
  margin: -12px 0 18px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 620;
}

.workspace-status.is-error {
  color: var(--red);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 26px;
}

.metric-card {
  min-width: 0;
  min-height: 142px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 680;
}

.metric-card header svg {
  width: 18px;
  height: 18px;
}

.metric-value {
  display: block;
  margin: 14px 0 6px;
  color: var(--text-strong);
  font-size: clamp(2rem, 3vw, 2.8rem);
  font-weight: 740;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.metric-card.is-good header svg,
.status-dot.is-good {
  color: var(--green);
}

.metric-card.is-attention header svg,
.status-dot.is-attention {
  color: var(--amber);
}

.insights-section {
  min-width: 0;
  padding: 26px 0;
  border-top: 1px solid var(--line);
}

.section-heading {
  margin-bottom: 22px;
}

.section-heading > div {
  min-width: 0;
}

.section-heading h2 {
  margin-bottom: 6px;
  font-size: 1.45rem;
  line-height: 1.15;
}

.section-summary {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--text);
  background: var(--soft);
  font-size: 0.8rem;
  font-weight: 720;
  white-space: nowrap;
}

.language-progress {
  display: grid;
  gap: 2px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.language-row {
  display: grid;
  grid-template-columns: minmax(145px, 0.8fr) minmax(260px, 2fr) minmax(225px, 1fr);
  align-items: center;
  gap: 24px;
  min-height: 94px;
  padding: 18px 20px;
  background: var(--surface);
}

.language-name strong,
.language-outcome strong {
  display: block;
  color: var(--text-strong);
}

.language-name span,
.language-outcome span {
  color: var(--muted);
  font-size: 0.84rem;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--soft);
}

.progress-track i {
  display: block;
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: var(--blue);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 620;
}

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

.two-column-band {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.85fr);
  gap: 38px;
}

.pace-chart {
  display: grid;
  height: 188px;
  grid-auto-flow: column;
  grid-auto-columns: minmax(10px, 1fr);
  align-items: end;
  gap: 5px;
  padding: 12px 0 28px;
  border-bottom: 1px solid var(--line);
}

.pace-column {
  position: relative;
  display: flex;
  height: 100%;
  align-items: flex-end;
  justify-content: center;
}

.pace-column i {
  display: block;
  width: min(18px, 72%);
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--blue);
}

.pace-column span {
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  color: var(--subtle);
  font-size: 0.68rem;
  white-space: nowrap;
  transform: translateX(-50%);
}

.funnel-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding-top: 18px;
}

.funnel-stat {
  min-width: 0;
}

.funnel-stat span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.76rem;
}

.funnel-stat strong {
  color: var(--text-strong);
  font-size: 1.02rem;
}

.source-list,
.readiness-list {
  display: grid;
  gap: 0;
}

.source-row,
.readiness-row {
  display: grid;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.source-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.source-row:last-child,
.readiness-row:last-child {
  border-bottom: 0;
}

.source-row strong,
.readiness-copy strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text-strong);
}

.source-row span,
.readiness-copy span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.source-count {
  color: var(--text-strong);
  font-size: 1.1rem;
  font-weight: 740;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  margin: 0;
  padding: 18px 0;
  color: var(--muted);
  line-height: 1.45;
}

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

.operation-item {
  min-height: 100px;
  padding: 16px;
  border-left: 3px solid var(--line-strong);
  background: var(--surface);
}

.operation-item.is-good {
  border-left-color: var(--green);
}

.operation-item.is-attention {
  border-left-color: var(--amber);
}

.operation-item strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text-strong);
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}

.operation-item span {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.room-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.room-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.language-code {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 0.72rem;
  font-weight: 760;
}

.room-row strong {
  display: block;
  color: var(--text-strong);
  font-size: 0.9rem;
}

.room-row small {
  color: var(--muted);
}

.room-state {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 680;
  text-transform: capitalize;
}

.final-band {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.readiness-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

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

.status-dot.is-neutral {
  color: var(--subtle);
}

.status-label {
  min-width: 86px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 720;
  text-align: right;
  text-transform: uppercase;
}

.metric-definitions {
  margin-top: 2px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

.metric-definitions summary {
  width: fit-content;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 680;
  cursor: pointer;
}

.metric-definitions dl {
  display: grid;
  grid-template-columns: minmax(120px, 0.28fr) minmax(0, 1fr);
  gap: 12px 24px;
  max-width: 880px;
  margin: 18px 0 0;
}

.metric-definitions dt {
  color: var(--text-strong);
  font-weight: 680;
}

.metric-definitions dd {
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 980px) {
  .metric-strip,
  .operations-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .language-row {
    grid-template-columns: 145px minmax(0, 1fr);
  }

  .language-outcome {
    grid-column: 1 / -1;
  }

  .two-column-band,
  .final-band {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

@media (max-width: 680px) {
  .insights-shell {
    padding: 0 16px 40px;
  }

  .topbar {
    min-height: 64px;
  }

  .project-context,
  .freshness-pill,
  .quiet-link span {
    display: none;
  }

  .quiet-link {
    width: 40px;
    height: 40px;
    justify-content: center;
    padding: 0;
  }

  .workspace {
    padding-top: 28px;
  }

  .workspace-heading,
  .section-heading {
    display: grid;
    gap: 16px;
  }

  .workspace-heading h1 {
    font-size: 2.5rem;
  }

  .heading-tools {
    width: 100%;
  }

  .range-control {
    flex: 1;
  }

  .metric-strip,
  .operations-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .metric-card {
    min-height: 132px;
    padding: 14px;
  }

  .metric-value {
    font-size: 2rem;
  }

  .language-row {
    grid-template-columns: 1fr;
    gap: 16px;
    min-height: 0;
  }

  .language-outcome {
    grid-column: auto;
  }

  .funnel-summary {
    grid-template-columns: 1fr;
  }

  .room-list {
    grid-template-columns: 1fr;
  }

  .operation-item {
    min-height: 92px;
    padding: 14px 12px;
  }

  .metric-definitions dl {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .metric-definitions dd {
    margin-bottom: 12px;
  }
}

@media (max-width: 420px) {
  .access-gate {
    margin-top: 7vh;
    padding: 24px;
  }

  .access-gate h1 {
    font-size: 1.9rem;
  }

  .workspace-heading h1 {
    font-size: 2.2rem;
  }

}

@media (max-width: 350px) {
  .metric-strip,
  .operations-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
