:root {
  --bg: #f6f1e8;
  --panel: #fffdf8;
  --panel-strong: #fff;
  --ink: #1f2933;
  --muted: #667085;
  --accent: #d96b27;
  --accent-dark: #b44f13;
  --line: #eadfce;
  --success: #237b4b;
  --warn: #b36a00;
  --shadow: 0 20px 45px rgba(70, 48, 24, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(217, 107, 39, 0.18), transparent 20%),
    linear-gradient(180deg, #f9f4ec 0%, #f3ece0 100%);
  color: var(--ink);
}

.app-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.hero {
  display: grid;
  grid-template-columns: 1.8fr 0.9fr;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 24px;
}

.eyebrow,
.panel-tag {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

.hero h1,
.panel-head h2 {
  margin: 0 0 10px;
}

.hero h1 {
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.05;
}

.hero-copy {
  max-width: 760px;
  margin: 0;
  font-size: 17px;
  line-height: 1.7;
  color: #4f5b67;
}

.hero-card,
.phone-panel,
.desktop-panel,
.info-card,
.queue-panel,
.stats-panel,
.flow-note {
  background: var(--panel);
  border: 1px solid rgba(234, 223, 206, 0.95);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.hero-card-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.hero-card strong {
  font-size: 28px;
}

.hero-card span {
  color: #4f5b67;
  line-height: 1.6;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 430px) 1fr;
  gap: 24px;
  align-items: start;
}

.single-column {
  display: block;
}

.desktop-only {
  display: block;
}

.centered-panel {
  max-width: 480px;
  margin: 0 auto;
}

.phone-panel,
.desktop-panel {
  padding: 20px;
}

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

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: #fff4eb;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.status-chip.live {
  background: #e9f7ef;
  color: var(--success);
}

.status-chip.alt {
  background: #f2efe8;
  color: #675a45;
}

.status-stack {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
}

.phone-frame {
  width: min(100%, 360px);
  margin: 0 auto;
  padding: 12px;
  border-radius: 36px;
  background: #1f2933;
}

.phone-screen {
  border-radius: 28px;
  background: linear-gradient(180deg, #fffefb 0%, #f7f0e5 100%);
  padding: 18px;
}

.store-banner {
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(135deg, #d96b27 0%, #f09a61 100%);
  color: #fff;
  margin-bottom: 16px;
}

.store-banner h3,
.task-card h4,
.queue-head h3,
.flow-note h3 {
  margin: 0 0 8px;
}

.store-name {
  margin: 0 0 4px;
  opacity: 0.92;
  font-size: 13px;
}

.store-banner p:last-child {
  margin: 0;
  line-height: 1.5;
  opacity: 0.92;
}

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

.field,
.option-group,
.notice,
.task-card,
.info-card,
.flow-note {
  border-radius: 18px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.field,
.notice {
  padding: 12px 14px;
}

.field span,
.option-group > span {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

input,
select,
button {
  font: inherit;
}

input[type="text"],
input[type="number"],
input[type="file"],
select {
  width: 100%;
  border: 1px solid #d7cab8;
  border-radius: 12px;
  padding: 11px 12px;
  background: #fffcf8;
}

.file-preview strong {
  color: #344054;
  word-break: break-all;
}

.selected-file-list {
  display: grid;
  gap: 8px;
}

.empty-selected-files {
  color: var(--muted);
  font-size: 14px;
}

.selected-file-chip {
  cursor: pointer;
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffaf3;
  padding: 9px;
  text-align: left;
}

.selected-file-chip.active {
  border-color: var(--accent);
  background: #ffeede;
}

.selected-file-chip span,
.selected-file-chip small,
.selected-file-chip em {
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.selected-file-chip span {
  color: var(--accent-dark);
}

.selected-file-chip strong {
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  word-break: break-all;
}

.selected-file-chip small {
  grid-column: 2 / 4;
  color: var(--muted);
  line-height: 1.35;
}

.selected-file-chip em {
  border-radius: 999px;
  padding: 5px 8px;
  background: #fdecec;
  color: #b42318;
}

.option-group {
  padding: 12px;
}

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

.segmented label {
  cursor: pointer;
}

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

.segmented span {
  display: flex;
  min-height: 44px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 11px 12px;
  text-align: center;
  border-radius: 12px;
  border: 1px solid #decfbe;
  background: #fff8ef;
  color: #5d5241;
  font-weight: 700;
}

.segmented small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.segmented input:checked + span small {
  color: var(--accent-dark);
}

.segmented input:checked + span {
  border-color: var(--accent);
  background: #ffe3cf;
  color: var(--accent-dark);
}

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

.notice {
  background: #fff8ef;
}

.notice p {
  margin: 6px 0 0;
  color: #5a534b;
  line-height: 1.55;
}

.notice a {
  color: var(--accent-dark);
  font-weight: 700;
  word-break: break-all;
}

.preview-card {
  border-radius: 18px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  padding: 12px;
}

.preview-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.preview-head strong {
  font-size: 14px;
}

.preview-head span,
.preview-tip {
  font-size: 12px;
  color: var(--muted);
}

.preview-tip {
  display: block;
  margin: -4px 0 10px;
}

.preview-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.preview-nav-btn {
  cursor: pointer;
  border: 1px solid #decfbe;
  border-radius: 10px;
  padding: 6px 8px;
  background: #fff8ef;
  color: #5d5241;
  font-size: 12px;
  font-weight: 800;
}

.preview-nav-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.preview-box {
  min-height: 180px;
  border-radius: 14px;
  border: 1px dashed #d7cab8;
  background: #f3ede3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 12px;
}

.empty-preview {
  color: var(--muted);
  font-size: 14px;
}

.sheet-preview {
  min-height: 260px;
}

.paper-sheet {
  position: relative;
  width: min(100%, 320px);
  max-width: 100%;
  max-height: 430px;
  background: #fff;
  border: 1px solid #d8d1c7;
  border-radius: 4px;
  box-shadow: 0 10px 24px rgba(31, 41, 51, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 16px;
}

.a4.portrait .paper-sheet {
  aspect-ratio: 210 / 297;
  width: min(100%, 304px);
}

.a4.landscape .paper-sheet {
  aspect-ratio: 297 / 210;
  width: 100%;
}

.a3.portrait .paper-sheet {
  aspect-ratio: 297 / 420;
  width: min(100%, 304px);
}

.a3.landscape .paper-sheet {
  aspect-ratio: 420 / 297;
  width: 100%;
}

.sheet-meta {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 8px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  pointer-events: none;
}

.sheet-meta span {
  border-radius: 999px;
  padding: 3px 6px;
  background: rgba(255, 248, 239, 0.92);
  color: #675a45;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  border: 1px solid rgba(215, 202, 184, 0.78);
}

.sheet-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.bw .sheet-image,
.bw .sheet-pdf {
  filter: grayscale(1);
}

.sheet-pdf,
.sheet-pdf iframe {
  width: 100%;
  height: 100%;
  min-height: 220px;
  border: none;
  display: block;
  background: #fff;
}

.pdf-sheet .paper-sheet {
  padding: 0;
}

.pdf-sheet .sheet-meta,
.mini-sheet .sheet-meta {
  left: 6px;
  right: 6px;
  top: 6px;
}

.pdf-sheet .sheet-meta span,
.mini-sheet .sheet-meta span {
  font-size: 9px;
  padding: 2px 5px;
}

.primary-btn,
.ghost-btn {
  cursor: pointer;
  border: none;
  border-radius: 16px;
  font-weight: 700;
}

.primary-btn {
  padding: 14px 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, #ed9158 100%);
  box-shadow: 0 14px 28px rgba(217, 107, 39, 0.25);
}

.ghost-btn {
  padding: 10px 14px;
  background: #f7f0e5;
  color: #5d5241;
}

.task-card {
  margin-top: 16px;
  padding: 14px;
}

.task-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

#polling-badge {
  font-size: 12px;
  color: var(--success);
  font-weight: 700;
}

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

.task-summary {
  display: grid;
  gap: 8px;
}

.task-summary strong {
  font-size: 16px;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.task-meta span,
.state-pill {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.task-meta span {
  background: #f6f1e8;
  color: #5d5241;
}

.task-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 4px 0 0;
}

.task-detail-grid div {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffaf3;
}

.task-detail-grid dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.task-detail-grid dd {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  word-break: break-word;
}

.batch-task-list {
  display: grid;
  gap: 8px;
}

.batch-task-item {
  display: grid;
  gap: 4px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffaf3;
}

.batch-task-item strong {
  font-size: 13px;
  word-break: break-all;
}

.batch-task-item span,
.batch-task-item small {
  color: #5a534b;
  font-size: 12px;
  line-height: 1.45;
}

.batch-task-item small {
  color: var(--accent-dark);
  font-weight: 800;
}

.payment-panel {
  display: grid;
  grid-template-columns: 1fr 170px;
  gap: 12px;
  align-items: stretch;
  padding: 12px;
  border: 1px solid #f0c9aa;
  border-radius: 16px;
  background: #fff4eb;
}

.payment-panel.warning {
  display: block;
  border-color: #f0d39a;
  background: #fff8df;
}

.payment-label {
  display: block;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.payment-amount {
  display: block;
  margin: 4px 0;
  color: var(--accent-dark);
  font-size: 30px;
  line-height: 1;
}

.payment-panel p {
  margin: 0;
  color: #5a534b;
  font-size: 13px;
  line-height: 1.5;
}

.payment-steps {
  margin: 10px 0 0;
  padding-left: 18px;
  color: #5a3320;
  font-size: 13px;
  line-height: 1.55;
}

.self-print-btn {
  width: 100%;
  margin-top: 4px;
  border: none;
  border-radius: 12px;
  padding: 12px 10px;
  background: var(--success);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(35, 123, 75, 0.18);
}

.self-print-btn:disabled {
  cursor: wait;
  opacity: 0.72;
}

.payment-limit-note {
  margin-top: 10px !important;
  color: var(--warn) !important;
  font-weight: 800;
}

.qr-placeholder {
  min-height: 170px;
  border: 1px solid #f0c9aa;
  border-radius: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  text-align: center;
}

.qr-placeholder img {
  display: block;
  width: 100%;
  max-width: 138px;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 6px;
}

.qr-placeholder small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.state-pill.pending {
  background: #fff3d9;
  color: var(--warn);
}

.state-pill.awaiting_payment {
  background: #fff3d9;
  color: var(--warn);
}

.state-pill.printing {
  background: #e8f1ff;
  color: #1f5fbf;
}

.state-pill.success {
  background: #e8f8ee;
  color: var(--success);
}

.state-pill.failed {
  background: #fdecec;
  color: #b42318;
}

.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.info-card {
  padding: 18px;
}

.info-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.info-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 22px;
}

.info-card p,
.flow-note li {
  margin: 0;
  line-height: 1.6;
  color: #4f5b67;
}

.queue-panel,
.stats-panel,
.flow-note {
  padding: 18px;
}

.stats-panel {
  margin-bottom: 16px;
}

.stats-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffaf3;
  padding: 14px;
}

.stat-card > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stat-card > strong {
  display: block;
  margin-bottom: 12px;
  color: var(--accent-dark);
  font-size: 20px;
  line-height: 1.25;
}

.stat-list {
  max-height: 280px;
  overflow: auto;
  display: grid;
  gap: 8px;
}

.stat-empty {
  border-radius: 12px;
  padding: 14px;
  background: #fff;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.stat-item {
  border: 1px solid #eadfce;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
}

.stat-item div {
  display: grid;
  gap: 4px;
  margin-bottom: 6px;
}

.stat-item strong {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
  word-break: break-all;
}

.stat-item span,
.stat-item p,
.stat-item small {
  color: #5a534b;
  font-size: 12px;
  line-height: 1.45;
}

.stat-item p {
  margin: 0 0 6px;
}

.stat-item small {
  display: block;
  color: var(--accent-dark);
  font-weight: 800;
}

.queue-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.queue-actions,
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.table-actions {
  align-items: flex-start;
  flex-direction: column;
}

.file-name-cell {
  display: block;
  max-width: 260px;
  margin-bottom: 10px;
  word-break: break-all;
}

.file-compact-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.file-compact-cell strong {
  font-size: 14px;
}

.admin-preview {
  display: grid;
  gap: 8px;
  width: min(260px, 100%);
}

.admin-preview.large-preview {
  width: 100%;
  justify-items: center;
}

.file-preview-card {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffaf2;
  padding: 12px;
}

.file-preview-card + .file-preview-card {
  margin-top: 14px;
}

.file-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.file-preview-head div {
  display: grid;
  gap: 4px;
}

.file-preview-head strong {
  word-break: break-all;
}

.file-preview-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.preview-edit-panel {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 8px;
  width: 100%;
  align-items: end;
}

.preview-edit-panel label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.preview-edit-panel select,
.preview-edit-panel input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  padding: 7px 9px;
}

.mini-sheet {
  min-height: 150px;
  border-radius: 12px;
  border: 1px dashed #d7cab8;
  background: #f3ede3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.mini-sheet .paper-sheet {
  max-height: 210px;
  padding: 10px;
}

.mini-sheet.portrait .paper-sheet {
  width: auto;
  height: 210px;
}

.mini-sheet.landscape .paper-sheet {
  width: 100%;
  height: auto;
}

.mini-sheet .sheet-pdf,
.mini-sheet .sheet-pdf iframe {
  min-height: 130px;
}

.modal-sheet {
  width: min(100%, 720px);
  min-height: 420px;
}

.modal-sheet .paper-sheet {
  max-height: 68vh;
}

.modal-sheet.portrait .paper-sheet {
  height: min(68vh, 680px);
  width: auto;
}

.modal-sheet.landscape .paper-sheet {
  width: min(100%, 720px);
}

.modal-sheet .sheet-pdf,
.modal-sheet .sheet-pdf iframe {
  min-height: 520px;
}

.unsupported-preview {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  line-height: 1.5;
}

.confirm-btn {
  cursor: pointer;
  border: none;
  border-radius: 12px;
  padding: 9px 12px;
  background: var(--success);
  color: #fff;
  font-weight: 800;
}

.preview-link {
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  padding: 9px 12px;
  background: #f7f0e5;
  color: #5d5241;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.confirm-btn:disabled,
.ghost-btn:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.table-wrap {
  overflow: auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(31, 41, 51, 0.56);
}

.modal-backdrop[hidden] {
  display: none;
}

.preview-modal {
  width: min(96vw, 880px);
  max-height: 92vh;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 28px 70px rgba(31, 41, 51, 0.28);
  padding: 18px;
}

.preview-modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.preview-modal-head h3 {
  margin: 0 0 6px;
}

.preview-modal-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.preview-modal-body {
  border-radius: 16px;
  background: #f3ede3;
  padding: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1040px;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

tr.needs-confirm td {
  background: #fffaf0;
}

thead th {
  font-size: 13px;
  color: var(--muted);
}

.table-empty {
  color: var(--muted);
  text-align: center;
}

.flow-note {
  margin-top: 16px;
}

.flow-note ol {
  margin: 0;
  padding-left: 20px;
}

code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
}

@media (max-width: 1080px) {
  .hero,
  .layout,
  .dashboard-cards,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .preview-edit-panel {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .phone-frame {
    width: 100%;
    max-width: 420px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 18px 14px 32px;
  }

  .panel-head,
  .task-card-head,
  .queue-head {
    flex-direction: column;
    align-items: start;
  }

  .inline-grid,
  .segmented,
  .payment-panel,
  .preview-edit-panel {
    grid-template-columns: 1fr;
  }

  .file-preview-head {
    flex-direction: column;
  }

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