:root {
  color-scheme: dark;
  --background: #0f141b;
  --surface: #151a22;
  --surface-soft: #1d2633;
  --text: #f6f8fb;
  --muted: #9aa8bb;
  --line: #2d3746;
  --primary: #2d86ff;
  --primary-dark: #6ec8ff;
  --warning: #ffb454;
  --danger: #ff5f5f;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 0 0, rgba(45, 134, 255, 0.18), transparent 420px),
    linear-gradient(180deg, #111923 0, var(--background) 380px);
}

.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 40px 24px;
  background:
    radial-gradient(circle at 14% 28%, rgba(45, 134, 255, 0.18), transparent 360px),
    radial-gradient(circle at 82% 84%, rgba(45, 134, 255, 0.16), transparent 420px),
    linear-gradient(135deg, #14243a 0, #0f141b 33%, #111821 70%, #15263d 100%);
}

.login-layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(320px, 620px) minmax(340px, 420px);
  align-items: center;
  gap: clamp(48px, 9vw, 128px);
  width: min(100%, 1120px);
  min-height: min(760px, calc(100vh - 80px));
}

.login-brand {
  display: grid;
  gap: 28px;
  align-content: center;
}

.login-brand .kicker {
  margin-bottom: 8px;
  color: #6ec8ff;
}

.login-logo {
  width: min(100%, 540px);
  filter: drop-shadow(0 22px 54px rgba(45, 134, 255, 0.24));
}

.login-copy {
  max-width: 620px;
  margin: 0;
  color: #b7d9f8;
  font-size: 1.13rem;
  line-height: 1.7;
}

.login-card {
  display: grid;
  gap: 20px;
  width: min(100%, 420px);
  border: 1px solid #334256;
  border-radius: 22px;
  background: rgba(21, 26, 34, 0.82);
  box-shadow: 0 28px 78px rgba(0, 0, 0, 0.42);
  padding: 30px 28px 28px;
}

.login-card h1 {
  margin-bottom: 10px;
  font-size: 1.9rem;
  line-height: 1.1;
}

.login-eyebrow {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.login-tabs button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: #d7e2f0;
  font-weight: 900;
}

.login-tabs .is-active {
  border-color: var(--primary);
  background: rgba(45, 134, 255, 0.18);
  color: #ffffff;
}

.login-card label {
  color: #c7d0dd;
}

.login-card input {
  min-height: 48px;
  border-color: transparent;
  background: #e8f0fb;
  color: #0f141b;
}

.login-card input::placeholder {
  color: #52627a;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 72px;
}

.password-field button {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #7db7ff;
  font-weight: 900;
}

.forgot-button {
  justify-self: end;
  margin-top: -8px;
  border: 0;
  background: transparent;
  color: #8ec5ff;
  font-size: 0.82rem;
  font-weight: 700;
}

.login-submit {
  min-height: 50px;
  border: 1px solid var(--primary);
  border-radius: 10px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 900;
}

.login-footer {
  position: absolute;
  left: 50%;
  bottom: 12px;
  display: flex;
  gap: 10px;
  transform: translateX(-50%);
  color: #9fb1c7;
  font-size: 0.8rem;
}

.login-footer a {
  color: inherit;
  text-decoration: none;
}

.login-error {
  margin: 0;
  border: 1px solid rgba(255, 95, 95, 0.42);
  border-radius: 8px;
  background: rgba(255, 95, 95, 0.13);
  color: #ff9d9d;
  padding: 10px;
  font-weight: 800;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(1800px, calc(100% - 24px));
  margin: 0 auto;
  padding: 32px 0;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.brand-heading {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.app-logo {
  width: clamp(138px, 18vw, 225px);
  flex: 0 0 auto;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.user-badge {
  display: inline-grid;
  place-items: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--primary-dark);
  padding: 0 12px;
  font-weight: 900;
}

.menu-wrap {
  position: relative;
}

.app-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 25;
  display: grid;
  gap: 6px;
  width: min(280px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 10px;
}

.app-menu button,
.app-menu label {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 9px 10px;
  text-align: left;
  font-weight: 850;
}

.app-menu button:hover,
.app-menu label:hover {
  background: var(--surface-soft);
}

.app-menu label {
  display: block;
}

.app-menu select {
  min-height: 38px;
  font-size: 0.9rem;
  text-transform: none;
}

.submenu-wrap {
  position: relative;
}

.submenu-panel {
  position: absolute;
  top: 0;
  right: calc(100% + 8px);
  z-index: 26;
  display: grid;
  gap: 6px;
  width: min(300px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 10px;
}

.submenu-panel button {
  width: 100%;
}

.header-select {
  min-width: 210px;
}

.header-select select {
  min-height: 40px;
  font-size: 0.92rem;
  font-weight: 800;
  text-transform: none;
}

.kicker {
  margin: 0 0 8px;
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.inventory-folders {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  padding: 18px;
}

.barcode-panel {
  margin-bottom: 0;
}

.barcode-modal-card {
  width: min(100%, 1080px);
}

.barcode-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 1fr) max-content max-content;
  gap: 10px;
  align-items: end;
}

.barcode-form .primary-button,
.barcode-form .secondary-button {
  width: auto;
  min-width: 108px;
  height: 42px;
  align-self: end;
  justify-self: start;
  padding: 0 14px;
  white-space: nowrap;
}

.barcode-form #printBarcode {
  min-width: 82px;
}

.barcode-output {
  display: grid;
  place-items: center;
  min-height: 190px;
  margin-top: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 16px;
  overflow-x: auto;
}

.barcode-output p {
  margin: 0;
  color: var(--muted);
}

.barcode-svg {
  width: min(100%, 720px);
  height: auto;
  border: 1px solid var(--line);
}

.barcode-svg text {
  fill: var(--text);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
}

.barcode-svg .barcode-value {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.barcode-matches {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 14px;
}

.barcode-matches h3 {
  margin: 0 0 10px;
  font-size: 0.9rem;
}

.match-list {
  display: grid;
  gap: 8px;
}

.match-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.match-row strong,
.match-row span {
  display: block;
}

.match-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.match-row button {
  min-height: 34px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  padding: 0 12px;
  font-weight: 800;
  white-space: nowrap;
}

.match-row button:disabled {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--primary-dark);
  cursor: default;
}

.match-row button.danger-action {
  border-color: #ffd0c2;
  background: #ffe9df;
  color: var(--danger);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-heading p {
  margin: 6px 0 0;
  color: var(--muted);
}

.new-inventory-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 160px) auto;
  gap: 10px;
  align-items: center;
  width: min(100%, 560px);
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.folder-card {
  position: relative;
  display: grid;
  gap: 5px;
  min-height: 126px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fdfefe;
  color: var(--text);
  padding: 26px 16px 16px;
  cursor: pointer;
  text-align: left;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease,
    background 140ms ease;
}

.folder-menu-button {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 26px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.15rem;
  font-weight: 900;
  line-height: 1;
  padding: 0;
  text-align: center;
}

.folder-menu-button:hover {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--primary-dark);
}

