/* ============================================
   Banff Forum — Admissions Review
   Design system inherited from Banff Forum project
   ============================================ */

:root {
  --primary: #90B058;
  --primary-dark: #7a9847;
  --primary-light: #a8c476;
  --primary-bg: #f0f5e8;
  --danger: #d4183d;
  --warning: #FDB913;
  --warning-bg: #fef3cd;
  --purple: #8B5CF6;
  --purple-bg: #f3eefe;
  --teal: #26A69A;
  --teal-bg: #e6f7f5;
  --orange: #E65100;
  --orange-bg: #fff3e0;
  --blue: #2563eb;
  --blue-bg: #eff6ff;

  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-display: 'DM Serif Display', Georgia, serif;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --app-header-height: 64px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
  min-height: 100vh;
}

body.review-page {
  padding-bottom: 112px;
}

body.loading-active {
  overflow: hidden;
}

.notion-loading {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(249, 250, 251, 0.94);
  backdrop-filter: blur(8px);
}

.notion-loading[hidden] {
  display: none;
}

.notion-loading-panel {
  width: min(420px, 100%);
  padding: 30px;
  text-align: center;
}

.notion-loading-logo {
  width: 300px;
  height: auto;
  margin: -10px 0 20px;
  clip-path: inset(15% 15% 12% 15%);
}

.notion-loading-title {
  display: block;
  font-family: var(--font-serif);
  font-size: 30px;
  line-height: 1.05;
  color: var(--gray-900);
}

.notion-loading-text {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-600);
}

.notion-loading-track {
  position: relative;
  height: 8px;
  margin-top: 22px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--gray-100);
}

.notion-loading-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--warning));
  animation: notion-loading-slide 1.25s ease-in-out infinite;
}

@keyframes notion-loading-slide {
  0% { transform: translateX(-105%); }
  55% { transform: translateX(75%); }
  100% { transform: translateX(245%); }
}

/* ---- Header ---- */
.header {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 2000;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  flex-shrink: 0;
}

.logo {
  height: 36px;
  width: auto;
  flex-shrink: 0;
}

.header-divider {
  width: 1px;
  height: 28px;
  background: var(--gray-200);
  flex-shrink: 0;
}

.header-settings-link {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-600);
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-decoration: none;
  transition: color 0.15s ease;
}

.header-settings-link svg {
  color: var(--gray-300);
  transition: color 0.15s ease, transform 0.2s ease;
}

.header-settings-link:hover {
  color: var(--primary);
}

.header-settings-link:hover svg {
  color: var(--primary);
  transform: translateX(2px);
}

.header-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  background: var(--gray-50);
}

.header-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--gray-600);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.header-nav-link:hover {
  color: var(--gray-900);
}

.header-nav-link.active {
  background: #fff;
  color: var(--gray-900);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.10);
}

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

.greeting {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- User Switcher ---- */
.user-switcher {
  position: relative;
  flex-shrink: 0;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-sans);
  border: 2px solid var(--primary-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  line-height: 1;
}

.user-avatar:hover {
  box-shadow: 0 0 0 3px rgba(144, 176, 88, 0.25);
  transform: scale(1.08);
}

.user-avatar:active {
  transform: scale(0.95);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all 0.15s ease;
  z-index: 1000;
}

.user-switcher.open .user-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-dropdown-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-400);
  padding: 12px 14px 8px;
}

.user-dropdown-list {
  padding: 0 6px 6px;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.1s ease;
}

.user-dropdown-item:hover {
  background: var(--gray-50);
}

.user-dropdown-item.active {
  background: var(--primary-bg);
}

.user-dropdown-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}

.user-dropdown-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-dropdown-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  line-height: 1.3;
}

.user-dropdown-check {
  margin-left: auto;
  color: var(--primary);
  flex-shrink: 0;
  opacity: 0;
}

.user-dropdown-item.active .user-dropdown-check {
  opacity: 1;
}

.user-dropdown-meta {
  font-size: 11px;
  color: var(--gray-400);
  line-height: 1.3;
}

.user-dropdown-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(100% - 12px);
  margin: 6px;
  height: 34px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: var(--gray-50);
  color: var(--gray-700);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.user-dropdown-action:hover {
  background: var(--gray-100);
}

.user-dropdown-link {
  background: #fff;
  color: var(--gray-800);
}

