:root {
  color-scheme: light;
  --blue-900: #0b2f6f;
  --blue-800: #124082;
  --blue-700: #1657b8;
  --blue-600: #1d6fe8;
  --blue-500: #2d86ff;
  --blue-100: #eaf3ff;
  --blue-50: #f5f9ff;
  --ink: #172033;
  --muted: #66758f;
  --line: #d7e3f2;
  --line-strong: #b9cce3;
  --panel: #ffffff;
  --bg: #f4f8fd;
  --ok: #0b8f62;
  --warn: #b7791f;
  --bad: #c2412f;
  --shadow: 0 18px 42px rgba(28, 74, 128, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Inter",
    "PingFang SC",
    "Microsoft YaHei",
    Arial,
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 284px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--blue-700), var(--blue-500));
  color: white;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 0 10px 20px rgba(29, 111, 232, 0.24);
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.panel p,
.recent-panel h2 {
  margin: 0;
}

.brand h1 {
  font-size: 17px;
  letter-spacing: 0;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.primary-action,
.solid-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 650;
  transition:
    background 0.18s ease,
    border 0.18s ease,
    transform 0.18s ease;
}

.primary-action,
.solid-btn {
  background: var(--blue-700);
  color: #ffffff;
}

.primary-action {
  width: 100%;
  margin-bottom: 18px;
  min-height: 44px;
}

.primary-action:hover,
.solid-btn:hover {
  background: var(--blue-800);
}

.ghost-btn {
  background: #ffffff;
  border-color: var(--line-strong);
  color: var(--blue-800);
}

.ghost-btn:hover {
  background: var(--blue-50);
  border-color: #9cb9dd;
}

.large {
  min-height: 46px;
  padding: 0 24px;
}

