:root {
  color-scheme: light;
  --ink: #202522;
  --muted: #68706b;
  --line: #dfe3e0;
  --surface: #ffffff;
  --surface-alt: #f5f7f5;
  --green: #137a42;
  --green-dark: #0d5d31;
  --blue: #245c9c;
  --amber: #946200;
  --red: #a12d2d;
  --shadow: 0 12px 32px rgb(25 38 30 / 10%);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-width: 320px;
  background: var(--surface-alt);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface-alt);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

a {
  color: var(--green-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #bfc7c1;
  border-radius: 5px;
  background: var(--surface);
  padding: 8px 10px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgb(36 92 156 / 25%);
  outline-offset: 2px;
}

label {
  display: grid;
  gap: 5px;
  color: #454d48;
  font-size: 13px;
  font-weight: 650;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 14px;
  font-size: 16px;
  line-height: 1.3;
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 96%);
  padding: 8px clamp(16px, 4vw, 48px);
}

.brand,
.login-brand {
  color: var(--ink);
  font-size: 19px;
  font-weight: 800;
}

.brand:hover {
  text-decoration: none;
}

.brand span,
.login-brand span {
  color: var(--green);
  font-weight: 650;
}

.account {
  display: flex;
  align-items: center;
  gap: 18px;
}

.header-nav {
  display: flex;
  gap: 14px;
  font-size: 13px;
  font-weight: 700;
}

.account > div {
  display: grid;
  text-align: right;
}

.account span {
  color: var(--muted);
  font-size: 12px;
}

.page {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 32px clamp(16px, 4vw, 48px) 64px;
}

