/* Print Controller. Cool grey workshop, textured-PEI bronze accent.
   The one bold element is the build plate on the dashboard. */
:root {
  color-scheme: light;
  --paper: #eef1f3;
  --surface: #ffffff;
  --sunken: #f5f7f8;
  --ink: #1d2125;
  --muted: #5d6670;
  --line: #d3d9df;
  --accent: #8f6210;
  --accent-fill: #d9a43b;
  --printing: #17705f;
  --attention: #9a5700;
  --failed: #b3261e;
  --done: #2e7d32;
  --focus: #2f6fd6;
  --radius-s: 6px;
  --radius-m: 10px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #15181b;
    --surface: #1e2226;
    --sunken: #191c20;
    --ink: #e6e9ec;
    --muted: #9aa4ae;
    --line: #343a40;
    --accent: #e2b457;
    --accent-fill: #c9962f;
    --printing: #4db6a6;
    --attention: #f0a540;
    --failed: #f2766b;
    --done: #6bbf6e;
    --focus: #7aa7ff;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 var(--font); font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.75rem; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 650; }
.brand svg { flex: none; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: var(--radius-s); }
.nav a:hover { color: var(--ink); background: var(--sunken); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--sunken); box-shadow: inset 0 -2px 0 var(--accent-fill); }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; }
.who form { margin: 0; }
.who-name { color: var(--muted); text-decoration: none; }
.who-name:hover { color: var(--ink); text-decoration: underline; }
.auth-card { max-width: 420px; margin: 6vh auto 0; }
.temp { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 1.6rem; letter-spacing: .04em;
        padding: 12px 16px; background: var(--sunken); border: 1px dashed var(--line); border-radius: var(--radius-s);
        display: inline-block; user-select: all; }

main { padding: 28px 0 64px; }
.banner { padding: 10px 14px; border-radius: var(--radius-s); margin-bottom: 18px; border: 1px solid var(--line); background: var(--surface); }
.banner.warn { border-color: var(--attention); }
.banner.error { border-color: var(--failed); color: var(--failed); }
.banner.ok { border-color: var(--done); }
.flashes.in-section .banner { margin-bottom: 14px; }
section[id] { scroll-margin-top: 16px; }

/* panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 20px; }
.panel + .panel { margin-top: 16px; }
.grid > .panel + .panel { margin-top: 0; }
.panel h2 { margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 16px; }

/* the build plate */
.plate-card { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 24px; align-items: end; }
@media (max-width: 560px) { .plate-card { grid-template-columns: 1fr; } .plate { order: -1; } }
.state-word { font-family: var(--font-display); font-size: clamp(2.3rem, 5.5vw, 3.4rem); font-weight: 700; letter-spacing: -.025em; line-height: 1; margin: 0 0 10px; }
.state-word[data-phase="printing"] { color: var(--printing); }
.state-word[data-phase="paused"] { color: var(--attention); }
.state-word[data-phase="offline"] { color: var(--muted); }
.job-line { font-size: 1.1rem; font-weight: 600; margin-bottom: 2px; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px 18px; margin-top: 18px; }
.fact .k { color: var(--muted); font-size: .8rem; }
.fact .v { font-size: 1.05rem; font-weight: 600; }
.plate {
  --c: var(--accent-fill); --p: 0;
  position: relative; height: 210px; border-radius: 4px;
  border: 2px solid var(--ink); background: var(--sunken); overflow: hidden;
}
.plate::before { /* textured sheet edge */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 10px;
  background: repeating-linear-gradient(90deg, var(--accent-fill) 0 3px, color-mix(in srgb, var(--accent-fill) 70%, var(--ink)) 3px 5px);
}
.plate .layers {
  position: absolute; left: 22%; right: 22%; bottom: 10px;
  height: calc((100% - 22px) * var(--p) / 100);
  background: repeating-linear-gradient(0deg, var(--c) 0 3px, color-mix(in srgb, var(--c) 72%, #000) 3px 4px);
  border-radius: 3px 3px 0 0; transition: height .8s ease; z-index: 1;
}
.plate[data-phase="paused"] .layers { filter: saturate(.35); }
.plate[data-phase="offline"] { border-style: dashed; border-color: var(--muted); }
.plate .pct {
  position: absolute; top: 10px; right: 12px; font-family: var(--font-display);
  font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1;
  z-index: 3; padding: 2px 6px; border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--sunken) 88%, transparent);
}
.plate .nozzle { position: absolute; left: 50%; width: 14px; height: 10px; margin-left: -7px; background: var(--ink); clip-path: polygon(0 0, 100% 0, 70% 100%, 30% 100%); z-index: 2; bottom: calc(10px + (100% - 22px) * var(--p) / 100); transition: bottom .8s ease; }
.plate[data-phase="idle"] .nozzle, .plate[data-phase="offline"] .nozzle { bottom: auto; top: 14px; }
@media (prefers-reduced-motion: reduce) { .plate .layers, .plate .nozzle { transition: none; } }

