:root {
  --ink: #08090a;
  --muted: #666b73;
  --line: rgba(22, 26, 31, 0.14);
  --surface: #ffffff;
  --surface-2: #f2f4f6;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --accent: #0d0f12;
  --accent-2: #b42318;
  --warning: #b45309;
  --pdf-page-width: 277mm;
  --pdf-page-height: 190mm;
}

html {
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, #fbfbfc 0%, #eef1f4 100%);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  min-width: 320px;
  color: var(--ink);
  background: linear-gradient(180deg, #fbfbfc 0%, #eef1f4 100%);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: calc(100vh - 32px);
  width: min(1720px, calc(100% - 20px));
  margin: 0 auto;
  padding: 8px 0 10px;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 0 8px;
}

.brand-block {
  display: grid;
  grid-template-columns: 230px 250px;
  grid-template-rows: auto auto auto;
  align-items: center;
  column-gap: 34px;
  row-gap: 0;
  min-width: 0;
}

.brand-logo {
  grid-column: 1;
  grid-row: 1;
  display: inline-flex;
  align-items: center;
  width: 230px;
  min-width: 160px;
  text-decoration: none;
}

.brand-logo img {
  display: block;
  width: 100%;
  max-height: 58px;
  object-fit: contain;
}

.eyebrow {
  grid-column: 1;
  grid-row: 2;
  margin: 0;
  width: 230px;
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.04;
  text-align: left;
  text-transform: none;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 4vw, 2.35rem);
  line-height: 1.08;
}

.topbar-note {
  margin: 0;
  max-width: 720px;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.app-switch {
  position: relative;
  grid-column: 2;
  grid-row: 1 / 3;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 240px;
  min-height: 44px;
  gap: 0;
  border: 1px solid rgba(18, 22, 27, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.7), 0 12px 34px rgba(20, 24, 30, 0.1);
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.app-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0 16px;
  opacity: 0.42;
  filter: blur(0.45px);
  transition: opacity 0.18s ease, filter 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.app-link.active,
.app-link:hover,
.app-link:focus-visible {
  background: rgba(255,255,255,0.82);
  color: #050608;
  opacity: 1;
  filter: blur(0);
  box-shadow: 0 10px 28px rgba(23, 28, 34, 0.16);
  outline: none;
}

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

.summary-strip {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
  width: min(1060px, 100%);
  align-self: stretch;
}

.summary-chip {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.78);
  backdrop-filter: blur(18px);
  padding: 6px 7px;
}

.summary-chip span {
  display: block;
  color: var(--muted);
  font-size: 0.64rem;
}

.summary-chip strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 0.7rem;
  line-height: 1.12;
}

.creator-credit {
  position: fixed;
  right: 24px;
  bottom: 6px;
  z-index: 10;
  display: grid;
  gap: 2px;
  justify-items: end;
  text-align: right;
  color: #111317;
  font-size: 0.56rem;
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: 0;
  pointer-events: auto;
}

.creator-credit a {
  color: inherit;
  text-decoration: none;
}

.creator-credit a:hover,
.creator-credit a:focus-visible {
  text-decoration: underline;
  outline: none;
}

.layout {
  display: grid;
  grid-template-columns: clamp(300px, 22vw, 360px) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  min-height: 0;
  transition: grid-template-columns 0.22s ease;
}

body.controls-collapsed .layout {
  grid-template-columns: 42px minmax(0, 1fr);
}

.controls-panel,
.work-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass);
  box-shadow: 0 16px 42px rgba(20, 24, 30, 0.1);
  backdrop-filter: blur(18px);
}

.controls-panel {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 16px;
  transition: padding 0.2s ease;
}

.work-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(246, 248, 250, 0.72);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  backdrop-filter: blur(3px);
}

.busy-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.busy-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 210px;
  padding: 18px 20px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
  color: var(--ink);
}

