
/* Admin-only controls are hidden for users. Cosmetic: the server enforces it. */
body:not(.is-admin) .admin-only { display: none !important; }

/* ==========================================================================
   SIGN-IN / SET-PASSWORD SCREEN
   ========================================================================== */
.auth-screen { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(360px, 1fr); background: var(--bg); }
.auth-art { position: relative; overflow: hidden; background: var(--panel2); border-right: 1px solid var(--line); }
/* The graphic: the image's shape, filled with the theme's soft grey. */
.auth-splat {
  position: absolute; inset: 12% 12% 18%; background: var(--splat);
  -webkit-mask: var(--splat-img) center / contain no-repeat; mask: var(--splat-img) center / contain no-repeat;
}
/* Overprint: cyan and magenta copies, slightly out of register. */
.auth-splat-c, .auth-splat-m { display: none; }
:root[data-decor] .auth-splat-c, :root[data-decor] .auth-splat-m { display: block; mix-blend-mode: var(--blend); opacity: .2; }
:root[data-decor] .auth-splat-c { background: var(--c); translate: -1.6% -1.2%; }
:root[data-decor] .auth-splat-m { background: var(--m); translate: 1.4% 1.1%; }
/* Sign-in animation (js/shell/auth-anim.js): the picture waits hidden while
   the dots gather, shakes on a wrong password, and an uploaded picture fades in. */
.auth-anim-wait .auth-splat { visibility: hidden; }
.auth-shake .auth-splat, .auth-shake .auth-anim-canvas { animation: auth-shake .32s cubic-bezier(.36,.07,.19,.97); }
@keyframes auth-shake { 20% { translate: -7px 0; } 40% { translate: 6px 0; } 60% { translate: -4px 0; } 80% { translate: 2px 0; } }
:root[data-decor] .auth-shake .auth-splat-c { animation-name: auth-shake-c; }
:root[data-decor] .auth-shake .auth-splat-m { animation-name: auth-shake-m; }
@keyframes auth-shake-c { 0%, 100% { translate: -1.6% -1.2%; } 20% { translate: calc(-1.6% - 7px) -1.2%; } 40% { translate: calc(-1.6% + 6px) -1.2%; } 60% { translate: calc(-1.6% - 4px) -1.2%; } 80% { translate: calc(-1.6% + 2px) -1.2%; } }
@keyframes auth-shake-m { 0%, 100% { translate: 1.4% 1.1%; } 20% { translate: calc(1.4% - 7px) 1.1%; } 40% { translate: calc(1.4% + 6px) 1.1%; } 60% { translate: calc(1.4% - 4px) 1.1%; } 80% { translate: calc(1.4% + 2px) 1.1%; } }
.auth-fade-in .auth-splat { animation: auth-fade-in .6s ease both; }
@keyframes auth-fade-in { from { opacity: 0; } }
:root[data-decor] .auth-fade-in .auth-splat-c, :root[data-decor] .auth-fade-in .auth-splat-m { animation-name: auth-fade-in-decor; }
@keyframes auth-fade-in-decor { from { opacity: 0; } to { opacity: .2; } }
.auth-burst { position: fixed; inset: 0; z-index: 1000; pointer-events: none; }
.auth-burst.fading { background: transparent !important; transition: background-color .45s ease .15s; }
@media (prefers-reduced-motion: reduce) {
  .auth-shake .auth-splat, .auth-fade-in .auth-splat { animation: none; }
  .auth-burst { display: none; }
}
.auth-org { position: absolute; left: 36px; bottom: 32px; right: 36px; }
.auth-org-name { font-family: var(--font-heading); font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.auth-caption { margin-top: 4px; font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

.auth-panel { display: grid; place-items: center; padding: 32px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 36px; }
.auth-card h1 { font-family: var(--font-display); font-size: 28px; font-weight: var(--display-weight, 700); margin-bottom: 6px; letter-spacing: -0.02em; }
.auth-card .lead { color: var(--muted); font-size: 14.5px; margin: 0 0 22px; }
.auth-card .input { min-height: var(--touch); }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.label-row > label { flex: 1; }
.label-row .linkish { font-size: 13px; }
.auth-help { margin-top: 8px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--panel2); border: 1px solid var(--line); font-size: 13.5px; color: var(--ink2); }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--touch); margin: 2px 0 6px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); margin: 0; }
.btn-ink { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-ink:hover { background: color-mix(in srgb, var(--ink) 86%, var(--bg)); }
.btn-block { width: 100%; min-height: 48px; font-weight: 600; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: 13px; }
.auth-links button { background: none; border: 0; padding: 0; color: var(--brand-quiet); font-weight: 600; cursor: pointer; }
.auth-links button:hover { text-decoration: underline; }
@media (max-width: 799px) {
  .auth-screen { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-art { min-height: 230px; border-right: 0; border-bottom: 1px solid var(--line); }
  .auth-splat { inset: 10% 30% 34% 30%; }
  .auth-org { left: 20px; bottom: 18px; }
  .auth-org-name { font-size: 18px; }
  .auth-panel { place-items: start center; padding: 26px 18px 40px; }
  .auth-top { margin-bottom: 22px; }
}
.auth-ok {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 13px; border-radius: var(--radius-sm);
  background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--line));
  color: var(--ink2); font-size: 14px;
}
.auth-ok svg { width: 18px; height: 18px; color: var(--ok); flex: none; margin-top: 1px; }
.auth-ok > div { flex: 1; min-width: 0; }   /* lets the link box truncate instead of overflowing the modal */

