:root {
  --ink: #0b1420;
  --ink-soft: #52606d;
  --line: #dfe5e9;
  --line-dark: #c7d0d6;
  --paper: #ffffff;
  --canvas: #f1f4f5;
  --signal: #b7f34a;
  --signal-dark: #7ab81d;
  --error: #c43d33;
  --navy: #09131f;
  --radius: 4px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(rgba(9, 19, 31, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(9, 19, 31, 0.025) 1px, transparent 1px),
    var(--canvas);
  background-size: 28px 28px;
}

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

.app-shell { min-height: 100vh; }

.topbar {
  height: 76px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--navy);
  color: #fff;
  border-bottom: 3px solid var(--signal);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 8px;
  border: 1px solid #405063;
}

.brand-mark span { background: var(--signal); }
.brand-mark span:nth-child(2) { transform: translateY(5px); }

.brand strong { display: block; font-size: 1.05rem; letter-spacing: 0.01em; }
.brand small { display: block; margin-top: 2px; color: #9fabb7; font-size: 0.7rem; letter-spacing: 0.18em; }

.system-state {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #c9d1d9;
  font-size: 0.875rem;
}

.pulse-dot, .status-pill i, .waiting-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 4px rgba(183, 243, 74, 0.12);
}

.workspace {
  width: min(1180px, calc(100% - 40px));
  margin: 42px auto 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}

.form-panel, .status-card, .my-tasks-card, .flow-card, .notice-card {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 10px 32px rgba(18, 31, 43, 0.05);
}

.form-panel { padding: clamp(24px, 4vw, 48px); }

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--signal-dark);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.06; letter-spacing: -0.045em; }
.intro { max-width: 650px; margin: 14px 0 0; color: var(--ink-soft); line-height: 1.7; }