.busy-card img {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.busy-spiral {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #111827 0 4px, transparent 5px),
    repeating-conic-gradient(from 0deg, #111827 0 18deg, transparent 18deg 31deg);
  -webkit-mask:
    radial-gradient(circle at center, transparent 0 9px, #000 10px 46px),
    conic-gradient(from -90deg, #000 0deg, #000 var(--busy-sweep), transparent var(--busy-sweep));
  mask:
    radial-gradient(circle at center, transparent 0 9px, #000 10px 46px),
    conic-gradient(from -90deg, #000 0deg, #000 var(--busy-sweep), transparent var(--busy-sweep));
  animation: busy-spiral-grow 1.05s steps(9, end) infinite;
}

@property --busy-sweep {
  syntax: "<angle>";
  inherits: false;
  initial-value: 20deg;
}

@keyframes busy-spiral-grow {
  0% { --busy-sweep: 24deg; transform: rotate(0deg) scale(0.82); opacity: 0.45; }
  70% { --busy-sweep: 340deg; transform: rotate(28deg) scale(1); opacity: 1; }
  100% { --busy-sweep: 360deg; transform: rotate(45deg) scale(1.02); opacity: 0.62; }
}

.busy-card img {
  object-fit: contain;
}

.busy-card strong {
  font-size: 0.98rem;
}

.busy-card span {
  color: var(--muted);
  font-size: 0.86rem;
}

.panel-title-row,
.button-row,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title-row {
  position: sticky;
  top: 0;
  z-index: 3;
  margin: -16px -16px 12px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(18,22,27,0.08);
}

.controls-collapse-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.8);
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
}

body.controls-collapsed .controls-panel {
  padding: 0;
  overflow: hidden;
}

body.controls-collapsed .controls-panel > :not(.panel-title-row) {
  display: none;
}

body.controls-collapsed .panel-title-row {
  display: grid;
  place-items: center;
  height: 100%;
  margin: 0;
  padding: 0;
  border-bottom: 0;
  background: rgba(255,255,255,0.74);
}

body.controls-collapsed .panel-title-row h2 {
  display: none;
}

body.controls-collapsed .controls-collapse-button {
  transform: rotate(180deg);
}

.button-row {
  justify-content: end;
  gap: 8px;
}

.pdf-annotation-panel {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(18,22,27,0.1);
  background: rgba(255,255,255,0.64);
}

.annotation-tool-row,
.annotation-scale-row,
.annotation-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.annotation-tool-row label,
.annotation-scale-row label {
  display: inline-grid;
  gap: 3px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
}

.annotation-tool-row select,
.annotation-tool-row input,
.annotation-scale-row input {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 5px 8px;
  font-size: 0.78rem;
  font-weight: 600;
}

.annotation-text-field {
  min-width: min(280px, 100%);
  flex: 1;
}

.annotation-scale-row input {
  width: 70px;
}

.annotation-status {
  min-height: 16px;
  color: var(--muted);
  font-size: 0.72rem;
}

.annotation-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  border: 1px solid rgba(17,24,39,0.14);
  border-radius: 999px;
  background: rgba(255,255,255,0.84);
  padding: 3px 4px 3px 9px;
  color: var(--ink);
  font-size: 0.7rem;
  font-weight: 700;
}

.annotation-pill button {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-size: 0.76rem;
  line-height: 1;
}

.plan-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
}

.plan-tool-buttons button {
  min-width: 38px;
  min-height: 28px;
  padding: 4px 8px;
  font-size: 0.72rem;
}

.plan-note-entry,
.plan-scale-controls,
.plan-display-controls,
.plan-snap-controls,
.plan-zoom-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.plan-note-entry label,
.plan-scale-controls label,
.plan-display-controls label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
}

.plan-note-entry input,
.plan-note-entry select,
.plan-scale-controls select,
.plan-display-controls select {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 4px 7px;
  font-size: 0.72rem;
  font-weight: 600;
}

.plan-note-entry input {
  min-width: 132px;
}

.plan-scale-controls {
  max-width: 460px;
}

.plan-display-controls {
  max-width: 640px;
}

.plan-settings-menu {
  position: relative;
}

.plan-settings-menu summary {
  min-height: 28px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.plan-settings-menu summary::-webkit-details-marker {
  display: none;
}

.plan-settings-menu[open] {
  z-index: 20;
}

.plan-settings-menu[open] .plan-snap-controls,
.plan-settings-menu[open] .plan-scale-controls,
.plan-settings-menu[open] .plan-display-controls {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 320px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.18);
}

.plan-settings-menu[open] .plan-display-controls {
  top: calc(100% + 74px);
}

.plan-zoom-controls {
  align-items: center;
  min-height: 28px;
}

.plan-zoom-controls button {
  min-width: 28px;
  min-height: 28px;
  padding: 4px 8px;
}

.plan-zoom-controls span {
  min-width: 46px;
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 800;
  text-align: center;
}

.plan-toolbar .button-row {
  margin-left: auto;
  flex-wrap: nowrap;
}

.plan-toolbar .button-row button {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 0.72rem;
}

.plan-snap-controls label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 700;
}

.plan-status {
  min-height: 18px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.plan-sheet-frame {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dfe4ea;
  padding: 10px;
}

.plan-sheet-preview {
  display: grid;
  place-items: start center;
  min-width: 980px;
}

.plan-sheet-preview > svg {
  display: block;
  width: calc(1320px * var(--plan-zoom, 1));
  max-width: none;
  min-width: 720px;
  height: auto;
  background: #fff;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
}

.plan-view-hit-area {
  cursor: crosshair;
}

.plan-snap-marker,
.plan-user-annotations {
  pointer-events: none;
}

.contact-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(15, 23, 42, 0.42);
}

.contact-modal {
  position: relative;
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  overflow: auto;
  border: 1px solid rgba(17, 24, 39, 0.16);
  border-radius: 8px;
  background: #ffffff;
  padding: 22px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.contact-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 5px 7px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
}

.contact-modal-close:hover,
.contact-modal-close:focus-visible {
  color: var(--ink);
}

.contact-modal h2 {
  margin: 0 52px 6px 0;
  color: var(--ink);
  font-size: 1.3rem;
  line-height: 1.2;
}

.contact-modal p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

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

.contact-modal label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.contact-modal input,
.contact-modal textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
}

.contact-modal textarea {
  resize: vertical;
  line-height: 1.35;
}

.contact-modal-full {
  grid-column: 1 / -1;
}