.folder-menu {
  position: absolute;
  top: 42px;
  right: 10px;
  z-index: 5;
  display: grid;
  gap: 4px;
  width: 130px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 6px;
}

.folder-menu button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 7px 8px;
  text-align: left;
  font-weight: 800;
}

.folder-menu button:hover {
  background: var(--surface-soft);
}

.folder-card::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 16px;
  width: 48px;
  height: 11px;
  border-radius: 5px 5px 0 0;
  background: #cfded9;
}

.folder-card.active {
  border-color: var(--primary);
  background: #dff0ea;
  box-shadow:
    inset 0 0 0 2px rgba(22, 121, 111, 0.34),
    0 18px 36px rgba(12, 92, 84, 0.16);
  transform: translateY(-2px);
}

.folder-card.active::after {
  content: "Selected";
  position: absolute;
  right: 12px;
  bottom: 12px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 900;
}

.folder-card.active::before {
  background: var(--primary);
}

.folder-card strong {
  align-self: end;
  font-size: 1.15rem;
}

.folder-type {
  display: inline-grid;
  place-items: center;
  width: max-content;
  min-height: 26px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--primary-dark);
  padding: 0 9px;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.folder-type.secondary {
  background: #f0f2f1;
  color: var(--muted);
}

.folder-card span,
.folder-card small {
  color: var(--muted);
  font-weight: 750;
}

.stats article,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.stats article {
  display: grid;
  gap: 6px;
  min-height: 104px;
  padding: 18px;
}

.stats .selected-stat {
  border-color: var(--primary);
  background: #dff0ea;
  box-shadow: inset 0 0 0 2px rgba(22, 121, 111, 0.24);
}

.stats .selected-stat span,
.stats .selected-stat strong {
  color: var(--primary-dark);
}

.stats span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.stats strong {
  align-self: end;
  font-size: 2rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.history-panel {
  margin-bottom: 16px;
}

.purchase-panel {
  margin-bottom: 16px;
}

.settings-panel {
  margin-bottom: 16px;
}

.page-view {
  min-height: 520px;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.page-header h1 {
  margin-bottom: 0;
}

.page-list {
  max-height: none;
  overflow: visible;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.settings-grid section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 14px;
}

.settings-wide {
  grid-column: 1 / -1;
}

.settings-form {
  margin-top: 10px;
}

.invite-form {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(180px, 240px) max-content;
  gap: 10px;
  align-items: end;
}

.member-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
}

.member-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.member-row strong {
  color: var(--text);
  overflow-wrap: anywhere;
}

.member-row span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.small-empty {
  padding: 10px 0 0;
}

.storage-status {
  margin-top: 10px !important;
  color: var(--primary-dark) !important;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.settings-grid h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.settings-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.print-logo {
  display: none;
  width: 190px;
  margin-bottom: 16px;
}

.print-company-info {
  display: none;
  margin-bottom: 16px;
}

.print-company-info strong,
.print-company-info span {
  display: block;
}

.print-company-info span {
  color: var(--muted);
  font-weight: 700;
}

.panel-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 750;
}

.purchase-list {
  margin-top: 14px;
}

.purchase-table {
  display: grid;
  gap: 8px;
}

.purchase-header,
.purchase-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) 1fr 1fr 0.8fr 0.6fr 0.8fr;
  gap: 10px;
  align-items: start;
}

.purchase-header {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.purchase-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 10px;
}

.purchase-row strong,
.purchase-row small {
  display: block;
}

.purchase-row small {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 750;
}

.history-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  margin-top: 14px;
}

#historyPage .history-list {
  max-height: none;
  overflow: visible;
}

.history-entry {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 10px;
}

.history-type {
  display: inline-grid;
  place-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.history-entry strong,
.history-entry small {
  display: block;
}

.history-entry small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

.history-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 10px 0 0;
}

.history-details div {
  min-width: 0;
}

.history-details dt {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.history-details dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.empty-history {
  margin: 0;
  color: var(--muted);
}

.left-stack {
  display: contents;
}

.panel {
  padding: 18px;
}

.collapsible-panel {
  padding: 0;
  overflow: hidden;
}

.collapsible-heading {
  padding: 16px 18px;
}

.collapsible-content {
  display: grid;
  gap: 14px;
  padding: 0 18px 18px;
}

.collapsible-panel.is-collapsed .collapsible-content {
  display: none;
}

.collapsible-panel.is-collapsed .collapsible-heading {
  padding-bottom: 16px;
}

.panel-heading,
.filters {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.inventory-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 121, 111, 0.15);
}

