:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --line: #d9dee7;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --warn: #fef3c7;
  --warn-line: #f59e0b;
  --bad-bg: #fee2e2;
  --good: #15803d;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
.demo-page {
  height: 100vh;
  overflow: hidden;
}
a { color: var(--primary); text-decoration: none; }
.topbar {
  height: 56px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.nav {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  color: var(--muted);
  font-size: 14px;
}
.container {
  max-width: 1680px;
  margin: 0 auto;
  padding: 12px 18px;
}
.demo-page .container {
  height: calc(100vh - 56px);
  overflow: hidden;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.demo-grid {
  --preview-pane: 54%;
  --result-min-pane: 34%;
  grid-template-columns: minmax(240px, var(--preview-pane)) 12px minmax(var(--result-min-pane), 1fr);
  align-items: stretch;
  height: 100%;
  min-height: 0;
}
.demo-grid.preview-ready #emptyResultHint { display: grid; }
label { display: block; font-size: 13px; font-weight: 650; margin: 0 0 6px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
  background: #fff;
}
textarea { min-height: 74px; resize: vertical; }
button {
  border: 0;
  border-radius: 6px;
  padding: 9px 13px;
  background: var(--primary);
  color: white;
  font-weight: 650;
  cursor: pointer;
}
button:hover { background: var(--primary-dark); }
button.secondary { background: #e5e7eb; color: #111827; }
button.secondary:hover { background: #d1d5db; }
button.danger { background: var(--danger); }
button:disabled { opacity: .55; cursor: not-allowed; }
.csv-action-button {
  background: #16a34a;
  color: #fff;
}
.csv-action-button:hover {
  background: #15803d;
}
.compact-action-button {
  padding: 7px 9px;
  font-size: 12px;
  white-space: nowrap;
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.status { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); }
.success { color: var(--good); }
.demo-control-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 8px 10px;
  gap: 8px;
  align-content: start;
}
.demo-input-row {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(360px, 520px) 108px;
  gap: 8px;
  align-items: end;
  justify-content: start;
  width: min(1004px, 100%);
}
.demo-key-field,
.demo-file-field {
  min-width: 0;
}
.demo-control-panel .grid-2 {
  gap: 10px;
}
.demo-control-panel label {
  margin: 0;
}
.demo-control-panel .file-help {
  display: none;
}
.demo-control-panel .status {
  font-size: 12px;
}
.demo-control-panel input {
  height: 38px;
  padding: 7px 10px;
}
.demo-control-panel button {
  padding: 8px 14px;
}
.demo-run-button {
  width: 108px;
  height: 38px;
}
.demo-entry {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  max-width: 980px;
  margin: 64px auto 0;
}
.entry-card {
  min-height: 220px;
  display: grid;
  grid-template-rows: 1fr auto;
  align-content: center;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  box-shadow: 0 16px 40px rgba(15, 23, 42, .08);
}
.entry-card:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}
.entry-card h1 {
  margin: 0 0 10px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
}
.entry-card p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}
.entry-card button {
  width: fit-content;
}
.workspace-area {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  height: 100%;
  min-height: 0;
}
.demo-tabs {
  grid-column: 1;
  justify-self: start;
  display: inline-flex;
  width: fit-content;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.tab-button {
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
}
.tab-button:hover {
  background: #f1f5f9;
}
.tab-button.active {
  background: var(--primary);
  color: #fff;
}
.demo-workbench {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.review-file-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.order-switcher {
  display: flex;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 2px;
}
.review-file-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.csv-action-status {
  grid-column: 1 / -1;
  min-height: 0;
  font-size: 12px;
}
.csv-action-status:empty {
  display: none;
}
.csv-action-status.error {
  color: #b91c1c;
  font-weight: 700;
}
.csv-action-status.success {
  color: var(--good);
  font-weight: 700;
}
.order-chip {
  flex: 0 0 min(240px, 54vw);
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 8px;
  align-items: center;
  min-height: 60px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
}
.order-chip.selected {
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.order-chip.status-pending {
  background: #f8fafc;
  opacity: .68;
}
.order-chip.status-processing {
  background: #fffbeb;
  opacity: 1;
}
.order-chip.status-completed {
  background: #fff;
  opacity: 1;
}
.order-chip.status-confirmed {
  background: #f0fdf4;
  opacity: 1;
}
.order-chip.status-failed {
  background: #fef2f2;
  opacity: 1;
}
.order-chip:hover,
.order-chip.selected {
  opacity: 1;
  filter: brightness(.99);
}
.order-chip-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
}
.order-chip-meta {
  grid-column: 1 / -1;
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-chip-meta:empty {
  display: block;
}
.order-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 18;
  background: rgba(15, 23, 42, .34);
}
.order-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 19;
  width: min(430px, 92vw);
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  padding: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
  box-shadow: -24px 0 60px rgba(15, 23, 42, .22);
  transform: translateX(100%);
  transition: transform .18s ease;
  pointer-events: none;
}
.order-drawer.open {
  transform: translateX(0);
  pointer-events: auto;
}
.order-drawer-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}
.order-drawer-header h1 {
  margin: 0;
  font-size: 18px;
}
.order-drawer-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.csv-export-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}
.export-scope-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}
.export-scope-row input {
  width: 16px;
  height: 16px;
  margin: 0;
}
.order-export-list {
  display: grid;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.order-export-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin: 0;
  padding: 8px 9px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}
