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

:root {
  --pri-blue-900: #1E497E;
  --pri-blue-700: #4B84C0;
  --pri-gray-500: #A6A6A6;
  --pri-orange-500: #F37900;
  --pri-green-500: #74AF4C;
  --pri-white: #ffffff;
  --pri-ink: #233142;
  --pri-ink-soft: #5f6f82;
  --pri-surface: #f4f7fb;
  --pri-surface-strong: #eaf1f8;
  --pri-border: rgba(30, 73, 126, 0.12);
  --pri-shadow: 0 18px 40px rgba(30, 73, 126, 0.10);
}

body {
  font-family: "Open Sans", Calibri, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(75, 132, 192, 0.18), transparent 28%),
    linear-gradient(180deg, #f6f9fc 0%, #eef3f8 100%);
  min-height: 100vh;
  color: var(--pri-ink);
}

/* ── CLIENT BANNER (?clientId=) ── */
.client-banner {
  background: linear-gradient(90deg, var(--pri-orange-500) 0%, #f7963f 100%);
  color: var(--pri-white);
  padding: 14px 24px;
  text-align: center;
}
.client-banner[hidden] {
  display: none !important;
}
.client-banner-inner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 18px;
  max-width: 1200px;
  margin: 0 auto;
}
.client-banner-name {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  word-break: break-word;
}

/* ── HEADER ── */
.site-header {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--pri-blue-900) 0%, #295f9f 55%, var(--pri-blue-700) 100%);
  color: var(--pri-white);
  padding: 24px 32px;
}
.site-header::after {
  content: "PRI";
  position: absolute;
  right: 28px;
  top: 8px;
  font-size: 6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.08);
  pointer-events: none;
}
.site-header-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: var(--pri-white);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand-name {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.74);
}
.site-header h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.site-header .subtitle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.92);
}
.subtitle-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.66);
}
.subtitle-separator { margin: 0 6px; }

/* ── MAIN ── */
main {
  max-width: 1400px;
  margin: 28px auto;
  padding: 0 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--pri-border);
  border-radius: 16px;
  box-shadow: var(--pri-shadow);
  padding: 20px 24px;
  backdrop-filter: blur(6px);
}

/* ── FILTER BAR ── */
.filter-bar { padding: 16px 20px; position: relative; z-index: 2; }
.filter-bar-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--pri-blue-900);
  margin-bottom: 12px;
}
.filter-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
  flex: 1;
}
.filter-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--pri-blue-900);
}
.filter-group select {
  padding: 8px 10px;
  border: 1px solid rgba(30, 73, 126, 0.20);
  border-radius: 10px;
  font-size: 0.875rem;
  color: var(--pri-ink);
  background: rgba(255, 255, 255, 0.98);
}
.filter-group select:focus {
  outline: none;
  border-color: var(--pri-blue-700);
  box-shadow: 0 0 0 3px rgba(75, 132, 192, 0.16);
}

/* ── MULTI-SELECT DROPDOWNS ── */
.ms-wrap {
  position: relative;
}
.ms-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid rgba(30, 73, 126, 0.20);
  border-radius: 10px;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--pri-ink);
  background: rgba(255, 255, 255, 0.98);
  cursor: pointer;
  text-align: left;
  gap: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ms-btn:hover {
  border-color: var(--pri-blue-700);
}
.ms-btn.ms-open,
.ms-btn:focus {
  outline: none;
  border-color: var(--pri-blue-700);
  box-shadow: 0 0 0 3px rgba(75, 132, 192, 0.16);
}
.ms-btn.ms-active {
  border-color: var(--pri-blue-700);
  background: rgba(75, 132, 192, 0.07);
  font-weight: 600;
  color: var(--pri-blue-900);
}
.ms-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ms-arrow {
  font-size: 0.7rem;
  color: var(--pri-blue-700);
  flex-shrink: 0;
  transition: transform 0.15s;
}
.ms-btn.ms-open .ms-arrow {
  transform: rotate(180deg);
}
.ms-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  max-width: 280px;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid rgba(30, 73, 126, 0.18);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(30, 73, 126, 0.14);
  z-index: 200;
  padding: 6px 0;
}
.ms-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 0.875rem;
  color: var(--pri-ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s;
}
.ms-option:hover {
  background: rgba(75, 132, 192, 0.09);
}
.ms-option input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--pri-blue-700);
  cursor: pointer;
  flex-shrink: 0;
}
.btn-clear-filters {
  padding: 8px 14px;
  background: rgba(30, 73, 126, 0.06);
  border: 1px solid rgba(30, 73, 126, 0.14);
  border-radius: 10px;
  font-size: 0.8rem;
  color: var(--pri-blue-900);
  cursor: pointer;
  white-space: nowrap;
  align-self: flex-end;
}
.btn-clear-filters:hover { background: rgba(30, 73, 126, 0.12); color: var(--pri-blue-900); }

