:root {
  --navy: #11304e;
  --navy-2: #1c466b;
  --accent: #2f80ed;
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1a2330;
  --muted: #586477;
  --line: #e2e7ee;
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(17, 48, 78, .12), 0 6px 18px rgba(17, 48, 78, .06);
}

* { box-sizing: border-box; }
/* The `hidden` attribute must win over display:flex/grid utilities (e.g. .fld). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* App bar */
.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: #fff;
  padding-top: env(safe-area-inset-top);
  box-shadow: var(--shadow);
}
.appbar-inner {
  display: flex;
  align-items: baseline;
  gap: 10px;
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 16px;
}
.appbar .logo { font-size: 18px; color: #8fd0ff; }
.appbar h1 { font-size: 19px; margin: 0; letter-spacing: .3px; }
.appbar-sub { font-size: 13px; color: #b9cbe0; }

main { max-width: 760px; margin: 0 auto; padding: 14px max(16px, env(safe-area-inset-left)) 40px max(16px, env(safe-area-inset-right)); }

/* Search panel */
.search-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  position: relative;
}
select, input[type="search"], input[type="number"], button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 12px 12px;
  background: #fff;
  color: var(--ink);
}
input[type="search"] { -webkit-appearance: none; }
select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%2365728a' d='M2 4l4 4 4-4z'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  padding: 12px 18px;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }

/* Visible keyboard focus */
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
.tab:focus-visible, .chip:focus-visible, .fam:focus-visible, .brand-toggle:focus-visible, .vcard:focus-visible, .rc:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.tab:focus-visible { outline-color: #fff; outline-offset: -2px; }

.hint { color: var(--muted); font-size: 13px; margin: 10px 2px 2px; }

/* Autocomplete */
.suggest {
  list-style: none;
  margin: 6px 0 0;
  padding: 4px;
  position: absolute;
  left: 12px; right: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 20;
  max-height: 320px;
  overflow: auto;
}
.suggest li {
  padding: 11px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: center;
}
.suggest li:hover, .suggest li.active { background: #eef4fe; }
.suggest .code { font-weight: 600; }
.suggest .nm { color: var(--muted); font-size: 14px; }

/* Status / errors */
.status { margin: 16px 4px; color: var(--muted); }
.status.error { color: var(--danger); }
.spinner {
  display: inline-block; width: 16px; height: 16px; vertical-align: -3px;
  border: 2px solid #cdd6e4; border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Results */
.results { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  cursor: pointer;
}
.card:active { background: #fafbfd; }
.swatch {
  width: 46px; height: 46px; flex: none;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,.12);
  background: repeating-conic-gradient(#e9edf3 0% 25%, #fff 0% 50%) 50% / 14px 14px;
}
.card .meta { min-width: 0; flex: 1; }
.card .code { font-weight: 700; font-size: 16px; }
.card .name { color: var(--ink); }
.card .sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.badge {
  display: inline-block; font-size: 11.5px; font-weight: 600;
  color: var(--navy-2); background: #e8f0fb; border-radius: 999px;
  padding: 2px 9px; margin-left: 6px; vertical-align: 1px;
}
.chev { color: #b6c0d2; font-size: 22px; flex: none; }

.capped {
  margin: 12px 4px 0; font-size: 13px; color: #8a5a00;
  background: #fff5e0; border: 1px solid #ffe2a8; border-radius: 10px; padding: 8px 10px;
}

/* Detail */
.back {
  background: none; color: var(--accent); border: none; padding: 12px 8px;
  font-weight: 600; margin-bottom: 4px; min-height: 44px;
}
.detail-head { display: flex; gap: 14px; align-items: center; margin: 6px 0 14px; }
.detail-head .swatch { width: 64px; height: 64px; }
.detail-head h2 { margin: 0; font-size: 22px; }
.detail-head .sub { color: var(--muted); margin-top: 3px; }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 22px 2px 8px; }
/* Ticket-form section titles are <h3> for heading navigation — neutralise the UA bold/size. */
h3.section-title { font-weight: inherit; }
#status { scroll-margin-top: 72px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #eef2f7; border: 1px solid var(--line); border-radius: 999px; padding: 9px 13px; font-size: 14px; min-height: 40px; display: inline-flex; align-items: center; }

.revs { display: grid; gap: 8px; }
.rev {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden;
}
.rev-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px; cursor: pointer; gap: 10px;
}
.rev-head .t { font-weight: 600; }
.rev-head .d { color: var(--muted); font-size: 13.5px; }
.rev-body { padding: 0 12px 12px; }

table.comp { width: 100%; border-collapse: collapse; }
table.comp th, table.comp td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); font-size: 14.5px; vertical-align: middle; }
table.comp th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.tnr { display: flex; align-items: center; gap: 9px; }
.tdot { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); flex: none; }
.bar { height: 6px; border-radius: 999px; background: #e6ebf2; margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }

/* Toast */
.toast {
  /* Top-anchored so the mobile keyboard (which covers the bottom during ticket
     save) can't hide it; sits just below the app bar. */
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 64px); bottom: auto;
  transform: translateX(-50%);
  background: #1d2734; color: #fff; padding: 11px 16px; border-radius: 12px;
  box-shadow: var(--shadow); font-size: 14px; max-width: 90%; z-index: 50;
}

.empty { text-align: center; color: var(--muted); margin-top: 36px; }
.muted { color: var(--muted); }

/* Color-family browse chips */
.families { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.fam {
  background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 999px;
  padding: 11px 12px 11px 11px; font-size: 13.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 7px; min-height: 44px;
}
.fam:active { background: #f1f5fb; }
.fdot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.18); }