.contact-modal-feedback {
  min-height: 18px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.contact-modal-feedback.error {
  color: #b91c1c;
}

.contact-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

@media (max-width: 680px) {
  .contact-modal-grid {
    grid-template-columns: 1fr;
  }
}

.input-tab-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.input-tab-list button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.input-tab-list button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.input-tab-list button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.access-card,
.mode-note,
.auto-size-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  padding: 12px;
}

.access-card {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  order: 5;
}

.internal-access-card {
  border-color: #c9d1dc;
  background: #f4f7fb;
  order: 6;
}

.access-copy {
  display: grid;
  gap: 4px;
}

.access-copy p {
  display: none;
}

.access-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.access-row input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
}

.access-feedback {
  min-height: 18px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.access-feedback.error {
  color: #b42318;
}

.mode-note {
  display: grid;
  gap: 6px;
}

.mode-note p,
.auto-size-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.auto-size-card {
  display: grid;
  gap: 8px;
}

.auto-size-card strong {
  font-size: 0.92rem;
}

.auto-adjust-row {
  display: grid;
  gap: 8px;
}

.auto-adjust-label {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.auto-adjust-toggle {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

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

.auto-size-chip {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 10px;
}

.auto-size-chip span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
}

.auto-size-chip strong {
  display: block;
  margin-top: 4px;
  font-size: 0.95rem;
}

.control-mode-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  padding: 12px;
}

.control-mode-copy {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.control-mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.control-group.is-readonly label::after {
  content: " Auto";
  color: var(--accent);
  font-size: 0.72rem;
}

.control-group input:disabled,
.control-group select:disabled,
.stepper-button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.control-stack {
  display: grid;
  gap: 12px;
  min-height: 0;
}

.selection-gate {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(17, 24, 39, 0.14);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.selection-gate .eyebrow {
  width: auto;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
  text-transform: uppercase;
}

.selection-gate strong {
  font-size: 0.96rem;
  line-height: 1.3;
}

.selection-gate p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.selection-gate-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.selection-gate-options .secondary-button {
  min-height: 40px;
}

.selection-gate-options .secondary-button.active {
  border-color: #090a0c;
  background: #090a0c;
  color: #ffffff;
}

.selection-gate-note,
.catalog-rule-note {
  border: 1px solid rgba(180, 83, 9, 0.2);
  border-radius: 8px;
  background: #fffaf0;
  color: #713f12;
  padding: 9px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.45;
}

.pricing-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.pricing-heading strong {
  font-size: 0.9rem;
}

.pricing-heading span {
  color: var(--muted);
  font-size: 0.67rem;
}

.pricing-rate-row {
  display: grid;
  gap: 5px;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
}

.pricing-rate-row input {
  width: 100%;
  min-height: 37px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 7px 9px;
  font: inherit;
}

.pricing-total {
  border-radius: 8px;
  background: #090a0c;
  color: #ffffff;
  padding: 11px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: right;
}

.control-section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 8px 0 -2px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--accent);
  font-size: 0.84rem;
  letter-spacing: 0;
  text-transform: uppercase;
  text-align: left;
  padding: 0 0 6px;
}

.control-section-heading span {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  font-size: 0.72rem;
}

.control-section-heading strong {
  font-size: inherit;
}

.control-group {
  display: grid;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.control-group label {
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 700;
}

.control-hint {
  display: none;
}

.control-group input,
.control-group select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 7px 9px;
}

.control-group input:focus,
.control-group select:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(15, 118, 110, 0.16);
}

.input-stepper {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.range-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  gap: 8px;
  align-items: center;
}

.control-group input[type="range"] {
  min-height: 38px;
  padding: 0;
  accent-color: var(--accent);
}

.range-control input[type="text"] {
  text-align: right;
}

.stepper-buttons {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
  width: 34px;
}

.stepper-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 700;
  min-height: 0;
  font-size: 0.72rem;
  line-height: 1;
  padding: 0;
}

.stepper-button:hover,
.stepper-button:focus-visible {
  border-color: var(--accent);
  background: rgba(15, 118, 110, 0.08);
  outline: none;
}

.tab-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border-bottom: 1px solid var(--line);
  background: rgba(248, 249, 250, 0.56);
  padding: 8px;
  gap: 8px;
}

.tab-button,
.segmented-control button,
.secondary-button,
.primary-button,
.view-gizmo button {
  border-radius: 8px;
  min-height: 36px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.tab-button,
.segmented-control button,
.secondary-button,
.view-gizmo button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.64);
  color: var(--ink);
  backdrop-filter: blur(14px);
}

.tab-button.active,
.segmented-control button.active {
  border-color: #090a0c;
  background: #090a0c;
  color: white;
}

.tab-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.secondary-button {
  padding: 0 10px;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
}

.primary-button {
  min-height: 40px;
  background: #090a0c;
  color: white;
  font-weight: 600;
  padding: 0 14px;
}

.primary-button:hover,
.tab-button.active:hover,
.segmented-control button.active:hover {
  background: #2b2f35;
}

.tab-panel {
  display: none;
  padding: 12px;
  min-height: 0;
  overflow: hidden;
}

.tab-panel.active {
  display: block;
  height: 100%;
  overflow: auto;
  scrollbar-gutter: stable;
}

#tab-three.active,
#tab-plans.active,
#tab-treads.active,
#tab-pdf.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

#tab-results.active {
  padding-bottom: 32px;
}

#tab-treads.active {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

