:root {
  --bg: #f4f1ea;
  --card: #fffdf8;
  --line: #e2dccf;
  --text: #1d1b16;
  --muted: #736c5e;
  --accent: #1f4fd1;
  --ok: #1b8a54;
  --warn: #b7791f;
  --bad: #c53030;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding: 0 16px 32px; max-width: 1080px; margin: 0 auto; }
button, input, textarea { font: inherit; color: inherit; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 22px 0 18px; flex-wrap: wrap; }
.eyebrow { margin: 0; color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 2px 0 0; font-size: 24px; }
h2 { margin: 0 0 14px; font-size: 16px; }
.mt { margin-top: 22px; }

.station { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.station b { display: block; font-size: 14px; }
.station small { color: var(--muted); font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #b9b2a3; flex: none; }
.station[data-state="ok"] .dot { background: var(--ok); }
.station[data-state="warn"] .dot { background: var(--warn); }
.station[data-state="bad"] .dot { background: var(--bad); }

.layout { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; min-width: 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; background: #fff; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

.items { width: 100%; border-collapse: collapse; margin-top: 4px; }
.items th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 0 4px 6px; }
.items td { padding: 3px 4px; }
.items .n { width: 92px; }
.items td.x { width: 36px; }
.items input.n { text-align: right; }
.del { border: 0; background: none; color: var(--muted); font-size: 20px; cursor: pointer; width: 32px; height: 32px; border-radius: 8px; }
.del:hover { background: var(--bg); color: var(--bad); }
.link { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 8px 4px; cursor: pointer; }

.totals { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 10px; }
.totals div { display: flex; justify-content: space-between; padding: 2px 0; color: var(--muted); }
.totals b { color: var(--text); font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 19px; color: var(--text); padding-top: 6px; }

.opts { display: flex; gap: 18px; margin: 16px 0; flex-wrap: wrap; }
.opts label { display: flex; align-items: center; gap: 8px; }
.opts input { width: 18px; height: 18px; accent-color: var(--accent); }

.btn { width: 100%; border: 0; border-radius: 12px; padding: 14px; background: var(--accent); color: #fff; font-weight: 650; font-size: 16px; cursor: pointer; }
.btn:disabled { opacity: .5; cursor: progress; }
.btn--ghost { background: var(--bg); color: var(--text); border: 1px solid var(--line); font-size: 15px; padding: 11px; margin-top: 8px; }

.adv { margin-top: 18px; }
.adv summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.adv textarea { margin-top: 10px; font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }

.paper { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 16px 12px; font: 12px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; overflow-x: auto; box-shadow: 0 8px 24px -16px #0004; }

.jobs { list-style: none; margin: 0; padding: 0; }
.jobs li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.jobs li.empty { color: var(--muted); justify-content: center; border: 0; }
.jobs small { display: block; color: var(--muted); font-size: 12px; }
.jobs .err { color: var(--bad); }
.badge { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--bg); align-self: start; white-space: nowrap; }
.badge--printed { background: #dff3e8; color: var(--ok); }
.badge--failed { background: #fbe3e3; color: var(--bad); }
.badge--queued, .badge--sent { background: #fbf0d9; color: var(--warn); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--text); color: #fff; padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .grid2 { grid-template-columns: 1fr; }
  .items .n { width: 64px; }
}
