/* ============================================================
   SpoolBase — shared design system
   Dark-mode primary. Inter (UI) + JetBrains Mono (metrics).
   Accent + density are driven by CSS vars set in tweaks.js.
   ============================================================ */

:root {
  /* ---- surfaces (very dark, faintly cool slate) ---- */
  --bg-deep:   #0d0e11;
  --bg:        #121317;
  --surface:   #181a1f;
  --surface-2: #1f2228;
  --surface-3: #262a31;
  --hover:     rgba(255,255,255,.04);

  /* ---- lines ---- */
  --border:      #272a31;
  --border-soft: rgba(255,255,255,.06);
  --border-mid:  rgba(255,255,255,.10);

  /* ---- text ---- */
  --text:   #f3f4f6;
  --text-2: #a6abb4;
  --text-4: #7a808a; /* was #4b4f56 — ~2.3:1 against --bg, failed WCAG AA (4.5:1). Don't darken below ~#767b84 without rechecking contrast. */

  /* ---- accent (overridden live by tweaks) ---- */
  --accent:      #2de0c8;
  --accent-2:    #55ead9;
  --on-accent:   #06231f;
  --accent-soft: color-mix(in oklab, var(--accent) 16%, transparent);
  --accent-line: color-mix(in oklab, var(--accent) 38%, transparent);
  --accent-glow: color-mix(in oklab, var(--accent) 30%, transparent);

  /* ---- status (independent of accent) ---- */
  --good:  #3ecf8e;
  --good-soft: color-mix(in oklab, var(--good) 16%, transparent);
  --warn:  #f5b13d;
  --warn-soft: color-mix(in oklab, var(--warn) 16%, transparent);
  --low:   #ff5d52;
  --low-soft: color-mix(in oklab, var(--low) 16%, transparent);

  /* ---- category accents (muted, desaturated) ---- */
  --cat-opened:   #5b93c7;
  --cat-unopened: #6b7180;
  --cat-third:    #a98cff;

  /* ---- type ---- */
  --ui:   "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* ---- radius ---- */
  --r-sm: 7px;
  --r:    11px;
  --r-lg: 16px;
  --r-xl: 22px;

  /* ---- density (overridden by tweaks: compact/regular/comfy) ---- */
  --row-h: 52px;
  --pad:   16px;
  --gap:   16px;

  --sidebar-w: 244px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.32);
  --shadow-lg: 0 24px 64px rgba(0,0,0,.5);
}