.order-export-row input {
  width: 16px;
  height: 16px;
  margin: 0;
}
.order-export-row span {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
}
.order-export-row small {
  color: var(--muted);
  font-size: 12px;
}
.order-export-row.disabled {
  color: var(--muted);
  background: #f8fafc;
}
.csv-export-options .status {
  grid-column: 1 / -1;
  min-height: 0;
}
.order-drawer .orders-list {
  overflow: auto;
  padding: 12px;
  align-content: start;
}
.order-drawer .order-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 0;
}
.order-drawer .order-meta {
  align-items: center;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .42);
}
.modal-panel {
  width: min(420px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 60px rgba(15, 23, 42, .24);
}
.csv-export-dialog {
  width: min(520px, 100%);
  display: grid;
  gap: 0;
  padding: 0;
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}
.modal-header h1 {
  margin: 0;
  font-size: 18px;
}
.modal-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.csv-export-dialog .order-export-list {
  max-height: min(260px, 34vh);
}
.csv-export-dialog .modal-actions {
  padding: 16px 18px 18px;
  border-top: 1px solid var(--line);
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 12px;
  font-size: 15px;
  font-weight: 650;
}
.checkbox-row input {
  width: 18px;
  height: 18px;
  margin: 0;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
.orders-list {
  display: grid;
  gap: 8px;
}
.order-row {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  display: grid;
  gap: 7px;
  padding: 10px 34px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
}
.order-row.selected {
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.order-row.status-pending {
  background: #f8fafc;
  opacity: .68;
}
.order-row.status-processing {
  background: #fffbeb;
  opacity: 1;
}
.order-row.status-completed {
  background: #fff;
  opacity: 1;
}
.order-row.status-confirmed {
  background: #f0fdf4;
  opacity: 1;
}
.order-row.status-failed {
  background: #fef2f2;
  opacity: 1;
}
.order-row:hover,
.order-row.selected {
  opacity: 1;
  filter: brightness(.99);
}
.order-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 750;
  overflow-wrap: anywhere;
}
.order-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
}
.order-meta:empty {
  display: block;
}
.order-review-count,
.order-confirm {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 750;
}
.order-confirm.confirmed {
  background: #dcfce7;
  color: #15803d;
}
.order-state-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}
.order-state-icon.state-completed,
.order-state-icon.state-review,
.order-state-icon.state-confirmed {
  background: #dcfce7;
  color: #15803d;
}
.order-state-icon.state-processing {
  background: #dbeafe;
  color: #1d4ed8;
}
.order-state-icon.state-failed {
  background: #fee2e2;
  color: #b91c1c;
}
.order-review-count {
  background: #fff7ed;
  color: #c2410c;
}
.order-confirm.unconfirmed {
  background: #f8fafc;
  color: #64748b;
  border: 1px solid #cbd5e1;
}
.order-error {
  color: #b91c1c;
  font-weight: 700;
}
.order-progress {
  display: grid;
  gap: 4px;
  min-width: 132px;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 750;
}
.order-progress-text {
  line-height: 1.2;
}
.order-progress-track {
  display: block;
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbeafe;
}
.order-progress-bar {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #2563eb;
  transition: width .2s ease;
}
.order-delete {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #64748b;
  background: #f1f5f9;
  font-size: 18px;
  line-height: 1;
  font-weight: 800;
}
.order-delete:hover,
.order-delete:focus {
  color: #b91c1c;
  background: #fee2e2;
  outline: none;
}
.empty-list {
  padding: 14px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}