textarea {
  resize: vertical;
}

.photo-preview {
  display: grid;
  place-items: center;
  min-height: 130px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 10px;
}

.photo-preview img {
  max-width: 100%;
  max-height: 180px;
  border-radius: 6px;
  object-fit: contain;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-button,
.secondary-button,
.link-button,
.row-actions button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.primary-button.compact {
  width: auto;
  min-width: 74px;
}

.secondary-button.compact {
  width: auto;
}

.full-width {
  width: 100%;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.secondary-button:hover,
.link-button:hover,
.row-actions button:hover {
  background: var(--surface-soft);
}

.muted-action {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.inventory-panel {
  min-width: 0;
  padding: 0;
  overflow: hidden;
}

.filters {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.filters label:first-of-type {
  flex: 1 1 320px;
}

.table-wrap {
  overflow: visible;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

th:nth-child(1) {
  width: 22%;
}

th:nth-child(5),
th:nth-child(6),
th:nth-child(7) {
  width: 7%;
}

th:nth-child(8) {
  width: 9%;
}

th:nth-child(11) {
  width: 8%;
}

td strong,
td small {
  display: block;
}

.item-cell {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.item-cell img,
.photo-placeholder {
  width: 64px;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  object-fit: cover;
}

td small {
  margin-top: 5px;
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  min-width: 42px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--primary-dark);
  padding: 0 9px;
  font-size: 0.75rem;
  font-weight: 800;
}

.status.low {
  background: #ffe9df;
  color: var(--danger);
}

.row-actions {
  display: grid;
  gap: 6px;
}

.row-actions button {
  min-height: 32px;
  padding: 0 8px;
  font-size: 0.78rem;
}

.empty-state {
  margin: 0;
  padding: 42px 18px;
  color: var(--muted);
  text-align: center;
}

.item-row {
  cursor: pointer;
}

.item-row:hover {
  background: #f6fbf9;
}

.item-row.low-stock-row {
  background: #fff6f2;
}

.item-row.low-stock-row:hover {
  background: #ffede5;
}

.detail-panel {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 20;
  display: grid;
  justify-items: end;
  width: min(100%, 520px);
  background: rgba(23, 33, 31, 0.18);
}

.detail-card {
  width: 100%;
  height: 100%;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -20px 0 50px rgba(23, 33, 31, 0.16);
  padding: 20px;
}

.detail-header,
.detail-actions {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.detail-header {
  margin-bottom: 16px;
}

.detail-photo {
  display: grid;
  place-items: center;
  min-height: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  overflow: hidden;
}

.detail-photo img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
}

.detail-photo-empty {
  color: var(--muted);
  font-weight: 800;
}

.detail-actions {
  justify-content: start;
  margin: 16px 0;
}

.detail-body {
  display: grid;
  gap: 14px;
}

.detail-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 14px;
}

.detail-section h3 {
  margin: 0 0 12px;
  font-size: 0.95rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.detail-grid div {
  min-width: 0;
}

.detail-grid dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.detail-grid dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.detail-description {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.detail-location-list {
  display: grid;
  gap: 8px;
}

.detail-location-list article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.detail-location-list strong,
.detail-location-list span {
  display: block;
}

.detail-location-list span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(6, 10, 16, 0.68);
  backdrop-filter: blur(14px) saturate(0.78);
  -webkit-backdrop-filter: blur(14px) saturate(0.78);
  padding: 18px;
}

.modal-card {
  width: min(100%, 560px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.modal-card.barcode-modal-card {
  width: min(calc(100vw - 32px), 1080px);
}

.modal-card.item-modal-card {
  width: min(calc(100vw - 32px), 760px);
  max-height: calc(100vh - 36px);
  overflow: auto;
}

.modal-card.transfer-modal-card {
  width: min(calc(100vw - 32px), 620px);
}

.modal-form-content {
  display: grid;
  gap: 14px;
}

.modal-summary {
  margin: 2px 0 4px;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.4;
}

.scanner-card {
  display: grid;
  gap: 14px;
}

.scanner-preview {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101817;
  aspect-ratio: 4 / 3;
}

.scanner-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-frame {
  position: absolute;
  inset: 28% 10%;
  border: 3px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28);
}

@media (max-width: 1000px) {
  .login-layout {
    grid-template-columns: 1fr;
    gap: 32px;
    min-height: auto;
  }

  .login-brand,
  .login-card {
    justify-self: center;
  }

  .login-brand {
    text-align: center;
  }

  .login-logo {
    width: min(100%, 420px);
    justify-self: center;
  }

  .login-footer {
    position: static;
    justify-self: center;
    transform: none;
  }

  .app-header,
  .brand-heading,
  .workspace,
  .section-heading {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-logo {
    width: 198px;
  }
}

@media (max-width: 640px) {
  .app {
    width: min(100% - 20px, 1440px);
    padding: 20px 0;
  }

  h1 {
    font-size: 2.2rem;
  }

  .stats,
  .two-column,
  .filters,
  .inventory-actions,
  .new-inventory-form,
  .barcode-form,
  .settings-grid,
  .invite-form,
  .detail-grid,
  .history-entry,
  .history-details,
  .purchase-header,
  .purchase-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .purchase-header {
    display: none;
  }

  .inventory-actions .primary-button,
  .inventory-actions .secondary-button {
    width: 100%;
  }

  .barcode-form .primary-button,
  .barcode-form .secondary-button {
    width: 100%;
    justify-self: stretch;
  }

  .detail-panel {
    width: 100%;
  }

  .submenu-panel {
    position: static;
    width: 100%;
    margin-top: 6px;
    box-shadow: none;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  .item-row {
    border-bottom: 1px solid var(--line);
    padding: 12px;
  }

  td {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 10px;
    border-bottom: 0;
    padding: 6px 0;
  }

  td::before {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
  }

  td:nth-child(1)::before {
    content: "Item";
  }

  td:nth-child(2)::before {
    content: "Category";
  }

  td:nth-child(3)::before {
    content: "Brand";
  }

  td:nth-child(4)::before {
    content: "Model";
  }

  td:nth-child(5)::before {
    content: "Qty";
  }

  td:nth-child(6)::before {
    content: "Minimum";
  }

  td:nth-child(7)::before {
    content: "Maximum";
  }

  td:nth-child(8)::before {
    content: "Value";
  }

  td:nth-child(9)::before {
    content: "Location";
  }

  td:nth-child(10)::before {
    content: "Supplier";
  }

  td:nth-child(11)::before {
    content: "Actions";
  }

  .row-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.login-card,
.inventory-folders,
.stats article,
.panel,
.folder-card,
.match-row,
.history-entry,
.purchase-row,
.settings-grid section,
.detail-card,
.detail-section,
.detail-location-list article,
.modal-card,
.app-menu,
.submenu-panel {
  background: rgba(21, 26, 34, 0.94);
  border-color: var(--line);
}

.login-card,
.inventory-folders,
.panel,
.folder-card,
.detail-card,
.modal-card,
.app-menu,
.submenu-panel {
  box-shadow: var(--shadow);
}

.kicker,
.history-type,
.folder-type,
.stats .selected-stat span,
.stats .selected-stat strong {
  color: var(--primary-dark);
}

.app-logo,
.login-logo,
.print-logo {
  filter: drop-shadow(0 0 18px rgba(45, 134, 255, 0.16));
}

input,
select,
textarea {
  background: #0f141b;
  border-color: var(--line);
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: #73839a;
}

.primary-button,
.match-row button {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.secondary-button,
.link-button,
.row-actions button,
.icon-button {
  background: #121821;
  border-color: var(--line);
  color: var(--text);
}

.secondary-button:hover,
.link-button:hover,
.row-actions button:hover,
.app-menu button:hover,
.app-menu label:hover,
.folder-menu button:hover {
  background: var(--surface-soft);
}

.user-badge,
.folder-type,
.status,
.history-type {
  background: rgba(45, 134, 255, 0.14);
}

.folder-type.secondary {
  background: rgba(154, 168, 187, 0.12);
}

.folder-card::before {
  background: #3a4657;
}

.folder-card.active::before {
  background: #2e9dff;
}

.folder-card.active,
.stats .selected-stat {
  background: rgba(45, 134, 255, 0.12);
  border-color: rgba(110, 200, 255, 0.78);
  box-shadow:
    inset 0 0 0 1px rgba(110, 200, 255, 0.22),
    0 18px 42px rgba(0, 0, 0, 0.28);
}

.folder-card.active strong,
.folder-card.active span,
.folder-card.active small {
  color: #ffffff;
}

.folder-card.active::after {
  background: var(--primary);
  color: #ffffff;
}

.barcode-output,
.barcode-matches,
.purchase-row,
.history-entry,
.detail-photo,
.detail-section,
.photo-preview,
.settings-grid section {
  background: #121821;
}

.item-row:hover {
  background: #1a2230;
}

.item-row.low-stock-row {
  background: transparent;
}

.item-row.low-stock-row:hover {
  background: #241d25;
}

.item-row.low-stock-row td:first-child {
  border-left: 5px solid var(--danger);
}

.item-row.low-stock-row .quantity-cell {
  color: #ff8b8b;
  font-weight: 900;
}

.photo-placeholder {
  background: #1a2230;
}

.login-error,
.match-row button.danger-action {
  border-color: rgba(255, 95, 95, 0.38);
  background: rgba(255, 95, 95, 0.14);
  color: #ff8b8b;
}

#menuToggle,
.folder-menu-button,
.row-actions button[data-action="edit"] {
  border-color: rgba(110, 200, 255, 0.55);
  background: rgba(45, 134, 255, 0.16);
  color: #ffffff;
}

.folder-menu-button {
  min-width: 36px;
  height: 28px;
}

.folder-menu button {
  border: 1px solid var(--line);
  background: #121821;
}

.folder-menu button[data-action="delete-inventory"],
.row-actions button[data-action="delete"] {
  border-color: rgba(255, 95, 95, 0.46);
  background: rgba(255, 95, 95, 0.14);
  color: #ff8b8b;
}

#menuToggle:hover,
.folder-menu-button:hover,
.row-actions button[data-action="edit"]:hover {
  border-color: rgba(110, 200, 255, 0.85);
  background: rgba(45, 134, 255, 0.28);
}

@media print {
  body {
    background: #fff;
  }

  body:not(.print-supply-list) * {
    visibility: hidden;
  }

  body:not(.print-supply-list) .barcode-output,
  body:not(.print-supply-list) .barcode-output * {
    visibility: visible;
  }

  body:not(.print-supply-list) .barcode-output {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    border: 0;
    padding: 24px;
  }

  body:not(.print-supply-list) .barcode-svg {
    width: 6in;
    border: 0;
  }

  body.print-supply-list * {
    visibility: hidden;
  }

  body.print-supply-list #purchaseListPanel,
  body.print-supply-list #purchaseListPanel * {
    visibility: visible;
  }

  body.print-supply-list #purchaseListPanel {
    position: absolute;
    inset: 0;
    display: block !important;
    border: 0;
    box-shadow: none;
    padding: 0.35in;
  }

  body.print-supply-list .print-logo {
    display: block;
  }

  body.print-supply-list .print-company-info {
    display: block;
  }

  body.print-supply-list .panel-actions {
    display: none;
  }

  body.print-supply-list .purchase-header,
  body.print-supply-list .purchase-row {
    grid-template-columns: 1.6fr 1fr 1fr 0.8fr 0.7fr 0.8fr;
    break-inside: avoid;
  }

  body.print-supply-list .purchase-row {
    background: #fff;
  }
}

/* Compact inventory workspace */
.inventory-folders { padding: 16px 20px; }
.inventory-folders .section-heading { margin-bottom: 14px; }
.inventory-folders h2 { font-size: 14px; color: var(--muted); }
.folder-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.folder-card { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 48px 10px 16px; border-radius: 8px; }
.folder-card::before, .folder-card.active::after { display: none; }
.folder-card strong { font-size: 14px; }
.folder-card .folder-menu-button { top: 8px; right: 6px; }
.folder-card .location-alert { color: #ffd18a; font-size: 12px; }
.add-inventory-disclosure { position: relative; }
.add-inventory-disclosure > summary { cursor: pointer; color: #8acbff; font-size: 13px; font-weight: 700; padding: 8px; }
.add-inventory-disclosure form { position: absolute; right: 0; top: 40px; z-index: 8; width: min(420px, 80vw); padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.stats { display: flex; flex-direction: column; gap: 8px; padding: 8px 4px; }
.stats h1 { margin: 0; font-size: 28px; }
.inventory-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 18px; }
.inventory-summary span, .inventory-summary strong { font-size: 14px; }
.inventory-summary strong { color: var(--text); }
.stock-status { display: inline-flex; align-items: center; width: fit-content; padding: 5px 9px; border: 1px solid #34584e; border-radius: 20px; color: #9bddbd; background: #172e28; font-size: 12px; font-weight: 700; white-space: nowrap; }
button.stock-status { cursor: pointer; }
.stock-status.is-low { color: #ffd18a; background: #382c19; border-color: #70532a; }
.filters { flex-wrap: wrap; }
.filters label:first-of-type { order: 0; flex: 1 1 260px; }
.filters label:last-of-type { order: 1; }
.inventory-actions { order: 2; flex-wrap: wrap; }
.inventory-panel { overflow: visible; }
.inventory-panel table { table-layout: auto; }
.inventory-panel th:first-child { width: 42%; }
.inventory-panel th:last-child { width: 80px; }
.inventory-panel td { vertical-align: middle; overflow-wrap: normal; }
.item-cell small { overflow-wrap: anywhere; }
.item-name-button { padding: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-weight: 700; text-align: left; cursor: pointer; }
.item-name-button:hover { color: #8acbff; text-decoration: underline; }
.item-actions-menu { position: relative; width: fit-content; }
.item-actions-menu summary { list-style: none; cursor: pointer; border: 1px solid var(--line); border-radius: 6px; padding: 2px 12px; font-size: 22px; }
.item-actions-menu summary::-webkit-details-marker { display: none; }
.item-actions-list { position: absolute; z-index: 9; right: 0; top: 100%; min-width: 120px; padding: 6px; display: grid; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.item-actions-list button { text-align: left; }
.detail-panel:not([hidden]) { animation: inventory-slide-in 180ms ease-out; }
@keyframes inventory-slide-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
@media (prefers-reduced-motion: reduce) { .detail-panel:not([hidden]) { animation: none; } }
@media (max-width: 700px) {
  .inventory-actions { width: 100%; }
  .inventory-panel .table-wrap { overflow-x: auto; padding-bottom: 80px; }
  .inventory-panel table { min-width: 580px; }
  .inventory-summary { gap: 10px 16px; }
  .folder-card { flex: 1 1 auto; }
}
.item-actions-list button { border: 0; border-radius: 5px; padding: 8px 12px; background: transparent; color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.item-actions-list button:hover { background: #23354a; }
.item-actions-list button[data-action="delete"] { color: #ffaaa6; }

/* Item editor: essentials first, optional details on demand. */
.item-modal-card { max-height: 90dvh; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.item-modal-card > .panel-heading { padding: 20px 24px 8px; margin: 0; flex-shrink: 0; }
.item-modal-card > .form-help { padding: 0 24px 12px; margin: 0; }
.item-modal-card .modal-form-content { overflow-y: auto; min-height: 0; padding: 0 24px 20px; display: grid; gap: 12px; }
.item-basics { display: grid; gap: 16px; padding: 8px 0 12px; }
.item-form-section { border: 1px solid var(--line); border-radius: 9px; padding: 0 16px; }
.item-form-section > summary { padding: 15px 0; cursor: pointer; font-size: 14px; font-weight: 700; }
.item-form-section > summary span { float: right; color: var(--muted); font-weight: 400; font-size: 12px; }
.item-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding-bottom: 16px; }
.item-fields label:has(textarea), .item-fields label:has(#photo) { grid-column: 1 / -1; }
.form-help { color: var(--muted); font-size: 12px; line-height: 1.6; }
.item-form-section > .form-help { margin: 0 0 12px; }
.price-preview { display: block; padding: 12px; margin-bottom: 16px; border-radius: 6px; background: #1b3047; color: #a4d9ff; font-size: 13px; }
.item-form-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 24px; border-top: 1px solid var(--line); flex-shrink: 0; }
.form-error { color: #ffaaa6; font-size: 13px; }
.item-modal-card button:disabled { opacity: .5; cursor: wait; }
@media (max-width: 600px) { .item-fields { grid-template-columns: 1fr; } .item-modal-card .modal-form-content { padding: 0 16px 16px; } .item-form-footer { padding: 12px 16px; } }
.item-form-footer .form-help { white-space: nowrap; }
.item-form-footer .primary-button { width: auto; min-width: 150px; }
/* Keep the item editor anchored while optional sections expand downward. */
#itemForm {
  align-items: start;
  padding-top: clamp(18px, 6dvh, 64px);
}
#itemForm .item-modal-card {
  max-height: calc(100dvh - clamp(18px, 6dvh, 64px) - 18px);
  overflow: hidden;
}

#transferForm { align-items: start; padding-top: clamp(18px, 6dvh, 64px); }
#transferForm .transfer-modal-card { max-height: calc(100dvh - clamp(18px, 6dvh, 64px) - 18px); overflow-y: auto; }
.transfer-search { display: flex; align-items: end; gap: 10px; }
.transfer-search label { flex: 1; }
.transfer-preview { border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: #17283a; font-size: 14px; }
.transfer-balances { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 14px 0; }
.transfer-balances span { color: var(--muted); }
.transfer-balances b { display: block; color: #a4d9ff; font-size: 22px; margin-top: 5px; }
.transfer-preview small { color: var(--muted); line-height: 1.5; }
#transferForm button:disabled { opacity: .45; cursor: not-allowed; }

.transfer-search-results { border: 1px solid var(--line); border-radius: 8px; background: #142235; padding: 10px; }
#transferResultCount { margin: 0 0 8px; color: var(--muted); font-size: 12px; }
#transferResultItems { display: grid; gap: 5px; max-height: 210px; overflow-y: auto; }
.transfer-search-result { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; padding: 12px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.transfer-search-result:hover, .transfer-search-result:focus-visible { background: #243c56; border-color: #68b9ff; outline: none; }
.transfer-search-result small { display: block; color: var(--muted); margin-top: 4px; }
.transfer-search-result > span:last-child { color: #a4d9ff; white-space: nowrap; font-size: 12px; }
/* Match the size and alignment of the inventory toolbar actions. */
.inventory-actions { align-items: center; }
.inventory-actions > button {
  box-sizing: border-box;
  height: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0 14px;
  white-space: nowrap;
}

.job-return-action { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: 13px; color: #a4d9ff; }
.job-issue-link { display: inline-block; margin-top: 10px; color: #a4d9ff; }
.history-entry:target { outline: 2px solid #68b9ff; outline-offset: 3px; }
#jobReturnModal .modal-card { max-height: calc(100dvh - 36px); overflow-y: auto; }

/* Restocking reports */
.supply-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.supply-summary > div { display: grid; gap: 8px; padding: 18px; background: #17283a; border: 1px solid var(--line); border-radius: 8px; }
.supply-summary span { color: var(--muted); font-size: 13px; }
.supply-summary strong { font-size: 25px; }
.supply-guidance { color: var(--muted); font-size: 13px; line-height: 1.6; }
.purchase-header, .purchase-row { grid-template-columns: minmax(170px, 2fr) 1fr 1.4fr .8fr .7fr .8fr 1fr; }
.purchase-header { padding: 0 14px; }
.purchase-row { padding: 14px; }
.purchase-row > span { min-width: 0; overflow-wrap: anywhere; }
.supply-order > strong { color: #94ceff; font-size: 22px; }
.supply-status { display: inline-block; margin-top: 8px; font-size: 11px; font-style: normal; color: #ffd18a; }
@media screen and (max-width: 800px) {
  .supply-summary { grid-template-columns: 1fr; }
  .purchase-header { display: none; }
  .purchase-row { grid-template-columns: 1fr 1fr; gap: 16px; }
  .purchase-row > span:first-child { grid-column: 1 / -1; }
  .purchase-row > span::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }
}
@media print {
  body.print-supply-list .purchase-header, body.print-supply-list .purchase-row { display: grid; grid-template-columns: 1.6fr 1fr 1.3fr .7fr .7fr .7fr 1fr; font-size: 10px; }
  .supply-summary > div { background: white; color: black; break-inside: avoid; }
  .supply-summary span, .supply-guidance, .supply-order > strong, .supply-status { color: #333; }
}

#receiveStockModal { align-items: start; padding-top: clamp(18px, 6dvh, 64px); }
#receiveStockForm { max-height: calc(100dvh - clamp(18px, 6dvh, 64px) - 18px); overflow-y: auto; width: min(100%, 640px); }
.receive-matches { max-height: 170px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; background: #142235; padding: 8px; }
#confirmReceiveStock:disabled { opacity: .45; cursor: not-allowed; }

/* Phone inventory layout */
@media screen and (max-width: 640px) {
  .app { padding: 12px 0; }
  .app-header { grid-template-columns: 1fr; gap: 6px; margin-bottom: 12px; position: relative; }
  .app-logo { width: 130px; }
  .header-actions { display: block; min-width: 0; }
  .header-actions .menu-wrap { position: absolute; right: 0; top: 8px; }
  .user-badge { display: block; min-height: 0; padding: 4px 0; border: 0; background: transparent; font-size: 12px; overflow-wrap: anywhere; }
  .inventory-folders { padding: 10px; }
  .inventory-folders .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
  .folder-grid { gap: 6px; }
  .folder-card { flex: 1 1 140px; min-width: 0; min-height: 44px; padding: 8px 42px 8px 10px; gap: 5px; flex-wrap: wrap; }
  .folder-card strong { font-size: 13px; overflow-wrap: anywhere; }
  .folder-card .location-alert { font-size: 11px; }
  .stats { gap: 6px; padding: 10px 2px; }
  .stats h1 { font-size: 24px; }
  .inventory-summary { gap: 6px 12px; }
  .inventory-summary span, .inventory-summary strong { font-size: 12px; }
  .workspace, .left-stack, .inventory-panel { min-width: 0; }
  .inventory-panel .filters { display: grid; grid-template-columns: minmax(0, 1fr) 100px; gap: 10px; padding: 12px; }
  .filters label { min-width: 0; }
  .filters input, .filters select { width: 100%; min-width: 0; }
  .inventory-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-column: 1 / -1; gap: 8px; }
  .inventory-actions > button { height: 44px; min-height: 44px; padding: 0 8px; }
  .inventory-panel .table-wrap { overflow: visible; padding-bottom: 0; }
  .inventory-panel table { min-width: 0; width: 100%; }
  .inventory-panel .item-row { padding: 12px; }
  .inventory-panel td { grid-template-columns: 80px minmax(0, 1fr); gap: 10px; padding: 5px 0; align-items: center; overflow-wrap: anywhere; }
  .inventory-panel td:first-child { display: block; padding-bottom: 10px; }
  .inventory-panel td:first-child::before { content: none; }
  .inventory-panel td:nth-child(2)::before { content: "In stock"; }
  .inventory-panel td:nth-child(3)::before { content: "Status"; }
  .inventory-panel td:nth-child(4)::before { content: "Location"; }
  .inventory-panel td:nth-child(5)::before { content: "Actions"; }
  .item-cell { grid-template-columns: 44px minmax(0, 1fr); }
  .item-cell img, .item-cell .photo-placeholder { width: 44px; height: 44px; }
  .item-name-button { overflow-wrap: anywhere; }
  .item-actions-menu summary { min-height: 44px; min-width: 44px; display: grid; place-items: center; }
  .item-actions-list { left: 0; right: auto; }
}

@media screen and (max-width: 640px) { body { min-width: 0; } }

/* Compact phone item cards: identity, stock, then shelf location. */
@media screen and (max-width: 640px) {
  .inventory-panel .item-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 44px; gap: 6px 10px; padding: 12px; }
  .inventory-panel .item-row > td { display: block; min-width: 0; padding: 0; border: 0; }
  .inventory-panel .item-row > td::before { content: none; }
  .inventory-panel .item-row > td:first-child { grid-column: 1 / 3; grid-row: 1; align-self: center; }
  .inventory-panel .item-row > td:nth-child(2) { grid-column: 1; grid-row: 2; align-self: center; font-size: 15px; }
  .inventory-panel .item-row > td:nth-child(2)::after { content: " in stock"; color: var(--muted); font-size: 12px; font-weight: 400; }
  .inventory-panel .item-row > td:nth-child(3) { grid-column: 2 / 4; grid-row: 2; justify-self: end; align-self: center; }
  .inventory-panel .item-row > td:nth-child(4) { grid-column: 1 / -1; grid-row: 3; font-size: 12px; color: var(--muted); }
  .inventory-panel .item-row > td:nth-child(4)::before { content: "Location: "; font-size: inherit; font-weight: 400; text-transform: none; }
  .inventory-panel .item-row > td:nth-child(5) { grid-column: 3; grid-row: 1; justify-self: end; align-self: start; }
  .inventory-panel .item-cell { grid-template-columns: 36px minmax(0, 1fr); gap: 8px; }
  .inventory-panel .item-cell:has(.photo-placeholder) { grid-template-columns: minmax(0, 1fr); }
  .inventory-panel .photo-placeholder { display: none; }
  .inventory-panel .item-cell img { width: 36px; height: 36px; }
  .inventory-panel .item-name-button { font-size: 15px; line-height: 1.3; }
  .inventory-panel .item-cell small { font-size: 11px; line-height: 1.4; margin-top: 3px; }
  .inventory-panel .stock-status { padding: 3px 8px; font-size: 11px; }
  .inventory-panel .item-actions-list { left: auto; right: 0; }
}

/* Phone list follows the photo, code, name and quantity reference. */
.phone-item-code, .phone-item-stock { display: none; }
@media screen and (max-width: 640px) {
  .inventory-panel .item-row { display: grid; grid-template-columns: minmax(0, 1fr) 32px; gap: 8px; padding: 14px 10px; }
  .inventory-panel .item-row > td:first-child { grid-column: 1; grid-row: 1; border: 0; }
  .inventory-panel .item-row > td:nth-child(2),
  .inventory-panel .item-row > td:nth-child(3),
  .inventory-panel .item-row > td:nth-child(4) { display: none; }
  .inventory-panel .item-row > td:nth-child(5) { grid-column: 2; grid-row: 1; }
  .inventory-panel .item-cell, .inventory-panel .item-cell:has(.photo-placeholder) { display: grid; grid-template-columns: 68px minmax(0, 1fr); gap: 12px; align-items: center; }
  .inventory-panel .item-cell img, .inventory-panel .photo-placeholder { display: block; width: 68px; height: 76px; border-radius: 6px; }
  .inventory-panel .photo-placeholder { display: grid; place-items: center; background: #315b7e; border: 1px solid #507998; }
  .inventory-panel .photo-placeholder::after { content: ""; width: 24px; height: 31px; background: #83a9c5; clip-path: polygon(0 0, 65% 0, 100% 27%, 100% 100%, 0 100%); border-radius: 2px; }
  .inventory-panel .item-cell small { display: none; }
  .phone-item-code { display: block; color: #afbdcc; font-size: 11px; line-height: 1.3; overflow-wrap: anywhere; }
  .phone-item-code:empty { display: none; }
  .inventory-panel .item-name-button { display: block; font-size: 16px; font-weight: 700; line-height: 1.25; margin: 2px 0 7px; }
  .phone-item-stock { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; font-size: 13px; line-height: 1.5; font-weight: 600; }
  .phone-low-stock { color: #fff; background: #d44b50; border-radius: 5px; padding: 0 6px; }
  .phone-item-value { color: #c8d1dd; font-weight: 400; }
  .inventory-panel .item-actions-menu summary { border: 0; min-width: 32px; min-height: 44px; padding: 0; font-size: 23px; }
}

/* Collapsible location selector on phones; desktop folders stay visible. */
.phone-inventory-toggle { display: none; }
@media screen and (max-width: 640px) {
  .inventory-folders { padding: 0; }
  .phone-inventory-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 48px; padding: 12px 14px; border: 0; border-radius: 8px; background: var(--surface-soft); color: var(--text); font: inherit; font-size: 18px; font-weight: 700; text-align: left; cursor: pointer; }
  #phoneInventoryName { min-width: 0; overflow-wrap: anywhere; }
  .inventory-folders:not(.phone-inventories-open) .section-heading,
  .inventory-folders:not(.phone-inventories-open) .folder-grid { display: none; }
  .inventory-folders.phone-inventories-open .section-heading { margin: 8px 10px; }
  .inventory-folders.phone-inventories-open .folder-grid { display: grid; grid-template-columns: 1fr; padding: 0 10px 10px; }
  .phone-inventories-open .phone-inventory-toggle > span:last-child { transform: rotate(180deg); }
  .stats h1 { display: none; }
  .stats { margin: 0; padding: 10px 2px; }
}

/* Quick actions on phones. Existing controls retain their permissions. */
.inventory-actions > .phone-actions-toggle { display: none; }
@media screen and (max-width: 640px) {
  .inventory-panel .filters { grid-template-columns: minmax(0, 1fr) 44px; }
  .inventory-panel .filters label:first-of-type { grid-column: 1; grid-row: 1; }
  .inventory-panel .filters label:last-of-type { grid-column: 1 / -1; grid-row: 2; display: flex; align-items: center; gap: 10px; }
  .inventory-panel .filters label:last-of-type select { width: auto; flex: 1; }
  .inventory-actions { display: contents; }
  #scanBarcodeToggle { grid-column: 2; grid-row: 1; align-self: end; width: 44px; height: 40px; min-height: 40px; padding: 0; font-size: 0; }
  #scanBarcodeToggle::after { content: ""; width: 22px; height: 22px; border: 2px solid currentColor; border-radius: 4px; background: repeating-linear-gradient(90deg, currentColor 0 2px, transparent 2px 4px); background-size: 14px 12px; background-repeat: no-repeat; background-position: center; }
  .inventory-actions > #addItemToggle, .inventory-actions > #receiveStockToggle, .inventory-actions > #moveStockToggle { display: none; }
  .inventory-actions > .phone-actions-toggle { display: flex; position: fixed; right: 20px; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 30; width: 56px; height: 56px; min-height: 56px; padding: 0; border: 0; border-radius: 50%; background: var(--primary); color: white; font-size: 34px; font-weight: 400; box-shadow: 0 5px 20px #0008; }
  .inventory-actions:not(:has(#addItemToggle:not([hidden]), #receiveStockToggle:not([hidden]), #moveStockToggle:not([hidden]))) > .phone-actions-toggle { display: none; }
  .phone-actions-open > #addItemToggle, .phone-actions-open > #receiveStockToggle, .phone-actions-open > #moveStockToggle { display: flex; position: fixed; right: 20px; z-index: 30; width: 180px; height: 44px; box-shadow: 0 4px 18px #0008; }
  .phone-actions-open > #addItemToggle { bottom: 188px; }
  .phone-actions-open > #receiveStockToggle { bottom: 136px; }
  .phone-actions-open > #moveStockToggle { bottom: 84px; }
  .phone-actions-open > .phone-actions-toggle { transform: rotate(45deg); }
  .inventory-panel .table-wrap { padding-bottom: 80px; }
}

/* Keep phone search, status and scan in one compact toolbar. */
@media screen and (max-width: 640px) {
  .inventory-panel .filters { grid-template-columns: minmax(0, 1fr) 86px 40px; gap: 8px; }
  .inventory-panel .filters label:first-of-type { grid-column: 1; grid-row: 1; }
  .inventory-panel .filters label:last-of-type { grid-column: 2; grid-row: 1; display: grid; gap: 8px; }
  .inventory-panel .filters label:last-of-type select { width: 100%; min-width: 0; padding-left: 8px; padding-right: 4px; }
  #scanBarcodeToggle { grid-column: 3; grid-row: 1; width: 40px; }
  #searchInput { padding-left: 10px; padding-right: 8px; }
}

@media screen and (max-width: 640px) {
  .inventory-panel .filters label:first-of-type,
  .inventory-panel .filters label:last-of-type { display: grid; gap: 8px; align-content: end; font-size: 12px; line-height: 16px; }
  .inventory-panel .filters #searchInput,
  .inventory-panel .filters #statusFilter,
  .inventory-panel .filters #scanBarcodeToggle { box-sizing: border-box; height: 40px; min-height: 40px; max-height: 40px; margin: 0; align-self: end; }
  .inventory-panel .filters #searchInput,
  .inventory-panel .filters #statusFilter { padding-top: 0; padding-bottom: 0; font-size: 12px; line-height: normal; }
}

@media screen and (max-width: 640px) {
  .phone-inventories-open .folder-card { display: flex; flex-wrap: nowrap; align-items: center; gap: 10px; min-height: 48px; padding: 8px 48px 8px 10px; }
  .phone-inventories-open .folder-card strong { flex: 1; min-width: 0; margin: 0; line-height: 18px; }
  .phone-inventories-open .folder-card .location-alert { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; align-self: center; margin: 0; padding: 3px 8px; min-height: 24px; line-height: 16px; border: 1px solid #70532a; border-radius: 12px; background: #382c19; color: #ffd18a; font-size: 11px; white-space: nowrap; }
  .phone-inventories-open .folder-card .folder-menu-button { top: 50%; transform: translateY(-50%); }
}

@media screen and (max-width: 640px) { .phone-inventories-open .folder-card strong { align-self: center; } }

#cloudStatus { display:block; font-size:11px; color:var(--muted); padding:4px; }
#cloudGate { position:fixed; inset:0; z-index:1000; background:#08101bed; display:grid; place-items:center; padding:20px; }
#cloudGate > div { max-width:440px; background:var(--surface); color:var(--text); padding:24px; border:1px solid var(--line); border-radius:12px; line-height:1.6; }
#cloudGate button { padding:12px 16px; background:var(--primary); color:white; border:0; border-radius:8px; cursor:pointer; font:inherit; }
