:root {
  --ink: #17211d;
  --muted: #5f6b64;
  --soft: #eef2ed;
  --paper: #ffffff;
  --line: #d8ded7;
  --green: #1f6f64;
  --green-dark: #154e47;
  --blue: #2459a6;
  --amber: #bf7f10;
  --red: #b33a3a;
  --shadow: 0 18px 50px rgba(23, 33, 29, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  color: var(--ink);
  background: #f5f7f4;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 86px;
  padding: 14px 28px;
  border-bottom: 1px solid rgba(216, 222, 215, 0.9);
  background: rgba(248, 250, 247, 0.95);
  backdrop-filter: blur(14px);
}

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

.brand-mark {
  flex: 0 0 auto;
  filter: drop-shadow(0 8px 18px rgba(23, 33, 29, 0.12));
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: var(--green-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: 1.1rem;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.top-actions,
.inline-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.button,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 13px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
  box-shadow: 0 1px 0 rgba(23, 33, 29, 0.04);
}

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

.button.secondary,
.file-button {
  border-color: var(--line);
}

.button.quiet {
  min-height: 34px;
  padding: 7px 10px;
  border-color: transparent;
  background: transparent;
  color: var(--green-dark);
}

.button.danger {
  border-color: rgba(179, 58, 58, 0.35);
  color: var(--red);
}

.button:hover,
.file-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(23, 33, 29, 0.1);
}

.button:focus-visible,
.file-button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(36, 89, 166, 0.32);
  outline-offset: 2px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(560px, 1.02fr) minmax(420px, 0.98fr);
  gap: 24px;
  width: min(1780px, calc(100% - 40px));
  margin: 24px auto 32px;
}

.editor,
.outputs {
  min-width: 0;
}

.notice {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(191, 127, 16, 0.35);
  border-left: 5px solid var(--amber);
  border-radius: 8px;
  background: #fff9ec;
  color: #4a3a1e;
}

.panel,
.output-card {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 28px rgba(23, 33, 29, 0.06);
}

.panel {
  padding: 18px;
}

.output-card {
  padding: 16px;
}

.panel-head,
.output-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-head.compact {
  align-items: center;
  margin-bottom: 12px;
}

.panel-head.split {
  align-items: center;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #edf7f4;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.status-pill.warn {
  background: #fff2de;
  color: #7b4b00;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

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

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-weight: 550;
}

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

textarea {
  resize: vertical;
  padding: 10px;
}

.table-shell {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.editable-table {
  width: 100%;
  min-width: 950px;
  border-collapse: collapse;
  table-layout: fixed;
}

.editable-table th {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #f2f6f1;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: left;
  text-transform: uppercase;
}

.editable-table td {
  padding: 10px;
  border-top: 1px solid #edf0ec;
  vertical-align: top;
}

.editable-table th:nth-child(1),
.editable-table td:nth-child(1) {
  width: 86px;
}

.editable-table th:nth-child(2),
.editable-table td:nth-child(2) {
  width: 290px;
}

.editable-table th:nth-child(3),
.editable-table td:nth-child(3) {
  width: 130px;
}

.editable-table th:nth-child(5),
.editable-table td:nth-child(5) {
  width: 86px;
}

.editable-table textarea {
  min-height: 82px;
}

.editable-table .compact-input {
  min-height: 36px;
}

.risk-table {
  min-width: 1040px;
}

.risk-table th,
.risk-table td {
  width: 15%;
}

.risk-table th:nth-child(5),
.risk-table td:nth-child(5) {
  width: 25%;
}

.risk-table th:nth-child(7),
.risk-table td:nth-child(7) {
  width: 78px;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.outputs {
  position: sticky;
  top: 110px;
  align-self: start;
  max-height: calc(100vh - 124px);
  overflow-y: auto;
  padding-right: 4px;
}

.output-toolbar {
  align-items: center;
  padding: 16px 0 0;
}

.code-output {
  min-height: 168px;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre;
}

.json-output {
  min-height: 250px;
}

.tests-card {
  border-color: rgba(36, 89, 166, 0.28);
}

.test-summary {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin-bottom: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-weight: 800;
}

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

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

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

.test-results li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 0.88rem;
}

.test-results .pass {
  color: var(--green-dark);
  font-weight: 850;
}

.test-results .fail {
  color: var(--red);
  font-weight: 850;
}

.file-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.document-preview {
  display: grid;
  gap: 18px;
  margin-bottom: 40px;
}

.paper {
  width: 100%;
  min-height: 840px;
  padding: 42px;
  border: 1px solid #d9d9d4;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.paper h2 {
  margin-bottom: 18px;
  font-size: 1.55rem;
}

.paper h3 {
  margin: 24px 0 8px;
  color: var(--green-dark);
  font-size: 1rem;
}

.paper p,
.paper li {
  color: #2b3731;
}

.doc-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: start;
  margin-bottom: 26px;
  padding-bottom: 18px;
  border-bottom: 2px solid #1d342f;
}

.ce-mark {
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  border: 3px solid #1d342f;
  border-radius: 50%;
  color: #1d342f;
  font-size: 2rem;
  font-weight: 900;
}

.doc-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 20px;
}

.meta-box {
  padding: 10px 12px;
  border: 1px solid #dde3dc;
  border-radius: 7px;
  background: #fbfcfb;
}

.meta-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.87rem;
}

.doc-table th,
.doc-table td {
  padding: 9px 10px;
  border: 1px solid #dde3dc;
  text-align: left;
  vertical-align: top;
}

.doc-table th {
  background: #f2f6f1;
  color: #405048;
}

.signature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 26px;
}

.signature-line {
  min-height: 72px;
  padding-top: 42px;
  border-bottom: 1px solid #1d342f;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  justify-content: center;
  padding: 18px 24px 32px;
  color: var(--muted);
  font-size: 0.86rem;
}

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

  .outputs {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 760px) {
  .topbar,
  .brand,
  .top-actions,
  .panel-head,
  .output-toolbar,
  .doc-header,
  .signature-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
    padding: 18px;
  }

  .workspace {
    width: calc(100% - 24px);
    margin-top: 12px;
  }

  .form-grid,
  .doc-meta {
    grid-template-columns: 1fr;
  }

  .paper {
    padding: 24px;
  }
}

@media print {
  @page {
    size: A4;
    margin: 14mm;
  }

  html,
  body {
    background: #fff;
  }

  .topbar,
  .editor,
  .output-toolbar,
  .output-card,
  .site-footer {
    display: none !important;
  }

  .workspace,
  .outputs,
  #printArea {
    display: block !important;
    width: auto !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  body[data-print="doc"] #packOutput {
    display: none !important;
  }

  .paper {
    display: block !important;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    break-after: page;
  }

  .paper:last-child {
    break-after: auto;
  }

  .button {
    display: none !important;
  }
}
