:root {
  color-scheme: light;
  --ink: #17202d;
  --muted: #667085;
  --line: #e4e7ec;
  --surface: #ffffff;
  --canvas: #f5f7fa;
  --brand: #3157d5;
  --brand-dark: #2443a6;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --warning: #b54708;
  --warning-bg: #fffaeb;
  --success: #027a48;
  --success-bg: #ecfdf3;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
a { color: var(--brand); }
.site-header {
  min-height: 68px;
  padding: 0 5vw;
  background: #101828;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand { color: #fff; font-size: 1.15rem; font-weight: 800; text-decoration: none; }
.brand span { font-weight: 500; color: #cbd5e1; }
.site-nav { display: flex; gap: 6px; margin-left: auto; }
.site-nav a {
  border-radius: 7px;
  color: #cbd5e1;
  font-size: .86rem;
  font-weight: 700;
  padding: 7px 10px;
  text-decoration: none;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { background: #344054; color: #fff; }
.environment { color: #98a2b3; font-size: .85rem; }
.container { width: min(1120px, 92vw); margin: 0 auto; padding: 48px 0 72px; }
.hero { max-width: 720px; margin-bottom: 28px; }
h1, h2 { line-height: 1.15; margin: 0; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); letter-spacing: -.04em; }
h2 { font-size: 1.35rem; }
.hero p:not(.eyebrow) { color: var(--muted); font-size: 1.08rem; }
.eyebrow {
  color: var(--brand);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .12em;
  margin: 0 0 8px;
  text-transform: uppercase;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 4px 18px rgb(16 24 40 / 5%);
  padding: 24px;
}
.upload-card h2 { margin-bottom: 20px; }
.form-grid {
  display: grid;
  grid-template-columns: minmax(160px, .8fr) minmax(160px, .7fr) minmax(260px, 1.5fr);
  gap: 18px;
  margin-bottom: 20px;
}
.upload-only-grid { grid-template-columns: minmax(280px, 620px); }
.confirm-grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
label { color: #344054; font-size: .85rem; font-weight: 700; }
input {
  width: 100%;
  margin-top: 7px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 10px 12px;
}
input:focus { border-color: var(--brand); outline: 3px solid rgb(49 87 213 / 14%); }
input[type="file"] { padding: 8px; }
.drop-zone {
  align-items: center;
  background: #f9fafb;
  border: 2px dashed #b8c2d5;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  min-height: 190px;
  justify-content: center;
  padding: 28px;
  text-align: center;
  transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.drop-zone:hover, .drop-zone:focus-within, .drop-zone.is-dragging {
  background: #eff4ff;
  border-color: var(--brand);
}
.drop-zone.is-dragging { transform: scale(1.01); }
.drop-zone.has-file { background: var(--success-bg); border-color: var(--success); }
.drop-zone input {
  height: 1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  width: 1px;
}
.drop-icon {
  align-items: center;
  background: #e5eaff;
  border-radius: 50%;
  color: var(--brand);
  display: inline-flex;
  font-size: 1.4rem;
  height: 42px;
  justify-content: center;
  margin-bottom: 10px;
  width: 42px;
}
.drop-zone > span:not(.drop-icon):not(.selected-file) { color: var(--muted); font-weight: 500; }
.selected-file { color: var(--muted); font-size: .78rem; font-weight: 600; margin-top: 12px; overflow-wrap: anywhere; }
.drop-zone.has-file .selected-file { color: var(--success); }
.field-hint {
  color: var(--success);
  display: block;
  font-size: .75rem;
  font-weight: 600;
  margin-top: 6px;
}
.confirmation-note { color: var(--muted); font-size: .85rem; margin: 0 0 18px; }
.compact-hero h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); }
button, .button-link {
  display: inline-block;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  padding: 11px 18px;
  text-decoration: none;
}
button:hover, .button-link:hover { background: var(--brand-dark); }
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin: 42px 0 14px;
}
.secondary-link, .back-link { font-size: .9rem; font-weight: 700; text-decoration: none; }
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { border-bottom: 1px solid var(--line); padding: 14px 18px; text-align: left; vertical-align: middle; }
th { background: #f9fafb; color: #475467; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfcfd; }
.status {
  display: inline-flex;
  border-radius: 999px;
  background: #eef2f6;
  color: #344054;
  font-size: .72rem;
  font-weight: 800;
  padding: 4px 9px;
  white-space: nowrap;
}
.status-staging { background: var(--success-bg); color: var(--success); }
.status-reject_structure, .status-reject_content { background: var(--danger-bg); color: var(--danger); }
.status-validating, .status-received { background: #eff4ff; color: #3538cd; }
.status-superseded { background: #f2f4f7; color: #667085; }
.status-large { font-size: .8rem; padding: 7px 12px; }
.alert { border: 1px solid; border-radius: 10px; margin: 0 0 20px; padding: 13px 16px; }
.alert-error { background: var(--danger-bg); border-color: #fecdca; color: var(--danger); }
.alert-success { background: var(--success-bg); border-color: #abefc6; color: var(--success); }
.alert-info { background: #eff8ff; border-color: #b2ddff; color: #175cd3; }
.empty-state { color: var(--muted); margin: 0; padding: 24px; text-align: center; }
.back-link { display: inline-block; margin-bottom: 26px; }
.detail-header { display: flex; justify-content: space-between; align-items: start; gap: 24px; }
.detail-header h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); overflow-wrap: anywhere; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 28px 0; }
.metric { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.metric span { color: var(--muted); display: block; font-size: .78rem; margin-bottom: 4px; }
.metric strong { overflow-wrap: anywhere; }
.muted { color: var(--muted); font-size: .82rem; }
.count-fail { color: var(--danger); font-weight: 800; }
.count-warning { color: var(--warning); font-weight: 800; }
.outcome-detail td { background: #f9fafb; padding: 12px 18px 18px; }
.outcome-detail:hover { background: transparent; }
.outcome-detail summary { color: #344054; cursor: pointer; font-weight: 750; }
.outcome {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 10px;
  padding: 12px 14px;
}
.outcome-meta { align-items: center; color: var(--muted); display: flex; flex-wrap: wrap; font-size: .78rem; gap: 8px; }
.outcome ul { margin: 10px 0 0; padding-left: 20px; }
.outcome li + li { margin-top: 4px; }
.outcome-fail { background: var(--danger-bg); color: var(--danger); }
.outcome-warning { background: var(--warning-bg); color: var(--warning); }
#processing-status, .success-result { display: flex; align-items: center; gap: 16px; padding: 10px; }
#processing-status p, .success-result p { color: var(--muted); margin: 3px 0 0; }
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #dbe3ff;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
.success-mark {
  align-items: center;
  background: var(--success-bg);
  border-radius: 50%;
  color: var(--success);
  display: inline-flex;
  font-size: 1.4rem;
  font-weight: 900;
  height: 40px;
  justify-content: center;
  width: 40px;
}
.not-found { margin: 10vh auto; max-width: 620px; text-align: center; }
.not-found p:not(.eyebrow) { color: var(--muted); margin-bottom: 24px; }
.rules-summary { display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)); gap: 14px; margin: 28px 0; max-width: 680px; }
.rules-summary .metric strong { font-size: 1.35rem; }
.gate-index { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 38px; }
.gate-index a {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #344054;
  font-size: .86rem;
  font-weight: 750;
  padding: 8px 13px;
  text-decoration: none;
}
.gate-index a:hover { border-color: var(--brand); color: var(--brand); }
.gate-index span, .rule-count, .rule-category h3 span {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 650;
}
.gate-section { margin-top: 46px; scroll-margin-top: 20px; }
.gate-heading { align-items: end; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; padding-bottom: 12px; }
.rule-category { margin-top: 24px; }
.rule-category h3 { color: #344054; font-size: .95rem; margin: 0 0 12px; }
.rule-category h3 span { margin-left: 4px; }
.rule-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rule-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 3px 12px rgb(16 24 40 / 4%);
  padding: 20px;
}
.rule-card > header { align-items: start; display: flex; gap: 14px; justify-content: space-between; }
.rule-card h4 { font-size: 1.05rem; line-height: 1.3; margin: 4px 0 0; }
.rule-card > p { color: var(--muted); font-size: .88rem; min-height: 2.7em; }
.rule-id { color: var(--brand); font-size: .78rem; font-weight: 850; letter-spacing: .06em; }
.severity { border-radius: 999px; flex: 0 0 auto; font-size: .68rem; font-weight: 800; padding: 4px 8px; }
.severity-blocking { background: var(--danger-bg); color: var(--danger); }
.severity-warning { background: var(--warning-bg); color: var(--warning); }
.rule-metadata { display: grid; gap: 8px 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 18px 0 0; }
.rule-metadata div { min-width: 0; }
.rule-metadata .wide { grid-column: 1 / -1; }
.rule-metadata dt { color: var(--muted); font-size: .68rem; font-weight: 750; text-transform: uppercase; }
.rule-metadata dd { font-size: .8rem; margin: 2px 0 0; overflow-wrap: anywhere; }
.rule-metadata code { font-size: .75rem; }
.rule-config { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
.rule-config summary { color: #344054; cursor: pointer; font-size: .8rem; font-weight: 750; }
.rule-config h5 { color: var(--muted); font-size: .7rem; margin: 14px 0 5px; text-transform: uppercase; }
.rule-config pre { background: #f8fafc; border-radius: 7px; font-size: .7rem; margin: 0; max-height: 240px; overflow: auto; padding: 10px; white-space: pre-wrap; word-break: break-word; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .container { padding-top: 32px; }
  .environment { display: none; }
  .site-header { padding: 0 4vw; }
  .brand span { display: none; }
  .site-nav { gap: 2px; }
  .site-nav a { font-size: .78rem; padding: 7px; }
  .form-grid, .metrics, .rules-summary, .rule-grid { grid-template-columns: 1fr; }
  .detail-header { align-items: start; flex-direction: column; }
  th, td { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}
