/* =============================================================
   Inventario — Design system
   Palette: Obsidian Depth (dark)
   Inspiration: Linear / Raycast / GitHub
   No glassmorphism, no gradients, no transform animations.
   ============================================================= */

:root {
  color-scheme: dark;

  --bg: #0a0a0a;
  --surface: #111111;
  --surface-2: #161616;
  --surface-3: #1c1c1c;
  --surface-hover: #1a1a1a;

  --line: #1f1f1f;
  --line-2: #2a2a2a;
  --line-strong: #353535;

  --text: #ededed;
  --text-dim: #c4c4c4;
  --muted: #8b8b8b;
  --muted-2: #5e5e5e;

  --primary: #00d4aa;
  --primary-hover: #1cdfb5;
  --primary-soft: rgba(0, 212, 170, 0.12);
  --primary-ring: rgba(0, 212, 170, 0.22);
  --primary-contrast: #04140f;

  --danger: #ff5b8a;
  --danger-soft: rgba(255, 91, 138, 0.12);

  --r-sm: 5px;
  --r-md: 7px;
  --r-lg: 10px;
  --r-xl: 12px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);

  --ease: cubic-bezier(0.2, 0, 0, 1);
  --t-fast: 120ms;
  --t-base: 160ms;
  --t-slow: 220ms;

  --sidebar-w: 240px;
  --topbar-h: 56px;
  --content-max: 1180px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

input,
select,
textarea,
button {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--primary-soft);
}

/* Scrollbar — discreta */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--line-strong);
  background-clip: padding-box;
  border: 2px solid transparent;
}

/* =======================
   Layout shell
   ======================= */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 18px 12px 14px;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 16px;
}

.brand-logo {
  display: block;
  width: 152px;
  height: auto;
  border-radius: var(--r-md);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 4px;
}

.nav-section {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted-2);
  padding: 14px 10px 6px;
  letter-spacing: 0.02em;
}

.nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-md);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.nav a i {
  font-size: 15px;
  color: var(--muted-2);
  transition: color var(--t-fast) var(--ease);
  width: 16px;
  text-align: center;
}

.nav a:hover {
  background: var(--surface-2);
  color: var(--text-dim);
}
.nav a:hover i {
  color: var(--muted);
}

.nav a.is-active {
  background: var(--surface-2);
  color: var(--text);
}
.nav a.is-active i {
  color: var(--primary);
}
.nav a.is-active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--primary);
  border-radius: 2px;
}

.sidebar-foot {
  margin-top: auto;
  padding: 10px;
  color: var(--muted-2);
  font-size: 11.5px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kbd {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 5px;
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  color: var(--muted);
}

/* =======================
   Topbar (content)
   ======================= */

.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px;
  background: rgba(10, 10, 10, 0.85);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(140%) blur(6px);
  -webkit-backdrop-filter: saturate(140%) blur(6px);
}

.mobile-topbar-brand {
  display: none;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
}

.mobile-topbar-brand img {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.scan-form {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 520px;
}

.scan-shell {
  position: relative;
  flex: 1;
}

.scan-shell > i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-2);
  font-size: 14px;
  pointer-events: none;
}

.scan-input {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  padding: 0 36px 0 32px;
  outline: none;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.scan-input::placeholder {
  color: var(--muted-2);
}

.scan-input:focus {
  border-color: var(--line-strong);
  background: var(--surface-3);
}

.scan-hint {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.topbar-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.topbar-notice {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 13px;
}

.topbar-notice span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =======================
   Main
   ======================= */

.main {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 28px 24px 56px;
  animation: pageIn var(--t-slow) var(--ease) both;
}

@keyframes pageIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.page-head .actions {
  flex-wrap: nowrap;
}

.h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--text);
  margin: 0;
}

.h1 i {
  color: var(--muted);
  font-size: 19px;
}

.h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 14px;
  letter-spacing: -0.005em;
}

.h2 i {
  color: var(--muted);
  font-size: 15px;
}

.h3 {
  margin: 0 0 8px;
  font-size: 13.5px;
  line-height: 1.3;
  font-weight: 650;
  color: var(--text);
}

