/* Graphics
   White sheets on a warm mat board. The UI is set in Source Sans 3, the
   same face the labels print in, served from /fonts.css. One accent, the
   cut-line magenta from print production, appears only on armed actions
   (Approve, Order) and the "ready" state; everything else is ink on paper.
   The proof (the label at true size with its dimensions) is the hero. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
	--font: 'Source Sans 3', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
	--board: #edece6;
	--board-deep: #e2e0d8;
	--sheet: #fff;
	--rule: #dcd9d1;
	--rule-soft: #ebe9e3;
	--ink: #23221f;
	--graphite: #6c6963;
	--faint: #a29f98;
	--cut: #b0245f;
	--cut-deep: #92184c;
	--cut-soft: #f8e7ee;
	--ok: #3d7a41;
	--ok-soft: #e7f0e6;
	--warn: #a3590c;
	--warn-soft: #fbefdf;
	--bad: #b3261e;
	--bad-soft: #fbe9e7;
	--radius: 4px;
	--radius-lg: 6px;
	--shadow-sheet: 0 1px 2px rgba(35, 34, 31, 0.06);
	--shadow-proof: 0 1px 1px rgba(35, 34, 31, 0.12), 0 6px 18px rgba(35, 34, 31, 0.14);
}

html { font-size: 16px; }
body { font-family: var(--font); font-size: 0.9375rem; color: var(--ink); background: var(--board); line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100vh; font-feature-settings: "tnum"; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h1 { font-size: 1.75rem; font-weight: 600; letter-spacing: -0.015em; line-height: 1.15; }
h2 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.005em; margin-bottom: 0.75rem; }
h3 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
.mute { color: var(--graphite); }
.faint { color: var(--faint); }
.small { font-size: 0.875rem; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.sub { color: var(--graphite); margin-top: 0.15rem; }
.sub > * + *::before { content: ""; display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: var(--faint); margin: 0 0.6em; vertical-align: middle; }

@media (prefers-reduced-motion: no-preference) {
	.btn, .chip, input, select, textarea, .state, #toast { transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, opacity 200ms ease; }
}

/* Topbar */
.topbar:empty { display: none; }
.topbar { display: flex; align-items: center; gap: 1.25rem; padding: 0 1.5rem; height: 3.25rem; background: var(--sheet); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 5; }
.topbar .mark { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 600; letter-spacing: -0.01em; }
.topbar .mark svg { width: 18px; height: 18px; display: block; }
.topbar .crumbs { display: flex; align-items: center; gap: 0.55rem; color: var(--graphite); min-width: 0; overflow: hidden; white-space: nowrap; }
.topbar .crumbs a { color: var(--graphite); }
.topbar .crumbs a:hover { color: var(--ink); text-decoration: none; }
.topbar .crumbs .sep { color: var(--rule); font-weight: 300; }
.topbar .crumbs .here { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.topbar .who { margin-left: auto; color: var(--graphite); font-size: 0.875rem; display: flex; gap: 0.75rem; align-items: center; flex: none; }

main { max-width: 68rem; margin: 0 auto; padding: 2rem 1.5rem 6rem; }
main.wide { max-width: 90rem; }

/* Page head */
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.75rem; flex-wrap: wrap; }
.head .actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; padding-top: 0.25rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 0.45rem 0.9rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--sheet); color: var(--ink); font-size: 0.9375rem; font-weight: 500; cursor: pointer; white-space: nowrap; line-height: 1.25; }
.btn:hover { border-color: var(--graphite); }
.btn:disabled { opacity: 0.4; cursor: default; border-color: var(--rule); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; border-color: #000; }
.btn-live { background: var(--cut); border-color: var(--cut); color: #fff; }
.btn-live:hover { background: var(--cut-deep); border-color: var(--cut-deep); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--graphite); }
.btn-ghost:hover { color: var(--ink); background: var(--board); border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: transparent; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.875rem; }
.btn .count { font-weight: 400; opacity: 0.75; }
.row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

/* Forms */
label.f { display: block; font-size: 0.8125rem; color: var(--graphite); margin-bottom: 0.2rem; }
input[type=text], input[type=number], input[type=password], input[type=email], select, textarea { width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--sheet); line-height: 1.35; }
input:hover, select:hover, textarea:hover { border-color: #c4c1b9; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
input:disabled, select:disabled, textarea:disabled { background: transparent; border-color: var(--rule); color: var(--graphite); opacity: 1; -webkit-text-fill-color: var(--graphite); }
.editor form.locked .field { margin-bottom: 0.5rem; }
textarea { resize: vertical; min-height: 4.5rem; }
.field { margin-bottom: 0.9rem; }
.field:last-child { margin-bottom: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem; }
.err { color: var(--bad); font-size: 0.875rem; }
.err:empty { display: none; }
.hint { color: var(--graphite); font-size: 0.875rem; }
.hint a { text-decoration: underline; text-underline-offset: 2px; }
.check { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0; cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--ink); }
.check .mute, .check .faint { margin-left: 0.35rem; font-size: 0.875rem; }
.checks { display: flex; flex-direction: column; gap: 0.1rem; }
table.library td .btn + .btn { margin-left: 0.25rem; }
table.library tr.editing td { background: #faf9f6; }

/* Sheets (cards) & tables */
.card { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 1.1rem 1.25rem; margin-bottom: 1.5rem; box-shadow: var(--shadow-sheet); }
.card > h2:first-child { margin-bottom: 0.6rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.6rem; }
.card-head h2 { margin: 0; }
.card table.list { margin: 0 -1.25rem -1.1rem; width: calc(100% + 2.5rem); }
.card table.list th:first-child, .card table.list td:first-child { padding-left: 1.25rem; }
.card table.list th:last-child, .card table.list td:last-child { padding-right: 1.25rem; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 0.8125rem; color: var(--graphite); font-weight: 500; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--rule); }
table.list td { padding: 0.6rem 0.6rem; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.link { cursor: pointer; }
table.list tr.link:hover td { background: #faf9f6; }
table.list tr.link td a:hover { text-decoration: none; }
table.list .ref { font-weight: 600; white-space: nowrap; }
/* The text column takes what is left and truncates, so the table never
   grows past its sheet whatever the other columns need. */
table.list .excerpt { color: var(--graphite); width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.list th, table.list td { white-space: nowrap; }
table.list td.excerpt, table.list td.note { white-space: nowrap; }
table.list td.excerpt b { color: var(--ink); font-weight: 500; }
.num { text-align: right; }
table.list th.th-thumb { width: 8.5rem; }
.empty { color: var(--graphite); padding: 0.4rem 0; }

/* State: a dot and the word */
.state { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.875rem; white-space: nowrap; color: var(--graphite); }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid currentColor; flex: none; }
.state-draft { color: var(--graphite); }
.state-ready { color: var(--cut); }
.state-ready::before { background: var(--cut); }
.state-approved { color: var(--ok); }
.state-approved::before { background: var(--ok); }
.state-ordered { color: var(--ink); }
.state-ordered::before { background: var(--ink); }
.state-received { color: var(--graphite); }
.state-received::before { background: var(--graphite); border-color: var(--graphite); }
.state-overflow { color: var(--warn); }
.state-overflow::before { border-radius: 1px; background: var(--warn); border-color: var(--warn); }

/* Progress strip: a set's labels by state, left to right toward printed */
.strip { display: flex; height: 6px; width: 100%; max-width: 16rem; border-radius: 3px; overflow: hidden; background: var(--rule-soft); }
.strip i { display: block; height: 100%; }
.strip .s-draft { background: #cfccc4; }
.strip .s-ready { background: var(--cut); }
.strip .s-approved { background: var(--ok); }
.strip .s-ordered { background: var(--ink); }
.strip .s-received { background: var(--graphite); }
.progress { display: flex; flex-direction: column; gap: 0.35rem; min-width: 12rem; }
.progress .legend { display: flex; gap: 0.9rem; font-size: 0.8125rem; color: var(--graphite); white-space: nowrap; }
.progress .legend .ready { color: var(--cut); font-weight: 500; }
.progress .legend .approved { color: var(--ok); font-weight: 500; }

/* Thumbnails */
.thumb { display: block; width: 7.25rem; max-height: 6rem; overflow: hidden; border: 1px solid var(--rule); background: #fff; box-shadow: var(--shadow-sheet); }
.thumb svg { width: 100%; height: auto; display: block; }
.thumb.wide { width: 16rem; max-height: none; }

/* The proof: label editor preview on the deep board, with dimensions */
.desk { background: var(--board-deep); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 2.25rem 2.25rem 1.75rem; overflow: auto; min-height: 22rem; display: flex; align-items: flex-start; justify-content: center; }
.proof { display: grid; grid-template-columns: minmax(0, auto) 1.6rem; grid-template-rows: auto 1.6rem; column-gap: 0.75rem; row-gap: 0.6rem; max-width: 100%; }
.desk.fit .proof { width: 100%; }
.sheet { grid-area: 1 / 1; box-shadow: var(--shadow-proof); background: #fff; line-height: 0; }
.desk.fit .sheet svg { width: 100%; height: auto; }
.dim { position: relative; color: var(--graphite); font-size: 0.8125rem; }
.dim span { position: absolute; background: var(--board-deep); padding: 0 0.35rem; line-height: 1; white-space: nowrap; }
.dim-h { grid-area: 2 / 1; height: 1.6rem; }
.dim-h::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--graphite); }
.dim-h::after { content: ""; position: absolute; left: 0; right: 0; top: calc(50% - 5px); height: 10px; border-left: 1px solid var(--graphite); border-right: 1px solid var(--graphite); }
.dim-h span { left: 50%; top: 50%; transform: translate(-50%, -50%); }
.dim-v { grid-area: 1 / 2; width: 1.6rem; }
.dim-v::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; border-left: 1px solid var(--graphite); }
.dim-v::after { content: ""; position: absolute; top: 0; bottom: 0; left: calc(50% - 5px); width: 10px; border-top: 1px solid var(--graphite); border-bottom: 1px solid var(--graphite); }
.dim-v span { left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-90deg); }
.readout { font-size: 0.875rem; color: var(--graphite); display: flex; gap: 1.25rem; align-items: center; margin-top: 0.75rem; min-height: 1.5rem; }
.readout .overflow { color: var(--warn); font-weight: 500; }

/* Editor layout */
.editor { display: grid; grid-template-columns: minmax(20rem, 24rem) minmax(0, 1fr); gap: 2rem; align-items: start; }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } }
.editor form .field { margin-bottom: 0.75rem; }
.editor .meta { display: grid; grid-template-columns: 5rem 1fr 1fr; gap: 0.6rem; margin-bottom: 0.75rem; }
.editor .foot { display: flex; align-items: center; gap: 0.6rem; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.editor .foot .btn-danger { margin-left: auto; }
.saved { font-size: 0.875rem; color: var(--faint); min-width: 4rem; }
.pager { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; background: var(--sheet); }
.pager a { padding: 0.3rem 0.65rem; color: var(--graphite); font-size: 0.875rem; }
.pager a + a { border-left: 1px solid var(--rule); }
.pager a:hover { color: var(--ink); background: var(--board); text-decoration: none; }
.pager a[aria-disabled] { opacity: 0.35; pointer-events: none; }
.locked { padding: 0.6rem 0.75rem; background: var(--board); border-radius: var(--radius); font-size: 0.875rem; color: var(--graphite); margin-top: 0.75rem; }
.locked a { color: var(--ink); font-weight: 500; }

/* History */
.history { list-style: none; font-size: 0.875rem; }
.history li { padding: 0.4rem 0; border-bottom: 1px solid var(--rule-soft); display: flex; gap: 0.75rem; align-items: baseline; }
.history li:last-child { border-bottom: 0; padding-bottom: 0; }
.history .when { color: var(--faint); min-width: 5rem; flex: none; }
.history .who { font-weight: 500; flex: none; }
.history .note { color: var(--graphite); }

/* Dialog */
dialog { border: 0; border-radius: 8px; padding: 1.5rem 1.75rem 1.5rem; width: min(40rem, 92vw); box-shadow: 0 20px 60px rgba(35, 34, 31, 0.25); background: var(--sheet); color: var(--ink); }
dialog::backdrop { background: rgba(35, 34, 31, 0.4); }
dialog h3 { margin-bottom: 1rem; }
dialog.wide { width: min(70rem, 95vw); }
dialog .foot { display: flex; align-items: center; gap: 0.6rem; margin-top: 1.25rem; }

/* Filters */
.chips { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.chip { padding: 0.25rem 0.7rem; border: 1px solid transparent; border-radius: 999px; background: transparent; font-size: 0.875rem; cursor: pointer; color: var(--graphite); }
.chip:hover { color: var(--ink); }
.chip.on { background: var(--sheet); border-color: var(--rule); color: var(--ink); font-weight: 500; }
.chip .n { color: var(--faint); margin-left: 0.3rem; }
.chip.on .n { color: var(--graphite); }

/* Login */
.login { max-width: 21rem; margin: 15vh auto 0; }
.login .mark { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.4rem; }
.login .mark svg { width: 26px; height: 26px; }
.login h1 { font-size: 1.75rem; }
.login .tag { color: var(--graphite); margin-bottom: 2rem; }
.login .btn { width: 100%; justify-content: center; margin-top: 0.4rem; padding: 0.6rem; }
.login .err { margin-top: 0.75rem; }

/* Import preview */
.import-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.import-table th, .import-table td { border-bottom: 1px solid var(--rule-soft); padding: 0.3rem 0.5rem; text-align: left; vertical-align: top; max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-table th { background: var(--sheet); position: sticky; top: 0; border-bottom-color: var(--rule); }
.import-table th select { padding: 2px 4px; font-size: 0.8125rem; width: auto; }
.import-table th .from { font-weight: 400; color: var(--faint); margin-bottom: 0.15rem; }
.import-scroll { max-height: 40vh; overflow: auto; border: 1px solid var(--rule); border-radius: var(--radius); margin: 0.8rem 0 1.25rem; }

/* Theme editor: type as a spec sheet, one line per role */
.editor.theme { grid-template-columns: minmax(22rem, 27rem) minmax(0, 1fr); }
.editor.theme > div { position: sticky; top: 4.25rem; }
@media (max-width: 900px) { .editor.theme > div { position: static; } }
.editor form h2 { margin: 1.75rem 0 0.6rem; }
.editor form h2:first-child { margin-top: 0.35rem; }
.spec-row { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr) 6.5rem 2.25rem; gap: 0.6rem; align-items: center; padding: 0.35rem 0; border-bottom: 1px solid var(--rule); }
.spec-row:last-of-type { border-bottom: 0; }
.spec-role { font-weight: 500; line-height: 1.2; }
.spec-role small { display: block; font-weight: 400; font-size: 0.75rem; color: var(--faint); }
.spec-pt { display: flex; align-items: center; gap: 0.25rem; }
.spec-pt input { text-align: center; padding-left: 0.3rem; padding-right: 0.3rem; }
.spec-pt span { color: var(--faint); }
.spec .hint { margin-top: 0.5rem; }
input[type=color] { width: 100%; height: 2.25rem; padding: 3px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--sheet); cursor: pointer; }
.swatch { width: 2.1rem; height: 2.1rem; padding: 0; border: 1px solid var(--rule); border-radius: var(--radius); cursor: pointer; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6); }
.swatch:hover { border-color: var(--graphite); }
.inks { grid-column: 1 / -1; display: flex; gap: 0.6rem; padding: 0.1rem 0 0.35rem 6.1rem; }
.inks label { display: flex; align-items: center; gap: 0.3rem; font-size: 0.8125rem; color: var(--graphite); }
.inks input { width: 3.6rem; padding: 0.25rem 0.4rem; text-align: right; }
.paper-row { display: flex; align-items: center; gap: 0.6rem; white-space: nowrap; }
.spec-row.paper-inks { border: 0; padding: 0; margin-top: -0.25rem; }
.spec-row.paper-inks .inks { padding-left: 0; }
table.sizes { border-collapse: collapse; width: 100%; }
table.sizes th { text-align: left; font-size: 0.8125rem; color: var(--graphite); font-weight: 500; padding: 0 0.25rem 0.25rem; }
table.sizes td { padding: 0.15rem 0.25rem; }
table.sizes td:nth-child(-n+3) { width: 5.25rem; }
table.sizes td:last-child { width: 2rem; padding-right: 0; }
table.sizes input { padding: 0.3rem 0.5rem; }
.theme-summary { display: flex; align-items: flex-start; gap: 1.75rem; }
.theme-summary dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; font-size: 0.875rem; }
.theme-summary dt { color: var(--graphite); }