/* ── FILE TABLE CARD ── */
.file-card { padding: 0; overflow: hidden; }

.table-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--pri-border);
  background: linear-gradient(180deg, rgba(75, 132, 192, 0.08) 0%, rgba(75, 132, 192, 0.02) 100%);
}
.table-status {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--pri-blue-900);
}
.selection-summary {
  font-size: 0.8rem;
  color: var(--pri-blue-700);
  font-weight: 600;
}

.load-error {
  padding: 20px;
  color: #9a4d00;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(243, 121, 0, 0.08);
}
.retry-link {
  background: none;
  border: 1px solid rgba(243, 121, 0, 0.35);
  border-radius: 999px;
  color: var(--pri-orange-500);
  cursor: pointer;
  padding: 3px 10px;
  font-size: 0.8rem;
  font-weight: 700;
}
.retry-link:hover { background: rgba(243, 121, 0, 0.10); }

.loading-row {
  padding: 32px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--pri-ink-soft);
  font-size: 0.875rem;
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(75, 132, 192, 0.18);
  border-top-color: var(--pri-blue-700);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── FILE TABLE ── */
#file-table-wrap { overflow-x: auto; }

.file-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.file-table thead {
  background: rgba(30, 73, 126, 0.04);
  position: sticky;
  top: 0;
  z-index: 1;
}
.file-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--pri-blue-900);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--pri-border);
  white-space: nowrap;
}
.file-table td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(30, 73, 126, 0.06);
  color: var(--pri-ink);
  vertical-align: middle;
}
.file-table tr:last-child td { border-bottom: none; }
.file-table tbody tr { cursor: pointer; transition: background 0.1s; }
.file-table tbody tr:hover td { background: rgba(75, 132, 192, 0.08); }
.file-table tbody tr.row-selected td { background: rgba(75, 132, 192, 0.14); }

/* Sticky first two columns (checkbox + Name) */
.col-check    { width: 36px; text-align: center; position: sticky; left: 0; z-index: 2; background: var(--pri-white); }
.col-name     { min-width: 180px; max-width: 260px; position: sticky; left: 36px; z-index: 2; background: var(--pri-white); box-shadow: 2px 0 6px -2px rgba(30,73,126,0.14); }

