/* Pass 1 UI cleanup */
:root {
  --gp-bg: #f5f7fb;
  --gp-surface: #ffffff;
  --gp-border: #e5e7eb;
  --gp-text: #111827;
  --gp-muted: #6b7280;
  --gp-primary: #1d4ed8;
  --gp-primary-soft: #dbeafe;
  --gp-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

html, body { min-height: 100%; }
html { font-size: 15px; }
body.app-body {
  background: var(--gp-bg);
  color: var(--gp-text);
  font-family: "Inter Tight", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 400;
  line-height: 1.5;
}

a { text-decoration: none; }
a:hover { text-decoration: none; }

.site-shell { min-height: calc(100vh - 132px); }
.site-header .navbar,
.site-footer { background: rgba(255,255,255,.92); backdrop-filter: saturate(160%) blur(14px); }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, var(--gp-primary), #3b82f6);
  color: #fff;
  font-size: .8rem;
  font-weight: 600;
}

.dashboard-sidebar-card,
.card { box-shadow: var(--gp-shadow); border-color: var(--gp-border) !important; }
.dashboard-nav-link {
  border-radius: .8rem;
  padding: .65rem .85rem;
  color: var(--gp-text);
  font-weight: 400;
}
.dashboard-nav-link:hover,
.dashboard-nav-link:focus { background: #f3f4f6; color: var(--gp-primary); }
.nav-profile-link {
  color: var(--gp-muted);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: .18rem;
  transition: color .15s ease, text-decoration-color .15s ease;
}
.nav-profile-link:hover,
.nav-profile-link:focus {
  color: var(--gp-primary);
  text-decoration-color: currentColor;
}
.limit-counter-near {
  color: #a16207;
  font-weight: 500;
}
.limit-counter-close {
  color: #b45309;
  font-weight: 600;
}
.limit-counter-over {
  color: #b91c1c;
  font-weight: 600;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.page-title { font-size: clamp(1.5rem, 1.9vw, 2.05rem); font-weight: 600; margin: 0; }
.page-subtitle { color: var(--gp-muted); max-width: 64ch; }

.btn {
  font-weight: 500;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-weight: 600;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
@media (min-width: 992px) {
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1400px) {
  .summary-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
.summary-card {
  background: var(--gp-surface);
  border: 1px solid var(--gp-border);
  border-radius: 1rem;
  padding: 1rem 1.1rem;
  box-shadow: var(--gp-shadow);
  color: var(--gp-text);
}
.summary-card-span-2 {
  grid-column: span 2;
}
.summary-label { color: var(--gp-muted); font-size: .76rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; margin-bottom: .45rem; }
.summary-value { font-size: clamp(1.5rem, 2.1vw, 1.9rem); font-weight: 600; }
.summary-meta { color: var(--gp-muted); font-size: .82rem; margin-top: .35rem; }

.js-sponsor-picker {
  position: relative;
}

.sponsor-picker-shell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  min-height: calc(1.5em + .75rem + 2px);
  padding-top: .375rem;
  padding-bottom: .375rem;
}

.sponsor-picker-input {
  border: 0;
  outline: 0;
  min-width: 8rem;
  flex: 1 1 8rem;
  padding: 0;
  background: transparent;
}

.sponsor-picker-input:focus {
  outline: none;
}

.sponsor-picker-menu {
  position: absolute;
  top: calc(100% + .25rem);
  left: 0;
  right: 0;
  z-index: 20;
  display: none;
  max-height: 14rem;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--gp-border);
  border-radius: .85rem;
  box-shadow: var(--gp-shadow);
  padding: .35rem;
}

.js-sponsor-picker.is-open .sponsor-picker-menu {
  display: grid;
  gap: .2rem;
}

.sponsor-picker-option {
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: .65rem;
  padding: .5rem .65rem;
  text-align: left;
  font-size: .95rem;
}

.sponsor-picker-option:hover,
.sponsor-picker-option:focus {
  background: #f3f4f6;
  outline: none;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: .35rem .7rem;
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  line-height: 1;
  white-space: nowrap;
}
.status-badge-neutral {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #4b5563;
}
.status-badge-primary {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1d4ed8;
}
.status-badge-success {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}
.status-badge-danger {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}
.status-badge-warning {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #b45309;
}

.table > :not(caption) > * > * { padding: .85rem .9rem; }
.table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gp-muted); font-weight: 600; }