/* Receiving: one tick per piece */
.tick { display: inline-flex; width: 1.6rem; height: 1.6rem; align-items: center; justify-content: center; border: 1px solid var(--rule); border-radius: var(--radius); cursor: pointer; background: var(--sheet); }
.tick:hover { border-color: var(--graphite); }
.tick.on { background: var(--ok); border-color: var(--ok); }
.tick input { appearance: none; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.tick.on input::before { content: ""; display: block; width: 0.4rem; height: 0.7rem; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); margin: 0.1rem auto 0; }
table.list tr:has(.tick.on) td { color: var(--graphite); }

/* Order dialog: one group per printer */
.groups { display: flex; flex-direction: column; gap: 0.5rem; }
.group { display: grid; grid-template-columns: 1fr 9rem; gap: 1rem; align-items: center; padding: 0.6rem 0.75rem; border: 1px solid var(--rule); border-radius: var(--radius); }
.checks.pieces { max-height: 40vh; overflow: auto; }
.checks.pieces .mute { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.list .ref small { display: block; font-weight: 400; font-size: 0.75rem; }
table.list .ref .state, table.list td > .state + .state { display: flex; font-weight: 400; margin-top: 0.15rem; }

/* Font library: Google search */
.google-search { display: flex; align-items: center; gap: 1rem; }
.google-search input { max-width: 28rem; }
.gfam { padding: 0.75rem 0 0.5rem; border-top: 1px solid var(--rule-soft); margin-top: 0.75rem; }
.gfam-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.35rem; }
.gfam-head .btn { margin-left: auto; }
.gstyles { display: flex; flex-wrap: wrap; gap: 0 1.25rem; }

