:root {
  --fs-scale: 1;
  --bg: #0f1117;
  --s1: #13161e;
  --s2: #181c26;
  --s3: #1f2535;
  --border: #2a3148;
  --border-strong: #343d5a;
  --amber: #f5a623;
  --amber-light: #f7c050;
  --amber-glow: rgba(245, 166, 35, 0.08);
  --amber-border: rgba(245, 166, 35, 0.25);
  --green: #22c55e;
  --green-glow: rgba(34, 197, 94, 0.08);
  --green-border: rgba(34, 197, 94, 0.25);
  --red: #f43f5e;
  --red-glow: rgba(244, 63, 94, 0.08);
  --red-border: rgba(244, 63, 94, 0.25);
  --text: #dce3f0;
  --text-soft: #7a8aaa;
  --muted: #4a5470;
  --grid-line: rgba(42, 49, 72, 0.3);
  --topbar-bg: rgba(15, 17, 23, 0.95);
  --row-hover: rgba(255, 255, 255, 0.03);
  --status-ok: #22c55e;
  --status-error: #f43f5e;
  --mono: "JetBrains Mono", monospace;
  --sans: "DM Sans", sans-serif;
}

html[data-theme="light"] {
  --bg: #f1f4fb;
  --s1: #ffffff;
  --s2: #f7f9ff;
  --s3: #eef2fb;
  --border: #cfd6e6;
  --border-strong: #b7c1d8;
  --amber-glow: rgba(245, 166, 35, 0.14);
  --amber-border: rgba(245, 166, 35, 0.35);
  --green: #18894a;
  --green-glow: rgba(24, 137, 74, 0.1);
  --green-border: rgba(24, 137, 74, 0.3);
  --red: #be2f46;
  --red-glow: rgba(190, 47, 70, 0.1);
  --red-border: rgba(190, 47, 70, 0.3);
  --text: #171d2e;
  --text-soft: #4b5978;
  --muted: #7b87a2;
  --grid-line: rgba(95, 113, 154, 0.22);
  --topbar-bg: rgba(241, 244, 251, 0.95);
  --row-hover: rgba(27, 38, 69, 0.06);
  --status-ok: #18894a;
  --status-error: #be2f46;
}

/* Text size scaling */
[data-text-size="large"] { --fs-scale: 1.15; }
[data-text-size="xl"]    { --fs-scale: 1.30; }

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  max-width: 100%;
  overflow-x: hidden;
}
#appRoot {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
}
html {
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: calc(16px * var(--fs-scale));
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 40px 40px;
  z-index: 0;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(400px, 100% - 2rem);
  background: var(--s2);
  border: 1px solid var(--border);
  border-top: 3px solid var(--amber);
  border-radius: 14px;
  padding: 2.8rem 2.5rem;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6);
  text-align: center;
  animation: loginFadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes loginFadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-badge {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  margin: 0 auto 1.25rem;
  background: linear-gradient(135deg, var(--amber), var(--amber-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.login-title {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 2.5px;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.login-title em { color: var(--amber); font-style: normal; }

.login-sub {
  font-size: 0.82rem;
  color: var(--text-soft);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  height: 48px;
  background: linear-gradient(135deg, var(--amber), var(--amber-light));
  color: #0f1117;
  border: none;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.btn-google:hover { opacity: 0.9; }
.btn-google:active { transform: scale(0.98); }

.g-icon {
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #333;
  flex-shrink: 0;
}

.login-note {
  margin-top: 1.1rem;
  font-size: 0.68rem;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: 0.5px;
}

.login-err {
  margin-top: 0.875rem;
  padding: 0.6rem 0.875rem;
  background: var(--red-glow);
  border: 1px solid var(--red-border);
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--red);
  display: none;
}

.login-err.show { display: block; }

.login-divider {
  font-family: var(--mono); font-size: 10px; letter-spacing: 1px;
  color: var(--muted); text-transform: uppercase; text-align: center;
  margin: 16px 0 12px; position: relative;
}
.login-divider::before, .login-divider::after {
  content: ''; position: absolute; top: 50%; width: 30%; height: 1px;
  background: var(--border);
}
.login-divider::before { left: 0; }
.login-divider::after { right: 0; }

.email-link-input {
  width: 100%; box-sizing: border-box; padding: 12px 14px;
  background: var(--s2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-family: var(--mono); font-size: 14px;
  margin-bottom: 8px; outline: none;
}
.email-link-input:focus { border-color: var(--amber); }

.btn-emaillink {
  width: 100%; padding: 12px; background: var(--amber); border: none;
  border-radius: 8px; color: #000; font-family: var(--mono); font-size: 13px;
  font-weight: 700; letter-spacing: 1px; cursor: pointer; transition: opacity .15s;
}
.btn-emaillink:hover { opacity: .9; }
.btn-emaillink:disabled { opacity: .5; cursor: not-allowed; }

.email-link-sent {
  font-family: var(--mono); font-size: 12px; color: var(--green, #22c55e);
  text-align: center;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(1rem, env(safe-area-inset-right)) 0
    max(1rem, env(safe-area-inset-left));
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px) saturate(1.4);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.tb-stripe {
  width: 3px;
  height: 26px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--amber), var(--amber-light));
  flex-shrink: 0;
}

/* .tb-brand removed — titles now direct child of topbar */

.tb-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tb-name {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text);
  line-height: 1;
}

.tb-name em { color: var(--amber); font-style: normal; }

.tb-sub {
  font-family: var(--mono);
  font-size: 0.52rem;
  letter-spacing: 1.5px;
  color: var(--muted);
  text-transform: uppercase;
}

.tb-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tb-conn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  height: 24px;
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.15s;
  flex-shrink: 0;
}

.tb-conn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}

.tb-conn-dot.live {
  background: var(--green);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
  animation: tbConnPulse 2s infinite;
}
.tb-conn-dot.slow-conn {
  background: var(--amber);
  box-shadow: 0 0 8px rgba(245, 166, 35, 0.4);
  animation: tbConnPulse 2s infinite;
}

@keyframes tbConnPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.tb-conn-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.5px;
  color: var(--text-soft);
}

.tb-conn.online { border-color: var(--green-border); }
.tb-conn.online .tb-conn-label { color: var(--green); }
.tb-conn.offline { border-color: var(--red-border); }
.tb-conn.offline .tb-conn-label { color: var(--red); }
.tb-conn.offline .tb-conn-dot { background: var(--red); }

.tb-action-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
  white-space: nowrap;
  min-height: unset;
}

.tb-action-btn:hover { border-color: var(--amber); color: var(--amber); }
.tb-action-btn:active { transform: scale(0.97); }
.tb-action-btn--active { border-color: var(--amber-border); color: var(--amber); }
.tb-btn-icon { font-size: 0.8rem; line-height: 1; }

.tb-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--s1);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
  padding: 0;
  min-height: unset;
}

.tb-icon-btn:hover { border-color: var(--amber); color: var(--amber); }

