:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-subtle: #f4f4f5;
  --ink: #0a0a0a;
  --ink-secondary: #52525b;
  --muted: #71717a;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.14);
  --accent: #0070f3;
  --accent-soft: rgba(0, 112, 243, 0.08);
  --primary: #111111;
  --primary-hover: #27272a;
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-line: #a7f3d0;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --warning-line: #fde68a;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-line: #fecaca;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 6px 16px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.06);
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.5 var(--font-sans);
  position: relative;
}

.ambient {
  position: fixed;
  inset: 0 0 auto 0;
  height: 420px;
  background: radial-gradient(ellipse 75% 60% at 50% -15%, rgba(0, 112, 243, 0.07), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

[hidden] {
  display: none !important;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 28px;
  position: relative;
  z-index: 1;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line);
}

.top {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(180deg, #27272a 0%, #09090b 100%);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 2px 6px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.brand-icon svg {
  width: 20px;
  height: 20px;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.brand-text strong {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.badge-version {
  font-size: 11px;
  font-weight: 550;
  color: var(--muted);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  padding: 1px 7px;
  border-radius: 999px;
}

.brand-text small {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: 1px;
}

.topright {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cal-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--warning-line);
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 12px;
  font-weight: 550;
  transition: all 0.15s ease;
}

.cal-pill:hover {
  filter: brightness(0.97);
}

.cal-pill.ok {
  border-color: var(--success-line);
  background: var(--success-bg);
  color: var(--success);
}

.cal-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-icon,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: var(--radius-sm);
  font-weight: 550;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  padding: 10px 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.985);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  padding: 8px 13px;
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-subtle);
  border-color: rgba(0, 0, 0, 0.2);
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-xs);
}

.btn-icon:hover:not(:disabled) {
  background: var(--surface-subtle);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-secondary);
  border: 1px solid transparent;
  padding: 6px 8px;
  font-size: 12px;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--ink);
  background: var(--surface-subtle);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 12px;
}

.btn-full {
  width: 100%;
  padding: 11px 16px;
}

/* Intro */
.intro {
  padding: 40px 0 22px;
  max-width: 640px;
}

.eyebrow {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.09em;
  color: var(--accent);
  text-transform: uppercase;
}

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

.intro h1 {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.08;
  margin: 8px 0 10px;
  color: var(--ink);
}

.intro p {
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-secondary);
}

/* Stepper */
.steps {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px 6px 8px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}

.step {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 550;
  color: var(--muted);
  white-space: nowrap;
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface-subtle);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  transition: all 0.2s ease;
}

.step.current {
  color: var(--ink);
}

.step.current .step-num {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.step.done {
  color: var(--success);
}

.step.done .step-num {
  background: var(--success-bg);
  border-color: var(--success-line);
  color: var(--success);
}

.step-line {
  width: 22px;
  height: 1px;
  background: var(--line-strong);
}

/* Status Banner */
#status {
  padding: 11px 15px;
  border-radius: var(--radius-md);
  border: 1px solid var(--warning-line);
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}

#status.error {
  background: var(--danger-bg);
  border-color: var(--danger-line);
  color: var(--danger);
}

#status.success {
  background: var(--success-bg);
  border-color: var(--success-line);
  color: var(--success);
}

/* Upload Zone */
.upload {
  background: var(--surface);
  border: 1.5px dashed rgba(0, 0, 0, 0.16);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease, padding 0.2s ease;
}

.upload:hover {
  border-color: rgba(0, 0, 0, 0.28);
}

.upload.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 4px rgba(0, 112, 243, 0.08);
}

.upload-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  color: var(--ink);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.upload-icon svg {
  width: 22px;
  height: 22px;
}

.upload-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.upload-text h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.upload-text p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.upload.loaded {
  padding: 14px 18px;
  border-style: solid;
  border-color: var(--line);
}

.upload.loaded .upload-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--success-bg);
  border-color: var(--success-line);
  color: var(--success);
}

/* Order Header */
.orderhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 26px 0 16px;
}

.orderhead h2 {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-top: 3px;
}

.summary-card {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  box-shadow: var(--shadow-xs);
}

.summary-card strong {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

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

/* Workspace Grid */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 18px;
  align-items: start;
}

.right {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 84px;
}

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

.panelhead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.panelhead h3,
.panelhead h2 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--ink);
}

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