.page-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}

/* =======================
   Grids
   ======================= */

.grid {
  display: grid;
  gap: 12px;
}
.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Stagger animation for grid/list items */
.stagger > * {
  opacity: 0;
  animation: itemIn 360ms var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * 35ms + 40ms);
}

.stagger.paginated-list > * {
  opacity: 1;
  animation: none;
}

@keyframes itemIn {
  from {
    opacity: 0;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* =======================
   Cards
   ======================= */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  transition: border-color var(--t-base) var(--ease), background var(--t-base) var(--ease);
}

.card-hover:hover {
  border-color: var(--line-2);
  background: var(--surface-hover);
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px 16px;
}

.stat-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}

.stat-label i {
  font-size: 14px;
}

.stat {
  font-size: 26px;
  line-height: 1.1;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-meta {
  font-size: 12px;
  color: var(--muted-2);
}

/* =======================
   Buttons
   ======================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text-dim);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
}

.btn i {
  font-size: 14px;
  line-height: 1;
}

.btn:hover {
  background: var(--surface-3);
  border-color: var(--line-strong);
  color: var(--text);
}

.btn:active {
  background: var(--surface-2);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--primary-ring);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-contrast);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--primary-contrast);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-soft);
  border-color: rgba(255, 91, 138, 0.3);
  color: #ffb1c8;
}

.btn-sm {
  height: 28px;
  padding: 0 9px;
  font-size: 12.5px;
}

.btn-icon {
  width: 32px;
  padding: 0;
}

.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.actions form,
.table-actions form,
.user-row-actions form {
  margin: 0;
}

.table-actions,
.user-row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.table-actions {
  width: 100%;
}

.topbar-actions form {
  margin: 0;
}

.mobile-actions-menu {
  position: relative;
  display: none;
}

.mobile-actions-menu summary {
  list-style: none;
}

.mobile-actions-menu summary::-webkit-details-marker {
  display: none;
}

.mobile-actions-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 176px;
  display: grid;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  z-index: 70;
}

.mobile-actions-panel form {
  margin: 0;
}

.mobile-action {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 9px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
}

.mobile-action:hover {
  background: var(--surface-2);
  color: var(--text);
}

.mobile-action i {
  width: 15px;
  color: var(--muted);
}

/* =======================
   Inputs / forms
   ======================= */

.input,
.textarea,
.select {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  padding: 0 10px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted-2);
}

.textarea {
  height: auto;
  min-height: 88px;
  padding: 9px 10px;
  resize: vertical;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
  background: var(--surface-2);
}

.input[type="file"] {
  padding: 6px 10px;
  height: auto;
}

.form {
  display: grid;
  gap: 14px;
  max-width: 720px;
}

.field {
  display: grid;
  gap: 6px;
}

.label {
  font-weight: 500;
  font-size: 12.5px;
  color: var(--text-dim);
}

/* Search input (page-level) */
.search-shell {
  position: relative;
}
.search-shell > i {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  font-size: 15px;
}
.search-input {
  height: 44px;
  padding-left: 40px;
  font-size: 15px;
}

/* =======================
   Tables
   ======================= */

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: 13.5px;
}