/* lists of jobs */
.jobs { list-style: none; margin: 0; padding: 0; }
.jobs li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.jobs li:first-child { border-top: 0; }
.jobs .num { color: var(--muted); font-size: .85rem; min-width: 2.6em; }
.jobs .title { font-weight: 600; overflow-wrap: anywhere; }
.jobs .title a { color: inherit; text-decoration: none; }
.jobs .title a:hover { text-decoration: underline; }
.jobs .sub { color: var(--muted); font-size: .875rem; }
.jobs .when { text-align: right; font-size: .875rem; color: var(--muted); white-space: nowrap; }
.jobs .when form { display: inline; margin-left: 6px; }
.jobs.swaps li { grid-template-columns: minmax(0, 1fr) auto; }
.jobs .move { margin-top: 4px; }
.jobs .move button { padding: 2px 9px; min-height: 0; line-height: 1.4; }
.reorderable li.movable { cursor: grab; }
.reorderable li.dragging { opacity: .45; }
.reorderable li.drop-before { box-shadow: inset 0 3px 0 var(--focus); }
.empty { color: var(--muted); padding: 8px 0; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.s-queued { color: var(--muted); }
.s-staged { color: var(--accent); }
.s-printing, .s-paused { color: var(--printing); }
.s-paused { color: var(--attention); }
.s-attention { color: var(--attention); }
.s-done { color: var(--done); }
.s-failed { color: var(--failed); }
.s-cancelled { color: var(--muted); }

.swatches { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.swatch { width: 14px; height: 14px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--ink) 35%, transparent); display: inline-block; vertical-align: middle; }
.trays { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.trays li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); }
.trays li.active { border-color: var(--accent-fill); box-shadow: inset 3px 0 0 var(--accent-fill); }
.trays .swatch { width: 22px; height: 22px; }
.trays li.empty-tray { color: var(--muted); }

.camera { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-s); background: var(--sunken); display: block; }

