/* Draftsman. Plain, calm, readable on a phone and a desktop. No external fonts or images. */

:root {
  --ink: #1c2530;
  --ink-soft: #55606e;
  --paper: #f6f7f8;
  --surface: #ffffff;
  --line: #d5dae0;
  --accent: #1f4e79;
  --accent-ink: #ffffff;
  --ok: #1d6b3a;
  --ok-bg: #e7f3ea;
  --warn: #7a4b00;
  --warn-bg: #fdf3dc;
  --error: #a1261d;
  --error-bg: #fbe9e7;
  --info-bg: #e8eff6;
  --focus: #b35c00;
  --radius: 6px;
  --gap: 1rem;
  --measure: 72rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6e9ed;
    --ink-soft: #a9b3bf;
    --paper: #14181d;
    --surface: #1d232a;
    --line: #38424d;
    --accent: #8fbce6;
    --accent-ink: #10202f;
    --ok: #8fd3a5;
    --ok-bg: #1c3325;
    --warn: #f0c56e;
    --warn-bg: #3a2e12;
    --error: #f2a199;
    --error-bg: #3d1e1b;
    --info-bg: #1f2c3a;
    --focus: #ffb454;
  }
}

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

html {
  font-size: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--gap);
}

main:focus {
  outline: none;
}

h1 {
  font-size: 1.6rem;
  margin: 0.5rem 0 1rem;
}

h2 {
  font-size: 1.3rem;
  margin: 1.5rem 0 0.75rem;
}

h3 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.5rem;
}

h4,
h5 {
  font-size: 1rem;
  margin: 1rem 0 0.5rem;
}

p {
  margin: 0 0 0.75rem;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -999rem;
  top: 0;
  background: var(--surface);
  padding: 0.5rem 1rem;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
  z-index: 10;
}

.muted,
.hint {
  color: var(--ink-soft);
}

.hint {
  font-size: 0.9rem;
  margin: 0.25rem 0 0.75rem;
}

/* ---------------------------------------------------------------- header */

.top {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.top-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0.5rem var(--gap);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--ink);
}

.top nav {
  display: flex;
  gap: 1rem;
  flex: 1;
}

.top nav a {
  padding: 0.35rem 0;
  text-decoration: none;
  border-bottom: 3px solid transparent;
}

.top nav a[aria-current="page"] {
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.who {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.who-email {
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- buttons */

button,
.button-link {
  font: inherit;
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
}

button.primary,
.button-link {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

button.quiet {
  border-color: var(--line);
  color: var(--ink);
  min-height: 2.25rem;
  padding: 0.25rem 0.75rem;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0 0.5rem;
}

/* ---------------------------------------------------------------- messages */

.notice,
.status:not(:empty) {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  border-left: 4px solid var(--accent);
  background: var(--info-bg);
}

.status {
  margin: 0.5rem 0;
}

.status:empty {
  display: none;
}

.notice.warn,
.status.warn {
  border-left-color: var(--warn);
  background: var(--warn-bg);
}

.notice.error,
.status.error {
  border-left-color: var(--error);
  background: var(--error-bg);
}

.notice.ok,
.status.ok {
  border-left-color: var(--ok);
  background: var(--ok-bg);
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.85rem;
  white-space: nowrap;
}

.badge.warn,
.badge.status-awaiting_facts,
.badge.status-awaiting_approval,
.badge.severity-check {
  border-color: var(--warn);
  background: var(--warn-bg);
  color: var(--warn);
}

.badge.status-failed,
.badge.severity-blocking {
  border-color: var(--error);
  background: var(--error-bg);
  color: var(--error);
}

.badge.status-approved {
  border-color: var(--ok);
  background: var(--ok-bg);
  color: var(--ok);
}

/* ---------------------------------------------------------------- panels and cards */

.panel,
.card,
.statement,
.drop {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--gap);
  margin: 0 0 var(--gap);
}

.panel.narrow {
  max-width: 28rem;
  margin: 3rem auto;
}

.panel.locked {
  border-left: 4px solid var(--warn);
}

.statement {
  border-left: 4px solid var(--accent);
  font-size: 1.05rem;
}

.statement h3,
.panel h2,
.panel h3,
.card h3,
.card h4 {
  margin-top: 0;
}

ul.items,
ul.findings,
ul.sources,
ul.uploads,
ol.steps {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--gap);
}

.card.item.severity-blocking {
  border-left: 4px solid var(--error);
}

.card.item.severity-check,
.card.finding.open {
  border-left: 4px solid var(--warn);
}

.item-message {
  font-size: 1.05rem;
}

.ack {
  margin-top: 0.75rem;
  padding: 0.6rem 0.8rem;
  background: var(--info-bg);
  border-radius: var(--radius);
  font-weight: 600;
}

blockquote {
  margin: 0 0 0.5rem;
  padding: 0.25rem 0 0.25rem 0.75rem;
  border-left: 3px solid var(--line);
  overflow-wrap: anywhere;
}

.sources li {
  margin-bottom: 0.5rem;
  font-size: 0.92rem;
}

.source-where {
  color: var(--ink-soft);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.source-where .badge {
  margin-left: 0.5rem;
}

.with-sources {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.25rem 1rem;
  margin: 0 0 0.75rem;
}

dt {
  color: var(--ink-soft);
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

details.excluded {
  margin: 0 0 var(--gap);
}

details.excluded > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.6rem 0.8rem;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

details.excluded[open] > summary {
  margin-bottom: 0.75rem;
}

/* ---------------------------------------------------------------- forms */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.25rem var(--gap);
  align-items: start;
}

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
}

.field {
  margin-bottom: 0.75rem;
  min-width: 0;
}

.field.wide {
  grid-column: 1 / -1;
}

.field > label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  font: inherit;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--ink-soft);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

textarea {
  resize: vertical;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--paper);
  color: var(--ink-soft);
}

