:root {
  --page: #f7f3ec;
  --paper: #ffffff;
  --ink: #1f2933;
  --muted: #5f6b76;
  --line: #d9d2c7;
  --blue: #146c94;
  --blue-dark: #0e516f;
  --amber: #b86913;
  --red: #b42318;
  --shadow: 0 16px 36px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  background: var(--page);
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
select,
textarea {
  font: inherit;
  font-size: 16px;
}

button,
a,
input[type="submit"],
input[type="button"],
.preset-chip {
  cursor: pointer;
}

button,
[role="button"] {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--primary, #0284c7) !important;
  outline-offset: 2px !important;
}

button:active,
a:active,
.preset-chip:active {
  transform: translateY(1px);
}

table, .badge, [data-report], td, th, .tabular-nums {
  font-variant-numeric: tabular-nums;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 243, 236, 0.96);
}

.topbar__inner {
  width: min(1180px, calc(100% - 32px));
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-header nav {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  max-width: 100%;
}

.wordmark,
.promise,
.eyebrow,
.value-bar__copy,
.card-heading p,
.status-panel p {
  margin: 0;
}

.wordmark,
h1,
h2,
.status-panel__header strong {
  font-family: var(--font-heading, "Plus Jakarta Sans", "Inter", sans-serif);
  font-weight: 700;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 1rem;
  color: var(--ink);
  text-decoration: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--blue-dark);
  background: #eef7f9;
  font-size: 0.78rem;
  font-weight: 700;
}

.promise {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(20, 108, 148, 0.22);
  border-radius: 8px;
  color: var(--blue-dark);
  background: #eef7f9;
  font-weight: 600;
  white-space: nowrap;
}

.save-status__dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--blue);
}

.factory-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.value-bar {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--blue-dark);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.2;
}

.pro-upgrade-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  background: var(--ink);
  color: #ffffff;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.15s ease;
}

.site-header .pro-link,
.site-header .jump-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--on-primary, #ffffff) !important;
  background: var(--primary) !important;
  font-size: 0.85rem;
  font-weight: 700 !important;
  text-decoration: none !important;
  white-space: nowrap;
}

.site-header .jump-tool-btn {
  background: var(--blue-dark) !important;
}

.pro-upgrade-btn:hover {
  background: #000000;
}

.preset-chip {
  background: #ffffff;
  border: 1px solid var(--line);
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.preset-chip:hover {
  border-color: var(--blue);
  background: #f0f7fa;
}

.value-bar__copy {
  max-width: 780px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 68fr) minmax(280px, 32fr);
  gap: 32px;
  align-items: start;
}

.workbench-pane {
  min-width: 0;
}

.intake {
  display: grid;
  gap: 24px;
  grid-column: 1;
}

.paper-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.paper-card--active {
  border-color: rgba(20, 108, 148, 0.42);
}

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

.card-number {
  display: inline-grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--blue);
  font-weight: 800;
}

h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
}

.card-heading p {
  color: var(--muted);
  line-height: 1.45;
}

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

.field-grid > .field {
  min-width: 220px;
}

.field-stack {
  display: grid;
  gap: 16px;
}

.field,
.checkbox-field {
  display: grid;
  gap: 8px;
}

.field--wide {
  grid-column: 1 / -1;
}

.validation-summary {
  padding: 16px;
  border: 1px solid rgba(180, 35, 24, 0.42);
  border-radius: 8px;
  color: var(--red);
  background: #fff5f2;
}

.validation-summary strong {
  display: block;
  margin-bottom: 8px;
}

.validation-summary ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 20px;
}

.field span,
.checkbox-field {
  color: var(--ink);
  font-size: 0.93rem;
  font-weight: 700;
}

.field strong {
  margin-left: 6px;
  color: var(--amber);
  font-size: 0.72rem;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #bfc7cf;
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: #ffffff;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

.field.is-invalid input,
.field.is-invalid select,
.field.is-invalid textarea {
  border-color: var(--red);
  box-shadow: 0 0 0 1px rgba(180, 35, 24, 0.12);
}

.field-error {
  min-height: 1.2em;
  color: var(--red);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.35;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(20, 108, 148, 0.18);
  border-color: var(--blue);
}

.parts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.parts-row input {
  min-width: 220px;
}

.secondary-action {
  min-height: 40px;
  margin-top: 16px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--blue-dark);
  background: #ffffff;
  font-weight: 700;
}