.page-auth {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(400px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 34px;
}

.login-panel h1 {
  margin: 26px 0 22px;
  font-size: 22px;
}

.form-stack {
  display: grid;
  gap: 15px;
}

.compact-form {
  margin-top: 18px;
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover {
  text-decoration: none;
}

.button-primary {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
}

.button-primary:hover {
  border-color: var(--green-dark);
  background: var(--green-dark);
}

.button-secondary {
  border-color: #b9c2bb;
  color: var(--ink);
  background: var(--surface);
}

.button-secondary:hover,
.button-quiet:hover {
  border-color: #89958c;
  background: var(--surface-alt);
}

.button-quiet {
  min-height: 34px;
  border-color: transparent;
  color: #4d5750;
  background: transparent;
}

.button-wide {
  width: 100%;
  margin-top: 4px;
}

.alert {
  margin-bottom: 20px;
  border: 1px solid;
  border-radius: 5px;
  padding: 11px 14px;
  font-weight: 600;
}

.alert-success {
  border-color: #a4cfb5;
  color: #0d5d31;
  background: #edf8f1;
}

.alert-error {
  border-color: #dfabab;
  color: #812020;
  background: #fff1f1;
}

.alert-warning {
  border-color: #dfc173;
  color: #674600;
  background: #fff6dc;
}

.page-heading,
.document-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 26px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.inline-form,
.heading-actions,
.filters,
.upload-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.create-period input {
  width: 92px;
}

.create-period select {
  width: 150px;
}

.table-section {
  border-top: 2px solid #303732;
  background: var(--surface);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

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

th {
  color: #59615c;
  background: #fafbfa;
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

td.actions {
  width: 1%;
  text-align: right;
}

.empty {
  height: 120px;
  color: var(--muted);
  text-align: center;
}

.filename {
  display: inline-block;
  max-width: 420px;
  overflow-wrap: anywhere;
}

.period-state,
.status,
.duplicate {
  display: inline-block;
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.period-open,
.status-new {
  color: #3e4b43;
  background: #e9eeea;
}

.period-complete,
.status-accepted {
  color: #0d5d31;
  background: #dff2e6;
}

.status-needs_review {
  color: #734d00;
  background: #fff0c9;
}

.status-missing_data {
  color: #194e87;
  background: #e2eefb;
}

.status-rejected {
  color: #812020;
  background: #f8dddd;
}

.duplicate {
  margin-left: 6px;
  color: #6d3e00;
  background: #f7e5cc;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 13px;
}

.upload-band {
  margin: 0 calc(-1 * clamp(16px, 4vw, 48px)) 24px;
  border-block: 1px solid #cddbd1;
  background: #edf5ef;
  padding: 18px clamp(16px, 4vw, 48px);
}

.file-picker {
  min-width: min(520px, 60vw);
}

.filters {
  margin-bottom: 14px;
}

.filters label:first-child {
  width: min(400px, 100%);
}

.filters label:nth-child(2) {
  width: 190px;
}

.document-heading {
  align-items: flex-start;
}

.document-heading h1 {
  max-width: 920px;
  overflow-wrap: anywhere;
  font-size: 22px;
}

.document-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.document-layout {
  display: grid;
  min-height: 720px;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 390px);
  border-top: 2px solid #303732;
  background: var(--surface);
}

.preview-panel {
  display: grid;
  min-width: 0;
  place-items: center;
  border-right: 1px solid var(--line);
  background: #e8ebe9;
  padding: 18px;
}

.preview-panel iframe,
.preview-panel img {
  width: 100%;
  height: 100%;
  min-height: 680px;
  border: 0;
  background: #fff;
  object-fit: contain;
}

.document-sidebar {
  min-width: 0;
}

.side-section {
  border-bottom: 1px solid var(--line);
  padding: 22px;
}

.details-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.details-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.details-list dt {
  color: var(--muted);
}

.details-list dd {
  margin: 0;
  font-weight: 650;
}

.comment-list {
  display: grid;
  gap: 14px;
}

.comment {
  border-left: 3px solid #c7d0ca;
  padding-left: 11px;
}

.comment time,
.history-list time {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.comment p,
.history-list p {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.history-list {
  display: grid;
  gap: 17px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-list li {
  position: relative;
  display: grid;
  gap: 4px;
  border-left: 1px solid #bdc5bf;
  padding-left: 13px;
}

.history-list .status {
  width: fit-content;
}

.muted {
  color: var(--muted);
}

.settings-panel {
  width: min(520px, 100%);
  border-top: 2px solid #303732;
  background: var(--surface);
  padding: 26px;
}

.settings-panel h1 {
  margin-bottom: 22px;
  font-size: 22px;
}

.settings-form .button {
  width: fit-content;
}

.credential-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
  border: 1px solid #9ec8ae;
  border-radius: 6px;
  background: #edf8f1;
  padding: 16px 18px;
}

.credential-panel > div {
  display: grid;
  gap: 2px;
}

.credential-panel span {
  color: var(--muted);
  font-size: 12px;
}

.credential-panel code {
  overflow-wrap: anywhere;
  color: #173c27;
  font-size: 17px;
  font-weight: 750;
}

.admin-layout {
  display: grid;
  align-items: start;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
}

.create-user-panel {
  border-top: 2px solid #303732;
  background: var(--surface);
  padding: 20px;
}

.row-form {
  display: flex;
  align-items: center;
  gap: 7px;
}

.row-form select {
  min-width: 150px;
}

.cell-secondary {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.access-state {
  font-size: 12px;
  font-weight: 750;
}

.access-active {
  color: var(--green-dark);
}

.access-inactive {
  color: var(--red);
}

.settings-grid {
  display: grid;
  gap: 34px;
}

.section-heading {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2 {
  margin: 0;
}

.section-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.inline-create-form {
  display: grid;
  grid-template-columns: minmax(240px, 440px) auto;
  align-items: end;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 14px;
}

.requirement-create-form {
  grid-template-columns: minmax(240px, 1fr) minmax(220px, 320px) auto;
}

.checklist-section {
  margin-bottom: 24px;
  border-top: 2px solid #303732;
  background: var(--surface);
}

.checklist-section > .section-heading {
  padding: 12px 14px;
}

.checklist-table td:first-child {
  width: 28%;
}

.checklist-table td:last-child {
  width: 46%;
}

.checklist-form {
  display: grid;
  grid-template-columns: 130px minmax(160px, 1fr) auto;
  gap: 7px;
}

.checklist-form select,
.checklist-form input {
  min-height: 36px;
}

.requirement-state {
  display: inline-block;
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.requirement-missing {
  color: #812020;
  background: #f8dddd;
}

.requirement-present {
  color: #0d5d31;
  background: #dff2e6;
}

.requirement-waived {
  color: #4d5750;
  background: #e9eeea;
}

.empty-checklist {
  display: grid;
  min-height: 92px;
  place-items: center;
  border-top: 1px solid var(--line);
}

@media (max-width: 900px) {
  .page-heading,
  .document-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .create-period,
  .heading-actions {
    flex-wrap: wrap;
  }

  .document-layout {
    grid-template-columns: 1fr;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .create-user-panel {
    grid-row: 1;
  }

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

  .preview-panel iframe,
  .preview-panel img {
    min-height: 520px;
  }
}

@media (max-width: 640px) {
  .app-header {
    align-items: flex-start;
  }

  .account > div {
    display: none;
  }

  .header-nav {
    display: none;
  }

  .page {
    padding-top: 22px;
  }

  h1 {
    font-size: 24px;
  }

  .inline-form,
  .filters,
  .upload-form {
    align-items: stretch;
    flex-direction: column;
  }

  .create-period input,
  .create-period select,
  .filters label:first-child,
  .filters label:nth-child(2),
  .file-picker {
    width: 100%;
    min-width: 0;
  }

  .heading-actions {
    display: grid;
  }

  .heading-actions .button,
  .heading-actions form,
  .heading-actions form .button,
  .upload-form .button,
  .filters .button {
    width: 100%;
  }

  .login-panel {
    padding: 26px 22px;
  }

  .document-layout {
    margin-inline: -16px;
  }

  .credential-panel,
  .row-form {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-form .button,
  .row-form .button,
  .inline-create-form .button {
    width: 100%;
  }

  .inline-create-form,
  .requirement-create-form,
  .checklist-form {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    padding: 10px;
  }

  .preview-panel iframe,
  .preview-panel img {
    min-height: 420px;
  }
}