[data-density="compact"] { --row-h: 44px; --pad: 12px; --gap: 12px; }
[data-density="comfy"]   { --row-h: 62px; --pad: 20px; --gap: 22px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--ui);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv05" 1, "ss01" 1;
}
::selection { background: var(--accent-glow); color: #fff; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
h1,h2,h3,h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
.mono { font-family: var(--mono); font-feature-settings: "tnum" 1; }
.tnum { font-variant-numeric: tabular-nums; }

/* faint grid texture, used on landing + auth */
.grid-bg {
  background-image:
    linear-gradient(var(--border-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-soft) 1px, transparent 1px);
  background-size: 46px 46px;
}

/* ============================================================
   App shell : sidebar + main
   ============================================================ */
.app { display: flex; min-height: 100vh; }

/* Mobile nav drawer trigger + scrim (2026-08-11). Both are injected once by
   _ensureMobileNavToggle() in app.js — see that comment for why. Hidden by
   default; the @media block below is what actually makes them usable, at
   the same 880px breakpoint the sidebar itself collapses at. */
.nav-toggle {
  display: none; flex: 0 0 auto;
  width: 38px; height: 38px; align-items: center; justify-content: center;
  border-radius: var(--r-sm); border: 1px solid var(--border-mid);
  background: var(--surface-2); color: var(--text); cursor: pointer; padding: 0;
}
.nav-toggle svg { width: 19px; height: 19px; }
.nav-toggle:hover { background: var(--surface-3); }
.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 290;
  background: rgba(6,7,9,.62); backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

.sidebar {
  position: sticky; top: 0; align-self: flex-start;
  width: var(--sidebar-w); height: 100vh; flex: 0 0 var(--sidebar-w);
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 18px 14px 14px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 22px; }
.brand .logo { flex: 0 0 auto; }
.brand .name { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.brand .name b { color: var(--accent); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-4); padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  cursor: pointer; position: relative; transition: background .12s, color .12s;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); }
.nav-item.active::before {
  content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-item .count {
  margin-left: auto; font-family: var(--mono); font-size: 11px; font-weight: 600;
  background: var(--accent); color: var(--on-accent);
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
}
.sidebar .spacer { flex: 1; }

.upsell {
  margin-top: 12px; padding: 14px; border-radius: var(--r);
  background: linear-gradient(160deg, var(--accent-soft), transparent 80%);
  border: 1px solid var(--accent-line);
}
.upsell .h { font-size: 12.5px; font-weight: 650; margin-bottom: 3px; }
.upsell p { margin: 0 0 11px; font-size: 11.5px; color: var(--text-2); line-height: 1.45; }

.account {
  display: flex; align-items: center; gap: 10px; margin-top: 12px;
  padding: 8px; border-radius: var(--r-sm);
}
.account:hover { background: var(--hover); }
.avatar {
  width: 30px; height: 30px; border-radius: 8px; flex: 0 0 30px;
  background: var(--surface-3); display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--text);
}
.account .who { font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.account .plan { font-size: 11px; color: var(--text-2); }

/* main column */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 28px; min-height: 68px;
  background: color-mix(in oklab, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .title { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.topbar .sub { font-size: 12.5px; color: var(--text-2); margin-top: 1px; white-space: nowrap; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.content { padding: 26px 28px 60px; flex: 1; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--border-mid); background: var(--surface-2); color: var(--text);
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-mid); }
.btn:active { transform: translateY(.5px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-sm { height: 31px; padding: 0 11px; font-size: 12.5px; gap: 6px; border-radius: 6px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-block { width: 100%; height: 42px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-danger { color: var(--low); border-color: color-mix(in oklab, var(--low) 40%, transparent); background: var(--low-soft); }
.btn-danger:hover { background: color-mix(in oklab, var(--low) 24%, transparent); }

/* ============================================================
   Cards & generic bits
   ============================================================ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.card-pad { padding: var(--pad); }
.eyebrow {
  font-size: 11px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-2);
}

.search {
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 12px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border); min-width: 220px;
}
.search svg { width: 15px; height: 15px; color: var(--text-2); flex: 0 0 15px; }
.search input {
  border: 0; background: transparent; color: var(--text); font: inherit; font-size: 13px;
  outline: none; width: 100%;
}
.search input::placeholder { color: var(--text-4); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 31px; padding: 0 11px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); font-size: 12.5px; font-weight: 550; cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.chip:hover { color: var(--text); border-color: var(--border-mid); }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); border-color: var(--accent-line); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }

/* ============================================================
   Color swatch (used everywhere)
   ============================================================ */
.swatch {
  --d: 22px;
  width: var(--d); height: var(--d); border-radius: 50%; flex: 0 0 var(--d);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14), inset 0 -3px 6px rgba(0,0,0,.35);
  position: relative;
}
.swatch.lg { --d: 30px; }
.swatch.sm { --d: 15px; }
.swatch.metallic { background-image: linear-gradient(135deg, rgba(255,255,255,.5), transparent 42%, rgba(0,0,0,.35)); }
.swatch.glow { box-shadow: inset 0 0 0 1px rgba(255,255,255,.2), 0 0 11px 1px currentColor; }
.swatch.matte::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: rgba(0,0,0,.16);
}

/* ============================================================
   Weight / status bar
   ============================================================ */
.weight {
  display: flex; flex-direction: column; gap: 5px; min-width: 132px;
}
.weight .row { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.weight .g { font-family: var(--mono); font-size: 12.5px; font-weight: 600; letter-spacing: -.02em; }
.weight .pct { font-family: var(--mono); font-size: 10.5px; color: var(--text-4); margin-left: auto; }
.est-badge { font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 1px 5px; border-radius: 4px; background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; white-space: nowrap; }
.bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; position: relative; }
.bar > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; }
.bar.good > span { background: var(--good); }
.bar.warn > span { background: var(--warn); }
.bar.low  > span { background: var(--low); }
.bar.sealed { background: repeating-linear-gradient(90deg, var(--surface-3) 0 6px, transparent 6px 11px); }
.bar.sealed > span { background: var(--cat-unopened); opacity: .5; }

.statetag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600;
}
.statetag .dot { width: 7px; height: 7px; border-radius: 50%; }
.statetag.good { color: var(--good); }
.statetag.warn { color: var(--warn); }
.statetag.low  { color: var(--low); }
.statetag.sealed { color: var(--text-2); }

/* ============================================================
   Badges / pills / tags
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 6px; font-size: 11px; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge.ams { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent-line); font-family: var(--mono); }
.badge.dim { color: var(--text-4); }
.badge.ams-loaded {
  height: auto; min-height: 22px; flex-direction: column; align-items: flex-start; gap: 1px; padding: 3px 8px;
}
.ams-loaded-printer {
  font-family: var(--font, inherit); font-size: 10px; font-weight: 600; color: var(--text-2); line-height: 1.3;
  max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ams-loaded-slot { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; line-height: 1.3; }

.cat-tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 550; color: var(--text-2);
}
.cat-tag .bar3 { width: 3px; height: 13px; border-radius: 2px; }
.cat-opened   .bar3 { background: var(--cat-opened); }
.cat-unopened .bar3 { background: var(--cat-unopened); }
.cat-third    .bar3 { background: var(--cat-third); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.online { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.status-dot.offline { background: var(--text-4); }
.status-dot.warning { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,0.2); }

/* ============================================================
   Stat cards (dashboard)
   ============================================================ */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 18px; position: relative; overflow: hidden;
}
.stat .k { font-size: 12px; color: var(--text-2); font-weight: 550; display: flex; align-items: center; gap: 7px; }
.stat .k svg { width: 15px; height: 15px; }
.stat .v { font-family: var(--mono); font-size: 33px; font-weight: 700; letter-spacing: -.03em; margin-top: 10px; line-height: 1; }
.stat .v small { font-size: 15px; color: var(--text-2); font-weight: 600; }
.stat .meta { font-size: 12px; color: var(--text-2); margin-top: 8px; }
.stat.alert { border-color: color-mix(in oklab, var(--low) 35%, var(--border)); }
.stat.alert .v { color: var(--low); }
.stat.alert .k { color: var(--low); }
.stat-link { display: block; text-decoration: none; color: inherit; transition: border-color .15s; }
.stat-link:hover { border-color: var(--border-mid); }

/* progress meter for plan usage */
.meter { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 10px; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.meter.over > span { background: var(--low); }

/* ============================================================
   Tables (My Spools hero)
   ============================================================ */
/* overflow-x (not a flat `overflow: hidden`) so a table wider than its
   container scrolls horizontally on a narrow screen instead of silently
   clipping columns off the edge — 2026-08-11 mobile pass. */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.spools { width: 100%; border-collapse: collapse; }
table.spools thead th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-2); padding: 12px 16px; background: var(--bg-deep);
  border-bottom: 1px solid var(--border); white-space: nowrap; cursor: default; user-select: none;
}
table.spools thead th.sortable { cursor: pointer; }
table.spools thead th.sortable:hover { color: var(--text); }
table.spools thead th .arrow { color: var(--accent); margin-left: 4px; }
.group-row td {
  padding: 14px 16px 7px; font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-2);
}
.group-row .gcount { color: var(--text-4); margin-left: 8px; font-family: var(--mono); }
tbody tr.spool { border-bottom: 1px solid var(--border-soft); transition: background .1s; }
tbody tr.spool:hover { background: var(--hover); }
tbody tr.spool td { padding: 0 16px; height: var(--row-h); vertical-align: middle; }
tbody tr.spool td.idcell { position: relative; }
tbody tr.spool td.idcell::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0;
}
tr.spool.cat-opened   td.idcell::before { background: var(--cat-opened); }
tr.spool.cat-unopened td.idcell::before { background: var(--cat-unopened); opacity: .55; }
tr.spool.cat-third    td.idcell::before { background: var(--cat-third); }
tr.spool.loaded { background: var(--accent-soft); }
tr.spool.loaded:hover { background: color-mix(in oklab, var(--accent) 22%, transparent); }
tr.spool.low-row td.idcell::after {
  content: ""; position: absolute; inset: 0; background: var(--low-soft); pointer-events: none;
  mix-blend-mode: normal; opacity: .5; z-index: -0;
}