.pill-subtle {
  font-size: 11px;
  font-weight: 550;
  color: var(--ink-secondary);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Product Cards */
.product {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.product + .product {
  margin-top: 10px;
}

.product:hover {
  border-color: var(--line-strong);
}

.product-top {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.product-top input[type="checkbox"] {
  margin-top: 2px;
}

.product-info {
  flex: 1;
  min-width: 0;
}

.product-info b {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.product-info small {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
}

.quantity {
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.product details {
  margin: 12px 0 0 28px;
}

.product summary,
.excluded summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  user-select: none;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.product summary::-webkit-details-marker,
.excluded summary::-webkit-details-marker {
  display: none;
}

.product summary::before,
.excluded summary::before {
  content: "›";
  display: inline-block;
  font-size: 15px;
  line-height: 1;
  transition: transform 0.15s ease;
}

.product details[open] > summary::before,
.excluded[open] > summary::before {
  transform: rotate(90deg);
}

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

.editfields label,
.field {
  display: grid;
  gap: 5px;
  font-size: 12px;
  font-weight: 550;
  color: var(--ink-secondary);
}

input:not([type="checkbox"]),
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  color: var(--ink);
  background: var(--surface);
  font-size: 13px;
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:not([type="checkbox"]):focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 112, 243, 0.12);
}

input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 4px;
}

.serial-edit {
  max-height: 190px;
  overflow: auto;
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding-right: 4px;
}

.serial-edit input {
  font-size: 12px;
  font-family: var(--font-mono);
  padding: 6px 9px;
}

.link {
  background: transparent;
  border: none;
  padding: 6px 0 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 550;
}

.link:hover {
  text-decoration: underline;
}

.excluded {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 16px;
}

.excluded summary {
  color: var(--muted);
}

.excluded-row {
  font-size: 12px;
  color: var(--muted);
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.excluded-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.excluded-row b {
  display: block;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink);
  margin-bottom: 2px;
}

/* Preview Canvas */
.preview-stage {
  min-height: 196px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background-color: #f4f4f5;
  background-image: radial-gradient(rgba(0, 0, 0, 0.08) 1px, transparent 1px);
  background-size: 14px 14px;
  display: grid;
  place-items: center;
  padding: 20px;
  position: relative;
}

.preview-stage img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
}

.preview-msg {
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

.preview-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  gap: 12px;
}

.preview-meta {
  text-align: center;
  min-width: 0;
}

.preview-meta strong {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.preview-meta small {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Calibration Warning inside Print Panel */
.cal-warning {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  background: var(--warning-bg);
  border: 1px solid var(--warning-line);
  margin-bottom: 12px;
}

.cal-warning strong {
  display: block;
  font-size: 12.5px;
  color: var(--warning);
}

.cal-warning p {
  font-size: 11.5px;
  color: var(--warning);
  opacity: 0.9;
  margin-top: 2px;
}

/* Check Card */
.check-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink);
  cursor: pointer;
  margin-bottom: 14px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.check-card:hover {
  border-color: var(--line-strong);
}

.check-card input {
  margin-top: 2px;
}

/* Printers */
.printer-list {
  display: grid;
  gap: 8px;
}

.printer-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.printer-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  color: var(--ink);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.printer-icon.second {
  background: #f0f9ff;
  border-color: #bae6fd;
  color: #0369a1;
}

.printer-info {
  flex: 1;
  min-width: 0;
}

.printer-info strong,
.printer-info small {
  display: block;
  overflow-wrap: anywhere;
}

.printer-info strong {
  font-size: 13px;
  font-weight: 600;
}

.printer-info small {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 1px;
}

.print-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.print-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.scale-tag {
  font-size: 11px;
  font-weight: 550;
  color: var(--muted);
}

.small-note {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 10px;
}

/* Empty State Feature Grid */
.empty-help {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-xs);
}

.feature-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  color: var(--ink);
  display: grid;
  place-items: center;
  margin-bottom: 12px;
}

.feature-card strong {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.feature-card p {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 4px;
}

/* Footer */
footer {
  padding: 32px 0 28px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

footer .dot {
  opacity: 0.5;
}

/* Settings Modal */
dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: min(460px, 94vw);
  width: 100%;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}

dialog::backdrop {
  background: rgba(9, 9, 11, 0.45);
  backdrop-filter: blur(4px);
}

.form-stack {
  display: grid;
  gap: 14px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dialog-actions {
  margin-top: 18px;
}

/* Responsive */
@media (max-width: 860px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .right {
    position: static;
  }

  .preview-stage img {
    max-width: 540px;
  }

  .empty-help {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 0 16px;
  }

  .intro {
    padding: 26px 0 18px;
  }

  .intro h1 {
    font-size: 30px;
  }

  .cal-pill {
    display: none;
  }

  .steps {
    width: 100%;
    justify-content: space-between;
    padding: 6px 10px;
  }

  .step-line {
    width: 10px;
  }

  .upload {
    flex-wrap: wrap;
    padding: 18px;
  }

  .upload .btn-primary {
    width: 100%;
  }

  .panel {
    padding: 16px;
  }

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

  .printer-icon {
    display: none;
  }
}