.checkbox-field {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  margin-top: 16px;
  color: var(--muted);
  font-weight: 600;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
  margin: 2px 0 0;
}

.action-bar,
.form-action-dock {
  position: static;
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
  padding: 16px 0 0;
  background: transparent;
}

.primary-action {
  min-height: 48px;
  min-width: 184px;
  padding: 0 20px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: var(--blue);
  font-weight: 800;
}

.primary-action:disabled {
  cursor: not-allowed;
  background: #7f9bac;
}

.closeout-packet {
  margin-top: 24px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.jump-shelf {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  margin-top: 24px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px 10px 0 0;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -8px 20px rgba(31, 41, 51, 0.08);
}

.jump-shelf span {
  font-size: 0.85rem;
  font-weight: 800;
}

.jump-shelf a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--on-primary, #ffffff);
  background: var(--primary);
  font-size: 0.84rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.packet-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.packet-kicker {
  margin: 0 0 6px;
  color: var(--blue-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.packet-meta,
.report-list {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
}

.packet-meta {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.packet-meta div,
.report-list div {
  min-width: 0;
}

.packet-meta dt,
.report-list dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.packet-meta dd,
.report-list dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  line-height: 1.35;
}

.print-action {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(20, 108, 148, 0.34);
  border-radius: 8px;
  color: var(--blue-dark);
  background: #eef7f9;
  font-weight: 800;
}

.packet-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.packet-section {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
}

.packet-section--wide {
  grid-column: 1 / -1;
}

.packet-section h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  text-transform: uppercase;
}

.packet-section p {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  line-height: 1.5;
}

.report-list--compact {
  margin-top: 12px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.parts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.parts-table th,
.parts-table td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
}

.parts-table th {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(31, 41, 51, 0.02);
}

.parts-table th:nth-child(2),
.parts-table td:nth-child(2) {
  text-align: center;
  white-space: nowrap;
  width: 44px;
}

.parts-table th:nth-child(3),
.parts-table td:nth-child(3) {
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
}

.parts-table th:last-child,
.parts-table td:last-child {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.status-panel {
  position: sticky;
  top: 88px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.free-pro-panel {
  display: grid;
  gap: 12px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.free-pro-panel > p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

.free-pro-panel table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.free-pro-panel th,
.free-pro-panel td {
  padding: 7px 4px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

#btnNavRestore {
  min-height: 44px;
  margin-top: 0;
}

#license-card-canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.cockpit-horizon-bar {
  display: none;
}

@media (min-width: 900px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .topbar {
    height: 65px;
  }

  .factory-shell {
    height: calc(100dvh - 65px);
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 20px 0 16px;
  }

  .value-bar {
    margin-bottom: 16px;
    padding-bottom: 16px;
  }

  .value-bar__copy {
    font-size: 0.98rem;
  }

  .workspace {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.42fr);
    gap: 24px;
    overflow: hidden;
  }

  .workbench-pane,
  .status-panel {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .workbench-pane {
    padding: 0 10px 28px 0;
  }

  .intake {
    grid-column: auto;
  }

  .status-panel {
    top: auto;
    align-self: stretch;
  }

  .cockpit-horizon-bar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    display: block;
    height: 8px;
    border-top: 1px solid rgba(20, 108, 148, 0.45);
    background: linear-gradient(90deg, var(--blue-dark), var(--primary), var(--blue-dark));
    pointer-events: none;
  }
}

.status-panel__header {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.status-panel p {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-panel__header strong {
  font-size: 1.25rem;
  line-height: 1.15;
}

.essential-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.essential-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  line-height: 1.35;
}

.essential-list span.status-marker {
  display: inline-grid !important;
  place-items: center;
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--amber);
  font-size: 0.82rem;
  font-weight: 800;
  flex-shrink: 0;
}

.essential-list .essential-label {
  flex: 1;
  min-width: 0;
}

.essential-list li.is-complete {
  color: var(--blue-dark);
}

.essential-list li.is-complete span.status-marker {
  background: var(--blue);
}

.status-panel__action {
  margin-top: 20px;
}

.status-panel-compile {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 800;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.08));
  transition: background var(--transition-fast, 0.15s ease), transform var(--transition-fast, 0.15s ease);
}

.status-panel-compile:hover {
  background: var(--blue-dark, #0e4c6a);
}

.status-panel__action-hint {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 8px;
  margin-bottom: 0;
  line-height: 1.35;
  text-align: center;
}

@media (max-width: 760px) {
  .topbar__inner,
  .factory-shell {
    width: min(100% - 24px, 540px);
  }

  .topbar__inner {
    min-height: 72px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
  }

  .save-status {
    min-height: 30px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .factory-shell {
    padding-top: 20px;
    padding-bottom: 96px;
  }

  .workspace,
  .workbench-pane,
  .field-grid,
  .parts-row,
  .packet-grid,
  .packet-meta {
    grid-template-columns: 1fr;
  }

  .intake,
  .closeout-packet,
  .status-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .status-panel {
    position: static;
    order: 2;
    margin-top: 24px;
    padding: 16px;
  }

  .status-panel__header {
    margin-bottom: 0;
  }

  .essential-list,
  .status-panel__action {
    display: none;
  }

  .paper-card {
    padding: 20px;
  }

  .action-bar,
  .form-action-dock {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 0;
    padding: 12px 0 max(12px, env(safe-area-inset-bottom));
    justify-content: stretch;
    background: linear-gradient(180deg, rgba(247, 243, 236, 0), var(--page) 38%);
    z-index: 40;
  }

  .primary-action {
    width: 100%;
  }

  .packet-header {
    flex-direction: column;
  }

  .print-action {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .topbar__inner {
    min-height: 96px;
    height: 96px;
    padding: 2px 0;
  }

  .site-header nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 44px 44px;
    gap: 4px 8px;
    align-items: center;
    flex: 1;
  }

  .site-header .wordmark {
    min-width: 0;
    overflow: hidden;
    font-size: 0.88rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .site-header .badge,
  .site-header .header-submit-btn,
  .smart-fold-bar .header-submit-btn,
  .header-submit-btn {
    display: none !important;
  }

  .site-header .jump-tool-btn {
    min-width: 44px;
    padding-inline: 10px;
    font-size: 0.78rem;
  }

  .site-header .pro-link {
    grid-column: 1 / -1;
    width: 100%;
  }

  button,
  [role="button"],
  .preset-chip,
  .secondary-action,
  .print-action,
  .pro-upgrade-btn,
  .jump-shelf a {
    min-width: 44px;
    min-height: 44px;
  }

  .checkbox-field {
    min-height: 44px;
  }

  .checkbox-field input {
    width: 24px;
    min-width: 24px;
    min-height: 24px;
    margin-top: 0;
  }

  .field-grid > .field,
  .parts-row input {
    min-width: 0;
  }

  .preset-chip,
  [data-preset-chip],
  .pro-upgrade-btn,
  .free-watermark {
    white-space: normal;
    text-wrap: wrap;
  }

  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  .jump-shelf {
    align-items: stretch;
    flex-direction: column;
  }

  .jump-shelf a {
    justify-content: center;
    white-space: normal;
    text-align: center;
  }
}

@media print {
  @page {
    margin: 0.45in;
  }

  body {
    background: #ffffff;
    color: #000000;
  }

  .no-print,
  button,
  [data-action],
  .secondary-action,
  .topbar,
  .value-bar,
  .validation-summary,
  .intake,
  .status-panel,
  .status-panel__action,
  .status-panel-compile,
  .action-bar,
  .form-action-dock,
  .print-action,
  .jump-shelf,
  .cockpit-horizon-bar,
  .smart-fold-bar,
  .fold-controls,
  [data-action="print-deliverable"] {
    display: none !important;
  }

  .factory-shell {
    width: 100%;
    padding: 0;
  }

  .workspace {
    display: block;
  }

  .workbench-pane {
    display: block !important;
    overflow: visible !important;
  }

  .closeout-packet {
    display: block !important;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .packet-header,
  .packet-section {
    break-inside: avoid;
  }

  .packet-grid {
    gap: 10px;
  }

  .packet-section {
    padding: 10px;
    background: #ffffff;
  }
}