.auth-row {
  grid-template-columns: minmax(300px, 360px) minmax(360px, 520px) 108px;
}
.sample-input-row {
  grid-template-columns: minmax(360px, 520px) 108px;
}
.file-help {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  text-align: right;
}
.demo-meta-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 18px;
  width: min(1180px, 100%);
}
#uploadControls > #status.upload-controls-status {
  min-width: 0;
  min-height: 0;
  width: min(1004px, 100%);
}
#uploadControls > #status.upload-controls-status:empty {
  display: none;
}
#uploadControls > #status.upload-controls-status.error {
  display: inline-flex;
  align-items: center;
  width: min(1004px, 100%);
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fef2f2;
  color: #b91c1c;
  font-weight: 650;
  line-height: 1.5;
  white-space: pre-line;
}
#uploadControls > #status.upload-controls-status.success {
  color: var(--good);
  font-weight: 650;
}
.demo-key-field,
.demo-file-field {
  position: relative;
}
.demo-key-field label,
.demo-file-field > label:first-child {
  position: absolute;
  left: 10px;
  top: -7px;
  z-index: 1;
  padding: 0 5px;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
}
.file-picker {
  height: 38px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
}
.file-picker:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}
.file-picker.disabled,
.file-picker.disabled:hover {
  border-color: var(--line);
  background: #f8fafc;
  color: var(--muted);
  cursor: not-allowed;
}
.file-picker.drag-over {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.file-button-text {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 5px;
  background: #eef2ff;
  color: #1d4ed8;
  font-weight: 700;
  font-size: 12px;
}
.file-name-text {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 13px;
}
.file-clear-button {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #64748b;
  background: #f1f5f9;
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
}
.file-clear-button:hover {
  color: #b91c1c;
  background: #fee2e2;
}
.file-clear-button[hidden] {
  display: none;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.process-steps {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  width: min(860px, 100%);
  margin: 8px auto 0;
  padding: 7px 12px 0;
}
.process-steps[hidden] { display: none; }
.process-track {
  position: absolute;
  left: calc(16.666% + 12px);
  right: calc(16.666% + 12px);
  top: 17px;
  height: 3px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}
.process-track-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #2563eb;
  transition: width .28s ease;
}
.process-step {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-align: center;
}
.process-step span {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid #d1d5db;
  background: #fff;
  box-shadow: 0 0 0 4px var(--panel);
}
.process-step.active span {
  border-color: #2563eb;
  background: #fff;
  animation: pulse-step 1.2s ease-in-out infinite;
}
.process-step.complete span {
  border-color: #2563eb;
  background: #2563eb;
}
.process-step.complete span::after {
  content: "\2713";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  font-weight: 900;
}
.process-step.active,
.process-step.complete {
  color: #111827;
}
.process-step.active b {
  color: #1d4ed8;
}
@keyframes pulse-step {
  0%, 100% { box-shadow: 0 0 0 4px var(--panel), 0 0 0 5px rgba(37, 99, 235, .12); }
  50% { box-shadow: 0 0 0 4px var(--panel), 0 0 0 10px rgba(37, 99, 235, .08); }
}
.small { font-size: 12px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: auto; }
th, td { border-bottom: 1px solid var(--line); padding: 9px; text-align: left; vertical-align: top; min-width: 0; }
th { background: #f9fafb; font-weight: 700; white-space: nowrap; text-align: center; }
th.numeric { text-align: center; }
td input { min-width: 0; }
td input::placeholder { color: #9ca3af; }
.table-wrap {
  --table-font-size: 15px;
  --table-editor-height: 36px;
  overflow-x: auto;
}
.result-table {
  width: auto;
  table-layout: fixed;
  font-size: var(--table-font-size);
}
.result-table col {
  min-width: 0;
}
.result-table th,
.result-table td {
  min-width: 0;
  padding: 5px 4px;
  overflow: hidden;
}
.result-table th {
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  line-height: 1.25;
  text-overflow: ellipsis;
  overflow: hidden;
}
.result-table td input {
  width: 100%;
  height: var(--table-editor-height);
  padding: 7px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}
.result-table td textarea.cell-editor {
  width: 100%;
  min-height: var(--table-editor-height);
  height: auto;
  padding: 7px 8px;
  resize: none;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  line-height: 1.35;
  font-size: var(--table-font-size);
}
.result-table td.numeric textarea.cell-editor {
  text-align: right;
  white-space: nowrap;
  overflow-wrap: normal;
}
.result-table td.date textarea.cell-editor,
.result-table td.type-date textarea.cell-editor {
  white-space: nowrap;
  overflow-wrap: normal;
}
.result-table td.date textarea.cell-editor {
  white-space: nowrap;
}
.result-table.locked textarea.cell-editor,
.field-card.locked textarea.field-editor {
  background: #f8fafc;
  color: var(--muted);
  cursor: default;
}
#tablesArea.table-wrap { overflow-x: auto; }
.badge { display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: 12px; background: #eef2ff; color: #3730a3; }
.preview {
  position: relative;
  top: auto;
  background: #111827;
  border-radius: 8px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.preview-toolbar {
  min-height: 46px;
  padding: 8px 10px 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #f8fafc;
  background: #111827;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.preview-title { font-weight: 750; letter-spacing: 0; }
.preview-actions { display: flex; align-items: center; gap: 8px; }
.preview-actions button {
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,.16);
  background: #f8fafc;
  color: #111827;
}
.preview-actions button:hover { background: #e5e7eb; }
.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}
.preview-viewport {
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
.preview-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  display: block;
  text-align: center;
}
.preview img, .preview canvas {
  width: calc(100% * var(--preview-zoom, 1));
  max-width: none;
  height: auto;
  display: inline-block;
  vertical-align: top;
  background: #fff;
  box-shadow: 0 12px 30px rgba(0,0,0,.28);
}
.split-handle {
  width: 12px;
  height: 100%;
  min-height: 0;
  padding: 0;
  cursor: col-resize;
  border-radius: 999px;
  background: transparent;
  align-self: stretch;
  touch-action: none;
}
.split-handle::before {
  content: "";
  display: block;
  width: 4px;
  height: 100%;
  margin: 0 auto;
  border-radius: 999px;
  background: #d1d5db;
}
.split-handle:hover::before,
.resizing-split .split-handle::before {
  background: #2563eb;
}
.resizing-split {
  cursor: col-resize;
  user-select: none;
}
.preview-placeholder { color: #cbd5e1; padding: 24px; text-align: center; }
.highlight {
  position: absolute;
  border: 0;
  background: rgba(250, 204, 21, .34);
  pointer-events: none;
  display: none;
}
.field-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}
#fieldsArea {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.result-panel {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.result-panel .section-title {
  flex: 0 0 auto;
}
.result-scroll {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding-right: 4px;
}
.field-card textarea.field-editor {
  min-width: 0;
  width: 100%;
  min-height: 40px;
  resize: none;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  line-height: 1.4;
}
.field-card.type-date textarea.field-editor,
.field-card.type-number textarea.field-editor,
.field-card.type-quantity textarea.field-editor,
.field-card.type-unit_price textarea.field-editor,
.field-card.type-amount textarea.field-editor {
  white-space: nowrap;
  overflow-wrap: normal;
}
.empty-result-hint {
  min-height: 160px;
  display: none;
  place-content: center;
  gap: 8px;
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  background: #f9fafb;
}
.empty-result-hint strong {
  color: var(--text);
  font-size: 18px;
}
.review { background: var(--warn); border-color: var(--warn-line); }
.missing { background: var(--bad-bg); border-color: #f87171; }
.field-card .meta { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.field-card .meta span:first-child { font-weight: 700; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.section-title h2, .section-title h1 { margin: 0; font-size: 20px; }
.table-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 8px;
}
.table-section-title[hidden] {
  display: none;
}
.table-section-title h2 {
  margin: 0;
  font-size: 18px;
}
.table-font-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
}
.table-font-label {
  padding: 0 8px 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.table-font-controls .table-font-button {
  min-width: 38px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  text-align: center;
  font-weight: 700;
}
.table-font-button.is-small {
  font-size: 12px;
}
.table-font-button.is-large {
  font-size: 17px;
}
.numeric { text-align: right; }
td.numeric { text-align: right; }
td.numeric input { text-align: right; }
td.numeric input { min-width: 0; }
.review-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.review-list button {
  width: fit-content;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid #fed7aa;
  border-radius: 999px;
  background: #fff7ed;
  color: #c2410c;
  font-weight: 750;
  text-align: left;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.review-list button:hover,
.review-list button:focus {
  background: #ffedd5;
  color: #9a3412;
  outline: 2px solid rgba(194, 65, 12, .22);
  outline-offset: 2px;
}
.review-jump-target {
  position: relative;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, .32), 0 0 0 7px rgba(249, 115, 22, .14) !important;
  animation: review-jump-pulse 1.2s ease-in-out 1;
}
@keyframes review-jump-pulse {
  0% { box-shadow: 0 0 0 0 rgba(249, 115, 22, .45), 0 0 0 0 rgba(249, 115, 22, .18); }
  45% { box-shadow: 0 0 0 4px rgba(249, 115, 22, .35), 0 0 0 10px rgba(249, 115, 22, .14); }
  100% { box-shadow: 0 0 0 3px rgba(249, 115, 22, .32), 0 0 0 7px rgba(249, 115, 22, .14); }
}
.login-box { max-width: 420px; margin: 72px auto; }
.copy-box { display: grid; gap: 8px; padding: 12px; background: #ecfdf5; border: 1px solid #86efac; border-radius: 8px; }
.key-cell { display: grid; gap: 6px; min-width: 230px; }
.key-copy {
  width: 100%;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 700;
  text-align: left;
  overflow-wrap: anywhere;
}
.key-copy:hover { background: #dbeafe; color: #1e40af; }
.inline-form { display: grid; grid-template-columns: repeat(5, 1fr) auto; gap: 10px; align-items: end; }
.template-row { display: grid; grid-template-columns: 1.2fr 150px 90px 1.4fr 44px; gap: 8px; align-items: center; margin-bottom: 8px; }
@media (max-width: 900px) {
  .grid-2, .demo-grid, .inline-form, .demo-input-row, .demo-entry, .demo-workbench { grid-template-columns: 1fr; }
  #fieldsArea { grid-template-columns: 1fr; }
  .demo-input-row, .demo-meta-row, .process-steps { width: 100%; }
  .split-handle { display: none; }
  .demo-grid { height: auto; }
  .preview { height: 72vh; min-height: 520px; }
  .result-panel { height: 72vh; min-height: 520px; }
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 0 14px;
  }
  .demo-tabs {
    grid-column: 1;
    justify-self: start;
  }
  .nav {
    grid-column: 2;
    justify-self: end;
  }
}
