/* Printer Status: dark theme matching the PCM Lending Library (OMS) interface. */
:root {
  --accent: #e0244a;
  --accent-2: #881124;
  --accent-soft: rgba(224, 36, 74, .14);
  --accent-text: #ff7a93;
  --bg: #0a0b0f;
  --surface: #13151b;
  --surface-2: #1a1d25;
  --surface-3: #222631;
  --glass: rgba(19, 21, 27, .72);
  --text: #e9eaf0;
  --muted: #8b90a0;
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .14);
  --good: #4ade80;
  --good-bg: rgba(74, 222, 128, .12);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, .12);
  --bad: #f87171;
  --bad-bg: rgba(248, 113, 113, .12);
  --info: #7cb4ff;
  --info-bg: rgba(124, 180, 255, .1);
  --focus: rgba(224, 36, 74, .55);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 10px 30px -12px rgba(0, 0, 0, .6);
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--text);
  display: flex; flex-direction: column;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(136, 17, 36, .28), transparent 60%),
    radial-gradient(900px 500px at 110% 0%, rgba(30, 58, 95, .25), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  font: .9375rem/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { font-family: "Familjen Grotesk", Inter, sans-serif; line-height: 1.2; margin: 0 0 .6em; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; }
.mono, .tag { font-family: "Space Mono", ui-monospace, monospace; font-size: .86em; }
:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); border-radius: 6px; }
::selection { background: rgba(224, 36, 74, .4); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }

/* ---------- layout ---------- */
.container { flex: 1 0 auto; width: 100%; max-width: 82.5rem; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.4rem; }
.page-head h1 { margin: 0; }
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, .025), transparent 40%), var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.3rem 1.4rem; box-shadow: var(--shadow);
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; flex-wrap: wrap;
  background: var(--glass); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border); padding: .6rem 1.25rem;
}
.topbar p { margin: 0; }
.brand { font-family: "Familjen Grotesk", sans-serif; font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: .55rem; white-space: nowrap; }
.brand-logo { width: 1.375rem; height: auto; display: block; filter: drop-shadow(0 2px 8px rgba(224, 36, 74, .45)); }
#last-updated.stale { color: var(--bad); font-weight: 600; }
/* ---------- notices ---------- */
.flash { padding: .7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1.4rem; border: 1px solid transparent; font-size: .92rem; }
.flash-warning { background: var(--warn-bg); color: var(--warn); border-color: rgba(251, 191, 36, .25); }

/* ---------- view toggle ---------- */
.seg { display: inline-flex; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 3px; gap: 2px; }
.seg-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 .55rem 0 .5rem; }
.seg button {
  display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .7rem; border: 0; border-radius: 99px;
  background: none; color: var(--muted); font: inherit; font-size: .84rem; font-weight: 500; cursor: pointer;
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text); background: var(--surface-2); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-text); }
.seg svg { width: .875rem; height: .875rem; fill: currentColor; }