.stepper {
  display: grid;
  gap: 8px;
  margin: 20px 0 24px;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.step span {
  display: grid;
  width: 28px;
  height: 26px;
  place-items: center;
  border-radius: 6px;
  background: var(--blue-50);
  color: var(--blue-700);
  font-size: 12px;
  font-weight: 750;
}

.step.is-active {
  background: var(--blue-100);
  border-color: #c9dcf7;
  color: var(--blue-900);
  font-weight: 700;
}

.recent-panel {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.section-title,
.panel-head,
.topbar,
.topbar-actions,
.preview-actions,
.export-actions {
  display: flex;
  align-items: center;
}

.section-title,
.panel-head,
.topbar {
  justify-content: space-between;
  gap: 16px;
}

.section-title h2 {
  font-size: 14px;
}

.section-title button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.recent-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.recent-item {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--blue-50);
  padding: 10px;
  text-align: left;
}

.recent-item strong {
  display: block;
  color: var(--blue-900);
  font-size: 13px;
}

.recent-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.workspace {
  padding: 22px;
  overflow-x: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: -22px -22px 18px;
  padding: 18px 22px;
  background: rgba(244, 248, 253, 0.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar h2 {
  margin-top: 4px;
  font-size: 24px;
}

.eyebrow {
  color: var(--blue-700);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mode-switch,
.checkbox-row,
.inline-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.mode-switch {
  min-width: 96px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel h3 {
  margin-top: 3px;
  font-size: 18px;
}

.hint,
.small-copy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--blue-50);
  color: var(--blue-800);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 720;
}

.product-panel,
.preview-panel,
.export-panel {
  grid-column: 1 / -1;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.product-card {
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #ffffff;
  text-align: left;
  transition:
    border 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.product-card:hover {
  transform: translateY(-1px);
  border-color: #99bbeb;
  box-shadow: 0 12px 22px rgba(28, 74, 128, 0.1);
}

.product-card.is-selected {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(45, 134, 255, 0.14);
}

.product-card strong {
  display: block;
  margin-top: 12px;
  color: var(--ink);
  font-size: 14px;
}

.product-card span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.mini-diagram {
  position: relative;
  height: 48px;
  border: 1px solid #b9cce3;
  border-radius: 6px;
  background:
    linear-gradient(90deg, transparent 49%, #b9cce3 49%, #b9cce3 51%, transparent 51%),
    linear-gradient(180deg, #ffffff 0 48%, #eaf3ff 48% 52%, #ffffff 52%);
}

.mini-diagram::before,
.mini-diagram::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px dashed #6ea5ee;
  border-radius: 3px;
}

.mini-diagram::after {
  inset: 12px 36px;
  border-style: solid;
  background: rgba(29, 111, 232, 0.1);
}

.form-grid,
.export-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
  margin-top: 16px;
}

.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(45, 134, 255, 0.16);
}

.drop-zone {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 132px;
  margin-top: 16px;
  border: 1px dashed #8db2e9;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(234, 243, 255, 0.82), rgba(255, 255, 255, 0.96)),
    #ffffff;
  padding: 18px;
}

.drop-zone.is-dragging {
  border-color: var(--blue-600);
  background: var(--blue-100);
}

.drop-icon {
  display: grid;
  flex: 0 0 auto;
  width: 58px;
  height: 70px;
  place-items: center;
  border-radius: 7px;
  background: #ffffff;
  border: 1px solid var(--line-strong);
  color: var(--blue-700);
  font-weight: 800;
}

.drop-zone strong {
  color: var(--blue-900);
}

.drop-zone p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.pdf-list,
.preflight {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.pdf-item,
.check-item,
.fold-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  padding: 11px 12px;
}

.pdf-item strong,
.fold-item strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
}

.pdf-item span,
.fold-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.check-item {
  justify-content: flex-start;
  font-size: 13px;
}

.check-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
}

.check-item.warn .check-dot {
  background: var(--warn);
}

.check-item.bad .check-dot {
  background: var(--bad);
}

.fold-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 14px;
  margin-top: 16px;
}

.fold-list {
  display: grid;
  gap: 10px;
}

.fold-item {
  text-align: left;
}

.fold-item.is-selected {
  border-color: var(--blue-600);
  background: var(--blue-50);
  box-shadow: 0 0 0 3px rgba(45, 134, 255, 0.12);
}

.fold-metrics {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.fold-metrics em {
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid var(--line);
  padding: 5px 8px;
  color: var(--blue-800);
  font-size: 12px;
  font-style: normal;
}

.compensation-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--blue-50);
  padding: 14px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  color: var(--blue-900);
  font-size: 28px;
}

.creep-chart {
  display: grid;
  grid-auto-flow: column;
  align-items: end;
  gap: 5px;
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  padding: 8px;
}

.creep-bar {
  min-width: 10px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--blue-500), var(--blue-800));
}

.marks-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.marks-panel .marks-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mark-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  padding: 12px;
}

.mark-toggle strong {
  color: var(--ink);
  font-size: 13px;
  word-break: keep-all;
}

.mark-toggle span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.switch {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch i {
  width: 42px;
  border-radius: 999px;
  background: #c8d4e5;
  transition: background 0.18s ease;
}

.switch i::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.18s ease;
}

.switch input:checked + i {
  background: var(--blue-700);
}

.switch input:checked + i::before {
  transform: translateX(18px);
}

.preview-panel {
  min-height: 690px;
}

.preview-actions {
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  overflow: hidden;
  background: #ffffff;
}

.segmented button {
  min-width: 64px;
  min-height: 36px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--blue-800);
  font-weight: 650;
}

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

.segmented button.is-active {
  background: var(--blue-700);
  color: #ffffff;
}

.preview-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 14px;
  margin-top: 16px;
}

.sheet-viewport {
  position: relative;
  min-height: 600px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(13, 64, 130, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(13, 64, 130, 0.06) 1px, transparent 1px),
    #eef5ff;
  background-size: 24px 24px;
  padding: 24px;
}

#sheetPreview {
  display: block;
  margin: 0 auto;
  overflow: visible;
  filter: drop-shadow(0 18px 32px rgba(23, 57, 104, 0.18));
}

