:root {
  color-scheme: light;
  --ink: #16212b;
  --muted: #667381;
  --line: #dbe2e6;
  --soft: #f5f7f8;
  --white: #ffffff;
  --teal: #2c8f8b;
  --teal-dark: #176d69;
  --teal-soft: #dff2ef;
  --coral: #d96c5f;
  --shadow: 0 18px 45px rgba(29, 43, 54, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: #eef2f3;
  color: var(--ink);
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.quality-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(260px, 1fr);
  align-items: center;
  gap: 20px;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 7px 18px;
  backdrop-filter: blur(16px);
}

.quality-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 950;
  text-decoration: none;
  text-transform: uppercase;
}

.quality-brand img {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  object-fit: cover;
}

.quality-nav {
  display: flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
  padding: 4px;
}

.quality-nav a {
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  padding: 7px 11px;
  text-decoration: none;
}

.quality-nav a:hover,
.quality-nav a.active {
  background: var(--white);
  color: var(--teal-dark);
  box-shadow: 0 2px 8px rgba(29, 43, 54, 0.08);
}

.quality-account {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.quality-account strong {
  font-size: 0.82rem;
}

.quality-account small {
  color: var(--muted);
  font-size: 0.72rem;
}

.quality-account button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0 11px;
}

.quality-workspace {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.quality-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal-dark);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.quality-heading h1 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 3.3rem);
  line-height: 1;
}

.quality-heading > div > p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
}

.document-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.button,
.inline-button,
.add-row-button {
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 850;
}

.button {
  min-height: 42px;
  padding: 9px 14px;
}

.button.primary {
  background: var(--teal);
  color: var(--white);
}

.button.primary:hover {
  background: var(--teal-dark);
}

.button.secondary {
  border-color: var(--line);
  background: var(--white);
  color: var(--ink);
}

.button.print-button {
  background: var(--ink);
  color: var(--white);
}

.button.download-button {
  border-color: var(--teal);
  background: var(--white);
  color: var(--teal-dark);
}

.button.download-button:hover {
  background: var(--teal-soft);
}

.status-message {
  min-height: 22px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.status-message.success {
  color: #16704d;
}

.status-message.error {
  color: #a33b35;
}

.quality-settings {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 14px;
  margin-bottom: 18px;
}

.settings-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  box-shadow: 0 8px 26px rgba(29, 43, 54, 0.05);
  padding: 17px;
}

.settings-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.settings-title h2 {
  margin: 0;
  font-size: 1.12rem;
}

.save-state {
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 0.72rem;
  font-weight: 850;
  padding: 5px 9px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.settings-grid label,
.reuse-row label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.settings-grid label > span,
.reuse-row label > span,
.template-action > span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.settings-grid .wide-field {
  grid-column: span 2;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd9df;
  border-radius: 7px;
  background: var(--white);
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 40px;
  padding: 8px 10px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(44, 143, 139, 0.12);
}

.template-action {
  display: grid;
  align-content: end;
  gap: 5px;
}

.template-admin-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  border: 1px dashed rgba(44, 143, 139, 0.45);
  border-radius: 10px;
  background: rgba(223, 242, 239, 0.48);
  padding: 12px;
}

.template-admin-panel p {
  margin: 0;
}

.template-admin-panel .eyebrow {
  margin-bottom: 4px;
}

