:root {
  color-scheme: light;
  --ink: #17253a;
  --muted: #516076;
  --canvas: #f6f7f9;
  --paper: #fff;
  --line: #ccd3dd;
  --soft-line: #e2e6ed;
  --amber: #f8ab28;
  --amber-deep: #a64d06;
  --amber-soft: #fff2da;
  --green: #13653a;
  --red: #a71d34;
  --radius: 0.55rem;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

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

body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.2; }
h1 { font-size: clamp(1.65rem, 1.25rem + 1.6vw, 2.5rem); letter-spacing: -.035em; }
h2 { font-size: clamp(1.25rem, 1.1rem + .65vw, 1.85rem); letter-spacing: -.02em; }
h3 { font-size: 1.05rem; }
:focus-visible { outline: .2rem solid #246caf; outline-offset: .16rem; }
.muted { color: var(--muted); }

.visually-hidden, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus {
  position: absolute;
  z-index: 5;
  top: .5rem;
  left: .5rem;
  padding: .65rem;
  background: var(--paper);
  color: var(--ink);
}

.site-header { background: var(--ink); color: var(--paper); }
.site-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 1.25rem;
  max-width: 90rem;
  margin-inline: auto;
  padding: .5rem clamp(.75rem, 3vw, 2rem);
}
.brand {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding-inline-start: .65rem;
  border-inline-start: .3rem solid var(--amber);
  font-size: clamp(1.25rem, 1rem + .8vw, 1.7rem);
  font-weight: 750;
  letter-spacing: -.025em;
  text-decoration: none;
}
.site-navigation {
  order: 2;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-basis: 100%;
  margin-block-start: .25rem;
}
.site-navigation a, .sign-out {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  text-decoration: none;
}
.site-navigation a { border-block-end: .19rem solid transparent; color: #edf0f6; }
.site-navigation a[aria-current] { border-color: var(--amber); color: var(--paper); font-weight: 700; }
.site-navigation a:hover, .sign-out:hover { text-decoration: underline; }
.account { display: flex; gap: .7rem; align-items: center; margin-inline-start: auto; }
.account-name { display: none; }
.sign-out { border: 0; background: transparent; padding: .25rem 0; color: #edf0f6; cursor: pointer; }

.page-shell { max-width: 90rem; margin: 0 auto; padding: 1.1rem clamp(.75rem, 3vw, 2rem) 3rem; }
.page-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .65rem 1rem;
  margin-block-end: .9rem;
}
.page-heading p { margin-block-start: .35rem; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.button {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .58rem .85rem;
  border: 1px solid #8391a4;
  border-radius: .45rem;
  background: var(--paper);
  color: var(--ink);
  font-weight: 650;
  line-height: 1.22;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: #eef2f7; }
.button-primary { border-color: #d28511; background: var(--amber); color: #201508; }
.button-primary:hover { background: #ffbe4d; }
.back-link, .mobile-queue-back {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  margin-block-end: .45rem;
  color: var(--muted);
  font-weight: 650;
  text-decoration-thickness: .06rem;
  text-underline-offset: .2em;
}

.queue-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .3rem;
  margin-block-end: .9rem;
  border-block-end: 1px solid var(--line);
}
.queue-tab {
  display: flex;
  flex-wrap: wrap;
  gap: .2rem .4rem;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .42rem .2rem;
  border-block-end: .2rem solid transparent;
  border-radius: .35rem .35rem 0 0;
  font-size: .88rem;
  font-weight: 650;
  text-align: center;
  text-decoration: none;
}
.queue-tab:hover { background: #e9edf3; }
.queue-tab[aria-current] { border-color: #c46b13; background: var(--amber-soft); color: #713600; }
.queue-count { min-width: 1.5rem; padding: .08rem .25rem; border-radius: 1rem; background: #e3e8f0; color: var(--ink); font-size: .78rem; }
.queue-tab[aria-current] .queue-count { background: #f7dca9; color: #713600; }
.report-workspace { display: grid; gap: .9rem; }
.queue-column { min-width: 0; }
.queue-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .45rem; margin-block-end: .7rem; }
.report-list { display: grid; gap: .55rem; margin: 0; padding: 0; list-style: none; }
.report-list-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  padding: .7rem .85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.report-list-link:hover { border-color: #8391a4; }
.report-list-link[aria-current] { border-color: #d28511; background: var(--amber-soft); box-shadow: inset .23rem 0 #d28511; }
.report-list-title, .report-list-subtitle, .user-username { display: block; }
.report-list-subtitle, .user-username { margin-block-start: .18rem; color: var(--muted); font-size: .88rem; font-weight: 400; }
.report-list-arrow { color: var(--muted); font-size: 1.55rem; line-height: 1; }
.report-placeholder { display: none; }
.report-selected .queue-column { display: none; }
.report-detail { padding: clamp(.75rem, 2vw, 1.4rem); }
.detail-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; align-items: flex-start; }
.detail-heading h2 { margin-block-start: .4rem; overflow-wrap: anywhere; }
.detail-heading p { margin-block-start: .25rem; color: var(--muted); }
.detail-controls { display: flex; flex-wrap: wrap; gap: .5rem; }
.status-badge { display: inline-block; border-radius: 1rem; padding: .18rem .58rem; background: #edf1f6; color: #37465b; font-size: .82rem; font-weight: 700; }
.status-in_approval { background: var(--amber-soft); color: #713600; }
.status-finished { background: #eaf5ed; color: var(--green); }
.inspection-data {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
  margin: 1rem 0 0;
  padding: .7rem;
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  background: #f9fafc;
  overflow-wrap: anywhere;
}
.inspection-data dt { color: var(--muted); font-size: .83rem; }
.inspection-data dd { margin: .12rem 0 0; font-weight: 650; }
.results-section, .report-remarks, .review-history, .report-review { margin-block-start: 1.15rem; }
.results-section > h3 {
  padding: .7rem .65rem;
  border: 1px solid #e4d8c1;
  border-radius: .4rem .4rem 0 0;
  background: #fbf3e5;
}
.results-table { display: block; width: 100%; border-collapse: collapse; text-align: left; overflow-wrap: anywhere; }
.results-table thead { position: absolute; height: 1px; width: 1px; overflow: hidden; clip-path: inset(50%); }
.results-table tbody { display: block; }
.results-table tbody tr {
  display: grid;
  gap: .22rem;
  padding: .65rem;
  border: 1px solid var(--soft-line);
  border-block-start: 0;
}
.results-table tbody tr:nth-child(even) { background: #fafbfc; }
.results-table td { display: grid; grid-template-columns: minmax(0, 6.4rem) minmax(0, 1fr); gap: .3rem; align-items: baseline; font-size: .93rem; }
.mobile-cell-label { color: var(--muted); font-size: .82rem; font-weight: 650; }
.observed-value { min-width: 0; font-weight: 650; }
.outcome {
  display: inline-grid;
  width: 1.25rem;
  height: 1.25rem;
  place-items: center;
  margin-inline-start: .22em;
  border: .1rem solid currentColor;
  border-radius: 50%;
  font-size: .82rem;
  font-weight: 800;
  line-height: 1;
  vertical-align: .05em;
}
.outcome-pass { color: var(--green); }
.outcome-fail { color: var(--red); }
.report-remarks p, .review-history li p { margin-block-start: .28rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.review-history { border-block-start: 1px solid var(--soft-line); padding-block-start: .9rem; }
.review-history ol { display: grid; gap: .7rem; margin: .55rem 0 0; padding-inline-start: 1.35rem; }
.review-history li > span { display: block; color: var(--muted); font-size: .85rem; }
.report-review { padding-block-start: .9rem; border-block-start: 1px solid var(--soft-line); }
.report-review h3 { margin-block-end: .55rem; }

.form-stack { display: grid; gap: .85rem; }
.fields-grid { display: grid; gap: .8rem; }
.form-field { display: grid; align-content: start; gap: .28rem; min-width: 0; font-size: .9rem; font-weight: 650; }
input:not([type="checkbox"]), textarea, select {
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  padding: .5rem .65rem;
  border: 1px solid #9ca9b9;
  border-radius: .35rem;
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 400;
}
textarea { resize: vertical; }
.field-hint { color: var(--muted); font-size: .83rem; font-weight: 400; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.form-actions > * { flex: 1 1 auto; }
.entry-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .25rem .9rem;
  margin-block-end: .65rem;
}
.entry-heading h1 { font-size: clamp(1.25rem, 1rem + 1.2vw, 1.8rem); }
.entry-heading .back-link { margin-block-end: 0; }
.entry-mode { color: var(--muted); font-size: .82rem; font-weight: 650; }
.report-entry-form { gap: .55rem; }
.entry-section-heading {
  padding: .38rem .65rem;
  border-radius: var(--radius) var(--radius) 0 0;
  background: #fbf3e5;
  font-size: .94rem;
  letter-spacing: 0;
}
.entry-details, .entry-signoff { display: grid; gap: .42rem .7rem; padding: .55rem .65rem; }
.entry-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.entry-signoff { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.entry-signoff > :first-child { grid-column: 1 / -1; }
.entry-details .form-field, .entry-signoff .form-field { gap: .12rem; font-size: .85rem; }
.entry-test-table tbody tr {
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: .3rem .55rem;
  padding: .42rem .65rem;
}
.entry-test-table tbody th { grid-column: 1 / -1; font-size: .92rem; }
.entry-test-table tbody td { display: block; line-height: 1.24; }
.entry-test-table .entry-test-reference { font-size: .82rem; }
.entry-test-table .mobile-cell-label, .entry-cell-label {
  display: block;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 650;
}
.entry-cell-label { margin-block-end: .15rem; }
.entry-actions {
  position: sticky;
  z-index: 1;
  bottom: 0;
  padding: .6rem .1rem calc(.6rem + env(safe-area-inset-bottom));
  border-block-start: 1px solid var(--line);
  background: var(--canvas);
}
.entry-panel { padding: clamp(.75rem, 2vw, 1.4rem); }
.login-panel { max-width: 28rem; margin: clamp(1rem, 7vw, 6rem) auto 0; padding: clamp(1rem, 4vw, 2rem); }
.login-panel > p:first-of-type { margin: .35rem 0 1rem; }
.permissions-group { margin: 0; padding: .35rem .65rem .6rem; border: 1px solid var(--line); border-radius: .35rem; }
.permissions-group legend { padding: 0 .3rem; font-weight: 700; }
.permission-option { display: flex; align-items: center; gap: .55rem; min-height: 2.75rem; cursor: pointer; }
.permission-option input { width: 1.22rem; height: 1.22rem; margin: 0; accent-color: #a45306; }
.user-form { max-width: 55rem; }
.user-directory { overflow: hidden; }
.user-table td:last-child { display: block; margin-block-start: .3rem; }
.notice { margin-block-end: .8rem; padding: .65rem .75rem; border: 1px solid #9bbbcc; border-radius: .4rem; background: #edf5f9; }
.notice-error { border-color: #dcaab4; background: #fff0f3; color: #7b1830; }
.notice p { font-weight: 650; }
.notice ul { margin: .3rem 0 0; padding-inline-start: 1.3rem; }
.empty-state { padding: .9rem; border: 1px dashed #a7b3c2; border-radius: var(--radius); color: var(--muted); }

@media (min-width: 37rem) {
  .site-navigation { order: 0; flex-basis: auto; margin-block-start: 0; }
  .queue-tabs { grid-template-columns: repeat(3, max-content); gap: .45rem; }
  .queue-tab { padding-inline: .9rem; font-size: .94rem; }
  .fields-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-actions { justify-content: flex-end; }
  .form-actions > * { flex: 0 1 auto; }
  .inspection-data { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 51rem) {
  .site-header-inner { gap: 1.65rem; }
  .account-name { display: inline; }
  .site-navigation { padding-inline-start: 1.5rem; border-inline-start: 1px solid #546177; }
  .page-shell { padding-block-start: 1.65rem; }
  .report-workspace { align-items: start; grid-template-columns: minmax(15.5rem, .85fr) minmax(0, 2fr); }
  .report-selected .queue-column { display: block; }
  .mobile-queue-back { display: none; }
  .report-placeholder { display: grid; min-height: 15rem; padding: 1rem; place-items: center; color: var(--muted); }
  .results-table { display: table; }
  .results-table thead { display: table-header-group; position: static; width: auto; height: auto; overflow: visible; clip-path: none; background: #edf1f6; }
  .results-table tbody { display: table-row-group; }
  .results-table tbody tr { display: table-row; padding: 0; border: 0; }
  .results-table th, .results-table td { display: table-cell; padding: .5rem .48rem; border: 1px solid var(--soft-line); vertical-align: top; font-size: .9rem; }
  .results-table tbody th { font-weight: 650; }
  .results-table .mobile-cell-label { display: none; }
  .results-table.user-table th, .results-table.user-table td { padding: .75rem; vertical-align: middle; }
  .user-table td:last-child { display: table-cell; margin: 0; }
  .entry-details { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .entry-signoff { grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)); }
  .entry-signoff > :first-child { grid-column: auto; }
  .report-entry-form input:not([type="checkbox"]), .report-entry-form select {
    min-height: 1.7rem;
    padding: .12rem .35rem;
    font-size: .85rem;
    line-height: 1.25;
  }
  .report-entry-form textarea { min-height: 2.2rem; padding: .2rem .35rem; font-size: .85rem; }
  .entry-test-table { table-layout: fixed; }
  .entry-test-table tbody tr { display: table-row; padding: 0; border: 0; }
  .entry-test-table thead th, .entry-test-table tbody th, .entry-test-table tbody td {
    display: table-cell;
    padding: .08rem .45rem;
    vertical-align: middle;
    font-size: .83rem;
    line-height: 1.2;
  }
  .entry-test-table thead th { padding-block: .26rem; }
  .entry-test-table thead th:nth-child(1) { width: 23%; }
  .entry-test-table thead th:nth-child(2) { width: 22%; }
  .entry-test-table thead th:nth-child(3) { width: 21%; }
  .entry-test-table thead th:nth-child(4) { width: 23%; }
  .entry-test-table thead th:nth-child(5) { width: 11%; }
  .entry-test-table .mobile-cell-label { display: none; }
  .entry-cell-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .entry-actions { padding-block: .32rem; }
}
