:root {
    /* ThriftMetrics brand, sampled from the logo: "Thrift" blue and "Metrics" green. */
    --brand-blue: #00529c;
    --brand-blue-dark: #003f78;
    --brand-green: #78a716;
    --brand-green-dark: #5a7f0f;   /* the green, darkened enough to read as text on white */
    --blue-tint: #e9f1f9;
    --green-tint: #f1f7e4;

    --bg: #f3f5f8;
    --panel: #ffffff;
    --ink: #17212b;
    --muted: #5d6875;
    --line: #dde3ea;
    --accent: var(--brand-blue);
    --ok: var(--brand-green);
    --warn: #b35900;
    --px-per-in: 55px;           /* how big a label inch is drawn in the tray: half size, so a rack of ~100 fits */
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* author display rules (e.g. .notice flex) must not unhide */

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2 { margin: 0; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--brand-blue); margin-bottom: 10px; }
a { color: var(--brand-blue); }
:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 2px; }
input, select { accent-color: var(--brand-blue); }
.muted { color: var(--muted); font-weight: normal; }

/* ---- Header: the logo, the product name, then the page. A thin blue-to-green rule, as in the mark. ---- */
.top {
    position: relative; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 12px 24px 14px; background: var(--panel);
}
.top::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
    background: linear-gradient(90deg, var(--brand-blue), var(--brand-green));
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { display: block; height: 30px; width: auto; }
.brand span {
    padding-left: 12px; border-left: 1px solid var(--line);
    font-size: 14px; font-weight: 600; color: var(--brand-green-dark); white-space: nowrap;
}
.top h1 { font-size: 20px; color: var(--ink); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 600px) { .brand img { height: 24px; } .top { padding: 10px 16px 12px; } }
@media (max-width: 600px) { .top h1 { order: 3; flex-basis: 100%; } .status { margin-left: auto; } }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #c7c3ba; }
.dot.live { background: var(--ok); box-shadow: 0 0 0 4px rgba(120,167,22,.2); }
.dot.down { background: var(--warn); }

