@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700;800&display=swap");

:root {
  --brand-black: #000000;
  --brand-red: #f20505;
  --brand-red-deep: #b90404;
  --brand-white: #ffffff;
  --gray-900: #323232;
  --gray-700: #646464;
  --gray-300: #d2d2d2;
  --gray-100: #f0f0f0;
  --gray-050: #f7f7f7;
  --ink: var(--brand-black);
  --muted: var(--gray-700);
  --line: var(--gray-300);
  --surface: var(--brand-white);
  --surface-soft: var(--gray-050);
  --accent: var(--brand-red);
  --accent-soft: rgba(242, 5, 5, 0.08);
  --critical: var(--brand-red);
  --high: #d93a3a;
  --medium: #969696;
  --low: #323232;
  --shadow: 0 22px 50px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] {
  --ink: var(--brand-white);
  --muted: #d2d2d2;
  --line: #323232;
  --surface: #111111;
  --surface-soft: #1a1a1a;
  --accent-soft: rgba(242, 5, 5, 0.18);
  --shadow: 0 22px 50px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(242, 5, 5, 0.05) 0%, transparent 28%),
    linear-gradient(180deg, var(--gray-100) 0%, var(--brand-white) 22%, var(--gray-050) 100%);
}

[data-theme="dark"] body,
body.report-body {
  color: var(--ink);
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-shell {
  min-height: 100vh;
  padding: 1.5rem;
}

.upload-shell {
  display: flex;
  flex-direction: column;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--brand-black);
  background: var(--brand-black);
  color: var(--brand-white);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.brand-lockup h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.header-subline {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.brand-logo {
  width: auto;
  height: 2.2rem;
}

/* ── Partner co-branding (partner portal) ───────────────────────────────
   Paired logos with Expedient primary. The partner logo is slightly smaller;
   on the dark site header it sits in a white chip so any logo colour stays
   legible. On light headers (portable export / generated report) the
   cobrand-logo-onlight variant skips the chip. */
.cobrand-divider {
  width: 1px;
  align-self: stretch;
  max-height: 2.4rem;
  background: currentColor;
  opacity: 0.25;
}
.cobrand-logo {
  width: auto;
  height: 1.8rem;
  max-width: 200px;
  display: block;
  object-fit: contain;
}
.cobrand-chip {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border-radius: 8px;
  padding: 0.3rem 0.5rem;
}
.cobrand-logo-onlight {
  height: 2rem;
  /* Neutral plate so a white/transparent partner logo (which our upload hint
     recommends) stays visible on a light header. */
  background: #f6f7f9;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  padding: 0.3rem 0.5rem;
  box-sizing: content-box;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.eyebrow,
.header-subline,
.site-header .header-subline,
.site-header .eyebrow {
  color: var(--gray-300);
}

.header-actions,
.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem;
  justify-content: flex-end;
}

.settings-button-stack {
  display: grid;
  justify-items: start;
  gap: 0.25rem;
  align-content: start;
}

.settings-helper-slot {
  display: flex;
  align-items: flex-start;
  min-height: 1rem;
}

.settings-helper {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
}

.settings-helper[hidden] {
  display: inline;
  visibility: hidden;
}

.settings-helper.pending {
  color: #f20505;
}

.settings-helper.ready {
  color: #128a2e;
}

.action-button,
.ghost-button {
  appearance: none;
  border-radius: 999px;
  padding: 0.72rem 1.1rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.action-button {
  background: var(--accent);
  color: var(--brand-white);
  font-weight: 800;
}

.action-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.ghost-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.site-header .ghost-button {
  background: transparent;
  border-color: var(--gray-700);
  color: var(--brand-white);
}

.site-header .action-button {
  background: var(--brand-red);
  color: var(--brand-white);
}

.action-button:disabled,
.ghost-button:disabled,
.action-button[aria-disabled="true"],
.ghost-button[aria-disabled="true"],
a[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

.ghost-button.compact {
  padding: 0.45rem 0.7rem;
  font-size: 0.88rem;
}

.upload-main {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 2rem 0;
}

.upload-card {
  position: relative;
  width: min(880px, 100%);
  padding: 2rem;
  border-radius: 32px;
  background:
    linear-gradient(145deg, rgba(242, 5, 5, 0.03), transparent 35%),
    var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.upload-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 0 88%, rgba(0, 0, 0, 0.04) 88% 89%, transparent 89% 100%),
    linear-gradient(transparent 0 88%, rgba(0, 0, 0, 0.04) 88% 89%, transparent 89% 100%);
  opacity: 0.25;
  pointer-events: none;
}

.upload-card > * {
  position: relative;
  z-index: 1;
}

.upload-card h2,
.upload-card h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.card-copy p:last-child {
  max-width: 65ch;
  color: var(--muted);
  line-height: 1.65;
}

.drop-zone {
  margin: 1.5rem 0;
  padding: 2.25rem 1.5rem;
  border: 2px dashed rgba(242, 5, 5, 0.35);
  border-radius: 28px;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(242, 5, 5, 0.06), transparent 45%),
    var(--surface-soft);
  cursor: pointer;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background:
    linear-gradient(135deg, rgba(242, 5, 5, 0.12), transparent 45%),
    var(--surface-soft);
  transform: translateY(-2px);
}

.drop-icon {
  display: inline-grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--brand-black);
  color: var(--brand-white);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.drop-title {
  margin: 1rem 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.drop-subtitle,
.file-meta,
.field small,
#status-text,
.mapping-note,
.mapping-sheet-header p {
  color: var(--muted);
}

.file-meta {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
  font-size: 0.95rem;
  text-align: left;
}

.file-pill {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.file-pill button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.settings-panel,
.field-mapping-panel,
.clarification-panel,
.progress-shell,
.summary-card,
.sidebar-card {
  margin-top: 1.25rem;
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
}

.settings-head,
.field-mapping-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.settings-head h3,
.field-mapping-head h3 {
  margin: 0 0 0.25rem;
}

.settings-head p,
.field-mapping-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.field-mapping-panel {
  background:
    linear-gradient(135deg, rgba(242, 5, 5, 0.04), transparent 28%),
    var(--surface);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.45rem;
  font-weight: 600;
}

.field input,
.mapping-table select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 0.8rem 0.9rem;
  background: var(--surface-soft);
  color: var(--ink);
}

.field input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
}

.progress-bar-track {
  overflow: hidden;
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: var(--gray-100);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-black), var(--accent), var(--brand-black));
  background-size: 200% 100%;
  animation: pulse-slide 1.4s linear infinite;
}

