:root {
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-2: #edf2ee;
  --ink: #17201b;
  --muted: #66746c;
  --line: #dce3dd;
  --primary: #0b6f62;
  --primary-dark: #084f46;
  --accent: #c25a24;
  --gold: #b88a1e;
  --danger: #b3292f;
  --ok: #237944;
  --blue: #2b638f;
  --shadow: 0 18px 42px rgba(23, 32, 27, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

html {
  min-height: 100%;
  overflow-y: auto;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}

body,
#app {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
  overscroll-behavior-y: auto;
}

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

button {
  border: 0;
}

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

.sidebar {
  background: #14231d;
  color: #eef6f1;
  min-height: 100vh;
  height: 100vh;
  padding: max(22px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  align-self: start;
  overflow-y: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 48px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #dceee8;
  color: var(--primary-dark);
  font-weight: 800;
}

.brand-title {
  font-weight: 800;
  font-size: 1rem;
}

.brand-subtitle {
  color: #aac1b6;
  font-size: 0.82rem;
}

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

.nav button,
.compact-button {
  cursor: pointer;
}

.nav button {
  width: 100%;
  color: #cbdad2;
  background: transparent;
  min-height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  text-align: left;
}

.nav button:hover,
.nav button.active {
  background: #203a31;
  color: #ffffff;
}

.nav svg,
.button svg,
.icon-button svg,
.status-pill svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.app-icon,
.fallback-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: inline-block;
}

.app-icon {
  background: currentColor;
  mask: var(--icon-url) center / contain no-repeat;
  -webkit-mask: var(--icon-url) center / contain no-repeat;
}

.fallback-icon {
  display: inline-grid;
  place-items: center;
  font-size: 0.52rem;
  font-style: normal;
  font-weight: 800;
  line-height: 1;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  color: #aac1b6;
  font-size: 0.88rem;
}

.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
}

.connection-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--gold);
}

.connection-dot.cloud {
  background: #6bd58e;
}

.main {
  min-width: 0;
}

