:root {
  --bg: #f4f5f7; --card: #ffffff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --accent: #2563eb; --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
  --ok-bg: #dcfce7; --warn-bg: #fef3c7; --bad-bg: #fee2e2; --neutral-bg: #eef0f3;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --card: #1b1f25; --text: #e6e8eb; --muted: #9aa3ae; --line: #2c323b;
    --accent: #60a5fa; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171;
    --ok-bg: #12301f; --warn-bg: #3a2c0d; --bad-bg: #3b1515; --neutral-bg: #262b33;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
header { display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--card); }
h1 { font-size: 18px; margin: 0; } h2 { font-size: 15px; margin: 0 0 10px; }
/* Wide enough to use the print station's 1680 px screen; one column on narrow screens. */
main { max-width: 1560px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.cols > .stack { display: grid; gap: 14px; }
@media (max-width: 1100px) { .cols { grid-template-columns: minmax(0, 1fr); } }
.help-link { font-size: 13px; font-weight: normal; margin-left: 10px; padding: 2px 9px; border-radius: 999px;
             border: 1px solid var(--line); color: var(--muted); text-decoration: none; white-space: nowrap; }
.help-link:hover { color: var(--text); border-color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; gap: 8px; } .gap { gap: 8px; }
.muted { color: var(--muted); font-weight: normal; } .small { font-size: 13px; }
.hidden { display: none !important; }
.paper-warn { margin: 6px 0; padding: 7px 10px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-size: 13.5px; font-weight: 600; }
.alerts li.loaded { color: var(--text); list-style: none; }
.pill { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--neutral-bg); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.warn { color: var(--warn); margin: 8px 0 0; }
.btn { font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text); min-height: 34px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.armed { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn:disabled { opacity: .4; cursor: default; }
.icon { min-width: 34px; padding: 6px 8px; }

.inks { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 12px; }
.ink .label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.ink .bar { height: 8px; border-radius: 4px; background: var(--neutral-bg); overflow: hidden; margin-top: 3px; }
.ink .fill { height: 100%; background: var(--ok); }
.ink.waste .fill { background: var(--muted); }
.ink.low .fill { background: var(--bad); } .ink.low .label span:last-child { color: var(--bad); font-weight: 600; }
.alerts { margin: 10px 0 0; padding-left: 18px; color: var(--warn); }

.job { border-top: 1px solid var(--line); padding: 10px 0; display: grid; gap: 6px; }
.job:first-child { border-top: none; padding-top: 0; }
.job .title { font-weight: 600; word-break: break-word; }
.job .meta { font-size: 13px; color: var(--muted); }
.job .actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.job .note { width: 100%; font: inherit; font-size: 13px; padding: 6px 8px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.pos { font-size: 12px; color: var(--muted); min-width: 22px; }

.events { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.events li { padding: 4px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.events li:first-child { border-top: none; }
.events time { color: var(--muted); white-space: nowrap; }

nav { display: flex; gap: 4px; }
/* links in text: the browser default blue is unreadable on the dark theme */
a { color: var(--accent); }
nav a { color: var(--muted); text-decoration: none; font-size: 14px; padding: 5px 10px; border-radius: 7px; }
nav a.active { color: var(--text); background: var(--neutral-bg); }
header { flex-wrap: wrap; gap: 8px; }

.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
@media (max-width: 640px) { .grid-form { grid-template-columns: 1fr; } }
.grid-form .span2 { grid-column: 1 / -1; }
.grid-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.grid-form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.grid-form input[type=number], .grid-form select, .grid-form input[type=file] {
  font: inherit; font-size: 14px; padding: 7px 8px; border-radius: 7px; min-height: 36px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%; }
.grid-form input[type=color] { width: 60px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); }
.grow { flex: 1; }
.bar { height: 8px; border-radius: 4px; background: var(--neutral-bg); overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); transition: width .2s; }
.preview { max-width: 100%; max-height: 420px; border-radius: 6px; border: 1px solid var(--line); display: block; }
.bad-text { color: var(--bad); } .warn-text { color: var(--warn); } .ok-text { color: var(--ok); }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }

h3 { font-size: 13px; margin: 14px 0 6px; color: var(--muted); font-weight: 600; }
h3:first-child { margin-top: 0; }
table.stock { width: 100%; border-collapse: collapse; font-size: 14px; }
table.stock th { text-align: left; font-weight: normal; color: var(--muted); font-size: 12px; padding: 4px 6px; }
table.stock td { border-top: 1px solid var(--line); padding: 6px; }
table.stock td.actions { text-align: right; white-space: nowrap; }
table.stock td.actions .btn { margin-left: 4px; }
tr.low-row td.qty { color: var(--bad); font-weight: 600; }
.add-row { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); align-items: flex-end; }
.add-row label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.add-row input, .add-row select, input.num { font: inherit; font-size: 14px; padding: 7px 8px; border-radius: 7px;
  min-height: 36px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.add-row input[type=number], input.num { width: 110px; }
.plan { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--bg); font-size: 14px; display: grid; gap: 4px; }
.plan .big { font-size: 15px; font-weight: 600; }

/* canvas prep: photo library */
.drop { display: grid; gap: 8px; place-items: center; text-align: center; padding: 18px; border: 2px dashed var(--line);
  border-radius: 10px; cursor: pointer; color: var(--muted); background: var(--bg); }
.drop:hover, .drop.over { border-color: var(--accent); color: var(--text); }
.drop .bar { width: 100%; max-width: 420px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; }
.photo { position: relative; border: 2px solid var(--line); border-radius: 8px; overflow: hidden; cursor: pointer; background: var(--bg); }
.photo.selected { border-color: var(--accent); }
.photo img { width: 100%; height: 100px; object-fit: cover; display: block; }
.photo-meta { padding: 4px 6px; font-size: 12px; display: grid; }
.photo-meta .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-del { position: absolute; top: 4px; right: 4px; min-height: 26px; min-width: 26px; padding: 2px 6px; font-size: 12px; }

/* canvas prep: crop editor */
.editor-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; align-items: start; }
@media (max-width: 860px) { .editor-grid { grid-template-columns: 1fr; } }
.editor-grid .grid-form { grid-template-columns: 1fr 1fr; }
.crop-stage { position: relative; display: inline-block; max-width: 100%; overflow: hidden; border-radius: 6px;
  touch-action: none; user-select: none; -webkit-user-select: none; line-height: 0; background: #000; }
.crop-stage img { max-width: 100%; max-height: 70vh; display: block; pointer-events: none; }
.crop-rect { position: absolute; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55); outline: 2px solid #fff; cursor: move; }
.crop-guide { position: absolute; border: 2px dashed rgba(255, 210, 80, .95); pointer-events: none; }
.crop-rect .h { position: absolute; width: 22px; height: 22px; background: #fff; border: 2px solid var(--accent); border-radius: 4px; }
.crop-rect .nw { left: -11px; top: -11px; cursor: nwse-resize; } .crop-rect .se { right: -11px; bottom: -11px; cursor: nwse-resize; }
.crop-rect .ne { right: -11px; top: -11px; cursor: nesw-resize; } .crop-rect .sw { left: -11px; bottom: -11px; cursor: nesw-resize; }
.crop-tools { margin-top: 8px; }

.preview.zoomable { cursor: zoom-in; }
.saved.warn-bg { background: var(--warn-bg); color: var(--warn); }
.saved { font-size: 13px; padding: 6px 10px; border-radius: 7px; background: var(--ok-bg); color: var(--ok); word-break: break-all; }
.viewer { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .88); display: flex;
  align-items: center; justify-content: center; padding: 56px 16px 16px; cursor: zoom-out; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.viewer-close { position: absolute; top: 12px; right: 12px; font-size: 16px; padding: 8px 16px; min-height: 42px; }

/* orders */
.orders-main { max-width: 1560px; }
.input { font: inherit; font-size: 14px; padding: 7px 8px; border-radius: 7px; min-height: 36px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%; }
textarea.input { resize: vertical; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.tab { font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); cursor: pointer; }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.order-row { padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); margin-top: 6px; cursor: pointer; display: grid; gap: 2px; }
.order-row:hover { border-color: var(--muted); }
.order-row.selected { border-color: var(--accent); }
.order-row .meta { font-size: 12px; color: var(--muted); }
.cust-results { display: grid; gap: 4px; }
.cust { text-align: left; font: inherit; padding: 7px 10px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); cursor: pointer; }
.cust:hover { border-color: var(--accent); }
table.items td { vertical-align: middle; }
.input.cell { min-height: 30px; padding: 4px 6px; }
.input.cell.qty { width: 64px; text-align: right; }
.input.cell.price { width: 90px; text-align: right; }
td.num, th.num { text-align: right; white-space: nowrap; }
.totals-box { margin: 12px 0 0 auto; min-width: 260px; border-collapse: collapse; font-size: 14px; }
.totals-box td { padding: 3px 6px; }
.totals-box .grand td { font-weight: 700; border-top: 1px solid var(--line); }
#detail h3 { margin-top: 18px; }
@media (min-width: 980px) {
  .orders-main { display: grid; grid-template-columns: 400px 1fr; align-items: start; }
  .orders-main > .orders-list { grid-row: span 2; position: sticky; top: 12px; max-height: calc(100vh - 90px); overflow: auto; }
  .orders-main > section:last-child { grid-column: 2; }
}