.filter-header {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.filter-toggle i {
  font-size: 12px;
}

.filter-toggle:hover,
.filter-toggle.is-active {
  background: var(--surface-3);
  color: var(--primary);
}

.filter-dropdown {
  position: fixed;
  z-index: 70;
  width: 220px;
  max-height: 280px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.filter-dropdown[hidden] {
  display: none;
}

.filter-dropdown-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}

.check-row-all {
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
  padding-bottom: 8px;
}

.filter-dropdown-list .check-row {
  min-height: 30px;
  font-size: 12.5px;
}

.filter-dropdown-foot {
  display: flex;
  justify-content: flex-end;
  padding: 4px 6px 6px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.table th {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  letter-spacing: 0;
  text-transform: none;
}

.table tbody tr {
  transition: background var(--t-fast) var(--ease);
}

.table tbody tr:hover {
  background: var(--surface-hover);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table a {
  color: var(--text);
  transition: color var(--t-fast) var(--ease);
}
.table a:hover {
  color: var(--primary);
}

.table .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  color: var(--text);
}

/* =======================
   Badges
   ======================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  font-size: 11.5px;
  color: var(--text-dim);
  font-weight: 500;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.badge-soft {
  background: var(--surface-3);
  border-color: var(--line);
  font-family: inherit;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.tag-usage {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.tag-list-spaced {
  margin-top: 6px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
}

.filter-chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.filter-chip:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.filter-chip input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--primary);
}

.quantity-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.quantity-pill strong {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 650;
}

/* =======================
   Detail layout
   ======================= */

.detail {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}

.detail-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.qr {
  width: 132px;
  height: 132px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  padding: 8px;
}

.detail-meta {
  display: grid;
  gap: 4px;
  font-size: 13px;
}

.kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.kv:last-child {
  border-bottom: 0;
}
.kv dt {
  color: var(--muted);
  font-size: 12.5px;
  margin: 0;
}
.kv dd {
  color: var(--text);
  margin: 0;
  font-size: 13.5px;
}

/* =======================
   Empty / utility
   ======================= */

.muted {
  color: var(--muted);
}
.small {
  font-size: 12.5px;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.empty {
  padding: 28px 20px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  display: grid;
  gap: 8px;
  justify-items: center;
}

.empty i {
  font-size: 22px;
  color: var(--muted-2);
}

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  transition: background var(--t-fast) var(--ease);
}
.list-item:last-child {
  border-bottom: 0;
}
.list-item:hover {
  background: var(--surface-hover);
}
.list-item-main {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 2px;
}
.list-item-title {
  font-weight: 550;
  color: var(--text);
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-item-meta {
  color: var(--muted);
  font-size: 12px;
}

.arrow {
  color: var(--muted-2);
  font-size: 14px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12.5px;
}

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-status {
  min-width: 46px;
  text-align: center;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.pagination .btn:disabled {
  cursor: default;
  opacity: 0.45;
}

[hidden] {
  display: none !important;
}

/* =======================
   Modal
   ======================= */

.qr-modal,
.label-print-modal,
.audit-view-modal,
.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.audit-view-modal {
  z-index: 2147483000;
  isolation: isolate;
}

.qr-modal.is-open,
.label-print-modal.is-open,
.audit-view-modal.is-open,
.confirm-modal.is-open {
  display: flex;
  animation: fadeIn var(--t-base) var(--ease);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.qr-modal-backdrop,
.label-print-backdrop,
.audit-view-backdrop,
.confirm-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.audit-view-backdrop {
  z-index: 0;
}

.qr-modal-panel,
.label-print-panel,
.confirm-modal-panel {
  position: relative;
  width: min(560px, 100%);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.audit-view-panel {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100vw - 24px));
  height: calc(100vh - 24px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}

.audit-view-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.audit-view-body {
  overflow: auto;
  padding: 16px;
}

.audit-view-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.audit-view-stat {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.audit-view-stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.audit-view-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.audit-view-section {
  margin-top: 14px;
}

.audit-view-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}

.audit-view-table th,
.audit-view-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}

.audit-view-table th {
  color: var(--muted);
  font-weight: 550;
  background: var(--surface-2);
}

.audit-view-table tr:last-child td {
  border-bottom: 0;
}

.confirm-modal {
  z-index: 95;
}

.confirm-modal-panel {
  width: min(420px, 100%);
}

.label-print-panel {
  max-height: calc(100vh - 60px);
  overflow: auto;
}

.label-print-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 360px;
  overflow: auto;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 6px 8px;
  border-radius: var(--r-md);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  transition: background var(--t-fast) var(--ease);
}

.check-row:hover {
  background: var(--surface-2);
}

.check-row input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--primary);
}

.check-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.check-row-strong {
  background: var(--surface-2);
  font-weight: 550;
  color: var(--text);
}

.qr-reader {
  position: relative;
  overflow: hidden;
  margin: 14px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #000;
  aspect-ratio: 1 / 1;
}

.qr-reader video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qr-frame {
  position: absolute;
  inset: 18%;
  border: 2px solid var(--primary);
  border-radius: 6px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.32);
}