.tb-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber), var(--amber-light));
  color: #0f1117;
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  border: none;
  box-shadow: 0 2px 8px rgba(245, 166, 35, 0.3);
  transition: opacity 0.15s, transform 0.1s;
  padding: 0;
  min-height: unset;
  text-transform: uppercase;
  overflow: hidden;
}

.tb-avatar:hover { opacity: 0.85; }
.tb-avatar:active { transform: scale(0.93); }

/* ── Version button (Pocket Logbook style) ── */
.scanner-badge {
  height: 24px;
  padding: 0 8px;
  background: var(--green-glow);
  border: 1px solid var(--green-border);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.55rem;
  letter-spacing: 0.5px;
  color: var(--green);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  animation: scannerPulse 2s ease-in-out infinite;
}
@keyframes scannerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.tb-version-btn {
  height: 24px;
  padding: 0 8px;
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.5px;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
  min-height: unset;
  white-space: nowrap;
}
.tb-version-btn:hover { border-color: var(--amber); color: var(--amber); }
.tb-version-btn.has-update {
  border-color: var(--amber-border);
  color: var(--amber);
  background: var(--amber-glow);
}

/* ── User menu dropdown ── */
.user-menu-wrap { position: relative; }
.user-menu-wrap { position: relative; }
.user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 200px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
  z-index: 300;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px) scale(0.97);
  transform-origin: top right;
  transition: opacity 0.15s, transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}
.user-menu.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}
.user-menu-hdr {
  padding: 10px 14px 8px;
  font-family: var(--mono);
  font-size: calc(10px * var(--fs-scale));
  color: var(--muted);
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-menu-item {
  width: 100%;
  padding: 11px 14px;
  background: transparent;
  border: none;
  text-align: left;
  color: var(--text);
  font-family: var(--mono);
  font-size: calc(12px * var(--fs-scale));
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.1s;
  min-height: unset;
  border-radius: 0;
}
.user-menu-item:hover { background: var(--s2); }
.user-menu-divider {
  height: 1px;
  background: var(--border);
}
.user-menu-signout { color: var(--red); }
.user-menu-signout:hover { background: rgba(244, 63, 94, 0.08); }
/* ── Text Size Chips ── */
.user-menu-label {
  padding: 6px 14px 2px;
  font-family: var(--mono);
  font-size: 0.55rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}
.text-size-row {
  display: flex;
  gap: 6px;
  padding: 6px 20px 12px;
}
.text-size-chip {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.text-size-chip:hover { border-color: var(--amber); color: var(--amber); }
.text-size-chip.active { border-color: var(--amber); color: var(--amber); background: var(--amber-glow); }
.text-size-chip .ts-a { font-weight: 700; }

/* ── Settings Sheet Content ── */
.settings-group-lbl {
  font-family: var(--mono);
  font-size: calc(10px * var(--fs-scale));
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 0 6px;
}
.settings-row-col {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row-title {
  font-family: var(--mono);
  font-size: calc(12px * var(--fs-scale));
  font-weight: 600;
  color: var(--text);
}
.settings-row-hint {
  font-size: calc(11px * var(--fs-scale));
  color: var(--muted);
  margin-top: 2px;
}

.settings-row-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

/* ── Bottom Sheets (Pocket Logbook pattern) ── */
.btk-sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.btk-sheet.open {
  opacity: 1;
  pointer-events: all;
}
.btk-sheet-card {
  width: 100%;
  max-width: 540px;
  background: var(--s1);
  border: 1px solid var(--border);
  border-top: 2px solid var(--amber);
  border-radius: 14px 14px 0 0;
  padding: 0 0 28px;
  transform: translateY(32px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 92dvh;
  overflow-y: auto;
}
.btk-sheet.open .btk-sheet-card {
  transform: translateY(0);
}
.btk-sheet-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--s1);
  z-index: 1;
}
.btk-sheet-title {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text);
  flex: 1;
}
.btk-sheet-x {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-soft);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
  min-height: unset;
  padding: 0;
}
.btk-sheet-x:hover { border-color: var(--red); color: var(--red); }
.btk-sheet-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
/* ── Leaflet Map overrides ── */
#mapContainer .leaflet-container { font-family: var(--sans); }
#mapContainer { border-radius: 0 0 14px 14px; min-height: 60vh; height: 70vh; }
/* ── Onboarding Tutorial ── */
.onboarding {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 20px env(safe-area-inset-bottom, 0);
  pointer-events: none;
}
.onboarding.hidden { display: none; }
.onboarding-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  pointer-events: auto;
}
.onboarding-tooltip {
  position: relative;
  z-index: 401;
  background: var(--s1);
  border: 1px solid var(--amber);
  border-radius: 14px 14px 0 0;
  padding: 20px 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  margin-bottom: 0;
}
.onboarding-step {
  font-family: var(--mono);
  font-size: 0.5rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 6px;
}
.onboarding-title {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.onboarding-desc {
  font-size: 0.75rem;
  color: var(--text-soft);
  line-height: 1.5;
  margin-bottom: 14px;
}
.onboarding-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.onboarding-actions .secondary { font-size: 0.65rem; min-height: 36px; padding: 0 12px; }
.onboarding-actions .primary { font-size: 0.65rem; min-height: 36px; padding: 0 16px; }
.onboarding-spotlight {
  position: relative;
  z-index: 401;
  box-shadow: 0 0 0 4px var(--amber), 0 0 0 9999px rgba(0, 0, 0, 0.75);
  border-radius: 8px;
}

/* Hide default Leaflet layer control — using custom buttons instead */
.leaflet-control-layers { display: none !important; }
.map-layer-btns {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  display: flex;
  gap: 4px;
}
.map-layer-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--s2);
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 0.55rem;
  letter-spacing: 0.5px;
  cursor: pointer;
  opacity: 0.85;
}
.map-layer-btn.active {
  border-color: var(--amber);
  color: var(--amber);
  background: var(--amber-glow);
}

.sync-badge-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  margin-left: auto;
  padding: 0 4px;
}

.sync-badge {
  position: absolute;
  top: 0px;
  right: 0px;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  background: var(--amber);
  color: #0f1117;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
  line-height: 1;
}

/* Drawer badge (offline queue count on hamburger) */
.drawer-badge {
  position: absolute;
  top: 0; right: 0;
  min-width: 14px; height: 14px; border-radius: 7px;
  background: var(--red);
  color: #fff;
  font-family: var(--mono);
  font-size: 8px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 2px; line-height: 1;
}