/* ---- Login ---- */
.login-page {
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgba(249, 250, 251, 0.92), rgba(249, 250, 251, 0.46)),
    url("assets/background.jpg") center / cover no-repeat fixed;
}

.login-shell {
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4dvh, 24px);
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(10px);
  padding: 32px;
}

.login-logo {
  width: 98px;
  height: auto;
  margin-bottom: 28px;
}

.login-panel h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 36px;
  line-height: 1;
  color: var(--gray-900);
}

.login-panel p {
  margin: 0 0 24px;
  color: var(--gray-500);
  font-size: 14px;
  line-height: 1.5;
}

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

.login-form label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-form input {
  height: 44px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 0 12px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
}

.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(144, 176, 88, 0.15);
}

.login-form button {
  height: 44px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.login-form button:disabled {
  opacity: 0.7;
  cursor: default;
}

.login-error {
  min-height: 18px;
  font-size: 12px;
  font-weight: 700;
  color: #EF4444;
}

/* ---- Profile ---- */
.profile-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 24px;
}

.profile-panel {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  background: #fff;
  box-shadow: var(--shadow-sm);
  padding: 28px;
}

.profile-heading {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--gray-100);
}

.profile-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 800;
  flex-shrink: 0;
}

.profile-heading h1 {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1;
}

.profile-heading p {
  margin: 0;
  color: var(--gray-500);
  font-size: 14px;
  font-weight: 600;
}

.profile-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.profile-form h2 {
  margin: 0;
  color: var(--gray-900);
  font-size: 18px;
}

.profile-form label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.profile-form input {
  height: 44px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 0 12px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
}

.profile-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(144, 176, 88, 0.15);
}

.profile-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}

.profile-status {
  min-height: 18px;
  color: var(--gray-500);
  font-size: 12px;
  font-weight: 800;
}

.profile-status[data-state="success"] {
  color: var(--primary-dark);
}

.profile-status[data-state="error"] {
  color: #EF4444;
}

.profile-form button {
  height: 42px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  padding: 0 16px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.profile-form button:disabled {
  opacity: 0.7;
  cursor: default;
}

/* ---- Progress ---- */
.progress-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 32px 0;
}

.review-source-scope {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 10px;
}

.source-tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
}

.source-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--gray-500);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.source-tab:hover {
  background: var(--gray-50);
  color: var(--gray-700);
}

.source-tab.active {
  background: #eef5e6;
  border-color: #d7e7c2;
  color: var(--primary-dark);
}

.source-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.source-tab:hover .source-tab-count {
  background: #fff;
  color: var(--gray-700);
}

.source-tab.active .source-tab-count {
  background: #fff;
  color: var(--primary-dark);
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.progress-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
}

.progress-percent {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
}

.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  width: 0%;
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Main Layout ---- */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 32px 48px;
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 24px;
  align-items: start;
}

.card-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: calc(var(--app-header-height) + 20px);
  align-self: start;
  max-height: calc(100vh - var(--app-header-height) - 40px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gray-300) transparent;
}

.card-column::-webkit-scrollbar {
  width: 4px;
}

.card-column::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 2px;
}

.essay-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---- Cards ---- */
.card {
  background: #fff;
  border: 1px solid #d9dee7;
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: 0 2px 5px rgba(17, 24, 39, 0.07);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--gray-100);
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: transform 0.2s ease;
  animation: fadeSlideUp 0.3s ease both;
}

.card-badge.returning {
  background: #edf5df;
  color: #55752f;
}

.card-badge.new {
  background: #eaf1ff;
  color: #2457c5;
}

.card-badge.abj {
  background: #f3e8ff;
  color: #7e22ce;
}

.card-badge.other {
  background: var(--gray-100);
  color: var(--gray-700);
}

.card-badge.veto {
  background: #111827;
  color: #fff;
}

.card-date {
  font-size: 13px;
  color: var(--gray-400);
}

/* ---- Identity Card ---- */
.identity-top {
  margin-bottom: 20px;
}

.applicant-name {
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--gray-900);
  line-height: 1.2;
  margin-bottom: 2px;
}

.applicant-role {
  font-size: 14px;
  color: var(--gray-600);
  font-weight: 500;
}

.applicant-company {
  font-size: 14px;
  color: var(--gray-400);
}

/* Tags */
.identity-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.tag {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--gray-100);
  color: var(--gray-600);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.tag:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}

.tag-industry { background: var(--blue-bg); color: var(--blue); }
.tag-language { background: var(--purple-bg); color: var(--purple); }