.template-admin-panel p:last-child {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.template-save-button {
  min-width: 210px;
}

.inline-button {
  min-height: 40px;
  border-color: rgba(44, 143, 139, 0.35);
  background: var(--teal-soft);
  color: var(--teal-dark);
  padding: 8px 10px;
}

.reuse-row {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto auto;
  align-items: end;
  gap: 8px;
}

.settings-help {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.quality-paper {
  width: min(1120px, 100%);
  min-height: 297mm;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  box-shadow: var(--shadow);
  padding: 24px;
}

.paper-header {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 3px solid var(--teal);
}

.paper-header img {
  display: block;
  width: 100px;
  height: auto;
}

.paper-kicker {
  margin: 0 0 3px;
  color: var(--teal-dark);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.paper-header h2 {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.05;
}

.paper-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-weight: 750;
}

.paper-meta {
  display: grid;
  min-width: 145px;
  gap: 5px;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  padding: 12px 14px;
  text-align: right;
}

.paper-meta span {
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.paper-meta strong {
  font-size: 0.84rem;
}

.paper-information {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.paper-information > div {
  display: grid;
  gap: 4px;
  min-height: 66px;
  border-right: 1px solid var(--line);
  padding: 10px 12px;
}

.paper-information > div:last-child {
  border-right: 0;
}

.paper-information span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.paper-information strong {
  align-self: end;
  font-size: 0.9rem;
}

.key-dates-section {
  margin: 16px 0;
}

.key-dates-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.key-dates-heading h3 {
  margin: 0;
  font-size: 1.2rem;
}

.add-key-date-button {
  min-height: 36px;
  border: 1px solid #bfd2d2;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  cursor: pointer;
  font-weight: 850;
  padding: 7px 12px;
}

.key-dates-list {
  display: grid;
  gap: 7px;
}

.key-date-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.15fr) minmax(145px, 0.6fr) minmax(200px, 1.25fr) 34px;
  align-items: end;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  padding: 8px;
}

.key-date-row label {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.key-date-row label > span {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 850;
  text-transform: uppercase;
}

.key-date-row input {
  min-height: 36px;
  background: var(--white);
}

.delete-key-date {
  width: 34px;
  height: 36px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 900;
}

.delete-key-date:hover {
  background: #fff0ed;
  color: #a33b35;
}

.checklist-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.checklist-heading h3 {
  margin: 0;
  font-size: 1.2rem;
}

.checklist-heading > p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.quality-table-wrap {
  border: 1px solid #cbd7dc;
  border-radius: 8px;
  overflow: hidden;
}

.quality-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.step-column {
  width: 57%;
}

.validation-column {
  width: 12%;
}

.row-action-column {
  width: 7%;
}

.quality-table th {
  height: 46px;
  background: var(--teal);
  color: var(--white);
  font-size: 0.78rem;
  padding: 8px;
  text-align: center;
}

.quality-table th:first-child {
  padding-left: 14px;
  text-align: left;
}

.quality-table td {
  height: 52px;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: var(--white);
  padding: 0;
}

.quality-table tbody tr:nth-child(even) td {
  background: #f8fafb;
}

.quality-table td:last-child {
  border-right: 0;
}

.step-input {
  display: block;
  min-height: 50px;
  resize: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.35;
  overflow: hidden;
  padding: 14px;
}

.step-input:focus {
  background: #f3fbfa;
  box-shadow: inset 0 0 0 2px var(--teal);
}

.check-cell {
  text-align: center;
  vertical-align: middle;
}

.quality-check {
  position: relative;
  display: inline-grid;
  width: 34px;
  height: 34px;
  cursor: pointer;
  place-items: center;
}

.quality-check input {
  position: absolute;
  width: 34px;
  min-height: 34px;
  margin: 0;
  appearance: none;
  border: 2px solid #aebdc5;
  border-radius: 7px;
  background: var(--white);
  cursor: pointer;
  padding: 0;
}

.quality-check input:checked {
  border-color: var(--teal);
  background: var(--teal);
}

.quality-check span {
  position: relative;
  z-index: 1;
  color: transparent;
  font-size: 1.2rem;
  font-weight: 950;
  pointer-events: none;
}

.quality-check input:checked + span {
  color: var(--white);
}

.row-actions {
  white-space: nowrap;
  text-align: center;
}

.row-actions button {
  width: 24px;
  height: 28px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
  padding: 0;
}

.row-actions button:hover {
  background: #e8eef1;
  color: var(--ink);
}

.row-actions .delete-row:hover {
  background: #fff0ed;
  color: #a33b35;
}

.add-row-button {
  min-height: 38px;
  margin-top: 9px;
  border-color: #bfd2d2;
  background: var(--teal-soft);
  color: var(--teal-dark);
  padding: 7px 13px;
}

.paper-notes {
  display: grid;
  gap: 7px;
  margin-top: 18px;
}

.paper-notes label {
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.paper-notes textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.45;
  padding: 11px 12px;
}

.paper-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  padding-top: 9px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 1050px) {
  .quality-topbar {
    grid-template-columns: auto 1fr;
  }

  .quality-nav {
    justify-self: end;
  }

  .quality-account {
    grid-column: 1 / -1;
    justify-self: stretch;
    justify-content: flex-end;
    border-top: 1px solid var(--line);
    padding-top: 6px;
  }

  .quality-settings {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .quality-topbar {
    position: static;
    grid-template-columns: 1fr;
  }

  .quality-brand,
  .quality-nav,
  .quality-account {
    grid-column: 1;
    justify-self: stretch;
  }

  .quality-brand {
    justify-content: center;
  }

  .quality-nav {
    overflow-x: auto;
  }

  .quality-nav a {
    flex: 1 0 auto;
    text-align: center;
  }

  .quality-account {
    justify-content: space-between;
  }

  .quality-account > span {
    text-align: left;
  }

  .quality-workspace {
    padding: 12px;
  }

  .quality-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .document-actions {
    justify-content: stretch;
  }

  .document-actions .button {
    flex: 1 1 140px;
  }

  .settings-grid,
  .reuse-row {
    grid-template-columns: 1fr;
  }

  .template-admin-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .template-save-button {
    min-width: 0;
  }

  .settings-grid .wide-field {
    grid-column: auto;
  }

  .quality-paper {
    min-height: 0;
    padding: 14px;
  }

  .paper-header {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .paper-header img {
    width: 68px;
  }

  .paper-meta {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
    text-align: left;
  }

  .paper-information {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .paper-information > div:nth-child(2) {
    border-right: 0;
  }

  .paper-information > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .key-date-row {
    grid-template-columns: 1fr 1fr;
  }

  .key-date-row label:last-of-type {
    grid-column: 1 / -1;
  }

  .quality-table-wrap {
    overflow-x: auto;
  }

  .quality-table {
    min-width: 680px;
  }
}

@page {
  size: A4 portrait;
  margin: 10mm;
}

.pdf-export-mode .screen-only {
  display: none !important;
}

.pdf-export-mode .quality-paper {
  position: relative;
  width: 190mm;
  min-height: 277mm;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}

.pdf-export-mode .paper-header {
  grid-template-columns: 26mm minmax(0, 1fr) 40mm;
  gap: 5mm;
  padding-bottom: 4mm;
}

.pdf-export-mode .paper-header img {
  width: 25mm;
}

.pdf-export-mode .paper-header h2 {
  font-size: 18pt;
}

.pdf-export-mode .paper-meta {
  grid-column: auto;
  grid-template-columns: 1fr;
  text-align: right;
}

.pdf-export-mode .paper-information {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 4mm 0;
}

.pdf-export-mode .paper-information > div {
  min-height: 16mm;
  border-right: 1px solid var(--line);
  border-bottom: 0;
  padding: 2.5mm 3mm;
}

.pdf-export-mode .paper-information > div:last-child {
  border-right: 0;
}

.pdf-export-mode .key-dates-section {
  margin: 3mm 0;
}

.pdf-export-mode .key-dates-heading {
  margin-bottom: 1.5mm;
}

.pdf-export-mode .key-dates-heading h3 {
  font-size: 11pt;
}

.pdf-export-mode .key-date-row {
  grid-template-columns: 40mm 31mm minmax(0, 1fr);
  gap: 2mm;
  border-radius: 0;
  padding: 1.5mm 2mm;
}

.pdf-export-mode .key-date-row label {
  gap: 0.5mm;
}

.pdf-export-mode .key-date-row label:last-of-type {
  grid-column: auto;
}

.pdf-export-mode .key-date-row label > span {
  font-size: 6.5pt;
}

.pdf-export-mode .key-date-row input {
  appearance: none;
  min-height: 7mm;
  border: 0;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none;
  font-size: 8pt;
  padding: 0;
}

.pdf-export-mode .quality-table-wrap {
  border-radius: 0;
  overflow: visible;
}

.pdf-export-mode .quality-table {
  min-width: 0;
}

.pdf-export-mode .step-column {
  width: 61%;
}

.pdf-export-mode .validation-column {
  width: 13%;
}

.pdf-export-mode .quality-table th {
  height: 10mm;
  font-size: 8pt;
}

.pdf-export-mode .quality-table td {
  height: 11mm;
}

.pdf-export-mode .step-input {
  appearance: none;
  min-height: 10mm;
  border: 0;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none;
  font-size: 8.5pt;
  padding: 2.5mm 3mm;
}

.pdf-export-mode .step-input::placeholder,
.pdf-export-mode .key-date-row input::placeholder,
.pdf-export-mode .paper-notes textarea::placeholder {
  color: transparent;
}

.pdf-export-mode .quality-check,
.pdf-export-mode .quality-check input {
  width: 7mm;
  height: 7mm;
  min-height: 7mm;
}

.pdf-export-mode .quality-check input {
  background: #ffffff !important;
}

.pdf-export-mode .quality-check input:checked {
  background: var(--teal) !important;
}

.pdf-export-mode .quality-check span {
  font-size: 12pt;
}

.pdf-export-mode .paper-notes {
  margin-top: 4mm;
}

.pdf-export-mode .paper-notes textarea {
  appearance: none;
  min-height: 24mm;
  border: 1px solid var(--line);
  border-radius: 0 !important;
  background: #ffffff !important;
  box-shadow: none;
  resize: none;
  font-size: 8.5pt;
}

.pdf-export-mode .paper-footer {
  position: absolute;
  right: 0;
  bottom: 4mm;
  left: 0;
  margin-top: 0;
  padding-top: 2mm;
}

@media print {
  :root {
    --line: #c5cdd1;
  }

  body {
    min-width: 0;
    background: var(--white);
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .screen-only,
  .quality-topbar {
    display: none !important;
  }

  .quality-workspace {
    width: auto;
    margin: 0;
    padding: 0;
  }

  .quality-paper {
    width: 100%;
    min-height: auto;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }

  .paper-header {
    grid-template-columns: 26mm minmax(0, 1fr) 40mm;
    gap: 5mm;
    padding-bottom: 4mm;
  }

  .paper-header img {
    width: 25mm;
  }

  .paper-header h2 {
    font-size: 18pt;
  }

  .paper-meta {
    grid-column: auto;
    grid-template-columns: 1fr;
    text-align: right;
  }

  .paper-information {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 4mm 0;
  }

  .paper-information > div {
    min-height: 16mm;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    padding: 2.5mm 3mm;
  }

  .paper-information > div:last-child {
    border-right: 0;
  }

  .key-dates-section {
    margin: 3mm 0;
  }

  .key-dates-heading {
    margin-bottom: 1.5mm;
  }

  .key-dates-heading h3 {
    font-size: 11pt;
  }

  .key-date-row {
    grid-template-columns: 40mm 31mm minmax(0, 1fr);
    gap: 2mm;
    border-radius: 0;
    padding: 1.5mm 2mm;
  }

  .key-date-row label {
    gap: 0.5mm;
  }

  .key-date-row label:last-of-type {
    grid-column: auto;
  }

  .key-date-row label > span {
    font-size: 6.5pt;
  }

  .key-date-row input {
    min-height: 7mm;
    border: 0;
    background: transparent;
    box-shadow: none;
    font-size: 8pt;
    padding: 0;
  }

  .checklist-heading {
    margin-bottom: 2mm;
  }

  .quality-table-wrap {
    border-radius: 0;
    overflow: visible;
  }

  .quality-table {
    min-width: 0;
  }

  .step-column {
    width: 61%;
  }

  .validation-column {
    width: 13%;
  }

  .quality-table th {
    height: 10mm;
    font-size: 8pt;
  }

  .quality-table td {
    height: 11mm;
  }

  .step-input {
    min-height: 10mm;
    font-size: 8.5pt;
    padding: 2.5mm 3mm;
  }

  .step-input::placeholder,
  .key-date-row input::placeholder,
  .paper-notes textarea::placeholder {
    color: transparent;
  }

  .quality-check,
  .quality-check input {
    width: 7mm;
    height: 7mm;
    min-height: 7mm;
  }

  .quality-check span {
    font-size: 12pt;
  }

  .paper-notes {
    margin-top: 4mm;
  }

  .paper-notes textarea {
    min-height: 24mm;
    resize: none;
    font-size: 8.5pt;
  }

  .paper-footer {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    margin-top: 0;
    padding-top: 2mm;
  }

  tr,
  .paper-information,
  .key-date-row,
  .paper-notes {
    break-inside: avoid;
  }
}
