:root {
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --line: #d9dee7;
  --line-strong: #b9c4d3;
  --text: #25272d;
  --muted: #6d727e;
  --muted-2: #98a1af;
  --blue: #2f6bdc;
  --blue-soft: #e7f0ff;
  --navy: #0c1f5c;
  --amber: #ffdf8b;
  --green: #16a76c;
  --red: #da3c3c;
  --shadow: 0 18px 44px rgba(22, 31, 54, 0.11);
  --radius: 8px;
  font-family: Poppins, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-rows: 96px 1fr;
  overflow: hidden;
}

.document-header {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 320px 1fr 340px;
  grid-template-rows: 54px 42px;
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px;
  min-width: 0;
}

.brand-pin-wrap {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--navy);
  flex: 0 0 auto;
}

.brand-pin-wrap img {
  width: 17px;
  height: 21px;
  display: block;
}

.title-group h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
}

.upload-rail {
  grid-column: 2 / -1;
  grid-row: 1;
  justify-self: end;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px 0 8px;
  overflow-x: auto;
}

.upload-pill {
  min-width: 154px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: #364052;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.upload-pill:hover {
  border-color: var(--line-strong);
  background: #f8fafc;
}

.upload-pill input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.upload-pill span {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.upload-pill strong {
  font-size: 11px;
  line-height: 1.1;
  font-weight: 800;
  white-space: nowrap;
}

.upload-pill small {
  max-width: 102px;
  color: #737d8c;
  font-size: 10px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-pill.loaded,
.upload-tile.loaded {
  border-color: rgba(22, 167, 108, 0.42);
  background: #ecfdf3;
  color: #075f3d;
}

.upload-pill.loaded small,
.upload-tile.loaded span {
  color: #087443;
}

.document-name {
  grid-column: 1 / -1;
  grid-row: 2;
  align-self: stretch;
  display: flex;
  align-items: center;
  padding-left: 22px;
  border-top: 1px solid var(--line);
  color: #5d626e;
  font-size: 13px;
  background: #fbfcfe;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 7px;
}

.center-tools {
  grid-column: 2;
  grid-row: 2;
  justify-self: center;
}

.right-tools {
  grid-column: 3;
  grid-row: 2;
  justify-self: end;
  padding-right: 18px;
}

.text-button.review-action {
  display: none;
}

.icon-button,
.text-button,
.style-toggle,
.segment,
.decision {
  border: 1px solid var(--line);
  background: var(--surface);
  color: #354052;
  border-radius: 6px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
}

.icon-button.small {
  width: 36px;
  height: 32px;
}

.icon-button.plain {
  border-color: transparent;
  background: transparent;
}

.icon-button.active {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: var(--blue-soft);
}

.icon-button:hover,
.text-button:hover,
.style-toggle:hover,
.segment:hover {
  border-color: var(--line-strong);
  background: #f8fafc;
}

.icon-button svg,
.text-button svg,
  .decision svg,
  .search-box svg,
  .field-chip svg,
  .upload-pill svg,
  .upload-tile svg,
  .empty-state svg {
  width: 19px;
  height: 19px;
  stroke-width: 2;
}

.zoom-input {
  width: 62px;
  height: 32px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #545d6b;
  background: var(--surface);
}

.text-button {
  min-height: 34px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 600;
}

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

.text-button.primary:hover {
  background: #245dc5;
  border-color: #245dc5;
}

.text-button.full {
  width: 100%;
}

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

.side-panel {
  min-height: 0;
  padding: 24px 22px;
  overflow: auto;
}

.fields-panel {
  background: #f1f4f8;
  border-right: 1px solid #e1e6ed;
}

.styling-panel {
  background: #f6f8fb;
  border-left: 1px solid #e1e6ed;
}

.panel-card {
  background: var(--surface);
  border: 1px solid #e4e8ef;
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-pad {
  padding: 22px;
}

.panel-card h2 {
  margin: 0 0 7px;
  font-size: 23px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: 0;
}

.panel-card p {
  margin: 0;
  color: #5d626e;
  font-size: 15px;
  line-height: 1.55;
}

.search-box {
  height: 44px;
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  color: #5c6370;
  background: var(--surface);
}

.static-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  font-size: 15px;
  color: var(--text);
}

.search-box input::placeholder {
  color: #a1a6b0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 14px;
  padding: 3px;
  background: #e6e8ee;
  border: 1px solid #d4d8e1;
  border-radius: 6px;
}

.segment {
  height: 40px;
  border: 0;
  background: transparent;
  color: #596070;
  font-size: 15px;
  font-weight: 600;
}

.segment.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(21, 29, 44, 0.06);
}

.segmented.compact {
  display: inline-grid;
  grid-template-columns: repeat(3, auto);
  margin-top: 0;
  padding: 0;
  overflow: hidden;
  background: transparent;
}

.segmented.compact .segment {
  width: 65px;
  height: 38px;
  border-right: 1px solid var(--line);
  border-radius: 0;
  font-size: 13px;
  font-weight: 500;
}

.segmented.compact .segment:last-child {
  border-right: 0;
}

.segmented.compact .segment.active {
  background: #dbe7f4;
  box-shadow: none;
}

.field-groups {
  border-top: 1px solid #e5e7ec;
}

.field-group {
  padding: 24px 22px;
  border-bottom: 1px solid #e5e7ec;
}

.field-group h3 {
  margin: 0 0 18px;
  color: #636977;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 1.6px;
  text-transform: uppercase;
}

.field-chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 11px;
}

