/* ============================================================
   Teach for Poland — Portal Design Tokens
   Shared across login, teacher portal, and staff portal.
   ============================================================ */

:root {
  --tfp-bg-warm: #F6F3EC;
  --tfp-surface: #FFFFFF;
  --tfp-surface-muted: #FBFAF6;
  --tfp-teal: #1F8A8A;
  --tfp-teal-light: #2BB3B3;
  --tfp-teal-soft: rgba(31, 138, 138, 0.08);
  --tfp-teal-soft-border: rgba(31, 138, 138, 0.14);
  --tfp-teal-icon-bg: rgba(43, 179, 179, 0.12);
  --tfp-coral: #EE5A52;
  --tfp-coral-icon-bg: rgba(238, 90, 82, 0.1);
  --tfp-ink: #14181C;
  --tfp-ink-2: #3A4148;
  --tfp-ink-3: #6B7480;
  --tfp-ink-icon-bg: rgba(20, 24, 28, 0.06);
  --tfp-border: #E7E4DC;
  --tfp-chart-1: #EE5A52;
  --tfp-chart-2: #F4A261;
  --tfp-chart-3: #2BB3B3;
  --tfp-chart-4: #1F8A8A;
  --tfp-chart-5: #6B7480;
  --tfp-radius-sm: 10px;
  --tfp-radius-md: 12px;
  --tfp-radius-lg: 16px;
  --tfp-sidebar-width: 260px;
  --tfp-font-display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --tfp-font-ui: "Geist", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}
/* ============================================================
   Teach for Poland — Login Page
   Editorial split-screen layout with warm cream background,
   Instrument Serif display type and Geist sans-serif body.
   ============================================================ */

:root {
  --tfp-login-teal:       var(--tfp-teal-light);
  --tfp-login-teal-deep:  var(--tfp-teal);
  --tfp-login-coral:      var(--tfp-coral);
  --tfp-login-coral-deep: #D9433B;
  --tfp-login-ink:        var(--tfp-ink);
  --tfp-login-ink-2:      var(--tfp-ink-2);
  --tfp-login-ink-3:      var(--tfp-ink-3);
  --tfp-login-line:       var(--tfp-border);
  --tfp-login-bg:         var(--tfp-bg-warm);
  --tfp-login-card:       var(--tfp-surface);
  --tfp-login-field:      var(--tfp-surface-muted);
}

/* Override the global login-body background so the warm cream shows through. */
body.login-body {
  background: var(--tfp-login-bg);
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  color: var(--tfp-login-ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.login-body * {
  box-sizing: border-box;
}

/* ---------- Shell ---------- */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 24px;
  position: relative;
}

/* ---------- LEFT: form panel ---------- */
.login-panel {
  background: var(--tfp-login-card);
  border-radius: 20px;
  border: 1px solid var(--tfp-login-line);
  box-shadow:
    0 1px 0 rgba(20, 24, 28, 0.02),
    0 24px 60px -40px rgba(20, 24, 28, 0.18);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.login-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 32px;
}

.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--tfp-login-ink);
  text-decoration: none;
}

.login-brand-logo {
  height: 100px;
  width: auto;
  display: block;
}

.login-top-link {
  font-size: 13px;
  color: var(--tfp-login-ink-3);
}

.login-top-link a {
  color: var(--tfp-login-ink);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid var(--tfp-login-line);
  padding-bottom: 1px;
  margin-left: 4px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.login-top-link a:hover {
  border-color: var(--tfp-login-teal);
  color: var(--tfp-login-teal-deep);
}

.login-top-link-action {
  color: var(--tfp-login-ink-3);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid var(--tfp-login-line);
  padding-bottom: 1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.login-top-link-action:hover {
  color: var(--tfp-login-teal-deep);
  border-color: var(--tfp-login-teal);
}

.login-panel-head-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.login-locale-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-locale-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--tfp-login-ink-3);
  white-space: nowrap;
}

.login-locale-select-wrap {
  position: relative;
}

.login-locale-select {
  appearance: none;
  border: 1px solid var(--tfp-login-line);
  border-radius: 999px;
  background: var(--tfp-login-field);
  color: var(--tfp-login-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  padding: 8px 32px 8px 14px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='none' stroke='%23667085' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.login-locale-select:focus {
  outline: none;
  border-color: var(--tfp-login-teal);
  box-shadow: 0 0 0 3px rgba(43, 179, 179, 0.14);
}

.login-panel-body {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px 32px 40px;
}

.login-form-wrap {
  width: 100%;
  max-width: 408px;
}

.login-title {
  font-family: 'Instrument Serif', 'Times New Roman', serif;
  font-weight: 400;
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
  color: var(--tfp-login-ink);
}

.login-title em {
  font-style: italic;
  color: var(--tfp-login-teal-deep);
}

.login-subtitle {
  color: var(--tfp-login-ink-3);
  font-size: 15px;
  line-height: 1.5;
  margin: 0 0 28px;
}

/* ---------- Flash messages ---------- */
.login-flash {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 18px;
  border: 1px solid transparent;
}

.login-flash.is-alert {
  background: rgba(238, 90, 82, 0.08);
  border-color: rgba(238, 90, 82, 0.25);
  color: var(--tfp-login-coral-deep);
}

.login-flash.is-notice {
  background: rgba(43, 179, 179, 0.08);
  border-color: rgba(43, 179, 179, 0.25);
  color: var(--tfp-login-teal-deep);
}

/* ---------- Form fields ---------- */
.login-field {
  display: block;
  margin-bottom: 14px;
}

.login-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--tfp-login-ink-2);
  margin-bottom: 6px;
}

.login-field-input {
  position: relative;
}

.login-field-input input {
  width: 100%;
  height: 48px;
  padding: 0 44px 0 14px;
  border-radius: 12px;
  border: 1px solid var(--tfp-login-line);
  background: var(--tfp-login-field);
  font: inherit;
  font-size: 15px;
  color: var(--tfp-login-ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.login-field-input input::placeholder {
  color: #9AA2AC;
}

.login-field-input input:hover {
  border-color: #D9D5CB;
}

.login-field-input input:focus {
  border-color: var(--tfp-login-teal);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(43, 179, 179, 0.14);
}

.login-field-input input:-webkit-autofill,
.login-field-input input:-webkit-autofill:hover,
.login-field-input input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--tfp-login-ink);
  -webkit-box-shadow: 0 0 0 40px var(--tfp-login-field) inset;
  transition: background-color 5000s ease-in-out 0s;
}

.login-field-input .login-icon-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  color: var(--tfp-login-ink-3);
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}

.login-field-input .login-icon-btn:hover {
  color: var(--tfp-login-ink);
  background: rgba(20, 24, 28, 0.05);
}

/* ---------- Row between (checkbox + forgot) ---------- */
.login-row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 6px 0 22px;
}

.login-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--tfp-login-ink-2);
  user-select: none;
  cursor: pointer;
}

.login-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid #C8C2B4;
  background: #fff;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  margin: 0;
  transition: all 0.15s;
}

.login-check input[type="checkbox"]:checked {
  background: var(--tfp-login-ink);
  border-color: var(--tfp-login-ink);
}

.login-check input[type="checkbox"]:checked::after {
  content: "";
  width: 10px;
  height: 10px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='3 8.5 7 12 13 5'/></svg>") center/contain no-repeat;
}

.login-forgot {
  font-size: 14px;
  color: var(--tfp-login-ink);
  text-decoration: none;
  border-bottom: 1px solid var(--tfp-login-line);
  padding-bottom: 1px;
  transition: color 0.15s, border-color 0.15s;
}

.login-forgot:hover {
  color: var(--tfp-login-coral-deep);
  border-color: var(--tfp-login-coral);
}

.login-form-actions {
  margin-top: 8px;
}

.login-field-hint {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--tfp-login-ink-3);
}

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