details.costs { margin-top: 6px; }
details.costs summary { cursor: pointer; }
details.costs table { margin-top: 6px; }
.input.cell.cost { color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); max-width: calc(100% - 32px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; }
.toast.error { background: var(--bad); color: #fff; }

/* Canvas prep: Canvas | Framed print switch */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; justify-self: start; }
.seg button { font: inherit; padding: 8px 16px; border: 0; background: transparent; color: inherit; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--accent); color: #fff; }
body.mode-canvas .print-only, body.mode-print .canvas-only, body.no-mount .mount-only { display: none !important; }
body.mode-mug .print-only, body.mode-mug .canvas-only, body.mode-mug .not-mug, body:not(.mode-mug) .mug-only { display: none !important; }
/* the 3D mug (shop/static/mug3d.js, shared with the website) */
.mug3d-prep { margin-top: 12px; }
.mug3d-stage { width: 100%; border-radius: 12px; overflow: hidden; background: linear-gradient(#f3eee7, #e6ded2); touch-action: pan-y; margin-top: 4px; }
.mug3d-canvas { display: block; width: 100%; height: auto; cursor: grab; }
.mug3d-canvas:active { cursor: grabbing; }

/* Print queue: one tab per printer */
.printer-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.printer-tabs .tab { font: inherit; display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); cursor: pointer; }
.printer-tabs .tab.active { border-color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }

/* Phone upload QR overlay */
.phone-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center;
  justify-content: center; z-index: 50; padding: 16px; }