.fil-name { display: flex; align-items: center; gap: 12px; }
.fil-name .meta { min-width: 0; }
.fil-name .nm { font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; }
.fil-name .sub { font-size: 11.5px; color: var(--text-2); display: flex; gap: 8px; align-items: center; }
.fil-name .code { font-family: var(--mono); }

.cell-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity .12s; }
tr.spool:hover .cell-actions { opacity: 1; }
.icon-btn {
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 7px;
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 15px; height: 15px; }

/* ============================================================
   Drawer + modal
   ============================================================ */
.overlay {
  position: fixed; inset: 0; background: rgba(6,7,9,.62); backdrop-filter: blur(3px);
  z-index: 200; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 94vw; z-index: 210;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform .26s cubic-bezier(.32,.72,.3,1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer .dh { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.drawer .dh h3 { font-size: 17px; }
.drawer .db { padding: 22px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 18px; }
.drawer .df { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.drawer .df .btn { flex: 1; }
.section-divider { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-4); padding-bottom: 2px; border-bottom: 1px solid var(--border); margin-bottom: -4px; }
.cred-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cred-label { font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.cred-value { font-size: 13px; color: var(--text-2); background: var(--surface-2); border-radius: 6px; padding: 3px 8px; letter-spacing: .04em; }

.modal {
  position: fixed; z-index: 210; top: 50%; left: 50%; transform: translate(-50%,-46%) scale(.98);
  width: 440px; max-width: 92vw; opacity: 0; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); transition: opacity .18s, transform .18s;
}
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%,-50%) scale(1); }

/* ============================================================
   Form fields
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--text-4); }
.input, .selectbox, textarea.input {
  height: 40px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; font-size: 13.5px; outline: none;
  transition: border-color .12s, box-shadow .12s; width: 100%;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 76px; line-height: 1.5; }
.input:focus, .selectbox:focus, textarea.input:focus {
  border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--text-4); }
.selectbox {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236c7178' d='M1 1.5 6 6.5 11 1.5'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* segmented toggle for forms */
.seg { display: flex; padding: 3px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); }
.seg button {
  flex: 1; height: 32px; border: 0; background: transparent; color: var(--text-2);
  font: inherit; font-size: 12.5px; font-weight: 600; border-radius: 5px; cursor: pointer; transition: .12s;
}
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.3); }