.login-flash-list li + li {
  margin-top: 4px;
}

/* ---------- Buttons ---------- */
.login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 52px;
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s, box-shadow 0.15s;
  border: 1px solid transparent;
  -webkit-appearance: none;
  appearance: none;
}

.login-btn-primary {
  background: var(--tfp-login-ink);
  color: #fff;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 8px 20px -10px rgba(20, 24, 28, 0.5);
}

.login-btn-primary:hover {
  background: #000;
}

.login-btn-primary:active {
  transform: translateY(1px);
}

.login-btn-primary .login-arrow {
  width: 16px;
  height: 16px;
  transition: transform 0.2s;
}

.login-btn-primary:hover .login-arrow {
  transform: translate(2px, 0);
}

/* Force override against broad ActiveAdmin input styles */
body.login-body input[type="submit"].login-btn,
body.login-body input[type="submit"].login-btn-primary {
  background: var(--tfp-login-ink) !important;
  color: #ffffff !important;
  border: 1px solid transparent !important;
  text-shadow: none !important;
}

body.login-body input[type="submit"].login-btn-primary:hover {
  background: #000 !important;
}

/* ---------- Footer ---------- */
.login-panel-foot {
  padding: 20px 32px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--tfp-login-ink-3);
  font-size: 12px;
  border-top: 1px solid var(--tfp-login-line);
}

.login-panel-foot .login-foot-links {
  display: flex;
  gap: 18px;
}

.login-panel-foot a {
  color: var(--tfp-login-ink-3);
  text-decoration: none;
  transition: color 0.15s;
}

.login-panel-foot a:hover {
  color: var(--tfp-login-ink);
}

/* ---------- RIGHT: image stage ---------- */
.login-stage {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background: #1a1a1a;
  isolation: isolate;
}

.login-stage .login-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 62% center;
  z-index: 0;
}

.login-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(11, 30, 32, 0.18) 0%, rgba(11, 30, 32, 0) 35%, rgba(11, 30, 32, 0) 55%, rgba(11, 18, 20, 0.7) 100%),
    radial-gradient(120% 80% at 80% 10%, rgba(43, 179, 179, 0.18) 0%, rgba(43, 179, 179, 0) 55%);
  z-index: 1;
}

.login-stage-bottom {
  position: absolute;
  left: 40px;
  right: 40px;
  bottom: 40px;
  z-index: 2;
  color: #fff;
}

.login-stage-headline {
  font-family: 'Instrument Serif', 'Times New Roman', serif;
  font-weight: 400;
  font-size: 52px;
  line-height: 1.05;
  letter-spacing: -0.015em;
  margin: 0 0 14px;
  color: #fff;
  text-shadow: 0 1px 30px rgba(0, 0, 0, 0.35);
}

.login-stage-headline span {
  display: block;
}

.login-stage-headline em {
  font-style: italic;
  color: var(--tfp-login-teal);
}

.login-stage-bottom .login-stage-text {
  font-family: 'Geist', sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.85);
  max-width: 540px;
  margin: 0;
  text-shadow: 0 1px 20px rgba(0, 0, 0, 0.35);
}

/* Slim coral/teal accent strip — echoes the logo bookmark */
.login-accent-strip {
  position: absolute;
  top: 0;
  left: 32px;
  display: flex;
  gap: 4px;
  z-index: 3;
}

.login-accent-strip span {
  width: 4px;
  height: 64px;
  border-bottom-left-radius: 2px;
  border-bottom-right-radius: 2px;
}

.login-accent-strip span:first-child {
  background: var(--tfp-login-coral);
}

.login-accent-strip span:last-child {
  background: var(--tfp-login-teal);
}

/* ---------- Visually-hidden utility (a11y) ---------- */
.login-shell .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .login-shell {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }

  .login-stage {
    min-height: 320px;
    order: -1;
  }

  .login-title {
    font-size: 36px;
  }

  .login-stage-headline {
    font-size: 40px;
    margin-bottom: 12px;
  }

  .login-panel-head,
  .login-panel-body,
  .login-panel-foot {
    padding-left: 24px;
    padding-right: 24px;
  }
}

@media (max-width: 560px) {
  .login-panel-foot {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .login-stage-headline {
    font-size: 32px;
    line-height: 1.08;
  }
}

/* Comfortable touch targets on touch devices */
@media (pointer: coarse) {
  .login-field-input input {
    height: 52px;
    padding-right: 52px;
  }

  .login-field-input .login-icon-btn {
    width: 44px;
    height: 44px;
    right: 4px;
    border-radius: 10px;
  }

  .login-check input[type="checkbox"] {
    width: 22px;
    height: 22px;
  }
}
/* ============================================================
   Teach for Poland — Portal Dashboard (Survey Results)
   Paper Single Survey design — portal-* component prefix
   ============================================================ */

/* ---------- Layout Shell ---------- */
.portal-shell {
  display: flex;
  min-height: 100vh;
  font-family: var(--tfp-font-ui);
  background: var(--tfp-bg-warm);
  color: var(--tfp-ink);
}

/* Mobile top bar + drawer affordances (hidden on desktop) */
.portal-mobile-topbar {
  display: none;
}

.portal-mobile-brand {
  padding: 0;
  border: 0;
}

.portal-mobile-brand .portal-brand-icon {
  width: 32px;
  height: 32px;
}

.portal-mobile-nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--tfp-radius-sm);
  border: 1px solid var(--tfp-border);
  background: var(--tfp-surface);
  color: var(--tfp-ink-2);
  cursor: pointer;
}

.portal-sidebar-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-left: auto;
  border-radius: var(--tfp-radius-sm);
  border: 1px solid var(--tfp-border);
  background: var(--tfp-surface);
  color: var(--tfp-ink-2);
  cursor: pointer;
}

.portal-nav-backdrop {
  display: none;
}

/* ---------- Sidebar ---------- */
.portal-sidebar {
  width: var(--tfp-sidebar-width);
  min-width: var(--tfp-sidebar-width);
  background: var(--tfp-surface);
  border-right: 1px solid var(--tfp-border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}

.portal-sidebar-top {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--tfp-surface);
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--tfp-border);
  flex-shrink: 0;
}

.portal-brand-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.portal-brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.portal-brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.portal-brand-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  color: var(--tfp-ink);
}

.portal-brand-sub {
  font-size: 10px;
  font-weight: 600;
  color: var(--tfp-ink-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Navigation */
.portal-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.portal-nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--tfp-ink-3);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0 20px 6px;
}

.portal-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 2px 14px;
  border-radius: var(--tfp-radius-sm);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--tfp-ink-3);
  transition: background 0.15s ease, color 0.15s ease;
  border: 1px solid transparent;
}

.portal-nav-link:hover {
  background: var(--tfp-surface-muted);
  color: var(--tfp-ink-2);
}

.portal-nav-link.active {
  background: var(--tfp-teal-soft);
  border-color: var(--tfp-teal-soft-border);
  color: var(--tfp-teal);
  font-weight: 600;
}

.portal-nav-link.is-disabled {
  color: var(--tfp-ink-3);
  cursor: default;
  pointer-events: none;
}

.portal-nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
  flex-shrink: 0;
}

.portal-nav-link.active .portal-nav-dot {
  background: var(--tfp-teal);
  box-shadow: 0 0 0 3px rgba(31, 138, 138, 0.12);
}

/* Sidebar Footer */
.portal-sidebar-footer {
  border-top: 1px solid var(--tfp-border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--tfp-surface);
  flex-shrink: 0;
}

.portal-user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--tfp-radius-md);
  border: 1px solid var(--tfp-border);
  background: var(--tfp-surface);
}

.portal-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--tfp-teal);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.portal-user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.portal-user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--tfp-ink);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-user-role {
  font-size: 12px;
  font-weight: 500;
  color: var(--tfp-ink-3);
}