.topbar {
  min-height: 76px;
  padding: 16px max(28px, env(safe-area-inset-right)) 16px max(28px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  background: rgba(247, 248, 245, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 0;
  font-size: 1.85rem;
  letter-spacing: 0;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.content {
  padding: 26px max(28px, env(safe-area-inset-right)) max(42px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
  display: grid;
  gap: 24px;
}

.button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  white-space: nowrap;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease;
}

.button {
  padding: 0 14px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.button.secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.button.warn {
  background: var(--accent);
}

.button.danger {
  background: var(--danger);
}

.button.ghost {
  background: transparent;
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.icon-button {
  width: 40px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
}

.button span,
.compact-button span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.public-entry {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  overflow: hidden;
  background: #10211e url("assets/inventory-signin.webp") center / cover no-repeat;
  color: #ffffff;
}

.public-entry::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(7, 24, 22, 0.72);
}

.public-entry-inner {
  position: relative;
  z-index: 1;
  width: min(1180px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 28px max(24px, env(safe-area-inset-right)) 38px max(24px, env(safe-area-inset-left));
  display: grid;
  grid-template-rows: auto 1fr;
}

.public-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.public-entry .brand {
  min-height: 46px;
}

.public-entry .brand-mark {
  background: #dceee8;
  color: var(--primary-dark);
}

.public-entry .brand-title {
  color: #ffffff;
}

.public-entry .brand-subtitle {
  color: #c4d7ce;
}

.public-login-button {
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
}

.public-entry-hero {
  width: min(720px, 100%);
  align-self: center;
  padding: 82px 0 100px;
}

.public-entry-hero .eyebrow {
  color: #bce7d7;
}

.public-entry-hero h1 {
  max-width: 760px;
  margin: 16px 0 18px;
  font-size: clamp(2.8rem, 7vw, 5.7rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.public-entry-hero > p {
  max-width: 650px;
  margin: 0;
  color: #d4e4dd;
  font-size: 1.1rem;
}

.public-entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.public-entry-actions .button {
  min-height: 48px;
  padding-inline: 18px;
}

.public-entry-actions .button.secondary {
  background: rgba(255, 255, 255, 0.92);
  color: #17201b;
  border-color: transparent;
}

.public-entry-note {
  margin-top: 18px !important;
  color: #b8cbc3 !important;
  font-size: 0.88rem !important;
}

.login-screen {
  min-height: 100vh;
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
  background:
    linear-gradient(100deg, rgba(8, 31, 32, 0.94), rgba(8, 31, 32, 0.5)),
    url("assets/inventory-signin.webp");
  background-size: cover;
  background-position: center;
  color: #ffffff;
}

.login-panel {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 26px;
  padding: clamp(28px, 6vw, 76px);
}

.login-panel h1 {
  margin: 0;
  font-size: 3.4rem;
  line-height: 1.02;
  letter-spacing: 0;
  max-width: 780px;
}

.login-panel p {
  margin: 0;
  color: #d2e2da;
  max-width: 620px;
  font-size: 1.06rem;
}

.login-form-wrap {
  min-height: 100vh;
  width: 100%;
  min-width: 0;
  display: grid;
  align-items: center;
  padding: clamp(20px, 5vw, 64px);
  background: rgba(247, 248, 245, 0.96);
  color: var(--ink);
}

.login-form {
  width: min(100%, 480px);
  margin: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 24px;
  display: grid;
  gap: 18px;
}

.login-form h2 {
  margin: 0;
  font-size: 1.5rem;
}

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

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: #405149;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input,
.field select,
.field textarea,
.search-box input,
.scan-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

.field textarea {
  resize: vertical;
  min-height: 84px;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-box input:focus,
.scan-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 111, 98, 0.15);
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
}

.error {
  color: var(--danger);
  font-weight: 700;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.metric-card,
.item-card,
.panel-card,
.activity-row,
.member-row,
.label-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card {
  padding: 18px;
  display: grid;
  gap: 10px;
  min-height: 124px;
}

.metric-card span {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-card strong {
  font-size: 2.35rem;
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.7fr);
  gap: 18px;
  align-items: start;
}

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

.section-head h2,
.modal-title h2 {
  margin: 0;
  font-size: 1.15rem;
}

.section-head p,
.modal-title p {
  margin: 2px 0 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.segmented-control {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f7f5;
}

.segmented-control button {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.segmented-control button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.search-box {
  position: relative;
  min-width: min(100%, 280px);
  flex: 1 1 280px;
}

.search-box svg {
  position: absolute;
  top: 50%;
  left: 11px;
  transform: translateY(-50%);
  color: var(--muted);
  width: 17px;
  height: 17px;
}

.search-box input {
  padding-left: 36px;
}

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

.item-card {
  min-height: 184px;
  padding: 15px;
  display: grid;
  gap: 12px;
  cursor: pointer;
  align-content: start;
  min-width: 0;
  overflow: hidden;
}

.item-card:hover {
  border-color: rgba(11, 111, 98, 0.4);
  box-shadow: 0 10px 26px rgba(23, 32, 27, 0.08);
}

.item-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 111, 98, 0.14);
}

.item-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  min-width: 0;
}

.item-title h3 {
  margin: 0;
  font-size: 1rem;
  word-break: break-word;
}

.sku {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  word-break: break-all;
}

.stock-number {
  font-size: 2.15rem;
  font-weight: 850;
  line-height: 1;
}

.stock-label {
  color: var(--muted);
  font-size: 0.84rem;
}

.asset-card-summary {
  display: grid;
  gap: 4px;
}

.asset-card-summary strong {
  font-size: 1.25rem;
}

.asset-card-summary span {
  color: var(--muted);
  font-size: 0.88rem;
}

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

.item-card-actions {
  display: flex;
  justify-content: flex-end;
  min-width: 0;
}

.compact-button {
  max-width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 800;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: #33423a;
  font-size: 0.78rem;
  font-weight: 800;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}

.status-pill.ok {
  background: #dff2e4;
  color: #145d30;
}

.status-pill.low {
  background: #fff1cc;
  color: #6d4a00;
}

.status-pill.out {
  background: #fbe2e2;
  color: #8a171d;
}

.status-pill.info {
  background: #e0edf7;
  color: #1f5578;
}

.panel-stack {
  display: grid;
  gap: 14px;
}

.panel-card {
  padding: 16px;
}

.admin-page,
.admin-settings-form {
  display: grid;
  gap: 18px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  gap: 18px;
  align-items: stretch;
}

.admin-card,
.platform-card {
  display: grid;
  gap: 14px;
}

.admin-notice {
  max-width: 780px;
}

.platform-settings-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.admin-field-list,
.admin-member-list,
.connection-list {
  display: grid;
  gap: 10px;
}

.admin-field-row {
  display: grid;
  grid-template-columns: 34px minmax(180px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-field-row.dragging {
  opacity: 0.55;
  border-color: var(--primary);
}

.field-drag-handle {
  width: 32px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
}

.field-drag-handle:active {
  cursor: grabbing;
}

.admin-field-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  align-items: center;
}

.field-label-input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 9px;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
}

.field-label-input:hover,
.field-label-input:focus {
  border-color: var(--line);
  background: var(--surface-2);
  outline: none;
}

.admin-field-main > span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.field-order-actions {
  display: flex;
  gap: 4px;
}

.field-order-actions .icon-button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  font-weight: 900;
}

.field-advanced {
  grid-column: 2 / -1;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.field-advanced summary {
  width: max-content;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.field-advanced .field-toggle-grid {
  margin-top: 9px;
}

.field-advanced > .button {
  margin-top: 9px;
}

.field-toggle-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(96px, 1fr));
  gap: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  color: var(--ink);
  font-weight: 800;
}

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

.compact-check {
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.82rem;
}

.admin-add-field,
.company-create-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.company-create-form {
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 0.65fr) minmax(220px, 1fr) auto;
  padding-top: 4px;
}

.admin-form-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

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

.settings-overview-grid .full {
  grid-column: 1 / -1;
}

.setting-explainer {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.setting-explainer .compact-check {
  padding: 0;
  border: 0;
  background: transparent;
}

.setting-explainer p {
  margin: 3px 0 0 27px;
  color: var(--muted);
  font-size: 0.84rem;
}

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  color: var(--ok);
  font-size: 0.82rem;
  font-weight: 800;
}

.save-status svg,
.save-status .app-icon {
  width: 16px;
  height: 16px;
}

.save-status[data-state="saving"] {
  color: var(--muted);
}

.save-status[data-state="error"] {
  color: var(--danger);
}

.use-case-modal {
  width: min(840px, calc(100vw - 28px));
}

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

.use-case-option {
  min-width: 0;
  min-height: 94px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 22px;
  gap: 11px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.use-case-option:hover,
.use-case-option:focus-visible {
  border-color: var(--primary);
  background: var(--surface-2);
  outline: 3px solid color-mix(in srgb, var(--primary) 16%, transparent);
}

.use-case-option > svg:first-child,
.use-case-option > .app-icon:first-child {
  width: 28px;
  height: 28px;
  color: var(--primary);
}

.use-case-option span,
.use-case-option strong,
.use-case-option small {
  display: block;
  min-width: 0;
}

.use-case-option small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.admin-member-row {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.admin-member-actions,
.inline-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
  border: 0;
}

.data-management-grid {
  display: grid;
  gap: 10px;
}

.data-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.data-action strong,
.data-action span {
  display: block;
  min-width: 0;
}

.data-action span {
  color: var(--muted);
  font-size: 0.88rem;
}

.data-action.danger-zone {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
}

.company-list {
  display: grid;
  gap: 10px;
}

.company-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.company-row.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 111, 98, 0.12);
}

.company-row strong,
.company-row span {
  display: block;
}

.company-row span {
  color: var(--muted);
  font-size: 0.86rem;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(300px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.detail-hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  display: grid;
  gap: 18px;
}

.detail-hero h2 {
  margin: 0;
  font-size: 1.55rem;
}

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

.meta-box {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px;
  min-height: 74px;
}

.meta-box span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.meta-box strong {
  display: block;
  margin-top: 4px;
  word-break: break-word;
}

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

.scan-layout,
.batch-layout {
  display: grid;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.scan-layout > *,
.batch-layout > *,
.panel-stack,
.panel-stack > * {
  min-width: 0;
  max-width: 100%;
}

#qr-reader,
#batch-reader {
  min-height: 340px;
  border: 1px dashed #9fb2a8;
  border-radius: 8px;
  overflow: hidden;
  background: #0f1b17;
}

.native-scanner {
  min-height: 340px;
  position: relative;
  display: grid;
  place-items: center;
  background: #0f1b17;
}

.native-scanner video {
  width: 100%;
  min-height: 340px;
  object-fit: cover;
}

.native-scan-guide {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(88%, 360px);
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(15, 27, 23, 0.78);
  color: #eef6f1;
  text-align: center;
  font-weight: 700;
}

.batch-layout {
  grid-template-columns: minmax(280px, 0.9fr) minmax(340px, 1.1fr) minmax(280px, 0.7fr);
}

.batch-settings {
  align-self: start;
}

.batch-queue {
  display: grid;
  gap: 14px;
}

.batch-code-list {
  display: grid;
  gap: 8px;
  max-height: 470px;
  overflow: auto;
}

.batch-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 10px;
  align-items: center;
  padding: 10px 10px 10px 12px;
  background: var(--surface-2);
  border-radius: 8px;
}

.batch-code-row strong,
.batch-code-row span {
  display: block;
  min-width: 0;
}

.batch-code-row strong {
  word-break: break-all;
}

.batch-code-row span {
  color: var(--muted);
  font-size: 0.82rem;
}

.batch-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.scan-result {
  display: grid;
  gap: 10px;
}

.activity-list,
.member-list,
.label-grid {
  display: grid;
  gap: 10px;
}

.activity-row {
  padding: 12px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.activity-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--primary);
}

.activity-icon.remove {
  background: var(--danger);
}

.activity-icon.transfer {
  background: var(--blue);
}

.activity-icon.update {
  background: var(--gold);
}

.activity-main strong,
.member-row strong {
  display: block;
}

.activity-main span,
.activity-time,
.member-row span {
  color: var(--muted);
  font-size: 0.88rem;
}

.member-row {
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

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

.label-card {
  padding: 14px;
  display: grid;
  gap: 10px;
  page-break-inside: avoid;
}

.qr-box {
  width: 132px;
  height: 132px;
  display: grid;
  place-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.qr-box.large {
  width: 190px;
  height: 190px;
}

.label-modal {
  width: min(560px, 100%);
}

.label-modal-body {
  display: grid;
  justify-items: center;
  gap: 18px;
}

.single-label-card {
  width: min(360px, 100%);
  min-height: 280px;
  padding: 18px;
  border: 1px solid #1f2d27;
  border-radius: 8px;
  background: #ffffff;
  color: #111a16;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.single-label-code {
  min-height: 130px;
  display: grid;
  place-items: center;
}

.barcode-box {
  width: 320px;
  max-width: 100%;
  height: 128px;
}

.barcode-fallback {
  padding: 18px;
  border: 1px solid #111a16;
  font-family: "Courier New", monospace;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0;
}

.single-label-text {
  display: grid;
  gap: 4px;
  max-width: 100%;
}

.single-label-text strong,
.single-label-text span,
.single-label-text small {
  overflow-wrap: anywhere;
}

.single-label-text strong {
  font-size: 1.05rem;
}

.single-label-text span {
  font-family: "Courier New", monospace;
  font-weight: 800;
}

.single-label-text small {
  color: #405149;
}

.empty-state {
  border: 1px dashed #aab8b0;
  border-radius: 8px;
  min-height: 180px;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.empty-state.compact {
  min-height: 110px;
  padding: 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 100vw;
  background: rgba(13, 23, 19, 0.55);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 100;
}

.modal {
  width: min(720px, 100%);
  max-width: calc(100vw - 36px);
  min-width: 0;
  max-height: min(88vh, 900px);
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-head,
.modal-actions {
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.modal-title {
  min-width: 0;
  overflow: hidden;
}

.modal-head .icon-button {
  position: relative;
  z-index: 4;
  flex: 0 0 42px;
}

.modal-body {
  padding: 20px;
}

.modal-actions {
  border-top: 1px solid var(--line);
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .item-list,
  .label-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .dashboard-grid,
  .detail-layout,
  .scan-layout,
  .batch-layout,
  .admin-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 30;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left));
    overflow: visible;
  }

  .sidebar > .brand,
  .sidebar > .sidebar-footer {
    display: none;
  }

  .nav {
    grid-auto-flow: column;
    grid-auto-columns: minmax(72px, 1fr);
    overflow-x: auto;
  }

  .nav button {
    justify-content: center;
    min-width: 72px;
    padding: 0 10px;
  }

  .nav button span {
    display: none;
  }

  .topbar {
    position: static;
    padding: 18px max(18px, env(safe-area-inset-right)) 18px max(18px, env(safe-area-inset-left));
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .content {
    padding: 18px max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  }

  .login-screen {
    grid-template-columns: 1fr;
  }

  .login-panel,
  .login-form-wrap {
    min-height: auto;
  }

  .login-panel {
    padding-bottom: 26px;
  }
}

@media (max-width: 620px) {
  .modal-backdrop {
    padding: 10px;
  }

  .modal {
    width: 100%;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .modal-head,
  .modal-actions,
  .modal-body {
    padding: 14px;
  }

  .metrics-grid,
  .item-list,
  .label-grid,
  .form-grid,
  .detail-meta,
  .action-grid,
  .batch-actions,
  .admin-field-row {
    grid-template-columns: 1fr;
  }

  .admin-member-actions,
  .inline-actions {
    flex-direction: column;
  }

  .field-toggle-grid,
  .admin-add-field,
  .admin-form-footer,
  .company-create-form,
  .platform-settings-form,
  .company-row {
    grid-template-columns: 1fr;
  }

  .activity-row {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .activity-time {
    grid-column: 2;
  }
}

/* Product shell, themes, and display modes. Keep these overrides together so
   the offline web and Capacitor builds share one predictable visual system. */
:root {
  --bg: #f3f6f7;
  --surface: #ffffff;
  --surface-2: #edf2f3;
  --ink: #182226;
  --muted: #627177;
  --line: #d8e0e3;
  --primary: #087f75;
  --primary-dark: #07665f;
  --accent: #d4553d;
  --gold: #a77812;
  --danger: #b9363d;
  --ok: #247a4b;
  --blue: #316c96;
  --sidebar: #182326;
  --sidebar-active: #26383a;
  --topbar: rgba(243, 246, 247, 0.94);
  --input: #ffffff;
  --shadow: 0 12px 32px rgba(25, 40, 44, 0.08);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101617;
  --surface: #182123;
  --surface-2: #222d2f;
  --ink: #edf3f1;
  --muted: #9aaba8;
  --line: #303d3f;
  --primary: #45b9aa;
  --primary-dark: #83d6cb;
  --accent: #ee8069;
  --gold: #d8aa45;
  --danger: #ed777d;
  --ok: #61c287;
  --blue: #72abd1;
  --sidebar: #0b1011;
  --sidebar-active: #1d2c2e;
  --topbar: rgba(16, 22, 23, 0.94);
  --input: #12191a;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
}

body {
  background: var(--bg);
}

.sidebar {
  background: var(--sidebar);
}

.nav button:hover,
.nav button.active {
  background: var(--sidebar-active);
}

.topbar {
  background: var(--topbar);
}

.topbar h1 {
  font-size: 1.65rem;
}

.field label {
  color: var(--muted);
  letter-spacing: 0;
}

.field input,
.field select,
.field textarea,
.search-box input,
.scan-input {
  background: var(--input);
}

.button,
.icon-button,
.item-card,
.metric-card,
.panel-card {
  box-shadow: none;
}

.button:focus-visible,
.icon-button:focus-visible,
.nav button:focus-visible,
.item-card:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 34%, transparent);
  outline-offset: 2px;
}

.button.scan-command {
  background: var(--accent);
}

.segmented-control {
  background: var(--surface-2);
}

.segmented-control .icon-button {
  min-height: 34px;
  width: 36px;
  padding: 0;
  background: transparent;
  border: 0;
}

.segmented-control .icon-button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(20, 34, 38, 0.12);
}

.item-list-view {
  grid-template-columns: minmax(0, 1fr);
}

.item-list-view .item-card {
  min-height: 0;
  grid-template-columns: minmax(200px, 1.1fr) minmax(130px, 0.65fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 13px 15px;
}

.item-list-view .item-title,
.item-list-view .tag-row,
.item-list-view .item-card-actions {
  min-width: 0;
}

.dashboard-grid .item-list-view .item-card,
.panel-card .item-list-view .item-card {
  grid-template-columns: 1fr;
  align-items: start;
}

.item-list-view .asset-card-summary strong {
  font-size: 1rem;
}

.choice-wrap {
  align-items: center;
}

.workspace-options {
  width: 100%;
  max-width: 760px;
  min-width: 0;
  margin: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.workspace-option,
.plan-card {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 22px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.workspace-option.featured,
.plan-card.featured {
  border-color: var(--primary);
  box-shadow: inset 0 3px 0 var(--primary);
}

.workspace-option h2,
.plan-card h3 {
  margin: 0;
}

.workspace-option p,
.plan-card p,
.plan-card ul {
  margin: 0;
  color: var(--muted);
}

.workspace-option .button {
  width: 100%;
  margin-top: auto;
}

.eyebrow {
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0;
}

.upgrade-modal {
  width: min(1040px, calc(100vw - 32px));
}

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

.plan-card ul {
  padding-left: 18px;
  display: grid;
  gap: 7px;
}

.upgrade-note p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

html[data-theme="dark"] .login-form-wrap {
  background: rgba(16, 22, 23, 0.96);
}

html[data-theme="dark"] .admin-field-row,
html[data-theme="dark"] .admin-member-row,
html[data-theme="dark"] .company-row,
html[data-theme="dark"] .batch-code-row,
html[data-theme="dark"] .data-action,
html[data-theme="dark"] .segmented-control {
  background: var(--surface-2);
}

html[data-theme="dark"] .status-pill {
  background: #263336;
  color: #d9e8e4;
}

html[data-theme="dark"] .status-pill.ok {
  background: rgba(97, 194, 135, 0.18);
  color: #9ce2b3;
}

html[data-theme="dark"] .status-pill.low {
  background: rgba(216, 170, 69, 0.2);
  color: #f0cc76;
}

html[data-theme="dark"] .status-pill.out {
  background: rgba(237, 119, 125, 0.2);
  color: #ffaaa9;
}

html[data-theme="dark"] .status-pill.info {
  background: rgba(114, 171, 209, 0.18);
  color: #a9d4f0;
}

html[data-theme="dark"] .field label,
html[data-theme="dark"] .metric-card span,
html[data-theme="dark"] .meta-box span {
  color: #b7c8c4;
}

html[data-theme="dark"] .button.secondary,
html[data-theme="dark"] .icon-button,
html[data-theme="dark"] .compact-button {
  background: #202b2d;
  color: #edf3f1;
  border-color: #3b494c;
}

html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .search-box input,
html[data-theme="dark"] .scan-input {
  border-color: #3b494c;
}

@media (max-width: 900px) {
  .workspace-options,
  .plan-grid {
    grid-template-columns: 1fr;
  }

  .item-list-view .item-card {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .data-action {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .login-panel h1 {
    font-size: 2.15rem;
  }

  .public-entry-hero h1 {
    font-size: clamp(2.7rem, 10vw, 4.4rem);
  }
}

@media (max-width: 620px) {
  .app-shell,
  .main,
  .sidebar,
  .nav,
  .topbar,
  .content {
    width: 100%;
    min-width: 0;
    max-width: 100vw;
  }

  .public-entry-inner {
    padding-top: 16px;
    padding-bottom: calc(28px + env(safe-area-inset-bottom));
  }

  .public-entry-header {
    align-items: flex-start;
  }

  .public-entry-header .public-login-button {
    min-height: 40px;
    padding-inline: 11px;
  }

  .public-entry-header .public-login-button span {
    display: none;
  }

  .public-entry-hero {
    padding: 56px 0 72px;
  }

  .public-entry-hero h1 {
    font-size: clamp(2.55rem, 13vw, 4rem);
  }

  .public-entry-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .public-entry-actions .button {
    width: 100%;
  }

  .sidebar {
    overflow: hidden;
  }

  .nav {
    grid-auto-columns: 72px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .content {
    padding-bottom: calc(36px + env(safe-area-inset-bottom));
  }

  .topbar h1 {
    font-size: 1.4rem;
  }

  .topbar p {
    display: none;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, 40px);
    gap: 4px;
  }

  .topbar-actions .button,
  .topbar-actions .icon-button {
    width: 40px;
    min-height: 40px;
    padding: 0;
  }

  .topbar-actions .button span {
    display: none;
  }

}

/* Interaction and responsive hardening. These rules intentionally sit after
   the legacy breakpoints so the web and Android shells behave identically. */
.local-project-summary,
.settings-plan-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px 18px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.local-project-summary strong,
.settings-plan-row strong,
.settings-plan-row span {
  display: block;
}

.local-project-summary span,
.settings-plan-row span {
  color: var(--muted);
  font-size: 0.88rem;
}

.layout-option {
  min-height: 36px;
  padding: 0 11px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-weight: 800;
}

.layout-option.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(20, 34, 38, 0.12);
}

.item-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.item-status {
  max-width: none;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.item-open-hint {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

.inventory-section .search-box {
  display: grid;
}

.inventory-section .search-box > svg,
.inventory-section .search-box > input {
  grid-area: 1 / 1;
}

.inventory-section .search-box > i,
.inventory-section .search-box svg {
  display: none;
}

.inventory-section .search-box > input {
  padding-left: 14px;
}

.item-grid-view {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.item-grid-view .item-card {
  min-height: 152px;
  grid-template-rows: auto auto 1fr;
}

.item-grid-view .item-card-meta {
  display: none;
}

.item-grid-view .asset-card-summary strong {
  font-size: 1rem;
}

.item-grid-view .item-card-actions {
  align-items: end;
  justify-content: space-between;
  gap: 10px;
}

.item-list-view .item-open-hint {
  display: none;
}

.item-list-view .item-card-actions {
  align-items: center;
}

.scanner-station {
  position: sticky;
  top: 94px;
  align-self: start;
  min-width: 0;
}

.scanner-viewport {
  width: 100%;
  height: clamp(260px, 46vh, 430px);
  min-height: 0;
  overflow: hidden;
  border: 1px solid #6f827a;
  border-radius: 8px;
  background: #0f1b17;
  touch-action: pan-y;
}

.scanner-viewport.compact {
  height: clamp(210px, 32vh, 290px);
}

#qr-reader.scanner-reader,
#batch-reader.scanner-reader {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
}

.scanner-reader video,
.scanner-reader canvas,
.native-scanner video {
  width: 100% !important;
  height: 100% !important;
  min-height: 0;
  object-fit: cover;
  pointer-events: none;
  touch-action: pan-y;
}

.native-scanner {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.camera-zoom-control {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
}

.camera-zoom-heading,
.camera-zoom-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.camera-zoom-heading {
  justify-content: space-between;
  margin-bottom: 7px;
}

.camera-zoom-heading label {
  font-size: 0.88rem;
  font-weight: 800;
}

.camera-zoom-heading output {
  min-width: 3.2rem;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  text-align: right;
}

.camera-zoom-row svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  color: var(--muted);
}

.camera-zoom-row input[type="range"] {
  width: 100%;
  min-width: 0;
  accent-color: var(--primary);
  touch-action: pan-x;
}

.camera-zoom-row input[type="range"]:disabled {
  opacity: 0.55;
}

.camera-zoom-help {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.76rem;
}

.scanner-status {
  min-height: 44px;
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.88rem;
  font-weight: 700;
}

.scanner-state-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: #82908a;
}

.scanner-status[data-state="starting"] .scanner-state-dot {
  background: var(--gold);
}

.scanner-status[data-state="running"] .scanner-state-dot {
  background: var(--ok);
}

.scanner-manual-entry {
  margin-top: 12px;
}

.scan-manual-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.batch-layout {
  grid-template-columns: minmax(280px, 0.95fr) minmax(300px, 0.9fr) minmax(280px, 0.95fr);
  align-items: start;
}

.batch-workflow {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.batch-settings-panel summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.batch-settings-panel summary::-webkit-details-marker {
  display: none;
}

.batch-settings-panel summary > span {
  display: grid;
  gap: 3px;
}

.batch-settings-panel summary small {
  color: var(--muted);
}

.batch-settings-panel[open] summary {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.step-label {
  display: block;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

html[data-theme="dark"] .local-project-summary,
html[data-theme="dark"] .settings-plan-row,
html[data-theme="dark"] .scanner-status,
html[data-theme="dark"] .setting-explainer,
html[data-theme="dark"] .use-case-option,
html[data-theme="dark"] .admin-field-row {
  background: var(--surface-2);
}

html[data-theme="dark"] .field-label-input {
  color: var(--ink);
}

@media (max-width: 1180px) {
  .batch-layout {
    grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  }

  .batch-queue {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .batch-layout {
    grid-template-columns: 1fr;
  }

  .batch-queue {
    grid-column: auto;
  }

  .scanner-station {
    position: static;
  }

  .scanner-viewport {
    position: sticky;
    top: 8px;
    z-index: 10;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }

  .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 6px max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    overflow: hidden;
    z-index: 60;
  }

  .nav {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(78px, 1fr);
    gap: 3px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav button {
    min-width: 78px;
    min-height: 54px;
    padding: 5px 7px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 3px;
    text-align: center;
  }

  .nav button span {
    display: block;
    max-width: 100%;
    color: inherit;
    font-size: 0.66rem;
    font-weight: 750;
    line-height: 1.05;
    white-space: normal;
  }

  .topbar {
    position: static;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 14px max(14px, env(safe-area-inset-right)) 14px max(14px, env(safe-area-inset-left));
  }

  .topbar h1 {
    font-size: 1.45rem;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .topbar-actions .button,
  .topbar-actions .icon-button {
    width: 100%;
    min-height: 42px;
    padding: 0 10px;
  }

  .topbar-actions .button span {
    display: inline;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .content {
    padding: 16px max(14px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

  .inventory-section .section-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 12px;
  }

  .inventory-section .toolbar {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 8px;
  }

  .inventory-section .search-box {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }

  .inventory-section .search-box input {
    width: 100%;
  }

  .inventory-section .segmented-control,
  .inventory-section .toolbar > .button {
    width: 100%;
  }

  .inventory-section .segmented-control button {
    flex: 1 1 50%;
    justify-content: center;
    padding-inline: 8px;
  }
}

@media (max-width: 620px) {
  .item-grid-view {
    grid-template-columns: 1fr;
  }

  .item-list-view .item-card {
    gap: 10px;
    padding: 13px;
  }

  .local-project-summary,
  .settings-plan-row,
  .scan-manual-row {
    grid-template-columns: 1fr;
  }

  .settings-overview-grid,
  .use-case-grid {
    grid-template-columns: 1fr;
  }

  .admin-field-row {
    grid-template-columns: 30px minmax(0, 1fr) auto;
  }

  .admin-field-row > .compact-check {
    grid-column: 2 / 3;
    width: max-content;
  }

  .field-order-actions {
    grid-column: 3;
    grid-row: 1 / span 2;
    flex-direction: column;
  }

  .field-advanced {
    grid-column: 1 / -1;
  }

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

  .settings-plan-row .button,
  .scan-manual-row .button {
    width: 100%;
  }

  .scanner-viewport {
    height: clamp(230px, 42vh, 340px);
  }

  .scanner-viewport.compact {
    height: clamp(190px, 28vh, 240px);
  }

  .batch-settings-panel summary {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 420px) {
  .item-title {
    grid-template-columns: minmax(0, 1fr);
  }

  .item-status {
    justify-self: start;
  }

  .topbar-actions {
    grid-template-columns: 1fr 1fr;
  }
}

.smart-toggle-card {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.smart-toggle {
  width: 100%;
  min-height: 48px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.smart-toggle > span:first-child,
.smart-suggestion-panel > div,
.smart-suggestion-head > div,
.smart-suggestion-row > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.smart-toggle small,
.smart-toggle-card p,
.smart-suggestion-panel span,
.smart-suggestion-row span,
.smart-suggestion-row small {
  color: var(--muted);
}

.smart-suggestion-row small {
  font-size: 0.76rem;
}

.smart-toggle-card p {
  margin: 7px 0 0;
  font-size: 0.8rem;
}

.switch-track {
  width: 44px;
  height: 24px;
  padding: 3px;
  flex: 0 0 44px;
  border-radius: 999px;
  background: var(--muted);
}

.switch-track span {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform 140ms ease;
}

.smart-toggle[aria-checked="true"] .switch-track {
  background: var(--primary);
}

.smart-toggle[aria-checked="true"] .switch-track span {
  transform: translateX(20px);
}

.smart-suggestion-panel {
  margin-bottom: 18px;
  padding: 13px;
  display: grid;
  gap: 10px;
  border: 1px solid color-mix(in srgb, var(--primary) 45%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 7%, var(--surface));
}

.smart-suggestion-panel.quiet {
  min-height: 60px;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  border-color: var(--line);
  background: var(--surface-2);
}

.smart-suggestion-panel.quiet .app-icon {
  color: var(--muted);
}

.smart-suggestion-head,
.smart-suggestion-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.smart-suggestion-list,
.smart-mapping-list,
.smart-mapping-section {
  display: grid;
  gap: 8px;
}

.smart-suggestion-row {
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.smart-suggestion-row strong,
.smart-mapping-list span {
  overflow-wrap: anywhere;
}

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

.smart-field-settings {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.smart-field-settings legend {
  padding: 0 6px;
  color: var(--ink);
  font-weight: 800;
}

.smart-field-settings .check-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
}

.smart-provider-settings {
  margin-top: 14px;
}

.smart-mapping-section {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.compact-head {
  margin-bottom: 0;
}

@media (max-width: 700px) {
  .smart-admin-columns {
    grid-template-columns: 1fr;
  }

  .smart-suggestion-head,
  .smart-suggestion-row {
    align-items: stretch;
    flex-direction: column;
  }

  .smart-suggestion-head .button,
  .smart-suggestion-row .compact-button {
    width: 100%;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .sidebar,
  .topbar,
  .no-print {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .content {
    padding: 0;
  }

  .label-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .label-card {
    box-shadow: none;
    border: 1px solid #333333;
  }

  body.printing-label {
    background: #ffffff;
  }

  body.printing-label .sidebar,
  body.printing-label .main,
  body.printing-label .modal-head,
  body.printing-label .modal-actions,
  body.printing-label .no-print {
    display: none !important;
  }

  body.printing-label .modal-backdrop {
    position: static;
    inset: auto;
    padding: 0;
    background: #ffffff;
  }

  body.printing-label .modal {
    width: 100%;
    max-height: none;
    box-shadow: none;
    border-radius: 0;
  }

  body.printing-label .modal-body {
    padding: 0;
  }

  body.printing-label .single-label-card {
    margin: 0 auto;
    box-shadow: none;
    break-inside: avoid;
  }
}