.inspector {
  display: grid;
  align-content: start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--blue-50);
  padding: 14px;
}

.inspector h4 {
  margin: 0;
  color: var(--blue-900);
}

.selected-page {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.nudge-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.nudge-grid button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #ffffff;
  color: var(--blue-800);
  font-weight: 650;
}

.sheet-bg {
  fill: #ffffff;
  stroke: #9fb8d8;
  stroke-width: 1;
}

.gripper-zone {
  fill: rgba(29, 111, 232, 0.08);
}

.page-box {
  fill: #fdfefe;
  stroke: #2774d8;
  stroke-width: 0.9;
}

.page-box.selected {
  fill: #dcecff;
  stroke: #0b56bb;
  stroke-width: 2.2;
}

.bleed-box {
  fill: none;
  stroke: #e1872f;
  stroke-width: 0.55;
  stroke-dasharray: 3 2;
}

.page-label {
  fill: #0b2f6f;
  font-size: 20px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: middle;
}

.page-meta {
  fill: #66758f;
  font-size: 9px;
  text-anchor: middle;
}

.fold-line {
  stroke: #6b7c92;
  stroke-width: 0.55;
  stroke-dasharray: 6 4;
}

.mark-line {
  stroke: #0d1d34;
  stroke-width: 0.55;
}

.reg-line {
  stroke: #0d1d34;
  stroke-width: 0.65;
}

.info-text {
  fill: #172033;
  font-size: 10px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--blue-50);
  padding: 12px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-card strong {
  display: block;
  margin-top: 6px;
  color: var(--blue-900);
  font-size: 17px;
}

.export-actions {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  display: grid;
  gap: 10px;
  width: 320px;
}

.toast {
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue-700);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 12px;
  color: var(--ink);
  font-size: 13px;
}

.toast strong {
  display: block;
  margin-bottom: 4px;
  color: var(--blue-900);
}

.toast.warn {
  border-left-color: var(--warn);
}

.toast.bad {
  border-left-color: var(--bad);
}

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

.expert .product-panel,
.expert .preview-panel,
.expert .export-panel {
  grid-column: 1 / -1;
}

.expert .form-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

@media (max-width: 1320px) {
  body {
    min-width: 1024px;
  }

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

  .form-grid,
  .export-grid,
  .marks-grid,
  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 900px) {
  body {
    min-width: 0;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .workspace {
    padding: 14px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    margin: -14px -14px 14px;
    padding: 14px;
  }

  .topbar-actions,
  .preview-actions,
  .export-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid,
  .export-grid,
  .marks-grid,
  .marks-panel .marks-grid,
  .summary-strip,
  .fold-layout,
  .preview-workbench {
    grid-template-columns: 1fr;
  }

  .sheet-viewport {
    min-height: 420px;
    padding: 14px;
  }

  .toast-stack {
    left: 14px;
    right: 14px;
    width: auto;
  }
}

@media (max-width: 520px) {
  .sidebar,
  .panel {
    padding: 14px;
    max-width: calc(100vw - 28px);
  }

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

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar-actions > * {
    min-width: 0;
  }

  .topbar-actions .ghost-btn,
  .topbar-actions .solid-btn {
    width: 100%;
    padding-inline: 8px;
  }

  .mode-switch {
    grid-column: 1 / -1;
    width: 100%;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
  }
}

@media print {
  body {
    min-width: 0;
    background: #ffffff;
  }

  .sidebar,
  .topbar,
  .panel:not(.preview-panel) {
    display: none;
  }

  .app-shell,
  .workspace,
  .dashboard-grid,
  .preview-panel {
    display: block;
    padding: 0;
    margin: 0;
    box-shadow: none;
    border: 0;
  }

  .panel-head,
  .inspector {
    display: none;
  }

  .sheet-viewport {
    border: 0;
    background: #ffffff;
    overflow: visible;
  }
}