.portal-locale-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.portal-locale-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--tfp-ink-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0 2px;
}

.portal-locale-form {
  margin: 0;
}

.portal-locale-select-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--tfp-radius-sm);
  border: 1px solid var(--tfp-border);
  background: var(--tfp-surface);
  overflow: hidden;
}

.portal-locale-select-wrap .portal-icon {
  flex-shrink: 0;
  color: var(--tfp-ink-3);
}

.portal-locale-select-wrap .portal-icon:last-of-type {
  pointer-events: none;
}

.portal-locale-select {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--tfp-ink);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  min-width: 0;
}

.portal-locale-select:focus {
  outline: none;
}

.portal-logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  width: 100%;
  border-radius: var(--tfp-radius-sm);
  border: 1px solid var(--tfp-border);
  background: var(--tfp-surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--tfp-ink-2);
  cursor: pointer;
  transition: background 0.15s ease;
  text-decoration: none;
}

.portal-logout-btn .portal-icon {
  flex-shrink: 0;
}

.portal-logout-btn:hover {
  background: var(--tfp-surface-muted);
}

.portal-sidebar-footer .button_to {
  margin: 0;
  width: 100%;
}

.portal-sidebar-footer .button_to button {
  width: 100%;
}

/* ---------- Main Content ---------- */
.portal-main {
  flex: 1;
  min-width: 0;
  padding: 32px 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Page Header */
.portal-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 24px;
}

.portal-page-header-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.portal-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.portal-eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tfp-teal-light);
  flex-shrink: 0;
}

.portal-eyebrow-text {
  font-size: 11px;
  font-weight: 500;
  color: var(--tfp-ink-3);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.portal-page-title {
  font-family: var(--tfp-font-display);
  font-size: 36px;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--tfp-ink);
  margin: 0;
}

.portal-page-title em {
  font-style: italic;
  color: var(--tfp-teal);
}

.portal-page-subtitle {
  font-size: 14px;
  font-weight: 500;
  color: var(--tfp-ink-3);
  margin: 0;
}

/* View mode toggle */
.portal-view-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--tfp-border);
  background: var(--tfp-surface);
  box-shadow: 0 1px 2px rgba(20, 24, 28, 0.04);
  flex-shrink: 0;
  margin-top: 8px;
}

.portal-view-toggle-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--tfp-ink-2);
  white-space: nowrap;
  text-decoration: none;
  transition: color 0.18s cubic-bezier(0.22, 1, 0.36, 1), background 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.portal-view-toggle-item.is-active {
  background: var(--tfp-ink);
  color: #fbfaf6;
}

.portal-view-toggle-item:not(.is-active):not(.is-disabled):hover {
  background: var(--tfp-bg-warm);
  color: var(--tfp-ink);
}

.portal-view-toggle-item.is-disabled {
  color: var(--tfp-ink-3);
  cursor: default;
}

.portal-view-toggle-soon {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--tfp-bg-warm);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tfp-ink-3);
}

/* Filters */
.portal-filters-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.portal-survey-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.portal-filter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--tfp-teal);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.portal-survey-select {
  height: 38px;
  padding: 0 32px 0 14px;
  background: var(--tfp-surface);
  border: 1px solid var(--tfp-teal-light);
  border-radius: var(--tfp-radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--tfp-ink);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' viewBox='0 0 256 256'%3E%3Cpolyline points='208 96 128 176 48 96' fill='none' stroke='%236B7480' stroke-linecap='round' stroke-linejoin='round' stroke-width='12'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  max-width: 280px;
}

.portal-survey-select:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(43, 179, 179, 0.2);
}

.portal-secondary-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.portal-filter-pill {
  height: 38px;
  padding: 0 32px 0 14px;
  background: var(--tfp-surface);
  border: 1px solid var(--tfp-border);
  border-radius: var(--tfp-radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--tfp-ink-2);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' viewBox='0 0 256 256'%3E%3Cpolyline points='208 96 128 176 48 96' fill='none' stroke='%236B7480' stroke-linecap='round' stroke-linejoin='round' stroke-width='12'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.portal-filter-pill:focus {
  outline: none;
  border-color: var(--tfp-teal);
  box-shadow: 0 0 0 2px rgba(31, 138, 138, 0.15);
}

.portal-filter-pill.is-unavailable {
  padding-right: 14px;
  background-color: var(--tfp-surface-muted);
  background-image: none;
  border-style: dashed;
  color: var(--tfp-ink-3);
  cursor: not-allowed;
}

.portal-reset-link {
  height: 38px;
  padding: 0 14px;
  background: var(--tfp-surface);
  border: 1px solid var(--tfp-border);
  border-radius: var(--tfp-radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--tfp-ink-3);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.portal-reset-link .portal-icon {
  flex-shrink: 0;
}

.portal-reset-link:hover {
  background: var(--tfp-surface-muted);
  color: var(--tfp-ink-2);
}

/* Selected Survey Card */
.portal-selected-survey {
  padding: 20px 24px;
  border-radius: var(--tfp-radius-lg);
  border: 1px solid var(--tfp-border);
  background: var(--tfp-surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.portal-selected-survey-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tfp-teal);
}

.portal-selected-survey-name {
  margin: 0;
  font-family: var(--tfp-font-display);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.2;
  color: var(--tfp-ink);
  overflow-wrap: anywhere;
}

.portal-selected-survey-meta {
  font-size: 13px;
  color: var(--tfp-ink-3);
  margin: 0;
}

/* Stats Row */
.portal-stats-row {
  display: flex;
  gap: 20px;
}

.portal-stat-card {
  flex: 1;
  min-width: 0;
  background: var(--tfp-surface);
  border-radius: var(--tfp-radius-lg);
  border: 1px solid var(--tfp-border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.portal-stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--tfp-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.portal-stat-icon .portal-icon {
  flex-shrink: 0;
}

.portal-stat-icon.teal { background: var(--tfp-teal-icon-bg); color: var(--tfp-teal); }
.portal-stat-icon.ink  { background: var(--tfp-ink-icon-bg); color: var(--tfp-ink); }
.portal-stat-icon.coral { background: var(--tfp-coral-icon-bg); color: var(--tfp-coral); }

.portal-stat-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--tfp-ink-3);
}

.portal-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--tfp-ink);
  line-height: 1.2;
}

/* Section Header */
.portal-section-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.portal-section-title {
  font-family: var(--tfp-font-display);
  font-size: 20px;
  font-weight: 400;
  line-height: 1.2;
  color: var(--tfp-ink);
  margin: 0;
}

.portal-section-subtitle {
  font-size: 13px;
  line-height: 1.4;
  color: var(--tfp-ink-3);
  margin: 0;
}

.portal-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--tfp-radius-sm);
  border: 1px solid var(--tfp-border);
  background: var(--tfp-surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--tfp-ink);
  cursor: not-allowed;
  opacity: 0.85;
  flex-shrink: 0;
  white-space: nowrap;
}

.portal-export-btn .portal-icon {
  flex-shrink: 0;
}

/* Chart Grid — 2 columns */
.portal-chart-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.portal-chart-row {
  display: flex;
  gap: 20px;
}

.portal-chart-row > .portal-chart-card:only-child {
  flex: 0 1 calc(50% - 10px);
}

.portal-chart-card {
  flex: 1;
  min-width: 0;
  background: var(--tfp-surface);
  border-radius: var(--tfp-radius-lg);
  border: 1px solid var(--tfp-border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.portal-dim-badge {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  height: 26px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--tfp-teal-icon-bg);
  color: var(--tfp-teal);
}

.portal-chart-question {
  font-size: 15px;
  font-weight: 600;
  color: var(--tfp-ink);
  margin: 0;
  line-height: 1.45;
}

.portal-chart-row-inner {
  display: flex;
  align-items: center;
  gap: 24px;
}

.portal-pie-wrap {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
  position: relative;
}

.portal-pie-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* HTML tooltip for the pie charts, appended to <body> so it isn't clipped by the canvas. */
.portal-chart-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 50;
  width: max-content;
  max-width: min(320px, calc(100vw - 16px));
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--tfp-ink);
  color: var(--tfp-surface);
  font-family: var(--tfp-font-ui);
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 12px 32px -12px rgba(20, 24, 28, 0.45);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 100ms ease, visibility 0s linear 100ms;
}