.political-gauge-row {
  margin: -6px 0 20px;
}

.tag-political.political-gauge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 178px;
  padding: 6px 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--gray-200);
  color: var(--gray-700);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  cursor: help;
}

.political-gauge-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

.political-gauge-icon.left {
  background: #c92a2a;
}

.political-gauge-icon.right {
  background: #2457c5;
}

.political-gauge-body {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 auto;
  min-width: 92px;
}

.political-gauge-track {
  position: relative;
  display: block;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #c92a2a 0%, #f3f4f6 50%, #2457c5 100%);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.political-gauge-marker {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--gray-900);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.28);
  transform: translate(-50%, -50%);
}

.political-gauge-value {
  display: block;
  width: 100%;
  max-width: none;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-700);
  text-align: center;
}

.political-gauge-row .political-gauge {
  width: 100%;
}

/* Details */
.identity-details {
  border-top: 1px solid var(--gray-100);
  padding-top: 16px;
  margin-bottom: 16px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
}

.detail-label {
  font-size: 13px;
  color: var(--gray-400);
  font-weight: 500;
  flex-shrink: 0;
}

.detail-value {
  font-size: 13px;
  color: var(--gray-700);
  text-align: right;
  word-break: break-word;
}

.detail-links {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

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

.detail-link-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #d7e7c2;
  background: #eef5e6;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}

.detail-link-pill:hover {
  background: #e4efd6;
  text-decoration: none;
}

/* Section label */
.section-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-400);
  margin-bottom: 12px;
}

/* ---- Full-width Map ---- */
.map-fullwidth {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 32px;
  position: relative;
}

#map {
  height: 280px;
  border-radius: var(--radius-xl);
  z-index: 1;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}

.map-location-label {
  position: absolute;
  top: 32px;
  left: 48px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 96px);
  background: rgba(255, 255, 255, 0.94);
  padding: 6px 14px 6px 8px;
  border: 1px solid rgba(209, 213, 219, 0.9);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  color: var(--gray-800);
  box-shadow: var(--shadow-md);
  z-index: 10;
  pointer-events: none;
}

.map-location-flag-img {
  width: 32px;
  height: 22px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid rgba(17, 24, 39, 0.14);
  background: #fff;
  flex-shrink: 0;
}

/* ---- Policy Tags ---- */
.policy-section {
  margin-bottom: 12px;
}

.policy-section:last-child {
  margin-bottom: 0;
}

.policy-sublabel {
  font-size: 12px;
  color: var(--gray-400);
  display: block;
  margin-bottom: 6px;
}

.policy-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.policy-tag {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--primary);
  color: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.policy-tag:hover {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 2px 6px rgba(144, 176, 88, 0.3);
}

/* ---- Engagement ---- */
.engagement-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.engagement-item {
  font-size: 13px;
  color: var(--gray-600);
  padding: 6px 12px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease, padding-left 0.15s ease;
}

.engagement-item:hover {
  background: var(--gray-100);
  padding-left: 16px;
}

.engagement-item::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

/* ---- Essay Cards ---- */
.essay-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.essay-card .section-label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
  user-select: none;
}

.translation-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.translation-note {
  color: var(--gray-400);
  font-size: 11px;
  font-weight: 700;
}

.translation-toggle {
  height: 28px;
  padding: 0 10px;
  border: 1px solid #d7e7c2;
  border-radius: 999px;
  background: #eef5e6;
  color: var(--primary-dark);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.translation-toggle:hover {
  background: #e4efd6;
}

.essay-card .section-label::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.essay-card.collapsed .section-label::after {
  transform: rotate(-90deg);
}

.section-score-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  margin-left: auto;
  display: none;
}

.essay-card.collapsed .section-score-badge {
  display: inline-block;
  animation: badgePop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badgePop {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.essay-card .essay-text {
  font-size: 14px;
  line-height: 1.75;
  color: var(--gray-700);
  white-space: pre-line;
  transition: max-height 0.3s ease, opacity 0.2s ease, margin 0.3s ease;
  overflow: hidden;
}

.essay-card.collapsed .essay-text {
  max-height: 0;
  opacity: 0;
  margin: 0;
}

.essay-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-100);
  transition: max-height 0.3s ease, opacity 0.2s ease, margin 0.3s ease, padding 0.3s ease;
  overflow: hidden;
}