@keyframes pulse-slide {
  0% { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

.clarification-tables {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.mapping-sheet {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  background: var(--surface-soft);
}

.mapping-sheet.priority-sheet {
  border-color: rgba(242, 5, 5, 0.18);
  background: linear-gradient(135deg, rgba(242, 5, 5, 0.06), var(--surface-soft));
}

.mapping-sheet-header {
  margin-bottom: 0.75rem;
}

.mapping-sheet-header h4 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}

.mapping-sheet-header p {
  margin: 0;
}

.mapping-table {
  margin: 0;
  table-layout: fixed;
}

.mapping-table th:nth-child(1) { width: 24%; }
.mapping-table th:nth-child(2) { width: 31%; }
.mapping-table th:nth-child(3) { width: 45%; }

.mapping-table.priority-table th:nth-child(1) { width: 24%; }
.mapping-table.priority-table th:nth-child(2) { width: 18%; }
.mapping-table.priority-table th:nth-child(3) { width: 26%; }
.mapping-table.priority-table th:nth-child(4) { width: 32%; }

.mapping-note {
  font-size: 0.88rem;
  line-height: 1.45;
}

.mapping-table select.unmapped-select {
  color: #f20505;
  border-color: #f20505;
  background: rgba(242, 5, 5, 0.08);
  font-weight: 800;
}

.mapping-note.unmapped-note {
  color: #f20505;
  font-weight: 700;
}

.dr-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.dr-filters input,
.dr-filters select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 0.8rem 0.9rem;
  background: var(--surface-soft);
  color: var(--ink);
}

.dr-filters input {
  grid-column: 1 / -1;
}

.dr-table-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.dr-select-all {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
}

.dr-select-all input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.dr-table-wrap {
  overflow: auto;
  margin-top: 1rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.dr-table {
  min-width: 1320px;
  margin: 0;
}

.dr-table td:first-child,
.dr-table th:first-child {
  width: 4.5rem;
}

.dr-table input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip,
.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--ink);
  font-size: 0.9rem;
}

.error-box {
  margin-top: 1.25rem;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  color: var(--brand-white);
  background: linear-gradient(135deg, var(--critical), var(--brand-red-deep));
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.96rem;
}

th,
td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  font-weight: 800;
}

th button,
th.sortable {
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font-weight: 800;
}

code,
pre {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

pre {
  overflow-x: auto;
  padding: 1rem;
  border-radius: 18px;
  background: var(--brand-black);
  color: var(--brand-white);
}

@media (max-width: 960px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .dr-filters {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 840px) {
  .page-shell {
    padding: 1rem;
  }

  .site-header,
  .brand-lockup,
  .header-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .upload-card {
    padding: 1.25rem;
  }

  .mapping-table,
  .mapping-table thead,
  .mapping-table tbody,
  .mapping-table tr,
  .mapping-table th,
  .mapping-table td {
    display: block;
    width: 100%;
  }

  .mapping-table thead {
    display: none;
  }

  .mapping-table tr {
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--line);
  }

  .mapping-table td {
    border-bottom: 0;
    padding: 0.35rem 0;
  }

  .dr-filters {
    grid-template-columns: 1fr;
  }

  .dr-table-wrap {
    border: 0;
    background: transparent;
  }
}

/* ── Modal (shared between upload + report pages) ── */

.report-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.report-modal[hidden] {
  display: none;
}

.report-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
}

.report-modal-card {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  display: grid;
  gap: 1rem;
  padding: 1.4rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.report-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.report-modal-head h2 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.report-modal-copy {
  margin: 0;
  color: var(--muted);
}

.report-modal-form {
  display: grid;
  gap: 1rem;
}

.renewal-input-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: center;
}

fieldset.field {
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset.field legend {
  margin-bottom: 0.45rem;
  font-weight: 700;
}

.renewal-input-group input[type="date"] {
  min-width: 220px;
}

.checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
}

.report-modal-status,
.report-modal-error {
  margin: 0;
  padding: 0.8rem 0.95rem;
  border-radius: 14px;
  font-size: 0.95rem;
}

.report-modal-status {
  border: 1px solid rgba(193, 47, 42, 0.18);
  background: rgba(193, 47, 42, 0.08);
  color: var(--ink);
}

.report-modal-error {
  border: 1px solid rgba(193, 47, 42, 0.3);
  background: rgba(193, 47, 42, 0.12);
  color: var(--brand-red);
}

.report-modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Share Link Modal */
.share-link-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.share-link-input {
  flex: 1;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--surface-soft, #f7f7f7);
  color: var(--fg);
}

.report-modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  color: var(--muted, #646464);
}

/* Upload page nav */
.upload-nav {
  display: flex;
  justify-content: flex-end;
  padding: 0.5rem 0;
}