/* =======================
   Label grid
   ======================= */

.label-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.label-card {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  transition: border-color var(--t-fast) var(--ease);
}

.label-card:hover {
  border-color: var(--line-2);
}

.label-card .qr {
  width: 72px;
  height: 72px;
  padding: 4px;
}

.label-card-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.label-card-text .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
}
.label-card-text .name {
  font-weight: 550;
  font-size: 13.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =======================
   HTMX feedback
   ======================= */

.htmx-request {
  opacity: 0.55;
  transition: opacity var(--t-base) var(--ease);
}

.htmx-settling {
  animation: fadeIn 180ms var(--ease);
}

/* =======================
   Banner / flash
   ======================= */

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 16px;
  animation: fadeIn 200ms var(--ease);
}

.banner i {
  font-size: 14px;
}

.banner-ok {
  border-color: rgba(0, 212, 170, 0.35);
  background: var(--primary-soft);
  color: #b8f4e1;
}
.banner-ok i {
  color: var(--primary);
}

.banner-error {
  border-color: rgba(255, 91, 138, 0.35);
  background: var(--danger-soft);
  color: #ffc9d9;
}
.banner-error i {
  color: var(--danger);
}

.banner-info {
  color: var(--text-dim);
}

.banner-close {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: opacity var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.banner-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.05);
}

/* =======================
   Segmented control (mode tabs in modal)
   ======================= */

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  margin-bottom: 12px;
}

.segmented label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 8px;
  border-radius: 5px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.segmented label:hover {
  color: var(--text-dim);
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented input:checked + span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.segmented label:has(input:checked) {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

/* Mode panels (only one visible at a time, JS-driven) */
.mode-panel {
  display: none;
  animation: fadeIn 160ms var(--ease);
}
.mode-panel.is-active {
  display: block;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
}
.range-row .arrow-mid {
  color: var(--muted-2);
  font-size: 14px;
  text-align: center;
}

/* =======================
   Auth
   ======================= */

.auth-page {
  min-height: 100vh;
  background: var(--bg);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(360px, 100%);
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
}

.auth-logo {
  display: block;
  width: 170px;
  height: auto;
  margin: 0 auto 4px;
}

/* =======================
   Settings
   ======================= */

.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 10px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
}

.tabs a:hover {
  color: var(--text-dim);
}

.tabs a.is-active {
  border-bottom-color: var(--primary);
  color: var(--text);
}

.settings-panel {
  max-width: 720px;
}

.settings-panel-wide {
  max-width: 980px;
}

.settings-section {
  display: grid;
  gap: 10px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--line);
}

.settings-section:last-of-type {
  border-bottom: 0;
}

.settings-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-field-span {
  grid-column: 1 / -1;
}

.settings-import-steps {
  display: grid;
  gap: 8px;
}

.settings-import-steps > div {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.settings-import-steps span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 12px;
}

.settings-import-steps p {
  margin: 2px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.settings-import-steps .mono {
  display: inline;
  line-height: inherit;
  vertical-align: baseline;
}

.import-result {
  align-items: flex-start;
}

.import-result pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  color: inherit;
  font: 12px/1.45 var(--mono);
}

.photo-dropzone {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
}

.photo-dropzone.is-dragover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}

.photo-dropzone-hint {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}

.photo-dropzone-current {
  width: 100%;
  max-width: 240px;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-2);
}

.photo-dropzone-current.is-empty {
  display: grid;
  place-items: center;
}

.photo-dropzone-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted-2);
}

.photo-dropzone-placeholder svg {
  width: 58px;
  height: 58px;
  display: block;
}

.photo-dropzone-current img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-file-input {
  width: 100%;
}

.container-preview {
  position: fixed;
  z-index: 80;
  display: none;
  width: min(320px, calc(100vw - 24px));
  pointer-events: auto;
  user-select: text;
}

.container-preview.is-visible {
  display: block;
  animation: previewIn 180ms var(--ease) both;
}