.essay-card.collapsed .essay-footer {
  max-height: 0;
  opacity: 0;
  margin: 0;
  padding: 0;
  border-top-color: transparent;
}

.essay-score-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-400);
}

.essay-score-picker {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.score-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 2px solid var(--gray-200);
  background: #fff;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-400);
  cursor: pointer;
  transition: all 0.15s ease, transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.score-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
  transform: translateY(-1px);
}

.score-btn:disabled,
.score-btn:disabled:hover {
  cursor: not-allowed;
  border-color: var(--gray-200);
  background: var(--gray-50);
  color: var(--gray-400);
  transform: none;
}

.score-btn:active {
  transform: scale(0.92);
}

.score-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  animation: scorePop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.score-btn:disabled.active {
  border-color: var(--primary-light);
  background: var(--primary-bg);
  color: var(--primary-dark);
  animation: none;
}

@keyframes scorePop {
  0% { transform: scale(0.85); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* ---- Top bar breakdown ---- */
.scoring-bar-breakdown {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.breakdown-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.breakdown-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.breakdown-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-300);
  line-height: 1;
}

.breakdown-val.has-val {
  color: var(--primary);
  animation: valPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes valPop {
  0% { transform: scale(0.8); opacity: 0.5; }
  100% { transform: scale(1); opacity: 1; }
}

.breakdown-plus,
.breakdown-eq {
  font-size: 16px;
  font-weight: 500;
  color: var(--gray-300);
  margin-top: 12px;
}

/* ---- Automation Scores ---- */
.auto-scores-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.auto-score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  background: var(--gray-50);
  border-radius: var(--radius-md);
  transition: transform 0.15s ease, background 0.15s ease;
}

.auto-score-item:hover {
  transform: translateY(-2px);
  background: var(--gray-100);
}

.auto-score-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--gray-400);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.2;
}

.auto-score-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-800);
}

.auto-score-value.has-score {
  color: var(--primary);
}

.auto-scores-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--primary-bg);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-dark);
}

.auto-total-value {
  font-size: 22px;
  font-weight: 700;
}

/* ---- Fixed Review Toolbar ---- */
.scoring-bar {
  background: #fff;
  border-top: 2px solid var(--primary);
  box-shadow: 0 -14px 36px rgba(15, 23, 42, 0.14);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1500;
}

.scoring-bar.scored {
  border-top-color: var(--gray-200);
}

.scoring-bar.read-only {
  border-top-color: var(--gray-200);
  background: var(--gray-50);
}

.scoring-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.scoring-bar-left {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.scoring-bar-center {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}


.scoring-bar-value {
  display: flex;
  align-items: baseline;
  gap: 2px;
  flex-shrink: 0;
}

.score-value {
  font-family: var(--font-display);
  font-size: 44px;
  color: var(--gray-900);
  line-height: 1;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.score-value.bump {
  transform: scale(1.12);
}

.score-max {
  font-size: 16px;
  color: var(--gray-400);
  font-weight: 500;
}

.scoring-bar-right {
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-shrink: 0;
}

.score-notes-inline {
  width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--gray-700);
  resize: none;
  background: var(--gray-50);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.score-notes-inline:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(144, 176, 88, 0.15);
}

.score-notes-inline:read-only {
  cursor: default;
  background: var(--gray-100);
  color: var(--gray-500);
}

.scoring-bar-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scoring-bar-actions .btn {
  padding: 8px 20px;
  font-size: 13px;
  justify-content: center;
  flex: 1;
}

/* ---- Buttons ---- */
.btn {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  box-shadow: none;
}

.btn:disabled:hover {
  box-shadow: none;
}

.btn-submit {
  flex: 1;
  background: var(--primary);
  color: #fff;
  justify-content: center;
}

.btn-submit:hover {
  background: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(144, 176, 88, 0.3);
}

.btn-submit.is-saving {
  background: #6f873f;
}

.btn-skip {
  background: var(--gray-100);
  color: var(--gray-500);
}

.btn-skip:hover {
  background: var(--gray-200);
  color: var(--gray-600);
}

.btn-nav {
  background: #fff;
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
  padding: 10px 24px;
}

.btn-nav:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--gray-300);
  transform: translateY(-1px);
}

.btn-nav:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}


/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--gray-900);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 200;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ---- Review Completion Confetti ---- */
.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 4500;
  pointer-events: none;
  overflow: hidden;
  contain: layout paint;
}