.field-chip {
  max-width: 100%;
  min-height: 40px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  background: #eff1f6;
  color: #4e535e;
  font-size: 15px;
  white-space: normal;
  text-align: left;
}

.field-chip:hover {
  background: #e5e9f1;
}

.field-chip svg {
  flex: 0 0 auto;
}

.utility-chip {
  border: 1px solid #cdd7e6;
  background: #f8fbff;
  color: #2f4058;
  font-weight: 700;
}

.field-chip[data-type="image"]::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #38bdf8;
  flex: 0 0 auto;
}

.stage-shell {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #dfe8f1;
  overflow: hidden;
}

.page-scroll {
  height: 100%;
  overflow: auto;
  padding: 24px;
}

.pages,
.review-pages {
  width: max-content;
  min-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.review-pages {
  display: none;
}

.review-warning {
  width: min(760px, 100%);
  padding: 12px 14px;
  border: 1px solid #f0cf74;
  border-radius: 8px;
  background: #fff8e1;
  color: #705200;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(100, 76, 10, 0.08);
}

.review-stamp {
  position: absolute;
  top: 20px;
  right: 28px;
  z-index: 6;
  padding: 9px 16px;
  border: 2px solid currentColor;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1.5px;
  transform: rotate(-4deg);
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(22, 31, 54, 0.12);
}

.review-stamp.approved {
  color: #087443;
}

.review-stamp.rejected {
  color: #b42318;
}

.review-stamp[hidden] {
  display: none;
}

.pdf-page {
  position: relative;
  background: white;
  box-shadow: 0 8px 28px rgba(13, 24, 45, 0.16);
}

.pdf-page canvas {
  display: block;
}

.page-label {
  position: absolute;
  left: 12px;
  top: -23px;
  color: #667085;
  font-size: 12px;
  font-weight: 700;
}

.page-layer {
  position: absolute;
  inset: 0;
}

.placed-field {
  position: absolute;
  display: flex;
  align-items: center;
  min-width: 44px;
  min-height: 20px;
  border: 1px dashed #8aa3c4;
  background: rgba(255, 255, 255, 0.38);
  color: #20242b;
  user-select: none;
  overflow: visible;
}

.placed-field.selected {
  border: 2px dashed var(--blue);
  box-shadow: 0 0 0 1px rgba(47, 107, 220, 0.1);
}

.placed-field .field-text {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 2px 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.placed-field .delete-field {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: #ef4444;
  box-shadow: 0 2px 6px rgba(22, 29, 42, 0.2);
  font-size: 0;
  line-height: 0;
  cursor: pointer;
}

.placed-field .delete-field::before,
.placed-field .delete-field::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 2px;
  border-radius: 999px;
  background: #fff;
}

.placed-field .delete-field::before {
  transform: rotate(45deg);
}

.placed-field .delete-field::after {
  transform: rotate(-45deg);
}

.placed-field .resize-handle {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--blue);
  background: var(--blue);
  cursor: nwse-resize;
}