/* ---------- badges / tags ---------- */
.badge { display: inline-block; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: .16rem .5rem; border-radius: 99px; vertical-align: middle; border: 1px solid transparent; white-space: nowrap; }
.badge-green { background: var(--good-bg); color: var(--good); border-color: rgba(74, 222, 128, .2); }
.badge-red { background: var(--bad-bg); color: var(--bad); border-color: rgba(248, 113, 113, .2); }
.badge-amber { background: var(--warn-bg); color: var(--warn); border-color: rgba(251, 191, 36, .2); }
.badge-blue { background: var(--info-bg); color: var(--info); border-color: rgba(124, 180, 255, .2); }
.badge-grey { background: var(--surface-3); color: var(--muted); }
.tag { background: var(--bg); border: 1px solid var(--border-strong); padding: .06rem .4rem; border-radius: 5px; white-space: nowrap; color: #c9ccd6; font-size: .74rem; }
.count { display: inline-block; background: var(--surface-3); color: var(--muted); font-family: Inter, sans-serif; font-size: .72rem; font-weight: 600; padding: .02rem .5rem; border-radius: 99px; vertical-align: middle; margin-left: .4rem; }

/* ---------- printer groups ---------- */
.make { margin-bottom: 1.8rem; }
.make h2 { display: flex; align-items: center; }

/* shared printer bits */
.p-name { font-weight: 600; }
.line, .pcard { position: relative; }
.p-link { color: inherit; text-decoration: none; }
.p-link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.line:hover .p-link, .pcard:hover .p-link { color: var(--accent-text); }
.pcard:hover { border-color: var(--border-strong); }.line-id, .pcard-id { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.p-file { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; min-width: 0; }
.p-left { font-size: .86rem; white-space: nowrap; }
.p-time { display: flex; flex-direction: column; line-height: 1.3; white-space: nowrap; }
.p-time-main { font-size: .86rem; }
.p-time-sub { font-size: .76rem; color: var(--muted); }
.p-pct { font-size: .8rem; color: var(--muted); min-width: 3.4rem; text-align: right; }
.progress { flex: 1; height: .5rem; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #166534, var(--good)); border-radius: 99px; transition: width .4s var(--ease); }
.state-paused .progress-fill { background: var(--warn); }
.state-error .progress-fill { background: var(--bad); }

/* lines view: rows share one grid template so columns line up */
.lines {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.line {
  display: grid; align-items: center; column-gap: 1rem;
  grid-template-columns: minmax(10.625rem, 1.2fr) 5.75rem minmax(0, 2fr) minmax(9.375rem, 1.4fr) 11rem 15rem;
  padding: .6rem 1rem; border-bottom: 1px solid var(--border); transition: background .12s;
}
.line > *, .pcard > * { min-width: 0; }
.line:last-child { border-bottom: 0; }
.line:hover { background: rgba(255, 255, 255, .025); }
.line-progress { display: flex; align-items: center; gap: .6rem; }
.line-temps { text-align: right; white-space: nowrap; }
.line.state-printing { box-shadow: inset 3px 0 0 var(--good); }
.line.state-paused { box-shadow: inset 3px 0 0 var(--warn); }
.line.state-error { box-shadow: inset 3px 0 0 var(--bad); background: rgba(248, 113, 113, .05); }
.line.state-offline > * { opacity: .5; }

/* Narrower than one row needs (e.g. a portrait kiosk scaled up by app.js's
   fit): two rows per printer, status on top and the job underneath. */
.lines { container-type: inline-size; }
@container (max-width: 60rem) {
  .line {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 11rem; row-gap: .3rem;
    grid-template-areas: "id temps state" "job progress left";
  }
  .line-id { grid-area: id; }
  .line-temps { grid-area: temps; }
  .line-state { grid-area: state; justify-self: end; }
  .line-job { grid-area: job; }
  .line-progress { grid-area: progress; }
  .line-left { grid-area: left; text-align: right; }
  .line-left .p-time { align-items: flex-end; }
}
@container (max-width: 36rem) {
  .line { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: none; row-gap: .35rem; }
  .line > * { grid-area: auto; }
  .line-state { justify-self: end; }
  .line-job { grid-column: 1 / -1; }
  .line-progress { grid-column: 1 / -1; }
  .line-progress:empty, .line-left:empty, .line-temps:empty { display: none; }
  .line-temps { grid-column: 2; text-align: right; }
}

/* cards view */
.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17.5rem), 1fr)); gap: .9rem; }
.pcard {
  display: flex; flex-direction: column; gap: .55rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, .025), transparent 40%), var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.15rem; box-shadow: var(--shadow);
  border-top: 3px solid var(--surface-3);
}
.pcard-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.pcard-progress { display: flex; align-items: center; gap: .6rem; }
.pcard-foot { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; margin-top: auto; }
.pcard.state-printing { border-top-color: var(--good); }
.pcard.state-paused { border-top-color: var(--warn); }
.pcard.state-error { border-top-color: var(--bad); }
.pcard.state-offline { opacity: .55; }