.portal-chart-tooltip.is-visible {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.portal-chart-tooltip-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.portal-chart-tooltip-swatch {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.portal-chart-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.portal-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.portal-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.portal-legend-label {
  flex: 1;
  min-width: 0;
  color: var(--tfp-ink);
  font-weight: 400;
  overflow-wrap: anywhere;
}

.portal-legend-value {
  font-weight: 600;
  color: var(--tfp-ink);
  white-space: nowrap;
  width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.portal-no-chart-data {
  color: var(--tfp-ink-3);
  font-size: 14px;
  margin: 0;
  padding: 16px 0;
}

/* Icons */
svg.portal-icon {
  display: block;
  flex-shrink: 0;
  overflow: visible;
}

/* Empty State */
.portal-empty-state {
  background: var(--tfp-surface);
  border: 2px dashed var(--tfp-border);
  border-radius: var(--tfp-radius-lg);
  padding: 48px 32px;
  text-align: center;
}

.portal-empty-state p {
  font-size: 15px;
  color: var(--tfp-ink-3);
  margin: 0;
}

/* Survey Empty State */
.portal-survey-empty-state,
.portal-single-empty-state {
  position: relative;
  overflow: hidden;
  background: var(--tfp-surface);
  border: 1px solid var(--tfp-border);
  border-radius: var(--tfp-radius-lg);
  padding: 56px 64px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.portal-survey-empty-main,
.portal-single-empty-main {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
}

.portal-survey-empty-leading,
.portal-single-empty-leading {
  display: flex;
  align-items: flex-start;
  gap: 32px;
  flex: 1;
  min-width: 0;
}

.portal-survey-empty-icon,
.portal-single-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: var(--tfp-teal-icon-bg);
  flex-shrink: 0;
}

.portal-survey-empty-copy,
.portal-single-empty-copy {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  max-width: 560px;
}

.portal-survey-empty-eyebrow,
.portal-single-empty-eyebrow {
  margin: 0;
  font-family: var(--tfp-font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tfp-teal);
}

.portal-survey-empty-title,
.portal-single-empty-title {
  margin: 0;
  font-family: var(--tfp-font-display);
  font-size: 32px;
  font-weight: 400;
  line-height: 1.18;
  letter-spacing: -0.02em;
  color: var(--tfp-ink);
}

.portal-survey-empty-body,
.portal-single-empty-body {
  margin: 0;
  max-width: 480px;
  font-family: var(--tfp-font-ui);
  font-size: 15px;
  line-height: 1.6;
  color: var(--tfp-ink-3);
}

.portal-survey-empty-illustration,
.portal-single-empty-illustration {
  flex-shrink: 0;
  width: 154px;
  height: 162px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.portal-survey-empty-illustration img,
.portal-single-empty-illustration img {
  display: block;
  width: 154px;
  height: auto;
  max-height: 162px;
  object-fit: contain;
  object-position: center bottom;
}

.portal-survey-empty-divider,
.portal-single-empty-divider {
  position: relative;
  z-index: 1;
  height: 1px;
  background: var(--tfp-border);
}

.portal-survey-empty-steps,
.portal-single-empty-steps {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 32px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.portal-survey-empty-step,
.portal-single-empty-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.portal-survey-empty-step-badge,
.portal-single-empty-step-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  flex-shrink: 0;
  font-family: var(--tfp-font-ui);
  font-size: 12px;
  font-weight: 600;
  background: rgba(20, 24, 28, 0.08);
  color: var(--tfp-ink-3);
}

.portal-survey-empty-step--active .portal-survey-empty-step-badge,
.portal-single-empty-step--active .portal-single-empty-step-badge {
  background: var(--tfp-ink);
  color: var(--tfp-surface);
}

.portal-survey-empty-step--complete .portal-survey-empty-step-badge,
.portal-single-empty-step--complete .portal-single-empty-step-badge {
  background: var(--tfp-teal);
  color: var(--tfp-surface);
}

.portal-survey-empty-step-copy,
.portal-single-empty-step-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.portal-survey-empty-step-title,
.portal-single-empty-step-title {
  margin: 0;
  font-family: var(--tfp-font-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--tfp-ink);
}

.portal-survey-empty-step-action,
.portal-single-empty-step-action {
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.portal-survey-empty-step-action:hover,
.portal-survey-empty-step-action:focus-visible,
.portal-single-empty-step-action:hover,
.portal-single-empty-step-action:focus-visible {
  color: var(--tfp-teal);
  outline: none;
}

.portal-survey-empty-step-action:focus-visible,
.portal-single-empty-step-action:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.portal-survey-empty-step-desc,
.portal-single-empty-step-desc {
  margin: 0;
  font-family: var(--tfp-font-ui);
  font-size: 13px;
  line-height: 1.54;
  color: var(--tfp-ink-3);
}

@media (max-width: 900px) {
  .portal-survey-empty-state,
  .portal-single-empty-state {
    padding: 40px 28px;
  }

  .portal-survey-empty-main,
  .portal-single-empty-main {
    flex-direction: column;
    gap: 24px;
  }

  .portal-survey-empty-leading,
  .portal-single-empty-leading {
    flex-direction: column;
    gap: 20px;
  }

  .portal-survey-empty-title,
  .portal-single-empty-title {
    font-size: 28px;
  }

  .portal-survey-empty-illustration,
  .portal-single-empty-illustration {
    align-self: center;
  }

  .portal-survey-empty-steps,
  .portal-single-empty-steps {
    flex-direction: column;
    gap: 20px;
  }
}

/* Staff extra filters */
.portal-staff-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .portal-chart-row {
    flex-direction: column;
  }
}

@media (max-width: 900px) {
  .portal-shell {
    flex-direction: column;
  }

  /* Top bar replaces the always-on sidebar */
  .portal-mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 30;
    padding: 12px 16px;
    background: var(--tfp-surface);
    border-bottom: 1px solid var(--tfp-border);
  }

  /* Sidebar becomes an off-canvas drawer */
  .portal-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    width: min(86vw, 320px);
    min-width: 0;
    height: 100vh;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 24px 60px -28px rgba(20, 24, 28, 0.45);
    will-change: transform;
  }

  .portal-shell.is-nav-open .portal-sidebar {
    transform: translateX(0);
  }

  .portal-sidebar-close {
    display: inline-flex;
  }

  .portal-nav-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(20, 24, 28, 0.45);
  }

  .portal-main {
    padding: 20px 16px;
  }

  .portal-page-title {
    font-size: 28px;
  }

  .portal-stats-row {
    flex-direction: column;
  }

  .portal-chart-row-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
  .portal-sidebar {
    transition: none;
  }
}

/* Comfortable touch targets on touch devices (>= 44px) */
@media (pointer: coarse) {
  .portal-filter-pill,
  .portal-survey-select {
    height: 44px;
  }

  .portal-reset-link,
  .portal-compare-arrow {
    height: 44px;
  }

  .portal-view-toggle-item {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 8px 14px;
  }

  .portal-nav-link {
    padding: 12px 14px;
  }

  .portal-locale-select-wrap {
    height: 44px;
  }

  .portal-logout-btn {
    height: 44px;
  }
}

@media (max-width: 600px) {
  .portal-page-header {
    flex-direction: column;
  }

  .portal-secondary-filters {
    width: 100%;
  }

  .portal-filter-pill,
  .portal-survey-select {
    flex: 1;
    min-width: 0;
    max-width: none;
  }

  .portal-compare-survey-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .portal-compare-arrow {
    justify-content: center;
  }

  .portal-comparison-banner {
    flex-direction: column;
  }

  .portal-comparison-vs {
    padding: 12px 0;
  }

  .portal-compare-pies {
    flex-direction: column;
  }

  .portal-compare-pies-divider {
    width: 100%;
    height: 1px;
  }
}

/* ---------- Compare mode ---------- */
.portal-filter-label-baseline {
  color: var(--tfp-teal);
}

.portal-survey-select-baseline {
  border-color: var(--tfp-teal-light);
}

.portal-compare-survey-filters {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.portal-compare-survey-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.portal-compare-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  flex-shrink: 0;
  color: var(--tfp-ink-3);
}

.portal-comparison-banner {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--tfp-border);
  border-radius: var(--tfp-radius-lg);
  background: var(--tfp-surface);
  overflow: hidden;
}