/* Recent serial chips */
.recent-chips {
  display: flex; flex-wrap: wrap; gap: 0.3rem;
  margin-top: 0.3rem;
}
.recent-chip {
  background: var(--s3); border: 1px solid var(--border);
  border-radius: 16px; padding: 0.15rem 0.6rem;
  font-family: var(--mono); font-size: 0.68rem;
  color: var(--text-soft); cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.recent-chip:hover, .recent-chip:active {
  background: var(--amber-glow); border-color: var(--amber-border); color: var(--text);
}

.layout {
  position: relative;
  z-index: 1;
  max-width: min(1300px, 100vw);
  margin: 0 auto;
  overflow-x: hidden;
  padding: 1rem max(1rem, env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--s2);
  border: 1px solid var(--border);
  border-top: 3px solid transparent;
  border-radius: 12px;
  padding: 1rem;
  max-width: 100%;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
  transition: border-color 0.3s;
}

.card.action-receive { border-top-color: var(--green); }
.card.action-use { border-top-color: var(--amber); }
.card.action-mark_faulty,
.card.action-return_faulty { border-top-color: var(--red); }
.card.action-return_unused,
.card.action-adjust { border-top-color: var(--border-strong); }

h2 {
  margin: 0 0 0.85rem;
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.tx-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 1.25px;
  text-transform: uppercase;
  color: var(--text-soft);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 0.75rem;
  background: var(--s3);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-glow);
}

input::placeholder {
  color: var(--muted);
}

.inline-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
}

button {
  min-height: 44px;
  border: none;
  border-radius: 8px;
  padding: 0 0.9rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.9px;
  transition: transform 0.08s, border-color 0.15s, color 0.15s, background 0.15s;
}

button:active {
  transform: scale(0.98);
}

button.primary {
  background: linear-gradient(135deg, var(--amber), var(--amber-light));
  color: #10131a;
}

button.secondary {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--border);
}

button.secondary:hover {
  border-color: var(--amber);
  color: var(--amber);
}

.theme-btn {
  width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--s3);
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  line-height: 1;
}

.theme-btn:hover {
  border-color: var(--amber);
  color: var(--amber);
}

.theme-btn:active {
  transform: scale(0.94);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  grid-column: 1 / -1;
  font-size: 0.68rem;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--amber);
}

/* ── Toggle Switch ── */
.toggle-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.toggle-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 1.25px;
  text-transform: uppercase;
  color: var(--text-soft);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--s3);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: background 0.2s, border-color 0.2s;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--text-soft);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle-switch input:checked + .toggle-track {
  background: var(--amber-glow);
  border-color: var(--amber-border);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(20px);
  background: var(--amber);
}

.tx-form button.primary {
  grid-column: 1 / -1;
}

.more-options-section {
  grid-column: 1 / -1;
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

.more-options-section .panel-header {
  justify-content: center;
}

.more-options-section .panel-toggle {
  flex: 0;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-soft);
  font-weight: 500;
  gap: 0.3rem;
  transition: color 0.15s;
}

.more-options-section .panel-toggle:hover { color: var(--amber); }

.more-options-section .panel-toggle[aria-expanded="true"] { color: var(--amber); }

.more-options-section .panel-body {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding-left: 0.55rem;
  padding-right: 0.55rem;
  background: var(--s3);
  margin-top: 0.45rem;
}

.more-options-section .panel-body.open {
  padding-top: 0.65rem;
  padding-bottom: 0.55rem;
}

.more-options-section .panel-body > label {
  margin-bottom: 0.55rem;
}

.more-options-section .panel-body > label:last-child {
  margin-bottom: 0;
}

.mobile-only {
  display: none;
}

.mobile-note {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.4;
}

.status {
  margin: 0.75rem 0 0;
  min-height: 1.2rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.7px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.metric {
  background: var(--s3);
  border: 1px solid var(--border);
  border-top: 2px solid var(--amber);
  border-radius: 10px;
  padding: 0.85rem 0.9rem;
}

.metric h3 {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.57rem;
  letter-spacing: 1.3px;
  color: var(--muted);
  text-transform: uppercase;
}

.metric p {
  margin: 0.35rem 0 0;
  font-family: var(--mono);
  font-size: 1.45rem;
  color: var(--text);
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.section-header h2 {
  flex: 1;
  min-width: 120px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.filters input,
.filters select {
  min-width: 160px;
}

.table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border: 1px solid var(--border);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 680px;
}

thead th {
  background: var(--s1);
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.62rem 0.7rem;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.56rem;
  letter-spacing: 1.3px;
  text-transform: uppercase;
}

tbody td {
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 0.7rem;
  white-space: nowrap;
}

tbody tr:hover {
  background: var(--row-hover);
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  border-radius: 999px;
  padding: 0 0.7rem;
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.user-pill {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill.online {
  background: var(--green-glow);
  border-color: var(--green-border);
  color: var(--green);
}

.pill.offline {
  background: var(--red-glow);
  border-color: var(--red-border);
  color: var(--red);
}

.site-selector {
  display: grid;
  gap: 0.35rem;
}

.photo-capture {
  display: grid;
  gap: 0.45rem;
}
.photo-btn-row {
  display: flex;
  gap: 8px;
}
.photo-btn {
  flex: 1;
  min-height: 38px;
  font-size: 0.72rem;
}

.photo-preview {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.photo-preview img {
  max-width: 200px;
  max-height: 150px;
  border-radius: 6px;
  border: 1px solid var(--border);
  object-fit: cover;
  cursor: pointer;
}

.photo-clear {
  min-height: 32px;
  padding: 0 0.6rem;
  font-size: 0.62rem;
}

/* ── Announcements Banner ── */
.announcements-banner {
  position: relative;
  z-index: 10;
  display: grid;
  gap: 0.5rem;
  padding: 0.65rem max(1rem, env(safe-area-inset-right)) 0.65rem max(1rem, env(safe-area-inset-left));
  background: var(--amber-glow);
  border-bottom: 1px solid var(--amber-border);
}

.announcement {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: var(--text);
}

.announcement strong {
  color: var(--amber);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.ann-dismiss {
  min-height: 28px;
  min-width: 28px;
  padding: 0;
  border-radius: 6px;
  font-size: 0.68rem;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Mobile Dashboard Strip ── */
.mobile-dash-strip {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--s1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  white-space: nowrap;
}

.md-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  border-left: 3px solid var(--muted);
  background: var(--s2);
  min-width: 60px;
  flex: 1;
}

.md-card-number {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.md-card-label {
  font-family: var(--mono);
  font-size: 0.5rem;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-soft);
}

.md-card--stock { border-left-color: var(--green); }
.md-card--faulty { border-left-color: var(--amber); }
.md-card--aging { border-left-color: var(--red); }
.md-card--installed { border-left-color: var(--muted); }

.md-card {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s, box-shadow 0.1s;
}
.md-card:active {
  transform: scale(0.95);
  box-shadow: 0 0 0 2px var(--amber);
}

/* ── Dashboard Detail List ── */
.dash-unit-list {
  display: flex;
  flex-direction: column;
}
.dash-unit-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.dash-unit-item:last-child { border-bottom: none; }
.dash-unit-icon { flex-shrink: 0; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.equip-icon { width: 32px; height: 32px; }
.dash-unit-info { flex: 1; min-width: 0; }
.dash-unit-serial {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
}
.dash-unit-meta {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-detail-count {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted);
  margin-bottom: 8px;
}

/* ── Swap Prompt ── */
.swap-prompt {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 110;
  background: var(--s2);
  border-top: 3px solid var(--amber);
  padding: 16px 20px calc(60px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.swap-prompt.show {
  transform: translateY(0);
}
.swap-prompt-msg {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--amber);
  margin: 0 0 12px;
  letter-spacing: 0.3px;
}
.swap-prompt-actions {
  display: flex;
  gap: 10px;
}
.swap-prompt-actions .primary,
.swap-prompt-actions .secondary {
  flex: 1;
  padding: 10px;
  font-size: 0.72rem;
}

/* ── Photo Gallery ── */
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}
.photo-gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--s2);
}
.photo-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-gallery-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  font-family: var(--mono);
  font-size: 0.45rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
}
.photo-gallery-serial {
  position: absolute;
  top: 4px;
  left: 4px;
  font-family: var(--mono);
  font-size: 0.45rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.75);
  color: var(--amber);
}
.photo-gallery-filters {
  margin-bottom: 12px;
}
.photo-gallery-filters select {
  width: 100%;
}

/* ── Form Submit Row ── */
.form-submit-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.form-submit-row .secondary {
  min-width: 44px;
  padding: 0 10px;
  font-size: 1.1rem;
}

/* ── Transaction Templates ── */
.template-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--s2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background 0.1s;
}
.template-card:active { background: var(--amber-glow); }
.template-card-body { flex: 1; min-width: 0; }
.template-card-name {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
}
.template-card-meta {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.template-card-action {
  font-family: var(--mono);
  font-size: 0.5rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--s3);
  color: var(--text-soft);
  white-space: nowrap;
}
.template-delete {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
  border-radius: 4px;
  flex-shrink: 0;
}
.template-delete:hover { color: var(--red); background: var(--red-glow); }

/* ── Photo Type Picker ── */
.photo-type-picker {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.photo-type-card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-top: 2px solid var(--amber);
  border-radius: 14px;
  padding: 20px;
  width: 100%;
  max-width: 320px;
}
.photo-type-title {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  margin: 0 0 12px;
  color: var(--text);
}
.photo-type-preview {
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
  max-height: 200px;
}
.photo-type-preview img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
}
.photo-type-btns {
  display: flex;
  gap: 8px;
}
.photo-type-btn {
  flex: 1;
  min-height: 44px;
  font-size: 0.72rem;
}

/* Photo preview chips in form */
.photo-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--s3);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.6rem;
  margin: 4px 4px 0 0;
}
.photo-chip img {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
}
.photo-chip-rm {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  line-height: 1;
}
.photo-chip-rm:hover { color: var(--red); }

