:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --panel-soft: #f7f9fb;
  --ink: #17202c;
  --muted: #627084;
  --line: #d9e0e8;
  --line-strong: #b9c3cf;
  --blue: #1f5f99;
  --blue-dark: #16446f;
  --green: #16745a;
  --amber: #9b6515;
  --red: #b42318;
  --shadow: 0 18px 48px rgba(31, 45, 61, 0.16);
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1,
.preview-toolbar h2,
.form-section h2,
.self-test-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.2;
}

.brand p,
.eyebrow {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.eyebrow {
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.segmented-button,
.ghost-button,
.primary-button,
.secondary-button,
.mini-button,
.suggest-button,
.icon-button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 13px;
  font-weight: 700;
  letter-spacing: 0;
}

.segmented-button {
  min-width: 82px;
  background: transparent;
  color: var(--muted);
}

.segmented-button.is-active {
  background: var(--ink);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(23, 32, 44, 0.18);
}

.ghost-button,
.secondary-button,
.mini-button,
.suggest-button {
  background: #ffffff;
  border-color: var(--line-strong);
  color: var(--ink);
}

.primary-button {
  background: var(--blue);
  color: #ffffff;
  border-color: var(--blue);
}

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

.secondary-button {
  width: 100%;
}

.mini-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.suggest-button {
  min-height: 30px;
  padding: 0 9px;
  color: var(--blue-dark);
  font-size: 12px;
  white-space: nowrap;
}

.icon-button {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  background: #fff7f6;
  color: var(--red);
  border-color: #f2b8b5;
  font-size: 18px;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.control-panel {
  height: calc(100vh - 74px);
  overflow: auto;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--panel-soft);
}

.preview-panel {
  min-width: 0;
  height: calc(100vh - 74px);
  overflow: auto;
  padding: 18px 28px 34px;
  background:
    linear-gradient(90deg, rgba(217, 224, 232, 0.55) 1px, transparent 1px),
    linear-gradient(180deg, rgba(217, 224, 232, 0.55) 1px, transparent 1px),
    #e8edf3;
  background-size: 24px 24px;
}

.status-panel,
.form-section,
.self-test-panel,
.preview-toolbar {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(31, 45, 61, 0.04);
}

.status-panel {
  padding: 14px;
  margin-bottom: 14px;
}

.status-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.status-meter {
  height: 8px;
  margin: 12px 0 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5eaf0;
}

.status-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 160ms ease;
}

.missing-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: var(--amber);
  font-size: 13px;
}

.missing-list .is-ok {
  color: var(--green);
}

.doc-form {
  display: grid;
  gap: 14px;
}

.form-section,
.self-test-panel {
  padding: 14px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  font-size: 15px;
}

.section-required,
.section-optional,
.test-summary {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.section-required {
  background: #fff1d8;
  color: var(--amber);
}

.section-optional {
  background: #edf4fb;
  color: var(--blue-dark);
}

.test-summary {
  background: #edf4fb;
  color: var(--muted);
}

.test-summary.is-pass {
  background: #e7f4ef;
  color: var(--green);
}

.test-summary.is-fail {
  background: #fff0ee;
  color: var(--red);
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: #344155;
  font-size: 13px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  padding: 9px 10px;
  font-weight: 500;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 95, 153, 0.14);
}

input:disabled {
  background: #edf1f5;
  color: var(--muted);
}

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

.helper-text {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.directive-tools {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.directive-picker {
  display: grid;
  gap: 10px;
}

.directive-group {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.directive-group:first-child {
  padding-top: 0;
  border-top: 0;
}

.directive-group h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.directive-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.directive-option {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  margin: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  font-weight: 500;
}

.directive-option input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  padding: 0;
}

.directive-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.directive-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.directive-detail {
  color: var(--muted);
  font-size: 12px;
}

.standards-rows {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.standard-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.75fr) minmax(160px, 1fr) 34px;
  align-items: end;
  gap: 8px;
}

.standard-row label {
  margin-bottom: 0;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
}

.body-fields {
  display: block;
}

.body-fields.is-disabled {
  opacity: 0.65;
}

.self-test-panel {
  margin-top: 14px;
}

.test-results {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.test-results li {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 7px 8px;
  border-radius: var(--radius);
  background: var(--panel-soft);
  font-size: 12px;
}

.test-results span {
  font-weight: 900;
}

.test-results p {
  margin: 0;
}

.test-results .pass span {
  color: var(--green);
}

.test-results .fail span {
  color: var(--red);
}

.preview-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: 210mm;
  margin: 0 auto 18px;
  padding: 12px 14px;
}

.preview-toolbar h2 {
  font-size: 18px;
}

.preview-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.preview-badges span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: #e7f4ef;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.preview-badges span:first-child {
  background: var(--ink);
  color: #ffffff;
}