/* checkbox/radio swatch picker for weight presets */
.preset-row { display: flex; gap: 8px; flex-wrap: wrap; }
.preset {
  height: 34px; padding: 0 13px; border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--bg); color: var(--text-2); font-size: 12.5px; font-weight: 600; cursor: pointer;
  font-family: var(--mono);
}
.preset[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-soft); color: var(--text); }

/* toggle switch */
.switch { position: relative; width: 40px; height: 23px; border: 0; border-radius: 999px; background: var(--surface-3); cursor: pointer; padding: 0; flex: 0 0 40px; transition: background .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch i { position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch[aria-checked="true"] i { transform: translateX(17px); }

/* ============================================================
   AMS slot chips — shared by Dashboard's printer panel and
   Printers.html's printer cards. One rendering function
   (_buildAmsSection in data.js) produces this markup for both pages;
   do not fork this block per page.
   ============================================================ */
.ams-units { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.ams-unit-label { font-size: 10px; font-weight: 500; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 3px; }
.no-slots { padding: 16px 0; font-size: 12.5px; color: var(--text-4); font-style: italic; }
.ams-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.ams-slot-col { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ams-slot-num { font-size: 10px; color: var(--text-2); font-weight: 500; line-height: 1; }
.ams-chip { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 5px 8px; border-radius: 5px; font-size: 11px; font-weight: 550; border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; cursor: default; width: 88px; height: 86px; box-sizing: border-box; flex-shrink: 0; overflow: hidden; }
.ams-chip.flag { border: 1.5px solid #ef4444; background: #fee2e2; color: #b91c1c; cursor: pointer; box-shadow: 0 1px 4px rgba(239,68,68,0.2); font-weight: 600; transition: transform 0.1s, box-shadow 0.1s; }
.ams-chip.flag:hover { background: #fecaca; transform: translateY(-1px); box-shadow: 0 3px 8px rgba(239,68,68,0.3); }
.ams-chip.flag:active { transform: translateY(0); box-shadow: 0 1px 3px rgba(239,68,68,0.2); }
.ams-chip-sub { font-weight: 400; opacity: 0.7; font-size: 10px; }
/* Color name can be longer than the chip is wide (e.g. user-entered names
   like "Vibrant Orange") — truncate with ellipsis rather than scrolling,
   so macOS "Always show scrollbars" doesn't render a phantom gray line. */
.ams-chip-color { display: block; font-weight: 400; opacity: 0.7; font-size: 10px; white-space: normal; line-height: 1.3; }
.ams-chip-id { display: block; font-weight: 400; opacity: 0.55; font-size: 9.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ams-chip.empty { border: 1.5px dashed rgba(150,150,150,0.35); background: rgba(128,128,128,0.04); color: var(--text-2); font-weight: 400; align-items: center; justify-content: center; font-size: 16px; letter-spacing: 1px; }
.ams-ext-inline { padding-left: 10px; margin-left: 3px; border-left: 1px solid var(--border-soft); }
.ams-note { font-size: 10.5px; color: var(--text-2); margin-top: 4px; font-style: italic; }
.ams-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; border: 1px solid rgba(0,0,0,.08); }

/* ============================================================
   Queue cards
   ============================================================ */
.queue { display: flex; flex-direction: column; gap: 14px; max-width: 820px; }
.qcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.qcard .qh { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border-soft); }
.qcard .qh .when { margin-left: auto; font-size: 11.5px; color: var(--text-4); }
.qcard .detected { display: flex; align-items: center; gap: 13px; padding: 16px 18px; }
.qcard .detected .lbl { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.qcard .suggest { padding: 4px 18px 14px; display: flex; flex-direction: column; gap: 8px; }
.match {
  display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--bg);
}
.match.best { border-color: var(--accent-line); background: var(--accent-soft); }
.match .pctscore { margin-left: auto; font-family: var(--mono); font-size: 12px; font-weight: 700; }
.match.best .pctscore { color: var(--accent-2); }
.qcard .qa { display: flex; gap: 9px; padding: 14px 18px; border-top: 1px solid var(--border-soft); }

/* Moved from Confirmation Queue.html's page-local <style> so Admin.html's
   Queue Preview tab (assets/queueCards.js) renders identically without a
   duplicate copy of these rules. */
.qcard, .rcard { max-width: 820px; transition: opacity .25s, transform .25s; }
.qcard.dismiss, .rcard.dismiss { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.rcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.qbody { font-size: 13px; color: var(--text-2); line-height: 1.6; padding: 0 18px 14px; }
.suggest-lbl { font-size: 11px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; padding: 0 18px 8px; }
.match { cursor: pointer; transition: background .1s; }
.match:hover { background: var(--surface-2); }
.match.selected { background: var(--accent-soft); border-color: var(--accent-line) !important; }
.match .m { flex: 1; min-width: 0; }
.match .nm { font-size: 13px; font-weight: 600; }
.match .sub { font-size: 11.5px; color: var(--text-2); }
.empty-q { text-align: center; padding: 70px 20px; color: var(--text-2); max-width: 820px; }
.empty-q .big { width: 56px; height: 56px; border-radius: 16px; background: var(--good-soft); color: var(--good); display: grid; place-items: center; margin: 0 auto 16px; }
.empty-q .big svg { width: 28px; height: 28px; }
.empty-q h3 { font-size: 18px; color: var(--text); margin-bottom: 6px; }
.nomatch { display: flex; align-items: center; gap: 10px; padding: 13px; border: 1px dashed var(--border-mid); border-radius: var(--r-sm); color: var(--text-2); font-size: 12.5px; }
.nomatch svg { width: 16px; height: 16px; flex-shrink: 0; }
.confidence { font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 20px; }
.conf-high { background: var(--good-soft); color: var(--good); }
.conf-mid  { background: color-mix(in oklab,var(--warn) 15%,transparent); color: var(--warn); }
.conf-low  { background: var(--surface-2); color: var(--text-2); }
.section-hd { font-size: 11px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .07em; max-width: 820px; margin-bottom: 10px; }
/* A card's footer action row (.qa on an .rcard — runout/slot-question cards)
   and its warn/confirm sub-panels (.skip-warn, .sq-actions,
   .sq-dismiss-confirm, on either card type) got this tint from an inline
   style="background:var(--bg-deep)" on Confirmation Queue.html's own
   pre-DEC-057 markup. queueCards.js's extracted versions (DEC-057) never
   carried it over and nothing here replaced it, so every page rendering
   these functions (Confirmation Queue.html itself once wired up, and
   Admin.html's Queue Preview tab) was missing this tint — added 2026-08-11
   while fixing Confirmation Queue.html's queueCards.js drift (DEC-062).
   .qcard's own .qa never had this tint and still shouldn't. */
.rcard .qa, .skip-warn, .sq-actions, .sq-dismiss-confirm { background: var(--bg-deep); }

/* ============================================================
   Spool mismatch trigger — shared by Dashboard.html and Printers.html,
   rendered by _buildMismatchTrigger (data.js) right after the AMS chips.
   ============================================================ */
.mismatch-trigger { margin-top: 8px; font-size: 11.5px; font-weight: 600; color: var(--text-2); background: transparent; border: 1px dashed var(--border-mid); border-radius: 6px; padding: 5px 10px; cursor: pointer; transition: color .12s, border-color .12s; }
.mismatch-trigger:hover { color: var(--accent); border-color: var(--accent-line); }

/* ============================================================
   Correction modal — shared by Print Jobs.html and My Spools.html via
   assets/correctionModal.js. Do not redefine these rules per page.
   ============================================================ */
.cm-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 22px 0; }
.cm-title { font-size: 15px; font-weight: 700; }
.cm-sub   { font-size: 13px; color: var(--text-2); margin-top: 3px; max-width: 340px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-body  { padding: 16px 22px 0; display: flex; flex-direction: column; gap: 14px; }
.cm-err  { font-size: 12.5px; color: var(--low); margin: 6px 22px 0; display: none; }
.cm-foot { padding: 16px 22px; display: flex; gap: 10px; margin-top: 4px; }
.cm-confirm-msg { font-size: 13px; color: var(--text-2); line-height: 1.5; padding: 10px 22px 4px; }

.cm-total-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; color: var(--text-2); background: var(--surface-2); }
.cm-total-box strong { color: var(--text); }
.cm-total-box.warn { border-color: var(--low); background: color-mix(in oklab, var(--low) 8%, transparent); color: var(--low); }
.cm-total-box.warn strong { color: var(--low); }

.cm-add-split { align-self: flex-start; background: transparent; border: none; padding: 0; font-size: 12.5px; font-weight: 600; color: var(--accent); cursor: pointer; }
.cm-add-split:hover { text-decoration: underline; }
#cm_rows { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.cm-row { display: flex; align-items: center; gap: 8px; }
.cm-row-picked { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px; cursor: pointer; transition: border-color .12s, background .12s; }
.cm-row-picked:hover { border-color: var(--accent); background: var(--accent-soft); }
button.cm-row-empty { font: inherit; font-size: 12.5px; color: var(--text-2); text-align: left; background: var(--surface-2); }
.cm-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; border: 1px solid rgba(0,0,0,.12); }
.cm-row-body { flex: 1; min-width: 0; }
.cm-row-id   { font-size: 12px; font-weight: 700; font-family: var(--mono); }
.cm-row-info { font-size: 11.5px; color: var(--text-2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-row-grams { width: 72px; flex-shrink: 0; }
#cm_rows .icon-btn.act-del:hover { border-color: var(--low); color: var(--low); }
.cm-row-search { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.cm-row-search-results { display: flex; flex-direction: column; gap: 6px; max-height: 180px; overflow-y: auto; }

/* RFID-mismatch per-field picker — same clickable-row language as .cm-row-picked,
   but a real toggle (aria-pressed) instead of a one-shot pick, since either side
   can be selected/deselected repeatedly before Save. */
.rfid-choice {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--surface); cursor: pointer; text-align: left;
  font: inherit; color: var(--text); transition: border-color .12s, background .12s;
}
.rfid-choice:hover { border-color: var(--border-mid); }
.rfid-choice[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-soft); }
.rfid-choice-body  { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.rfid-choice-label { font-size: 11px; font-weight: 600; color: var(--text-4); text-transform: uppercase; letter-spacing: .02em; }
.rfid-choice-val   { font-size: 13px; font-weight: 600; font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   Slot resolution modal — shared by Dashboard.html and Printers.html
   via assets/slotModal.js. Do not redefine these rules per page.
   ============================================================ */
.sp-head { display: flex; align-items: flex-start; gap: 14px; padding: 20px 22px 0; }
.sp-head-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.sp-head h3 { font-size: 15px; font-weight: 700; color: var(--text); }
.sp-head p  { font-size: 13px; color: var(--text-2); margin-top: 4px; line-height: 1.5; }
.sp-form { padding: 16px 22px 0; display: flex; flex-direction: column; gap: 12px; }
.sp-candidates { padding: 14px 22px 0; display: flex; flex-direction: column; gap: 8px; }
.sp-candidate { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; transition: border-color .15s, background .15s; }
.sp-candidate:hover { border-color: var(--accent); background: var(--accent-soft); }
.sp-candidate .sp-cid { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--text); }
.sp-candidate .sp-cmeta { font-size: 11.5px; color: var(--text-2); margin-top: 1px; }
.sp-err { font-size: 12.5px; color: var(--low); margin: 8px 22px 0; display: none; }
.sp-foot { padding: 16px 22px; display: flex; gap: 10px; margin-top: 6px; }
.sp-wm-toggle { display: flex; gap: 1px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px; }
.sp-wm-btn { font-size: 11px; font-weight: 600; padding: 2px 10px; border: 0; background: transparent; border-radius: 4px; cursor: pointer; color: var(--text-2); transition: background .1s, color .1s; }
.sp-wm-btn[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }
.sp-cond-toggle { display: flex; gap: 6px; }
.sp-cond-btn { flex: 1; font-size: 13px; font-weight: 550; padding: 9px 12px; border: 1px solid var(--border); background: var(--surface); border-radius: 7px; cursor: pointer; color: var(--text-2); transition: background .12s, color .12s, border-color .12s; text-align: center; }
.sp-cond-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
/* Tare spool-type selector */
.sp-tare-wrap { position: relative; }
.sp-tare-sel { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--r); cursor: pointer; font-size: 13px; color: var(--text); background: var(--surface); user-select: none; }
.sp-tare-sel:hover { border-color: var(--accent); }
.sp-tare-sel:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sp-tare-placeholder { color: var(--text-2); }
.sp-tare-drop { position: absolute; left: 0; right: 0; top: calc(100% + 3px); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); z-index: 50; overflow: hidden; display: none; }
.sp-tare-list { max-height: 185px; overflow-y: auto; }
.sp-tare-sec { font-size: 10px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; padding: 7px 12px 3px; }
.sp-tare-opt { padding: 8px 12px; font-size: 13px; cursor: pointer; color: var(--text); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sp-tare-opt:hover { background: var(--surface-2); }
.sp-tare-opt .tw { font-size: 11px; color: var(--text-2); white-space: nowrap; flex-shrink: 0; }
.sp-tare-opt.mine { color: var(--accent); }
.sp-tare-manual-row { display: flex; align-items: center; gap: 7px; padding: 8px 12px; border-top: 1px solid var(--border); }
.sp-tare-add-row { display: flex; align-items: center; gap: 6px; padding: 9px 12px; border-top: 1px solid var(--border); font-size: 13px; color: var(--accent); cursor: pointer; }
.sp-tare-add-row:hover { background: var(--accent-soft); }
.sp-tare-cf { flex-direction: column; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); display: none; }
/* Brand autocomplete */
.sp-brand-wrap { position: relative; }
.sp-brand-ac { position: absolute; left: 0; right: 0; top: calc(100% + 3px); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); z-index: 50; max-height: 200px; overflow-y: auto; display: none; }
.sp-bac-opt { padding: 8px 12px; font-size: 13px; cursor: pointer; color: var(--text); }
.sp-bac-opt:hover, .sp-bac-opt.hi { background: var(--surface-2); }
.sp-bac-opt.muted { color: var(--text-2); font-style: italic; }
/* Top-anchored so it expands downward when the Weighed section opens */
#slotModal { top: 6vh; transform: translate(-50%, -6px) scale(.98); max-height: 90vh; overflow-y: auto; }
#slotModal.open { transform: translate(-50%, 0) scale(1); }

/* ============================================================
   Helpers
   ============================================================ */
.flex { display: flex; }
.aic { align-items: center; }
.jcb { justify-content: space-between; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }
.muted { color: var(--text-2); }
.section-title { font-size: 14px; font-weight: 650; margin-bottom: 13px; display: flex; align-items: center; gap: 10px; }
.section-title .muted { font-weight: 500; }
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }
.hide { display: none !important; }

/* responsive: mobile nav drawer + touch/form/table tuning (2026-08-11 pass — see Reference/MOBILE.md) */
@media (max-width: 880px) {
  /* Sidebar becomes an off-canvas drawer instead of vanishing outright —
     .nav-toggle (see its own rule above) is what opens it. Only the
     transform changes at this breakpoint; .sidebar's own base rule
     (width/padding/nav markup) is untouched so the drawer's contents look
     identical to the desktop sidebar. */
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; max-width: 86vw;
    z-index: 300; transform: translateX(-100%);
    transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .nav-toggle { display: inline-flex; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 18px 14px 50px; }
  .topbar { padding: 14px 16px; gap: 12px; }

  /* iOS Safari auto-zooms the page on focusing any field under 16px —
     bumping to 16px here (desktop keeps the tighter 13.5px) kills that
     without changing the desktop design at all. */
  .input, .selectbox, textarea.input { font-size: 16px; }

  /* Two-up form rows (Add Spool, Settings, Order Imports, the RFID-mismatch
     picker, ...) get cramped once neither column has much room — stack
     instead. Nothing here changes on desktop. */
  .field-row { grid-template-columns: 1fr; }

  /* Touch targets below ~44px are hard to hit reliably; both grow only at
     this breakpoint. .switch's "on" thumb position is computed from its own
     track/knob/padding sizes (46 - 20 - 3*2 = 20px of travel), so it's
     restated here rather than left to derive from the desktop rule. */
  .icon-btn { width: 38px; height: 38px; }
  .switch { width: 46px; height: 26px; flex: 0 0 46px; }
  .switch i { width: 20px; height: 20px; }
  .switch[aria-checked="true"] i { transform: translateX(20px); }
}