.report-matrix-shell {
  overflow-x: auto;
}

.report-matrix-table {
  min-width: max-content;
}

.report-matrix-table thead th {
  background: #f8fafc;
  vertical-align: bottom;
  white-space: nowrap;
}

.report-matrix-table tfoot th {
  background: #eff6ff;
  white-space: nowrap;
}

.report-matrix-row-header {
  font-weight: 600;
  min-width: 14rem;
}

.report-matrix-row-meta {
  min-width: 10rem;
  white-space: nowrap;
}

.report-matrix-first-column {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 2;
}

.report-matrix-table thead .report-matrix-first-column {
  background: #f8fafc;
  z-index: 4;
}

.report-matrix-table tfoot .report-matrix-first-column {
  background: #eff6ff;
  z-index: 3;
}

.report-matrix-total-label {
  font-weight: 600;
}

.site-footer .small { line-height: 1.6; }
.flash-stack { display: grid; gap: .75rem; }
.gp-toast-container {
  z-index: 1400;
  display: grid;
  gap: .75rem;
}
.gp-toast {
  min-width: min(24rem, calc(100vw - 2rem));
  border-radius: 1rem;
  backdrop-filter: blur(10px);
}
.ai-evaluation-overlay-open {
  overflow: hidden;
}
.ai-evaluation-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(3px);
}
.ai-evaluation-overlay[hidden] {
  display: none !important;
}
.ai-evaluation-overlay-card {
  width: min(28rem, 100%);
  border-radius: 1rem;
  background: #fff;
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
}

.field { display: grid; gap: .45rem; margin-bottom: 1rem; }
.field label { font-weight: 500; }
input, select, textarea { max-width: 100%; }

@media (max-width: 991.98px) {
  .page-header { flex-direction: column; }
  .dashboard-sidebar-card { position: static; }
}


/* Pass 2C UI/permission hotfix */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .75rem;
  flex-wrap: wrap;
}
.page-header-actions .btn { white-space: nowrap; }