.container-preview-inner {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.container-preview-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px;
}

.container-preview-header .mono {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.container-preview-items {
  display: flex;
  flex-direction: column;
  max-height: 260px;
  overflow-y: auto;
}

.container-preview-item {
  display: grid;
  grid-template-columns: 90px 1fr 32px;
  gap: 8px;
  align-items: center;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--text);
  transition: background var(--t-fast) var(--ease);
  text-decoration: none;
}

.container-preview-item:last-child {
  border-bottom: 0;
}

.container-preview-item:hover {
  background: var(--surface-hover);
}

.container-preview-item .mono {
  font-size: 12px;
  color: var(--muted);
}

.container-preview-item span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.container-preview-item .muted {
  text-align: right;
  font-size: 11.5px;
}

.container-preview-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.item-preview {
  position: fixed;
  z-index: 80;
  display: none;
  width: min(380px, calc(100vw - 24px));
  pointer-events: auto;
  user-select: text;
}

.item-preview.is-visible {
  display: block;
  animation: previewIn 180ms var(--ease) both;
}

@keyframes previewIn {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.item-preview-inner {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

.item-preview-photo {
  width: 88px;
  height: 88px;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--surface-2);
}

.item-preview-placeholder {
  width: 88px;
  height: 88px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--muted-2);
}

.item-preview-placeholder svg {
  width: 58px;
  height: 58px;
  display: block;
}

.item-preview-body {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.item-preview-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.item-preview-code {
  font-size: 12px;
  color: var(--muted);
}

.item-preview-list {
  display: grid;
  gap: 6px;
  margin: 4px 0 0;
}

.item-preview-list > div {
  display: grid;
  gap: 2px;
}

.item-preview-list dt {
  font-size: 11px;
  color: var(--muted-2);
  text-transform: none;
}

.item-preview-list dd {
  margin: 0;
  font-size: 12.5px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.setup-body {
  min-height: 100vh;
  background: var(--bg);
}

.setup-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 820px);
  justify-content: center;
  gap: 18px;
  padding: 28px;
}

.setup-side {
  position: sticky;
  top: 28px;
  height: fit-content;
  display: grid;
  gap: 14px;
  padding: 20px;
}

.setup-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.setup-steps {
  display: grid;
  gap: 10px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.setup-steps li {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
}

.setup-steps span {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 12px;
}

.setup-steps strong,
.setup-steps small {
  display: block;
}

.setup-steps strong {
  color: var(--text);
  font-size: 13px;
}

.setup-steps small {
  font-size: 12px;
}

.setup-card {
  align-self: start;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 12px;
  align-items: start;
}

.settings-grid .api-docs-panel {
  max-width: none;
  min-width: 0;
}

.api-docs {
  min-width: 0;
}

.api-docs-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.api-docs-table {
  min-width: 620px;
}

.api-docs-table th,
.api-docs-table td {
  padding: 8px 10px;
  font-size: 12.5px;
}

.api-docs-table td:nth-child(1),
.api-docs-table td:nth-child(3) {
  width: 86px;
  white-space: nowrap;
}

.api-docs-table td:nth-child(2) {
  max-width: 260px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.api-docs-table td:nth-child(4) {
  min-width: 150px;
  white-space: normal;
}

.api-doc-page {
  display: grid;
  gap: 12px;
  max-width: 1040px;
}

.api-doc-body {
  min-height: 100vh;
  background: var(--bg);
}

.api-doc-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.api-doc-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.api-doc-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  color: var(--text);
  font-weight: 650;
}

.api-doc-brand img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.api-doc-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--muted);
}

.api-doc-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.api-doc-nav {
  display: grid;
  gap: 2px;
  overflow-y: auto;
}

.api-doc-nav a {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 32px;
  padding: 0 9px;
  border-radius: var(--r-md);
  color: var(--muted);
  font-size: 13px;
  transition: background var(--t-base) var(--ease), color var(--t-base) var(--ease);
}

.api-doc-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.api-doc-nav a.is-active {
  background: var(--surface-2);
  color: var(--text);
}

.api-doc-nav a.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: var(--primary);
}