/* ── Unit Photo Grid (per serial in lookup) ── */
.unit-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 6px;
  margin-top: 6px;
}
.unit-photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--s2);
}
.unit-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.unit-photo-badge {
  position: absolute;
  top: 3px;
  left: 3px;
  font-size: 0.55rem;
}
.unit-photo-share {
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  color: #fff;
  font-size: 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.unit-photo-share:active {
  background: var(--amber);
}
.lookup-share-btn {
  font-size: 0.72rem !important;
}

/* ── Google Drive Status ── */
.drive-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.3px;
}
.drive-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.drive-status.connected .drive-status-dot { background: var(--green); }
.drive-status.disconnected .drive-status-dot { background: var(--muted); }

/* ── Batch Action Bar ── */
.batch-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 550;
  background: var(--s2);
  border-top: 2px solid var(--amber);
  padding: 10px 16px max(10px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}
.batch-bar-count {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--amber);
  white-space: nowrap;
}
.batch-bar-select {
  flex: 1;
  min-width: 0;
  height: 34px;
  font-size: 0.72rem;
}
.batch-bar-btn {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.68rem;
  white-space: nowrap;
}
.unit-cb {
  width: 18px;
  height: 18px;
  accent-color: var(--amber);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Modal Overlay (shared) ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  overflow-y: auto;
}

.modal-panel {
  width: min(640px, 100%);
  max-height: 90vh;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
}

.modal-close {
  min-height: 34px;
  padding: 0 0.7rem;
  font-size: 0.64rem;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.modal-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ── Unit Detail Grid ── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.detail-label {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}

.detail-section-title {
  margin: 1.2rem 0 0.6rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--amber);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
}

/* ── Timeline (Audit Trail) ── */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.timeline-item:last-child {
  border-bottom: none;
}

.tl-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
  margin-top: 0.35rem;
}

.tl-content {
  flex: 1;
  min-width: 0;
}

.tl-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tl-header strong {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.tl-date {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
}

.tl-meta {
  margin-top: 0.25rem;
  font-size: 0.82rem;
  color: var(--text-soft);
  line-height: 1.4;
}

.tl-photo {
  margin-top: 0.4rem;
}

.tl-photo img {
  max-width: 120px;
  max-height: 90px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  object-fit: cover;
  transition: opacity 0.15s;
}

.tl-photo img:hover {
  opacity: 0.8;
}

/* ── Photo Lightbox ── */
.lightbox-panel {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.lightbox-panel img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 10px;
  object-fit: contain;
}

.lightbox-panel .modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

/* ── QR Label Panel ── */
.qr-panel {
  width: min(400px, 100%);
}

.qr-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.qr-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background: #fff;
  border-radius: 8px;
}

.qr-serial-text {
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 1px;
  color: #111;
  text-align: center;
  word-break: break-all;
}

/* ── Bulk Receive Panel ── */
.bulk-panel {
  margin-top: 0.75rem;
}

.bulk-toggle {
  font-size: 0.64rem;
  padding: 0 0.7rem;
  min-height: 34px;
}

.bulk-info {
  margin: 0 0 0.65rem;
  color: var(--text-soft);
  font-size: 0.88rem;
}

.bulk-input-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.bulk-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--s3);
}

.bulk-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.82rem;
}

.bulk-list li:last-child {
  border-bottom: none;
}

.bulk-remove {
  min-height: 28px;
  min-width: 28px;
  padding: 0 0.4rem;
  font-size: 0.62rem;
  color: var(--red);
  border-color: var(--red-border);
}

.bulk-remove:hover {
  background: var(--red-glow);
}

.bulk-count {
  margin: 0.5rem 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.6px;
}

.bulk-actions {
  display: flex;
  gap: 0.5rem;
}

/* ── Clickable Table Rows ── */
.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: var(--amber-glow) !important;
}

.clickable-cell {
  cursor: pointer;
  color: var(--amber);
}

.clickable-cell:hover {
  text-decoration: underline;
}

/* ── Photo Button (transaction table) ── */
.photo-btn {
  min-height: 30px;
  min-width: 30px;
  padding: 0;
  border-radius: 6px;
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Required Tag ── */
.required-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.52rem;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--red);
  background: var(--red-glow);
  border: 1px solid var(--red-border);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  vertical-align: middle;
  margin-left: 0.3rem;
}