/* Font library */
table.fonts .specimen { font-size: 1.25rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 26rem; }
table.fonts .ref small { display: block; font-weight: 400; font-size: 0.75rem; }
table.fonts tr.editing td { background: #faf9f6; }
table.fonts td .btn + .btn { margin-left: 0.25rem; }
label.btn { cursor: pointer; }

/* Toast */
#toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); padding: 0.55rem 1rem; border-radius: var(--radius); background: var(--ink); color: #fff; font-size: 0.9375rem; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,0.2); pointer-events: none; }
#toast.bad { background: var(--bad); }

/* Packet (batch) */
.packet-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, max-content)); gap: 0.35rem 2.5rem; font-size: 0.9375rem; margin-bottom: 1.75rem; }
.packet-meta dt { color: var(--graphite); font-size: 0.8125rem; }
.packet-meta .note { grid-column: 1 / -1; }

@media print {
	.topbar, .noprint { display: none !important; }
	body { background: #fff; }
	main { max-width: none; padding: 0; }
	.card { border: 0; padding: 0; box-shadow: none; }
	.card table.list { margin: 0; width: 100%; }
	table.list td, table.list th { padding: 0.3rem 0.4rem; }
	.thumb { border-color: #ccc; box-shadow: none; }
}

@media (max-width: 640px) {
	main { padding: 1.25rem 1rem 4rem; }
	.topbar { padding: 0 1rem; gap: 0.75rem; }
	.topbar .who span { display: none; }
	.grid2, .grid3, .theme-grid, .editor .meta { grid-template-columns: 1fr; }
	h1 { font-size: 1.4rem; }
	.desk { padding: 1.25rem; }
	.card table.list { display: block; overflow-x: auto; }
}
