:root {
  color-scheme: light;
  --ink: #1f242b;
  --ink-soft: #5f6266;
  --navy: #2d3034;
  --teal: #f89921;
  --teal-dark: #c96d12;
  --aqua: #fff1df;
  --lime: #f89921;
  --canvas: #f1f2f2;
  --paper: #ffffff;
  --line: #d9dada;
  --line-strong: #b9bbbd;
  --orange: #f89921;
  --amber: #f6c657;
  --red: #b64949;
  --shadow: 0 22px 60px rgba(31, 36, 43, 0.14);
  --radius: 14px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--canvas);
  color: var(--ink);
  overflow: hidden;
}

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

button {
  color: inherit;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: -80px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.skip-link:focus {
  top: 12px;
}

.app-header {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: #fff;
  color: var(--ink);
  border-bottom: 3px solid var(--teal);
}

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

.brand-lockup > span:last-child {
  display: grid;
  gap: 2px;
}

.brand-lockup strong {
  font-size: 15px;
  letter-spacing: 0.01em;
}

.brand-lockup small {
  color: #7a7d80;
  font-size: 11px;
}

.brand-logo {
  width: 112px;
  height: auto;
  display: block;
}

.header-actions,
.button-row,
.preview-toolbar,
.zoom-controls {
  display: flex;
  align-items: center;
}

.header-actions {
  gap: 8px;
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: 6px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #666a6d;
  font-size: 11px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 4px rgba(248, 153, 33, 0.14);
}

.button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button:focus-visible,
.step-tab:focus-visible,
.zoom-controls button:focus-visible,
.row-action:focus-visible,
[contenteditable="true"]:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(248, 153, 33, 0.3);
  outline-offset: 2px;
}

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

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

.button.ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: inherit;
}

.control-panel .button.ghost {
  color: var(--ink);
  border-color: var(--line);
}

.button.grow {
  flex: 1;
}

.workspace {
  height: calc(100vh - 72px);
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(350px, 420px) minmax(0, 1fr);
  overflow: hidden;
}

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

.control-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #f7f7f7;
  border-right: 1px solid var(--line);
}

.stepper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 14px 14px 0;
  border-bottom: 1px solid var(--line);
}

.step-tab {
  position: relative;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 10px 4px 13px;
  border: 0;
  background: transparent;
  color: #71818d;
  font-size: 10px;
  font-weight: 750;
  cursor: pointer;
}

.step-tab span {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e4e9e8;
  font-size: 9px;
}

.step-tab::after {
  content: "";
  position: absolute;
  inset: auto 10px -1px;
  height: 2px;
  border-radius: 2px;
  background: transparent;
}

.step-tab.active {
  color: var(--ink);
}

.step-tab.active span {
  background: var(--aqua);
  color: var(--teal-dark);
}

.step-tab.active::after {
  background: var(--teal);
}

.panel-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 24px 22px 38px;
}

.panel-body[hidden] {
  display: none;
}

.panel-heading {
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.panel-heading h1,
.panel-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 27px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.025em;
}

.panel-heading p:last-child {
  margin: 9px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.55;
}

.paste-launch {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 18px;
  border: 1px dashed #95abae;
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.paste-launch:hover,
.paste-launch:focus-visible {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(248, 153, 33, 0.1);
}

.paste-launch strong,
.paste-launch small {
  display: block;
}

.paste-launch strong {
  font-size: 13px;
}

.paste-launch small {
  margin-top: 3px;
  color: #778994;
  font-size: 10px;
}

.paste-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--aqua);
  color: var(--teal-dark);
  font-size: 20px;
  font-weight: 800;
}

.import-paste-step textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f8;
  color: #304454;
  font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.import-dialog {
  width: min(1120px, calc(100vw - 36px));
  max-width: none;
  height: min(860px, calc(100dvh - 36px));
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  background: #f7f7f7;
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(31, 36, 43, 0.32);
}

.import-dialog::backdrop {
  background: rgba(31, 36, 43, 0.58);
  backdrop-filter: blur(3px);
}

.import-dialog-frame {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.import-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.import-dialog-header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
  line-height: 1.1;
}

.import-dialog-header p:last-child {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
}

.dialog-close {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: #677985;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.import-paste-step {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #f7f7f7;
}