/* ── Edit Transaction Form ── */
.edit-tx-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.edit-tx-form .status {
  grid-column: 1 / -1;
}

.editable-row,
.editable-tl {
  cursor: pointer;
}

.edit-btn {
  min-height: 28px;
  padding: 0 0.5rem;
  font-size: 0.6rem;
  vertical-align: middle;
}

.tl-edit {
  margin-top: 0.35rem;
}

/* ── Muted text ── */
.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.scan-page {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 150;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.scan-page .scan-wrap {
  width: min(520px, 100%);
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
}

.scan-wrap {
  padding: 0.85rem;
  display: grid;
  gap: 0.65rem;
  position: relative;
}

#scanReader {
  border-radius: 8px;
  overflow: hidden;
}

#scanStatus {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-soft);
}

.scan-actions {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  display: flex;
  gap: 0.45rem;
  z-index: 10;
}

.scan-actions button {
  min-height: 36px;
  padding: 0 0.7rem;
  background: rgba(15, 17, 23, 0.7);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: #dce3f0;
}

html[data-theme="light"] .scan-actions button {
  background: rgba(255, 255, 255, 0.85);
  color: #171d2e;
}

@media (max-width: 1000px) {
  .tx-form {
    grid-template-columns: 1fr;
  }

  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {

  .filters {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters input,
  .filters select,
  .filters button {
    min-width: 0;
    width: 100%;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .modal-panel {
    max-height: 95vh;
    border-radius: 10px;
  }

  .detail-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .bulk-input-row {
    grid-template-columns: 1fr auto;
  }

  .mobile-dash-strip {
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
  }

  .md-card {
    padding: 0.25rem 0.45rem;
    min-width: 50px;
  }

  .md-card-number { font-size: 0.82rem; }
  .md-card-label { font-size: 0.45rem; }

  .edit-tx-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: block;
  }

}

/* ── Recent Transactions List (field app) ── */
.recent-tx-list { list-style: none; margin: 0; padding: 0; }
.recent-tx-item { padding: 0.65rem 0; border-bottom: 1px solid var(--border); }
.recent-tx-item:last-child { border-bottom: none; }
.rtx-row { display: flex; align-items: center; gap: 0.5rem; }
.rtx-type { font-family: var(--mono); font-size: 0.68rem; text-transform: uppercase; color: var(--amber); flex-shrink: 0; }
.rtx-serial { font-family: var(--mono); font-size: 0.82rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rtx-serial-sub { display: block; font-size: 0.65rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rtx-time { font-family: var(--mono); font-size: 0.62rem; color: var(--muted); flex-shrink: 0; }
.rtx-meta { font-size: 0.78rem; color: var(--text-soft); margin-top: 0.18rem; }
.recent-tx-empty { color: var(--muted); font-size: 0.88rem; padding: 0.65rem 0; }

/* ── B1: Transaction Toast ── */
.tx-toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--s2); border: 1px solid var(--amber-border); border-left: 3px solid var(--amber);
  color: var(--text); font-family: var(--mono); font-size: 0.8rem;
  padding: 0.65rem 1.1rem; border-radius: 8px; z-index: 9999;
  white-space: normal; max-width: calc(100vw - 2rem); text-align: center; word-break: break-word;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  pointer-events: none;
}
.tx-toast-show { animation: toastSlideUp 0.3s ease forwards; }
.tx-toast-hide { animation: toastFadeOut 0.4s ease forwards; }
@keyframes toastSlideUp { from { opacity:0; transform:translateX(-50%) translateY(12px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }
@keyframes toastFadeOut { from { opacity:1; } to { opacity:0; } }

/* ── Panel Card Accents ── */
.card-accent-amber { border-left: 3px solid var(--amber); }
.card-accent-soft { border-left: 3px solid var(--text-soft); }

.card > .panel-header { padding: 0.25rem 0; }

.panel-icon {
  font-size: 0.85rem;
  flex-shrink: 0;
  line-height: 1;
}

.panel-action-btn {
  width: 28px;
  height: 28px;
  min-height: unset;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}

.panel-action-btn:hover { border-color: var(--amber); color: var(--amber); }

.card > .panel-body.open { border-top: 1px solid var(--border); margin-top: 0.5rem; }

/* ── Collapsible Panels ── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.panel-toggle {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  min-height: unset;
  transition: color 0.15s;
}

.panel-toggle:hover { color: var(--amber); }

.panel-chevron {
  font-size: 1rem;
  color: var(--muted);
  transition: transform 0.2s ease, color 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.panel-toggle[aria-expanded="true"] .panel-chevron {
  transform: rotate(90deg);
  color: var(--amber);
}

.panel-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease, padding-top 0.25s ease;
  padding-top: 0;
}

.panel-body.open {
  max-height: 4000px;
  padding-top: 0.75rem;
}

/* ── B4: Unit Lookup ── */
.lookup-card { background: var(--s3); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem 0.9rem; margin-top: 0.5rem; }
.lookup-row { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; padding: 0.22rem 0; border-bottom: 1px solid var(--border); font-size: 0.84rem; }
.lookup-row:last-child { border-bottom: none; }
.lookup-label { color: var(--muted); font-size: 0.72rem; flex-shrink: 0; }
.lookup-loading { color: var(--muted); font-size: 0.84rem; margin-top: 0.5rem; }
.lookup-not-found { color: var(--text-soft); font-size: 0.84rem; margin-top: 0.5rem; }
.pill-ok { background: var(--green-glow); border-color: var(--green-border); color: var(--green); }
.pill-warn { background: var(--amber-glow); border-color: var(--amber-border); color: var(--amber); }
.pill-err { background: var(--red-glow); border-color: var(--red-border); color: var(--red); }

/* ── B5: Queue Modal ── */
.queue-list { padding: 0; }
.queue-item { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); gap: 0.5rem; }
.queue-item:last-child { border-bottom: none; }
.queue-item-info { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.queue-type { font-size: 0.72rem; text-transform: uppercase; color: var(--amber); font-family: var(--mono); }
.queue-serial { font-family: var(--mono); font-size: 0.85rem; color: var(--text); }
.queue-time { font-size: 0.68rem; color: var(--muted); }
.queue-remove { flex-shrink: 0; padding: 0.25rem 0.5rem; font-size: 0.78rem; }

/* ── B6: My Units Panel ── */
.my-units-body { overflow-x: auto; }
.my-units-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.my-units-table th { text-align: left; font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; padding: 0.3rem 0.4rem; border-bottom: 1px solid var(--border); }
.my-units-table td { padding: 0.45rem 0.4rem; border-bottom: 1px solid var(--border); }
.my-units-table tr:last-child td { border-bottom: none; }

@media (max-width: 520px) {
  .layout {
    gap: 0.75rem;
    padding-top: 0.75rem;
  }

  .card {
    padding: 0.85rem;
    border-radius: 10px;
    overflow: hidden;
  }

  .tx-form {
    grid-template-columns: 1fr;
  }

  .inline-input {
    grid-template-columns: 1fr auto;
  }

  .filters {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 600px) {
  .topbar { padding-left: 10px; padding-right: 10px; gap: 6px; }
  .tb-right {
    margin-left: auto;
    gap: 6px;
  }
  .tb-icon-btn, .tb-avatar { width: 44px; height: 44px; }
}

@media (max-width: 480px) {
  .topbar { gap: 4px; }
}

/* ── Pull to Refresh ── */
.pull-refresh-indicator {
  text-align: center;
  padding: 0.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 1px;
  color: var(--amber);
  background: var(--amber-glow);
  border-bottom: 1px solid var(--amber-border);
  transition: opacity 0.3s;
  opacity: 0;
}

/* ── Stale Data Banner ── */
.stale-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.35rem 1rem;
  background: rgba(245, 166, 35, 0.12);
  border-bottom: 1px solid var(--amber-border);
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--amber);
  letter-spacing: 0.5px;
}

/* ── Unit Lookup History ── */
.unit-history {
  margin-top: 0.6rem;
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
}

.unit-history-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.unit-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  gap: 0.5rem;
}

.unit-history-item:last-child { border-bottom: none; }

.unit-history-meta {
  font-size: 0.65rem;
  color: var(--muted);
  font-family: var(--mono);
}

/* ── Scan Success Flash (#3) ── */
@keyframes scanFlash {
  0% { border-color: var(--green); box-shadow: 0 0 8px var(--green-border); }
  100% { border-color: var(--border); box-shadow: none; }
}
.scan-success { animation: scanFlash 0.6s ease-out; }

/* ── Sticky Submit Bar (#1) ── */
.sticky-submit-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom));
  background: var(--topbar-bg);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(12px) saturate(1.4);
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  justify-content: center;
}
.sticky-submit-bar.visible { transform: translateY(0); }
.sticky-submit-bar.bulk-active { display: none !important; }
.sticky-submit-bar button.primary { width: 100%; max-width: 480px; }