/* Header cells for the sticky columns need a higher z-index and matching header background */
.file-table thead .col-check,
.file-table thead .col-name { background: #eef4f9; z-index: 3; }

/* Sticky cells must use fully opaque backgrounds so scrolled columns
   cannot bleed through. Values are rgba(75,132,192,x) composited on #fff. */
.file-table tbody tr:hover td.col-check,
.file-table tbody tr:hover td.col-name     { background: #f1f5fa; }
.file-table tbody tr.row-selected td.col-check,
.file-table tbody tr.row-selected td.col-name { background: #e6eef6; }
.file-table tbody tr.row-maxed td.col-check,
.file-table tbody tr.row-maxed td.col-name  { background: var(--pri-white); }

.col-vendor   { min-width: 80px; }
.col-doctype  { min-width: 100px; }
.col-category { min-width: 120px; }
.col-project-year { min-width: 90px; text-align: center; }
.col-trueup   { min-width: 60px; text-align: center; color: #6b7280; }
.col-submitted-by { min-width: 120px; }
.col-submitted-on { min-width: 130px; }
.col-last-submitted { min-width: 130px; }
.col-last-submitted-by { min-width: 140px; }
.col-status   { min-width: 130px; }
.col-subcount { min-width: 90px; text-align: center; }

.col-name td, td.col-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

input[type="checkbox"] {
  width: 16px; height: 16px;
  cursor: pointer;
  accent-color: var(--pri-blue-700);
}

.no-results {
  padding: 32px 20px;
  text-align: center;
  color: var(--pri-ink-soft);
  font-size: 0.875rem;
}

/* ── STATUS BADGES ── */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-none        { background: rgba(166, 166, 166, 0.18); color: #5f6a76; }
.status-submitted   { background: rgba(116, 175, 76, 0.16); color: #49752f; }
.status-resubmitted { background: rgba(75, 132, 192, 0.16); color: var(--pri-blue-900); }
.status-failed      { background: rgba(243, 121, 0, 0.14); color: #a35300; }

/* Submission count badges */
.count-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(166, 166, 166, 0.18);
  color: #5f6a76;
}
.count-maxed { background: rgba(243, 121, 0, 0.18); color: #9a4d00; }

/* Rows at max submissions */
.file-table tbody tr.row-maxed td { opacity: 0.55; }
.file-table tbody tr.row-maxed { cursor: default; }
.file-table tbody tr.row-maxed:hover td { background: inherit; }

/* ── SUBMIT BAR ── */
.submit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 24px;
  flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(75, 132, 192, 0.06) 0%, rgba(75, 132, 192, 0.02) 100%);
}
.submit-bar-left { flex: 1; }
.submit-label { font-size: 0.875rem; font-weight: 700; color: var(--pri-blue-900); }
.submit-note  { font-size: 0.75rem; color: var(--pri-ink-soft); margin-top: 3px; }
.submit-error {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(243, 121, 0, 0.24);
  border-radius: 10px;
  background: rgba(243, 121, 0, 0.08);
  color: #9a4d00;
  font-size: 0.8rem;
}

.btn-submit {
  padding: 10px 24px;
  background: linear-gradient(90deg, var(--pri-blue-900) 0%, var(--pri-blue-700) 100%);
  color: var(--pri-white);
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 10px 22px rgba(30, 73, 126, 0.22);
}
.btn-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(30, 73, 126, 0.28);
}
.btn-submit:disabled {
  background: linear-gradient(90deg, rgba(166, 166, 166, 0.75) 0%, rgba(166, 166, 166, 0.58) 100%);
  box-shadow: none;
  cursor: not-allowed;
}
.submit-count { font-weight: 400; margin-left: 4px; }

/* ── CONFIRMATION ── */
.confirm-card {
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
  padding: 48px 40px;
}
.check { font-size: 3rem; margin-bottom: 16px; }
.confirm-card h3 { font-size: 1.2rem; color: var(--pri-blue-900); margin-bottom: 8px; }
.confirm-card > p { font-size: 0.875rem; color: var(--pri-ink-soft); line-height: 1.6; }

.submitted-list {
  margin: 20px 0;
  text-align: left;
  background: rgba(75, 132, 192, 0.06);
  border: 1px solid var(--pri-border);
  border-radius: 12px;
  padding: 12px 16px;
  max-height: 200px;
  overflow-y: auto;
}
.submitted-item {
  font-size: 0.82rem;
  color: var(--pri-ink);
  padding: 4px 0;
  border-bottom: 1px solid rgba(30, 73, 126, 0.08);
}
.submitted-item:last-child { border-bottom: none; }

.submission-id {
  margin-top: 16px;
  font-size: 0.72rem;
  color: var(--pri-gray-500);
  font-family: monospace;
}
.btn-reset {
  margin-top: 24px;
  padding: 9px 24px;
  background: rgba(30, 73, 126, 0.06);
  border: 1px solid rgba(30, 73, 126, 0.14);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--pri-blue-900);
  font-weight: 700;
}
.btn-reset:hover { background: rgba(30, 73, 126, 0.12); }

/* ── GUIDANCE PANEL ── */
.guidance-panel { padding: 0; overflow: hidden; }

.guidance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--pri-border);
  background: linear-gradient(180deg, rgba(75,132,192,0.08) 0%, rgba(75,132,192,0.02) 100%);
  cursor: pointer;
  user-select: none;
}
.guidance-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--pri-blue-900);
}
.guidance-toggle {
  background: none;
  border: none;
  font-size: 0.72rem;
  color: var(--pri-blue-900);
  cursor: pointer;
  padding: 2px 6px;
  opacity: 0.55;
  transition: transform 0.2s;
}
.guidance-toggle[aria-expanded="false"] { transform: rotate(180deg); }