/* ---- Layout ---- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; padding: 20px 24px; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; padding: 16px; } }

/* ---- Printer and labels ---- */
.printer {
    position: relative; min-height: 420px; padding: 34px 24px 24px;
    background: linear-gradient(#2b2b2e, #1f1f22); border-radius: 14px; overflow: hidden;
}
.slot {
    position: absolute; left: 24px; right: 24px; top: 14px; height: 8px;
    background: #0d0d0f; border-radius: 4px; box-shadow: inset 0 2px 3px rgba(0,0,0,.6);
}
.tray { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; }
.output-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; font-size: 14px; }
.output-bar button { padding: 5px 12px; }
.output-bar button:disabled { opacity: .5; cursor: default; }
.empty { color: #aeb6c0; text-align: center; margin: 120px 0 0; }

.tag {
    position: relative; flex: none;
    width: calc(var(--w) * var(--px-per-in)); height: calc(var(--h) * var(--px-per-in));
    max-width: 100%;
    background: var(--stock, #fff);
    border-radius: 6px;
    box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 5px 12px rgba(0,0,0,.45);
    cursor: pointer;
}
.tag img { position: relative; width: 100%; height: 100%; object-fit: contain; display: block; }

/* Banded stock: white, with the colour band pre-printed across the top. The label PNG is transparent and sits
   on top, so printed ink lands over the band as it does on a real tag. */
.tag.banded { background: #fff; }
.tag.sticker-stock { border-radius: calc(.09 * var(--px-per-in)); overflow: hidden; }
.tag:not(.sticker-stock) { border-radius: 3px; }
.band {
    position: absolute; left: 0; right: 0; top: 0; height: calc(var(--band) * var(--px-per-in));
    background: var(--stock, #fff); border-bottom: 1px solid rgba(0,0,0,.06);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    border-radius: inherit; border-bottom-left-radius: 0; border-bottom-right-radius: 0;
}
.band-text {
    color: #fff; font: 700 calc(var(--band) * var(--px-per-in) * .52)/1 "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
    white-space: nowrap;
    /* Centre the letters, not the font's line box: fonts differ in the space above and below their glyphs, and
       without this the words sat near the bottom of the band in some browsers. */
    text-box: trim-both cap alphabetic;
}
/* Tags (softlines): the header sits low in the band, so what the printer puts at the top (store, employee) is
   clear above it (HK, 2026-10-25). Stickers keep it centred, with the printed numbers either side. */
.tag:not(.sticker-stock) .band { align-items: flex-end; padding-bottom: calc(var(--px-per-in) * .06); }
/* The pre-printed word keeps its size whatever the band depth; a deeper band only adds room above it. */
.tag:not(.sticker-stock) .band-text.caps { font-size: calc(var(--px-per-in) * .26); }
.band-text.caps { letter-spacing: .08em; font-size: calc(var(--band) * var(--px-per-in) * .46); }
.band-text.dark { color: rgba(0,0,0,.55); }
.tag .err { padding: 10px; color: #8a1c1c; font-size: 13px; }
.tag .badge {
    position: absolute; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: 6px;
    font-size: 11px; background: rgba(0,0,0,.65); color: #fff;
}
.chip {
    display: inline-block; margin-right: 8px; padding: 0 8px; border-radius: 10px; font-size: 12px;
    line-height: 20px; border: 1px solid var(--line); background: #fff; vertical-align: 1px;
}
.hint { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.props {
    display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0;
    padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13px;
}
.props dt { color: var(--muted); }
.props dd { margin: 0; word-break: break-word; }
.tag.new { animation: feed 1s cubic-bezier(.2,.7,.2,1); }
@keyframes feed {
    from { transform: translateY(-110%); clip-path: inset(100% 0 0 0); }
    60%  { clip-path: inset(0 0 0 0); }
    to   { transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) { .tag.new { animation: none; } }

/* ---- Side panel ---- */
.side { display: flex; flex-direction: column; gap: 16px; }
.sticker, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.sticker { text-align: center; }
.sticker img { display: block; margin: 0 auto 8px; }
.sticker .code { font: 600 22px/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .04em; }
.sticker p { color: var(--muted); font-size: 13px; margin: 8px 0; }
.sticker .url { font-size: 12px; color: var(--accent); word-break: break-all; }

.settings label, .panel label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.panel input, .panel select {
    display: block; width: 100%; margin-top: 4px; padding: 7px 9px;
    font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px;
}
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors button {
    width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer;
}
.colors button[aria-checked="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px #fff inset; }

.devices { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.devices li { padding: 6px 0; border-top: 1px solid var(--line); }
.devices li:first-child { border-top: 0; }
.devices small { display: block; color: var(--muted); }

/* ---- Job list ---- */
.jobs { padding: 0 24px 32px; }
@media (max-width: 860px) { .jobs { padding: 0 16px 24px; } }
.jobs ol { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.jobs li {
    display: grid; grid-template-columns: 90px minmax(0, 1fr) auto; gap: 12px; align-items: center;
    padding: 10px 14px; border-top: 1px solid var(--line); cursor: pointer;
}
.jobs li:first-child { border-top: 0; }
.jobs li:hover { background: var(--blue-tint); }
.jobs time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.jobs .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jobs .n { font-size: 13px; color: var(--muted); }
.jobs .bad { color: var(--warn); }

/* ---- Detail dialog ---- */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(900px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.detail-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.detail-head button { border: 0; background: none; font-size: 18px; cursor: pointer; }
.detail-labels { --px-per-in: 110px; display: flex; flex-wrap: wrap; gap: 16px; padding: 16px; background: #2b2b2e; max-height: 45vh; overflow: auto; } /* full size */

/* Barcode text: what each code on the label carries, big enough to read and check at a glance. */
.codes { display: grid; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); max-height: 30vh; overflow: auto; }
.code-row {
    display: grid; grid-template-columns: max-content minmax(0, 1fr) auto; gap: 12px; align-items: center;
    padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.code-row.qr { background: var(--blue-tint); border-color: #c4d8ee; }
.code-type {
    font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-blue);
    padding: 2px 8px; border-radius: 999px; background: #fff; border: 1px solid #c4d8ee; white-space: nowrap;
}
.code-text {
    font: 600 18px/1.3 ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--ink);
    overflow-wrap: anywhere; user-select: all;
}
.code-row button { padding: 4px 12px; font-size: 13px; }
.props dt.site, .props dd.site { color: var(--brand-blue); font-weight: 600; }
@media (max-width: 600px) { .code-row { grid-template-columns: 1fr auto; } .code-text { grid-column: 1 / -1; grid-row: 2; } }
.zpl { margin: 0; padding: 16px; max-height: 260px; overflow: auto; font-size: 12px; background: #f7f9fb; white-space: pre-wrap; word-break: break-all; }

/* ---- Buttons, notices, small bits ---- */
button, .button {
    display: inline-block; font: inherit; font-size: 14px; padding: 7px 14px; border-radius: 8px; cursor: pointer;
    border: 1px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; text-align: center;
}
button:hover, .button:hover { background: var(--blue-tint); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .button.primary:hover { background: var(--brand-blue-dark); border-color: var(--brand-blue-dark); }
button.danger { color: #b42318; border-color: #f1c4bf; margin-top: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }
.row input { flex: 1; min-width: 200px; padding: 8px 10px; font: inherit; border: 1px solid var(--line); border-radius: 8px; }
.small { font-size: 13px; }
.row label.usage { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; color: var(--muted); white-space: nowrap; }
.row label.usage select { padding: 8px 10px; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.error { color: #b42318; font-size: 13px; margin: 8px 0 0; }
.notice {
    margin: 16px 24px 0; padding: 10px 14px; border-radius: 10px; background: var(--blue-tint); border: 1px solid #c4d8ee;
    display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.notice.warn { background: #fff6e5; border-color: #ffe0a3; }
.sticker .code { color: var(--brand-blue); }
.top .back { font-size: 14px; color: var(--accent); text-decoration: none; }
.panel label.check { display: flex; gap: 8px; align-items: flex-start; color: var(--ink); }
.panel label.check input { width: auto; margin-top: 3px; }
.tag img.as-printed { transform: rotate(180deg); }

/* ---- Landing page ---- */
.home-main { max-width: 860px; margin: 0 auto; padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 16px; }
.home-main .notice { margin: 0; }
@media (max-width: 600px) { .home-main { padding: 16px; } }
.printer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.printer-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.printer-card.gone { opacity: .75; border-style: dashed; }
.pc-name { font-weight: 600; font-size: 17px; }
.pc-code { font: 500 14px ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--muted); margin-top: 2px; }
.pc-meta { font-size: 13px; margin-top: 6px; }
.pc-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.pair-body { padding: 20px; text-align: center; }
.pair-body .code { font: 600 22px ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .04em; margin: 8px 0; }