/* ── Loading Pulse (#8) ── */
@keyframes loadingPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
.loading-pulse { animation: loadingPulse 1.5s ease-in-out infinite; color: var(--muted) !important; }

/* ── Photo Lightbox (#9) ── */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  cursor: pointer;
}
.lightbox-overlay img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 8px;
  object-fit: contain;
}

/* ── Empty States (#11) ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 1.2rem 0.5rem;
  text-align: center;
}
.empty-state-icon { font-size: 1.5rem; opacity: 0.6; }
.empty-state-msg { color: var(--muted); font-size: 0.88rem; }
.empty-state-hint { color: var(--text-soft); font-size: 0.78rem; }

/* ── Update Banner ── */
.update-banner {
  position: fixed;
  bottom: calc(5rem + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9998;
  width: calc(100% - 2rem);
  max-width: 28rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--s2);
  border: 1px solid var(--amber-border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: toastSlideUp 0.3s ease forwards;
}

.update-msg {
  flex: 1;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text);
}

.update-dismiss {
  min-height: 32px;
  padding: 0 0.6rem;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  cursor: pointer;
}

.update-dismiss:hover { color: var(--text-soft); }

.update-apply {
  min-height: 32px;
  padding: 0 0.75rem;
  background: linear-gradient(135deg, var(--amber), var(--amber-light));
  color: #10131a;
  border: none;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
}

.update-apply:active { transform: scale(0.97); }

/* ── Lookup Sidebar Drawer ── */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.lookup-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 91;
  width: min(380px, 85vw);
  background: var(--s2);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.4);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lookup-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(0.75rem + env(safe-area-inset-top)) 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--s1);
  flex-shrink: 0;
}

.drawer-header h2 {
  margin: 0;
}

.drawer-tabs {
  display: flex;
  gap: 0;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.drawer-tabs::-webkit-scrollbar { display: none; }

.drawer-tab {
  padding: 0.45rem 0.65rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: unset;
  transition: color 0.15s, border-color 0.15s;
}

.drawer-tab:hover { color: var(--text-soft); }

.drawer-tab.active {
  color: var(--amber);
  border-bottom-color: var(--amber);
}

.drawer-tab-panel { display: none; }
.drawer-tab-panel.active { display: flex; flex-direction: column; }

.drawer-tab-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}

.drawer-tab-actions .panel-action-btn {
  width: auto;
  padding: 0 0.5rem;
  gap: 0.25rem;
  font-size: 0.62rem;
}

.drawer-close {
  min-height: 34px;
  min-width: 34px;
  padding: 0;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem max(1rem, env(safe-area-inset-right)) 1rem 1rem;
  -webkit-overflow-scrolling: touch;
}

.drawer-body .inline-input {
  margin-bottom: 0.75rem;
}

.drawer-footer {
  padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.drawer-footer-email {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.3px;
  color: var(--muted);
  padding: 0 0.2rem 0.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-menu-list {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--s1);
  margin-bottom: 0.5rem;
}
.drawer-menu-item {
  width: 100%;
  padding: 11px 14px;
  background: transparent;
  border: none;
  text-align: left;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.1s;
  min-height: unset;
  border-radius: 0;
}
.drawer-menu-item:hover { background: var(--s2); }
.drawer-menu-divider {
  height: 1px;
  background: var(--border);
}
.drawer-menu-signout { color: var(--red); }
.drawer-menu-item.drawer-tab.active {
  color: var(--amber);
  background: var(--amber-glow);
  border-left: 3px solid var(--amber);
}
.drawer-nav-list {
  padding: 0 1rem;
  margin-bottom: 0.5rem;
}
.drawer-header-title {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text);
}
.drawer-footer-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.2rem 0.4rem;
}

