:root {
  --bg: #141612;
  --bg2: #1c1f18;
  --card: #22261e;
  --ink: #e8e4d8;
  --muted: #9a9484;
  --line: #3a3f32;
  --accent: #c4a574;
  --accent-ink: #1a160e;
  --danger: #d36b5a;
  --ok: #7fa36b;
  --warn: #d4a017;
  --sidebar: #10120e;
  --sidebar-ink: #d7d2c4;
  --brand: #c4a574;
  --focus: #e0c48a;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --wallpaper: none;
  --login-wallpaper: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; height: 100%; max-width: 100%; overflow-x: clip; background-color: var(--bg); background-image: var(--wallpaper); background-size: cover; background-position: center; background-attachment: fixed; color: var(--ink); font: 15px/1.45 var(--sans); -webkit-text-size-adjust: 100%; }
#app { max-width: 100%; min-width: 0; }
html { font-size: clamp(15px, 0.25vw + 14.5px, 16.5px); }
a { color: var(--accent); }
button, input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line);
  border-radius: 6px; padding: 0.45rem 0.65rem;
}
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]),
select, textarea { min-width: 0; max-width: 100%; }
button { cursor: pointer; background: var(--line); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: 0; color: var(--accent); padding: 0; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
label { display: block; font-size: 0.82rem; color: var(--muted); margin: 0.35rem 0 0.15rem; }
.field, label.field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0.28rem;
  margin: 0;
  min-width: 0;
  font-size: inherit;
  color: inherit;
}
.field-name {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.03em;
  line-height: 1.2;
  white-space: nowrap;
}
.field input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]),
.field select,
.field textarea {
  width: 100%;
  display: block;
}
.field[hidden] { display: none !important; }
.layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100dvh;
  align-items: stretch;
  max-width: 100%;
  transition: grid-template-columns 0.18s ease;
}
.layout.collapsed { grid-template-columns: 76px minmax(0, 1fr); }
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-ink);
  padding: 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 100dvh;
  height: 100dvh;
  position: sticky;
  top: 0;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px;
  color: var(--brand);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.brand img, .brand .mark {
  width: 36px; height: 36px; border-radius: 9px; object-fit: cover;
  background: var(--accent); flex-shrink: 0;
}
.brand .mark {
  display: grid; place-items: center; color: var(--accent-ink); font-weight: 700;
}
.brand-text { min-width: 0; overflow: hidden; }
.brand strong { display: block; font-size: 15px; line-height: 1.2; color: var(--brand); }
.brand small { display: block; color: var(--sidebar-ink); font-weight: 400; font-size: 11px; margin-top: 0.15rem; }
.nav-ico { width: 20px; height: 20px; flex-shrink: 0; }
.nav-ico-mask {
  display: inline-block;
  background: currentColor;
  -webkit-mask: var(--nav-mask) center / contain no-repeat;
  mask: var(--nav-mask) center / contain no-repeat;
}
.nav-label { overflow: hidden; white-space: nowrap; }
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  border: 0; background: transparent; color: inherit;
  padding: 9px 10px; border-radius: 8px; text-align: left; width: 100%;
}
.nav-btn:hover { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.nav-btn.active { background: var(--accent); color: var(--accent-ink); }
.sidebar .spacer { flex: 1; }
.collapse-btn { margin-top: 8px; justify-content: center; }
.layout.collapsed .brand { justify-content: center; padding: 6px 0 14px; }
.layout.collapsed .brand-text,
.layout.collapsed .nav-label,
.layout.collapsed .status-bar { display: none; }
.layout.collapsed .nav-btn { justify-content: center; padding: 10px 8px; }
.nav-mobile-only { display: none; }
.nav-scrim { display: none; }
.main { padding: 1.1rem 1.4rem 3rem; min-width: 0; max-width: 100%; overflow: visible; }
html.has-wallpaper .layout { background: transparent; }
html.has-wallpaper .main { background: color-mix(in srgb, var(--bg) 82%, transparent); }
h1 { font-size: 1.35rem; font-weight: 650; margin: 0 0 0.75rem; }
h2 { font-size: 1.05rem; margin: 1.2rem 0 0.5rem; }
.banner { background: color-mix(in srgb, var(--warn) 14%, var(--card)); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line)); padding: 0.7rem 0.85rem; border-radius: 8px; color: var(--ink); font-size: 0.88rem; margin-bottom: 1rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0.85rem 1rem; }
.card .k { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.card .v { font-size: 1.45rem; font-weight: 650; margin-top: 0.2rem; }
.toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: end; margin: 0.6rem 0 0.8rem; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.45rem 0.75rem; align-items: start; margin: 0 0 0.75rem; }
.filters .search { width: 100%; }
.filter-count { align-self: end; padding-bottom: 0.55rem; }
.qb-col-bar { display: flex; align-items: flex-end; }
.col-picker { position: relative; }
.col-picker-btn {
  cursor: pointer;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  color: var(--ink);
  min-height: 44px;
}
.col-picker-menu {
  position: fixed;
  z-index: 80;
  left: 0;
  top: 0;
  margin: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  box-shadow: 0 10px 28px rgba(0,0,0,0.4);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.col-picker-menu[hidden] { display: none !important; }
.col-picker-menu label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  margin: 0;
  padding: 0.55rem 0.35rem;
  min-height: 44px;
  font-size: 0.95rem;
}
.cartridge-spec {
  display: grid;
  grid-template-columns: minmax(12rem, 24rem) 1fr;
  gap: 0.85rem 1.25rem;
  align-items: start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin: 0 0 0.85rem;
}
.cartridge-spec[hidden] { display: none; }
.cartridge-spec .spec-diagram {
  background: #fff;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
}
.cartridge-spec .spec-diagram img { display: block; width: 100%; height: auto; }
.cartridge-spec h2 { margin: 0 0 0.15rem; }
.cartridge-spec .spec-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.18rem 1.1rem;
  margin: 0.55rem 0 0;
}
.cartridge-spec .spec-dl dt {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cartridge-spec .spec-dl dd { margin: 0; font-family: var(--mono); font-size: 0.95rem; }
@media (max-width: 720px) {
  .cartridge-spec { grid-template-columns: 1fr; }
}
.table-wrap {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100dvh - 14rem);
  border: 1px solid var(--line);
  border-radius: 8px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.table-wrap th,
.table-wrap td {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
  vertical-align: top;
}
.table-wrap td:has(.calibers-cell) {
  white-space: normal;
  max-width: 18rem;
  min-width: 10rem;
}
.calibers-cell {
  display: block;
  overflow-wrap: break-word;
  word-break: normal;
  line-height: 1.35;
}
.table-wrap table,
.table-wrap table.load-table,
.table-wrap table.qb-table,
.table-wrap table.inv-table {
  border: 0;
  width: max-content;
  min-width: 100%;
  max-width: none;
  table-layout: auto;
}
.load-table { min-width: max-content; }
.table-wrap .inv-table td:has(.qty-edit),
.table-wrap .inv-table td:last-child {
  overflow: visible;
}
.load-table thead th { position: sticky; background: var(--bg2); z-index: 2; }
.load-table thead tr.groups th { top: 0; }
.load-table thead tr.cols th { top: 2.15rem; }
.load-table th.group.start { text-align: center; color: var(--ink); }
.load-table th.group.max { text-align: center; color: var(--ink); }
.load-table th.sortable { cursor: pointer; user-select: none; }
.load-table th.sortable:hover { color: var(--ink); }
.load-table th.sorted { color: var(--accent); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sorted { color: var(--accent); }
.load-table .num { font-family: var(--mono); font-size: 0.86rem; }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
th, td { padding: 0.45rem 0.65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
tr:hover td { background: color-mix(in srgb, var(--accent) 12%, var(--card)); color: var(--ink); }
tr.clickable { cursor: pointer; }
.badge { display: inline-block; font-size: 0.72rem; padding: 0.1rem 0.4rem; border-radius: 999px; border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.danger { color: var(--danger); border-color: var(--danger); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem 1rem; align-items: start; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid .field:has(textarea) { grid-column: 1 / -1; }
.conditions-heading { font-size: 0.75rem; margin: 0 0 0.4rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.conditions { display: flex; flex-wrap: wrap; gap: 0.15rem 1rem; margin: 0; }
.cond { display: inline-flex; align-items: baseline; gap: 0.35rem; white-space: nowrap; }
.cond-label { color: var(--muted); font-size: 0.75rem; }
.cond-value { font-family: var(--mono); font-size: 0.86rem; }
.combo { width: 100%; position: relative; z-index: 1; }
.combo.open { z-index: 50; }
.combo input { width: 100%; display: block; padding-right: 2.75rem; }
.clearable { position: relative; width: 100%; min-width: 0; }
.clearable input { width: 100%; display: block; padding-right: 1.9rem; }
button.field-clear,
button.combo-toggle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}
button.field-clear { right: 0.28rem; }
button.combo-toggle {
  right: 0.18rem;
  display: flex;
  font-size: 0.8rem;
}
.combo.clearable.has-value button.field-clear { right: 1.7rem; }
.clearable.has-value button.field-clear { display: flex; }
button.field-clear:hover,
button.combo-toggle:hover { color: var(--ink); background: var(--line); }
.combo-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 0.15rem;
  max-height: min(14rem, 45vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
  z-index: 60;
}
.combo-opt {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0.62rem 0.7rem;
  min-height: 2.6rem;
  color: var(--ink);
}
.combo-opt:hover,
.combo-opt:active { background: color-mix(in srgb, var(--accent) 16%, var(--card)); }
.combo-more { padding: 0.5rem 0.7rem; font-size: 0.78rem; color: var(--muted); }
.multi-combo { width: 100%; }
.form-grid .field:has(.multi-combo) { grid-column: 1 / -1; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0 0 0.4rem; min-height: 0; }
.chips:empty { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  min-height: 1.8rem;
}
.chip-x { color: var(--muted); font-size: 0.95rem; line-height: 1; }
.chip:hover { border-color: var(--danger); color: var(--danger); }
.chip:hover .chip-x { color: var(--danger); }
.field, .form-grid, .card { overflow: visible; }
.muted { color: var(--muted); }
.auth {
  min-height: 100dvh;
  margin: 0;
  max-width: none;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  background-color: var(--bg);
  background-image: radial-gradient(1200px 500px at 20% -10%, color-mix(in srgb, var(--accent) 28%, transparent), var(--bg));
  background-size: cover;
  background-position: center;
  border: 0;
  border-radius: 0;
}
.auth-center { flex: 1; display: grid; place-items: center; width: 100%; }
.auth-card {
  width: min(26rem, 100%);
  background: var(--card);
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.auth-card h2 { text-align: center; width: 100%; }
.auth-card > p { text-align: center; width: 100%; }
.auth-card label {
  width: 100%;
  max-width: 16rem;
  text-align: left;
}
.auth-card label input:not([type=checkbox]):not([type=radio]):not([type=file]) {
  display: block;
  width: 100%;
}
.auth-card button.primary { min-width: 8rem; margin-top: 0.25rem; }
.auth-head { text-align: center; margin-bottom: 0.85rem; width: 100%; }
.auth-head h1 { margin: 0 0 0.2rem; font-size: 1.35rem; }
.auth-head h2 { margin: 0.6rem 0 0.25rem; }
.auth-logo { display: block; margin: 0 auto 0.75rem; max-width: 11rem; max-height: 4.5rem; object-fit: contain; }
.auth-foot { text-align: center; font-size: 0.78rem; color: var(--muted); max-width: 36rem; margin: 0 auto; padding-top: 1rem; line-height: 1.5; }
html.has-login-wallpaper .auth { background-image: var(--login-wallpaper); }
html.has-login-wallpaper .auth-foot { color: #fff; mix-blend-mode: difference; }
.wallpaper-preview { max-width: 100%; max-height: 8rem; object-fit: cover; border-radius: 8px; display: block; margin: 0.4rem 0; border: 1px solid var(--line); }
.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.qty-edit { display: flex; align-items: center; flex-wrap: nowrap; gap: 0.35rem; min-width: max-content; }
.qty-edit input { width: 5.2rem; flex: 0 0 auto; }
.qty-edit button { padding: 0.35rem 0.55rem; font-size: 0.8rem; white-space: nowrap; flex: 0 0 auto; }
.menu-fab {
  display: none; position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: calc(env(safe-area-inset-left, 0px) + 12px);
  z-index: 50;
  width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: var(--sidebar); color: var(--accent);
}
.chart { width: 100%; height: 220px; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; }
.target-wrap {
  max-width: none;
  width: 100%;
  margin: 0.35rem 0 1rem;
  cursor: default;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem 1rem 1rem;
  min-width: 0;
}
.scope-sim-slot { margin-top: 0.75rem; }
.chart.target-face { width: 100%; height: 100%; max-width: 100%; max-height: 100%; aspect-ratio: unset; object-fit: contain; }
.reticle-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem 0.85rem;
  align-items: start;
  margin: 0 0 0.75rem;
  width: 100%;
}
.reticle-toolbar .field {
  min-width: 0;
  width: 100%;
}
.reticle-toolbar .field-name { white-space: normal; }
.reticle-toolbar select,
.reticle-toolbar .reticle-optic,
.reticle-toolbar .reticle-design,
.reticle-toolbar .reticle-bg,
.reticle-toolbar .reticle-objective {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
.reticle-span { grid-column: 1 / -1; }
.reticle-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  width: 100%;
}
.reticle-seg button {
  width: 100%;
  min-width: 0;
  min-height: 2.5rem;
  margin: 0;
  padding: 0.4rem 0.35rem;
}
.reticle-unit.active, .reticle-plane.active { outline: 2px solid var(--accent); background: var(--bg2); }
.reticle-stage {
  cursor: zoom-in;
  width: 100%;
  height: min(calc(100dvh - 8.5rem), 100vw);
  max-height: calc(100dvh - 8.5rem);
  min-height: 16rem;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.reticle-yards,
.reticle-mag {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  min-width: 0;
}
.reticle-yards.disabled { opacity: 0.45; }
.reticle-yards-slider,
.reticle-mag-slider {
  width: 100%;
  min-width: 0;
}
.reticle-yards-readout,
.reticle-mag-readout {
  min-width: 3.6rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  color: var(--accent);
}
.reticle-turret-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem 0.85rem;
  align-items: start;
  justify-items: stretch;
}
.reticle-turret-row .field {
  align-items: center;
  text-align: center;
}
.reticle-turret-row .field-name {
  width: 100%;
  text-align: center;
}
.reticle-turret {
  display: grid;
  justify-items: center;
  gap: 0.2rem;
  width: 100%;
  min-width: 0;
  user-select: none;
}
.reticle-toolbar .reticle-turret-name { display: none; }
.reticle-turret-name {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--accent);
}
.reticle-turret-well {
  position: relative;
  width: 3.6rem;
  height: 3.6rem;
}
.reticle-turret-well::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid var(--accent);
  z-index: 1;
}
.reticle-turret-knob {
  width: 3.6rem;
  height: 3.6rem;
  border-radius: 50%;
  background: repeating-conic-gradient(from var(--rot, 0deg), #3a372e 0 7deg, #1c1b16 7deg 14deg);
  border: 3px solid #8a8374;
  box-shadow: inset 0 0 0 0.55rem #2a281f, 0 2px 6px rgb(0 0 0 / 0.45);
  position: relative;
  cursor: grab;
  touch-action: none;
}
.reticle-turret-knob::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(#e8c98a, #e8c98a) 50% 0.45rem / 3px 0.7rem no-repeat;
  transform: rotate(var(--rot, 0deg));
  pointer-events: none;
}
.reticle-turret-knob:active { cursor: grabbing; }
.reticle-turret-readout {
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  color: var(--ink);
  min-height: 1.1rem;
  text-align: center;
}
.reticle-turret-btns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.25rem;
  width: 100%;
  max-width: 8.4rem;
}
.reticle-turret-btn, .reticle-turret-zero {
  min-width: 0;
  min-height: 2.2rem;
  width: 100%;
  padding: 0;
  font-size: 0.75rem;
}
.reticle-toolbar-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}
.reticle-toolbar-actions button {
  width: 100%;
  min-width: 0;
  min-height: 2.6rem;
}
.target-lightbox {
  position: fixed; inset: 0; z-index: 80;
  background: rgb(10 12 8 / 0.96);
  display: flex; flex-direction: column;
}
.target-lightbox-chrome {
  flex: 0 0 auto;
  z-index: 3;
  background: rgb(12 14 10 / 0.98);
  border-bottom: 1px solid #3a372e;
  padding-top: max(0.4rem, env(safe-area-inset-top));
  padding-left: max(0.55rem, env(safe-area-inset-left));
  padding-right: max(0.55rem, env(safe-area-inset-right));
}
.target-lightbox-tools {
  position: relative;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0.35rem;
  align-items: stretch;
  z-index: 2;
}
.target-lightbox-hint {
  margin: 0;
  padding: 0.3rem 0.2rem 0.45rem;
  color: #9a9484;
  font-size: 0.85rem;
}
.target-zoom-stage {
  flex: 1; min-height: 0; overflow: hidden; position: relative;
  touch-action: none; cursor: grab;
}
.target-zoom-stage:active { cursor: grabbing; }
.target-zoom-inner {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  transform-origin: center center;
}
.target-zoom-inner svg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.target-zoom-btn, .target-lightbox-close { min-height: 2.5rem; min-width: 2.5rem; }
body.target-lightbox-open { overflow: hidden; }
.empty { padding: 1.5rem; color: var(--muted); }
.status-bar { margin-top: 0.5rem; padding: 0.5rem 0.65rem 0; font-size: 0.75rem; color: var(--muted); }
.search { width: min(16rem, 100%); }
.sidebar-backdrop { display: none; }
.settings-nav { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1rem; }
.settings-tab.active { outline: 2px solid var(--accent); background: var(--bg2); }
.theme-swatches { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.theme-swatch { min-width: 6.5rem; text-align: left; }
.theme-swatch.active { outline: 2px solid var(--accent); }
.user-card { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0.5rem 0.75rem; align-items: end; margin-bottom: 0.75rem; }
.check { display: flex; align-items: center; gap: 0.4rem; margin: 0.6rem 0 0.2rem; color: var(--ink); }
@media (max-width: 800px) {
  .layout,
  .layout.collapsed {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: fixed;
    z-index: 40;
    left: 0;
    top: 0;
    width: min(300px, 88vw);
    height: 100dvh;
    min-height: 100dvh;
    transform: translateX(-110%);
    transition: transform 0.2s ease;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    margin: 0;
  }
  .layout:not(.collapsed) .sidebar {
    transform: translateX(0);
    box-shadow: 12px 0 40px rgb(0 0 0 / 0.28);
  }
  .layout:not(.collapsed) .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgb(0 0 0 / 0.45);
  }
  .layout.collapsed .menu-fab { display: grid; place-items: center; }
  .layout.collapsed .main { padding-top: calc(62px + env(safe-area-inset-top, 0px)); }
  .nav-btn { min-height: 44px; padding: 12px 10px; }
  .nav-mobile-only { display: flex; }
  .main { padding: 3.4rem max(0.85rem, env(safe-area-inset-right)) max(2rem, env(safe-area-inset-bottom)) max(0.85rem, env(safe-area-inset-left)); }
  .menu-fab {
    width: 44px;
    height: 44px;
    top: calc(env(safe-area-inset-top, 0px) + 10px);
    left: calc(env(safe-area-inset-left, 0px) + 10px);
  }
  input, select, textarea, button { font-size: 16px; }
  .filters { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
  .load-table { min-width: 52rem; }
  .table-wrap { max-height: none; }
  .auth { margin: 0; padding: 1rem max(0.75rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left)); }
  .target-wrap { padding: 0.7rem 0.7rem 0.85rem; }
  .reticle-toolbar { gap: 0.6rem 0.65rem; }
  .target-lightbox-chrome {
    max-height: min(52dvh, 28rem);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
}
@media (max-width: 520px) {
  .cards { grid-template-columns: 1fr; }
  .reticle-toolbar { grid-template-columns: minmax(0, 1fr); }
  .reticle-yards,
  .reticle-mag {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
  .reticle-yards-readout,
  .reticle-mag-readout {
    grid-column: 1 / -1;
    min-width: 0;
  }
}
@media (display-mode: standalone), (display-mode: fullscreen) {
  .menu-fab {
    top: max(54px, calc(env(safe-area-inset-top, 0px) + 10px));
    left: calc(env(safe-area-inset-left, 0px) + 10px);
  }
  .layout.collapsed .main {
    padding-top: max(96px, calc(62px + env(safe-area-inset-top, 0px)));
  }
}
html.standalone .menu-fab {
  top: max(54px, calc(env(safe-area-inset-top, 0px) + 10px));
  left: calc(env(safe-area-inset-left, 0px) + 10px);
}
html.standalone .layout.collapsed .main {
  padding-top: max(96px, calc(62px + env(safe-area-inset-top, 0px)));
}
@media (min-width: 1100px) {
  .main { padding: 1.25rem 1.75rem 3rem; }
  .reticle-toolbar { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
html[data-theme="slate"] {
  --bg: #12151c; --bg2: #181c25; --card: #1e2430; --ink: #e6eaf2; --muted: #8b93a3;
  --line: #323a4a; --accent: #7aa2f7; --accent-ink: #0d1220; --sidebar: #0e1118; --sidebar-ink: #cdd3df; --focus: #9bb6f8;
}
html[data-theme="sand"] {
  --bg: #1c1812; --bg2: #241f18; --card: #2b241c; --ink: #f3ead9; --muted: #b3a48c;
  --line: #433b2e; --accent: #e0a45a; --accent-ink: #1a130a; --sidebar: #15110c; --sidebar-ink: #e8dcc8; --focus: #f0c07a;
}
html[data-theme="night"] {
  --bg: #09090b; --bg2: #111113; --card: #18181b; --ink: #f4f4f5; --muted: #a1a1aa;
  --line: #27272a; --accent: #22c55e; --accent-ink: #052e16; --sidebar: #000; --sidebar-ink: #e4e4e7; --focus: #4ade80;
}
html[data-theme="light"] {
  --bg: #f4f1ea; --bg2: #fffdf8; --card: #ffffff; --ink: #1c1914; --muted: #6b6458;
  --line: #d9d2c5; --accent: #8a5a1b; --accent-ink: #fff8ee; --sidebar: #ece6d8; --sidebar-ink: #2a251c; --focus: #b07a32;
  --danger: #b42318; --ok: #3f7d2c; --warn: #a16207;
}
.sku-scan-row { display: flex; gap: 0.4rem; align-items: stretch; }
.sku-scan-row .combo { flex: 1; min-width: 0; }
.scan-sku-btn { white-space: nowrap; flex-shrink: 0; }
.scanner-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin: 1rem 0; }
.scanner-big { min-height: 4.6rem; font-size: 1.15rem; }
.scanner-big.out { background: var(--danger); color: #fff; border-color: var(--danger); }
.scanner-log { display: grid; gap: 0.5rem; }
.ok-line { color: var(--ok); margin: 0.25rem 0; }
.scanner-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgb(0 0 0 / 0.72);
  display: flex; align-items: flex-end; justify-content: center;
}
.scanner-sheet {
  width: min(100%, 32rem);
  max-height: 100dvh;
  overflow: auto;
  background: var(--bg2);
  color: var(--ink);
  padding: 1rem 1rem max(1.1rem, env(safe-area-inset-bottom));
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -12px 40px rgb(0 0 0 / 0.35);
}
.scan-reader {
  width: 100%;
  min-height: 200px;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}
.scan-reader video, .scan-reader img, .scan-reader canvas { width: 100%; display: block; }
.scan-actions { margin: 0.6rem 0; }
.scan-photo-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.6rem; padding: 0.45rem 0.8rem;
  background: var(--line); border-radius: 6px; cursor: pointer; color: var(--ink);
}
.scan-photo-btn input { display: none; }
.scan-hit { margin: 0.5rem 0; }
.scanner-hit-card { margin: 0; }
.firearm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.85rem;
}
.firearm-card {
  display: flex; flex-direction: column; align-items: stretch; gap: 0.35rem;
  text-align: left; padding: 0.55rem; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); border-radius: 10px; cursor: pointer;
}
.firearm-card img, .firearm-ph {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px;
  background: var(--bg2);
}
.firearm-ph { display: grid; place-items: center; color: var(--muted); font-size: 0.85rem; }
.firearm-card strong { font-size: 0.95rem; }
.firearm-photos { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; }
.firearm-photos img {
  width: 9rem; height: 9rem; object-fit: cover; border-radius: 8px; cursor: zoom-in;
  border: 1px solid var(--line);
}
.firearm-dl { display: grid; grid-template-columns: 10rem 1fr; gap: 0.35rem 0.85rem; }
.firearm-dl dt { color: var(--muted); }
.firearm-dl dd { margin: 0; }
.photo-lightbox {
  position: fixed; inset: 0; z-index: 80; background: rgb(0 0 0 / 0.82);
  display: grid; place-items: center; padding: 1.5rem;
}
.photo-lightbox img { max-width: 100%; max-height: 88vh; object-fit: contain; border-radius: 8px; }
.photo-caption { color: #ddd; margin-top: 0.5rem; text-align: center; }
.form-overlay {
  position: fixed; inset: 0; z-index: 85;
  background: rgb(0 0 0 / 0.72);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 1.25rem 1rem 2rem;
  overflow: auto;
}
.form-overlay-sheet {
  width: min(100%, 46rem);
  margin: auto;
  background: var(--bg2);
  color: var(--ink);
  padding: 1rem 1.1rem 1.2rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 16px 48px rgb(0 0 0 / 0.4);
  position: relative;
  overflow: visible;
}
.form-overlay-sheet > form.card {
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  box-shadow: none;
}
.form-overlay-close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border-radius: 999px;
  font-size: 1.25rem;
  line-height: 1;
  z-index: 2;
}
.form-overlay-sheet form h2 { padding-right: 2.2rem; }
.optic-opt-card { margin: 0 0 0.85rem; }
.optic-opt-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.45rem; }
.optic-opt-head h2 { margin: 0; font-size: 1rem; }
.optic-opt-add { display: flex; gap: 0.4rem; align-items: stretch; margin-top: 0.55rem; }
.optic-opt-add input { flex: 1; min-width: 0; }
.optic-chip-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.optic-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.35rem 0.2rem 0.65rem;
  color: var(--ink);
}
.optic-chip input {
  width: auto;
  min-width: 6rem;
  max-width: 14rem;
  border: 0;
  background: transparent;
  padding: 0.15rem 0.1rem;
}
.optic-chip button {
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
}
.optic-chip button:hover { color: var(--danger); background: var(--line); }
.optic-chip.builtin { opacity: 0.92; }
.page-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0 0 1rem;
  padding: 0 0 0.35rem;
  border-bottom: 1px solid var(--line);
}
a.page-tab, button.page-tab {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  border-radius: 6px 6px 0 0;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
  background: transparent;
  font: inherit;
  cursor: pointer;
}
a.page-tab:hover, button.page-tab:hover { color: var(--ink); background: var(--bg2); }
a.page-tab.active, button.page-tab.active {
  color: var(--ink);
  background: var(--card);
  border-color: var(--line);
  font-weight: 600;
}
.lab-charts { display: grid; gap: 0.75rem; }
.lab-chart { overflow: hidden; }
.lab-chart-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 0.75rem;
}
.lab-compare-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; }
.lab-compare-hint { margin: 0; }
.lab-legend { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; font-size: 0.82rem; color: var(--muted); }
.lab-legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.lab-swatch { display: inline-block; width: 1.15rem; border-top: 3px solid currentColor; }
.lab-swatch.dash { border-top-style: dashed; }
.lab-delta { font-variant-numeric: tabular-nums; }
.lab-svg { width: 100%; height: auto; color: var(--muted-foreground, var(--muted)); }
.lab-svg .lab-gridline { stroke: currentColor; stroke-width: 1; opacity: 0.2; }
.lab-svg .lab-axis { stroke: currentColor; stroke-width: 1.25; opacity: 0.55; }
.lab-svg .lab-zero { stroke: currentColor; stroke-width: 1.25; opacity: 0.4; }
.lab-svg .lab-tick-label { fill: currentColor; font-size: 9px; }
.lab-tip { margin: 0 0 0.25rem; }
.lab-svg .lab-hold-mark { stroke: var(--accent); stroke-width: 1.6; opacity: 0.9; }
.lab-hold { display: grid; gap: 0.55rem; }
.lab-hold h2 { margin: 0; }
.lab-hold-row { display: flex; align-items: center; gap: 0.85rem; }
.lab-hold-slider {
  flex: 1 1 auto; min-width: 0; width: 100%; height: 1.55rem; padding: 0;
  background: transparent; border: 0; accent-color: var(--accent);
}
.lab-hold-yd { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 5.5rem; }
.lab-hold-metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.65rem 1.25rem;
}
.lab-hold-metrics .field-name { margin: 0; }
.lab-hold-metrics strong { display: block; font-size: 1.12rem; font-variant-numeric: tabular-nums; }
.lab-hold-cmp {
  display: grid;
  gap: 0.18rem;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}