/* forms and buttons */
label { display: block; font-weight: 600; margin-bottom: 4px; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: .875rem; }
input[type=text], input[type=email], input[type=number], input[type=password], input[type=datetime-local],
input[type=time], input[type=date], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 10px;
}
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 16px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > .field { flex: 1 1 180px; }
button, .button {
  font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-s); border: 1px solid var(--ink);
  background: var(--ink); color: var(--surface); text-decoration: none;
}
button:hover, .button:hover { filter: brightness(1.15); }
button.quiet, .button.quiet { background: transparent; color: var(--ink); border-color: var(--line); }
button.quiet:hover { background: var(--sunken); filter: none; }
button.danger { background: transparent; color: var(--failed); border-color: var(--failed); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 400; text-decoration: underline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

.drop {
  display: block; border: 2px dashed var(--line); border-radius: var(--radius-m); padding: 34px 20px;
  text-align: center; background: var(--sunken); cursor: pointer;
}
.drop.over { border-color: var(--accent-fill); background: color-mix(in srgb, var(--accent-fill) 10%, var(--sunken)); }
.drop input { display: block; margin: 12px auto 0; max-width: 100%; }
.drop strong { font-size: 1.1rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px 8px 0; border-top: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; border-top: 0; }
.scroll { overflow-x: auto; }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0 6px 16px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 13px; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.timeline time { color: var(--muted); font-size: .85rem; margin-right: 8px; }

footer { color: var(--muted); font-size: .8rem; padding: 0 0 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* narrow screens: brand and account on one row, nav scrolls sideways below */
@media (max-width: 760px) {
  .top .wrap { gap: 4px 16px; padding-top: 10px; }
  .brand { order: 1; }
  .who { order: 2; margin-left: auto; }
  .nav { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; margin: 0 -20px; padding: 0 20px 8px;
         scrollbar-width: none; }
  .nav a { white-space: nowrap; }
  .who-name { display: none; }
  main { padding-top: 18px; }
  .panel { padding: 16px; }
  .jobs li { grid-template-columns: minmax(0, 1fr) auto; }
  .jobs .num { display: none; }
}

/* calendar: week grid on wide screens, agenda on phones */
.week { display: grid; grid-template-columns: 44px repeat(7, minmax(0, 1fr)); gap: 0 4px; position: relative; }
.week-hours { position: relative; margin-top: 32px; height: 1152px; }
.week-hours span { position: absolute; right: 6px; transform: translateY(-50%); font-size: .72rem; color: var(--muted); }
.week-head { height: 32px; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-day.today .week-head strong { color: var(--accent); }
.week-body { position: relative; height: 1152px; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: repeating-linear-gradient(180deg, transparent 0 47px, color-mix(in srgb, var(--line) 55%, transparent) 47px 48px); }
.week-day.off .week-body { background-color: color-mix(in srgb, var(--sunken) 70%, var(--line)); }
.office { position: absolute; left: 0; right: 0; background: color-mix(in srgb, var(--accent-fill) 10%, transparent); pointer-events: none; }
.slot { position: absolute; left: 0; right: 0; height: calc(100% / 24); }
.slot:hover { background: color-mix(in srgb, var(--focus) 12%, transparent); }
.closure { display: block; font-size: .72rem; color: var(--attention); font-weight: 600; }
.blk { position: absolute; left: 3px; right: 3px; border-radius: 4px; padding: 2px 5px; overflow: hidden; font-size: .75rem;
  line-height: 1.25; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--accent-fill); z-index: 1; min-height: 18px; }
.blk:hover { z-index: 2; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.blk-t { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk-s { display: block; color: var(--muted); }
.blk-overnight { border-left-color: #5b5fc7; background: color-mix(in srgb, #5b5fc7 12%, var(--surface)); }
.blk-attended { background: color-mix(in srgb, var(--printing) 7%, var(--surface)); }
.blk-attended { border-left-color: var(--printing); }
.blk-running { border-left-color: var(--printing); background: color-mix(in srgb, var(--printing) 12%, var(--surface)); }
.blk-estimate { border-style: dashed; border-left-style: solid; border-left-color: var(--muted); opacity: .85; }
.now { position: absolute; left: -2px; right: -2px; border-top: 2px solid var(--failed); z-index: 3; pointer-events: none; }
.agenda { display: none; }
.agenda-day h3 { margin: 14px 0 4px; }
.agenda-day.today h3 { color: var(--accent); }
.legend { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; background: var(--accent-fill); }
.legend-overnight { background: #5b5fc7; }
.legend-attended, .legend-running { background: var(--printing); }
.legend-estimate { background: transparent; border: 1px dashed var(--muted); }
.legend-office { background: color-mix(in srgb, var(--accent-fill) 25%, transparent); }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 12px 0 0; }
.legend-row > span { display: inline-flex; gap: 6px; align-items: center; }
fieldset.choice { border: 0; padding: 0; margin: 0 0 16px; }
fieldset.choice legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
fieldset.choice .check { align-items: flex-start; margin-bottom: 8px; }
fieldset.choice .check input { margin-top: 4px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.seg a { padding: 6px 12px; color: var(--ink); text-decoration: none; font-size: .9rem; }
.seg a + a { border-left: 1px solid var(--line); }
.seg a[aria-current] { background: var(--accent-fill); color: #fff; font-weight: 600; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.month-dow { font-size: .8rem; font-weight: 600; color: var(--muted); padding: 0 4px; }
.month-cell { min-height: 108px; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 4px;
  display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.month-cell.off { background: color-mix(in srgb, var(--sunken) 70%, var(--line)); }
.month-cell.out { opacity: .55; }
.month-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.month-head { display: flex; justify-content: space-between; align-items: baseline; }
.month-day { font-weight: 600; color: var(--ink); text-decoration: none; font-size: .85rem; }
.month-cell.today .month-day { color: var(--accent); }
.month-book { text-decoration: none; }
.chip { position: static; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 0;
  font-size: .72rem; padding: 1px 4px; border-radius: 4px; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent-fill); }
.chip.blk-overnight { border-left-color: #5b5fc7; background: color-mix(in srgb, #5b5fc7 12%, var(--surface)); }
.chip.blk-attended { border-left-color: var(--printing); background: color-mix(in srgb, var(--printing) 7%, var(--surface)); }
.chip.blk-running { border-left-color: var(--printing); background: color-mix(in srgb, var(--printing) 12%, var(--surface)); }
.chip.blk-estimate { border-style: dashed; border-left-style: solid; border-left-color: var(--muted); opacity: .85; }
.chip-s { color: var(--muted); }
.chip-more { color: var(--muted); }
@media (max-width: 860px) {
  .week, .month { display: none; }
  .agenda { display: block; }
  .agenda .jobs li { grid-template-columns: auto minmax(0, 1fr) auto; }
}
.week { max-height: 680px; overflow-y: auto; }
.week-head { position: sticky; top: 0; background: var(--surface); z-index: 4; padding-top: 4px; }
.week-hours { position: sticky; left: 0; }
.print-controls { margin-top: 14px; display: grid; gap: 10px; }
.print-controls select { width: auto; }
.stop-print summary { cursor: pointer; color: var(--failed); }
.stop-print form { margin-top: 10px; }
.map-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.map-table th, .map-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