.portal-comparison-panel {
  flex: 1;
  min-width: 0;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.portal-comparison-panel.baseline {
  background: rgba(43, 179, 179, 0.06);
}

.portal-comparison-panel-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tfp-teal);
}

.portal-comparison-panel-label.muted {
  color: var(--tfp-ink-3);
}

.portal-comparison-panel-name {
  margin: 0;
  font-family: var(--tfp-font-display);
  font-size: 22px;
  font-weight: 400;
  line-height: 1.2;
  color: var(--tfp-ink);
}

.portal-comparison-panel-meta {
  margin: 0;
  font-size: 13px;
  color: var(--tfp-ink-3);
}

.portal-comparison-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  border-left: 1px solid var(--tfp-border);
  border-right: 1px solid var(--tfp-border);
  flex-shrink: 0;
}

.portal-comparison-vs span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--tfp-border);
  background: var(--tfp-bg-warm);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--tfp-ink-3);
}

.portal-compare-stats-row {
  align-items: stretch;
}

.portal-compare-stat-card {
  flex: 1;
}

.portal-compare-stat-questions {
  flex: 0 0 238px;
  max-width: 238px;
}

.portal-compare-stat-values {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.portal-compare-stat-values .portal-stat-value.teal {
  color: var(--tfp-teal);
}

.portal-compare-stat-arrow {
  font-size: 16px;
  color: var(--tfp-ink-3);
  font-weight: 500;
}

.portal-compare-delta-badge {
  display: inline-flex;
  align-self: flex-start;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.portal-compare-delta-badge.positive {
  background: rgba(43, 179, 179, 0.1);
  color: var(--tfp-teal);
}

.portal-compare-delta-badge.negative {
  background: rgba(238, 90, 82, 0.1);
  color: #D9433B;
}

.portal-compare-shift-question {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--tfp-ink-3);
}

.portal-compare-section-header .portal-section-header-top {
  align-items: center;
}

.portal-compare-section-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.portal-compare-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.portal-compare-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--tfp-ink-3);
}

.portal-compare-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.portal-compare-legend-dot.baseline {
  background: var(--tfp-teal);
}

.portal-compare-legend-dot.comparison {
  background: var(--tfp-ink);
}

.portal-export-btn-active {
  cursor: pointer;
  opacity: 1;
  text-decoration: none;
}

.portal-export-btn-active:hover {
  background: var(--tfp-surface-muted);
}

.portal-export-menu {
  position: relative;
  flex-shrink: 0;
}

.portal-export-menu .portal-export-caret {
  color: var(--tfp-ink-3);
  transition: transform 0.15s ease;
}

.portal-export-menu .portal-export-btn[aria-expanded="true"] .portal-export-caret {
  transform: rotate(180deg);
}

.portal-export-menu.is-busy .portal-export-btn {
  cursor: progress;
  opacity: 0.75;
}

.portal-export-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  width: 280px;
  padding: 6px;
  border: 1px solid var(--tfp-border);
  border-radius: var(--tfp-radius-sm);
  background: var(--tfp-surface);
  box-shadow: 0 12px 32px rgba(26, 26, 26, 0.12);
}

.portal-export-dropdown[hidden] {
  display: none;
}

.portal-export-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border-radius: calc(var(--tfp-radius-sm) - 2px);
  color: var(--tfp-ink);
  text-decoration: none;
}

.portal-export-option:hover,
.portal-export-option:focus-visible {
  background: var(--tfp-surface-muted);
  outline: none;
}

.portal-export-option .portal-icon {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--tfp-ink-3);
}

.portal-export-option-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.portal-export-option-text strong {
  font-size: 13px;
  font-weight: 600;
}

.portal-export-option-text small {
  font-size: 12px;
  line-height: 1.35;
  color: var(--tfp-ink-3);
}

.portal-export-error {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  width: 260px;
  margin: 0;
  padding: 8px 10px;
  border-radius: var(--tfp-radius-sm);
  background: #fdecea;
  color: #b3261e;
  font-size: 12px;
  line-height: 1.4;
}

.portal-export-error[hidden] {
  display: none;
}

.portal-compare-chart-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.portal-compare-question-card {
  background: var(--tfp-surface);
  border: 1px solid var(--tfp-border);
  border-radius: var(--tfp-radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.portal-compare-question-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.portal-compare-delta-badge.improved {
  background: rgba(43, 179, 179, 0.1);
  color: var(--tfp-teal);
}

.portal-compare-delta-badge.declined {
  background: rgba(238, 90, 82, 0.1);
  color: #D9433B;
}

.portal-compare-delta-badge.unchanged,
.portal-compare-delta-badge.not-comparable {
  background: var(--tfp-ink-icon-bg);
  color: var(--tfp-ink-2);
}

.portal-compare-question-top .portal-compare-delta-badge {
  margin-top: 0;
  padding: 4px 10px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.portal-compare-group-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--tfp-ink-3);
}

.portal-score-direction-note {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  margin: 0;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--tfp-ink-icon-bg);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--tfp-ink-2);
}

.portal-info-tip-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin: -4px -6px -4px 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--tfp-ink-3);
  cursor: help;
}

.portal-info-tip-button:hover,
.portal-info-tip.is-open .portal-info-tip-button {
  color: var(--tfp-ink);
}

.portal-info-tip-button:focus-visible {
  outline: 2px solid var(--tfp-teal);
  outline-offset: 1px;
}

/* Anchored to the whole note so the panel lines up with the text, not the icon. */
.portal-info-tip-content {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  width: max-content;
  max-width: min(340px, calc(100vw - 80px));
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--tfp-ink);
  color: var(--tfp-surface);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  box-shadow: 0 12px 32px -12px rgba(20, 24, 28, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease, visibility 0s linear 120ms;
}

/* Covers the gap above the panel so moving the pointer onto it keeps it open. */
.portal-info-tip-content::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 0;
  right: 0;
  height: 12px;
}

.portal-info-tip:not(.is-dismissed):hover .portal-info-tip-content,
.portal-info-tip:not(.is-dismissed) .portal-info-tip-button:focus-visible + .portal-info-tip-content,
.portal-info-tip.is-open .portal-info-tip-content {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.portal-mean-score {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--tfp-border);
  background: var(--tfp-bg-warm);
}

.portal-mean-score-label,
.portal-score-cell-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tfp-ink-3);
}

.portal-mean-score-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--tfp-ink);
  font-variant-numeric: tabular-nums;
}

.portal-mean-score-value.is-empty,
.portal-score-cell-value.is-empty {
  font-size: 14px;
  font-weight: 600;
  color: var(--tfp-ink-3);
}

.portal-mean-score-meta,
.portal-score-cell-meta {
  font-size: 12px;
  color: var(--tfp-ink-3);
}

.portal-mean-score .portal-score-direction-note {
  flex-basis: 100%;
  align-self: auto;
  padding: 0;
  background: none;
}