.import-paste-step > label {
  display: block;
  margin-bottom: 7px;
  color: #586c79;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.import-paste-step .button-row {
  justify-content: space-between;
}

.modal-status {
  color: #637580;
  font-size: 10px;
}

.import-interpretation {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 24px 18px;
}

.import-interpretation[hidden] {
  display: none;
}

.interpretation-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0 10px;
}

.interpretation-toolbar strong,
.interpretation-toolbar small {
  display: block;
}

.interpretation-toolbar strong {
  font-size: 12px;
}

.interpretation-toolbar small {
  margin-top: 3px;
  color: #73848f;
  font-size: 9px;
}

.header-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #425764;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.header-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mini-check {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border: 1px solid #9badb1;
  border-radius: 50%;
  color: transparent;
  font-size: 10px;
  line-height: 1;
}

.header-toggle input:checked + .mini-check {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.header-toggle:focus-within {
  outline: 3px solid rgba(248, 153, 33, 0.24);
  outline-offset: 2px;
}

.import-grid-wrap {
  flex: 1;
  min-height: 160px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  scrollbar-gutter: stable;
}

.import-grid {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 10px;
}

.import-grid th,
.import-grid td {
  min-width: 125px;
  max-width: 280px;
  padding: 8px 10px;
  border-right: 1px solid #dce2e3;
  border-bottom: 1px solid #dce2e3;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--ink);
  color: #fff;
  font-size: 9px;
}

.import-grid .selection-cell {
  left: 0;
  z-index: 3;
  min-width: 72px;
  width: 72px;
  max-width: 72px;
  background: #f0f4f3;
  color: #586b77;
  text-align: center;
}

.import-grid thead .selection-cell {
  background: var(--ink);
  color: #fff;
}

.import-grid tbody .selection-cell {
  position: sticky;
}

.import-grid th label,
.import-grid td label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.import-column-control {
  display: grid;
  grid-template-columns: auto minmax(100px, 1fr);
  align-items: center;
  gap: 7px;
}

.import-column-check {
  position: relative;
}

.import-header-input {
  width: 100%;
  min-width: 100px;
  padding: 5px 7px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font: inherit;
  font-weight: 700;
}

.import-header-input:focus {
  border-color: var(--orange);
  background: #fff;
  color: var(--ink);
  outline: 2px solid rgba(248, 153, 33, 0.25);
}

.import-type-hint {
  display: block;
  margin-top: 3px;
  color: #b8c2c7;
  font-size: 7px;
  font-weight: 600;
  text-transform: uppercase;
}

.import-grid th.excluded .import-header-input {
  color: #96a2a8;
  text-decoration: line-through;
}

.import-grid tr.excluded td:not(.selection-cell),
.import-grid th.excluded,
.import-grid td.excluded {
  background: #f0f2f2;
  color: #96a2a8;
  text-decoration: line-through;
}

.import-grid .header-row td {
  background: #fff3e4;
  color: #4d4032;
  font-weight: 750;
}

.import-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.button.dialog-secondary {
  border-color: var(--line);
  background: #fff;
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.button-row {
  gap: 8px;
  margin-top: 12px;
}

.panel-action-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.import-summary {
  min-height: 18px;
  margin-top: 10px;
  color: var(--teal-dark);
  font-size: 11px;
}

.tip-card {
  margin-top: 20px;
  padding: 14px 15px;
  border-left: 3px solid var(--orange);
  border-radius: 0 9px 9px 0;
  background: #fff6ed;
}

.tip-card strong {
  font-size: 11px;
}

.tip-card p {
  margin: 5px 0 0;
  color: #6f5a48;
  font-size: 10px;
  line-height: 1.5;
}

.field-grid,
.terms-list {
  display: grid;
  gap: 12px;
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-field > span,
.term-card label {
  color: #586c79;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.form-field input,
.form-field textarea,
.form-field select,
.term-card textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}

.form-field textarea,
.term-card textarea {
  resize: vertical;
  line-height: 1.5;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.term-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
}

.term-card > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.term-card small {
  color: #82919b;
  font-size: 9px;
}

.term-card textarea {
  min-height: 108px;
}

.special-term-card > div:first-child {
  align-items: center;
}

.empty-terms {
  padding: 22px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 11px;
  background: #fff;
  text-align: center;
}

.empty-terms strong {
  font-size: 12px;
}

.empty-terms p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.5;
}

.terms-import-dialog {
  width: min(760px, calc(100vw - 36px));
  max-width: none;
  max-height: calc(100dvh - 36px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  background: #f7f7f7;
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(31, 36, 43, 0.32);
}

.terms-import-dialog::backdrop {
  background: rgba(31, 36, 43, 0.58);
  backdrop-filter: blur(3px);
}

.terms-import-frame {
  max-height: calc(100dvh - 36px);
  display: flex;
  flex-direction: column;
}

.terms-import-body {
  min-height: 0;
  overflow: auto;
  padding: 18px 24px;
}

.terms-import-body > label {
  display: block;
  margin-bottom: 7px;
  color: #586c79;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.terms-import-body > textarea,
.terms-import-preview textarea {
  width: 100%;
  padding: 11px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.5;
}

.terms-import-preview {
  display: grid;
  gap: 9px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: imported-term;
}

.terms-import-preview[hidden] {
  display: none;
}

.terms-import-preview li {
  counter-increment: imported-term;
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: start;
  gap: 8px;
}

.terms-import-preview li::before {
  content: counter(imported-term) ".";
  grid-column: 1;
  grid-row: 1;
  margin-top: 10px;
  color: var(--teal-dark);
  font-size: 10px;
  font-weight: 800;
}

.terms-import-preview li > label {
  grid-column: 1;
  grid-row: 1;
  margin-top: 30px;
}

.terms-import-preview textarea {
  grid-column: 2;
  grid-row: 1;
}

.terms-import-preview li.excluded textarea {
  background: #eceeee;
  color: #8b9498;
  text-decoration: line-through;
}

.review-score {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 13px;
  margin-bottom: 16px;
  padding: 14px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
}

.score-number {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 4px solid var(--lime);
  font-size: 16px;
  font-weight: 850;
}

.review-score strong,
.review-score small {
  display: block;
}

.review-score strong {
  font-size: 12px;
}

.review-score small {
  margin-top: 3px;
  color: #b7c6cf;
  font-size: 10px;
  line-height: 1.4;
}

.review-list {
  display: grid;
  gap: 9px;
}

.review-export-card {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
}

.review-export-card > strong {
  font-size: 11px;
}

.review-export-card > p {
  margin: 5px 0 10px;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.45;
}

.review-export-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.review-export-actions .button {
  padding-inline: 8px;
}

.columns-dialog {
  width: min(920px, calc(100vw - 36px));
  max-width: none;
  height: min(820px, calc(100dvh - 36px));
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  background: #f7f7f7;
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(31, 36, 43, 0.32);
}

.columns-dialog::backdrop {
  background: rgba(31, 36, 43, 0.58);
  backdrop-filter: blur(3px);
}

.columns-dialog-frame {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.columns-dialog-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 24px 24px;
}

.columns-grid-header,
.column-config-row {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) 130px 100px 54px 26px;
  align-items: center;
  gap: 9px;
}

.columns-grid-header {
  padding: 0 11px 7px;
  color: #71818b;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.columns-grid {
  display: grid;
  gap: 7px;
}

.column-config-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.column-config-row.computed {
  border-left: 3px solid var(--teal);
}

.column-config-row input,
.column-config-row select {
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 11px;
}

.column-name-field small {
  display: block;
  margin-top: 4px;
  color: #839097;
  font-size: 8px;
}

.column-config-row .column-formula-input {
  margin-top: 5px;
  padding: 5px 7px;
  border-color: #e2c69f;
  background: #fffaf4;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
}

.column-name-field code,
.computed-column-builder code,
.formula-references code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.column-width-field {
  position: relative;
}

.column-width-field input {
  padding-right: 28px;
}

.column-width-field small {
  position: absolute;
  right: 8px;
  top: 8px;
  color: #8b989f;
  font-size: 9px;
}

.sum-toggle {
  display: grid;
  place-items: center;
  cursor: pointer;
}

.sum-toggle input {
  position: absolute;
  opacity: 0;
}

.sum-toggle span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #8a979e;
  font-size: 12px;
  font-weight: 850;
}

.sum-toggle input:checked + span {
  border-color: var(--teal);
  background: var(--aqua);
  color: var(--teal-dark);
}

.sum-toggle input:disabled + span {
  opacity: 0.35;
  cursor: not-allowed;
}

.computed-column-builder {
  margin-top: 20px;
  padding: 16px;
  border-radius: 11px;
  background: #fff3e4;
}

.computed-column-builder h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
}

.computed-column-builder > div:first-child > p:last-child {
  margin: 5px 0 0;
  color: #6f6356;
  font-size: 10px;
}

.computed-column-form {
  display: grid;
  grid-template-columns: 1fr 1.5fr 110px auto;
  align-items: end;
  gap: 8px;
  margin-top: 13px;
}

.computed-column-form label {
  display: grid;
  gap: 5px;
}

.computed-column-form label > span {
  color: #675b4e;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.computed-column-form input,
.computed-column-form select {
  min-width: 0;
  height: 38px;
  padding: 0 9px;
  border: 1px solid #d7c4ad;
  border-radius: 7px;
  background: #fff;
  font-size: 11px;
}

.formula-references {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 11px;
}

.formula-references button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 7px;
  border: 1px solid #dbc7ad;
  border-radius: 999px;
  background: #fff;
  color: #5b5045;
  font-size: 8px;
  cursor: pointer;
}

.review-item {
  display: grid;
  grid-template-columns: 9px 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.review-item .marker {
  width: 9px;
  height: 9px;
  margin-top: 3px;
  border-radius: 50%;
  background: var(--amber);
}

.review-item.error .marker {
  background: var(--red);
}

.review-item.ok .marker {
  background: var(--teal);
}

.review-item strong {
  display: block;
  font-size: 11px;
}

.review-item p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.45;
}

.preview-shell {
  height: 100%;
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-rows: 50px minmax(0, 1fr);
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(31, 36, 43, 0.035) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(rgba(31, 36, 43, 0.035) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--canvas);
}

.preview-toolbar {
  min-height: 50px;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid rgba(31, 36, 43, 0.1);
  background: rgba(241, 242, 242, 0.94);
  backdrop-filter: blur(8px);
}

.preview-toolbar strong,
.preview-toolbar span {
  display: block;
}

.preview-toolbar strong {
  font-size: 11px;
}

.preview-toolbar > div:first-child > span {
  margin-top: 2px;
  color: #73848f;
  font-size: 9px;
}

.zoom-controls {
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.zoom-controls button {
  width: 30px;
  height: 28px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.zoom-controls span {
  min-width: 45px;
  color: var(--ink-soft);
  font-size: 10px;
  text-align: center;
}

.document-stage {
  height: auto;
  min-height: 0;
  overflow: auto;
  overflow-y: scroll;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  padding: 36px max(36px, calc((100% - 860px) / 2));
}

.document-page {
  --preview-scale: 0.85;
  width: 816px;
  min-height: 1056px;
  padding: 62px 62px 70px;
  transform: scale(var(--preview-scale));
  transform-origin: top left;
  margin-bottom: 0;
  background: var(--paper);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  line-height: 1.45;
}

.doc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
  border-bottom: 3px solid var(--teal);
}

.doc-brand {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.doc-brand img {
  width: 126px;
  height: auto;
}

.doc-brand span {
  padding-bottom: 2px;
  color: #676a6d;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.doc-meta {
  display: grid;
  gap: 3px;
  min-width: 180px;
  text-align: right;
}

.doc-meta strong {
  font-size: 12px;
}

.doc-meta span {
  color: #647681;
  font-size: 9px;
}

.inline-control {
  min-height: 18px;
  padding: 1px 3px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  font: inherit;
}

.inline-control:hover,
.inline-control:focus {
  border-color: #f4bd78;
  background: #fff7ed;
  outline: 0;
}

.inline-select {
  width: 58px;
}

.inline-date {
  width: 104px;
}

.doc-title-block {
  padding: 23px 0 19px;
}

.doc-kicker {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.doc-title-block h1 {
  margin: 0;
  font-family: "Times New Roman", Times, serif;
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.doc-title-block p:last-child {
  max-width: 610px;
  margin: 10px 0 0;
  color: #52636f;
  font-size: 10px;
}

.doc-section {
  margin-top: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 10px;
  padding: 7px 9px;
  border-left: 4px solid var(--lime);
  background: #f3f3f2;
  color: var(--ink);
  font-family: "Times New Roman", Times, serif;
  font-size: 14px;
  line-height: 1.1;
}

.section-heading-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 10px;
}

.section-heading-row .section-heading {
  margin-bottom: 0;
}

.doc-table-actions {
  display: flex;
  gap: 5px;
}

.doc-import-button {
  padding: 0 9px;
  border: 1px solid #c7c9ca;
  border-radius: 4px;
  background: #fff;
  color: var(--teal-dark);
  font-size: 8px;
  font-weight: 800;
  cursor: pointer;
}

.doc-import-button:hover,
.doc-import-button:focus-visible {
  border-color: var(--teal);
  background: #fff6ec;
  outline: 0;
}

.review-locked .doc-import-button,
.review-locked .add-line,
.review-locked .row-delete-margin .row-action,
.review-locked .invoice-delete-margin,
.review-locked .term-remove-inline {
  display: none;
}

.review-locked [contenteditable="false"] {
  cursor: default;
}

.locked-value {
  color: inherit;
}

.section-heading small {
  color: #71818c;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8px;
  font-weight: 500;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--line);
}

.summary-card {
  min-height: 72px;
  padding: 11px 12px;
  background: #fff;
}

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

.summary-card h3 {
  margin: 0 0 7px;
  color: var(--teal-dark);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.key-values {
  display: grid;
  grid-template-columns: minmax(95px, 0.8fr) 1.4fr;
  gap: 5px 10px;
  margin: 0;
}

.key-values dt {
  color: #647681;
  font-weight: 700;
}

.key-values dd {
  margin: 0;
}

[contenteditable="true"] {
  border-radius: 3px;
  transition: background 120ms ease, box-shadow 120ms ease;
}

[contenteditable="true"]:hover {
  background: #fff5e8;
}

[contenteditable="true"]:focus {
  background: #fff7ed;
  box-shadow: inset 0 -1px 0 var(--orange);
  outline: 0;
}

[contenteditable="true"]:empty::before {
  content: attr(data-placeholder);
  color: #a0adb5;
}

.products-wrap {
  overflow-x: auto;
  padding-right: 28px;
  padding-bottom: 2px;
}

.products-table {
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

.products-table th {
  position: relative;
  min-width: 0;
  padding: 7px 6px;
  border: 1px solid #a7b4b7;
  background: var(--ink);
  color: #fff;
  font-size: 7.5px;
  line-height: 1.2;
  text-align: left;
  vertical-align: bottom;
}

.products-table th > span,
.products-table th > small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.products-table th > small {
  margin-top: 2px;
  color: #aeb7bc;
  font-size: 6px;
  font-weight: 500;
  text-transform: uppercase;
}

.column-resizer {
  position: absolute;
  z-index: 3;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
}

.column-resizer::after {
  content: "";
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 3px;
  width: 1px;
  background: rgba(255, 255, 255, 0.28);
}

.column-resizer:hover::after,
.resizing-column .column-resizer::after {
  width: 2px;
  background: var(--orange);
}

.products-table td {
  padding: 5px 6px;
  border: 1px solid #d4dbdd;
  font-size: 8px;
  line-height: 1.25;
  vertical-align: middle;
}

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

.products-table input {
  width: 100%;
  min-width: 0;
  padding: 2px 1px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.products-table input[type="number"],
.products-table .type-number,
.products-table .type-currency {
  text-align: right;
}

.products-table .computed-value {
  background: #fff8ef;
  font-variant-numeric: tabular-nums;
}

.products-table tfoot td {
  padding: 7px 6px;
  border-top: 2px solid var(--teal);
  border-right: 1px solid #d4dbdd;
  background: #fff5e8;
  font-size: 8px;
  font-weight: 800;
}

.products-table .row-delete-margin {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  position: relative;
  overflow: visible;
}

.products-table td.row-delete-margin .row-action {
  position: absolute;
  top: 50%;
  left: 7px;
  transform: translateY(-50%);
}

.products-table td.row-delete-margin .row-action:hover {
  transform: translateY(-50%);
}

.row-action {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #8a9aa4;
  font-size: 11px;
  cursor: pointer;
}

.row-action:hover {
  background: #f7dddd;
  color: var(--red);
}

.add-line {
  margin-top: 7px;
  padding: 5px 8px;
  border: 1px dashed #a8b7ba;
  border-radius: 5px;
  background: #fff;
  color: var(--teal-dark);
  font-size: 8px;
  font-weight: 750;
  cursor: pointer;
}

.total-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-top: 8px;
  padding: 10px 12px;
  border-top: 2px solid var(--teal);
  background: #fff5e8;
}

.total-bar span {
  color: #5b6e79;
  font-size: 9px;
}

.total-bar strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
}

.invoice-list {
  display: grid;
  gap: 5px;
  margin: 8px 0 0;
  padding-right: 28px;
}

.invoice-row {
  position: relative;
  display: grid;
  grid-template-columns: 85px 1fr 110px;
  align-items: center;
  gap: 7px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.invoice-row > span {
  min-width: 0;
  padding: 3px 4px;
  border-bottom: 1px solid #dfe4e5;
  font-size: 8px;
}

.invoice-row .numeric-display {
  text-align: right;
}

.invoice-delete-margin {
  position: absolute;
  right: -26px;
  top: 50%;
  transform: translateY(-50%);
}

.invoice-delete-margin:hover {
  transform: translateY(-50%);
}

.invoice-row input {
  min-width: 0;
  padding: 3px 4px;
  border: 0;
  border-bottom: 1px solid #cad3d5;
  background: transparent;
  font-size: 8px;
}

.legal-copy {
  color: #293944;
  font-size: 11px;
  line-height: 1.45;
}

.legal-copy p {
  margin: 0 0 8px;
}

.legal-copy ol,
.legal-copy ul {
  margin: 6px 0 9px;
  padding-left: 19px;
}

.legal-copy li {
  margin: 0 0 4px;
}

.doc-special-terms {
  display: grid;
  gap: 8px;
}

.doc-special-terms li {
  position: relative;
  padding-right: 24px;
}

.special-term-inline {
  min-height: 18px;
}

.term-remove-inline {
  position: absolute;
  top: 0;
  right: 0;
}

.empty-special-terms {
  color: #7a888f;
  font-style: italic;
}

.signature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-top: 14px;
}

.signature-party {
  min-width: 0;
}

.signature-party > strong {
  display: block;
  margin-bottom: 22px;
}

.signature-line {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px;
  align-items: end;
  margin-top: 10px;
  font-size: 8px;
}

.signature-line::after {
  content: "";
  display: block;
  border-bottom: 1px solid #475864;
}

.doc-footer-note {
  margin-top: 22px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: #72828c;
  font-size: 8px;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: 330px;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 15px 35px rgba(31, 36, 43, 0.25);
  font-size: 11px;
  animation: toast-in 180ms ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (max-width: 1050px) {
  .workspace {
    grid-template-columns: 360px minmax(0, 1fr);
  }

  .document-stage {
    padding: 24px;
  }
}

@media (max-width: 780px) {
  body {
    overflow: auto;
  }

  .app-header {
    height: auto;
    min-height: 72px;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
  }

  .brand-lockup small,
  .privacy-badge,
  .header-actions .ghost {
    display: none;
  }

  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .workspace {
    display: block;
    height: auto;
    overflow: visible;
  }

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

  .panel-body {
    max-height: none;
  }

  .preview-shell {
    height: min(900px, calc(100dvh - 24px));
    min-height: 620px;
  }

  .document-stage {
    padding: 18px;
  }

  .document-page {
    --preview-scale: 0.72;
  }

  .import-dialog {
    width: calc(100vw - 16px);
    height: calc(100dvh - 16px);
  }

  .terms-import-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .columns-dialog {
    width: calc(100vw - 16px);
    height: calc(100dvh - 16px);
  }

  .columns-grid-header {
    display: none;
  }

  .column-config-row {
    grid-template-columns: minmax(0, 1fr) 105px 78px 40px 24px;
  }

  .computed-column-form {
    grid-template-columns: 1fr 1fr;
  }

  .import-dialog-header,
  .import-paste-step,
  .import-dialog-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .import-interpretation {
    padding-left: 16px;
    padding-right: 16px;
  }

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

@media print {
  body {
    overflow: visible;
    background: #fff;
  }

  .app-header,
  .control-panel,
  .preview-toolbar,
  .toast-region,
  .row-action,
  .add-line,
  .doc-import-button,
  .column-resizer {
    display: none !important;
  }

  .workspace,
  .preview-shell,
  .document-stage {
    display: block;
    height: auto;
    overflow: visible;
    padding: 0;
    background: #fff;
  }

  .document-page {
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 0.55in;
    transform: none;
    box-shadow: none;
  }
}