#tab-plans.active {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.toolbar {
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segmented-control button {
  padding: 0 12px;
  font-weight: 700;
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

.toolbar-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.toolbar-select label {
  font-weight: 700;
}

.toolbar-select select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
}

.toggle-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.viewport-frame,
.developed-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  user-select: none;
  -webkit-user-select: none;
}

.viewport-frame {
  height: 100%;
  min-height: 0;
  touch-action: none;
  cursor: default;
}

.viewport-actions {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: min(620px, calc(100% - 220px));
}

.developed-frame {
  min-height: 500px;
  touch-action: none;
}

#view3d,
#view2d,
#viewTreadsPlan,
#viewTreadsLower,
#viewTreadsSection,
#viewPdfTop,
#viewPdfLower,
#viewPdfSection {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-select: none;
}

#view3d,
#view2d {
  cursor: default;
  touch-action: none;
}

#view3d:active,
#view2d:active {
  cursor: default;
}

.control-group input[type="text"],
.control-group input[type="number"],
.control-group textarea,
.access-row input {
  cursor: text;
}

.control-group select,
.toolbar-select select {
  cursor: pointer;
}

#view2d {
  min-height: 500px;
}

.tread-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(340px, 0.86fr);
  gap: 12px;
  align-items: stretch;
  min-height: 0;
  height: 100%;
}

.layout-choice-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.62fr) minmax(460px, 1.9fr);
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.layout-choice-heading {
  display: grid;
  align-content: start;
  gap: 7px;
  padding-right: 8px;
}

.layout-choice-heading .eyebrow {
  margin: 0 0 4px;
}

.layout-choice-heading h2 {
  margin: 0;
  font-size: 1.06rem;
}

.layout-choice-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.42;
}

.layout-choice-group h3 {
  margin: 0 0 7px;
  font-size: 0.86rem;
}

.layout-choice-journey {
  display: grid;
  gap: 10px;
}

.layout-completed-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.layout-completed-choice {
  display: grid;
  gap: 2px;
  min-height: 43px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f8fa;
  color: var(--ink);
  padding: 6px 9px;
  text-align: left;
}

.layout-completed-choice:hover,
.layout-completed-choice:focus-visible {
  border-color: #111827;
  outline: none;
}

.layout-completed-choice span {
  color: var(--muted);
  font-size: 0.64rem;
}

.layout-completed-choice strong {
  font-size: 0.73rem;
}

.layout-current-step {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.layout-current-step.complete {
  align-content: start;
}

.layout-current-step.complete .primary-button {
  justify-self: start;
  margin-top: 4px;
}

.layout-step-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.layout-current-step h3 {
  margin: 0;
  font-size: 0.98rem;
}

.layout-step-prompt {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.layout-option-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.layout-option {
  position: relative;
}

.layout-option-button {
  display: grid;
  gap: 2px;
  min-height: 48px;
  min-width: 142px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.layout-option-button:hover,
.layout-option-button:focus-visible {
  border-color: #111827;
  outline: none;
}

.layout-option.selected .layout-option-button {
  border-color: #101114;
  background: #f1f3f5;
}

.layout-option.quote-only .layout-option-button {
  border-style: dashed;
  cursor: help;
}

.layout-option-label {
  font-size: 0.78rem;
  font-weight: 700;
}

.layout-option-status {
  color: var(--muted);
  font-size: 0.67rem;
}

.layout-option-preview {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 25;
  display: none;
  width: 260px;
  overflow: hidden;
  border: 1px solid #d6dbe1;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.17);
}

.layout-step-sidebar .secondary-button {
  width: 100%;
}

.quote-contact-prompt {
  margin-bottom: 10px;
  border: 1px solid rgba(15, 118, 110, 0.25);
  border-left: 4px solid #0f766e;
  border-radius: 8px;
  background: #f0fdfa;
  color: #134e4a;
  padding: 9px 12px;
  font-size: 0.82rem;
}

.quote-contact-prompt strong {
  display: block;
  margin-bottom: 2px;
}

.layout-option:hover .layout-option-preview,
.layout-option:focus-within .layout-option-preview {
  display: grid;
}

.layout-option-preview img {
  display: block;
  width: 100%;
  height: 128px;
  object-fit: cover;
  background: var(--surface-2);
}

.layout-option-preview strong,
.layout-option-preview p,
.layout-option-preview a {
  margin-left: 11px;
  margin-right: 11px;
}

.layout-option-preview strong {
  margin-top: 10px;
  font-size: 0.85rem;
}

.layout-option-preview p {
  margin-top: 5px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.38;
}

.layout-option-price {
  color: #0f766e !important;
  font-weight: 700;
}

.layout-option-preview a {
  margin-bottom: 10px;
  color: #1d4ed8;
  font-size: 0.72rem;
  text-decoration: none;
}

.admin-config-panel {
  display: grid;
  gap: 12px;
}

.admin-config-header,
.admin-config-filters,
.admin-pricing-panel,
.admin-config-steps,
.admin-config-editor {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.admin-config-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
  padding: 16px;
}

.admin-config-header h2 {
  margin: 4px 0 6px;
  font-size: 1.2rem;
}

.admin-config-header p:not(.eyebrow) {
  margin: 0;
  max-width: 680px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.admin-config-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 7px;
}

.admin-config-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 14px;
}

.admin-pricing-panel {
  display: grid;
  gap: 11px;
  padding: 13px 14px;
}

.admin-pricing-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.admin-pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 9px;
}

.admin-pricing-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.admin-pricing-grid .admin-config-field {
  min-width: 0;
}

.admin-pricing-subtitle {
  margin: 2px 0 0;
  font-size: 0.85rem;
}

.admin-config-field {
  display: grid;
  gap: 5px;
  min-width: min(260px, 100%);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.admin-config-field input,
.admin-config-field textarea,
.admin-config-field select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
  font-size: 0.83rem;
  font-weight: 500;
}

.admin-config-field textarea {
  min-height: 68px;
  resize: vertical;
}

.admin-config-workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.76fr) minmax(500px, 1.45fr);
  gap: 12px;
  align-items: start;
}