.confetti-piece {
  position: absolute;
  top: var(--start-y);
  left: var(--left);
  width: var(--width);
  height: var(--height);
  border-radius: 3px;
  background: var(--color);
  opacity: 0;
  transform: translate3d(0, var(--start-y), 0) rotate(0deg) scale(0.86);
  transform-origin: center;
  animation: reviewConfettiFall var(--duration) cubic-bezier(0.18, 0.68, 0.2, 1) var(--delay) forwards;
  box-shadow: 0 2px 4px rgba(17, 24, 39, 0.08);
  will-change: transform, opacity;
}

.confetti-piece.round {
  border-radius: 999px;
}

@keyframes reviewConfettiFall {
  0% {
    opacity: 0;
    transform: translate3d(0, var(--start-y), 0) rotate(0deg) scale(0.86);
  }
  12% {
    opacity: 1;
    transform: translate3d(calc(var(--sway) * -0.2), 12vh, 0) rotate(calc(var(--spin) * 0.16)) scale(1);
  }
  48% {
    opacity: 0.95;
    transform: translate3d(var(--sway), 48vh, 0) rotate(calc(var(--spin) * 0.5)) scale(0.98);
  }
  78% {
    opacity: 0.85;
    transform: translate3d(calc(var(--drift) * 0.72), 82vh, 0) rotate(calc(var(--spin) * 0.78)) scale(0.94);
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--drift), 108vh, 0) rotate(var(--spin)) scale(0.86);
  }
}

@media (max-width: 640px) {
  .confetti-layer.mobile .confetti-piece {
    top: auto;
    bottom: 86px;
    animation-name: reviewConfettiBurst;
    animation-timing-function: cubic-bezier(0.17, 0.84, 0.27, 1);
    transform: translate3d(0, 0, 0) rotate(0deg) scale(0.55);
  }

  .confetti-piece {
    border-radius: 2px;
    box-shadow: none;
  }

  .confetti-piece.round {
    border-radius: 999px;
  }
}

@keyframes reviewConfettiBurst {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(0.45);
  }
  10% {
    opacity: 1;
    transform: translate3d(calc(var(--drift) * 0.12), calc(var(--burst-y) * -0.42), 0) rotate(calc(var(--spin) * 0.16)) scale(1);
  }
  42% {
    opacity: 0.98;
    transform: translate3d(calc(var(--drift) * 0.72), calc(var(--burst-y) * -1), 0) rotate(calc(var(--spin) * 0.55)) scale(0.96);
  }
  72% {
    opacity: 0.72;
    transform: translate3d(var(--drift), calc((var(--burst-y) * -0.68) + var(--settle-y)), 0) rotate(calc(var(--spin) * 0.82)) scale(0.86);
  }
  100% {
    opacity: 0;
    transform: translate3d(calc(var(--drift) * 1.08), var(--settle-y), 0) rotate(var(--spin)) scale(0.72);
  }
}

@media (prefers-reduced-motion: reduce) {
  .confetti-layer {
    display: none;
  }
}

/* ---- Floating Section Nav ---- */
.section-nav {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
  padding: 10px 8px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(217, 222, 231, 0.82);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.10);
  backdrop-filter: blur(8px);
}

.section-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border-radius: 999px;
  text-decoration: none;
  color: var(--gray-400);
  font-size: 11px;
  font-weight: 500;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.section-nav-item:hover {
  color: var(--gray-700);
}

.section-nav-item.active {
  color: var(--primary-dark);
}

.section-nav-icon {
  width: 28px;
  height: 28px;
  color: var(--gray-400);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s ease, transform 0.2s ease;
}

.section-nav-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.section-nav-item:hover .section-nav-icon {
  color: var(--gray-700);
  transform: translateX(-1px) scale(1.05);
}

.section-nav-item.active .section-nav-icon {
  color: var(--primary-dark);
  transform: scale(1.12);
}