.step-chip {
  flex: 0 0 auto;
  padding: 8px 10px;
  color: #344251;
  background: #f4f7f7;
  border-left: 3px solid var(--signal);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

fieldset { margin: 0; padding: 32px 0; border: 0; border-bottom: 1px solid var(--line); }
legend { margin-bottom: 22px; padding: 0; font-size: 0.9rem; font-weight: 800; letter-spacing: 0.06em; }

.field-grid { display: grid; gap: 18px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-columns { grid-template-columns: 1fr 1fr 1.05fr; }
.full-width + .field-grid, .field-grid + .full-width, .full-width + .full-width { margin-top: 18px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field > span:first-child { font-size: 0.875rem; font-weight: 700; }
.field b { color: var(--error); }

.field input, .field select, .field textarea {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  color: var(--ink);
  background: #fbfcfc;
  border: 1px solid var(--line-dark);
  border-radius: 2px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.field textarea { min-height: 94px; padding-top: 12px; line-height: 1.5; resize: vertical; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #98a5ae; }
.field input:focus, .field select:focus, .field textarea:focus { background: #fff; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(183, 243, 74, 0.28); }
.field input[aria-invalid="true"], .field select[aria-invalid="true"] { border-color: var(--error); }
.field small { min-height: 1em; color: #7a8792; font-size: 0.75rem; line-height: 1.4; }
.field-error { color: var(--error) !important; }
.material-availability.available { color: #4c7d18; }
.material-availability.unavailable { color: var(--error); }
.character-count { text-align: right; }

.number-control { display: grid; grid-template-columns: 42px minmax(55px, 1fr) 42px; }
.number-control button, .number-control input { min-height: 48px; border: 1px solid var(--line-dark); background: #fbfcfc; }
.number-control button { font-size: 1.15rem; }
.number-control button:hover { background: var(--signal); }
.number-control input { padding: 0 4px; text-align: center; border-left: 0; border-right: 0; border-radius: 0; }
.number-control input::-webkit-inner-spin-button { appearance: none; }

.drop-zone {
  min-height: 168px;
  padding: 20px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(90deg, var(--line-dark) 50%, transparent 50%) top/12px 1px repeat-x,
    linear-gradient(90deg, var(--line-dark) 50%, transparent 50%) bottom/12px 1px repeat-x,
    linear-gradient(0deg, var(--line-dark) 50%, transparent 50%) left/1px 12px repeat-y,
    linear-gradient(0deg, var(--line-dark) 50%, transparent 50%) right/1px 12px repeat-y,
    #f8faf9;
  outline: none;
  transition: background-color 150ms ease, transform 150ms ease;
}

.drop-zone:hover, .drop-zone:focus, .drop-zone.dragging { background-color: #f2f8e8; transform: translateY(-1px); }
.empty-file-state { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.empty-file-state > span:last-child { color: #73808b; font-size: 0.8125rem; }
.upload-icon { width: 42px; height: 42px; display: grid; place-items: center; color: var(--ink); background: var(--signal); }
.upload-icon svg { width: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: square; stroke-linejoin: miter; }

.selected-file-state { width: 100%; max-width: 520px; align-items: center; gap: 14px; padding: 16px; background: white; border: 1px solid var(--line); }
.selected-file-state:not([hidden]) { display: flex; }
.file-badge { flex: 0 0 auto; padding: 14px 9px; color: var(--signal); background: var(--navy); font-size: 0.72rem; font-weight: 900; letter-spacing: 0.06em; }
.file-details { min-width: 0; display: flex; flex: 1; flex-direction: column; gap: 3px; }
.file-details strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-details small { color: #72808b; }
.icon-button { width: 36px; height: 36px; padding: 0; color: #687681; background: transparent; border: 0; font-size: 1.4rem; }
.icon-button:hover { color: var(--error); background: #fff3f1; }
.file-error { display: block; min-height: 1em; margin-top: 8px; }

.auto-print-confirm {
  margin-top: 28px;
  padding: 18px;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 13px;
  align-items: start;
  color: #5e6a74;
  background: #f7faef;
  border: 1px solid #cfe6a8;
  line-height: 1.55;
  cursor: pointer;
}
.auto-print-confirm input { width: 19px; height: 19px; margin: 2px 0 0; accent-color: var(--signal-dark); }
.auto-print-confirm strong { display: block; margin-bottom: 3px; color: var(--ink); font-size: 0.9rem; }
.auto-print-confirm span { font-size: 0.8rem; }
.confirm-error { display: block; min-height: 1em; margin-top: 7px; }

.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-top: 28px; }
.form-actions p { max-width: 420px; margin: 0; color: #6c7984; font-size: 0.8125rem; line-height: 1.5; }
.form-actions p span { color: var(--signal-dark); font-weight: 800; }

.primary-button, .secondary-button {
  min-height: 50px;
  padding: 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  border: 1px solid transparent;
  font-weight: 800;
}

.primary-button { color: var(--navy); background: var(--signal); box-shadow: 4px 4px 0 var(--navy); }
.primary-button:hover { background: #c5ff57; transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--navy); }
.primary-button:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--navy); }
.primary-button:disabled { cursor: wait; opacity: 0.65; }
.primary-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }

.side-panel { display: grid; gap: 18px; position: sticky; top: 24px; }
.status-card { padding: 22px; color: white; background: var(--navy); border-color: var(--navy); }
.status-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #90a0af; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.12em; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 8px; color: #d7e2c2; background: #172535; border: 1px solid #2b3b4c; font-size: 0.7rem; letter-spacing: 0; }
.status-pill i { width: 6px; height: 6px; box-shadow: none; }
.queue-number { padding: 28px 0 24px; display: flex; align-items: baseline; gap: 12px; border-bottom: 1px solid #263645; }
.queue-number strong { color: var(--signal); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 3.4rem; line-height: 1; }
.queue-number span { color: #afbbc5; font-size: 0.85rem; }
.printer-status-list { padding-top: 16px; display: grid; gap: 10px; }
.status-placeholder { margin: 0; padding: 14px; color: #aab6c0; background: #111f2d; font-size: 0.78rem; line-height: 1.5; text-align: center; }
.status-placeholder.error { color: #ffb7b1; }
.printer-card { padding: 14px; background: #111f2d; border: 1px solid #283a4b; }
.printer-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.printer-card-head > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.printer-card-head strong { overflow: hidden; color: #f4f7f8; font-size: 0.83rem; text-overflow: ellipsis; white-space: nowrap; }
.printer-card-head small { color: #8f9eaa; font-size: 0.67rem; }
.printer-state { flex: 0 0 auto; padding: 4px 6px; color: #b8c3cc; background: #243444; border-left: 2px solid #738493; font-size: 0.65rem; font-weight: 800; }
.printer-state.running, .printer-state.idle { color: #d8f9a4; border-color: var(--signal); }
.printer-state.finish, .printer-state.pause, .printer-state.prepare { color: #ffe6a9; border-color: #efbd4c; }
.printer-state.failed { color: #ffc2bd; border-color: #e16459; }
.printer-job { margin: 12px 0 8px; overflow: hidden; color: #dce3e8; font-size: 0.76rem; text-overflow: ellipsis; white-space: nowrap; }
.printer-job.muted { color: #7f8e9a; }
.printer-progress, .task-progress { height: 4px; overflow: hidden; background: #2c3b49; }
.printer-progress i, .task-progress i { height: 100%; display: block; background: var(--signal); transition: width 240ms ease; }
.printer-metrics { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 5px 10px; color: #9eabb5; font-size: 0.66rem; }
.material-chips { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 5px; }
.material-chip { padding: 4px 6px; display: inline-flex; align-items: center; gap: 5px; color: #c9d2d8; background: #1a2a39; font-size: 0.65rem; }
.material-chip i { width: 8px; height: 8px; border: 1px solid rgba(255,255,255,.35); border-radius: 50%; }
.material-empty { color: #7f8e9a; font-size: 0.67rem; }
.printer-warning { margin-top: 9px; display: inline-block; color: #ffbbb5; font-size: 0.68rem; }
.printer-clear-action { width: 100%; min-height: 36px; margin-top: 12px; padding: 7px 10px; color: var(--navy); background: var(--signal); border: 1px solid var(--signal-dark); font-size: 0.72rem; font-weight: 800; }
.printer-clear-action:hover { background: #c5ff57; }
.printer-clear-action:disabled { cursor: wait; opacity: .6; }

.my-tasks-card { padding: 22px; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.card-heading .eyebrow { margin-bottom: 3px; font-size: 0.62rem; }
.card-heading h2 { margin: 0; font-size: 1rem; }
.text-button { padding: 6px 9px; color: #52616d; background: #f3f6f7; border: 1px solid var(--line-dark); font-size: 0.72rem; font-weight: 700; }
.text-button:hover { color: var(--ink); background: var(--signal); border-color: var(--signal-dark); }
.my-tasks-list { margin-top: 12px; display: grid; gap: 9px; }
.empty-tasks { margin: 0; padding: 16px 8px; color: #7b8790; font-size: 0.76rem; text-align: center; }
.task-card { padding: 13px; background: #f8faf9; border: 1px solid var(--line); }
.task-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.task-card-head strong { min-width: 0; overflow: hidden; font-size: 0.79rem; text-overflow: ellipsis; white-space: nowrap; }
.task-card > small { margin-top: 4px; display: block; color: #82909a; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.61rem; }
.task-card > p { margin: 8px 0 0; color: #65727c; font-size: 0.7rem; line-height: 1.45; }
.task-status { flex: 0 0 auto; padding: 3px 5px; color: #5e6b75; background: #e8edef; font-size: 0.61rem; font-weight: 800; }
.task-status.pending, .task-status.queued { color: #79590c; background: #fff0c5; }
.task-status.printing { color: #245f79; background: #dff5ff; }
.task-status.completed { color: #477416; background: #e8f8cf; }
.task-status.failed, .task-status.cancelled { color: #9d3028; background: #ffe5e2; }
.task-printer { margin-top: 9px !important; }
.task-progress { margin-top: 8px; background: #dbe3e6; }
.task-actions { margin-top: 11px; display: flex; align-items: center; }
.task-action { width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid; font-size: 0.72rem; font-weight: 800; }
.task-action:disabled { cursor: wait; opacity: .6; }
.cancel-action { color: #9c352d; background: #fff; border-color: #e2aaa5; }
.cancel-action:hover { background: #fff0ee; }
.clear-action { color: var(--navy); background: var(--signal); border-color: var(--signal-dark); }
.clear-action:hover { background: #c5ff57; }
.cleared-mark { color: #477416; font-size: 0.72rem; font-weight: 800; }
.task-hint { color: #7a8790; font-size: 0.68rem; }
.task-error { color: var(--error) !important; }
.legacy-task { opacity: .8; }
.privacy-note { margin: 12px 0 0; color: #89949c; font-size: 0.65rem; line-height: 1.45; }

.flow-card { padding: 26px 24px; }
.flow-card h2 { margin: 0 0 22px; font-size: 1rem; }
.flow-card ol { margin: 0; padding: 0; list-style: none; }
.flow-card li { position: relative; display: grid; grid-template-columns: 34px 1fr; gap: 13px; min-height: 66px; }
.flow-card li:not(:last-child)::after { content: ""; position: absolute; left: 16px; top: 31px; bottom: 3px; width: 1px; background: var(--line); }
.flow-card li > span { width: 34px; height: 28px; display: grid; place-items: center; color: #82909b; background: #edf1f2; font-family: ui-monospace, monospace; font-size: 0.7rem; font-weight: 800; z-index: 1; }
.flow-card li.active > span { color: var(--navy); background: var(--signal); }
.flow-card li div { display: flex; flex-direction: column; gap: 5px; padding-top: 3px; }
.flow-card li strong { font-size: 0.875rem; }
.flow-card li small { color: #73808a; font-size: 0.75rem; line-height: 1.45; }

.notice-card { display: grid; grid-template-columns: 32px 1fr; gap: 12px; padding: 18px; box-shadow: none; }
.notice-card > span { width: 30px; height: 30px; display: grid; place-items: center; color: var(--navy); background: var(--signal); font-weight: 900; }
.notice-card p { margin: 0; color: #65727d; font-size: 0.78rem; line-height: 1.55; }
.notice-card strong { display: block; margin-bottom: 3px; color: var(--ink); font-size: 0.82rem; }

.success-dialog {
  width: min(500px, calc(100% - 32px));
  padding: 38px;
  color: var(--ink);
  background: white;
  border: 0;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.25);
  text-align: center;
}
.success-dialog::backdrop { background: rgba(5, 12, 20, 0.76); backdrop-filter: blur(3px); }
.dialog-accent { position: absolute; top: 0; left: 0; right: 0; height: 5px; background: var(--signal); }
.dialog-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; background: transparent; border: 0; font-size: 1.5rem; }
.success-mark { width: 58px; height: 58px; margin: 4px auto 18px; display: grid; place-items: center; color: var(--navy); background: var(--signal); font-size: 1.8rem; font-weight: 900; }
.success-dialog h2 { margin: 0 0 10px; font-size: 1.75rem; }
.success-dialog > p:not(.eyebrow) { margin: 0 auto 24px; color: #697681; font-size: 0.9rem; line-height: 1.6; }
.ticket { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; padding: 16px; background: var(--navy); text-align: left; }
.ticket span { grid-column: 1 / -1; color: #95a3af; font-size: 0.7rem; letter-spacing: 0.1em; }
.ticket strong { align-self: center; color: var(--signal); font-family: ui-monospace, monospace; font-size: 1.35rem; }
.ticket button { padding: 8px 12px; color: white; background: #1a2a3a; border: 1px solid #34485a; font-size: 0.75rem; }
.success-dialog dl { margin: 20px 0; }
.success-dialog dl div { padding: 10px 0; display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); font-size: 0.85rem; text-align: left; }
.success-dialog dt { color: #7a8791; }
.success-dialog dd { margin: 0; font-weight: 700; }
.waiting-dot { width: 7px; height: 7px; margin-right: 8px; background: #f4bd44; box-shadow: none; }
.secondary-button { width: 100%; color: white; background: var(--navy); }
.secondary-button:hover { background: #162638; }

.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(360px, calc(100% - 48px)); padding: 13px 16px; color: white; background: var(--navy); border-left: 4px solid var(--signal); box-shadow: 0 10px 30px rgba(0,0,0,.18); opacity: 0; transform: translateY(12px); pointer-events: none; transition: 180ms ease; z-index: 30; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { border-color: var(--error); }

@media (max-width: 940px) {
  .workspace { grid-template-columns: 1fr; }
  .side-panel { grid-template-columns: 1fr 1fr; position: static; }
  .notice-card { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .topbar { height: 68px; padding: 0 18px; }
  .brand-mark { width: 36px; height: 36px; }
  .system-state span:last-child { display: none; }
  .workspace { width: min(100% - 24px, 1180px); margin-top: 18px; }
  .form-panel { padding: 24px 18px; }
  .section-heading { display: block; }
  .step-chip { display: inline-block; margin-top: 20px; }
  .two-columns, .three-columns, .side-panel { grid-template-columns: 1fr; }
  .notice-card { grid-column: auto; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .primary-button { width: 100%; }
  .success-dialog { padding: 34px 22px 24px; }
}

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