.admin-config-steps,
.admin-config-editor {
  display: grid;
  gap: 9px;
  align-content: start;
  padding: 12px;
}

.admin-config-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}

.admin-config-section-head h3,
.admin-config-editor > h3 {
  margin: 0;
  font-size: 0.95rem;
}

.admin-step-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  align-items: center;
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbfc;
}

.admin-step-row.active {
  border-color: #111827;
  background: #f1f3f5;
}

.admin-step-select {
  display: grid;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 4px 5px;
  text-align: left;
}

.admin-step-select span {
  font-size: 0.79rem;
  font-weight: 700;
}

.admin-step-select small {
  color: var(--muted);
  font-size: 0.66rem;
}

.admin-icon-button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 7px;
  font-size: 0.69rem;
  font-weight: 700;
}

.admin-icon-button:disabled {
  opacity: 0.42;
}

.admin-icon-button.danger {
  color: #991b1b;
}

.admin-config-help {
  margin: 0 0 4px;
  border-radius: 7px;
  background: #f7f8fa;
  color: var(--muted);
  padding: 9px 10px;
  font-size: 0.77rem;
  line-height: 1.42;
}

.admin-option-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbfc;
  padding: 11px;
}

.admin-option-card > strong {
  font-size: 0.84rem;
}

.admin-option-card .admin-config-field {
  min-width: 0;
}

.tread-views-column {
  display: grid;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-height: 0;
}

.tread-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
  min-height: 0;
  height: 100%;
}

.tread-view-frame {
  min-height: 0;
  height: 100%;
}

.tread-lower-frame {
  min-height: 0;
}

.tread-section-frame {
  min-height: 0;
}

.viewport-help {
  position: absolute;
  left: 12px;
  top: 58px;
  max-width: min(420px, calc(100% - 250px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 0.82rem;
  pointer-events: none;
}

.compliance-banner {
  position: absolute;
  left: 12px;
  top: 54px;
  max-width: min(520px, calc(100% - 190px));
  border: 1px solid #f59e0b;
  border-left: 4px solid #b42318;
  border-radius: 8px;
  background: rgba(255, 251, 235, 0.96);
  color: #7c2d12;
  padding: 8px 10px;
  font-size: 0.82rem;
  line-height: 1.35;
  pointer-events: none;
}

.compliance-banner:empty {
  display: none;
}

.view-gizmo {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 170px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  padding: 8px;
  box-shadow: 0 8px 20px rgba(32, 33, 36, 0.12);
}

.view-gizmo svg {
  display: block;
  margin: 0 auto 6px;
}

.gizmo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.gizmo-grid button {
  min-height: 30px;
  font-size: 0.76rem;
  font-weight: 700;
}

.note-line,
.cad-note {
  display: none;
}

.mode-note p,
.auto-size-card p,
.control-mode-copy,
.auto-adjust-label {
  display: none;
}

.note-line,
.cad-note {
  border: 1px solid var(--line);
  border-left: 4px solid var(--warning);
  border-radius: 8px;
  background: #fffaf0;
  color: #523a12;
  padding: 10px 12px;
  font-size: 0.88rem;
  line-height: 1.4;
}

.note-line {
  margin-bottom: 12px;
}

.cad-note {
  margin: 10px 0 0;
}

.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.pdf-toolbar {
  justify-content: space-between;
}

.pdf-sheet {
  display: grid;
  grid-template-rows: auto minmax(0, 1.22fr) minmax(0, 0.98fr) auto;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.pdf-sheet-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}

.pdf-sheet-header .eyebrow {
  margin-bottom: 4px;
}

.pdf-sheet-header h2 {
  font-size: 1.02rem;
}

.pdf-sheet-meta {
  display: grid;
  gap: 3px;
  justify-items: end;
  color: var(--muted);
  font-size: 0.58rem;
  text-align: right;
}

.pdf-template-layout {
  display: grid;
  grid-template-columns: minmax(230px, 1.04fr) minmax(220px, 0.9fr) minmax(250px, 0.86fr);
  gap: 6px;
  min-height: 0;
  height: 100%;
  align-items: stretch;
}

.pdf-views-column,
.pdf-quote-card {
  display: grid;
  gap: 6px;
  min-height: 0;
  height: 100%;
}

.pdf-views-column {
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.pdf-quote-card {
  grid-template-rows: minmax(0, 0.84fr) minmax(0, 1.16fr);
}

.pdf-sheet-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 5px;
  min-height: 0;
  height: 100%;
}

.pdf-sheet-card h3 {
  margin-bottom: 0;
  font-size: 0.8rem;
}

.pdf-card-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 8px;
}

.pdf-card-heading span {
  color: var(--muted);
  font-size: 0.6rem;
  text-align: right;
}

.pdf-view-card {
  grid-template-rows: auto minmax(0, 1fr);
}

.pdf-view-frame {
  position: relative;
  display: flex;
  min-height: 0;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #ffffff;
}

.pdf-view-frame svg {
  display: block;
  flex: 1;
  width: 100%;
  height: 100%;
}

.pdf-card-section {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
  gap: 6px;
  min-height: 0;
  height: 100%;
}

.pdf-form-grid {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.pdf-form-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.75fr) minmax(0, 1.25fr);
  align-items: stretch;
  background: #ffffff;
}

