/* Roll nester -- the app's own looks, on top of Tabler (static/vendor/tabler).
 *
 * Tabler (Bootstrap 5) does the page: header, cards, buttons, forms, tables,
 * badges, alerts, tabs, steps. This file keeps what is the app's own: the
 * drop zone, the drawing and the roll viewers (SVG), the selection bar,
 * chips and swatches, the figures, the history list, the printed cutting
 * plan. Colours come from Tabler's variables where there is one, so a theme
 * change carries through.
 */

:root {
  --rn-ok: var(--tblr-green, #2fb344);
  --rn-bad: var(--tblr-red, #d63939);
  --rn-warn: #d98324;
  --rn-ink: var(--tblr-body-color, #1d273b);
  --rn-muted: var(--tblr-secondary, #667382);
  --rn-line: var(--tblr-border-color, #dce1e7);
  --rn-accent: var(--tblr-primary, #066fd1);
  --rn-roll: #fbfbfb;
  --rn-soft: var(--tblr-bg-surface-secondary, #f6f8fb);
}

/* `hidden` must win over every display rule (Bootstrap's does too) */
[hidden] { display: none !important; }

.min-w-0 { min-width: 0; }

/* ---- icons: <svg class="ti"><use href="/static/vendor/tabler-icons.svg#ti-NAME"/></svg> ---- */

.ti {
  width: 1.25em; height: 1.25em; flex: none;
  vertical-align: -0.25em;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
.btn .ti { width: 1.15rem; height: 1.15rem; vertical-align: -0.2rem; }
.btn-sm .ti { width: 1rem; height: 1rem; }
.btn-icon .ti { margin: 0; }

/* ---- the header -------------------------------------------------------------- */

.app-navbar { position: sticky; top: 0; z-index: 1020; }
.app-navbar .container-xl { gap: .5rem 1rem; flex-wrap: wrap; }
.brand-btn {
  display: inline-flex; align-items: center; gap: .6rem;
  border: 0; background: none; padding: 0; color: inherit; font-weight: 700; font-size: 1.05rem;
}
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: .6rem;
  background: var(--rn-ink); color: #fff;
}
.brand-mark .ti { width: 1.2rem; height: 1.2rem; }
.brand-mark-lg { width: 3rem; height: 3rem; border-radius: .9rem; }
.brand-mark-lg .ti { width: 1.75rem; height: 1.75rem; }
.app-views { gap: .25rem; }
.app-views .nav-link {
  display: inline-flex; align-items: center; gap: .4rem;
  border: 0; background: none; border-radius: var(--tblr-border-radius);
  padding: .45rem .75rem; color: var(--rn-muted); font-weight: 500;
}
.app-views .nav-link:hover { color: var(--rn-ink); background: var(--rn-soft); }
.app-views .nav-link.active { color: var(--rn-accent); background: var(--tblr-primary-lt, #e7f1fc); }
.app-tools .lang select { width: auto; }
.user-toggle { border: 0; background: none; }
#user-avatar { background: var(--rn-ink); color: #fff; font-weight: 600; font-size: .75rem; }

/* whether what happens here is saved: the database pill */
.db-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--rn-soft); color: var(--rn-muted); border: 1px solid var(--rn-line);
  font-weight: 500; white-space: nowrap;
}
.db-pill::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: #b0b5bb; }
.db-pill[data-state=on]::before { background: var(--rn-ok); }
.db-pill[data-state=down], .db-pill[data-state=server] { color: var(--rn-bad); border-color: #efc4be; }
.db-pill[data-state=down]::before, .db-pill[data-state=server]::before { background: var(--rn-bad); }

@media (max-width: 767.98px) {
  .app-views .nav-text, .brand-name { display: none; }
}

/* ---- the steps: 1 drawing, 2 settings, 3 the nest --------------------------- */

.work-bar { display: flex; align-items: center; gap: .5rem 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.work-steps { margin: 0 auto; max-width: 960px; flex: 1 1 360px; }

/* the steps as buttons: a tick on the done ones, the current one filled, a
   locked one pale -- its tooltip says what it waits for */
.stepper { display: flex; align-items: center; gap: .5rem; }
.stepper-line { flex: 1 1 1.5rem; min-width: .75rem; height: 2px; background: var(--rn-line); }
.stepper-item {
  display: flex; align-items: center; gap: .6rem; min-width: 0; max-width: 19rem; padding: .45rem .8rem .45rem .5rem;
  border: 1px solid var(--rn-line); border-radius: 999px; background: var(--tblr-bg-surface, #fff);
  color: var(--rn-ink); font: inherit; text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.stepper-item:hover:not(.locked):not(.current) { border-color: var(--rn-accent); box-shadow: 0 0 0 3px var(--tblr-primary-lt, #e7f1fc); }
.stepper-dot {
  width: 1.75rem; height: 1.75rem; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--rn-line); background: #fff; color: var(--rn-muted); font-weight: 700; font-size: .8125rem;
}
.stepper-dot .tick { display: none; width: 1rem; height: 1rem; stroke-width: 2.6; }
.stepper-text { display: flex; flex-direction: column; min-width: 0; }
.stepper-title { font-weight: 600; line-height: 1.2; }
.stepper-sub { font-size: .75rem; color: var(--rn-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stepper-item.current { border-color: var(--rn-accent); background: var(--tblr-primary-lt, #e7f1fc); cursor: default; }
.stepper-item.current .stepper-dot { background: var(--rn-accent); border-color: var(--rn-accent); color: #fff; }
.stepper-item.done .stepper-dot { background: var(--rn-ok); border-color: var(--rn-ok); color: #fff; }
.stepper-item.done .num { display: none; }
.stepper-item.done .tick { display: block; }
.stepper-item.open .stepper-dot { border-color: var(--rn-accent); color: var(--rn-accent); }
.stepper-item.locked { background: var(--rn-soft); cursor: not-allowed; }
.stepper-item.locked .stepper-title, .stepper-item.locked .stepper-dot { opacity: .55; }
@media (max-width: 767.98px) {
  .stepper-sub { display: none; }
  .stepper-item { padding: .35rem .5rem; }
}
.materials-table input[data-f=name] { min-width: 12rem; }

/* ---- home: the drop zone ---------------------------------------------------- */

.dropzone-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem;
  min-height: 240px; padding: 2rem 1.25rem; text-align: center; cursor: pointer;
  border: 2px dashed var(--rn-line); border-radius: var(--tblr-border-radius-lg, 8px);
  background: var(--rn-soft); transition: border-color .15s, background .15s;
}
.dropzone-box:hover, .dropzone-box.dragging { border-color: var(--rn-accent); background: var(--tblr-primary-lt, #e7f1fc); }
.dropzone-box:focus-within { outline: 2px solid var(--rn-accent); outline-offset: 2px; }
.dropzone-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 3.5rem; height: 3.5rem; border-radius: 1rem;
  background: var(--tblr-primary-lt, #e7f1fc); color: var(--rn-accent);
}
.dropzone-icon .ti { width: 2rem; height: 2rem; }
.dropzone-title { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.dropzone-text { max-width: 34rem; }

/* ---- step 2: the settings column and the selection bar ---------------------- */

/* the whole width of the screen: a drawing and a roll are wide things. The
   settings (step 2) and the part and files (step 3) keep a fixed width at
   the side; the drawing and the roll take everything else */
.app-wide { padding-left: 1.5rem; padding-right: 1.5rem; }
@media (max-width: 575.98px) {
  .app-wide { padding-left: 1rem; padding-right: 1rem; }
}
.drawing-col, .roll-pane { min-width: 0; }
@media (min-width: 1200px) {
  .settings-col { width: 380px; position: sticky; top: 5rem; }
  .side { width: 340px; }
}
.form-selectgroup.two-up .form-selectgroup-item { flex: 1 1 0; }
#method-sparrow.unavailable { opacity: .5; }
#method-sparrow.unavailable .form-selectgroup-label { cursor: not-allowed; }
details.advanced { border-top: 1px solid var(--rn-line); padding-top: .75rem; }
details.advanced summary {
  display: flex; flex-direction: column; cursor: pointer; list-style: none;
  padding-right: 1.5rem; position: relative;
}
details.advanced summary::-webkit-details-marker { display: none; }
details.advanced summary::after {
  content: ""; position: absolute; right: .25rem; top: .35rem;
  width: .5rem; height: .5rem; border-right: 2px solid var(--rn-muted); border-bottom: 2px solid var(--rn-muted);
  transform: rotate(45deg); transition: transform .15s;
}
details.advanced[open] summary::after { transform: rotate(-135deg); top: .6rem; }

.sel-bar { background: var(--rn-soft); }

/* ---- the selected pieces (#pick-card): what they are cut from and how ---- */

/* one card beside the drawing, two tabs: the cutting settings, the selected pieces */
.side-tabs .nav-link { display: inline-flex; align-items: center; font-weight: 500; }
.side-tabs .nav-link:disabled { opacity: .5; }
.side-tabs .nav-link.active { font-weight: 600; }
.pick-count {
  min-width: 2rem; height: 2rem; padding: 0 .5rem; border-radius: .5rem; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--rn-accent); color: #fff; font-weight: 700;
}
.pick-body fieldset { border: 0; margin: 0; padding: 0; }
.pick-mats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .375rem; }
.pick-mats button {
  display: flex; align-items: center; gap: .5rem; min-height: 2.4rem; padding: 0 .6rem;
  border: 1px solid var(--rn-line); border-radius: var(--tblr-border-radius); background: var(--tblr-bg-surface, #fff);
  color: var(--rn-ink); font: inherit; text-align: left; overflow: hidden;
}
.pick-mats button .swatch { margin: 0; width: 1rem; height: 1rem; }
.pick-mats button.none { border-style: dashed; color: var(--rn-muted); }
.pick-mats button:hover { border-color: var(--rn-accent); }
.pick-mats button[aria-pressed=true] { border: 2px solid var(--rn-accent); background: var(--tblr-primary-lt, #e7f1fc); font-weight: 600; }
/* a segmented choice: the value the whole selection has is pressed */
.pick-seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; padding: 3px; background: #eef1f5; border-radius: var(--tblr-border-radius); }
.pick-seg-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
#pick-rot { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }  /* "as the settings allow (0 / 90 / 180 / 270°)" is the long one */
.pick-seg > button, .pick-seg-input {
  min-height: 2.1rem; border: 0; border-radius: calc(var(--tblr-border-radius) - 2px);
  background: transparent; color: var(--rn-muted); font: inherit; padding: 0 .4rem;
}
.pick-seg > button[aria-pressed=true], .pick-seg-input.on {
  background: var(--tblr-bg-surface, #fff); color: var(--rn-ink); font-weight: 600; box-shadow: 0 1px 2px rgba(24, 36, 51, .15);
}
.pick-seg-input { display: flex; align-items: center; gap: 2px; }
.pick-seg-input input { width: 100%; min-width: 0; border: 0; background: transparent; font: inherit; text-align: right; color: var(--rn-ink); }
.pick-seg-input input:focus { outline: none; }
.pick-seg-input:focus-within { background: var(--tblr-bg-surface, #fff); box-shadow: 0 0 0 2px var(--rn-accent); }
.pick-mixed:not(:empty) {
  display: inline-block; margin-top: .375rem; padding: 1px 8px; border-radius: 10px;
  background: var(--tblr-yellow-lt, #fdf3d8); color: #6b5310; font-size: .75rem;
}
.pick-nest .form-check-input { margin-top: .3rem; }


/* the legend under the drawing: materials, then what is special */
.drawing-legend { display: flex; flex-wrap: wrap; gap: .75rem 1.75rem; align-items: flex-start; padding: .75rem 1rem; border-top: 1px solid var(--rn-line); }
.drawing-legend:empty { display: none; }
.legend-group { display: flex; flex-direction: column; gap: .375rem; }
.legend-title { font-size: .6875rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--rn-muted); }
.legend-hint { margin-left: auto; align-self: center; font-size: .75rem; color: var(--rn-muted); }

.drawing-stage { position: relative; }
.drawing-tools { position: absolute; right: .75rem; top: .75rem; }
.drawing-tools .btn { background: var(--tblr-bg-surface, #fff); }

/* ---- chips and swatches ------------------------------------------------------- */

.chips { display: flex; flex-wrap: wrap; gap: .375rem; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .2rem .65rem; border: 1px solid var(--rn-line); border-radius: 999px;
  background: var(--tblr-bg-surface, #fff); color: var(--rn-ink); font: inherit; font-size: .8125rem; cursor: pointer;
}
.chip:hover { border-color: var(--rn-accent); }
.chip .count { color: var(--rn-muted); }
.swatch {
  display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; flex: none;
  border: 1px solid rgba(0, 0, 0, .25); vertical-align: -2px; margin-right: .375rem;
}
.chip .swatch { margin-right: 0; }
.swatch.none { background: repeating-linear-gradient(45deg, #fff 0 3px, #d7dade 3px 6px); }
.swatch.hatch { background: repeating-linear-gradient(45deg, var(--rn-ink) 0 1.5px, #fff 1.5px 4px); }
.swatch.out { background: #fff; border-style: dashed; }
/* "don't rotate": an arrow, this way up -- on the chip and over each such piece */
.swatch.fixed { background: #fff; color: var(--rn-ink); font-size: 10px; line-height: 10px; font-weight: 700; text-align: center; }

/* ---- projects: more drawings nested together with the first ------------------- */

.projects-bar .chips { margin: 0; }
.project-chip { padding: 0; gap: 0; overflow: hidden; cursor: default; }
.project-chip button { background: transparent; color: inherit; font: inherit; border: 0; border-radius: 0; cursor: pointer; }
.project-chip .chip-main { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px 4px 10px; font-weight: 500; }
.project-chip .chip-drop { padding: 4px 9px 4px 6px; color: var(--rn-muted); font-size: 14px; line-height: 1; }
.project-chip .chip-drop:hover { color: var(--rn-bad); }
/* "?" beside a part of the page: the guide, opened at its chapter */
.help-link { display: inline-flex; align-items: center; color: var(--rn-muted); text-decoration: none; }
.help-link:hover { color: var(--rn-accent); }
.side-tabs-head { display: flex; align-items: center; }

/* a merged drawing's own number of sets, inside its chip */
.project-chip .chip-sets { display: inline-flex; align-items: center; gap: 3px; margin: 0; padding: 2px 6px;
  border-left: 1px solid var(--rn-line); color: var(--rn-muted); font-size: .75rem; cursor: default; }
.project-chip .chip-sets input { width: 3.2em; padding: 0 2px; border: 1px solid var(--rn-line); border-radius: 4px;
  font: inherit; color: var(--rn-ink); text-align: right; background: transparent; }

/* "Repeat this layout": a native dialog dressed as a Tabler modal */
.rn-dialog { padding: 0; border: 0; border-radius: var(--tblr-border-radius-lg, 8px); width: min(420px, calc(100vw - 32px));
  box-shadow: 0 16px 48px rgba(0, 0, 0, .25); }
.rn-dialog::backdrop { background: rgba(24, 36, 51, .45); }
.rn-dialog .modal-content { border: 0; }
.rn-dialog .modal-header { padding: 1rem 1.25rem; }
.rn-dialog .modal-body { padding: 1rem 1.25rem; }
.rn-dialog .modal-footer { display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 1.25rem;
  border-top: 1px solid var(--rn-line); }
.project-tag { display: inline-flex; align-items: center; font-weight: 600; white-space: nowrap; }
#import-more .import-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .5rem; font-size: .8125rem; }
#import-more .import-bar select { width: auto; }
#import-more .warn { margin: .5rem 0 0; padding: .5rem .75rem; border-radius: var(--tblr-border-radius); background: var(--tblr-warning-lt, #fdf3d8); }
#import-note .assumed { color: #8a6d1a; font-weight: 600; }
.project-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin: .5rem 0 0; font-size: .8125rem; }
.legend-item { display: inline-flex; align-items: center; white-space: nowrap; }
.legend-item .muted { margin-left: 5px; }
.muted { color: var(--rn-muted); }

/* ---- the drawing preview ------------------------------------------------------ */

.viewer { overflow: auto; max-height: 80vh; background: var(--rn-soft); padding: .5rem; }
.viewer svg { display: block; }
.viewer.drawing {
  overflow: hidden; padding: .5rem; min-height: 320px;
  background-color: #fafbfc;
  background-image: linear-gradient(#eef0f3 1px, transparent 1px), linear-gradient(90deg, #eef0f3 1px, transparent 1px);
  background-size: 32px 32px;
}
.viewer.drawing svg { display: block; margin: 0 auto; cursor: grab; touch-action: none; }
.viewer.drawing.panning svg { cursor: grabbing; }
.viewer.drawing.picking svg { cursor: crosshair; }
.viewer.drawing .piece { stroke: none; fill-opacity: .55; cursor: pointer; }
.viewer.drawing .piece.untagged { fill-opacity: .35; }
.viewer.drawing .piece.sel { fill-opacity: 1; stroke: var(--rn-accent); stroke-width: 2; }
.viewer.drawing .piece.linked { fill-opacity: 1; stroke: var(--rn-ink); stroke-width: 3; stroke-dasharray: 6 4; }
.viewer.drawing .piece.spaced { stroke: var(--rn-ink); stroke-width: 1.5; stroke-dasharray: 5 3; }
/* left out: nested nowhere -- faint and dashed */
.viewer.drawing .piece.left-out { fill-opacity: .08; stroke: var(--rn-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.viewer.drawing .piece.left-out.sel { fill-opacity: .3; stroke: var(--rn-accent); }
/* cut from the backside: hatched over the piece's colour; clicks go to the piece */
.viewer.drawing .back-mark { pointer-events: none; stroke: none; }
.viewer.drawing .hatch-line { stroke: var(--rn-ink); stroke-opacity: .6; }
.viewer.drawing .fix-mark { fill: none; stroke: var(--rn-ink); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
#marquee { fill: rgba(6, 111, 209, .12); stroke: var(--rn-accent); stroke-width: 1; stroke-dasharray: 4 3; }
#marquee[hidden] { display: none; }
.viewer.drawing .layer-CUT { stroke: #1d2129; stroke-width: 1; }
.viewer.drawing .layer-PEN { stroke: #1f6feb; stroke-width: 1; }
.viewer.drawing .layer-DRILL { stroke: #c0392b; stroke-width: 1; }
.viewer.drawing .layer-other { stroke: #9aa0a6; stroke-width: 1; stroke-dasharray: 6 4; }
/* a DRILL point is a dot of fixed screen size: its non-scaling stroke, not its radius */
.viewer.drawing .point { stroke-width: 6px; fill: none; stroke-linecap: round; }
/* each project in the drawing: a frame in its colour and its name above it */
.viewer.drawing .project-frame { fill: none; stroke-width: 1.5; stroke-dasharray: 10 6; pointer-events: none; }
.viewer.drawing .project-name { font-weight: 700; pointer-events: none; }
.region-box { fill: rgba(47, 179, 68, .08); stroke: var(--rn-ok); stroke-width: 2; stroke-dasharray: 8 4; pointer-events: none; }

.parts-strip { display: flex; gap: .5rem; overflow-x: auto; padding: .75rem; border-top: 1px solid var(--rn-line); }
.parts-strip:empty { display: none; }
.part-tile {
  position: relative; flex: 0 0 auto; width: 112px; padding: 6px;
  border: 1px solid var(--rn-line); border-radius: var(--tblr-border-radius);
  background: var(--tblr-bg-surface, #fff); text-align: center; cursor: pointer;
  font-size: 11px; color: var(--rn-muted);
}
.part-tile:hover { border-color: var(--rn-accent); }
.part-tile.active { border-color: var(--rn-accent); box-shadow: 0 0 0 2px #cfe0fb; }
.part-tile svg { width: 96px; height: 56px; display: block; margin: 0 auto 4px; }
.part-tile svg path { stroke: #222; stroke-width: 1; fill-opacity: .8; }
.part-tile .qty { font-size: 14px; font-weight: 600; color: var(--rn-ink); }
.part-tile .shape-no {
  position: absolute; top: 4px; left: 4px; padding: 0 5px; border-radius: 4px;
  color: #fff; font-size: 11px; font-weight: 700; line-height: 16px;
}

/* ---- step 3: status, figures, the roll ---------------------------------------- */

.save-state { font-size: .8125rem; font-weight: 600; }
.save-state.ok { color: var(--rn-ok); }
.save-state.bad { color: var(--rn-bad); }

.edit-state { font-weight: 500; }
.edit-state[data-state=ok] { background: var(--tblr-green-lt, #e3f1e0); color: #2d5b23; }
.edit-state[data-state=pending] { background: var(--tblr-orange-lt, #fdebd3); color: #8a4300; }
.edit-state[data-state=warn] { background: var(--tblr-yellow-lt, #fdf3d8); color: #6b5310; }
.edit-state[data-state=bad] { background: var(--tblr-red-lt, #fbeceb); color: var(--rn-bad); }

.nest-tabs .tab { display: inline-flex; align-items: center; gap: .5rem; }
.nest-tabs .tab .tab-label { font-weight: 600; }
.nest-tabs .tab .muted { font-size: .75rem; }
.nest-tabs .tab .swatch { margin-right: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; font-variant-numeric: tabular-nums; }
.kpi {
  display: flex; flex-direction: column; gap: .2rem; padding: 1rem 1.25rem;
  background: var(--tblr-bg-surface, #fff); border: 1px solid var(--rn-line);
  border-radius: var(--tblr-border-radius-lg, 8px); box-shadow: var(--tblr-shadow-card, none);
}
.kpi .k {
  display: flex; align-items: center; gap: .375rem;
  font-size: .625rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--rn-muted);
}
.kpi .v { font-size: 1.5rem; font-weight: 700; line-height: 1.25; }
.kpi .s { font-size: .8125rem; color: var(--rn-muted); }
.kpi .bar { display: block; height: 6px; background: #e8eaee; border-radius: 3px; overflow: hidden; margin-top: .375rem; }
.kpi .bar span { display: block; height: 6px; background: var(--rn-accent); }
.kpi.check .v { font-size: 1.125rem; }
.kpi.check.ok { border-color: #bfe0c9; background: #f2faf4; }
.kpi.check.ok .v, .kpi.check.ok .k { color: var(--rn-ok); }
.kpi.check.warn { border-color: #f0c48a; background: #fff6ea; }
.kpi.check.warn .v, .kpi.check.warn .k { color: #8a4300; }
.kpi.check.bad { border-color: #efc4be; background: #fbeceb; }
.kpi.check.bad .v, .kpi.check.bad .k { color: var(--rn-bad); }
.kpi.material .v { font-size: 1.125rem; display: flex; align-items: center; }

.editor-bar .form-check { white-space: nowrap; }
.zoom-range { width: 8rem; }
.edit-status { min-height: 1.25rem; }
.edit-status.read-only { color: #6b3400; background: #fff6ea; border: 1px solid #f0c48a; border-radius: var(--tblr-border-radius); padding: .375rem .625rem; }
.shortcuts { min-width: 18rem; font-size: .8125rem; }
.shortcuts > div { padding: .15rem 0; }
.shortcuts kbd { font-size: .75rem; }
.legend-keys { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.legend-keys span::before { content: ""; display: inline-block; width: 16px; height: 10px; margin-right: 6px; border-radius: 2px; vertical-align: -1px; }
.key-near::before { border: 2px dashed var(--rn-warn); }
.key-bad::before { border: 2px solid var(--rn-bad); background: #f3b4ad; }

.viewer .roll { fill: var(--rn-roll); stroke: var(--rn-ink); stroke-width: 1; }
.viewer path { stroke: #222; stroke-width: 1; fill-opacity: .75; }
.viewer path:hover { fill-opacity: 1; stroke-width: 2; }
.viewer .tick { stroke: var(--rn-muted); stroke-width: 1; }
.viewer .tick-label { fill: var(--rn-muted); }
.viewer path.part { cursor: grab; touch-action: none; }
.viewer path.part:active { cursor: grabbing; }
.viewer path.part.selected { stroke: var(--rn-accent); stroke-width: 2.5; fill-opacity: 1; }
.viewer path.part.bad { stroke: var(--rn-bad); stroke-width: 2.5; fill: #f3b4ad; }
.viewer path.part.bad.selected { stroke: var(--rn-bad); }
.viewer path.part.near, .viewer path.part.live-near { stroke: var(--rn-warn); stroke-width: 2.5; stroke-dasharray: 6 4; }
/* parts that just moved to make room, outlined for a moment */
.viewer path.part.moved { stroke: var(--rn-ok); stroke-width: 3; fill-opacity: 1; }
/* the turn handle on the selected part */
.viewer .rot-line { stroke: var(--rn-accent); stroke-width: 1.5; stroke-dasharray: 4 3; }
.viewer .rot-centre { fill: var(--rn-accent); stroke: none; }
.viewer .rot-grip { fill: #fff; stroke: var(--rn-accent); stroke-width: 2; cursor: grab; touch-action: none; }
.viewer .rot-grip:hover { fill: #cfe0fb; }
/* two parts closer than their spacing asks: their closest points joined, a
   ring of fixed size on screen and the distance beside it -- the same while a
   part is dragged (#live-gap) as for what the server found */
.viewer .gap-line { stroke: var(--rn-warn); stroke-width: 2; pointer-events: none; }
.viewer .near-mark { fill: rgba(217, 131, 36, .15); stroke: var(--rn-warn); stroke-width: 2.5; pointer-events: visibleStroke; cursor: help; }
.viewer .gap-label { fill: #9a5612; font-weight: 600; pointer-events: none; }
.viewer .gap-label.bg { stroke: #fff; stroke-width: 4px; paint-order: stroke; }
.viewer #live-gap, .viewer #live-gap * { pointer-events: none; }
/* where two parts overlap: a ring of fixed size on screen, so a sliver
   thinner than a pixel at this zoom can still be found; only the ring itself
   takes the pointer, so the parts under it stay draggable */
.viewer .overlap-mark { fill: rgba(214, 57, 57, .12); stroke: var(--rn-bad); stroke-width: 2.5; pointer-events: visibleStroke; cursor: help; }
/* dimension overlay and the end of the used roll */
.viewer .dim-box { fill: none; stroke: var(--rn-accent); stroke-width: 1; stroke-dasharray: 5 4; pointer-events: none; }
.viewer .dim-label { fill: var(--rn-accent); font-weight: 600; pointer-events: none; }
.viewer .dim-label.bg { stroke: #fff; stroke-width: 4px; paint-order: stroke; }
.viewer .end-line { stroke: var(--rn-muted); stroke-width: 1; stroke-dasharray: 8 5; }
.viewer .spare { fill: #f1f2f4; stroke: none; }
.viewer .pno { fill: #111; font-weight: 700; pointer-events: none; paint-order: stroke; stroke: rgba(255,255,255,.85); stroke-width: 3px; vector-effect: non-scaling-stroke; }

.minimap { height: 34px; margin-bottom: .5rem; border: 1px solid var(--rn-line); border-radius: var(--tblr-border-radius); overflow: hidden; cursor: pointer; touch-action: none; }
.minimap svg { width: 100%; height: 100%; display: block; }
.minimap .mm-roll { fill: var(--rn-roll); }
.minimap path { fill: #c9d6ea; stroke: none; }
.minimap path.near { fill: #f0b46a; }
.minimap path.bad { fill: #e0705f; }
.minimap .mm-window { fill: rgba(6, 111, 209, .12); stroke: var(--rn-accent); stroke-width: 2; }

/* the selected part */
.empty-sel { display: flex; align-items: center; gap: .5rem; }
.part-badge {
  min-width: 2.25rem; height: 2.25rem; padding: 0 .4rem; border-radius: .6rem; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: #111; border: 1px solid rgba(0, 0, 0, .2);
}
.info { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; font-variant-numeric: tabular-nums; }
.info .datagrid-content { font-weight: 600; overflow-wrap: anywhere; }
.sel-alert { display: flex; gap: .5rem; align-items: flex-start; }
.downloads.locked .btn { opacity: .45; pointer-events: none; }
.sheet-summary { font-variant-numeric: tabular-nums; }

/* ---- the history: one table, the row picked beside it -------------------------- */

.history-search { width: 20rem; max-width: 100%; }
.hist-toolbar .btn-group .btn.active { background: var(--tblr-bg-surface, #fff); color: var(--rn-ink); font-weight: 600; }
.hist-toolbar #hist-filters .btn.active { background: var(--tblr-primary-lt, #e7f1fc); border-color: var(--rn-accent); color: var(--rn-accent); font-weight: 600; }
.hist-col { min-width: 0; }
@media (min-width: 1200px) {
  .hist-side { width: 360px; position: sticky; top: 5rem; }
}
.hist-table { font-variant-numeric: tabular-nums; }
.hist-table th { white-space: nowrap; }
.hist-row { cursor: pointer; }
.hist-row:hover td { background: var(--rn-soft); }
.hist-row.selected td { background: var(--tblr-primary-lt, #e7f1fc); }
.hist-row.selected td:first-child { box-shadow: inset 3px 0 0 var(--rn-accent); }
.hist-note-row td { background: var(--rn-soft); color: var(--rn-muted); font-size: .8125rem; }
/* a drawing opened to its nests: the nests indented under it, on a tint */
.hist-row.drawing.open td { border-bottom-color: transparent; }
.hist-row.sub td { background: var(--rn-soft); font-size: .8125rem; }
.hist-row.sub td:first-child { padding-left: 2rem; }
.hist-row.sub .hist-thumb { width: 84px; height: 30px; }
.hist-row.sub.selected td { background: var(--tblr-primary-lt, #e7f1fc); }
.nest-count { padding: 0 .4rem 0 .1rem; font-weight: 600; }
.nest-count .ti { margin-right: .15rem; }
.mat-line { display: flex; align-items: center; gap: .375rem; white-space: nowrap; }
.mat-line .swatch { margin: 0; }
.util { display: flex; align-items: center; gap: .5rem; min-width: 8rem; white-space: nowrap; }
.util-bar { flex: 1 1 auto; height: 6px; border-radius: 3px; background: #e8eaee; overflow: hidden; }
.util-bar span { display: block; height: 6px; }
.util-bar .good { background: var(--rn-ok); }
.util-bar .ok { background: #f59f00; }
.util-bar .low { background: var(--rn-warn); }
.who { display: inline-flex; align-items: center; gap: .375rem; }
.who .avatar { --tblr-avatar-size: 1.25rem; font-size: .5625rem; font-weight: 700; }
.empty-hist { padding: 2rem 1rem; text-align: center; color: var(--rn-muted); }
/* a nest's picture (server: thumbs.py): rows of the roll stacked, about 3:1 */
.hist-thumb, .recent-thumb, .detail-thumb {
  display: block; object-fit: contain; background: var(--rn-soft);
  border: 1px solid var(--rn-line); border-radius: 4px;
}
.hist-thumb { width: 108px; height: 40px; }
.thumb-cell { width: 1%; }
.recent-thumb { width: 84px; height: 30px; flex: none; }
.detail-thumb { width: 100%; height: auto; aspect-ratio: 3 / 1; margin-bottom: .375rem; }
.hist-thumb.none, .recent-thumb.none, .detail-thumb.none { background: repeating-linear-gradient(45deg, var(--rn-soft) 0 6px, #eef1f5 6px 12px); }
.hist-nests > li { display: block; }
.hist-nests { display: grid; gap: .375rem; font-size: .875rem; }
.hist-nests .swatch { margin: 0; }
.recent-list .swatch { margin: 0; }
.recent-swatches { display: inline-flex; gap: 2px; flex: none; }
.recent-swatches .swatch { width: .75rem; height: 1.75rem; border-radius: 3px; }
/* ---- the company, the operator, the account ------------------------------------ */

table.people td .email { display: block; color: var(--rn-muted); font-size: .75rem; overflow-wrap: anywhere; }
table.people tr.disabled td { color: var(--rn-muted); }
table.people td:nth-child(2), table.people td:nth-child(3), table.people td:nth-child(4) { white-space: nowrap; }
table.people select { width: auto; }
table.people .actions { display: flex; gap: .375rem; flex-wrap: nowrap; justify-content: flex-end; }
table.people .actions .btn { white-space: nowrap; }
table.companies td:first-child strong { display: block; }
.tag { margin-left: .25rem; }
.tag.pending { background: var(--tblr-orange-lt, #fdebd3); color: #8a4300; }
.tag.active { background: var(--tblr-green-lt, #e3f1e0); color: #2d5b23; }
.tag.suspended { background: var(--tblr-red-lt, #fbeceb); color: var(--rn-bad); }
.plain-list:empty { display: none; }
.plain-list .list-group-item { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; font-size: .8125rem; }
.plain-list.audit .list-group-item { color: var(--rn-muted); }
.plain-list.audit .list-group-item strong { color: var(--rn-ink); font-weight: 600; }
.invite-result { display: grid; gap: .4rem; font-size: .8125rem; }
.invite-result input { font-family: var(--tblr-font-monospace, monospace); font-size: .75rem; }
.invite-result button { justify-self: start; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; font-size: .875rem; }
dl.facts dt { color: var(--rn-muted); font-weight: 400; }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

/* ---- who may do what ----------------------------------------------------------- */

/* the cutting table (viewer): no nesting -- the history and the roll */
body.viewer #upload-card, body.viewer #form-card, body.viewer #drawing-card,
body.viewer #steps, body.viewer #nest-again { display: none !important; }
main[data-view="admin"] > #pending-banner,
main[data-view="company"] > #pending-banner,
main[data-view="account"] > #pending-banner { display: none; }

/* ---- the login page ------------------------------------------------------------- */

.auth-page .page-center { min-height: 100vh; }
.auth-tabs .nav-link { font-weight: 600; }

/* ---- the printed cutting plan --------------------------------------------------- */

#print-plan { display: none; }

@page { size: A4 landscape; margin: 10mm; }
@media print {
  body { background: #fff; }
  .page { display: none !important; }
  #print-plan { display: block; font: 10pt/1.35 system-ui, sans-serif; color: #000;
                -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* a nest of several projects: which colour and number is which drawing */
  .pp-projects { display: flex; flex-wrap: wrap; align-items: center; gap: 1mm 6mm; font-size: 9pt; }
  .pp-projects .swatch { display: inline-block; width: 3mm; height: 3mm; margin-right: 1.5mm; border: .5pt solid #000; vertical-align: -.4mm; }
  .pp-projects .pp-how { color: #333; }
  .pp-check .swatch { display: inline-block; width: 2.2mm; height: 2.2mm; border: .4pt solid #000; }
  /* one table: its header repeats on every page, and no section (a row) is
     broken across two pages or cut off */
  .pp-table { width: 100%; border-collapse: collapse; }
  .pp-table td { padding: 0; vertical-align: top; }
  .pp-table thead td { padding-bottom: 3mm; }
  .pp-table tbody tr { break-inside: avoid; page-break-inside: avoid; }
  .pp-table tbody td { padding-bottom: 4mm; }
  .pp-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 1.5pt solid #000; padding-bottom: 2mm; }
  .pp-head h1 { margin: 0; font-size: 17pt; }
  .pp-meta { font-size: 9pt; color: #333; }
  .pp-facts { display: flex; gap: 8mm; margin: 0; }
  .pp-facts dt { font-size: 8pt; color: #333; }
  .pp-facts dd { margin: 0; font-size: 12pt; font-weight: 700; }
  .pp-strip { display: flex; flex-direction: column; gap: 1mm; }
  .pp-strip svg { width: 100%; height: auto; max-height: 52mm; display: block; }
  .pp-strip .roll { fill: #fff; stroke: #000; stroke-width: 1pt; vector-effect: non-scaling-stroke; }
  .pp-strip .parts path { fill: #eef1f5; stroke: #000; stroke-width: .8pt; vector-effect: non-scaling-stroke; }
  .pp-strip text.n { font-weight: 700; fill: #000; }
  .pp-strip text.d { fill: #222; }
  .pp-ticks { position: relative; height: 4mm; font-size: 7.5pt; color: #333; }
  .pp-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
  .pp-ticks span.first { transform: none; }
  .pp-ticks span.last { transform: translateX(-100%); }
  .pp-strip-head { font-size: 9.5pt; }
  .pp-checks { display: flex; flex-wrap: wrap; gap: 1mm 4mm; font-size: 8.5pt; }
  .pp-check { display: inline-flex; align-items: center; gap: 1.5mm; }
  .pp-check .box { width: 3mm; height: 3mm; border: .8pt solid #000; }
  .pp-foot { margin-top: 2mm; display: flex; justify-content: space-between; gap: 6mm; border-top: .8pt solid #666; padding-top: 1.5mm; font-size: 8pt; color: #333; }
}