.placed-field.image-field {
  justify-content: center;
  color: rgba(73, 82, 98, 0.72);
}

.placed-field.static-text-field .field-text {
  white-space: normal;
}

.placed-field.signature-field {
  justify-content: center;
  background: rgba(255, 255, 255, 0.52);
}

.signature-preview {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.setup-panel {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-items: start center;
  align-content: start;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 28px 28px 96px;
  background: rgba(223, 232, 241, 0.92);
  backdrop-filter: blur(6px);
}

.setup-panel.hidden {
  display: none;
}

.setup-card {
  width: min(900px, 100%);
  padding: 28px;
  border: 1px solid #dce3ed;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  margin: 0 auto;
}

.setup-heading {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

.app-mark {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: var(--navy);
  font-weight: 800;
  flex: 0 0 auto;
}

.app-mark img {
  width: 26px;
  height: 32px;
  display: block;
}

.setup-wordmark {
  width: 124px;
  max-width: 22%;
  margin-left: auto;
  opacity: 0.48;
}

.setup-heading h2 {
  margin: 0 0 4px;
  font-size: 24px;
}

.setup-heading p {
  margin: 0;
  color: var(--muted);
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 14px;
}

.upload-tile {
  min-height: 120px;
  display: grid;
  place-items: center;
  gap: 7px;
  padding: 18px;
  border: 1px dashed #b8c3d1;
  border-radius: 8px;
  background: #fbfcff;
  text-align: center;
  cursor: pointer;
}

.upload-tile input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.upload-tile strong {
  font-size: 15px;
}

.upload-tile span {
  max-width: 100%;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merge-panel {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.merge-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #1f2937;
  font-size: 13px;
}

.merge-title svg {
  width: 17px;
  height: 17px;
  color: var(--green);
}

.merge-title span {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.merge-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.merge-controls label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: #555d6c;
  font-size: 12px;
  font-weight: 700;
}

.merge-controls select {
  height: 38px;
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: #2f3846;
  background: var(--surface);
}

.merge-controls .text-button {
  height: 38px;
  padding: 0 14px;
}

.mapping-panel {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

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

.mapping-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: #1f2937;
  font-size: 13px;
}

.mapping-title svg {
  width: 17px;
  height: 17px;
  color: var(--blue);
}

.mapping-title span {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mapping-rows {
  display: grid;
  gap: 14px;
  max-height: 360px;
  overflow: auto;
  padding-right: 3px;
}

.mapping-section {
  display: grid;
  gap: 8px;
}

.mapping-section + .mapping-section {
  padding-top: 12px;
  border-top: 1px solid #e7ebf1;
}

.mapping-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #344054;
  font-size: 13px;
}

.mapping-section-title span {
  min-width: 0;
  color: #8b95a5;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mapping-row {
  display: grid;
  grid-template-columns: minmax(104px, 0.75fr) minmax(180px, 1.45fr) minmax(150px, 0.9fr);
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid #eef1f5;
  border-radius: 8px;
  background: #fff;
}

.mapping-source {
  display: grid;
  gap: 2px;
  min-width: 0;
  color: #667085;
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.mapping-source small {
  color: #8b95a5;
  font-size: 10px;
  font-weight: 700;
}

.mapping-preview {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.mapping-preview span {
  max-width: 150px;
  padding: 4px 7px;
  border-radius: 999px;
  color: #556070;
  background: #f2f5f9;
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mapping-row input {
  height: 34px;
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: #2f3846;
  background: var(--surface);
}

.mapping-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.mapping-actions .text-button {
  width: 100%;
}

.filename-config {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.filename-config label {
  color: #555d6c;
  font-size: 13px;
  font-weight: 700;
}

.filename-config select {
  height: 40px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: #2f3846;
  background: var(--surface);
}

.sample-strip {
  position: sticky;
  z-index: 2;
  bottom: -28px;
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  margin: 20px -28px -28px;
  padding: 16px 28px 20px;
  border-top: 1px solid #edf1f6;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
}

.empty-state {
  height: 100%;
  min-height: 460px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 40px;
  height: 40px;
  color: var(--blue);
}

.empty-state h2 {
  margin: 0;
  color: var(--text);
}

.empty-state p {
  width: min(460px, 90%);
  margin: 0;
}

.style-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.style-title h2 {
  font-size: 21px;
  margin-bottom: 3px;
}

.style-title p {
  font-size: 13px;
}

.control-group {
  margin-top: 18px;
}

.control-group label {
  display: block;
  margin-bottom: 8px;
  color: #555d6c;
  font-size: 13px;
  font-weight: 600;
}

.control-group select,
.control-group input[type="text"],
.control-group input[type="number"],
.control-group textarea {
  height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  color: #2f3846;
  background: var(--surface);
  outline: 0;
}

.control-group textarea {
  min-height: 92px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.45;
}

.signature-control canvas {
  width: 100%;
  height: 130px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  touch-action: none;
}

.signature-control .text-button {
  margin-top: 8px;
}

.font-row {
  display: grid;
  grid-template-columns: 80px 42px 42px 42px;
  align-items: center;
  gap: 8px;
}

.style-toggle {
  height: 40px;
  font-weight: 800;
}

.style-toggle.active {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: #bcd0ef;
}

.style-toggle.italic {
  font-style: italic;
}

.style-toggle.underline {
  text-decoration: underline;
}

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

.color-row input[type="color"] {
  height: 44px;
  width: 44px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.hint {
  margin-top: 8px !important;
  color: #9aa3b0 !important;
  font-size: 13px !important;
  line-height: 1.5 !important;
}

.review-card {
  display: none;
}

.review-card h2 {
  font-size: 21px;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 18px 0;
  color: #5d6674;
}

.status-grid span {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f3f6fa;
}

.record-details {
  display: grid;
  gap: 8px;
  max-height: 230px;
  overflow: auto;
  padding-right: 3px;
  margin-bottom: 16px;
}

.record-anomalies {
  display: grid;
  gap: 6px;
  margin-bottom: 4px;
}

.record-anomaly {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 7px;
  align-items: start;
  padding: 8px 9px;
  border: 1px solid rgba(217, 119, 6, 0.24);
  border-radius: 7px;
  color: #8a4b08;
  background: #fff8eb;
  font-size: 12px;
  line-height: 1.35;
}

.record-anomaly-body {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.record-anomaly svg {
  width: 15px;
  height: 15px;
  margin-top: 1px;
  color: #d97706;
  stroke-width: 2.2;
}

.record-anomaly span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.record-reference-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.record-reference {
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(217, 119, 6, 0.28);
  border-radius: 999px;
  color: #8a4b08;
  background: #fff;
  font-size: 11px;
  font-weight: 700;
}

.record-reference:hover {
  border-color: rgba(217, 119, 6, 0.52);
  background: #fff4db;
}

.record-reference.current,
.record-reference:disabled {
  color: #fff;
  background: #d97706;
  border-color: #d97706;
  cursor: default;
  opacity: 1;
}

.record-source-reference {
  color: #9a5f17;
  font-size: 11px;
  font-weight: 700;
}

.record-detail {
  display: grid;
  grid-template-columns: minmax(0, 42%) minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #eef1f5;
  font-size: 13px;
  line-height: 1.35;
}

.record-detail strong {
  min-width: 0;
  color: #5a6270;
  overflow-wrap: anywhere;
}

.record-detail span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.decision-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 12px 0;
}

.review-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 10px;
}

.review-nav .text-button {
  width: 100%;
}

.text-button:disabled,
.decision:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.decision {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  font-weight: 700;
}

.decision.approve {
  background: var(--green);
  border-color: var(--green);
}

.decision.reject {
  background: var(--red);
  border-color: var(--red);
}

.decision.skip {
  background: #64748b;
  border-color: #64748b;
}

.decision.current {
  box-shadow: 0 0 0 3px rgba(47, 107, 220, 0.22);
}

.zip-progress {
  min-height: 20px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.review-card .text-button.full + .text-button.full {
  margin-top: 8px;
}

.action-bar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: 480px;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 16px;
  border-radius: 8px;
  color: #fff;
  background: #263142;
  box-shadow: 0 10px 28px rgba(10, 18, 32, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

body.preview-mode .placed-field {
  border-color: transparent;
  background: transparent;
}

body.setup-mode .workspace {
  grid-template-columns: 1fr;
}

body.setup-mode .side-panel {
  display: none;
}

body.setup-mode .stage-shell {
  grid-column: 1;
}

body.setup-mode .center-tools,
body.setup-mode .right-tools {
  visibility: hidden;
}

body.review-mode .style-card {
  display: none;
}

body.review-mode .builder-action {
  display: none;
}

body.review-mode .text-button.review-action {
  display: inline-flex;
}

body.review-mode .review-card {
  display: block;
}

body.review-mode .fields-panel {
  display: none;
}

body.review-mode .workspace {
  grid-template-columns: minmax(500px, 1fr) 360px;
}

body.review-mode .stage-shell {
  grid-column: 1;
}

body.review-mode .styling-panel {
  grid-column: 2;
}

body.review-mode .pages {
  display: none;
}

body.review-mode .review-pages {
  display: flex;
}

body.review-mode .document-header {
  grid-template-columns: 320px 1fr 340px;
}

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

  .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    grid-template-rows: auto 1fr auto;
  }

  .document-header {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(5, auto);
    gap: 10px;
    padding: 14px;
  }

  .title-group,
  .upload-rail,
  .document-name,
  .center-tools,
  .right-tools {
    grid-column: 1;
    grid-row: auto;
    justify-self: stretch;
    padding: 0;
  }

  .upload-rail {
    width: 100%;
    justify-self: stretch;
    justify-content: flex-start;
  }

  .upload-pill {
    min-width: 152px;
    flex: 0 0 auto;
  }

  .document-name {
    border-top: 0;
  }

  .center-tools,
  .right-tools {
    justify-content: flex-start;
  }

  .workspace,
  body.review-mode .workspace {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .side-panel,
  .styling-panel,
  body.review-mode .styling-panel,
  body.review-mode .stage-shell {
    grid-column: 1;
  }

  .side-panel {
    padding: 18px;
  }

  .stage-shell {
    min-height: 660px;
    order: -1;
  }

  .setup-panel {
    place-items: start center;
    overflow: auto;
    padding: 32px 18px 120px;
  }

  .upload-grid {
    grid-template-columns: 1fr;
  }

  .merge-controls {
    grid-template-columns: 1fr;
  }

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

  .filename-config {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .upload-rail {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    overflow: visible;
  }

  .upload-pill {
    width: 100%;
    min-width: 0;
    height: 50px;
    gap: 7px;
    padding: 0 8px;
  }

  .upload-pill svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
  }

  .upload-pill strong {
    font-size: 10px;
    white-space: normal;
  }

  .upload-pill small {
    max-width: 62px;
    font-size: 9px;
  }

  .panel-card h2,
  .setup-heading h2 {
    font-size: 23px;
  }

  .panel-card p {
    font-size: 15px;
  }

  .field-chip {
    font-size: 15px;
    min-height: 44px;
  }

  .right-tools {
    flex-wrap: wrap;
  }
}