.section-nav-item.scored .section-nav-icon {
  color: var(--primary);
  animation: dotPulse 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dotPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

.dot-auto {
  background: var(--blue) !important;
}

/* Smooth scroll offset for sticky headers */
.essay-card[id],
.card[id="section-auto"] {
  scroll-margin-top: 160px;
}

/* ---- Responsive ---- */

/* 1440: Section nav dots-only */
@media (max-width: 1440px) {
  .section-nav {
    right: 12px;
  }

  .section-nav-label {
    display: none;
  }

  .section-nav-item {
    padding: 6px;
    justify-content: center;
  }
}

/* 1200: Scoring bar wraps breakdown to second row */
@media (max-width: 1200px) {
  body.review-page {
    padding-bottom: 148px;
  }

  .scoring-bar-inner {
    flex-wrap: wrap;
    gap: 12px;
  }

  .scoring-bar-center {
    order: 3;
    width: 100%;
  }

  .score-notes-inline {
    width: 150px;
  }

  .scoring-bar-breakdown {
    gap: 6px;
  }

  .breakdown-label {
    font-size: 9px;
  }
}

/* 1024: Single column, unstick sidebar */
@media (max-width: 1024px) {
  .main {
    grid-template-columns: 1fr;
    padding: 20px 16px 48px;
  }

  .card-column {
    position: static;
    max-height: none;
    overflow-y: visible;
  }

  .header-inner {
    padding: 0 16px;
  }

  .scoring-bar-inner {
    padding: 12px 16px;
  }

  .progress-container,
  .map-fullwidth {
    padding-left: 16px;
    padding-right: 16px;
  }

  .auto-scores-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .section-nav {
    display: none;
  }

  /* Header: hide subtitle, keep logo + greeting */
  .header-title,
  .header-divider {
    display: none;
  }

  .header-left {
    gap: 10px;
  }

  .header-nav {
    padding: 3px;
  }

  .header-nav-link {
    min-height: 30px;
    padding: 0 10px;
    font-size: 13px;
  }
}

/* 768: Compact scoring bar, shrink header */
@media (max-width: 768px) {
  :root {
    --app-header-height: 56px;
  }

  body.review-page {
    padding-bottom: 142px;
  }

  .header-inner {
    height: 56px;
  }

  .logo {
    height: 30px;
  }

  .greeting {
    font-size: 13px;
  }

  /* Scoring bar: hide breakdown labels, keep values compact */
  .breakdown-label {
    display: none;
  }

  .scoring-bar-breakdown {
    gap: 4px;
  }

  .breakdown-val {
    font-size: 18px;
  }

  .breakdown-plus,
  .breakdown-eq {
    font-size: 13px;
    margin-top: 0;
  }

  .breakdown-item {
    min-width: 0;
  }

  .scoring-bar-center {
    gap: 12px;
  }

  .score-value {
    font-size: 36px;
  }

  .score-notes-inline {
    width: 130px;
    font-size: 12px;
  }

  .scoring-bar-actions .btn {
    padding: 6px 14px;
    font-size: 12px;
  }

  .btn-nav {
    padding: 8px 14px;
    font-size: 13px;
  }

  /* Map */
  #map {
    height: 220px;
  }
}

/* 640: Stack everything vertically */
@media (max-width: 640px) {
  :root {
    --app-header-height: 48px;
  }

  .login-page {
    background-attachment: scroll;
  }

  .login-panel {
    padding: 28px;
  }

  .login-logo {
    width: 88px;
    margin-bottom: 22px;
  }

  body.review-page {
    padding-bottom: 250px;
  }

  .header-inner {
    height: 48px;
    gap: 8px;
  }

  .logo {
    height: 26px;
  }

  .greeting {
    font-size: 12px;
  }

  .applicant-name {
    font-size: 22px;
  }

  .auto-scores-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .score-value {
    font-size: 32px;
  }

  .scoring-bar-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 16px;
  }

  .scoring-bar-left {
    justify-content: center;
    order: -1;
  }

  .scoring-bar-center {
    order: 0;
    flex-direction: row;
    justify-content: center;
    gap: 10px;
  }

  .scoring-bar-right {
    flex-direction: column;
    order: 1;
  }

  .score-notes-inline {
    width: 100%;
    min-height: 44px;
  }

  .scoring-bar-actions {
    flex-direction: row;
  }

  .scoring-bar-actions .btn {
    flex: 1;
  }

  #map {
    height: 180px;
  }

  .map-fullwidth {
    padding: 12px 16px;
  }

  .map-location-label {
    left: 28px;
    top: 24px;
    font-size: 12px;
    max-width: calc(100% - 56px);
    padding: 5px 10px 5px 7px;
  }

  .map-location-flag-img {
    width: 28px;
    height: 19px;
  }

  .progress-container {
    padding-top: 12px;
  }

  .essay-footer {
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
  }

  .score-btn {
    width: 36px;
    height: 36px;
    font-size: 13px;
  }
}