.phone-overlay.hidden { display: none; }
.phone-card { background: var(--card); color: var(--text); border-radius: 14px; padding: 20px 22px; width: min(520px, 100%);
  max-height: 100%; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.phone-card h2 { margin: 0 0 4px; }
.phone-qr { display: flex; justify-content: center; margin: 12px 0; }
.phone-qr svg, .phone-qr img { width: min(300px, 70vw); height: auto; background: #fff; border-radius: 8px; }
.phone-steps { margin: 6px 0 10px; padding-left: 20px; }
.phone-got { list-style: none; padding: 0; margin: 8px 0 0; max-height: 140px; overflow: auto; font-size: 14px; }

/* Printers page */
#printers { display: grid; gap: 16px; margin-top: 12px; }
.printer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px 24px; }
table.details td { padding: 4px 8px 4px 0; vertical-align: top; }
table.details td.muted { white-space: nowrap; width: 1%; }
.task { padding: 8px 0; border-top: 1px solid var(--line); }
.task.overdue b { color: var(--bad); }
.maint-log li { align-items: center; }
.maint-log li .btn { margin-left: auto; }

/* Stock: a roll's name / width / type sit on one line */
/* each roll in its own box - one after another they ran together */
#rolls { display: grid; gap: 12px; margin-bottom: 12px; }
.job.roll-card { border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 10px;
  padding: 12px 14px; background: var(--bg); }
.job.roll-card.loaded { border-left-color: var(--ok); }
.job.roll-card.out { border-left-color: var(--warn); }
.roll-head { flex-wrap: wrap; }
.roll-head .input { width: auto; flex: 0 0 auto; }
.roll-head .input[data-roll-name] { flex: 1 1 200px; }

/* Colour page */
.terminal { background: #0b0d10; color: #d6e2f0; font: 13px/1.45 ui-monospace, Consolas, monospace; padding: 10px 12px;
  border-radius: 8px; height: 280px; overflow: auto; white-space: pre-wrap; margin: 8px 0; }
.chart-thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.chart-thumb { height: 120px; border: 1px solid var(--line); border-radius: 4px; cursor: zoom-in; background: #fff; }

/* Price list */
.price-table td.num .input { width: 90px; text-align: right; }
.price-table td { vertical-align: middle; }

/* Orders: website items and access */
.web-item { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.web-item img { height: 56px; border-radius: 4px; border: 1px solid var(--line); }
.web-access { flex-wrap: wrap; }

/* Orders: website examples */
.st-examples { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin: 8px 0 12px; }
.st-example { border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.st-example img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; }
.job-what b { color: var(--text); font-weight: 600; }
.lp-row .input { width: auto; flex: none; }
body.loose .framed-only, body.loose .mount-only { display: none !important; }

/* the top menu (nav.js): groups open on a tap, so it works on the print station's touch screen */
nav.menu { align-items: center; flex-wrap: wrap; }
.menu-group { position: relative; }
.menu-btn { font: inherit; font-size: 14px; color: var(--muted); background: none; border: 0; cursor: pointer;
  padding: 5px 10px; border-radius: 7px; min-height: 34px; }
.menu-btn.active, .menu-btn[aria-expanded="true"] { color: var(--text); background: var(--neutral-bg); }
.menu-list { position: absolute; top: calc(100% + 4px); left: 0; z-index: 40; min-width: 190px; display: grid;
  background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
.menu-list[hidden] { display: none; }
.menu-list a { padding: 9px 12px; font-size: 15px; }
.menu-list a small { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.menu-found { outline: 3px solid var(--accent); outline-offset: 3px; transition: outline-color .4s; }