.drawer-footer-btn {
  width: 100%;
  min-height: 36px;
  padding: 0 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.drawer-footer-btn:hover { border-color: var(--amber); color: var(--amber); }
.drawer-footer-btn.checking { color: var(--amber); border-color: var(--amber-border); pointer-events: none; }
.spin-icon { display: inline-block; animation: spin 0.8s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.app-version {
  display: block;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.5rem;
  letter-spacing: 0.5px;
  color: var(--muted);
  opacity: 0.4;
  margin-top: 0.4rem;
}

/* ── Duplicate Serial Warning ── */
.duplicate-warning {
  background: var(--amber-glow);
  border: 1px solid var(--amber-border);
  border-left: 3px solid var(--amber);
  color: var(--amber);
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  margin-top: 0.5rem;
  line-height: 1.4;
}
.duplicate-warning strong { color: var(--text); }

/* ── Toast Share Button ── */
.toast-share-btn {
  background: none;
  border: none;
  color: var(--amber);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 0 0 0.5rem;
  line-height: 1;
  flex-shrink: 0;
}
.toast-share-btn:hover { opacity: 0.7; }
.toast-actions { display: flex; align-items: center; gap: 0.3rem; flex-shrink: 0; margin-left: 0.5rem; }
.toast-undo-btn {
  background: none; border: 1px solid var(--amber-border);
  color: var(--amber); font-family: var(--mono); font-size: 0.68rem;
  letter-spacing: 0.5px; text-transform: uppercase;
  padding: 0.2rem 0.5rem; border-radius: 4px; cursor: pointer;
}
.toast-undo-btn:hover { background: var(--amber-glow); }
.toast-countdown {
  position: absolute; bottom: 0; left: 0; right: 0; height: 2px;
  background: var(--amber);
  animation: countdown 10s linear forwards;
  border-radius: 0 0 8px 8px;
}
@keyframes countdown { from { width: 100%; } to { width: 0; } }
.tx-toast { display: flex; align-items: center; position: relative; }

/* ── Notification Center ── */
.notifications-list { display: flex; flex-direction: column; gap: 0.25rem; }
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
}
.notif-item:hover { background: var(--s3); }
.notif-item:last-child { border-bottom: none; }
.notif-unread { background: var(--amber-glow); }
.notif-read { opacity: 0.6; }
.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
  margin-top: 0.35rem;
}
.notif-content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.notif-content strong { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.5px; }
.notif-body { font-size: 0.82rem; color: var(--text-soft); line-height: 1.4; }
.notif-time { font-family: var(--mono); font-size: 0.62rem; color: var(--muted); letter-spacing: 0.5px; }
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--red);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}
.drawer-tab { position: relative; }

/* ── History Filters ── */
.history-filters {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}
.history-filters input[type="date"] {
  flex: 1;
  min-width: 0;
}

@media (max-width: 520px) {
  .lookup-drawer {
    width: 100vw;
  }
}

/* ── F6: Serial Suggestions Dropdown ── */
.serial-suggestions {
  position: absolute;
  left: 0; right: 0;
  top: 100%;
  z-index: 100;
  background: var(--s2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.serial-suggestions.hidden { display: none; }
.serial-sug-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.serial-sug-item:last-child { border-bottom: none; }
.serial-sug-item:hover, .serial-sug-item:focus { background: var(--amber-glow); }
.serial-sug-serial {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  flex: 1;
}
.serial-sug-meta {
  font-size: 0.68rem;
  color: var(--muted);
  text-align: right;
}
.serial-sug-status {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

/* ── F8: Quick Scan Toggle ── */
.quick-scan-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.quick-scan-toggle input { display: none; }
.qst-slider {
  width: 34px; height: 18px;
  background: var(--s3);
  border: 1px solid var(--border);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}
.qst-slider::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.quick-scan-toggle input:checked + .qst-slider {
  background: var(--amber-glow);
  border-color: var(--amber-border);
}
.quick-scan-toggle input:checked + .qst-slider::after {
  transform: translateX(16px);
  background: var(--amber);
}
.qst-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
}
.quick-scan-toggle input:checked ~ .qst-label { color: var(--amber); }

.quick-scan-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: var(--amber-glow);
  border: 1px solid var(--amber-border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}
.quick-scan-bar.hidden { display: none; }
#quickScanCount {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.5px;
  color: var(--amber);
  font-weight: 600;
}
.quick-scan-bar .secondary {
  min-height: 28px;
  padding: 0 0.6rem;
  font-size: 0.6rem;
}

/* ── F1: Low Stock Alert Banner ── */

.low-stock-banner {
  padding: 0.55rem 0.75rem;
  margin: 0.25rem 0.75rem;
  background: var(--red-glow);
  border: 1px solid var(--red-border);
  border-radius: 8px;
  color: var(--amber);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  box-shadow: 0 0 12px var(--red-glow), inset 0 0 8px var(--red-glow);
  animation: lowStockPulse 2.5s ease-in-out infinite;
}
@keyframes lowStockPulse {
  0%, 100% { box-shadow: 0 0 12px var(--red-glow), inset 0 0 8px var(--red-glow); }
  50% { box-shadow: 0 0 20px rgba(244, 63, 94, 0.2), inset 0 0 12px rgba(244, 63, 94, 0.12); }
}
.low-stock-banner + .low-stock-banner { margin-top: 0.35rem; }

/* ── F3: Inventory Counts Tab ── */

.counts-list { display: flex; flex-direction: column; gap: 0.5rem; }

.count-card {
  padding: 0.75rem;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.count-card:hover { border-color: var(--amber-border); background: var(--s3); }

.count-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}
.count-card-location {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
}
.count-card-progress { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.3rem; }
.count-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--s3);
  border-radius: 3px;
  overflow: hidden;
}
.count-progress-fill {
  height: 100%;
  background: var(--amber);
  border-radius: 3px;
  transition: width 0.3s;
}
.count-progress-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-soft);
  min-width: 3rem;
  text-align: right;
}
.count-card-due {
  font-size: 0.72rem;
  color: var(--muted);
}

/* Count Detail */
.count-detail { padding: 0; }
.count-detail-stats {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.count-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.6rem;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.count-stat-num {
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--amber);
}
.count-stat-label {
  font-size: 0.68rem;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.count-detail-actions { margin-bottom: 0.75rem; }
.count-scanned-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 0.5rem;
}
.count-scanned-item {
  padding: 0.35rem 0.5rem;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text);
}
.count-discrepancies { margin-top: 0.75rem; }
.disc-section { margin-bottom: 0.5rem; }
.disc-section strong {
  display: block;
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
  color: var(--text-soft);
}
.disc-missing strong { color: var(--red); }
.disc-extra strong { color: var(--amber); }
.disc-item {
  padding: 0.3rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  border-radius: 4px;
  margin-bottom: 0.15rem;
}
.disc-item-missing {
  background: var(--red-glow);
  border: 1px solid var(--red-border);
  color: var(--red);
}
.disc-item-extra {
  background: var(--amber-glow);
  border: 1px solid var(--amber-border);
  color: var(--amber);
}

/* ── F4: Monthly Summary Report ── */