input[type="checkbox"] {
  width: 1.4rem;
  height: 1.4rem;
  flex: none;
  accent-color: var(--accent);
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.3rem 0;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem var(--gap) var(--gap);
  margin: 0 0 var(--gap);
  min-width: 0;
}

legend {
  font-weight: 600;
  padding: 0 0.4rem;
}

fieldset.times {
  border-left: 4px solid var(--accent);
  background: var(--info-bg);
}

/* ---------------------------------------------------------------- tables */

.table-wrap {
  overflow-x: auto;
  margin-bottom: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  border-collapse: collapse;
  width: 100%;
}

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

thead th {
  font-size: 0.9rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

tbody tr:last-child > * {
  border-bottom: none;
}

table.edit td {
  min-width: 9rem;
}

table.edit td:has(input[type="checkbox"]),
table.edit td.row-action {
  min-width: 0;
}

table.edit td.extra {
  min-width: 16rem;
  max-width: 26rem;
}

table.rules td:nth-child(4) {
  min-width: 20rem;
}

/* ---------------------------------------------------------------- case page */

.crumb {
  margin: 0;
  font-size: 0.9rem;
}

.case-head h1 {
  margin: 0.25rem 0;
  overflow-wrap: anywhere;
}

.case-meta {
  color: var(--ink-soft);
}

.tabs {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--gap);
}

.tabs a {
  padding: 0.6rem 0.9rem;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}

.tabs a[aria-current="page"] {
  border-bottom-color: var(--accent);
  font-weight: 600;
  color: var(--ink);
}

.tab-body > h2 {
  margin-top: 0;
}

/* ---------------------------------------------------------------- upload */

.drop {
  border-style: dashed;
  border-width: 2px;
}

.drop.over {
  border-color: var(--accent);
  background: var(--info-bg);
}

.drop label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.drop input[type="file"] {
  font: inherit;
  max-width: 100%;
}

.uploads li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6rem;
  gap: 0.25rem 0.75rem;
  align-items: center;
  padding: 0.4rem 0;
  border-top: 1px solid var(--line);
  margin-top: 0.5rem;
}

.file-name {
  overflow-wrap: anywhere;
}

.file-state {
  grid-column: 1 / -1;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.file-state.error {
  color: var(--error);
}

.file-state.ok {
  color: var(--ok);
}

progress {
  width: 100%;
}

/* ---------------------------------------------------------------- run */

.steps li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 0.4rem;
}

.steps li.done {
  border-left-color: var(--ok);
}

.steps li.current {
  border-left-color: var(--accent);
  font-weight: 600;
}

.steps li.failed {
  border-left-color: var(--error);
  background: var(--error-bg);
}

.step-state {
  color: var(--ink-soft);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- small screens */

@media (max-width: 40rem) {
  .with-sources {
    grid-template-columns: minmax(0, 1fr);
  }

  h1 {
    font-size: 1.35rem;
  }

  .top nav {
    order: 3;
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: no-preference) {
  button,
  .button-link {
    transition: opacity 0.15s ease;
  }
}