.guidance-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.guidance-body.is-collapsed { display: none; }

.guidance-intro {
  font-size: 0.875rem;
  color: var(--pri-ink);
  line-height: 1.65;
}
.guidance-sub {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--pri-ink-soft);
}

.guidance-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}
.guidance-field-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 16px;
  align-items: baseline;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(75,132,192,0.04);
  border: 1px solid rgba(30,73,126,0.07);
}
.guidance-fields dt {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--pri-blue-900);
  white-space: nowrap;
}
.guidance-fields dd {
  font-size: 0.82rem;
  color: var(--pri-ink);
  line-height: 1.55;
  margin: 0;
}

.guidance-limit {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: rgba(243,121,0,0.06);
  border: 1px solid rgba(243,121,0,0.20);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: #7a3d00;
  line-height: 1.55;
}
.guidance-limit-icon {
  flex-shrink: 0;
  font-size: 0.95rem;
  color: var(--pri-orange-500);
  margin-top: 1px;
}

.guidance-reminder {
  font-size: 0.8rem;
  color: var(--pri-ink-soft);
  line-height: 1.65;
  padding: 10px 14px;
  border-left: 3px solid var(--pri-blue-700);
  background: rgba(75,132,192,0.05);
  border-radius: 0 8px 8px 0;
}
.guidance-reminder strong { color: var(--pri-blue-900); }

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .site-header { padding: 22px 20px; }
  .site-header-inner { align-items: flex-start; }
  .brand-lockup { align-items: flex-start; }
  .brand-mark {
    width: 50px;
    height: 50px;
    font-size: 1.15rem;
  }
  .site-header h1 { font-size: 1.15rem; }
  .site-header .subtitle {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .filter-row { flex-direction: column; }
  .filter-group { min-width: 100%; }
  .ms-menu { max-width: 100%; }
  .submit-bar { flex-direction: column; align-items: flex-start; }
  .btn-submit { width: 100%; }
  .guidance-field-row { grid-template-columns: 1fr; gap: 3px; }
  .guidance-fields dt::after { content: ":"; }
}

/* ── LAUNCH ERROR OVERLAY ── */
.launch-error-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at top left, rgba(75, 132, 192, 0.18), transparent 28%),
    linear-gradient(180deg, #f6f9fc 0%, #eef3f8 100%);
  min-height: 100vh;
}

.launch-error-card {
  background: var(--pri-white);
  border-radius: 16px;
  box-shadow: var(--pri-shadow);
  max-width: 480px;
  width: 90%;
  padding: 48px 40px;
  text-align: center;
}

.launch-error-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.launch-error-card h2 {
  color: var(--pri-blue-900);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.launch-error-card p {
  color: var(--pri-ink-soft);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ── ENVIRONMENT BADGE ── */
.library-name-tag {
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

/* ── BACK TO SITE LINK ── */
.back-to-site {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  margin-left: auto;
  padding: 4px 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.back-to-site:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--pri-white);
}
