:root {
  --bg: #fafafa;
  --paper: #fff;
  --line: #e6e6e8;
  --line-strong: #d2d2d6;
  --ink: #1c1c1e;
  --muted: #6e6e73;
  --muted-2: #8e8e93;
  --brand: #0b6bcb;
  --good: #0a7c4a;
  --warn: #9a5b00;
  --bad: #b3261e;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

strong,
b {
  font-weight: 600;
}

a {
  color: var(--brand);
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.preview-banner {
  padding: 8px 16px;
  text-align: center;
  background: #fff8ec;
  border-bottom: 1px solid #ead5aa;
  color: var(--warn);
  font-size: 12px;
}

.shell {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  min-height: calc(100vh - 35px);
}

aside {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px 10px;
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.brand {
  display: block;
  padding: 4px 10px 20px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.02em;
  text-decoration: none;
}

aside nav {
  display: grid;
  gap: 2px;
}

aside nav a {
  padding: 8px 10px;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-size: 12.5px;
  text-decoration: none;
}

aside nav a:hover {
  background: #f5f5f7;
  color: var(--ink);
}

aside nav a[aria-current=page] {
  border-left-color: var(--brand);
  color: var(--ink);
  font-weight: 600;
}

.skills-link {
  display: block;
  margin: 18px 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.skills-link:hover {
  color: var(--ink);
}

.sidebar-footer {
  min-height: 32px;
  margin-top: auto;
  padding: 12px 10px 0;
  border-top: 1px solid var(--line);
}

.sidebar-footer form {
  margin: 0;
}

.sidebar-footer button {
  width: 100%;
  font-size: 12px;
}

main {
  min-width: 0;
  padding: 20px clamp(16px, 3vw, 42px) 48px;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(100%, 360px);
  padding: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.login-card > p {
  margin: 6px 0 20px;
  color: var(--muted);
}

.login-card form p {
  display: grid;
  gap: 5px;
  margin: 0 0 14px;
}

.login-card label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.login-card input {
  width: 100%;
  height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}

.login-card button {
  width: 100%;
  margin-top: 2px;
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.login-card button:hover {
  background: #085daf;
}

h1,
h2,
h3 {
  color: var(--ink);
  font-weight: 600;
}

h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -.02em;
  line-height: 1.2;
}

h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

h3 {
  margin: 20px 0 0;
  font-size: 14px;
}

header > p,
.muted {
  color: var(--muted);
}

header > p {
  margin: 5px 0 0;
}

.page-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.mode {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.card,
.notice {
  margin-top: 16px;
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.unavailable {
  border-left: 3px solid var(--warn);
  background: #fffdf8;
}

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr)) auto;
  gap: 8px;
  margin-top: 16px;
}

.filters label {
  display: grid;
  min-width: 0;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.filters input,
.filters select,
.settings-fields input {
  min-width: 0;
  width: 100%;
  height: 30px;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}

button {
  align-self: end;
  min-height: 30px;
  padding: 5px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: #f5f5f7;
}

.save-button {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.save-button:hover {
  background: #085daf;
}

.table-heading,
.detail-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.table-heading p {
  margin: 3px 0 0;
}

.table-scroll {
  margin: 12px -14px -14px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

tbody tr:hover {
  background: #f5f5f7;
}

th {
  background: var(--paper);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .035em;
  text-transform: uppercase;
}

td a {
  color: inherit;
  text-decoration: none;
}

td a:hover strong {
  text-decoration: underline;
}

td span:not(.status) {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
}

.status.confirmed,
.status.positive,
.status.owner_attested,
.status.ready {
  border-color: #add9c2;
  background: #f0faf5;
  color: var(--good);
}

.status.blocked,
.status.negative,
.status.failed,
.status.error {
  border-color: #edb7b3;
  background: #fdf0ef;
  color: var(--bad);
}

.status.uncertain,
.status.stale,
.status.warning,
.status.unconfirmed_write {
  border-color: #ead5aa;
  background: #fff8ec;
  color: var(--warn);
}

td small {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.decision-table th:last-child,
.decision-table td:last-child,
.history-table th:last-child,
.history-table td:last-child,
.rank-table th:nth-child(2),
.rank-table td:nth-child(2),
.rank-table th:nth-child(3),
.rank-table td:nth-child(3),
.rank-table th:nth-child(4),
.rank-table td:nth-child(4) {
  text-align: right;
}

.decision-table {
  table-layout: fixed;
}

.decision-table th:nth-child(1) {
  width: 18%;
}

.decision-table th:nth-child(2) {
  width: 34%;
}

.decision-table th:nth-child(3) {
  width: 14%;
}

.decision-table th:nth-child(4) {
  width: 16%;
}

.decision-table th:nth-child(5) {
  width: 18%;
}

.decision-table td:nth-child(2) strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.decision-table td:last-child {
  white-space: nowrap;
}

.pagination {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

.detail-empty {
  margin-top: 16px;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
}

.detail-grid,
.summary-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 0;
}

.checkpoint-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.detail-grid > div,
.summary-list > div,
.checkpoint-grid > div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

dt {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

dd {
  margin: 4px 0 0;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.notice-inline {
  margin: 12px 0 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f5f5f7;
  color: var(--muted);
  font-size: 12px;
}

.coverage {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

.subnav {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.history-filters,
.rank-filters {
  grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
}

.history-table {
  min-width: 840px;
}

.outcome-table {
  table-layout: fixed;
}

.outcome-table th:nth-child(1) { width: 32%; }
.outcome-table th:nth-child(2) { width: 12%; }
.outcome-table th:nth-child(3) { width: 12%; }
.outcome-table th:nth-child(4) { width: 20%; }
.outcome-table th:nth-child(5) { width: 24%; }
.outcome-table td { overflow-wrap: anywhere; }

.rank-table {
  min-width: 860px;
}

.history-table td,
.rank-table td {
  overflow-wrap: anywhere;
}

.history-table td:nth-child(4) {
  white-space: nowrap;
}

.rank-evidence summary {
  color: var(--brand);
  cursor: pointer;
  font-weight: 600;
}

.rank-evidence p {
  margin: 8px 0;
}

.rank-evidence dl {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 0;
}

.settings-form {
  margin-top: 16px;
}

.settings-form > .muted {
  font-size: 12px;
}

.settings-group {
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.settings-group summary {
  padding: 10px 12px;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.settings-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
  padding: 2px 12px 12px;
  border-top: 1px solid var(--line);
}

.settings-fields label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.settings-fields input[type=checkbox] {
  width: auto;
  justify-self: start;
}

.settings-fields input:disabled {
  background: #f5f5f7;
  color: var(--muted);
}

.field-error input {
  border-color: var(--bad);
}

.field-error small,
.errorlist {
  color: var(--bad);
  font-size: 12px;
}

.detail-grid ul {
  margin: 0;
  padding-left: 18px;
}

.review-run-sheets { display: flex; flex-wrap: wrap; gap: 12px 24px; }
.review-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 16px 0; }
.review-table { table-layout: fixed; min-width: 680px; }
.review-table th:first-child { width: 64px; }
.review-confirm-table th:first-child { width: 36%; }
.review-confirm-table th:nth-child(2) { width: 24%; }
.review-confirm-table th:nth-child(3) { width: 40%; }
.review-table td { overflow-wrap: anywhere; }
.review-table input[type=checkbox] { width: 18px; height: 18px; }
.review-payload { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }

@media (max-width: 760px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  aside {
    padding: 10px 14px 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    padding: 2px 0 9px;
  }

  aside nav {
    display: flex;
    gap: 6px;
    margin: 0 -14px;
    padding: 0 14px 4px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }

  aside nav a {
    flex: 0 0 auto;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12px;
    white-space: nowrap;
  }

  aside nav a[aria-current=page] {
    border-color: var(--line-strong);
    border-left-color: var(--line-strong);
    background: #f5f5f7;
  }

  .skills-link {
    display: none;
  }

  .sidebar-footer {
    display: block;
    min-height: 0;
    margin-top: 8px;
    padding: 8px 0 0;
  }

  main {
    padding: 18px 14px 32px;
  }

  .page-head {
    flex-direction: column;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters label:first-child {
    grid-column: 1 / -1;
  }

  .filters button {
    justify-self: start;
  }

  .table-scroll {
    margin-inline: -14px;
    padding-inline: 14px;
  }

  .detail-grid,
  .summary-list,
  .checkpoint-grid,
  .settings-fields {
    grid-template-columns: 1fr;
  }

  .mode {
    white-space: normal;
  }
}