.report-month-picker {
  margin-bottom: 0.75rem;
}
.report-month-picker label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-soft);
}
.report-month-picker input[type="month"] {
  flex: 1;
  padding: 0.4rem 0.5rem;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.report-section { margin-bottom: 1rem; }
.report-section-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.report-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.report-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.3rem;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.report-metric-num {
  font-family: var(--mono);
  font-size: 1.2rem;
  font-weight: 700;
}
.report-metric-label {
  font-size: 0.62rem;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.report-metric--green .report-metric-num { color: var(--green); }
.report-metric--blue .report-metric-num { color: #60a5fa; }
.report-metric--red .report-metric-num { color: var(--red); }
.report-metric--amber .report-metric-num { color: var(--amber); }
.report-metric--purple .report-metric-num { color: #a78bfa; }

.report-total-tx {
  font-size: 0.75rem;
  color: var(--text-soft);
  text-align: center;
  padding: 0.3rem 0;
}

.report-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.report-breakdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.5rem;
  background: var(--s2);
  border-radius: 4px;
  font-size: 0.78rem;
}
.report-breakdown-name { color: var(--text); }
.report-breakdown-count {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--amber);
}

.pill-muted {
  background: var(--s3);
  color: var(--muted);
  border-color: var(--border);
}

/* ════════════════════════════════════
   UI IMPROVEMENTS v2.14
   ════════════════════════════════════ */

/* ── Bottom Navigation Bar ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  background: var(--s1);
  border-top: 1px solid var(--border);
  padding: 4px 0 max(4px, env(safe-area-inset-bottom));
}
.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.42rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.bnav-item.active { color: var(--amber); }
.bnav-item:active { transform: scale(0.93); }
.bnav-icon { font-size: 1.1rem; line-height: 1; }
.bnav-label { line-height: 1; }
.bnav-icon-wrap { position: relative; display: inline-block; }
.bnav-badge {
  position: absolute;
  top: -2px;
  right: -8px;
  background: var(--red);
  color: #fff;
  font-size: 0.42rem;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* Add padding to main content for bottom nav */
.layout { padding-bottom: 60px; }

/* ── Form Progress Dots ── */
.form-progress {
  display: flex;
  gap: 4px;
  padding: 8px 16px 0;
}
.fp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s, box-shadow 0.3s;
}
.fp-dot.filled {
  background: var(--green);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
}
.fp-dot.active {
  background: var(--amber);
  box-shadow: 0 0 6px rgba(245, 166, 35, 0.4);
}

/* ── Success Animation ── */
.success-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.success-overlay.show {
  opacity: 1;
  pointer-events: all;
}
.success-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.success-overlay.show .success-circle { transform: scale(1); }
.success-circle svg {
  width: 40px;
  height: 40px;
  stroke: #fff;
  stroke-width: 3;
  fill: none;
}
.check-path {
  stroke-dasharray: 50;
  stroke-dashoffset: 50;
}
.success-overlay.show .check-path {
  animation: drawCheck 0.4s 0.2s forwards;
}
@keyframes drawCheck { to { stroke-dashoffset: 0; } }
.success-text {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--green);
  letter-spacing: 0.5px;
  opacity: 0;
}
.success-overlay.show .success-text {
  animation: fadeUp 0.3s 0.4s forwards;
}
@keyframes fadeUp { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ── Counter Animation ── */
@keyframes countUp { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
.count-animated { animation: countUp 0.4s ease-out forwards; }

/* ── High Contrast Mode ── */
.high-contrast {
  --text: #ffffff;
  --text-soft: #c0c8d8;
  --muted: #8890a8;
  --border: #3a4568;
  --s2: #1a1f2e;
  --s3: #252c3e;
}
.high-contrast label { color: var(--text-soft); font-weight: 600; }
.high-contrast input, .high-contrast select { border-width: 2px; font-weight: 500; }

/* ── Containers View ── */
.container-card { background: var(--s1); border: 1px solid var(--border); border-left: 3px solid var(--amber); border-radius: 8px; padding: 12px 14px; margin-bottom: 8px; transition: border-color 0.15s; }
.container-card.expanded { border-color: var(--amber); }
.container-card-header { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.container-card-name { font-family: var(--mono); font-size: 0.76rem; font-weight: 600; color: var(--text); text-transform: capitalize; }
.container-card-count { font-family: var(--mono); font-size: 0.82rem; font-weight: 700; color: var(--amber); min-width: 32px; text-align: right; }
.container-card-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.container-badge { display: inline-block; font-family: var(--mono); font-size: 0.55rem; letter-spacing: 0.3px; padding: 2px 6px; border-radius: 4px; }
.badge-ok { background: var(--green-glow); color: var(--green); border: 1px solid var(--green-border); }
.badge-err { background: var(--red-glow); color: var(--red); border: 1px solid var(--red-border); }
.badge-muted { background: var(--s2); color: var(--muted); border: 1px solid var(--border); }
.badge-installed { background: var(--amber-glow); color: var(--amber); border: 1px solid var(--amber-border); }
.container-units { padding-top: 10px; border-top: 1px solid var(--border); margin-top: 10px; display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.container-unit-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.container-unit-icon { width: 24px; height: 24px; flex-shrink: 0; }
.container-unit-icon .equip-icon { width: 24px; height: 24px; }
.container-unit-info { flex: 1; min-width: 0; }

/* ── Transaction Receipt ── */
.receipt-header { text-align: center; padding: 0.5rem 0 1rem; }
.receipt-check { width: 48px; height: 48px; margin: 0 auto 0.5rem; background: var(--green-glow); border: 2px solid var(--green); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.receipt-title { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 1.5px; text-transform: uppercase; color: var(--green); font-weight: 700; }
.receipt-rows { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.receipt-row { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--border); }
.receipt-row:last-child { border-bottom: none; }
.receipt-row-label { font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); }
.receipt-row-value { font-family: var(--mono); font-size: 0.78rem; color: var(--text); font-weight: 500; text-align: right; max-width: 60%; word-break: break-word; }
.receipt-actions { display: flex; gap: 0.5rem; padding-top: 1rem; }
.receipt-actions button { flex: 1; min-height: 44px; border-radius: 8px; font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.8px; font-weight: 600; cursor: pointer; border: 1px solid var(--border); }
.receipt-share-btn { background: var(--amber); color: #0f1117; border-color: var(--amber) !important; }
.receipt-close-btn { background: var(--s2); color: var(--text-soft); }
.receipt-timestamp { text-align: center; font-family: var(--mono); font-size: 0.55rem; color: var(--muted); letter-spacing: 0.5px; padding-top: 0.75rem; }

/* ── Unit History Timeline ── */
.unit-timeline { position: relative; padding-left: 1.5rem; margin-top: 0.5rem; }
.unit-timeline::before { content: ""; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: var(--border); border-radius: 1px; }
.tl-item { position: relative; padding-bottom: 1rem; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; left: -1.5rem; top: 2px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); background: var(--s1); z-index: 1; }
.tl-dot--receive { border-color: var(--green); background: var(--green-glow); }
.tl-dot--use { border-color: var(--amber); background: var(--amber-glow); }
.tl-dot--mark_faulty { border-color: var(--red); background: var(--red-glow); }
.tl-dot--return_faulty { border-color: #f59e0b; background: rgba(245, 158, 11, 0.1); }
.tl-dot--return_unused { border-color: var(--green); background: var(--green-glow); }
.tl-dot--adjust, .tl-dot--transfer, .tl-dot--register { border-color: var(--muted); background: var(--s2); }
.tl-type { font-family: var(--mono); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text); }
.tl-detail { font-size: 0.72rem; color: var(--text-soft); margin-top: 0.15rem; }
.tl-meta { font-family: var(--mono); font-size: 0.6rem; color: var(--muted); margin-top: 0.1rem; }
.tl-photo-badge { display: inline-block; font-size: 0.6rem; color: var(--amber); margin-left: 0.4rem; }