/* ==========================================================================
   USER CHIP (sidebar / topbar) & BELL
   ========================================================================== */
.userchip {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-top: 4px;
  border-radius: var(--radius-sm); background: var(--panel2); border: 1px solid var(--line);
}
.userchip .avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--brand-wash); color: var(--brand-quiet);
  font-family: var(--font-heading); font-weight: 700; font-size: 13px;
}
.userchip .u-name { font-weight: 600; font-size: 13.5px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userchip .u-role { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.userchip .u-text { min-width: 0; flex: 1; }
.userchip .btn-icon { width: 34px; min-height: 34px; }

.bell { position: relative; }
.bell .badge {
  position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--warn-fill); color: var(--on-warn); font-size: 10px; font-weight: 700;
  line-height: 16px; text-align: center; font-family: var(--font-mono);
}

/* Five tabs on mobile now. */
.tabbar { grid-template-columns: repeat(5, 1fr); }
.tab .badge { left: calc(50% + 7px); }

/* "More" sheet on mobile */
.sheet-list { display: flex; flex-direction: column; gap: 2px; }
.sheet-list button {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 10px;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink); font-size: 15px; font-weight: 500; text-align: left;
}
.sheet-list button svg { width: 20px; height: 20px; color: var(--ink2); }
.sheet-list button:hover { background: var(--panel2); }
.sheet-list hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* ==========================================================================
   ADMIN: users table + outbox
   ========================================================================== */
.subnav { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.subnav button {
  padding: 9px 12px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: none; color: var(--ink2); font-weight: 600; font-size: 14px;
}
.subnav button[aria-selected='true'] { color: var(--brand-quiet); border-bottom-color: var(--brand); }

.urow {
  display: grid; grid-template-columns: 1fr auto; gap: 10px 14px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
}
.urow.is-off { opacity: 0.72; background: var(--panel2); }
.urow .u-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.urow .avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--brand-wash); color: var(--brand-quiet); font-family: var(--font-heading); font-weight: 700; font-size: 14px;
}
.urow.is-off .avatar { background: var(--lost-soft); color: var(--lost); }
.urow .u-name { font-weight: 600; font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.urow .u-email { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.urow .u-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 559px) { .urow { grid-template-columns: 1fr; } .urow .u-actions { justify-content: flex-start; } }

.linkbox {
  display: flex; gap: 8px; align-items: center; margin-top: 12px; padding: 10px 12px;
  border-radius: var(--radius-sm); background: var(--panel2); border: 1px dashed var(--line2);
}
.linkbox code { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mail {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
}
.mail .m-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.mail .m-subject { font-weight: 600; }
.mail .m-meta { font-size: 12.5px; color: var(--muted); font-family: var(--font-mono); }
.mail .m-to { font-size: 13px; color: var(--ink2); margin-top: 2px; }
.mail pre {
  margin: 10px 0 0; padding: 10px 12px; border-radius: var(--radius-xs); background: var(--panel2);
  font: 12.5px/1.5 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink2);
}
.mail .m-state { font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 1px 7px; border-radius: 99px; }
.mail .m-state.sent { background: var(--ok-soft); color: var(--ok); }
.mail .m-state.queued { background: var(--caution-soft); color: var(--caution-text); }
.mail .m-state.failed { background: var(--warn-soft); color: var(--warn); }

/* ==========================================================================
   NOTIFICATIONS
   ========================================================================== */
.notif {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
}
.notif.unread { border-left: var(--stripe) solid var(--s, var(--brand)); background: color-mix(in srgb, var(--s-wash, var(--brand-wash)) 55%, var(--panel)); }
.notif .n-icon {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; margin-top: 1px;
  background: var(--s-wash, var(--panel2)); color: var(--s, var(--muted));
}
.notif .n-icon svg { width: 15px; height: 15px; }
.notif .n-msg { font-size: 14px; }
.notif .n-time { font-size: 12px; color: var(--muted); font-family: var(--font-mono); margin-top: 3px; }

/* ==========================================================================
   SERVICE DUE widget (dashboard) & tool service line
   ========================================================================== */
.svc-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.svc-item { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; flex-wrap: wrap; }
.svc-item .lbl { color: var(--muted); }

/* ==========================================================================
   BARCODES
   ========================================================================== */
.bc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.bc-card {
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  display: flex; flex-direction: column; gap: 8px;
}
.bc-card .bc-svg { background: var(--paper); border-radius: var(--radius-xs); padding: 8px 6px 4px; border: 1px solid var(--line); }
.bc-card .bc-svg svg { display: block; width: 100%; height: auto; }
.bc-card .bc-name { font-family: var(--font-heading); font-weight: 600; font-size: 14.5px; overflow-wrap: anywhere; }
.bc-card .bc-sn { font-family: var(--font-mono); font-size: 12px; color: var(--ink2); }
.bc-card .bc-ids { display: flex; justify-content: space-between; gap: 8px; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.bc-card .bc-actions { display: flex; gap: 6px; margin-top: 2px; }
.bc-card.retired { opacity: 0.7; }
.bc-card.retired .bc-svg { filter: grayscale(1); }

/* Barcode label print sheet (see print block in views.css for .p-*) */
@media print {
  .p-cell .p-bc svg { display: block; width: 100%; max-width: 58mm; height: auto; margin: 0 auto; }
  .p-grid.single .p-cell .p-bc svg { max-width: 80mm; }
  .p-cell .p-code { font-family: 'JetBrains Mono', monospace; font-size: 9pt; letter-spacing: 0.08em; }
}