.portal-mean-score.is-ambiguous {
  flex-direction: column;
  align-items: flex-start;
  border-color: rgba(244, 162, 97, 0.45);
  background: rgba(244, 162, 97, 0.08);
}

.portal-mean-score-flag,
.portal-score-cell-flag,
.portal-multi-select-flag {
  align-self: flex-start;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(244, 162, 97, 0.16);
  color: #8A4513;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

.portal-mean-score-flag {
  flex-basis: 100%;
  padding: 0;
  background: none;
}

.portal-score-cell-flag {
  margin-top: 4px;
}

.portal-multi-select {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.portal-multi-select-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--tfp-ink-3);
}

.portal-multi-select-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.portal-multi-select-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.portal-multi-select-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.portal-multi-select-label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  min-width: 0;
  color: var(--tfp-ink);
  overflow-wrap: anywhere;
}

.portal-multi-select-value {
  flex-shrink: 0;
  font-weight: 600;
  color: var(--tfp-ink);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.portal-multi-select-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--tfp-ink-icon-bg);
  overflow: hidden;
}

.portal-multi-select-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--tfp-teal-light);
}

.portal-multi-select-item.is-unrecognized .portal-multi-select-bar span {
  background: var(--tfp-chart-2);
}

.portal-compare-pie-column.comparison .portal-multi-select-item:not(.is-unrecognized) .portal-multi-select-bar span {
  background: var(--tfp-ink-2);
}

.portal-compare-pie-column .portal-multi-select-row {
  font-size: 11px;
}

.portal-multi-select-meta {
  margin: 0;
  font-size: 12px;
  color: var(--tfp-ink-3);
}

.portal-score-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-radius: var(--tfp-radius-md);
  border: 1px solid var(--tfp-border);
  background: var(--tfp-bg-warm);
  overflow: hidden;
}

.portal-score-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 12px 14px;
}

.portal-score-cell + .portal-score-cell {
  border-left: 1px solid var(--tfp-border);
}

.portal-score-cell-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-score-cell.baseline .portal-score-cell-label {
  color: var(--tfp-teal);
}

.portal-score-cell-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--tfp-ink);
  font-variant-numeric: tabular-nums;
}

.portal-score-cell.change {
  background: var(--tfp-surface);
}

.portal-score-cell.change.improved .portal-score-cell-value {
  color: var(--tfp-teal);
}

.portal-score-cell.change.declined .portal-score-cell-value {
  color: #D9433B;
}

@media (max-width: 600px) {
  .portal-score-row {
    grid-template-columns: 1fr;
  }

  .portal-score-cell + .portal-score-cell {
    border-left: 0;
    border-top: 1px solid var(--tfp-border);
  }
}

.portal-compare-pies {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.portal-compare-pies-divider {
  width: 1px;
  background: var(--tfp-border);
  flex-shrink: 0;
}

.portal-compare-pie-column {
  flex: 1;
  min-width: 0;
  padding: 14px;
  border-radius: var(--tfp-radius-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.portal-compare-pie-column.baseline {
  background: rgba(43, 179, 179, 0.05);
  border: 1px solid rgba(43, 179, 179, 0.12);
}

.portal-compare-pie-column.comparison {
  background: var(--tfp-surface);
  border: 1px solid var(--tfp-border);
}

.portal-compare-pie-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tfp-teal);
}

.portal-compare-pie-column.comparison .portal-compare-pie-label {
  color: var(--tfp-ink-3);
}

.portal-compare-pie-inner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.portal-compare-pie-wrap {
  width: 96px;
  height: 96px;
}

.portal-compare-pie-legend .portal-legend-label {
  font-size: 11px;
}

.portal-compare-pie-legend .portal-legend-value {
  font-size: 11px;
}

@media (max-width: 1100px) {
  .portal-compare-stat-questions {
    flex: 1;
    max-width: none;
  }

  .portal-compare-pie-inner {
    flex-direction: column;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* ============================================================
   Correlate view
   ============================================================ */

.portal-correlate-link-row {
  margin: 14px 0 0;
}

.portal-correlate-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid var(--tfp-border);
  border-radius: 999px;
  background: var(--tfp-surface);
  color: var(--tfp-ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.portal-correlate-link:hover,
.portal-correlate-link:focus-visible {
  border-color: var(--tfp-teal-light);
  background: var(--tfp-teal-soft);
  color: var(--tfp-teal);
}

.portal-correlation-form {
  gap: 14px;
}

.portal-correlate-layout {
  --corr-card-shadow: 0 1px 2px rgba(20, 24, 28, 0.04), 0 10px 28px rgba(20, 24, 28, 0.06);
  --corr-hairline: #EEEBE3;
  --corr-teal-wash: #EAF5F4;
  --corr-coral-wash: #FDEDEB;
  --corr-coral-ink: #C8403A;
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  margin-top: 14px;
}

.portal-correlate-results {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
  transition: opacity 0.2s ease;
}

html[aria-busy="true"] .portal-correlate-results {
  opacity: 0.55;
}

.portal-correlation-card {
  background: var(--tfp-surface);
  border-radius: 24px;
  box-shadow: var(--corr-card-shadow);
  padding: 32px 36px;
  animation: portal-correlation-rise 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes portal-correlation-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.portal-correlation-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tfp-ink-3);
}

.portal-correlation-kicker.is-teal {
  color: var(--tfp-teal);
}

.portal-correlation-card-sub {
  display: block;
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--tfp-ink-3);
}

.portal-correlation-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* Picker */

.portal-correlation-picker {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
  overflow: hidden;
  background: var(--tfp-surface);
  border-radius: 24px;
  box-shadow: var(--corr-card-shadow);
}

.portal-correlation-picker-head {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--corr-hairline);
}

.portal-correlation-picker-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.portal-correlation-count {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--tfp-ink-3);
}

.portal-correlation-count.is-full {
  color: var(--corr-coral-ink);
}

.portal-correlation-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.portal-correlation-chips:empty {
  display: none;
}

.portal-correlation-chip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 8px 10px 14px;
  border-radius: 12px;
  background: var(--corr-teal-wash);
  color: #175F5F;
  font-size: 13px;
  line-height: 1.4;
  animation: portal-correlation-rise 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.portal-correlation-chip-code {
  flex: none;
  min-width: 30px;
  padding-top: 1px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--tfp-teal);
}

.portal-correlation-chip-text {
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.portal-correlation-chip-remove {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--tfp-teal);
  cursor: pointer;
  transition: background 0.15s ease;
}

.portal-correlation-chip-remove:hover,
.portal-correlation-chip-remove:focus-visible {
  background: rgba(31, 138, 138, 0.14);
}

.portal-correlation-placeholder {
  margin: 0;
  padding: 12px 14px;
  border: 1px dashed #CFCBC0;
  border-radius: 12px;
  font-size: 13px;
  color: var(--tfp-ink-3);
}

.portal-correlation-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.portal-correlation-survey {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
}

.portal-correlation-survey-select {
  appearance: none;
  max-width: 100%;
  height: 36px;
  padding: 0 34px 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--tfp-ink);
  color: #fbfaf6;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  cursor: pointer;
}

.portal-correlation-survey .portal-icon {
  position: absolute;
  right: 14px;
  color: #fbfaf6;
  pointer-events: none;
}

.portal-correlation-clear {
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--tfp-border);
  border-radius: 999px;
  background: var(--tfp-surface);
  color: var(--tfp-ink-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.portal-correlation-clear:hover {
  background: var(--tfp-bg-warm);
  border-color: #D9D5CA;
}

.portal-correlation-notices {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 24px 0;
}

.portal-correlation-notice {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--corr-coral-ink);
}

.portal-correlation-notice-block {
  padding: 18px 24px;
  color: var(--tfp-ink-3);
}

.portal-correlation-limit {
  padding: 0 24px 16px;
}