/* ---------- detail page (printer.php) ---------- */
.back-link { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); text-decoration: none; font-size: .88rem; margin-bottom: 1.2rem; }
.back-link:hover { color: var(--text); }
.back-link svg { width: .85rem; height: .85rem; fill: currentColor; }
.flash-error { background: var(--bad-bg); color: var(--bad); border-color: rgba(248, 113, 113, .25); overflow-wrap: anywhere; white-space: pre-line; }
.detail { display: grid; grid-template-columns: minmax(0, 22rem) minmax(0, 1fr); gap: 1.75rem; align-items: start; margin-bottom: 1.25rem; }
.detail-photo {
  /* product shots come on white, so give them a white plate instead of fighting the dark theme */
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.detail-photo img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.detail-photo-empty { background: var(--surface); border: 1px dashed var(--border-strong); color: var(--muted); font-family: "Familjen Grotesk", sans-serif; font-size: 1.2rem; }
.detail.state-offline .detail-photo img { filter: grayscale(1); opacity: .6; }
/* slicer previews are rendered on transparent or dark backgrounds, so keep them on the dark theme */
.detail-photo-model { position: relative; margin: 0; background: radial-gradient(circle at 50% 40%, var(--surface-3), var(--surface) 75%); border: 1px solid var(--border); }
.detail-photo-model figcaption {
  position: absolute; top: .75rem; left: .75rem;
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: .16rem .5rem; border-radius: 99px; background: var(--good-bg); color: var(--good); border: 1px solid rgba(74, 222, 128, .2);
}
.detail.state-paused .detail-photo-model figcaption { background: var(--warn-bg); color: var(--warn); border-color: rgba(251, 191, 36, .2); }
.detail-main { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.detail-head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.detail-head h1 { margin: 0; font-size: 2.3rem; }
.detail-head .badge { font-size: .78rem; padding: .22rem .65rem; }
.detail-sub { margin: -.6rem 0 0; display: flex; align-items: center; gap: .5rem; }
.detail-main .flash { margin: 0; }
.detail-card h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .8rem; }
.detail-file { margin: 0 0 .8rem; font-size: 1.05rem; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .75rem; margin-top: .9rem; }
.detail-card h2 + .stats { margin-top: 0; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .7rem .9rem; display: flex; flex-direction: column; gap: .15rem; }
.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat-value { font-family: "Familjen Grotesk", sans-serif; font-size: 1.45rem; font-weight: 700; display: flex; flex-direction: column; }
.stat-sub { font-family: Inter, sans-serif; font-size: .8rem; font-weight: 500; color: var(--muted); }
.detail-tabs { margin-bottom: 1rem; }
.history { list-style: none; margin: 0; padding: 0; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .65rem 0; border-bottom: 1px solid var(--border); }
.history-item:first-child { padding-top: 0; }
.history-item:last-child { border-bottom: 0; padding-bottom: 0; }
.history-main { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.history-file { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.raw { width: 100%; border-collapse: collapse; font-size: .9rem; }
.raw th, .raw td { text-align: left; vertical-align: top; padding: .5rem .25rem; border-bottom: 1px solid var(--border); }
.raw tr:last-child th, .raw tr:last-child td { border-bottom: 0; }
.raw th { font-weight: 500; width: 40%; padding-right: 1rem; }
.raw th .mono { display: block; font-size: .72rem; font-weight: 400; }
.raw td { overflow-wrap: anywhere; }
.raw code { font-family: "Space Mono", ui-monospace, monospace; font-size: .8rem; }
@media (max-width: 760px) {
  .detail { grid-template-columns: minmax(0, 1fr); }
  .detail-photo { max-width: 20rem; width: 100%; margin: 0 auto; }
  .detail-head h1 { font-size: 1.8rem; }
}

.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.seg button .count { margin-left: 0; }
@media (max-width: 700px) { .seg button span:not(.count), .seg-label { display: none; } }

/* ---------- footer ---------- */
.site-footer { display: flex; justify-content: center; padding: 0 1.25rem 2.5rem; margin-top: -1.5rem; }
.site-footer img { width: min(18.75rem, 70vw); height: auto; opacity: .22; transition: opacity .2s; }
.site-footer img:hover { opacity: .5; }
