:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #18202a;
  --muted: #66717f;
  --line: #d7dde5;
  --pcassi-red: #ed0012;
  --pcassi-blue: #126db4;
  --dominion-blue: #1557c0;
  --green: #177a4d;
  --amber: #a96400;
  --red: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand-pair {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.logo {
  display: block;
  object-fit: contain;
  min-width: 0;
}

.logo.dominion {
  width: 112px;
  height: 38px;
}

.logo.pcassi {
  width: 210px;
  height: 42px;
}

.divider {
  width: 1px;
  height: 34px;
  background: var(--line);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
}

.layout {
  width: calc(100% - 28px);
  margin: 0 auto;
  padding: 14px 0 24px;
}

.intro {
  margin-bottom: 8px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--dominion-blue);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 780px;
  margin-bottom: 4px;
  font-size: 22px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 6px;
  font-size: 16px;
}

.summary {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.25;
}

.run-panel,
.upload-box,
.steps,
.results {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.run-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 8px 12px;
  align-items: center;
  padding: 10px 12px;
}

.run-label {
  grid-column: 1;
  color: var(--muted);
  font-size: 13px;
}

#runStatus {
  grid-column: 1;
  font-size: 17px;
}

.run-panel .primary-action {
  grid-column: 2;
  grid-row: 1 / 3;
}

.primary-action,
.secondary-action,
.file-control span {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
}

.primary-action {
  width: 100%;
  color: #ffffff;
  background: var(--dominion-blue);
}

.secondary-action {
  padding: 0 12px;
  color: var(--dominion-blue);
  background: #eef4ff;
  border-color: #bfd2f6;
}

.row-action {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid #f2b8b5;
  border-radius: 6px;
  color: var(--red);
  background: #fff5f5;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 320px;
  gap: 10px;
  margin-bottom: 10px;
}

.upload-box {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
}

.upload-box p {
  margin-bottom: 0;
  color: var(--muted);
}

.upload-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: var(--pcassi-red);
  font-weight: 800;
}

.upload-icon.excel {
  background: var(--green);
}

.file-control input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.file-control span {
  padding: 0 12px;
  color: var(--ink);
  background: #f8fafc;
  border-color: var(--line);
}

.upload-box small {
  grid-column: 2 / 4;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  display: block;
}

.workspace[hidden] {
  display: none;
}

.steps {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  margin-bottom: 12px;
  padding: 10px 14px;
}

.steps ol {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 8px;
  margin: 0;
  padding-left: 0;
  list-style-position: inside;
}

.steps li {
  margin-bottom: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
  color: var(--muted);
  font-size: 13px;
}

.steps li.active {
  color: var(--dominion-blue);
  font-weight: 700;
}

.results {
  overflow: hidden;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.section-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.metrics div {
  padding: 10px 16px;
  border-right: 1px solid var(--line);
}

.metrics div:last-child {
  border-right: 0;
}

.metrics span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  font-size: 22px;
}

.table-wrap {
  overflow: auto;
}

.grid-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 190px;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.grid-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.grid-toolbar input,
.grid-toolbar select {
  min-height: 34px;
  width: 100%;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #ffffff;
}

.editable-wrap {
  max-height: calc(100vh - 360px);
  min-height: 300px;
}

table {
  width: 100%;
  min-width: 1000px;
  border-collapse: collapse;
}

.editable-grid {
  min-width: 1400px;
}

th,
td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--muted);
  background: #f8fafc;
  font-size: 13px;
  font-weight: 700;
}

td {
  font-size: 13px;
}

td[contenteditable="true"] {
  min-width: 78px;
  background: #ffffff;
  outline: none;
}

td[contenteditable="true"]:focus {
  box-shadow: inset 0 0 0 2px var(--dominion-blue);
  background: #f7fbff;
}

.editable-grid th:nth-child(4),
.editable-grid td:nth-child(4),
.editable-grid th:nth-child(13),
.editable-grid td:nth-child(13) {
  min-width: 185px;
}

.editable-grid th:last-child,
.editable-grid td:last-child {
  min-width: 86px;
  text-align: center;
}

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 48px;
  background: #ffffff;
  box-shadow: 1px 0 0 var(--line);
}

th.sticky-col {
  background: #f8fafc;
  z-index: 4;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.ok {
  color: var(--green);
  background: #e9f6ef;
}

.pill.warn {
  color: var(--amber);
  background: #fff2df;
}

.pill.danger {
  color: var(--red);
  background: #fdebea;
}

@media (max-width: 900px) {
  .topbar,
  .brand-pair,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    white-space: normal;
  }

  .divider {
    display: none;
  }

  .logo.pcassi {
    width: 220px;
  }

  .upload-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .run-panel {
    grid-template-columns: 1fr;
  }

  .run-panel .primary-action {
    grid-column: 1;
    grid-row: auto;
  }

  h1 {
    font-size: 30px;
  }

  .upload-box {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .file-control {
    grid-column: 1 / 3;
  }

  .upload-box small {
    grid-column: 1 / 3;
  }

  .metrics div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .table-actions,
  .grid-toolbar {
    width: 100%;
  }

  .grid-toolbar {
    grid-template-columns: 1fr;
  }

  .steps {
    grid-template-columns: 1fr;
  }

  .steps ol {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1300px) {
  .steps ol {
    grid-template-columns: repeat(5, minmax(120px, 1fr));
  }

  .steps li {
    font-size: 12px;
    padding: 7px 8px;
  }
}