.program-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: .9rem 1.25rem;
}
@media (min-width: 1200px) {
  .program-meta-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
.program-meta-item {
  background: #fff;
  border: 1px solid var(--gp-border);
  border-radius: 1rem;
  padding: 1rem 1.1rem;
}
.program-meta-label {
  color: var(--gp-muted);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: .35rem;
}
.program-meta-value {
  font-size: 1rem;
  font-weight: 500;
}
.program-section-card .card-body {
  padding: 1.25rem 1.35rem;
}
.program-controls-card .card-body {
  padding: 1rem 1.25rem;
}
.program-detail-table {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.5rem;
}
.program-detail-cell {
  min-width: 0;
}
.program-detail-label {
  color: var(--gp-muted);
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: .3rem;
}
.program-detail-value {
  font-size: .98rem;
  font-weight: 400;
  line-height: 1.4;
}
.question-card {
  cursor: grab;
}
.question-card-dragging {
  opacity: .65;
  cursor: grabbing;
}
.question-card-insert-before {
  box-shadow: inset 0 3px 0 0 var(--gp-primary), var(--gp-shadow);
}
.question-card-insert-after {
  box-shadow: inset 0 -3px 0 0 var(--gp-primary), var(--gp-shadow);
}
.question-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  color: var(--gp-muted);
  font-weight: 600;
  letter-spacing: -.08em;
  user-select: none;
}
@media (min-width: 1400px) {
  .program-detail-table {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.report-sort-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: left;
}
.report-sort-button::after {
  content: "";
  display: inline-block;
  margin-left: .35rem;
  border-left: .28rem solid transparent;
  border-right: .28rem solid transparent;
  border-top: .38rem solid transparent;
  opacity: .35;
  vertical-align: middle;
}
.report-sort-button.is-sorted-asc::after {
  border-top: 0;
  border-bottom: .38rem solid currentColor;
  opacity: .85;
}
.report-sort-button.is-sorted-desc::after {
  border-top-color: currentColor;
  opacity: .85;
}
.compact-table td, .compact-table th { vertical-align: middle; }

.advanced-config summary { cursor: pointer; list-style: none; }
.advanced-config summary::-webkit-details-marker { display: none; }

.filter-dropdown { position: relative; }
.filter-dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  width: 100%;
  min-height: 2.75rem;
  padding: .65rem .85rem;
  border: 1px solid var(--gp-border, #e5e7eb);
  border-radius: .85rem;
  background: #fff;
  text-align: left;
}
.filter-dropdown-toggle .filter-dropdown-label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filter-dropdown-toggle .filter-dropdown-meta {
  color: var(--gp-muted, #6b7280);
  font-size: .875rem;
}
.filter-dropdown-menu {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + .5rem);
  z-index: 1200;
  display: none;
  border: 1px solid var(--gp-border, #e5e7eb);
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
}
.filter-dropdown.is-open .filter-dropdown-menu { display: block; }
.filter-dropdown-search { padding: .85rem; border-bottom: 1px solid var(--gp-border, #e5e7eb); }
.filter-dropdown-search .form-control { border-radius: .75rem; }
.filter-dropdown-options { max-height: 18rem; overflow: auto; padding: .5rem; display: grid; gap: .35rem; }
.filter-dropdown-option { display: flex; align-items: center; gap: .65rem; padding: .65rem .75rem; border-radius: .75rem; cursor: pointer; }
.filter-dropdown-option:hover, .filter-dropdown-option.is-active { background: #f3f4f6; }
.filter-dropdown-option input { margin: 0; }
.filter-dropdown-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem; border-top: 1px solid var(--gp-border, #e5e7eb); }
.filter-dropdown-empty { padding: .75rem .85rem; color: var(--gp-muted); display: none; }

.assign-review-section {
  border: 1px solid var(--gp-border, #e5e7eb);
  border-radius: 1rem;
  padding: 1.25rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.86), rgba(255,255,255,0.98));
}
.assign-preview-card {
  border: 1px solid var(--gp-border, #e5e7eb);
  border-radius: 1rem;
  padding: 1rem 1.1rem;
  background: #f8fafc;
}
.assign-review-bucket {
  border: 1px solid var(--gp-border, #e5e7eb);
  border-radius: 1rem;
  padding: 1rem;
  background: #fff;
  transition: opacity .18s ease, background-color .18s ease;
}
.assign-review-bucket.is-inactive {
  opacity: .72;
  background: #f8fafc;
}

.tabs-card .nav-tabs { border-bottom: 1px solid var(--gp-border); gap: .5rem; }
.tabs-card .nav-link {
  border: 0;
  border-radius: .85rem .85rem 0 0;
  color: var(--gp-muted);
  font-weight: 600;
  padding: .85rem 1rem;
}
.tabs-card .nav-link.active {
  color: var(--gp-primary);
  background: #fff;
  box-shadow: inset 0 -2px 0 var(--gp-primary);
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 1rem;
}
@media (min-width: 1200px) {
  .admin-stats-grid { grid-template-columns: repeat(6, minmax(0,1fr)); }
}
.admin-stats-grid .summary-card { min-height: 100%; }

.hero-application-card { max-width: 56rem; }

@media (max-width: 991.98px) {
  .program-meta-grid { grid-template-columns: 1fr; }
  .page-header-actions { width: 100%; justify-content: flex-start; }
  .program-detail-table { grid-template-columns: 1fr; }
}