.api-doc-back {
  margin-top: auto;
}

.api-doc-main {
  min-width: 0;
  width: 100%;
  max-width: 1120px;
  padding: 26px 28px 42px;
}

.api-doc-header {
  margin-bottom: 18px;
}

.api-doc-section {
  max-width: none;
  margin-bottom: 18px;
  scroll-margin-top: 18px;
  transition: border-color var(--t-base) var(--ease), background var(--t-base) var(--ease);
}

.api-doc-section.is-highlighted {
  border-color: var(--line-2);
  background: var(--surface-hover);
}

.api-doc-section > p {
  margin-top: 0;
  color: var(--muted);
  line-height: 1.5;
}

.api-doc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.api-doc-kv {
  display: grid;
  gap: 8px;
  margin: 0;
}

.api-doc-kv div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.api-doc-kv dt {
  color: var(--text);
}

.api-doc-kv dd {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.api-doc-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.api-code {
  max-width: 100%;
  overflow-x: auto;
  margin: 8px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre;
}

.api-code code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.api-example-list {
  display: grid;
  gap: 12px;
}

.api-example {
  min-width: 0;
}

.endpoint-doc {
  min-width: 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.endpoint-doc:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.endpoint-doc:last-child {
  padding-bottom: 0;
}

.endpoint-doc p {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.45;
}

.endpoint-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.endpoint-row {
  display: grid;
  grid-template-columns: minmax(260px, 380px) minmax(0, 1fr);
  gap: 14px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.endpoint-row:last-child {
  border-bottom: 0;
}

.endpoint-main,
.endpoint-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.endpoint-meta {
  color: var(--muted);
  line-height: 1.4;
}

.endpoint-method {
  width: 48px;
  flex: 0 0 auto;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 650;
}

.endpoint-path {
  min-width: 0;
  overflow-wrap: anywhere;
}

.user-list {
  display: grid;
  gap: 1px;
}

.user-row {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.user-row:last-child {
  border-bottom: 0;
}

.field-hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.transfer-delete-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 14px;
  align-items: end;
  margin-bottom: 12px;
}

.transfer-delete-form {
  display: grid;
  gap: 10px;
}

/* =======================
   Inventory
   ======================= */

.inventory-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 14px;
  align-items: start;
}

.inventory-panel,
.inventory-log-panel {
  display: grid;
  gap: 14px;
}

.inventory-modes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.inventory-mode {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.inventory-mode input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.inventory-mode.is-active {
  border-color: var(--line-strong);
  background: var(--surface-3);
  color: var(--text);
}

.inventory-mode.is-locked {
  cursor: not-allowed;
  opacity: 0.62;
}

.inventory-mode.is-locked.is-active {
  opacity: 1;
}

.inventory-scan-area {
  display: grid;
  gap: 8px;
}

.inventory-scan-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: stretch;
}

.inventory-scan-input {
  height: 42px;
  font-size: 16px;
}

.inventory-scan-row .btn {
  height: 42px;
}

.inventory-state-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.inventory-state {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.inventory-state-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.btn-xs {
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  font-size: 11px;
}

.inventory-state-value {
  margin-top: 5px;
  min-height: 20px;
  font-weight: 550;
}

.inventory-status {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 13px;
}

.inventory-status[data-kind="ok"] {
  border-color: rgba(0, 212, 170, 0.3);
  color: #b8f4e1;
}

.inventory-status[data-kind="error"] {
  border-color: rgba(255, 91, 138, 0.35);
  color: #ffc9d9;
}

.inventory-log {
  display: grid;
  gap: 6px;
}

.inventory-log-row {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--muted);
  font-size: 12.5px;
}

.inventory-log-ok {
  color: #b8f4e1;
}

.inventory-log-error {
  color: #ffc9d9;
}

.split-action {
  position: relative;
  display: inline-flex;
  align-items: stretch;
}

.split-action > .btn:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.split-action > .btn:nth-child(2) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left-color: rgba(255, 255, 255, 0.18);
}

.split-action-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  width: 190px;
  padding: 5px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

.split-action-menu button {
  width: 100%;
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-dim);
  text-align: left;
  cursor: pointer;
}