.lab-hold-cmp-row {
  display: grid;
  grid-template-columns: 4.6rem minmax(0, 1fr);
  gap: 0.35rem 0.5rem;
  align-items: baseline;
}
.lab-hold-cmp-row .lab-delta { font-weight: 600; }
.lab-view-kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.55rem 1rem; }
.lab-view-row { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.lab-locked-val { font-variant-numeric: tabular-nums; }
.lab-shell-tabs { margin-bottom: 0.75rem; }
.lab-work-compare {
  display: grid;
  grid-template-columns: minmax(17rem, 22rem) minmax(0, 1fr);
  gap: 0.85rem 0.65rem;
  align-items: start;
}
.lab-work-compare > .lab-compare-inputs {
  grid-column: 1;
  grid-row: 1;
  align-self: start;
  position: sticky;
  top: 0.5rem;
  max-height: calc(100dvh - 1rem);
  overflow: auto;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
  z-index: 2;
}
.lab-work-compare > .lab-results { display: contents; }
.lab-chart-col { display: grid; gap: 0.65rem; min-width: 0; }
.lab-work-compare .lab-chart-col { grid-column: 2; grid-row: 1; }
.lab-table-host { overflow-x: auto; }
.lab-work-compare .lab-cmp-headrow {
  min-height: 2.35rem;
  align-items: center;
  margin: 0 0 0.35rem;
  padding: 0 0 0.35rem;
  border-bottom: 1px solid var(--line);
}
.lab-work-compare .lab-chart-head .page-tabs { margin: 0; }
.lab-work-compare .lab-results { min-width: 0; }
.lab-cmp-headrow { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.lab-compare-inputs h2 { margin: 0; font-size: 0.95rem; }
.lab-cmp-legend { margin: 0.15rem 0 0.35rem; font-size: 0.72rem; }
.lab-work-compare .lab-cmp-legend { margin-top: 0; }
.lab-cmp-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.28rem 0.4rem;
}
.lab-work-compare .lab-cmp-tiles {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.5rem;
}
.lab-cmp-tile {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.12rem 0.28rem;
  align-items: center;
  margin: 0;
  min-width: 0;
  font-size: inherit;
  color: inherit;
}
.lab-cmp-tile .lab-cmp-label {
  grid-column: 1 / -1;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  line-height: 1.15;
}
.lab-locked {
  padding: 0.18rem 0.32rem;
  border: 1px dashed var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lab-cmp-tile input, .lab-cmp-tile select {
  width: 100%;
  min-width: 0;
  padding: 0.18rem 0.32rem;
  font-size: 0.8rem;
}
.lab-compare-inputs .toolbar { margin-top: 0.4rem; gap: 0.3rem; }
.lab-compare-inputs .toolbar button { padding: 0.28rem 0.5rem; font-size: 0.78rem; }
.lab-profiles h2 { margin: 0; }
@media (max-width: 900px) {
  .lab-work-compare { grid-template-columns: 1fr; }
  .lab-work-compare > .lab-compare-inputs,
  .lab-work-compare .lab-chart-col { grid-column: auto; grid-row: auto; }
  .lab-work-compare .lab-compare-inputs { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 720px) {
  .lab-cmp-tiles { grid-template-columns: 1fr; }
}
.optic-chip.builtin input { font-weight: 600; }
.error-popup {
  position: fixed; inset: 0; z-index: 120;
  background: rgb(0 0 0 / 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1.25rem;
}
.error-popup-sheet {
  width: min(100%, 26rem);
  background: var(--bg2);
  color: var(--ink);
  border: 1px solid var(--danger);
  border-radius: 12px;
  padding: 1.1rem 1.15rem 1.2rem;
  box-shadow: 0 16px 48px rgb(0 0 0 / 0.45);
}
.error-popup-sheet h2 { margin: 0 0 0.45rem; color: var(--danger); font-size: 1.05rem; }
.app-popup-sheet { border-color: var(--line); width: min(100%, 34rem); }
.app-popup-sheet h2 { color: var(--ink); }
.load-detail-sheet {
  width: min(100%, 48rem);
  max-height: min(90vh, 48rem);
  overflow: auto;
  padding: 0.9rem 1rem 1rem;
}
.load-detail-body { display: grid; gap: 0.7rem; }
.load-detail-sheet .cartridge-spec,
.load-detail-sheet .load-spec {
  grid-template-columns: minmax(7.5rem, 11rem) 1fr;
  gap: 0.5rem 0.85rem;
  padding: 0.5rem 0.6rem;
  margin: 0;
}
.load-detail-sheet .load-spec-wide {
  grid-template-columns: 1fr;
}
.load-detail-sheet .load-spec-wide .spec-diagram {
  width: 100%;
  padding: 0.35rem;
}
.load-detail-sheet .load-spec-wide .spec-diagram img {
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
}
.load-detail-sheet .cartridge-spec h2 { font-size: 0.92rem; }
.load-detail-sheet .cartridge-spec .spec-dl {
  gap: 0.1rem 0.7rem;
  margin: 0.25rem 0 0;
}
.load-detail-sheet .cartridge-spec .spec-dl dt { font-size: 0.68rem; }
.load-detail-sheet .cartridge-spec .spec-dl dd { font-size: 0.85rem; }
.load-section h3 {
  margin: 0 0 0.4rem;
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.load-kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.25rem, 1fr));
  gap: 0.55rem 0.75rem;
}
.load-kv {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}
.load-kv .k {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.load-kv .v {
  font-family: var(--mono);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.load-notes p { margin: 0; font-size: 0.9rem; line-height: 1.35; }
.load-revs { margin: 0; font-size: 0.78rem; }
.popup-actions { margin: 0.7rem 0 0; justify-content: flex-end; gap: 0.4rem; }
@media (max-width: 720px) {
  .load-detail-sheet .cartridge-spec,
  .load-detail-sheet .load-spec { grid-template-columns: 1fr; }
}
.existing-photos { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.35rem 0 0.5rem; }
.spec-thumb { width: 5.5rem; height: 5.5rem; object-fit: contain; background: #fff; border-radius: 6px; border: 1px solid var(--line); }
.spec-diagram img + img { margin-top: 0.45rem; }
.cost-breakdown { text-decoration: underline; text-underline-offset: 2px; }
.cost-breakdown-body { display: grid; gap: 0.45rem; }
.cost-line { display: grid; grid-template-columns: 7.5rem 1fr auto; gap: 0.5rem; align-items: baseline; }
.cost-line strong { font-variant-numeric: tabular-nums; }
.error-popup-sheet p { margin: 0 0 0.9rem; }