.pdf-form-row.is-double {
  grid-template-columns: minmax(70px, 0.5fr) minmax(0, 1.14fr) minmax(70px, 0.5fr) minmax(0, 1.14fr);
}

.pdf-form-row + .pdf-form-row,
.pdf-data-row + .pdf-data-row,
.pdf-part-row + .pdf-part-row,
.pdf-total-row + .pdf-total-row {
  border-top: 1px solid var(--line);
}

.pdf-form-row.is-multiline {
  align-items: stretch;
}

.pdf-form-label,
.pdf-data-label,
.pdf-total-label {
  display: grid;
  align-items: center;
  min-height: 15px;
  padding: 2px 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.52rem;
  font-weight: 700;
}

.pdf-form-control,
.pdf-data-input,
.pdf-mini-input,
.pdf-select,
.pdf-total-input,
.pdf-total-value {
  min-width: 0;
  width: 100%;
  min-height: 15px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 2px 5px;
  font: inherit;
  font-size: 0.56rem;
  line-height: 1.04;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-part-cell {
  min-width: 0;
  width: 100%;
  min-height: 15px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 2px 5px;
  font: inherit;
  font-size: 0.56rem;
  line-height: 1.04;
  overflow-wrap: anywhere;
}

.pdf-form-control:focus,
.pdf-data-input:focus,
.pdf-part-cell:focus,
.pdf-mini-input:focus,
.pdf-select:focus,
.pdf-total-input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.16);
  outline-offset: -2px;
}

.pdf-form-textarea {
  min-height: 26px;
  resize: vertical;
}

.pdf-data-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.pdf-data-header,
.pdf-data-row {
  display: flex;
  align-items: stretch;
}

.pdf-data-header {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.52rem;
  font-weight: 700;
}

.pdf-data-header > div,
.pdf-data-label,
.pdf-data-input {
  min-width: 0;
}

.pdf-data-header-label,
.pdf-data-label {
  flex: 0.95;
}

.pdf-data-header-value,
.pdf-data-input {
  flex: 1;
}

.pdf-data-header > div {
  padding: 2px 5px;
}

.pdf-data-header-value,
.pdf-data-input {
  border-left: 1px solid var(--line);
}

.pdf-bottom-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.68fr) minmax(240px, 0.52fr);
  gap: 6px;
  min-height: 0;
  height: 100%;
  align-items: stretch;
}

.pdf-parts-card {
  min-height: 0;
}

.pdf-parts-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.pdf-parts-header,
.pdf-part-row {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.16fr) minmax(56px, 0.34fr) minmax(0, 0.9fr) minmax(58px, 0.38fr) minmax(72px, 0.46fr) 28px;
  align-items: stretch;
}

.pdf-parts-header {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.52rem;
  font-weight: 700;
}

.pdf-parts-header > div {
  display: grid;
  align-items: center;
  padding: 2px 5px;
}

.pdf-parts-header > div + div {
  border-left: 1px solid var(--line);
}

.pdf-part-cell {
  border-left: 1px solid var(--line);
}

.pdf-part-remove {
  width: 34px;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--accent-2);
  font-weight: 700;
}

.pdf-part-remove:hover,
.pdf-part-remove:focus-visible {
  background: rgba(180, 35, 24, 0.08);
  outline: none;
}

.pdf-part-static {
  border-left: 1px solid var(--line);
  background: transparent;
}

.pdf-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 5px;
  align-content: start;
  min-height: 0;
  height: 100%;
}

.pdf-mini-card {
  align-content: start;
}

.pdf-option-list,
.pdf-mini-fields,
.pdf-totals-list {
  display: grid;
  gap: 4px;
}

.pdf-option {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.55rem;
}

.pdf-option input {
  margin: 0;
}

.pdf-mini-field {
  display: grid;
  gap: 4px;
}

.pdf-mini-field label {
  color: var(--muted);
  font-size: 0.5rem;
  font-weight: 700;
}

.pdf-total-row {
  display: grid;
  grid-template-columns: minmax(88px, 0.8fr) minmax(0, 1.2fr);
}

.pdf-total-value {
  display: grid;
  align-items: center;
}