.split-action-menu button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.modal-toggle {
  position: fixed;
  opacity: 0;
  pointer-events: none;
}

.css-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-toggle:checked + .css-modal {
  display: flex;
}

.css-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
}

.css-modal-panel {
  position: relative;
  width: min(420px, 100%);
  padding: 18px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 420px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--text);
  animation: toastIn 240ms var(--ease) both;
  pointer-events: auto;
}

.toast.is-leaving {
  animation: toastOut 180ms var(--ease) forwards;
}

.toast-ok {
  border-color: rgba(0, 212, 170, 0.35);
  background: var(--primary-soft);
}

.toast-ok i {
  color: var(--primary);
}

.toast-error {
  border-color: rgba(255, 91, 138, 0.35);
  background: var(--danger-soft);
}

.toast-error i {
  color: var(--danger);
}

.toast-info i {
  color: var(--muted);
}

.toast span {
  flex: 1;
  line-height: 1.4;
}

.toast .toast-link {
  color: var(--primary);
  font-weight: 550;
  text-decoration: none;
}

.toast .toast-link:hover {
  text-decoration: underline;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(8px); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

/* =======================
   Responsive
   ======================= */

@media (max-width: 960px) {
  :root {
    --sidebar-w: 0px;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    top: auto;
    height: auto;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: space-between;
    padding: 5px;
    border: 1px solid var(--line-2);
    border-radius: var(--r-xl);
    background: rgba(17, 17, 17, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--shadow-md);
    z-index: 60;
  }

  .brand,
  .nav-section,
  .sidebar-foot {
    display: none;
  }

  .nav {
    display: contents;
  }

  .nav a {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 46px;
    padding: 0;
    gap: 0;
    border-radius: var(--r-md);
  }

  .nav a span {
    display: none;
  }

  .nav a i {
    width: auto;
    font-size: 18px;
    line-height: 1;
    -webkit-text-stroke: 0.25px currentColor;
  }

  .nav a.is-active i {
    font-size: 19px;
    -webkit-text-stroke-width: 0.45px;
  }

  .nav a.is-active::before {
    left: 12px;
    right: 12px;
    top: -1px;
    bottom: auto;
    width: auto;
    height: 2px;
  }

  .topbar {
    gap: 8px;
    padding: 0 12px;
  }

  .mobile-topbar-brand {
    display: inline-flex;
  }

  .scan-form {
    min-width: 0;
    max-width: none;
  }

  .scan-shell {
    min-width: 0;
  }

  .topbar-actions {
    display: none;
  }

  .mobile-actions-menu {
    display: block;
    flex-shrink: 0;
  }

  .main {
    padding: 18px 14px calc(78px + env(safe-area-inset-bottom));
  }

  .grid-2,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    overflow-x: auto;
  }

  .table {
    white-space: nowrap;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .pagination {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .pagination-actions {
    justify-content: space-between;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-form-grid {
    grid-template-columns: 1fr;
  }

  .settings-field-span {
    grid-column: auto;
  }

  .setup-shell {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .setup-side {
    position: static;
    padding: 8px 4px;
  }

  .api-doc-grid {
    grid-template-columns: 1fr;
  }

  .api-doc-layout {
    grid-template-columns: 1fr;
  }

  .api-doc-sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .api-doc-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .api-doc-main {
    padding: 18px 14px 28px;
  }

  .endpoint-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .transfer-delete-panel {
    grid-template-columns: 1fr;
  }

  .inventory-shell,
  .inventory-state-grid {
    grid-template-columns: 1fr;
  }

  .inventory-modes {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
    padding-bottom: 1px;
  }

  .tabs a {
    flex: 0 0 auto;
  }
}

@media (max-width: 520px) {
  .grid-4 {
    grid-template-columns: 1fr 1fr;
  }

  .scan-input {
    padding-right: 10px;
  }

  .scan-hint {
    display: none;
  }

  .topbar {
    padding: 0 10px;
  }

  .main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .label-grid {
    grid-template-columns: 1fr;
  }
}