.preview-badges .is-warning {
  background: #fff1d8;
  color: var(--amber);
}

.document-preview {
  display: flex;
  justify-content: center;
  padding-bottom: 36px;
}

.doc-page {
  position: relative;
  width: 210mm;
  min-height: 297mm;
  padding: 18mm 17mm 16mm;
  background: #ffffff;
  color: #151b24;
  box-shadow: var(--shadow);
  font-family: "Times New Roman", Times, serif;
  font-size: 11.5pt;
  line-height: 1.32;
}

.draft-ribbon {
  position: absolute;
  top: 9mm;
  right: -17mm;
  width: 64mm;
  transform: rotate(35deg);
  background: #fff1d8;
  color: var(--amber);
  border: 1px solid #e8c47d;
  padding: 3px 0;
  text-align: center;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8pt;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.doc-header {
  display: grid;
  grid-template-columns: 28mm minmax(0, 1fr);
  gap: 8mm;
  align-items: start;
  padding-bottom: 7mm;
  border-bottom: 2px solid #151b24;
}

.doc-mark {
  display: grid;
  place-items: center;
  min-height: 21mm;
  border: 2px solid #151b24;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 18pt;
  font-weight: 900;
  letter-spacing: 0;
}

.doc-title-block {
  min-width: 0;
}

.doc-kicker {
  margin: 0 0 2mm;
  color: #536070;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8.5pt;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.doc-title-block h2 {
  margin: 0;
  font-size: 22pt;
  line-height: 1.05;
  letter-spacing: 0;
}

.doc-number {
  margin: 3mm 0 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 9pt;
  color: #344155;
}

.doc-section {
  padding-top: 5mm;
  break-inside: avoid;
}

.doc-section h3 {
  margin: 0 0 2.5mm;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 10.5pt;
  letter-spacing: 0;
}

.legal-statement {
  margin: 0;
}

.doc-fields {
  display: grid;
  grid-template-columns: 39mm minmax(0, 1fr);
  gap: 1.8mm 4mm;
  margin: 0;
}

.doc-field {
  display: contents;
}

.doc-field dt {
  color: #536070;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8.5pt;
  font-weight: 800;
}

.doc-field dd {
  margin: 0;
  min-width: 0;
  white-space: pre-line;
}

.doc-missing {
  color: var(--red);
  font-weight: 700;
}

.doc-missing.block {
  margin: 0;
}

.legislation-list {
  display: grid;
  gap: 1.8mm;
  margin: 3mm 0 0;
  padding-left: 5mm;
}

.legislation-list li strong {
  display: block;
}

.legislation-list li span {
  display: block;
  color: #536070;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8.5pt;
}

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

.standards-table th,
.standards-table td {
  border: 1px solid #9aa7b6;
  padding: 2mm;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}

.standards-table th {
  background: #edf1f5;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8.5pt;
}

.standards-table th:first-child,
.standards-table td:first-child {
  width: 38%;
}

.signature-line {
  display: flex;
  align-items: flex-end;
  width: 72mm;
  height: 17mm;
  margin-top: 5mm;
  border-bottom: 1px solid #151b24;
}

.signature-line span {
  color: #536070;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8.5pt;
}

.doc-footer {
  margin-top: 8mm;
  padding-top: 4mm;
  border-top: 1px solid #9aa7b6;
  color: #536070;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8pt;
}

.doc-footer p {
  margin: 0 0 1.5mm;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel,
  .preview-panel {
    height: auto;
    min-height: 0;
  }

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

@media (max-width: 760px) {
  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .brand {
    width: 100%;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .workspace {
    display: block;
  }

  .control-panel,
  .preview-panel {
    padding: 12px;
  }

  .field-grid,
  .directive-row,
  .standard-row {
    grid-template-columns: 1fr;
  }

  .icon-button {
    width: 100%;
  }

  .preview-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .document-preview {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .doc-page {
    flex: 0 0 210mm;
  }
}