.pdf-disclaimer {
  margin: 0;
  color: var(--muted);
  font-size: 0.54rem;
  line-height: 1.2;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.result-tile {
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.result-tile span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.result-tile strong {
  display: block;
  margin-top: 8px;
  font-size: 1.08rem;
  word-break: break-word;
}

.svg-label {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  fill: var(--ink);
}

.svg-label-small {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  fill: var(--muted);
}

.svg-label-tiny {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 9.5px;
  fill: var(--muted);
}

@media (max-width: 1120px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-strip {
    width: 100%;
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  }

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

  .tread-layout,
  .layout-choice-panel,
  .admin-config-workspace,
  .pdf-template-layout,
  .pdf-bottom-layout,
  .pdf-mini-grid {
    grid-template-columns: 1fr;
  }

  .tread-views-column {
    grid-template-rows: auto;
  }

  .pdf-template-layout {
    grid-template-columns: 1fr;
  }

  .pdf-sheet {
    aspect-ratio: auto;
  }

  .pdf-views-column,
  .pdf-quote-card {
    grid-template-rows: auto;
  }

  .tread-view-frame,
  .tread-lower-frame,
  .tread-section-frame {
    min-height: 360px;
  }

  .pdf-parts-header,
  .pdf-part-row {
    grid-template-columns: minmax(90px, 0.8fr) minmax(120px, 1.15fr) 68px minmax(110px, 1fr) 70px 80px auto;
  }

  .viewport-help {
    max-width: min(360px, calc(100% - 240px));
  }

  .admin-config-header {
    flex-direction: column;
  }

  .admin-config-actions {
    justify-content: start;
  }
}

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

  .controls-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 16px, 1500px);
    padding-top: 10px;
  }

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

  .summary-strip {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  }

  .tab-list {
    grid-template-columns: 1fr;
  }

  .pdf-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .tread-view-frame,
  .tread-lower-frame,
  .tread-section-frame {
    min-height: 320px;
    aspect-ratio: 1 / 1;
  }

  .pdf-sheet-header,
  .pdf-card-heading,
  .pdf-data-header,
  .pdf-form-row,
  .pdf-total-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .pdf-card-heading {
    align-items: stretch;
  }

  .pdf-form-row.is-double {
    grid-template-columns: 1fr;
  }

  .pdf-sheet-meta,
  .pdf-card-heading span {
    justify-items: start;
    text-align: left;
  }

  .pdf-data-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .pdf-data-header {
    display: none;
  }

  .pdf-data-input,
  .pdf-form-control,
  .pdf-total-input,
  .pdf-total-value {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .pdf-parts-header {
    display: none;
  }

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

  .pdf-part-cell,
  .pdf-part-static,
  .pdf-part-remove {
    width: 100%;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .viewport-frame {
    min-height: 360px;
    height: 62vh;
  }

  .viewport-help {
    max-width: calc(100% - 24px);
    top: auto;
    bottom: 12px;
  }

  .compliance-banner {
    max-width: calc(100% - 24px);
    top: 12px;
    right: 12px;
  }

  .view-gizmo {
    width: 150px;
  }
}

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

  html,
  body,
  body.printing-pdf {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body.printing-pdf {
    background: #ffffff;
  }

  body.printing-pdf .app-shell {
    width: auto;
    margin: 0;
    padding: 0;
  }

  body.printing-pdf .topbar,
  body.printing-pdf .controls-panel,
  body.printing-pdf .tab-list,
  body.printing-pdf .toolbar,
  body.printing-pdf .busy-overlay,
  body.printing-pdf .contact-modal-backdrop,
  body.printing-pdf .pdf-annotation-panel,
  body.printing-pdf .note-line,
  body.printing-pdf .cad-note,
  body.printing-pdf #tab-three,
  body.printing-pdf #tab-plans,
  body.printing-pdf #tab-developed,
  body.printing-pdf #tab-treads,
  body.printing-pdf #tab-results {
    display: none !important;
  }

  body.printing-pdf .layout {
    display: block;
  }

  body.printing-pdf .work-panel {
    border: 0;
    box-shadow: none;
    overflow: visible;
    background: transparent;
  }

  body.printing-pdf #tab-pdf {
    display: block !important;
    padding: 0;
  }

  body.printing-pdf .pdf-sheet {
    display: grid !important;
    border: 0;
    padding: 0;
    width: 281mm;
    max-width: 281mm;
    height: 198mm;
    min-height: 198mm !important;
    max-height: 198mm;
    flex: none !important;
    aspect-ratio: auto;
    overflow: visible;
    margin: 0 auto;
    gap: 1.35mm;
    grid-template-rows: auto minmax(0, 1.5fr) minmax(0, 0.7fr) auto;
    align-content: stretch;
  }

  body.printing-pdf .pdf-template-layout {
    display: grid !important;
    grid-template-columns: minmax(0, 1.04fr) minmax(0, 0.88fr) minmax(0, 0.86fr);
    gap: 1.35mm;
    min-height: 0;
    height: 100%;
    align-items: stretch;
  }

  body.printing-pdf .pdf-views-column,
  body.printing-pdf .pdf-quote-card {
    display: grid !important;
    gap: 1.35mm;
    min-height: 0;
    height: 100%;
  }

  body.printing-pdf .pdf-views-column {
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  body.printing-pdf .pdf-quote-card {
    grid-template-rows: minmax(0, 0.86fr) minmax(0, 1.14fr);
  }

  body.printing-pdf .pdf-bottom-layout {
    display: grid !important;
    grid-template-columns: minmax(0, 1.74fr) minmax(0, 0.48fr);
    gap: 1.35mm;
    min-height: 0;
    height: 100%;
    margin-top: 0;
    align-items: stretch;
  }

  body.printing-pdf .pdf-mini-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(0, 1fr);
    gap: 1.35mm;
    min-height: 0;
    height: 100%;
  }

  body.printing-pdf .pdf-sheet-header {
    padding-bottom: 1.2mm;
    margin-bottom: 0.8mm;
  }

  body.printing-pdf .pdf-sheet-header h2 {
    font-size: 1.02rem;
  }

  body.printing-pdf .pdf-sheet-meta,
  body.printing-pdf .pdf-card-heading span {
    font-size: 0.53rem;
  }

  body.printing-pdf .pdf-sheet-card,
  body.printing-pdf .pdf-card-section {
    gap: 0.8mm;
    padding: 0.9mm;
    height: 100%;
  }

  body.printing-pdf .pdf-sheet-header,
  body.printing-pdf .pdf-card-heading {
    display: flex !important;
    align-items: end;
    justify-content: space-between;
  }

  body.printing-pdf .pdf-sheet-meta,
  body.printing-pdf .pdf-card-heading span {
    justify-items: end;
    text-align: right;
  }

  body.printing-pdf .pdf-form-row {
    display: grid !important;
    grid-template-columns: minmax(110px, 0.75fr) minmax(0, 1.25fr);
  }

  body.printing-pdf .pdf-form-row.is-double {
    grid-template-columns: minmax(56px, 0.46fr) minmax(0, 1.18fr) minmax(56px, 0.46fr) minmax(0, 1.18fr);
  }

  body.printing-pdf .pdf-data-header,
  body.printing-pdf .pdf-data-row {
    display: flex !important;
  }

  body.printing-pdf .pdf-parts-header,
  body.printing-pdf .pdf-part-row {
    display: grid !important;
    grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.16fr) minmax(56px, 0.34fr) minmax(0, 0.9fr) minmax(58px, 0.38fr) minmax(72px, 0.46fr) 28px;
  }

  body.printing-pdf .pdf-form-label,
  body.printing-pdf .pdf-data-label,
  body.printing-pdf .pdf-total-label,
  body.printing-pdf .pdf-data-header,
  body.printing-pdf .pdf-parts-header {
    font-size: 0.48rem;
  }

  body.printing-pdf .pdf-form-label,
  body.printing-pdf .pdf-data-label,
  body.printing-pdf .pdf-total-label,
  body.printing-pdf .pdf-data-header > div,
  body.printing-pdf .pdf-parts-header > div {
    min-height: 14px;
    padding: 1px 3px;
  }

  body.printing-pdf .pdf-form-control,
  body.printing-pdf .pdf-data-input,
  body.printing-pdf .pdf-part-cell,
  body.printing-pdf .pdf-mini-input,
  body.printing-pdf .pdf-total-input,
  body.printing-pdf .pdf-total-value {
    min-height: 14px;
    padding: 1px 3px;
    font-size: 0.52rem;
  }

  body.printing-pdf .pdf-form-textarea {
    min-height: 18px;
    resize: none;
  }

  body.printing-pdf .pdf-option {
    gap: 3px;
    font-size: 0.54rem;
  }

  body.printing-pdf .pdf-mini-field {
    gap: 2px;
  }

  body.printing-pdf .pdf-mini-field label {
    font-size: 0.5rem;
  }

  body.printing-pdf .pdf-option-list,
  body.printing-pdf .pdf-mini-fields,
  body.printing-pdf .pdf-totals-list {
    gap: 1px;
  }

  body.printing-pdf .pdf-disclaimer {
    font-size: 0.45rem;
    line-height: 1.05;
  }

  body.printing-pdf .pdf-form-control,
  body.printing-pdf .pdf-data-input,
  body.printing-pdf .pdf-part-cell,
  body.printing-pdf .pdf-mini-input,
  body.printing-pdf .pdf-total-input,
  body.printing-pdf .pdf-total-value {
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  body.printing-pdf .pdf-view-card,
  body.printing-pdf .pdf-section-card,
  body.printing-pdf .pdf-mini-card,
  body.printing-pdf .pdf-parts-card {
    grid-template-rows: auto minmax(0, 1fr);
  }

  body.printing-pdf .pdf-view-frame {
    min-height: 0;
    height: 100%;
  }

  body.printing-pdf .pdf-disclaimer {
    margin-top: 0.4mm;
  }

  body.printing-pdf .pdf-toolbar,
  body.printing-pdf .quote-contact-prompt,
  body.printing-pdf .pdf-part-remove {
    display: none !important;
  }
}

#tab-treads.active,
#tab-pdf.active {
  display: flex;
  flex-direction: column;
}

#tab-treads.active .tread-layout {
  flex: 1;
  min-height: clamp(620px, calc(100vh - 210px), 880px);
}

#tab-pdf.active .pdf-sheet {
  flex: 1;
  min-height: clamp(680px, calc(100vh - 220px), 980px);
}

@media (max-width: 1280px) {
  .plan-toolbar {
    align-items: start;
    justify-content: start;
  }

  .plan-toolbar .button-row {
    margin-left: 0;
  }
}