.portal-correlation-dimensions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--corr-hairline);
}

.portal-correlation-dimension {
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--tfp-bg-warm);
  color: var(--tfp-ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.portal-correlation-dimension:hover {
  background: #ECE7DC;
}

.portal-correlation-dimension.is-active {
  background: var(--tfp-ink);
  color: #fbfaf6;
}

.portal-correlation-questions {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  margin: 0;
  padding: 8px 12px 16px;
}

.portal-correlation-row[hidden] {
  display: none;
}

.portal-correlation-option {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.portal-correlation-option:hover {
  background: var(--tfp-surface-muted);
}

.portal-correlation-row.is-selected .portal-correlation-option {
  background: #F3F9F8;
}

.portal-correlation-checkbox {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.portal-correlation-check {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border: 1.5px solid #C2BEB3;
  border-radius: 6px;
  background: var(--tfp-surface);
  color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.portal-correlation-check .portal-icon {
  stroke-width: 2.4;
}

.portal-correlation-checkbox:checked + .portal-correlation-check {
  border-color: var(--tfp-teal);
  background: var(--tfp-teal);
  color: #fff;
}

.portal-correlation-checkbox:focus-visible + .portal-correlation-check {
  outline: 2px solid var(--tfp-teal);
  outline-offset: 2px;
}

.portal-correlation-checkbox:disabled ~ .portal-correlation-option-body {
  opacity: 0.45;
}

.portal-correlation-checkbox:disabled + .portal-correlation-check {
  border-color: #DDD9CF;
}

.portal-correlation-option:has(.portal-correlation-checkbox:disabled) {
  cursor: not-allowed;
}

.portal-correlation-option-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.portal-correlation-option-meta {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #9A9FA6;
}

.portal-correlation-option-text {
  font-size: 14px;
  line-height: 1.4;
  color: var(--tfp-ink);
}

/* Empty state */

.portal-correlation-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 56px 40px;
  text-align: center;
}

.portal-correlation-empty-art {
  width: 180px;
  height: auto;
}

.portal-correlation-empty-title {
  margin: 0;
  font-family: var(--tfp-font-display);
  font-size: 34px;
  font-weight: 400;
  line-height: 1.12;
  color: var(--tfp-ink);
  text-wrap: balance;
}

.portal-correlation-empty-title em {
  color: var(--tfp-teal);
}

.portal-correlation-empty-body {
  max-width: 44ch;
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--tfp-ink-3);
}

/* Matrix */

.portal-correlation-scale-key {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--tfp-ink-3);
}

.portal-correlation-scale-ramp {
  width: 140px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--tfp-coral), #F7F4EE 50%, var(--tfp-teal));
}

.portal-correlation-matrix-wrap {
  margin-top: 22px;
  overflow-x: auto;
}

.portal-correlation-matrix {
  width: 100%;
  border-collapse: separate;
  border-spacing: 4px;
  table-layout: fixed;
}

.portal-correlation-matrix-corner {
  width: clamp(150px, 28%, 240px);
}

.portal-correlation-matrix thead th {
  padding: 4px 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  color: var(--tfp-ink-3);
}

.portal-correlation-matrix-row-head {
  padding: 4px 10px 4px 0;
  text-align: left;
  font-weight: 400;
}

.portal-correlation-matrix-code {
  display: inline-block;
  margin-right: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--tfp-ink-3);
}

.portal-correlation-matrix-label {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--tfp-ink-2);
}

.portal-correlation-matrix-cell {
  padding: 0;
  min-width: 56px;
}

.portal-correlation-matrix-cell.is-diagonal {
  height: 52px;
  border-radius: 10px;
  background: #F4F2ED;
  color: #B9B5AA;
  text-align: center;
  font-weight: 700;
}

.portal-correlation-matrix-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border-radius: 10px;
  background: var(--cell-bg, #F4F2ED);
  color: var(--cell-ink, var(--tfp-ink-3));
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color 0.15s ease, transform 0.15s ease;
}

.portal-correlation-matrix-link:hover {
  transform: translateY(-1px);
}

.portal-correlation-matrix-link.is-focused {
  outline-color: var(--tfp-ink);
}

.portal-correlation-matrix-link:focus-visible {
  outline-color: var(--tfp-teal);
}

.portal-correlation-matrix-cell[data-status="suppressed"] .portal-correlation-matrix-link {
  font-size: 12px;
  font-weight: 600;
}

/* Pair */

.portal-correlation-pair-questions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
}

.portal-correlation-pair-label {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.is-a .portal-correlation-pair-label {
  color: var(--tfp-teal);
}

.is-b .portal-correlation-pair-label {
  color: var(--tfp-coral);
}

.portal-correlation-pair-text {
  margin: 8px 0 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--tfp-ink);
  text-wrap: pretty;
}

.portal-correlation-pair-meta {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--tfp-ink-3);
}

.portal-correlation-pair-body {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(300px, 1.1fr);
  gap: 32px;
  align-items: start;
  margin-top: 28px;
}

.portal-correlation-pair-body.is-unavailable {
  grid-template-columns: minmax(0, 1fr);
  max-width: 560px;
}

.portal-correlation-pair-summary {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.portal-correlation-stat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px 26px;
  border-radius: 16px;
  background: var(--tfp-bg-warm);
}

.portal-correlation-r-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 14px;
}

.portal-correlation-r {
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.portal-correlation-r.is-positive {
  color: var(--tfp-teal);
}

.portal-correlation-r.is-negative {
  color: var(--corr-coral-ink);
}

.portal-correlation-badge {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.portal-correlation-badge.is-muted {
  background: rgba(20, 24, 28, 0.06);
  color: var(--tfp-ink-2);
}

.portal-correlation-badge.is-positive {
  background: var(--corr-teal-wash);
  color: #175F5F;
}

.portal-correlation-badge.is-negative {
  background: var(--corr-coral-wash);
  color: var(--corr-coral-ink);
}

.portal-correlation-n {
  margin: 0;
  font-size: 14px;
  color: var(--tfp-ink-2);
}

.portal-correlation-bar {
  position: relative;
  height: 8px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(20, 24, 28, 0.07);
}

.portal-correlation-bar-zero {
  position: absolute;
  top: -3px;
  bottom: -3px;
  left: 50%;
  width: 1px;
  background: #B9B5AA;
}

.portal-correlation-bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 999px;
}

.portal-correlation-bar-fill.is-positive {
  background: var(--tfp-teal);
}

.portal-correlation-bar-fill.is-negative {
  background: var(--tfp-coral);
}

.portal-correlation-bar-scale {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #9A9FA6;
}

.portal-correlation-flag {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 500;
  color: var(--corr-coral-ink);
}

.portal-correlation-flag .portal-icon {
  flex: none;
  margin-top: 2px;
}

.portal-correlation-unavailable-title {
  margin: 4px 0 0;
  font-family: var(--tfp-font-display);
  font-size: 30px;
  line-height: 1.1;
  color: var(--tfp-ink);
}

.portal-correlation-explanation {
  max-width: 62ch;
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--tfp-ink-2);
  text-wrap: pretty;
}

.portal-correlation-caution {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--corr-hairline);
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--tfp-ink-3);
}

/* Bubble plot */

.portal-correlation-bubbles {
  margin: 0;
  min-width: 0;
}

.portal-correlation-plot {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 8px;
  row-gap: 8px;
  margin-top: 14px;
}

.portal-correlation-axis-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.portal-correlation-axis-title.is-y {
  grid-row: 1;
  grid-column: 1;
  align-self: center;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  color: var(--tfp-coral);
}

.portal-correlation-axis-title.is-x {
  grid-row: 2;
  grid-column: 2;
  justify-self: center;
  color: var(--tfp-teal);
}