/* Recent */
.recent { margin-top: 18px; }
.recent-colors { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
.rc { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 86px; scroll-snap-align: start; }
.rc-sw { width: 64px; height: 46px; border-radius: 8px; border: 1px solid rgba(0,0,0,.12); background: repeating-conic-gradient(#e9edf3 0% 25%, #fff 0% 50%) 50% / 12px 12px; }
.rc-code { font-size: 12.5px; font-weight: 600; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge.sm { font-size: 10.5px; padding: 1px 7px; margin-left: 0; }

/* Detail swatch + mixing */
.swatch.big { width: 64px; height: 64px; border-radius: 12px; }
.mixbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 10px 12px; margin-bottom: 10px;
}
.mix-label { font-weight: 600; }
.mix-in { width: 92px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; font: inherit; text-align: right; -webkit-appearance: none; }
.mix-unit { padding: 9px 8px; }
.mix-dp { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.mix-dp input { width: 16px; height: 16px; }
.mix-hint { color: var(--muted); font-size: 12.5px; flex-basis: 100%; }

.layer-title { font-weight: 600; font-size: 14px; margin: 10px 2px 6px; color: var(--navy-2); }

.comp-actions { display: flex; justify-content: space-between; align-items: center; padding: 2px 2px 6px; font-size: 13px; }
.mini { background: #eef4fe; color: var(--accent); border: 1px solid #d4e4fb; border-radius: 8px; padding: 10px 14px; font-size: 13px; font-weight: 600; min-height: 44px; }

table.comp td.num, table.comp th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 8px; }
table.comp td.pct { color: var(--muted); }
table.comp td.amt { font-weight: 600; }
table.comp tfoot td { border-top: 2px solid var(--line); font-weight: 600; font-size: 13px; color: var(--ink); }
table.comp tfoot td.num { color: var(--ink); }

/* Multi-field search form */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 8px 0; }
.fld { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 8px; min-width: 0; }
.grid2 .fld, .grid3 .fld { margin-bottom: 0; }
.fld input, .fld select { font-size: 16px; font-weight: 400; color: var(--ink); text-transform: none; letter-spacing: 0; width: 100%; min-width: 0; }
.fld.sm select { font-size: 14px; }
.ac-wrap { position: relative; }
.ac-wrap .suggest { position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px; z-index: 30; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 2px; }
.ghost { background: #fff; color: var(--muted); border: 1px solid var(--line); font-weight: 600; }
.ghost:active { background: #f1f5fb; }

/* Toggleable chips (variant brand filter) */
.chip { cursor: pointer; }
.chip.on { background: #e8f0fb; border-color: #cfe0f6; color: var(--navy-2); }
.var-brands { margin-bottom: 10px; }

/* Variant strip */
.variant-list { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
.vcard { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 92px; scroll-snap-align: start; }
.vcard.cur { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47,128,237,.25); }
.vsw { width: 72px; height: 50px; border-radius: 8px; border: 1px solid rgba(0,0,0,.12); background: repeating-conic-gradient(#e9edf3 0% 25%, #fff 0% 50%) 50% / 12px 12px; }
.vcode { font-size: 12.5px; font-weight: 600; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vdesc { font-size: 11px; font-weight: 600; color: var(--navy-2); max-width: 104px; text-align: center; line-height: 1.2; }
.vbrand { font-size: 10.5px; color: var(--muted); max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Cross-brand selector in the components header */
.comp-actions { gap: 8px; }
.ca-right { display: inline-flex; align-items: center; gap: 8px; }
.brandsel { font-size: 13px; padding: 6px 26px 6px 9px; border: 1px solid var(--line); border-radius: 8px; background-color: #fff; }

/* Detail header meta + formula notes */
.dmeta { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.form-notes { margin-top: 10px; padding: 10px 12px; background: #fbfaf4; border: 1px solid #efe9d4; border-radius: 10px; font-size: 13.5px; color: #5a4f2e; }
.form-notes strong { color: #7a6a36; margin-right: 6px; }

/* PPG sparkle/texture image next to the swatch */
.texture { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; border: 1px solid rgba(0,0,0,.14); flex: none; }

/* Detail top bar (back + share) */
.detail-top { display: flex; align-items: center; gap: 12px; }
.share.back { margin-left: auto; }

/* Print: a clean formula ticket (screen-hidden; only this prints) */
.print-area { display: none; }
@media print {
  .appbar, #main, #toast, .preview-close { display: none !important; }
  .print-area { display: block !important; padding: 10px 14px; color: #000; font: 12pt/1.4 -apple-system, Arial, sans-serif; }
}
.preview-close { margin: 0 0 10px; }
.print-area .p-title { font-size: 16pt; font-weight: 700; }
.print-area .p-sub { color: #333; font-size: 10pt; margin-top: 2px; }
.print-area .p-mix { margin: 9px 0; font-size: 11pt; font-weight: 600; }
.print-area .p-tbl { width: 100%; border-collapse: collapse; margin-top: 4px; }
.print-area .p-tbl th, .print-area .p-tbl td { border-bottom: 1px solid #ccc; padding: 5px 6px; text-align: left; font-size: 10.5pt; }
.print-area .p-tbl td.r, .print-area .p-tbl th.r { text-align: right; white-space: nowrap; }
.print-area .p-tbl tfoot td { font-weight: 700; border-top: 2px solid #000; border-bottom: none; }
.print-area .p-notes { margin-top: 10px; font-size: 10pt; }
.print-area .p-foot { margin-top: 16px; font-size: 9pt; color: #888; }

/* Ticket label (print) */
.print-area .tl { font: 11pt/1.35 -apple-system, Arial, sans-serif; color: #000; }
.print-area .tl-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 8px; }
.print-area .tl-no { font-size: 20pt; font-weight: 800; }
.print-area .tl-cust { font-size: 13pt; font-weight: 600; }
.print-area .tl-qr { width: 100px; height: 100px; }
.print-area .tl-row { display: flex; gap: 8px; padding: 2px 0; font-size: 11pt; }
.print-area .tl-k { flex: 0 0 70px; color: #555; font-weight: 600; }
.print-area .tl-notes { margin-top: 8px; padding-top: 6px; border-top: 1px solid #ccc; font-size: 10.5pt; }

/* Tabs. With every admin tab visible the row outgrows a phone screen, so the bar
   scrolls horizontally instead of pushing past the layout: tabs never shrink below
   their label (no wrap), and the overflow pans (scrollbar hidden). */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px; box-shadow: var(--shadow); overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1 0 auto; white-space: nowrap; background: none; border: none; color: var(--muted); font-weight: 600; padding: 14px 10px; border-radius: 9px; min-height: 44px; }
.tab.active { background: var(--navy); color: #fff; }

/* Print agent (admin) */
.agent-panel { margin: 8px 0 14px; }
.agent-pkg { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.agent-pkg-name { font-weight: 600; }
.agent-steps { margin: 6px 2px; padding-left: 22px; color: var(--ink); font-size: 14px; line-height: 1.6; }
.agent-steps code, .agent-panel code { background: #eef2f7; border-radius: 5px; padding: 1px 5px; font-size: 13px; }

/* Login */
.login { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; max-width: 420px; margin: 8px auto; }
.login h2 { margin: 0 0 4px; }
.login .hint { margin-top: 0; }
.login .fld { margin-bottom: 12px; }

/* Tickets */
.who { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.linkbtn { background: none; border: none; color: var(--accent); font-weight: 600; }
.ticket-toggles { display: flex; gap: 18px; margin: 6px 2px 8px; flex-wrap: wrap; }
.chk { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--ink); min-height: 40px; }
.chk input[type="checkbox"] { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.card.ticket .code { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card.t-done { background: #f3faf4; }
.card.t-hidden { background: #f4f4f6; opacity: .72; }
.card.t-overdue { background: #fdf3f2; }
.badge.ok { background: #e3f4e6; color: #277a37; }
.badge.warn { background: #fdeee0; color: #9a5a12; }

/* Ticket detail */
.tdetail { margin-top: 10px; }
.trow { display: flex; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.trow .tk { flex: 0 0 110px; color: var(--muted); font-size: 13px; font-weight: 600; }
.trow .tv { flex: 1; min-width: 0; }
.ticket-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 6px; }
.print-station { display: flex; align-items: center; gap: 8px; margin: 4px 2px 8px; font-size: 13px; flex-wrap: wrap; }
.who-actions { display: inline-flex; gap: 12px; align-items: center; }
.fld textarea { font: inherit; font-size: 16px; color: var(--ink); width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; resize: vertical; }
#ticketFormView .section-title { margin-top: 14px; }

/* Brand toggle bar (multi-select on/off) */
.brand-bar { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.brand-bar-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; padding-top: 8px; flex: none; }
.brand-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.brand-toggle { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; font-size: 13px; font-weight: 600; min-height: 44px; }
.brand-toggle.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.brand-toggle:active { transform: translateY(1px); }

/* "+N more" / show-less chip for collapsed lists */
.more-chip { cursor: pointer; color: var(--accent); border-color: #cfe0f6; background: #eef4fe; font-weight: 600; }

/* Ticket edit history (audit log) */
.ticket-history { margin-top: 16px; }
.ticket-history .section-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin: 0 0 8px; }
.thistory { display: flex; flex-direction: column; gap: 8px; }
.hrow { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: #fbfcfe; }
.hhead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.hact { font-weight: 700; font-size: 13px; color: var(--ink); }
.hwhen { font-size: 12px; color: var(--muted); white-space: nowrap; }
.hwho { font-size: 13px; color: var(--ink); margin-top: 2px; }
.hwho .hid { color: var(--muted); font-size: 12px; }
.hchanges { font-size: 12.5px; color: var(--muted); margin-top: 4px; white-space: pre-wrap; word-break: break-word; }

/* Ticket photos (mobile camera capture) */
.ticket-photos, .ef-photos { margin-top: 14px; }
.photo-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.photo-thumb { position: relative; width: 92px; height: 92px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #eef2f7; flex: none; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.photo-del { position: absolute; top: 3px; right: 3px; width: 26px; height: 26px; min-height: 0; padding: 0; border-radius: 50%; border: none; background: rgba(20,30,45,.72); color: #fff; font-size: 17px; line-height: 1; font-weight: 700; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-add { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.photo-add.busy { opacity: .6; pointer-events: none; }

/* VIN field: the input sits on one row with the camera + decode buttons. Monospace
   and uppercase because operators read a VIN back against the plate character by
   character — a proportional font makes 8/B and 5/S harder to tell apart, which is
   exactly the confusion we're trying to catch. */
.vin-row { display: flex; gap: 8px; align-items: stretch; }
.vin-row input { flex: 1 1 auto; min-width: 0; text-transform: uppercase; letter-spacing: .5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.vin-row .mini { flex: 0 0 auto; white-space: nowrap; }
.vin-status { font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0; line-height: 1.45; color: var(--muted); margin-top: 4px; }
.vin-status.ok { color: #157347; }
.vin-status.warn { color: #9a6700; }
.vin-status.error { color: var(--danger); }
.vin-status .vin-veh { font-weight: 700; }
.vin-status .mini { margin-top: 6px; min-height: 36px; padding: 6px 12px; }

/* Users & logins (admin) */
.user-table { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.user-main { flex: 1 1 auto; min-width: 0; }
.user-name { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-sub { font-size: 12px; margin-top: 2px; }
.user-acts { display: flex; gap: 6px; flex: 0 0 auto; }
.pill { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 2px 8px; border-radius: 999px; background: #eef4fe; color: var(--accent); }
.pill-admin { background: #fde8cf; color: #9a5b00; }
.pill-off { background: #f3d6d6; color: var(--danger); }
.user-dialog { border: none; border-radius: 16px; padding: 0; max-width: 26rem; width: calc(100vw - 32px); box-shadow: 0 12px 48px rgba(0,0,0,.3); }
.user-dialog::backdrop { background: rgba(10,16,24,.55); }
.user-dialog .search-panel { margin: 0; }
.user-dialog h3 { margin: 0 0 12px; }

/* Full-screen sign-in wall (external visitors only). */
.auth-wall { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
             padding: calc(env(safe-area-inset-top) + 20px) 20px 20px; background: var(--bg, #0f1621); }
.auth-card { width: 100%; max-width: 22rem; background: var(--card, #fff); border-radius: 16px; padding: 28px 24px;
             box-shadow: 0 12px 40px rgba(0,0,0,.28); }
.auth-brand { display: flex; align-items: center; gap: 8px; font-size: 1.4rem; font-weight: 800; letter-spacing: .01em; }
.auth-brand .logo { color: var(--accent); }
.auth-sub { color: var(--muted); margin: 6px 0 18px; }
.auth-card .form-actions { margin-top: 4px; }
.auth-card .form-actions button { width: 100%; }
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.86); display: flex; align-items: center; justify-content: center; padding: calc(env(safe-area-inset-top) + 12px) 12px 12px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* Temp Formula (scratch) editor */
.scratch-intro { margin-bottom: 6px; }
#scratchCapture { margin: 10px 0; }
.sc-head { margin-top: 6px; }
.sc-note { font-size: 12.5px; color: #8a5a00; background: #fff5e0; border: 1px solid #ffe2a8; border-radius: 8px; padding: 7px 10px; margin: 8px 0; }
table.comp.scratch td, table.comp.scratch th { vertical-align: top; }
.sc-tnr { min-width: 0; }
.sc-tnr-fields { display: flex; flex-direction: column; min-width: 0; gap: 3px; }
.sc-code { font: inherit; font-size: 14px; width: 100%; max-width: 140px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); }
.sc-nm { font-size: 12.5px; color: var(--muted); }
.sc-wt-note { font-size: 11px; color: var(--muted); font-style: italic; margin-top: 1px; text-align: right; line-height: 1.3; }
.sc-wt-note s { opacity: .75; }
.sc-flag { font-weight: 700; color: var(--danger); margin-left: 3px; cursor: help; }
.sc-flag.low { color: #9a5a12; }
.sc-cands { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.sc-cand { background: #eef4fe; color: var(--accent); border: 1px solid #d4e4fb; border-radius: 7px; padding: 4px 8px; font-size: 12px; font-weight: 600; min-height: 0; }

/* toner availability (admin) */
.toners-head h2 { margin: 0 0 4px; }
.toner-filter { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.toner-filter input[type=search] { flex: 1 1 220px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font: inherit; }
.toner-filter select { padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font: inherit; }
.toner-bulk { display: flex; align-items: center; gap: 10px; margin: 8px 0; padding: 8px 10px; background: #f4f7fc; border: 1px solid var(--line); border-radius: 9px; position: sticky; top: 0; z-index: 2; }
.toner-tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.toner-tbl th, .toner-tbl td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--line); }
.toner-tbl th { color: var(--muted); font-weight: 600; }
.toner-tbl .tn-chk { width: 34px; }
.toner-tbl .tn-chk input { width: 18px; height: 18px; }
.toner-tbl tr.tn-off td { color: var(--muted); background: #fafafa; }
.tn-toggle { border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 700; cursor: pointer; min-height: 0; }
.tn-toggle.on { background: #e7f6ec; color: #1c7a3e; border-color: #bfe6cd; }
.tn-toggle.off { background: #fdecec; color: #a32020; border-color: #f3c9c9; }
.sc-sugg { list-style: none; margin: 4px 0 0; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: var(--shadow); position: relative; z-index: 5; max-height: 240px; overflow: auto; }
.sc-sugg li { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 7px; cursor: pointer; }
.sc-sugg li:hover { background: #eef4fe; }
.sc-sugg .code { font-weight: 600; }
.sc-sugg .nm { color: var(--muted); font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-g { width: 80px; font: inherit; font-size: 14px; text-align: right; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; -webkit-appearance: none; color: var(--ink); }
.sc-d { width: 66px; font: inherit; font-size: 13px; text-align: right; padding: 7px 6px; border: 1px solid var(--line); border-radius: 8px; -webkit-appearance: none; color: var(--ink); }
.sc-d.def { border-color: #f0c98a; background: #fff8ee; color: #9a5a12; }
.sc-del { background: none; color: var(--muted); border: none; font-size: 15px; padding: 4px 6px; min-height: 0; }
.sc-summary { margin: 10px 2px; font-size: 13px; }

/* Predicted-colour strip on the Temp Formula page: per-angle bands from
   /api/scratch/predict, always labelled a prediction; dimmed when stale. */
.sc-predict { margin: 8px 0; }
.sc-predict.stale .sc-predict-strip { opacity: 0.45; }
.sc-predict-strip { display: flex; height: 56px; border: 1px solid #999; border-radius: 6px; overflow: hidden; max-width: 460px; }
.sc-predict-band { flex: 1; position: relative; }
.sc-predict-angle { position: absolute; bottom: 2px; left: 4px; font-size: 10.5px; color: rgba(255,255,255,0.85); text-shadow: 0 0 3px rgba(0,0,0,0.8); }
.sc-adj { display: grid; gap: 6px; }
.sc-adj-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fbfaf4; border: 1px solid #efe9d4; border-radius: 8px; padding: 8px 10px; font-size: 13.5px; color: #5a4f2e; }
.sc-adj-row.done { opacity: .5; }
.sc-adj-txt { min-width: 0; }
.sc-check { margin: 4px 2px 2px; font-size: 13px; border-radius: 8px; padding: 7px 10px; }
.sc-check.ok { color: #277a37; background: #e9f7ec; border: 1px solid #c4e8cd; }
.sc-check.warn { color: #9a5a12; background: #fdeee0; border: 1px solid #f6d8b3; }
.sc-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 6px; }

/* Narrow phones: relax tables, stack action rows + 2-up grids full-width */
@media (max-width: 480px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  table.comp { font-size: 13px; }
  table.comp th, table.comp td { padding: 6px 4px; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions button { width: 100%; }
  .ticket-actions { flex-direction: column; }
  .ticket-actions button { width: 100%; }
  /* Keep the batch qty and unit side by side on phones: qty left, unit right. */
  .mixbar { flex-wrap: wrap; align-items: center; }
  .mix-label { flex: 0 0 100%; }
  .mix-in { flex: 1 1 40%; width: auto; text-align: left; }
  .mix-unit { flex: 1 1 40%; width: auto; }
  .mix-hint, .mix-dp { flex: 0 0 100%; }
  .sc-code { max-width: 100%; }
  .sc-g { width: 66px; }
  .sc-actions button { flex: 1 1 40%; }
}

/* Temp Formula Settings (bottom of the page) */
.sc-prefs { margin-top: 18px; padding-top: 8px; border-top: 1px solid var(--line); }
.sc-prefs summary { cursor: pointer; font-weight: 600; color: var(--muted); padding: 6px 0; }
.sc-prefs label { display: flex; align-items: center; gap: 8px; padding: 8px 2px; min-height: 44px; }
.sc-prefs input[type="checkbox"] { width: 18px; height: 18px; }

/* Promote-to-Library dialog (admin) */
.promote-dlg { border: none; border-radius: 12px; padding: 0; box-shadow: 0 10px 40px rgba(0,0,0,.35); max-width: 92vw; }
.promote-dlg::backdrop { background: rgba(0,0,0,.4); }
.promote-form { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; width: 340px; max-width: 92vw; }
.promote-form h3 { margin: 0 0 4px; }
.promote-form .fld { display: flex; flex-direction: column; gap: 4px; }
.promote-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.muted.small { font-size: .82em; margin: 2px 0 0; }

/* ---- 3D paint viewer (View in 3D) ---- */
.view3d-btn {
  margin-top: 8px;
  padding: 6px 14px;
  border: 1px solid var(--accent, #3b82f6);
  border-radius: 8px;
  background: var(--accent, #3b82f6);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.view3d-btn:hover { filter: brightness(1.08); }
.view3d-btn:disabled {
  background: #9aa3ad; border-color: #9aa3ad; opacity: .65;
  cursor: not-allowed; filter: none;
  pointer-events: auto;   /* override the global disabled rule so the title tooltip (the unavailability reason) still shows */
}

.v3d-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: none; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.62);
  padding: 16px;
}
.v3d-box {
  width: min(96vw, 1120px); height: min(92vh, 800px);
  display: flex; flex-direction: column;
  background: #1e1e1e; border-radius: 12px; overflow: hidden;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}
.v3d-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; background: #2a2a2a; color: #eee; font-weight: 600;
}
.v3d-close {
  background: none; border: none; color: #ddd; font-size: 18px;
  line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.v3d-close:hover { background: rgba(255, 255, 255, 0.12); }
.v3d-body { position: relative; flex: 1; background: #808080; }
.v3d-frame { width: 100%; height: 100%; border: 0; display: none; }
.v3d-status {
  position: absolute; inset: 0; margin: 0;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: #f0f0f0; text-align: center; padding: 24px;
}

/* ---- Quick Pick (guided search) ---- */
.qp-title { margin: 12px 2px 4px; font-size: 18px; }
/* ★ Prime accents share the amber family used by .capped / .sc-note. */
.card.prime { border-color: #e8b84b; box-shadow: inset 0 0 0 1px #e8b84b, var(--shadow); }
.badge.prime { background: #fff5e0; border: 1px solid #ffe2a8; color: #8a5a00; }
.qp-rating { color: #8a5a00; font-weight: 600; font-size: 13px; margin-left: 6px; }
.card .code .qp-rating { vertical-align: 1px; }
.qp-print { font-style: italic; }
.qp-decks { overflow-wrap: anywhere; }
/* "Formula(s)" section title with the ★ Rate match button on the right. */
.section-title.fx { display: flex; align-items: center; justify-content: space-between; }
.section-title.fx .rate-btn { text-transform: none; letter-spacing: normal; font-size: 14px; }
/* Match-quality pills in the rating dialog. */
.rate-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.rate-pill {
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink); padding: 8px 14px; min-height: 44px; font-size: 15px;
}
.rate-pill.on { background: #fff5e0; border-color: #e8b84b; color: #8a5a00; font-weight: 700; }

/* ---- Toner conversions admin + converted-components view ---- */
/* Narrow phones: the actions row (brand picker + Print/Copy/label buttons) wraps
   instead of clipping unreachable past the card's overflow:hidden. */
.comp-actions { flex-wrap: wrap; row-gap: 6px; }
/* "replaces X" line under a converted toner row: small detail text. */
.cv-was { font-size: 12.5px; }
/* Right-align numeric columns in the admin tables (the .num rule is scoped to table.comp). */
.toner-tbl th.num, .toner-tbl td.num { text-align: right; }
/* The rules table can outgrow a phone viewport, especially in edit mode. */
#convList { overflow-x: auto; }
.cv-notes-edit { width: 140px; }

/* ============================== Desktop layout ==============================
   Phone-first stays the default; everything below is ADDITIVE for wide screens.
   Every block is scoped `screen and (min-width: ...)` — a bare min-width query
   also matches wide PRINT viewports (landscape letter ~1056 CSS px) and would
   leak into the printouts. Never restyle .print-area / .p-* / .tl-* here, and
   never set display with !important (the [hidden] view switcher must win). */

@media screen and (min-width: 1024px) {
  main, .appbar-inner { max-width: 1240px; }

  /* Formulas: search form left, results right. */
  #searchView { display: grid; grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
                grid-template-areas: "form status" "form results" "recent results";
                column-gap: 24px; align-items: start; }
  #searchForm { grid-area: form; }
  #status { grid-area: status; }
  #results { grid-area: results; }
  #recent { grid-area: recent; }
  #recent .recent-colors { flex-wrap: wrap; overflow-x: visible; }

  /* Color detail: revision cards side by side; variants wrap instead of panning. */
  #detail .revs { grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); align-items: start; }
  #detail .variant-list { flex-wrap: wrap; overflow-x: visible; }
  #detail table.comp { max-width: 860px; }

  /* Temp Formula: one 4-up header row; keep grams near toner names. */
  #scratchEditor .sc-head { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  #scratchEditor .sc-head .grid2 { display: contents; }
  #scratchEditor table.comp.scratch { max-width: 900px; }
  #scratchEditor .sc-code { max-width: 260px; }
  #scratchEditor .sc-g { width: 110px; }
  #scratchEditor .sc-d { width: 90px; }
  .sc-predict-strip { max-width: 640px; }

  /* Tickets: mirrors the Formulas two-pane. */
  #ticketsPane { display: grid; grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
                 grid-template-areas: "who who" "form status" "form results";
                 column-gap: 24px; align-items: start; }
  #ticketsPane .who { grid-area: who; }
  #ticketForm { grid-area: form; }
  #tStatus { grid-area: status; }
  #ticketResults { grid-area: results; }

  /* Long entry forms read badly at full width — keep them a centered column. */
  #ticketFormView { max-width: 860px; margin: 0 auto; }

  /* Quick Pick: card grids. */
  #qpIdentities, #qpLines, #qpOptions { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
  #qpIdentities > .empty, #qpLines > .empty, #qpOptions > .empty { grid-column: 1 / -1; }
  #qpForm { max-width: 720px; }

  /* Admin tables: keep the filter rows sane inside the wide main. */
  .toner-filter { max-width: 900px; }
  .toner-filter input[type=search] { max-width: 420px; }
  #convAdd { max-width: 900px; }
  .cv-notes-edit { width: 280px; }

  /* Saved Colours: multi-column cards (420px keeps the buttons off the meta text). */
  #scColList.results { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); align-items: start; }
  #scColList > .empty { grid-column: 1 / -1; }

  #userAdd { max-width: 860px; }

  /* Print Agent instructions: prose column, ~90 chars. */
  #agentView { max-width: 820px; margin: 0 auto; }
}

@media screen and (min-width: 1000px) {
  /* Ticket detail: key/value rows flow into two newspaper columns. */
  #ticketDetail { max-width: 1000px; margin: 0 auto; }
  #ticketDetail .tdetail { columns: 2; column-gap: 48px; }
  #ticketDetail .trow { break-inside: avoid; }
  #ticketDetail .photo-thumb { width: 128px; height: 128px; }
  #ticketDetail .thistory { max-width: 720px; }
}

@media screen and (min-width: 1100px) {
  /* Users: rows two-up (base is a flex column; grid here is additive). */
  .user-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 8px; }
}

@media screen and (min-width: 1400px) {
  /* Very wide screens: result cards flow into columns. */
  #results.results { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  #results > .capped, #results > .empty { grid-column: 1 / -1; }
  #ticketResults.results { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
  #ticketResults > .empty { grid-column: 1 / -1; }
}

/* Search & Correct (bench console). All inside #main, so print CSS never sees it. */
.snc-strip-wrap { margin: 10px 0 4px; }
.snc-strip-cap { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.snc-strip { display: flex; gap: 2px; overflow-x: auto; }
.snc-cell { flex: 1 0 46px; min-width: 46px; text-align: center; }
.snc-swatch { height: 40px; border-radius: 6px; border: 1px solid rgba(0,0,0,.15); }
.snc-lab { font-size: 10.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.snc-results-cap { margin: 12px 4px 2px; font-size: 13px; color: var(--muted); }
.snc-cmp { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 12px; }
.snc-cmp-row { display: grid; grid-template-columns: 88px 1fr 1fr 54px; gap: 8px; align-items: center; padding: 4px 0; border-top: 1px solid var(--line); }
.snc-cmp-row:first-child { border-top: none; }
.snc-cmp-head { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.snc-cmp-label { font-size: 13px; white-space: nowrap; }
.snc-cmp-sw { display: block; height: 30px; border-radius: 6px; border: 1px solid rgba(0,0,0,.15); }
.snc-cmp-miss { color: var(--muted); text-align: center; }
.snc-cmp-de { font-weight: 600; text-align: right; }
.snc-cmp-de.good { color: #1e7d32; }

/* ==================== PC workbench (>=1200px, screen only) ====================
   Not responsive widening: on a PC the app works like the desktop program —
   persistent side-by-side panels and dense sortable tables. All render-time
   branched in JS (isPc()); these rules only lay the furniture out. */

/* Shared sortable data table (Formulas results, S&C results). */
.pc-table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow-x: auto; }
table.pc-table { width: 100%; border-collapse: collapse; }
.pc-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
.pc-table th.sorted { color: var(--navy-2); }
.pc-table td { padding: 7px 8px; border-top: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
.pc-table tbody tr { cursor: pointer; }
.pc-table tbody tr:hover { background: #f4f8fd; }
.pc-table tbody tr.selected { background: #e8f0fb; }
.pc-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pc-table .sw { width: 30px; height: 30px; border-radius: 7px; border: 1px solid rgba(0,0,0,.14); background: repeating-conic-gradient(#e9edf3 0% 25%, #fff 0% 50%) 50% / 10px 10px; }
.pc-table .good { color: #1e7d32; font-weight: 600; }

@media screen and (min-width: 1200px) {
  /* Desktop tab bar: left-packed buttons, not full-width stretchers. */
  .tabs { justify-content: flex-start; }
  .tab { flex: 0 1 auto; padding: 14px 26px; }

  /* S&C three-panel workbench: jobs | job + search + results | compare. */
  #sncView { display: grid; grid-template-columns: 300px minmax(0, 1fr) 400px; gap: 18px; align-items: start; }
  #sncJobBack, #sncCompareBack { display: none; }
  #sncJobsPane .card { padding: 9px 10px; gap: 8px; }
  #sncJobsPane .card .code { font-size: 14.5px; }
  #sncJobsPane .card .sub { font-size: 12px; }
  #sncJobsPane .card.selected { outline: 2px solid var(--accent); outline-offset: -2px; }
  #sncJobsForm .grid2 { grid-template-columns: 1fr auto; align-items: end; }

  /* The search panel reads as ONE toolbar row (wrapping when it must). */
  #sncSearchForm { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
  #sncSearchForm .grid2 { display: contents; }
  #snc_brand { min-width: 210px; }
  #snc_code { width: 170px; }
  #snc_make { width: 190px; }
  #sncView .ticket-toggles label { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; min-height: 46px; }
  #sncSearchForm .form-actions { margin: 0 0 0 auto; }

  /* Target strip bands stretch across the panel. */
  .snc-cell { flex: 1 1 46px; }

  /* Compare dock: pinned while the results scroll, its own scrollbar when tall. */
  #sncComparePane { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; }
  .snc-placeholder { color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: 12px; padding: 22px 16px; text-align: center; }

  /* Tables: dates/numbers never wrap; only designated text columns do. */
  .pc-table td { white-space: nowrap; }
  .pc-table td.wrap { white-space: normal; min-width: 140px; }
}

@media screen and (min-width: 1400px) {
  /* A real PC monitor gets a real working width — the 1240px cap is phone-era. */
  main, .appbar-inner { max-width: 1720px; }
  /* PC tables span the whole results area — never squeezed into the >=1400
     card-grid tracks (that squeeze made the table overlay its neighbors). */
  #results > li.pc-row, #ticketResults > li.pc-row { grid-column: 1 / -1; }
}

/* PC ticket-table row states (the card equivalents are .card.t-*). */
@media screen and (min-width: 1200px) {
  .pc-table tr.t-done td { background: #f2faf3; }
  .pc-table tr.t-hidden td { background: #f5f5f6; color: var(--muted); }
  .pc-table tr.t-overdue td { background: #fdf3f2; }
  .pc-table tr.t-done:hover td, .pc-table tr.t-hidden:hover td, .pc-table tr.t-overdue:hover td { filter: brightness(.98); }
}

/* S&C correction dock */
#sncCorrResult table.comp { margin-top: 6px; }
.snc-run { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-top: 6px; font-size: 13.5px; cursor: pointer; }
.snc-run:hover { background: #f4f8fd; }
.snc-run-fail { border-color: #e7c4c1; }

/* S&C search knobs */
.snc-knobs { margin-top: 8px; }
.snc-knobs summary { color: var(--muted); font-size: 13px; cursor: pointer; padding: 4px 2px; }
.snc-knobs .grid2 { margin-top: 6px; }

/* Binder / Ready-to-spray section in the formula viewer (phone-first; no wide-media rules) */
.binderbox { margin-top: 14px; }
.binderbox .section-title { margin-bottom: 4px; }
.binder-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 6px 0 8px; }
.rts-vol { width: 90px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); font: inherit; }

/* ==================== Tickets Priority (triage) mode ====================
   Phone-first action board: sections of big cards, each with two 56px tap
   actions (Finished / New ETA). Tablet+PC get more columns via auto-fill —
   same board, wider. The New ETA sheet is a native <dialog>: bottom-anchored
   on touch, centered on desktop. */

.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; margin: 0 0 12px; max-width: 420px; }
.seg .seg-btn { flex: 1; background: transparent; border: none; color: var(--muted); font-weight: 600; font-size: 15px; padding: 10px 0; border-radius: 9px; min-height: 44px; }
.seg .seg-btn.active { background: var(--card); color: var(--navy); box-shadow: 0 1px 3px rgba(17, 48, 78, .18); }

.tri-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.tri-chip { display: inline-flex; align-items: center; gap: 7px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 600; }
.tri-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.tri-dot.red { background: #c62f2f; }
.tri-dot.gold { background: #d9a412; }
.tri-dot.orange { background: #d97b12; }
.tri-dot.blue { background: var(--accent); }

.tri-sect { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 16px 2px 8px; }
.tri-sect .n, details.tri-rest summary .n { font-weight: 600; letter-spacing: 0; color: #8a94a6; margin-left: 4px; }
/* min(330px,100%) keeps one full-width track on narrow phones (360px CSS width
   minus main padding is 328px — a bare 330px minimum would overflow sideways). */
.tri-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); align-items: start; }

.tri-card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; cursor: pointer; }
.tri-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.tri-card.st-red::before { background: #c62f2f; }
.tri-card.st-gold::before { background: #d9a412; }
.tri-card.st-orange::before { background: #d97b12; }
.tri-card.st-blue::before { background: var(--accent); }
.tri-card.st-grey::before { background: #b6c0d2; }
.tri-main { padding: 11px 12px 9px 16px; }
.tri-r1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tri-r1 .tri-who { font-weight: 700; font-size: 15.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tri-r1 .tri-who .no { color: var(--muted); font-weight: 600; }
.tri-badges { flex: none; display: inline-flex; gap: 6px; align-items: center; }
.tri-badge { flex: none; font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.tri-badge.red { background: #fbe3e1; color: #a3231c; }
.tri-badge.orange { background: #fdecd8; color: #99560b; }
.tri-badge.gold { background: #faf0cf; color: #8a6a06; }
.tri-badge.blue { background: #e3edfc; color: #1d5cb3; }
.tri-badge.grey { background: #eef1f5; color: var(--muted); }
.tri-r2 { color: var(--muted); font-size: 13px; margin-top: 3px; }
.tri-r3 { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 5px; font-size: 12.5px; min-height: 18px; }
.tri-r3 .tri-pr { color: #8a5a00; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tri-r3 .tri-pr.quiet { color: var(--muted); font-weight: 500; }
/* Tap-to-call is the Call list's primary action: negative margins grow the hit
   area to ~44px without shifting the visual row. */
.tri-tel { color: var(--accent); font-weight: 700; text-decoration: none; white-space: nowrap; padding: 13px 12px; margin: -11px -12px -11px 0; }
.tri-tel-plain { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50%; flex: none; }

.tri-acts { display: flex; border-top: 1px solid var(--line); }
.tri-acts .tri-act { flex: 1; min-height: 56px; background: transparent; border: none; border-radius: 0; font-weight: 700; font-size: 15px; padding: 0; }
.tri-act.done { color: #1e7d3e; border-right: 1px solid var(--line); }
.tri-act.eta { color: var(--accent); }
.tri-act:active { background: #f4f8fd; transform: none; }

details.tri-rest { margin-top: 18px; }
details.tri-rest summary { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); cursor: pointer; padding: 6px 2px; }
details.tri-rest .tri-cards { margin-top: 8px; }

.toast .toast-act { background: transparent; border: none; color: #8fd0ff; font-weight: 700; font-size: 14px; padding: 2px 6px; min-height: auto; margin-left: 4px; }

/* New ETA sheet: bottom sheet on touch widths… */
dialog.tri-sheet { border: none; width: 100%; max-width: none; margin: auto 0 0; border-radius: 22px 22px 0 0; padding: 16px 16px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(17, 48, 78, .25); background: var(--card); color: var(--ink); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; }
dialog.tri-sheet::backdrop { background: rgba(17, 48, 78, .45); }
.tri-sheet h3 { margin: 0 0 2px; font-size: 16px; }
.tri-was { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.tri-was.late { color: var(--danger); font-weight: 600; }
.tri-lab { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 14px 0 7px; }
.tri-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tri-pick { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); border-radius: 999px; padding: 10px 15px; font-size: 14px; font-weight: 600; min-height: 44px; }
.tri-pick.on { border-color: var(--accent); background: #e3edfc; color: #1d5cb3; }
.tri-date { margin-top: 8px; width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 10px; padding: 11px; background: var(--card); color: var(--ink); }
.tri-note { width: 100%; margin-top: 2px; font: inherit; border: 1px solid var(--line); border-radius: 10px; padding: 11px; background: var(--card); color: var(--ink); }
.tri-sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.tri-sheet-actions button { flex: 1; min-height: 52px; }
.tri-sheet-actions .ghost { flex: 0 1 36%; }

/* …and a centered modal on desktop widths. */
@media screen and (min-width: 1024px) {
  dialog.tri-sheet { width: 540px; max-width: 92vw; margin: auto; border-radius: 16px; padding-bottom: 18px; }

  /* The Priority board takes the full two-pane width under the mode toggle. */
  #ticketsPane { grid-template-areas: "who who" "mode mode" "form status" "form results" "triage triage"; }
  #tkModeSeg { grid-area: mode; }
  #triagePane { grid-area: triage; }
}

/* Pearl-concentrate toggle in the comp-actions bar */
.pearl-toggle{display:inline-flex;align-items:center;gap:4px;cursor:pointer}
.pearl-toggle input{margin:0;vertical-align:middle}