.portal-correlation-plot-grid {
  grid-row: 1;
  grid-column: 2;
  display: grid;
  grid-template-columns: 22px repeat(var(--plot-columns), minmax(48px, 64px));
  grid-template-rows: repeat(var(--plot-rows), minmax(48px, 60px)) 24px;
  align-items: center;
}

.portal-correlation-tick {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--tfp-ink-3);
  cursor: help;
}

.portal-correlation-tick.is-y {
  justify-self: end;
  padding-right: 8px;
}

.portal-correlation-tick.is-x {
  align-self: start;
  justify-self: center;
  padding-top: 6px;
  min-height: 0;
}

.portal-correlation-tick.is-corner {
  cursor: default;
}

.portal-correlation-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  border-left: 1px solid var(--corr-hairline);
  border-top: 1px solid var(--corr-hairline);
}

.portal-correlation-bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--bubble-size);
  height: var(--bubble-size);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--tfp-ink-2);
  opacity: 0.9;
  cursor: help;
}

.portal-correlation-bubble.is-match {
  background: var(--tfp-teal-light);
}

.portal-correlation-bubble.is-near {
  background: #92D3D3;
}

.portal-correlation-bubble.is-far {
  background: #F6A7A2;
}

.portal-correlation-bubble.is-large {
  color: #fff;
}

.portal-correlation-bubble.is-near.is-large,
.portal-correlation-bubble.is-far.is-large {
  color: var(--tfp-ink);
}

.portal-correlation-legend {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: #9A9FA6;
}

.portal-correlation-legend strong {
  color: var(--tfp-ink-3);
}

/* Details */

.portal-correlation-details {
  padding: 0;
}

.portal-correlation-details-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 36px;
  list-style: none;
  cursor: pointer;
}

.portal-correlation-details-summary::-webkit-details-marker {
  display: none;
}

.portal-correlation-details-summary > span {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 14px;
}

.portal-correlation-details-hint {
  font-size: 13px;
  color: var(--tfp-ink-3);
}

.portal-correlation-details-caret {
  flex: none;
  color: var(--tfp-ink-3);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.portal-correlation-details[open] .portal-correlation-details-caret {
  transform: rotate(180deg);
}

.portal-correlation-details-body {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 4px 36px 32px;
  border-top: 1px solid var(--corr-hairline);
}

.portal-correlation-subhead {
  margin: 24px 0 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--tfp-ink);
}

.portal-correlation-count-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px 24px;
  margin: 14px 0 0;
}

.portal-correlation-count-grid dt {
  font-size: 12px;
  color: var(--tfp-ink-3);
}

.portal-correlation-count-grid dd {
  margin: 4px 0 0;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--tfp-ink);
}

.portal-correlation-footnote,
.portal-correlation-method-notes p {
  max-width: 75ch;
  margin: 12px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--tfp-ink-3);
}

.portal-correlation-table-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.portal-correlation-table-scroll {
  margin-top: 12px;
  overflow-x: auto;
}

.portal-correlation-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.portal-correlation-table th,
.portal-correlation-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--corr-hairline);
  text-align: left;
  vertical-align: top;
}

.portal-correlation-table th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tfp-ink-3);
  white-space: nowrap;
}

.portal-correlation-table th a {
  color: inherit;
  text-decoration: none;
}

.portal-correlation-table th a:hover {
  color: var(--tfp-ink);
}

.portal-correlation-table td.is-numeric {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.portal-correlation-table td.is-positive {
  color: var(--tfp-teal);
  font-weight: 600;
}

.portal-correlation-table td.is-negative {
  color: var(--corr-coral-ink);
  font-weight: 600;
}

.portal-correlation-table-codes {
  display: block;
  font-weight: 700;
  color: var(--tfp-ink);
}

.portal-correlation-table-labels {
  display: block;
  max-width: 60ch;
  margin-top: 2px;
  color: var(--tfp-ink-3);
}

@media (max-width: 1180px) {
  .portal-correlation-pair-body {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .portal-correlate-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .portal-correlation-picker {
    position: static;
    max-height: 70vh;
  }

  .portal-correlation-card {
    padding: 24px 22px;
  }

  .portal-correlation-details {
    padding: 0;
  }

  .portal-correlation-details-summary,
  .portal-correlation-details-body {
    padding-left: 22px;
    padding-right: 22px;
  }

  .portal-correlation-r {
    font-size: 44px;
  }

  .portal-view-toggle {
    flex-wrap: wrap;
    border-radius: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portal-correlation-card,
  .portal-correlation-chip {
    animation: none;
  }

  .portal-correlation-matrix-link:hover {
    transform: none;
  }
}
/* ============================================================
   Powered by Blinq — shared attribution
   ============================================================ */

.tfp-powered-by {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--tfp-ink-3);
  opacity: 0.78;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.tfp-powered-by:hover {
  opacity: 1;
  color: var(--tfp-ink-2);
}

.tfp-powered-by:focus-visible {
  opacity: 1;
  color: var(--tfp-ink);
  outline: 2px solid var(--tfp-teal-soft-border);
  outline-offset: 4px;
  border-radius: 6px;
}

.tfp-powered-by-label {
  font-family: var(--tfp-font-ui);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1;
  white-space: nowrap;
}

.tfp-powered-by-logo {
  display: block;
  height: 24px;
  width: auto;
  opacity: 0.92;
  transition: opacity 0.2s ease;
}

.tfp-powered-by:hover .tfp-powered-by-logo,
.tfp-powered-by:focus-visible .tfp-powered-by-logo {
  opacity: 1;
}

.portal-powered-by {
  margin-top: auto;
  padding-top: 40px;
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

.login-powered-by {
  position: absolute;
  right: 32px;
  bottom: 32px;
  z-index: 5;
}

@media (max-width: 900px) {
  .login-powered-by {
    right: 20px;
    bottom: 20px;
  }

  .portal-powered-by {
    padding-top: 28px;
  }
}
/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *





 */

/* ============================================================
   Teach for Poland — Brand Design Tokens
   Primary Red:   #EA4745
   Primary Navy:  #0F345D
   Accent Teal:   #4CD2D7
   Text Dark:     #222330
   ============================================================ */

:root {
  /* Brand Palette */
  --tfp-red:          #EA4745;
  --tfp-red-dark:     #D03634;
  --tfp-red-light:    #F07F7D;
  --tfp-navy:         #0F345D;
  --tfp-navy-light:   #1A4A7A;
  --tfp-teal:         #4CD2D7;
  --tfp-teal-dark:    #1D898B;
  --tfp-teal-light:   #7BC9CB;

  /* Neutral Palette */
  --tfp-text:         #222330;
  --tfp-text-secondary: #4b5563;
  --tfp-text-muted:   #6b7280;
  --tfp-border:       #e5e7eb;
  --tfp-border-dark:  #d1d5db;
  --tfp-bg:           #f8f9fb;
  --tfp-bg-card:      #ffffff;
  --tfp-bg-subtle:    #f3f4f6;
}

/* Base Application Styles */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--tfp-bg);
  color: var(--tfp-text);
  line-height: 1.5;
}

/* Login Body — no background so the split layout fills the viewport */
body.login-body {
  background-color: var(--tfp-login-bg);
}

/* Portal Body — survey dashboard and future teacher portal pages */
body.portal-body {
  background-color: var(--tfp-bg-warm);
  font-family: var(--tfp-font-ui);
  color: var(--tfp-ink);
  -webkit-font-smoothing: antialiased;
}

body.portal-body .flash {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  max-width: 600px;
  width: 90%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Flash Messages */
.flash {
  max-width: 1400px;
  margin: 1rem auto;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 500;
}

.flash-notice {
  background-color: #ecfdf5;
  color: #065f46;
  border: 1px solid var(--tfp-teal-light);
}

.flash-alert {
  background-color: #fef2f2;
  color: #991b1b;
  border: 1px solid var(--tfp-red-light);
}
