:root {
  --bg: #f5f5f7;
  --surface: rgba(255,255,255,.88);
  --surface-solid: #fff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --accent: #0071e3;
  --accent-dark: #0066cc;
  --danger: #ff3b30;
  --radius: 18px;
  --shadow: 0 8px 30px rgba(0,0,0,.06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  min-height: 38px;
  font-size: 14px;
  font-weight: 600;
  transition: background .15s ease, transform .1s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { background: #f2f2f7; }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 7px 13px; font-size: 13px; }

/* Authentication */
.auth-screen {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #f5f5f7 0%, #eef0f2 100%);
}
.auth-card {
  width: min(100%, 360px);
  padding: 34px 30px 28px;
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 24px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 20px 60px rgba(0,0,0,.08);
  text-align: center;
}
.auth-mark { font-size: 34px; line-height: 1; margin-bottom: 12px; }
.auth-card h1 { margin: 0; font-size: 30px; letter-spacing: -.7px; font-weight: 650; }
.auth-tag { margin: 7px 0 26px; color: var(--muted); font-size: 14px; }
.auth-form { display: grid; gap: 15px; text-align: left; }
.auth-form label, .admin-form label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 500; }
.auth-form input, .admin-form input, .admin-form textarea, .add-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 11px 13px;
  outline: 0;
  font-size: 16px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.auth-form input:focus, .admin-form input:focus, .admin-form textarea:focus, .add-form input:focus {
  border-color: #8bbdf0;
  box-shadow: 0 0 0 3px rgba(0,113,227,.12);
}
.auth-error { margin: 0; padding: 10px 12px; border-radius: 10px; background: #fff0ef; color: #c9342b; font-size: 13px; }
.auth-toggle { margin-top: 18px; padding: 0; border: 0; background: none; color: var(--accent); font-size: 13px; }
.auth-toggle:hover { text-decoration: underline; }

/* App */
.app { min-height: 100svh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 64px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 10px max(18px, calc((100vw - 1080px)/2));
  background: rgba(255,255,255,.82);
  border-bottom: 1px solid rgba(0,0,0,.08);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
}
.topbar-title { display: flex; align-items: center; gap: 9px; }
.topbar-title .mark { font-size: 22px; }
.topbar-title h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.35px; }
.view-switch { justify-self: center; display: flex; gap: 2px; padding: 3px; background: #e8e8ed; border-radius: 10px; }
.view-btn { border: 0; border-radius: 8px; padding: 6px 13px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; }
.view-btn.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.topbar-user { justify-self: end; display: flex; align-items: center; gap: 8px; }

/* Header cart shortcut */
.cart-header-btn { position: relative; }
.cart-header-btn .cart-count-badge { position: absolute; top: -3px; right: -3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: #ff3b30; color: #fff; font-size: 9px; line-height: 16px; font-weight: 700; text-align: center; border: 2px solid #fff; }
.whoami { color: var(--muted); font-size: 13px; }
.role-badge { padding: 4px 8px; border-radius: 999px; background: #f2f2f7; color: var(--muted); font-size: 11px; font-weight: 600; }
.role-badge.admin { color: #8a5a00; background: #fff4d6; }

.main { width: min(1080px, 100%); margin: 0 auto; padding: 28px 20px 48px; }
.add-form { display: flex; gap: 9px; max-width: 700px; margin: 0 auto 8px; }
.add-form input { flex: 1; border-radius: 14px; background: rgba(255,255,255,.9); }
.add-form .btn { min-width: 68px; }
.add-hint { max-width: 700px; margin: 0 auto 20px; padding-left: 4px; color: var(--muted); font-size: 12px; }
.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* Coverflow */
.cards-view { position: relative; width: 100%; }
.carousel-track {
  width: 100%;
  display: flex;
  align-items: stretch;
  gap: 14px;
  overflow-x: auto;
  padding: 22px max(12px, calc((100% - 340px)/2)) 28px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  cursor: grab;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-track.dragging { cursor: grabbing; scroll-snap-type: none; }
.item-card {
  flex: 0 0 340px;
  width: 340px;
  min-height: 540px;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.07);
  border-radius: 22px;
  background: var(--surface-solid);
  box-shadow: 0 8px 28px rgba(0,0,0,.07);
  opacity: .48;
  transform: scale(.94);
  transition: transform .22s ease, opacity .22s ease, box-shadow .22s ease;
  user-select: none;
}
.item-card.is-center { opacity: 1; transform: scale(1); box-shadow: 0 16px 42px rgba(0,0,0,.12); }
.item-image, .image-placeholder { width: 100%; height: 230px; flex: 0 0 230px; object-fit: cover; background: #f2f2f7; }
.image-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #8e8e93; font-size: 32px; }
.image-placeholder span { font-size: 12px; }
.item-image.image-error { display: none; }
.card-body { display: flex; flex: 1; flex-direction: column; gap: 11px; padding: 18px; }
.category-row { display: flex; flex-wrap: wrap; gap: 6px; min-height: 22px; }
.category-badge { display: inline-flex; align-items: center; min-height: 22px; padding: 3px 8px; border-radius: 999px; background: #f2f2f7; color: var(--muted); font-size: 11px; font-weight: 600; }
.category-badge.film { background: #eaf4ff; color: #1769aa; }
.category-badge.product { background: #eef7ed; color: #327044; }
.item-card-name { font-size: 23px; line-height: 1.15; letter-spacing: -.5px; font-weight: 650; overflow-wrap: anywhere; }
.item-description { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.item-card-meta { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; color: var(--muted); text-align: left; font-size: 12px; }
.item-card-meta strong { color: var(--text); }
.who-count { white-space: nowrap; color: var(--accent); font-weight: 600; }
.stepper, .row-stepper { display: flex; align-items: center; justify-content: center; gap: 12px; }
.step-btn { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: #f8f8fa; color: var(--text); font-size: 20px; line-height: 1; }
.step-btn:hover { background: #ededf0; }
.step-btn.plus { border-color: #9bc7f3; color: var(--accent); }
.step-btn.minus { border-color: #f0aaa6; color: var(--danger); }
.step-btn:disabled { opacity: .35; cursor: not-allowed; }
.step-value { min-width: 2ch; text-align: center; font-size: 17px; font-weight: 650; }
.edit-item-btn { width: 100%; margin-top: 1px; }
.carousel-nav { position: absolute; top: 50%; z-index: 8; width: 38px; height: 38px; transform: translateY(-50%); display: grid; place-items: center; border: 1px solid rgba(0,0,0,.08); border-radius: 50%; background: rgba(255,255,255,.92); color: var(--text); box-shadow: 0 4px 14px rgba(0,0,0,.1); font-size: 24px; line-height: 1; }
.carousel-nav:hover { background: #fff; }
.carousel-prev { left: 0; }
.carousel-next { right: 0; }
.carousel-dots { display: flex; justify-content: center; align-items: center; gap: 5px; }
.dot { width: 5px; height: 5px; padding: 0; border: 0; border-radius: 50%; background: #c7c7cc; }
.dot.is-active { width: 16px; border-radius: 4px; background: #6e6e73; }

/* Table: CSS Grid gives the header and every row the exact same tracks. */
.table-view {
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.07);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}
.items-table {
  --item-col: minmax(0, 2.7fr);
  --tally-col: minmax(150px, 1fr);
  --qty-col: minmax(250px, 1.25fr);
  --edit-col: 100px;
  width: 100%;
  min-width: 0;
}
.table-header,
.table-row {
  display: grid;
  grid-template-columns: var(--item-col) var(--tally-col) var(--qty-col) var(--edit-col);
  align-items: center;
}
.table-header {
  min-height: 56px;
  padding: 0 20px;
  background: #f7f7f9;
  border-bottom: 1px solid #e5e5ea;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.table-header > div { min-width: 0; }
.table-header > div:nth-child(2),
.table-header > div:nth-child(3) { text-align: center; }
.table-header > div:nth-child(4) { text-align: right; }
.table-body { width: 100%; }
.table-row {
  min-height: 92px;
  padding: 0 20px;
  border-bottom: 1px solid #e5e5ea;
}
.table-row:last-child { border-bottom: 0; }
.table-row > div { min-width: 0; }
.item-cell { overflow: hidden; }
.table-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  width: 100%;
  min-width: 0;
}
.table-thumb {
  width: 56px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  background: #f2f2f7;
  display: block;
}
.table-thumb-empty { display: grid; place-items: center; font-size: 18px; color: #8e8e93; }
.table-item-copy { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 5px; }
.row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; line-height: 1.2; }
.table-item .category-row { min-height: 0; display: flex; flex-wrap: nowrap; overflow: hidden; margin: 0; }
.table-item .category-badge { flex: 0 0 auto; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-total { display: flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.tally-value { display: inline-block; min-width: 2ch; font-size: 16px; font-weight: 650; text-align: center; }
.who-link { display: inline-block; margin: 0; padding: 0; border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
.who-link:hover { color: var(--accent); text-decoration: underline; }
.quantity-cell { display: flex; align-items: center; justify-content: center; white-space: nowrap; }
.row-stepper { display: flex; align-items: center; justify-content: center; gap: 12px; white-space: nowrap; }
.row-stepper .step-btn { width: 38px; height: 38px; flex: 0 0 38px; font-size: 18px; }
.row-stepper .step-value { min-width: 2ch; font-size: 15px; }
.edit-cell { display: flex; align-items: center; justify-content: flex-end; white-space: nowrap; }
.edit-cell .btn { min-width: 68px; }


/* Modals */
.who-modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(0,0,0,.28); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.who-panel, .admin-panel { width: min(100%, 620px); max-height: min(90svh, 760px); overflow: auto; border: 1px solid rgba(0,0,0,.08); border-radius: 20px; background: rgba(255,255,255,.96); box-shadow: 0 24px 80px rgba(0,0,0,.18); }
.who-panel { max-width: 380px; }
.who-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 18px 20px; border-bottom: 1px solid #e5e5ea; }
.who-header h2 { margin: 0; font-size: 18px; letter-spacing: -.3px; }
.modal-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.who-list { padding: 8px 20px 18px; }
.who-entry { display: flex; align-items: center; justify-content: space-between; min-height: 48px; border-bottom: 1px solid #e5e5ea; font-size: 14px; }
.who-entry:last-child { border-bottom: 0; }
.who-name { font-weight: 600; }
.who-qty { min-width: 30px; padding: 5px 9px; border-radius: 999px; background: #f2f2f7; text-align: center; font-weight: 600; }
.admin-form { display: grid; gap: 16px; padding: 20px; }
.admin-form textarea { resize: vertical; min-height: 110px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 2px; }

@media (max-width: 760px) {
  .topbar { grid-template-columns: 1fr auto; }
  .view-switch { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; justify-content: center; }
  .topbar-user { grid-column: 2; grid-row: 1; }
  .whoami, .role-badge { display: none; }
  .main { padding: 20px 12px 36px; }
  .carousel-track { padding-left: calc((100% - min(84vw, 340px))/2); padding-right: calc((100% - min(84vw, 340px))/2); }
  .item-card { flex-basis: min(84vw, 340px); width: min(84vw, 340px); min-height: 500px; }
  .carousel-nav { display: none; }
  .table-view { overflow-x: auto; }
  .items-table { min-width: 760px; }
}

@media (max-width: 520px) {
  .auth-card { padding: 30px 22px 24px; }
  .add-form { gap: 7px; }
  .add-form .btn { padding-inline: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .who-modal { padding: 10px; align-items: flex-end; }
  .who-panel, .admin-panel { max-height: 92svh; border-radius: 20px 20px 0 0; }
}

/* ---------- Mobile-first polish / immersive cards ---------- */
.view-switch-row {
  display: flex;
  justify-content: flex-end;
  margin: -4px 0 8px;
}
.view-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 14px;
  background: rgba(235,235,240,.82);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}
.view-btn {
  width: 42px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #6e6e73;
  background: transparent;
}
.view-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.view-btn.active { color: var(--accent); background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.09); }
.view-btn:focus-visible { outline: 3px solid rgba(0,113,227,.2); outline-offset: 1px; }

.cards-view { padding-bottom: 2px; }
.carousel-track {
  padding-top: 34px;
  padding-bottom: 64px;
}
.item-card {
  position: relative;
  width: min(78vw, 390px);
  flex-basis: min(78vw, 390px);
  min-height: 620px;
  aspect-ratio: 0.68;
  border-radius: 28px;
  border-color: rgba(255,255,255,.7);
  background: #202a2a;
  isolation: isolate;
}
.item-card.is-center { box-shadow: 0 24px 60px rgba(0,0,0,.17), 0 8px 24px rgba(0,0,0,.10); }
.card-image-layer { position: absolute; inset: 0; z-index: -1; overflow: hidden; border-radius: inherit; }
.card-image-layer .item-image,
.card-image-layer .image-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  object-fit: cover;
  background: #d8d8dd;
}
.card-image-layer .image-placeholder { color: rgba(255,255,255,.78); background: linear-gradient(145deg,#6f7477,#303638); }
.card-image-top-gradient,
.card-image-bottom-gradient { position: absolute; inset: 0; pointer-events: none; }
.card-image-top-gradient { background: linear-gradient(180deg, rgba(0,0,0,.28), transparent 27%); }
.card-image-bottom-gradient { background: linear-gradient(180deg, transparent 32%, rgba(12,20,24,.08) 43%, rgba(10,17,22,.68) 74%, rgba(8,14,18,.88) 100%); }
.card-content { position: absolute; inset: 0; padding: 18px; display: flex; flex-direction: column; color: #fff; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-height: 30px; }
.card-top .category-row { margin: 0; }
.card-top .category-badge { background: rgba(255,255,255,.17); color: #fff; border: 1px solid rgba(255,255,255,.2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.card-top .category-badge.film, .card-top .category-badge.product { background: rgba(255,255,255,.17); color: #fff; }
.card-more { width: 42px; height: 42px; flex: 0 0 42px; border: 1px solid rgba(255,255,255,.22); border-radius: 50%; background: rgba(24,31,34,.35); color: #fff; font-size: 25px; line-height: 1; display: grid; place-items: center; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.card-lower { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.item-card-name { color: #fff; font-size: clamp(25px, 7vw, 34px); line-height: 1.06; letter-spacing: -.8px; font-weight: 700; text-shadow: 0 2px 14px rgba(0,0,0,.22); }
.item-description { margin: 0; max-width: 34ch; color: rgba(255,255,255,.84); font-size: 14px; line-height: 1.42; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; text-shadow: 0 1px 10px rgba(0,0,0,.22); }
.item-card-meta { margin-top: 3px; color: rgba(255,255,255,.88); font-size: 13px; }
.item-card-meta strong { color: #fff; }
.who-count { color: #fff; }
.who-link { color: rgba(255,255,255,.9); }
.who-link:hover { color: #fff; }
.card-controls { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid rgba(255,255,255,.2); border-radius: 22px; background: rgba(35,43,46,.32); backdrop-filter: blur(16px) saturate(130%); -webkit-backdrop-filter: blur(16px) saturate(130%); box-shadow: inset 0 1px 0 rgba(255,255,255,.1); }
.card-controls .stepper { flex: 1 1 auto; gap: 13px; }
.card-controls .step-btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.42); color: #fff; }
.card-controls .step-btn.plus { border-color: rgba(112,180,255,.95); color: #78b9ff; }
.card-controls .step-btn.minus { border-color: rgba(255,140,135,.95); color: #ff817a; }
.card-controls .step-value { color: #fff; }
.btn-glass { min-height: 46px; padding: 0 15px; background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.3); white-space: nowrap; }
.btn-glass:hover { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.5); }
.edit-icon { font-size: 18px; line-height: 1; }
.carousel-dots { position: relative; z-index: 2; }

@media (max-width: 760px) {
  .topbar { padding: 12px 14px; }
  .topbar-title .mark { font-size: 1.3rem; }
  .topbar-title h1 { font-size: 1.15rem; }
  .topbar-user .btn { min-height: 36px; padding: 7px 13px; }
  .main { padding: 16px 10px 34px; }
  .add-form { margin-bottom: 7px; }
  .add-form input { min-width: 0; font-size: 16px; }
  .add-form .btn { min-height: 46px; }
  .add-hint { margin-bottom: 10px; padding-left: 2px; font-size: 12px; line-height: 1.35; }
  .view-switch-row { margin: 0 2px 2px; }
  .carousel-track {
    gap: 12px;
    padding-left: calc((100% - min(84vw, 390px))/2);
    padding-right: calc((100% - min(84vw, 390px))/2);
    padding-top: 24px;
    padding-bottom: 62px;
  }
  .item-card { width: min(84vw, 390px); flex-basis: min(84vw, 390px); min-height: min(76svh, 650px); }
  .card-content { padding: 16px; }
  .card-controls { border-radius: 20px; }
  .card-controls .step-btn { width: 42px; height: 42px; flex-basis: 42px; }
  .btn-glass { min-height: 42px; padding-inline: 13px; }
}

@media (max-width: 420px) {
  .topbar { gap: 8px; }
  .topbar-user .btn { font-size: 13px; }
  .main { padding-inline: 6px; }
  .carousel-track { padding-left: 8vw; padding-right: 8vw; }
  .item-card { width: 84vw; flex-basis: 84vw; min-height: 570px; border-radius: 25px; }
  .card-content { padding: 14px; }
  .card-controls { gap: 6px; padding: 7px; }
  .card-controls .stepper { gap: 9px; }
  .btn-glass { padding-inline: 10px; font-size: 13px; }
  .item-description { font-size: 13px; }
}

/* ---------- Compact mobile table ---------- */
@media (max-width: 760px) {
  .table-view {
    overflow: visible;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,.06);
  }

  .items-table { min-width: 0; width: 100%; }

  /* On phones the labels are redundant; each row carries its own hierarchy. */
  .table-header {
    display: none;
  }

  .table-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-rows: auto auto;
    column-gap: 12px;
    row-gap: 12px;
    min-height: 0;
    padding: 14px;
    align-items: center;
  }

  .item-cell {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .table-item {
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 12px;
  }

  .table-thumb {
    width: 54px;
    height: 62px;
    border-radius: 12px;
  }

  .table-item-copy { gap: 4px; }
  .row-name {
    font-size: 16px;
    line-height: 1.2;
  }

  .table-item .category-row {
    max-width: 100%;
  }

  .table-item .category-badge {
    max-width: 42vw;
    font-size: 10px;
  }

  .row-total {
    grid-column: 1;
    grid-row: 2;
    justify-content: flex-start;
    gap: 7px;
  }

  .tally-value { font-size: 17px; }
  .row-total .who-link { font-size: 11px; }

  .quantity-cell {
    grid-column: 2;
    grid-row: 2;
    justify-content: flex-end;
  }

  .row-stepper {
    gap: 8px;
  }

  .row-stepper .step-btn {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .row-stepper .step-value {
    min-width: 2ch;
    font-size: 15px;
  }

  .edit-cell {
    grid-column: 3;
    grid-row: 2;
    justify-content: flex-end;
  }

  .edit-cell .btn {
    min-width: 0;
    min-height: 34px;
    padding: 7px 11px;
  }
}

@media (max-width: 420px) {
  .table-row {
    padding: 12px;
    column-gap: 8px;
    row-gap: 10px;
  }

  .table-item {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 10px;
  }

  .table-thumb {
    width: 48px;
    height: 56px;
  }

  .row-name { font-size: 15px; }
  .row-total { gap: 5px; }
  .row-total .who-link { display: none; }

  .row-stepper { gap: 6px; }
  .row-stepper .step-btn {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .edit-cell .btn {
    padding-inline: 10px;
    font-size: 12px;
  }
}


/* Modal selects use the same visual language as the main category filters.
   Keeping the shared class on these native selects also keeps the treatment
   consistent across desktop and mobile without changing their behavior. */
.admin-form .category-filter {
  width: 100%;
  min-width: 0;
  height: 44px;
  min-height: 44px;
  padding: 0 34px 0 16px;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 22px;
  background: #fff;
  color: var(--text);
  font-size: 15px;
  font-weight: 550;
  background-image: linear-gradient(45deg, transparent 50%, #8e8e93 50%), linear-gradient(135deg, #8e8e93 50%, transparent 50%);
  background-position: calc(100% - 17px) 19px, calc(100% - 13px) 19px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  outline: 0;
  appearance: none;
  -webkit-appearance: none;
}
.admin-form .category-filter:focus-visible {
  border-color: #8bbdf0;
  box-shadow: 0 0 0 3px rgba(0,113,227,.12);
}

/* ---------- Category filters ---------- */
.view-filter-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: -4px 0 8px;
}
.category-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.category-filter {
  appearance: none;
  min-width: 118px;
  height: 36px;
  padding: 0 30px 0 11px;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 11px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 550;
  background-image: linear-gradient(45deg, transparent 50%, #8e8e93 50%), linear-gradient(135deg, #8e8e93 50%, transparent 50%);
  background-position: calc(100% - 13px) 15px, calc(100% - 9px) 15px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  outline: 0;
}
.category-filter:focus-visible {
  border-color: #8bbdf0;
  box-shadow: 0 0 0 3px rgba(0,113,227,.12);
}

@media (max-width: 760px) {
  .view-filter-row {
    gap: 6px;
    margin: 0 2px 2px;
  }
  .category-filters {
    flex: 1 1 auto;
    min-width: 0;
  }
  .category-filter {
    flex: 1 1 0;
    min-width: 0;
    width: 0;
    height: 36px;
    padding-left: 9px;
    padding-right: 23px;
    font-size: 11px;
    background-position: calc(100% - 10px) 15px, calc(100% - 6px) 15px;
  }
  .view-switch {
    flex: 0 0 auto;
  }
}

@media (max-width: 360px) {
  .view-filter-row { gap: 4px; }
  .category-filters { gap: 4px; }
  .category-filter { font-size: 10px; padding-left: 7px; padding-right: 19px; }
  .view-btn { width: 38px; }
}

/* ---------- Price presentation ---------- */
.item-price {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin-top: 2px;
}
.item-price .price-final {
  font-size: clamp(24px, 6vw, 31px);
  line-height: 1;
  font-weight: 750;
  letter-spacing: -.7px;
  color: #fff;
  text-shadow: 0 2px 14px rgba(0,0,0,.22);
}
.item-price .price-srp {
  color: rgba(255,255,255,.68);
  font-size: 11px;
  line-height: 1.2;
}

.row-price {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  white-space: nowrap;
}
.row-price .price-final {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.2px;
}
.row-price .price-empty {
  color: #8e8e93;
}

.price-form-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  background: #f7f7f9;
  border: 1px solid #e5e5ea;
}
.price-grid { grid-template-columns: 1.25fr .9fr; }
.admin-only-field small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

/* Five aligned desktop table tracks: item / tally / price / quantity / edit */
.items-table {
  --item-col: minmax(0, 2.5fr);
  --tally-col: minmax(130px, .9fr);
  --price-col: minmax(115px, .85fr);
  --qty-col: minmax(210px, 1.2fr);
  --edit-col: 100px;
}
.table-header,
.table-row {
  grid-template-columns: var(--item-col) var(--tally-col) var(--price-col) var(--qty-col) var(--edit-col);
}
.table-header > div:nth-child(2),
.table-header > div:nth-child(3),
.table-header > div:nth-child(4) { text-align: center; }
.table-header > div:nth-child(5) { text-align: right; }

@media (max-width: 760px) {
  .price-form-section { padding: 12px; }
  .price-grid { grid-template-columns: 1fr 1fr; }
  .item-price .price-final { font-size: 25px; }

  /* Keep mobile rows compact while making price a first-class value. */
  .table-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-rows: auto auto;
  }
  .row-price {
    grid-column: 1;
    grid-row: 2;
    justify-content: flex-start;
    margin-top: 1px;
  }
  .row-price .price-final { font-size: 16px; }
  .quantity-cell {
    grid-column: 2;
    grid-row: 2;
  }
  .edit-cell {
    grid-column: 3;
    grid-row: 2;
  }
  .row-total {
    grid-column: 1;
    grid-row: 2;
    justify-content: flex-start;
    transform: translateY(-17px);
  }
  .row-price { transform: translateY(17px); }
}

@media (max-width: 420px) {
  .price-grid { grid-template-columns: 1fr; }
  .price-form-section { gap: 10px; }
  .item-price .price-final { font-size: 23px; }
  .row-price .price-final { font-size: 15px; }
}

@media (max-width: 760px) {
  .table-row {
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    grid-template-rows: auto auto;
    column-gap: 9px;
    row-gap: 9px;
  }
  .item-cell { grid-column: 1 / -1; grid-row: 1; }
  .row-total {
    grid-column: 1;
    grid-row: 2;
    transform: none;
    justify-content: flex-start;
  }
  .row-price {
    grid-column: 2;
    grid-row: 2;
    transform: none;
    justify-content: flex-start;
  }
  .quantity-cell {
    grid-column: 3;
    grid-row: 2;
    justify-content: flex-end;
  }
  .edit-cell {
    grid-column: 4;
    grid-row: 2;
    justify-content: flex-end;
  }
  .edit-cell .btn { padding-inline: 10px; }
}

/* ---------- Compact Apple-like header + toolbar ---------- */
.topbar {
  min-height: 56px;
  padding: 8px max(14px, calc((100vw - 1080px)/2));
  grid-template-columns: 1fr auto;
  gap: 12px;
}
.topbar-title { gap: 7px; }
.topbar-title .mark { font-size: 20px; }
.topbar-title h1 { font-size: 18px; }
.topbar-user { gap: 6px; }
.whoami, .role-badge { display: none; }
.topbar-user .btn { min-height: 34px; padding: 6px 12px; }
.main { padding: 14px 16px 40px; }

.utility-row {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 900px;
  margin: 0 auto 10px;
}
.search-box {
  min-width: 0;
  flex: 1;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.search-box svg { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: #8e8e93; stroke-width: 1.8; }
.search-box input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 16px; }
.search-box input::placeholder { color: #8e8e93; }
.search-box:focus-within { border-color: #9fc9f4; box-shadow: 0 0 0 3px rgba(0,113,227,.10); }
.add-item-btn { height: 44px; min-width: 82px; padding-inline: 16px; }
.add-item-btn span:first-child { font-size: 19px; line-height: 1; }

.view-filter-row {
  max-width: 900px;
  margin: 0 auto 14px;
  gap: 8px;
  align-items: center;
}
.category-filters { flex: 1; min-width: 0; gap: 8px; }
.category-filter { height: 40px; min-width: 0; padding-top: 0; padding-bottom: 0; font-size: 13px; border-radius: 11px; }
.view-switch { flex: 0 0 auto; height: 40px; padding: 3px; border-radius: 12px; }
.view-btn { width: 48px; height: 34px; padding: 6px; display: grid; place-items: center; }
.view-btn svg { width: 19px; height: 19px; }

/* Prevent old add-form styles from affecting the compact toolbar. */
.add-form, .add-hint { display: none !important; }

@media (max-width: 760px) {
  .topbar { min-height: 52px; padding: 7px 12px; }
  .topbar-title .mark { font-size: 18px; }
  .topbar-title h1 { font-size: 17px; }
  .topbar-user .btn { min-height: 32px; font-size: 13px; padding: 5px 11px; }
  .main { padding: 10px 8px 32px; }
  .utility-row { margin-bottom: 7px; gap: 6px; }
  .search-box { height: 40px; border-radius: 12px; padding-inline: 11px; }
  .add-item-btn { height: 40px; min-width: 54px; padding: 0 12px; }
  .view-filter-row { margin-bottom: 9px; gap: 6px; }
  .category-filters { gap: 6px; }
  .category-filter { height: 38px; font-size: 12px; padding-left: 10px; padding-right: 24px; border-radius: 10px; }
  .view-switch { height: 38px; }
  .view-btn { width: 42px; height: 32px; }
}

@media (max-width: 420px) {
  .add-label { display: none; }
  .add-item-btn { min-width: 40px; width: 40px; padding: 0; }
  .add-item-btn span:first-child { font-size: 22px; }
  .category-filter { font-size: 11px; padding-left: 8px; padding-right: 21px; }
  .view-btn { width: 39px; }
}

/* ---------- Sticky header + secondary filter toolbar ---------- */
:root { --header-h: 58px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: var(--header-h);
  display: grid;
  grid-template-columns: auto minmax(240px, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 7px max(14px, calc((100vw - 1080px)/2));
  background: rgba(255,255,255,.9);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid rgba(60,60,67,.12);
}
.topbar-title { min-width: max-content; }
.topbar-title h1 { font-size: 19px; }
.topbar-user { justify-self: end; }
.utility-row {
  width: min(100%, 620px);
  min-width: 0;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
}
.search-box { height: 40px; min-width: 0; padding-inline: 11px; border-radius: 12px; }
.search-box input { font-size: 15px; }
.add-item-btn { height: 40px; min-width: 76px; padding-inline: 14px; }
.view-filter-row {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  width: calc(100% + 32px);
  margin-left: -16px;
  margin-right: -16px;
  margin-top: -14px;
  margin-bottom: 14px;
  padding: 8px max(16px, calc((100vw - 1112px)/2));
  background: rgba(245,245,247,.88);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid rgba(60,60,67,.08);
}
.view-filter-row > .category-filters { max-width: none; }

@media (max-width: 760px) {
  :root { --header-h: 100px; }
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-rows: 44px 44px;
    gap: 0 10px;
    padding: 5px 10px;
  }
  .topbar-title { grid-column: 1; grid-row: 1; }
  .topbar-title .mark { font-size: 19px; }
  .topbar-title h1 { font-size: 18px; }
  .topbar-user { grid-column: 2; grid-row: 1; }
  .utility-row {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    gap: 6px;
  }
  .search-box { height: 38px; }
  .add-item-btn { height: 38px; min-width: 42px; width: 42px; padding: 0; }
  .add-label { display: none; }
  .add-item-btn span:first-child { font-size: 21px; }
  .main { padding-top: 10px; }
  .view-filter-row {
    width: calc(100% + 16px);
    margin-left: -8px;
    margin-right: -8px;
    margin-top: -10px;
    margin-bottom: 10px;
    padding: 7px 8px;
  }
}

@media (max-width: 420px) {
  .topbar { padding-inline: 8px; }
  .topbar-user .btn { min-height: 31px; padding: 5px 10px; }
  .view-filter-row { padding-inline: 6px; }
}

/* ---------- Final compact single-row header ---------- */
.topbar {
  grid-template-columns: auto minmax(180px, 1fr) auto;
  grid-template-rows: 1fr;
  min-height: 58px;
  padding-block: 7px;
}
.topbar-title { grid-column: 1; grid-row: 1; }
.utility-row { grid-column: 2; grid-row: 1; width: min(100%, 620px); justify-self: center; }
.topbar-user { grid-column: 3; grid-row: 1; }

@media (max-width: 760px) {
  :root { --header-h: 56px; }
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: 1fr;
    min-height: var(--header-h);
    gap: 6px;
    padding: 6px 8px;
  }
  .topbar-title { grid-column: 1; grid-row: 1; gap: 5px; }
  .topbar-title .mark { font-size: 17px; }
  .topbar-title h1 { font-size: 17px; letter-spacing: -.45px; }
  .utility-row { grid-column: 2; grid-row: 1; width: 100%; gap: 5px; }
  .search-box { height: 38px; border-radius: 11px; padding-inline: 10px; }
  .search-box input { font-size: 14px; }
  .add-item-btn { height: 38px; width: 40px; min-width: 40px; padding: 0; border-radius: 11px; }
  .add-label { display: none; }
  .add-item-btn span:first-child { font-size: 21px; }
  .topbar-user { grid-column: 3; grid-row: 1; }
  .topbar-user .btn { min-height: 36px; padding: 5px 9px; font-size: 12px; white-space: nowrap; }
  .main { padding-top: 10px; }
  .view-filter-row { top: var(--header-h); }
}

@media (max-width: 500px) {
  .topbar-title h1 { font-size: 16px; }
  .topbar-title .mark { font-size: 16px; }
  .topbar-user .btn { font-size: 0; width: 38px; padding: 0; }
  .topbar-user .btn::before { content: '↪'; font-size: 18px; line-height: 1; }
  .search-box svg { width: 17px; height: 17px; flex-basis: 17px; }
}

/* ---------- Refined responsive header ---------- */
.topbar {
  grid-template-columns: auto minmax(220px, 460px) auto auto;
  grid-template-rows: 52px;
  gap: 10px;
  min-height: 66px;
  padding: 7px max(16px, calc((100vw - 1080px)/2));
}
.topbar-title { grid-column: 1; grid-row: 1; }
.utility-row {
  grid-column: 2 / span 2;
  grid-row: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  justify-self: stretch;
}
.topbar-user { grid-column: 4; grid-row: 1; }
.search-box {
  height: 42px;
  border-radius: 13px;
  background: rgba(255,255,255,.78);
  box-shadow: none;
}
.search-box input { font-size: 15px; }
.add-item-btn {
  width: 44px;
  min-width: 44px;
  height: 42px;
  padding: 0;
  border-radius: 13px;
}
.add-item-btn .add-label { display: none; }
.add-item-btn span:first-child { font-size: 23px; }
.topbar-user .btn { min-height: 38px; }

@media (min-width: 761px) {
  .utility-row { max-width: 510px; justify-self: center; }
}

@media (max-width: 760px) {
  :root { --header-h: 104px; }
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 44px 44px;
    gap: 4px 10px;
    min-height: var(--header-h);
    padding: 6px 10px;
  }
  .topbar-title { grid-column: 1; grid-row: 1; }
  .topbar-user { grid-column: 2; grid-row: 1; }
  .utility-row {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    max-width: none;
    gap: 7px;
  }
  .search-box { height: 40px; border-radius: 12px; }
  .search-box input { font-size: 16px; }
  .add-item-btn { height: 40px; width: 44px; min-width: 44px; }
  .topbar-user .btn { min-height: 34px; padding: 5px 11px; font-size: 13px; }
}

@media (max-width: 420px) {
  .topbar { padding-inline: 8px; }
  .topbar-title h1 { font-size: 17px; }
  .topbar-title .mark { font-size: 17px; }
  .topbar-user .btn { width: auto; font-size: 12px; }
  .add-item-btn { width: 42px; min-width: 42px; }
}

/* ---------- Overflow-safe responsive filter toolbar ---------- */
.view-filter-row { min-width: 0; box-sizing: border-box; }
.category-filters { min-width: 0; }
.category-filter { min-width: 0; box-sizing: border-box; }

/* Treat medium/narrow layouts like mobile before the filters can become cramped. */
@media (max-width: 1100px) {
  .view-filter-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
  }
  .category-filters {
    display: contents;
  }
  .category-filter {
    width: 100%;
    min-width: 0;
  }
  .view-switch {
    min-width: 0;
    width: 88px;
  }
}

@media (max-width: 560px) {
  .view-filter-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 82px;
    gap: 6px;
    padding-inline: 8px;
  }
  .category-filter {
    height: 38px;
    padding-left: 10px;
    padding-right: 22px;
    font-size: 12px;
    text-overflow: ellipsis;
  }
  .view-switch {
    width: 82px;
    height: 38px;
  }
  .view-btn {
    width: 36px;
    height: 32px;
  }
  .view-btn svg { width: 18px; height: 18px; }
}

@media (max-width: 380px) {
  .view-filter-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 76px;
    gap: 4px;
    padding-inline: 6px;
  }
  .category-filter {
    font-size: 11px;
    padding-left: 8px;
    padding-right: 19px;
  }
  .view-switch { width: 76px; }
  .view-btn { width: 33px; }
}

/* ---------- Final responsive header + toolbar geometry ---------- */
.topbar {
  grid-template-columns: max-content minmax(180px, 1fr) auto auto;
  grid-template-rows: 52px;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 7px max(16px, calc((100vw - 1080px)/2));
}
.topbar-title { grid-column: 1; grid-row: 1; min-width: max-content; }
.topbar-title .mark { font-size: 22px; }
.topbar-title h1 { font-size: 21px; }
.utility-row {
  grid-column: 2; grid-row: 1;
  width: 100%; max-width: none; margin: 0;
  display: flex; align-items: center; gap: 8px;
}
.search-box {
  min-width: 0; flex: 1 1 auto;
  height: 44px; padding-inline: 14px;
  border-radius: 22px;
}
.search-box input { font-size: 16px; }
.add-item-btn {
  flex: 0 0 44px; width: 44px; min-width: 44px; height: 44px;
  padding: 0; border-radius: 22px;
}
.add-item-btn span:first-child { font-size: 24px; }
.topbar-user { grid-column: 4; grid-row: 1; justify-self: end; }
.topbar-user .btn { min-height: 44px; padding-inline: 18px; border-radius: 22px; white-space: nowrap; }

.view-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding-top: 10px;
  padding-bottom: 10px;
}
.view-filter-row > .category-filters { display: contents; }
.category-filter {
  width: 100%; min-width: 0; height: 44px;
  padding-inline: 16px 34px;
  border-radius: 22px;
  font-size: 15px;
  text-overflow: ellipsis;
}
.view-switch {
  width: 92px; height: 44px; min-width: 92px;
  padding: 4px; border-radius: 22px;
  justify-self: end;
}
.view-btn { width: 40px; height: 36px; border-radius: 18px; }

@media (max-width: 760px) {
  :root { --header-h: 66px; }
  .topbar {
    grid-template-columns: max-content minmax(90px, 1fr) auto auto;
    grid-template-rows: 44px;
    gap: 8px;
    min-height: var(--header-h);
    padding: 7px 12px;
  }
  .topbar-title .mark { font-size: 19px; }
  .topbar-title h1 { font-size: 18px; }
  .utility-row { gap: 6px; }
  .search-box { height: 40px; padding-inline: 11px; border-radius: 20px; }
  .search-box svg { width: 18px; height: 18px; flex-basis: 18px; }
  .search-box input { font-size: 15px; }
  .add-item-btn { flex-basis: 40px; width: 40px; min-width: 40px; height: 40px; border-radius: 20px; }
  .add-item-btn span:first-child { font-size: 22px; }
  .topbar-user .btn { min-height: 40px; padding-inline: 12px; border-radius: 20px; font-size: 13px; }
  .view-filter-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 84px;
    gap: 8px;
    padding: 8px 10px;
  }
  .category-filter { height: 40px; padding-inline: 12px 28px; border-radius: 20px; font-size: 13px; }
  .view-switch { width: 84px; min-width: 84px; height: 40px; border-radius: 20px; }
  .view-btn { width: 36px; height: 32px; border-radius: 16px; }
}

@media (max-width: 560px) {
  .topbar {
    grid-template-columns: max-content minmax(70px, 1fr) auto auto;
    gap: 6px;
    padding-inline: 8px;
  }
  .topbar-title { gap: 4px; }
  .topbar-title .mark { font-size: 17px; }
  .topbar-title h1 { font-size: 16px; letter-spacing: -.4px; }
  .search-box { padding-inline: 9px; }
  .search-box input { font-size: 14px; }
  .add-item-btn { width: 38px; min-width: 38px; flex-basis: 38px; height: 38px; }
  .topbar-user .btn { min-height: 38px; padding-inline: 9px; font-size: 12px; }
  .view-filter-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 80px; gap: 6px; padding-inline: 7px; }
  .category-filter { height: 38px; padding-inline: 10px 24px; font-size: 12px; }
  .view-switch { width: 80px; min-width: 80px; height: 38px; }
}

@media (max-width: 420px) {
  .topbar { grid-template-columns: max-content minmax(58px, 1fr) auto auto; gap: 5px; }
  .topbar-title h1 { font-size: 15px; }
  .topbar-title .mark { font-size: 16px; }
  .search-box input { font-size: 13px; }
  .search-box svg { width: 16px; height: 16px; flex-basis: 16px; }
  .add-item-btn { width: 36px; min-width: 36px; flex-basis: 36px; height: 36px; }
  .topbar-user .btn { width: 36px; min-width: 36px; padding: 0; font-size: 0; }
  .topbar-user .btn::before { content: '↪'; font-size: 18px; }
  .view-filter-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 74px; gap: 5px; padding-inline: 5px; }
  .category-filter { font-size: 11px; padding-inline: 8px 21px; }
  .view-switch { width: 74px; min-width: 74px; }
  .view-btn { width: 32px; }
}

/* ---------- User-first table hierarchy ---------- */
.user-row .row-price { justify-content: center; }
.user-row .row-total {
  flex-direction: column;
  gap: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.1;
}
.user-row .user-total-label {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 10px;
  font-weight: 650;
}
.user-row .user-total .tally-value {
  color: #8e8e93;
  font-size: 16px;
  font-weight: 600;
}
.user-row .user-quantity {
  flex-direction: column;
  gap: 5px;
}
.user-row .your-quantity-label {
  color: #1d1d1f;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}
.user-row .user-quantity .row-stepper {
  padding: 5px 9px;
  border-radius: 999px;
  background: #f5f5f7;
}

@media (max-width: 760px) {
  .user-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    column-gap: 12px;
    row-gap: 9px;
    padding: 14px;
  }
  .user-row .item-cell { grid-column: 1 / -1; grid-row: 1; }
  .user-row .row-price {
    grid-column: 1;
    grid-row: 2;
    justify-content: flex-start;
    align-items: center;
  }
  .user-row .row-total {
    grid-column: 1;
    grid-row: 2;
    justify-self: end;
    flex-direction: row;
    gap: 6px;
    align-items: baseline;
    margin-right: 112px;
  }
  .user-row .user-total-label { font-size: 9px; }
  .user-row .user-total .tally-value { font-size: 14px; }
  .user-row .user-quantity {
    grid-column: 2;
    grid-row: 2;
    align-items: flex-end;
    gap: 3px;
  }
  .user-row .your-quantity-label { font-size: 10px; }
  .user-row .user-quantity .row-stepper { padding: 3px 6px; }
  .user-row .edit-cell {
    grid-column: 1 / -1;
    grid-row: 3;
    justify-content: flex-end;
  }
}

@media (max-width: 420px) {
  .user-row { column-gap: 8px; padding: 12px; }
  .user-row .row-total { margin-right: 94px; }
  .user-row .user-quantity .row-stepper { gap: 5px; }
  .user-row .user-quantity .step-btn { width: 30px; height: 30px; flex-basis: 30px; }
  .user-row .user-quantity .step-value { font-size: 14px; }
}

.user-total-inline { display: none; color: var(--muted); font-size: 11px; font-weight: 500; }

@media (max-width: 760px) {
  /* For regular users, keep the shared tally visually secondary and make their own quantity the action focal point. */
  .user-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
  }
  .user-row .row-price {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
  }
  .user-row .user-total-inline { display: inline; }
  .user-row .user-total { display: none; }
  .user-row .user-quantity {
    grid-column: 2;
    grid-row: 2;
    align-items: flex-end;
  }
  .user-row .edit-cell {
    grid-column: 1 / -1;
    grid-row: 3;
  }
}

/* ---------- Stable filter/view toolbar layout ----------
   Keep the two filters as one grid group. The previous rules allowed
   .category-filters to occupy only one parent grid track at wider widths,
   which made its two children spill into the view-switch area.
*/
.view-filter-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.view-filter-row > .category-filters {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
  width: 100%;
}
.view-filter-row .category-filter {
  width: 100%;
  min-width: 0;
  max-width: none;
  box-sizing: border-box;
}
.view-filter-row .view-switch {
  grid-column: 2;
  width: auto;
  min-width: 92px;
  justify-self: end;
  flex: 0 0 auto;
}

@media (max-width: 760px) {
  .view-filter-row {
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 8px;
    padding-inline: 10px;
  }
  .view-filter-row > .category-filters {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }
  .view-filter-row .view-switch {
    min-width: 84px;
    width: 84px;
  }
}

@media (max-width: 560px) {
  .view-filter-row {
    gap: 6px;
    padding-inline: 8px;
  }
  .view-filter-row > .category-filters {
    gap: 6px;
  }
  .view-filter-row .view-switch {
    min-width: 80px;
    width: 80px;
  }
}

@media (max-width: 420px) {
  .view-filter-row {
    gap: 5px;
    padding-inline: 6px;
  }
  .view-filter-row > .category-filters {
    gap: 5px;
  }
  .view-filter-row .view-switch {
    min-width: 74px;
    width: 74px;
  }
}


/* ---------- Definitive overflow-proof filter toolbar ---------- */
.view-filter-row {
  display: flex !important;
  flex-flow: row nowrap !important;
  align-items: center !important;
  justify-content: stretch !important;
  box-sizing: border-box !important;
  width: 100% !important;
  min-width: 0 !important;
  gap: 10px !important;
  overflow: hidden !important;
}
.view-filter-row > .category-filters {
  display: flex !important;
  flex: 1 1 auto !important;
  flex-flow: row nowrap !important;
  align-items: center !important;
  min-width: 0 !important;
  width: auto !important;
  max-width: none !important;
  gap: 10px !important;
}
.view-filter-row > .category-filters > .category-filter {
  flex: 1 1 0 !important;
  width: 0 !important;
  min-width: 0 !important;
  max-width: none !important;
  box-sizing: border-box !important;
}
.view-filter-row > .view-switch {
  flex: 0 0 auto !important;
  width: 92px !important;
  min-width: 92px !important;
  max-width: 92px !important;
  box-sizing: border-box !important;
}

@media (max-width: 760px) {
  .view-filter-row {
    gap: 6px !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
  .view-filter-row > .category-filters { gap: 6px !important; }
  .view-filter-row > .view-switch {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
  }
}

@media (max-width: 420px) {
  .view-filter-row {
    gap: 4px !important;
    padding-left: 6px !important;
    padding-right: 6px !important;
  }
  .view-filter-row > .category-filters { gap: 4px !important; }
  .view-filter-row > .view-switch {
    width: 72px !important;
    min-width: 72px !important;
    max-width: 72px !important;
  }
  .view-filter-row > .view-switch .view-btn { width: 32px !important; }
}


/* ---------- Floating add action ---------- */
.add-item-btn {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 45;
  width: 56px;
  height: 56px;
  min-width: 56px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(0,0,0,.16), 0 2px 6px rgba(0,0,0,.08);
}
.add-item-btn span:first-child {
  font-size: 30px;
  line-height: 1;
  font-weight: 400;
  transform: translateY(-1px);
}
.add-item-btn:hover { transform: translateY(-1px); }
.add-item-btn:active { transform: scale(.96); }

/* Modals deliberately sit above the floating action button. */
.who-modal { z-index: 100; }

@media (max-width: 560px) {
  .add-item-btn {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    width: 52px;
    height: 52px;
    min-width: 52px;
  }
  .add-item-btn span:first-child { font-size: 28px; }
}

@media (max-width: 380px) {
  .add-item-btn {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    width: 50px;
    height: 50px;
    min-width: 50px;
  }
}


/* ---------- Motion + shuffle polish ---------- */
.view-filter-row,
.category-filter,
.view-switch,
.view-btn,
.icon-action,
.btn,
.search-box,
.item-card,
.table-row,
.table-thumb,
.card-more,
.step-btn,
.who-link,
.carousel-nav,
.dot {
  transition:
    transform 180ms cubic-bezier(.2,.8,.2,1),
    opacity 180ms ease,
    background-color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    color 180ms ease;
}

.category-filter:hover,
.search-box:focus-within {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(0,0,0,.06);
}

.view-btn:hover:not(.active),
.icon-action:hover:not(:disabled) {
  transform: scale(1.04);
}

.icon-action {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  padding: 0;
  border: 0;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #6e6e73;
  background: transparent;
  font-size: 16px;
}
.icon-action:hover:not(:disabled) { background: rgba(255,255,255,.72); }
.icon-action:active:not(:disabled) { transform: scale(.94); }
.icon-action:disabled { opacity: .38; cursor: default; }
.icon-action:focus-visible {
  outline: 3px solid rgba(0,113,227,.18);
  outline-offset: 2px;
}

.view-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

.shuffle-burst .item-card {
  animation: shuffleCard .48s cubic-bezier(.2,.8,.2,1) both;
}
.shuffle-burst .item-card:nth-child(2n) { animation-delay: 35ms; }
.shuffle-burst .item-card:nth-child(3n) { animation-delay: 70ms; }

@keyframes shuffleCard {
  0% { opacity: .45; transform: scale(.97) translateY(8px); }
  55% { opacity: 1; transform: scale(1.015) translateY(-3px); }
  100% { opacity: 1; transform: scale(1); }
}

/* Native hidden is intentionally preserved; the entrance animation runs when
   the element becomes visible and the panel itself gets a gentle lift. */
.who-modal:not([hidden]) {
  animation: modalBackdropIn 180ms ease-out both;
}
.who-modal:not([hidden]) .who-panel,
.who-modal:not([hidden]) .admin-panel {
  animation: modalPanelIn 220ms cubic-bezier(.2,.8,.2,1) both;
}

@keyframes modalBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modalPanelIn {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.table-row {
  animation: rowIn 220ms ease-out both;
}
.table-row:nth-child(2) { animation-delay: 20ms; }
.table-row:nth-child(3) { animation-delay: 40ms; }
.table-row:nth-child(4) { animation-delay: 60ms; }
@keyframes rowIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 760px) {
  .view-actions { gap: 3px; }
  .icon-action { width: 36px; height: 36px; flex-basis: 36px; border-radius: 11px; font-size: 14px; }
}

@media (max-width: 420px) {
  .view-actions { gap: 1px; }
  .icon-action { width: 33px; height: 33px; flex-basis: 33px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Final toolbar geometry: filters + shuffle + view switch always share one row. */
.view-filter-row > .category-filters {
  flex: 1 1 auto !important;
  min-width: 0 !important;
}
.view-filter-row > .view-actions {
  flex: 0 0 auto !important;
  min-width: max-content !important;
  display: inline-flex !important;
  align-items: center !important;
}
.view-filter-row > .view-actions .view-switch {
  width: 92px !important;
  min-width: 92px !important;
  max-width: 92px !important;
}

@media (max-width: 760px) {
  .view-filter-row > .view-actions .view-switch {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
  }
}
@media (max-width: 420px) {
  .view-filter-row > .view-actions .view-switch {
    width: 72px !important;
    min-width: 72px !important;
    max-width: 72px !important;
  }
}

/* ---------- Self-hosted Font Awesome + compact mobile editor ---------- */
.search-box .fa-magnifying-glass,
.view-btn .fa-solid,
.icon-action .fa-solid,
.add-item-btn .fa-solid {
  display: inline-block;
  line-height: 1;
}
.search-box .fa-magnifying-glass { color: #8e8e93; font-size: 18px; flex: 0 0 auto; }
.view-btn .fa-solid { font-size: 18px; }

/* The editor is intentionally compact on phones so the complete form fits
   within the viewport in normal portrait use. */
@media (max-width: 560px) {
  .who-modal { padding: 8px; align-items: center; }
  .who-panel, .admin-panel {
    width: min(100%, 430px);
    max-height: calc(100svh - 16px);
    border-radius: 22px;
    overflow: hidden;
  }
  .admin-panel { display: flex; flex-direction: column; }
  .admin-panel .who-header { padding: 13px 15px 11px; flex: 0 0 auto; }
  .admin-panel .who-header h2 { font-size: 17px; }
  .admin-panel .modal-subtitle { display: none; }
  .admin-form {
    gap: 9px;
    padding: 13px 15px 15px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .admin-form label { gap: 4px; font-size: 12px; }
  .admin-form input, .admin-form textarea, .admin-form select {
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 11px;
    font-size: 16px;
  }
  .admin-form textarea { min-height: 70px; }
  .form-grid { gap: 8px; }
  .price-form-section { padding-top: 1px; }
  .admin-only-field small { display: none; }
  .modal-actions { padding-top: 2px; gap: 7px; }
  .modal-actions .btn { min-height: 40px; padding-inline: 14px; }
}

@media (max-width: 390px) {
  .admin-form { gap: 7px; padding: 11px 13px 13px; }
  .admin-panel .who-header { padding: 11px 13px 9px; }
  .admin-form input, .admin-form textarea, .admin-form select { min-height: 38px; padding: 7px 9px; }
  .admin-form textarea { min-height: 58px; }
  .form-grid { gap: 6px; }
}


/* Font Awesome reliability: use the bundled font, not a remote CDN. */
.fa-solid,.fas,.fa{font-family:"Font Awesome 6 Free" !important;font-weight:900 !important;font-style:normal;}
.fa-solid::before,.fas::before,.fa::before{display:inline-block;}

/* ---------- Targeted header sizing: keep search compact without changing the rest of the UI ---------- */
.topbar {
  grid-template-columns: max-content minmax(180px, min(520px, 46vw)) max-content;
  justify-content: space-between;
}
.utility-row {
  min-width: 0;
  max-width: 520px;
}
.search-box {
  min-width: 0;
  max-width: 520px;
}

/* Uploaded-image alternative to the existing external URL field. */
.image-source-field {
  display: grid;
  gap: 6px;
}
.image-upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}
.image-upload-row .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex: 0 0 auto;
}
.upload-status {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: max-content minmax(120px, 1fr) auto;
    gap: 8px;
  }
  .topbar-title { grid-column: 1; grid-row: 1; }
  .utility-row {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    max-width: 420px;
  }
  .topbar-user {
    grid-column: 3;
    grid-row: 1;
  }
  .search-box {
    width: 100%;
    max-width: 420px;
  }
}

@media (max-width: 420px) {
  .topbar {
    grid-template-columns: max-content minmax(100px, 1fr) auto;
    gap: 6px;
    padding-inline: 8px;
  }
  .utility-row { max-width: none; }
  .search-box { max-width: none; }
  .image-upload-row { gap: 6px; }
  .image-upload-row .btn { padding-inline: 11px; }
}


/* ---------- Third view: thumbnail grid ----------
   A lightweight browse view: thumbnails are arranged in a vertical-scrolling
   grid, while selecting any tile opens that item in the existing card view.
*/
.grid-view {
  width: 100%;
  min-width: 0;
  padding: 8px 0 40px;
}
.thumbnail-grid {
  width: min(100%, 1080px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.thumbnail-tile {
  appearance: none;
  position: relative;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 22px;
  overflow: hidden;
  aspect-ratio: 1 / 1.08;
  background: #e8e8ed;
  box-shadow: 0 8px 24px rgba(0,0,0,.07);
  color: #fff;
  text-align: left;
  cursor: pointer;
  transition: transform 180ms cubic-bezier(.2,.8,.2,1), box-shadow 180ms ease, opacity 180ms ease;
}
.thumbnail-tile:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(0,0,0,.11); }
.thumbnail-tile:active { transform: scale(.985); }
.thumbnail-tile:focus-visible { outline: 3px solid rgba(0,113,227,.28); outline-offset: 3px; }
.thumbnail-media { position: absolute; inset: 0; display: block; }
.thumbnail-image, .thumbnail-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumbnail-placeholder {
  display: grid;
  place-items: center;
  background: linear-gradient(145deg,#707477,#34383a);
  color: rgba(255,255,255,.85);
  font-size: 34px;
}
.thumbnail-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 42%, rgba(0,0,0,.06) 52%, rgba(0,0,0,.72) 100%);
}
.thumbnail-name {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 13px;
  display: -webkit-box;
  overflow: hidden;
  color: #fff;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 650;
  text-shadow: 0 2px 10px rgba(0,0,0,.3);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Three view buttons need a little more room than the previous two-view switch. */
.view-filter-row > .view-actions .view-switch {
  width: 112px !important;
  min-width: 112px !important;
  max-width: 112px !important;
}
.view-filter-row > .view-actions .view-btn {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
}

@media (max-width: 760px) {
  .thumbnail-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }
  .thumbnail-tile { border-radius: 17px; }
  .thumbnail-name { left: 10px; right: 10px; bottom: 10px; font-size: 12px; }
  .view-filter-row > .view-actions .view-switch {
    width: 106px !important;
    min-width: 106px !important;
    max-width: 106px !important;
  }
}

@media (max-width: 520px) {
  .thumbnail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .grid-view { padding-top: 4px; }
}

@media (max-width: 420px) {
  .view-filter-row > .view-actions .view-switch {
    width: 100px !important;
    min-width: 100px !important;
    max-width: 100px !important;
  }
  .view-filter-row > .view-actions .view-btn { width: auto !important; }
}

@media (max-width: 360px) {
  .thumbnail-grid { gap: 7px; }
  .thumbnail-name { font-size: 11px; left: 8px; right: 8px; bottom: 8px; }
  .view-filter-row > .view-actions .view-switch {
    width: 96px !important;
    min-width: 96px !important;
    max-width: 96px !important;
  }
}

/* ---------- Slow physical-card motion ----------
   Subtle 3D drift gives cards the feel of real paper cards settling in space,
   while the outer card keeps its carousel geometry and snap position intact.
*/
.carousel-track,
.thumbnail-grid { perspective: 1400px; }

.card-motion,
.thumbnail-motion {
  transform-style: preserve-3d;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform;
}

.card-motion {
  position: absolute;
  inset: 0;
  transform-origin: 50% 55%;
  animation: slow-card-drift 18s ease-in-out infinite;
}

.item-card:nth-child(2n) .card-motion { animation-delay: -6s; }
.item-card:nth-child(3n) .card-motion { animation-delay: -12s; }
.item-card:nth-child(4n) .card-motion { animation-duration: 21s; animation-delay: -4s; }
.item-card:nth-child(5n) .card-motion { animation-duration: 16s; animation-delay: -9s; }

/* The animated wrapper owns the depth; the article itself remains responsible
   for the existing center/side-card scale and opacity states. */
.card-image-layer { z-index: 0; }
.card-content { z-index: 1; }

@keyframes slow-card-drift {
  0%, 100% { transform: translate3d(0, 0, 0) rotateX(-0.35deg) rotateY(-0.7deg) rotateZ(-0.18deg); }
  25% { transform: translate3d(0.7px, -1px, 0) rotateX(0.3deg) rotateY(0.55deg) rotateZ(0.12deg); }
  50% { transform: translate3d(-0.45px, 0.7px, 0) rotateX(0.55deg) rotateY(-0.4deg) rotateZ(0.2deg); }
  75% { transform: translate3d(0.35px, -0.45px, 0) rotateX(-0.25deg) rotateY(0.35deg) rotateZ(-0.1deg); }
}

.thumbnail-motion {
  position: absolute;
  inset: 0;
  transform-origin: 50% 55%;
  animation: slow-thumbnail-drift 15s ease-in-out infinite;
}
.thumbnail-tile:nth-child(2n) .thumbnail-motion { animation-delay: -5s; }
.thumbnail-tile:nth-child(3n) .thumbnail-motion { animation-delay: -10s; }
.thumbnail-tile:nth-child(4n) .thumbnail-motion { animation-duration: 18s; animation-delay: -3s; }
.thumbnail-tile:nth-child(5n) .thumbnail-motion { animation-duration: 13s; animation-delay: -7s; }

@keyframes slow-thumbnail-drift {
  0%, 100% { transform: translate3d(0, 0, 0) rotateX(-0.3deg) rotateY(0.65deg) rotateZ(-0.15deg); }
  30% { transform: translate3d(0.45px, -0.5px, 0) rotateX(0.35deg) rotateY(-0.45deg) rotateZ(0.12deg); }
  60% { transform: translate3d(-0.35px, 0.45px, 0) rotateX(-0.4deg) rotateY(0.3deg) rotateZ(0.16deg); }
}

@media (hover: hover) and (pointer: fine) {
  .item-card:hover .card-motion { animation-play-state: paused; }
  .thumbnail-tile:hover .thumbnail-motion { animation-play-state: paused; }
}

@media (prefers-reduced-motion: reduce) {
  .card-motion,
  .thumbnail-motion { animation: none !important; transform: none !important; }
}

/* ---------- Rounded physical-card surfaces ----------
   Keep the outer animated surface rounded so the image, glare, and content
   all share the same physical silhouette.
*/
.item-card {
  border-radius: 28px !important;
  overflow: hidden;
  clip-path: inset(0 round 28px);
}
.thumbnail-tile {
  border-radius: 18px !important;
  overflow: hidden;
  clip-path: inset(0 round 18px);
}

/* ---------- True physical-card motion (outer surface) ----------
   The transform now belongs to the actual card/tile element. The inner
   content wrapper is deliberately transform-neutral so text, controls and
   imagery cannot appear to slide independently of the card surface.
*/
.item-card {
  --card-scale: .94;
  transform-style: preserve-3d;
  transform-origin: 50% 55%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform, box-shadow;
  transform: scale(var(--card-scale));
  animation: physical-card-drift 18s ease-in-out infinite;
}
.item-card.is-center { --card-scale: 1; }
.item-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(112deg, transparent 25%, rgba(255,255,255,0) 40%, rgba(255,255,255,.22) 49%, rgba(255,255,255,0) 58%, transparent 75%);
  background-size: 220% 100%;
  background-position: 140% 0;
  mix-blend-mode: screen;
  opacity: .12;
  animation: physical-card-glare 18s ease-in-out infinite;
}
.item-card .card-motion,
.item-card .card-motion * { transform: none !important; }
.item-card:nth-child(2n) { animation-delay: -6s; }
.item-card:nth-child(3n) { animation-delay: -12s; }
.item-card:nth-child(4n) { animation-duration: 21s; animation-delay: -4s; }
.item-card:nth-child(5n) { animation-duration: 16s; animation-delay: -9s; }

@keyframes physical-card-drift {
  0%, 100% {
    transform: scale(var(--card-scale)) translate3d(0,0,0) rotateX(-1.1deg) rotateY(-2deg) rotateZ(-0.28deg);
    box-shadow: 0 18px 46px rgba(0,0,0,.13), 0 5px 16px rgba(0,0,0,.07);
  }
  25% {
    transform: scale(var(--card-scale)) translate3d(.8px,-.7px,0) rotateX(.8deg) rotateY(1.6deg) rotateZ(.22deg);
    box-shadow: 3px 21px 48px rgba(0,0,0,.15), 0 6px 18px rgba(0,0,0,.07);
  }
  50% {
    transform: scale(var(--card-scale)) translate3d(-.6px,.7px,0) rotateX(1.25deg) rotateY(-1.3deg) rotateZ(.3deg);
    box-shadow: -3px 20px 48px rgba(0,0,0,.14), 0 5px 17px rgba(0,0,0,.07);
  }
  75% {
    transform: scale(var(--card-scale)) translate3d(.45px,-.35px,0) rotateX(-.7deg) rotateY(1deg) rotateZ(-.18deg);
    box-shadow: 2px 18px 45px rgba(0,0,0,.14), 0 5px 16px rgba(0,0,0,.07);
  }
}

@keyframes physical-card-glare {
  0%, 100% { background-position: 140% 0; opacity: .08; }
  25% { background-position: 90% 0; opacity: .16; }
  50% { background-position: 35% 0; opacity: .23; }
  75% { background-position: -15% 0; opacity: .12; }
}

.thumbnail-tile {
  --thumb-scale: 1;
  transform-style: preserve-3d;
  transform-origin: 50% 55%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform, box-shadow;
  animation: physical-thumbnail-drift 15s ease-in-out infinite;
}
.thumbnail-tile .thumbnail-motion,
.thumbnail-tile .thumbnail-motion * { transform: none !important; }
.thumbnail-tile:nth-child(2n) { animation-delay: -5s; }
.thumbnail-tile:nth-child(3n) { animation-delay: -10s; }
.thumbnail-tile:nth-child(4n) { animation-duration: 18s; animation-delay: -3s; }
.thumbnail-tile:nth-child(5n) { animation-duration: 13s; animation-delay: -7s; }
.thumbnail-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(112deg, transparent 25%, rgba(255,255,255,0) 42%, rgba(255,255,255,.18) 50%, rgba(255,255,255,0) 58%, transparent 75%);
  background-size: 220% 100%;
  background-position: 140% 0;
  mix-blend-mode: screen;
  opacity: .1;
  animation: physical-thumbnail-glare 15s ease-in-out infinite;
}
@keyframes physical-thumbnail-drift {
  0%,100% { transform: scale(var(--thumb-scale)) rotateX(-.7deg) rotateY(-1.25deg) rotateZ(-.18deg); box-shadow: 0 8px 24px rgba(0,0,0,.07); }
  30% { transform: scale(var(--thumb-scale)) translate3d(.5px,-.4px,0) rotateX(.55deg) rotateY(1deg) rotateZ(.14deg); box-shadow: 2px 10px 27px rgba(0,0,0,.09); }
  60% { transform: scale(var(--thumb-scale)) translate3d(-.4px,.45px,0) rotateX(-.65deg) rotateY(.8deg) rotateZ(.17deg); box-shadow: -2px 10px 27px rgba(0,0,0,.09); }
}
@keyframes physical-thumbnail-glare {
  0%,100% { background-position: 140% 0; opacity: .06; }
  45% { background-position: 35% 0; opacity: .16; }
  75% { background-position: -10% 0; opacity: .08; }
}

@media (hover: hover) and (pointer: fine) {
  .item-card:hover,
  .thumbnail-tile:hover { animation-play-state: paused; }
  .item-card:hover::after,
  .thumbnail-tile:hover::after { animation-play-state: paused; }
}

@media (prefers-reduced-motion: reduce) {
  .item-card,
  .thumbnail-tile,
  .item-card::after,
  .thumbnail-tile::after { animation: none !important; }
  .item-card { transform: scale(var(--card-scale)) !important; }
  .thumbnail-tile { transform: none !important; }
}

/* ---------- Mobile header overflow correction ----------
   The Add button is fixed-position, so it must not reserve a grid column.
   Keep the title, search, and sign-out controls in three actual columns. */
@media (max-width: 760px) {
  .topbar {
    grid-template-columns: max-content minmax(0, 1fr) auto !important;
    grid-template-rows: 44px !important;
    gap: 8px !important;
    padding-inline: 10px !important;
    min-width: 0;
    overflow: hidden;
  }
  .topbar-title {
    grid-column: 1 !important;
    grid-row: 1 !important;
    min-width: 0 !important;
  }
  .utility-row {
    grid-column: 2 !important;
    grid-row: 1 !important;
    min-width: 0 !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
  }
  .topbar-user {
    grid-column: 3 !important;
    grid-row: 1 !important;
    min-width: 0 !important;
    justify-self: end !important;
  }
  .search-box {
    min-width: 0 !important;
    max-width: 100% !important;
  }
}

@media (max-width: 560px) {
  .topbar {
    grid-template-columns: max-content minmax(0, 1fr) auto !important;
    gap: 6px !important;
    padding-inline: 8px !important;
  }
}

@media (max-width: 420px) {
  .topbar {
    grid-template-columns: max-content minmax(0, 1fr) auto !important;
    gap: 5px !important;
    padding-inline: 8px !important;
  }
}


/* ---------- Compact logout control ----------
   Keep the mobile header from overflowing: the logout action is icon-only
   while retaining an accessible label and tooltip. */
.logout-icon-btn {
  width: 44px !important;
  min-width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 44px !important;
  border-radius: 50% !important;
  font-size: 18px !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}
.logout-icon-btn i {
  display: block;
}
@media (max-width: 560px) {
  .logout-icon-btn {
    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    flex-basis: 42px !important;
    font-size: 17px !important;
  }
}
@media (max-width: 360px) {
  .logout-icon-btn {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    flex-basis: 40px !important;
  }
}


/* Final logout icon fix: never render a text/emoji pseudo-element.
   The Font Awesome glyph is the only visual content of this control. */
.topbar-user .logout-icon-btn::before,
.topbar-user .logout-icon-btn::after {
  content: none !important;
  display: none !important;
}
.topbar-user .logout-icon-btn > i.fa-solid {
  display: inline-block !important;
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
  font-style: normal !important;
  font-size: 18px !important;
  line-height: 1 !important;
  width: auto !important;
  height: auto !important;
}
@media (max-width: 500px) {
  .topbar-user .logout-icon-btn > i.fa-solid {
    font-size: 17px !important;
  }
}


/* ---------- Personal cart view ---------- */
.cart-view { width: 100%; min-width: 0; padding-bottom: 28px; }
.cart-panel { overflow: hidden; border: 1px solid rgba(0,0,0,.07); border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.cart-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 20px; border-bottom: 1px solid #e5e5ea; background: #f7f7f9; }
.cart-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.35px; }
.cart-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.cart-summary { display: flex; align-items: flex-end; flex-direction: column; gap: 3px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.cart-summary-total { color: var(--text); font-size: 15px; font-weight: 700; }
.cart-list { display: grid; }
.cart-item { display: grid; grid-template-columns: 64px minmax(0,1fr) auto; align-items: center; gap: 14px; min-height: 88px; padding: 12px 20px; border-bottom: 1px solid #e5e5ea; }
.cart-item:last-child { border-bottom: 0; }
.cart-item-media { width: 64px; height: 64px; overflow: hidden; border-radius: 14px; background: #f2f2f7; display: grid; place-items: center; }
.cart-item-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cart-thumb-placeholder { font-size: 22px; color: #8e8e93; }
.cart-item-main { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.cart-item-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-item-main .category-row { margin: 0; min-height: 0; }
.cart-item-price { color: var(--muted); font-size: 12px; }
.cart-item-price strong { color: var(--text); }
.cart-item-actions { display: flex; align-items: center; gap: 10px; }
.cart-qty-label { display: none; color: var(--muted); font-size: 11px; }
.cart-empty { min-height: 220px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 7px; color: var(--muted); padding: 28px; text-align: center; }
.cart-empty i { font-size: 28px; color: var(--accent); margin-bottom: 4px; }
.cart-empty strong { color: var(--text); font-size: 16px; }
.cart-empty span { font-size: 12px; }
.cart-count-badge { position: absolute; top: 3px; right: 3px; min-width: 15px; height: 15px; padding: 0 3px; display: grid; place-items: center; border-radius: 999px; background: var(--accent); color: #fff; font-size: 9px; line-height: 1; font-weight: 700; box-shadow: 0 0 0 2px #fff; }
.cart-view-btn { position: relative; }

/* Four view icons still need to fit in the single-row toolbar. */
.view-filter-row > .view-actions .view-switch { width: 176px !important; min-width: 176px !important; max-width: 176px !important; }
.view-filter-row > .view-actions .view-btn { width: 39px !important; }
@media (max-width: 760px) {
  .view-filter-row > .view-actions .view-switch { width: 154px !important; min-width: 154px !important; max-width: 154px !important; }
  .view-filter-row > .view-actions .view-btn { width: 34px !important; }
  .cart-heading { padding: 15px; }
  .cart-item { padding: 11px 14px; gap: 11px; }
}
@media (max-width: 420px) {
  .view-filter-row > .view-actions .view-switch { width: 142px !important; min-width: 142px !important; max-width: 142px !important; }
  .view-filter-row > .view-actions .view-btn { width: 31px !important; }
  .cart-item { grid-template-columns: 52px minmax(0,1fr); }
  .cart-item-media { width: 52px; height: 52px; border-radius: 12px; }
  .cart-item-actions { grid-column: 2; justify-content: space-between; }
  .cart-qty-label { display: block; }
  .cart-heading { align-items: flex-start; gap: 10px; }
  .cart-summary { text-align: right; }
}


/* Final modal-select consistency: all edit/add dropdowns retain the same
   pill treatment as the main filter controls at every viewport size. */
.admin-form .category-filter {
  height: 44px !important;
  min-height: 44px !important;
  border-radius: 22px !important;
  padding: 0 34px 0 16px !important;
  font-size: 15px !important;
}
@media (max-width: 760px) {
  .admin-form .category-filter {
    height: 40px !important;
    min-height: 40px !important;
    border-radius: 20px !important;
    padding: 0 28px 0 12px !important;
    font-size: 13px !important;
    background-position: calc(100% - 14px) 17px, calc(100% - 10px) 17px;
  }
}
@media (max-width: 560px) {
  .admin-form .category-filter {
    height: 38px !important;
    min-height: 38px !important;
    border-radius: 19px !important;
    padding-inline: 10px 24px !important;
    font-size: 12px !important;
    background-position: calc(100% - 12px) 16px, calc(100% - 8px) 16px;
  }
}


/* Admin user management — compact, matching the existing modal language. */
.user-management-panel {
  width: min(100%, 560px);
  max-height: min(90svh, 700px);
  overflow: auto;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 20px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 24px 80px rgba(0,0,0,.18);
}
.user-management-body { padding: 14px 16px 16px; }
.user-management-list { display: grid; gap: 8px; }
.managed-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid rgba(0,0,0,.07);
  border-radius: 14px;
  background: rgba(248,248,246,.8);
}
.managed-user-row > div { min-width: 0; display: grid; gap: 2px; }
.managed-user-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.managed-user-row small { color: var(--muted); font-size: 11px; }
.user-management-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(0,0,0,.07);
  display: grid;
  gap: 10px;
}
.managed-user-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.managed-user-heading strong { font-size: 14px; }
.user-management-form label { display: grid; gap: 5px; }
.user-management-form label > span { font-size: 12px; font-weight: 600; }
.user-management-form label small { color: var(--muted); font-weight: 400; }
.user-management-form input {
  width: 100%; min-width: 0; height: 42px; border: 1px solid rgba(0,0,0,.1);
  border-radius: 21px; padding: 0 14px; background: rgba(248,248,246,.9); font: inherit;
}
.admin-user-management-btn { width: 38px; min-width: 38px; padding: 0; border-radius: 19px; }
@media (max-width: 560px) {
  .user-management-panel { border-radius: 18px; }
  .user-management-body { padding: 12px; }
  .managed-user-row { padding: 9px 10px; }
  .user-management-form input { height: 40px; }
}

/* Final user-management icon sizing: match the logout control on desktop and mobile. */
.topbar-user .admin-user-management-btn {
  width: 44px !important;
  min-width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 44px !important;
  border-radius: 50% !important;
  font-size: 18px !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}
.topbar-user .admin-user-management-btn::before,
.topbar-user .admin-user-management-btn::after {
  content: none !important;
  display: none !important;
}
.topbar-user .admin-user-management-btn > i.fa-solid {
  display: inline-block !important;
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
  font-style: normal !important;
  font-size: 18px !important;
  line-height: 1 !important;
  width: auto !important;
  height: auto !important;
}
@media (max-width: 560px) {
  .topbar-user .admin-user-management-btn {
    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    flex-basis: 42px !important;
    font-size: 17px !important;
  }
  .topbar-user .admin-user-management-btn > i.fa-solid {
    font-size: 17px !important;
  }
}
@media (max-width: 360px) {
  .topbar-user .admin-user-management-btn {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    flex-basis: 40px !important;
  }
}


/* Admin user cart inspection. */
.managed-user-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.managed-user-cart { margin-top: 4px; }
.managed-user-cart-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 4px 0 12px; border-bottom: 1px solid rgba(0,0,0,.07);
}
.managed-user-cart-header > div { min-width: 0; display: grid; gap: 3px; }
.managed-user-cart-header strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.managed-user-cart-header span { font-size: 11px; }
.managed-user-cart-list { display: grid; gap: 8px; padding-top: 12px; }
.managed-cart-item {
  display: grid; grid-template-columns: 52px minmax(0,1fr) auto; align-items: center; gap: 11px;
  min-width: 0; padding: 10px; border: 1px solid rgba(0,0,0,.07); border-radius: 14px; background: rgba(248,248,246,.8);
}
.managed-cart-item-media { width: 52px; height: 52px; overflow: hidden; border-radius: 12px; background: #f2f2f7; display: grid; place-items: center; }
.managed-cart-item-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.managed-cart-item-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.managed-cart-item-main > strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.managed-cart-item-main .category-row { margin: 0; min-height: 0; }
.managed-cart-item-main > span { color: var(--muted); font-size: 11px; }
.managed-cart-item-main > span strong { color: var(--text); }
.managed-cart-qty { display: grid; justify-items: end; gap: 1px; min-width: 32px; }
.managed-cart-qty small { color: var(--muted); font-size: 10px; }
.managed-cart-qty strong { font-size: 16px; }
.managed-cart-empty { min-height: 180px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 7px; color: var(--muted); padding: 24px; text-align: center; }
.managed-cart-empty i { font-size: 26px; color: var(--accent); margin-bottom: 3px; }
.managed-cart-empty strong { color: var(--text); font-size: 15px; }
.managed-cart-empty span { font-size: 11px; }
@media (max-width: 560px) {
  .managed-user-actions { gap: 4px; }
  .managed-user-row { align-items: center; }
  .managed-user-actions .btn { padding-inline: 10px; }
  .managed-cart-item { grid-template-columns: 48px minmax(0,1fr) auto; gap: 9px; padding: 9px; }
  .managed-cart-item-media { width: 48px; height: 48px; border-radius: 11px; }
  .managed-user-cart-header { align-items: flex-start; }
}


/* User management actions: compact horizontal icon buttons. */
.managed-user-actions {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 7px !important;
  flex-shrink: 0 !important;
  white-space: nowrap !important;
}
.managed-user-actions .managed-user-action-btn {
  width: 40px !important;
  min-width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 40px !important;
  font-size: 17px !important;
  line-height: 1 !important;
}
.managed-user-actions .managed-user-action-btn::before,
.managed-user-actions .managed-user-action-btn::after {
  content: none !important;
  display: none !important;
}
.managed-user-actions .managed-user-action-btn > i.fa-solid {
  display: inline-block !important;
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
  font-style: normal !important;
  font-size: 17px !important;
  line-height: 1 !important;
}
@media (max-width: 560px) {
  .managed-user-actions { gap: 6px !important; }
  .managed-user-actions .managed-user-action-btn {
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    flex-basis: 38px !important;
    font-size: 16px !important;
  }
  .managed-user-actions .managed-user-action-btn > i.fa-solid { font-size: 16px !important; }
}


/* Price sorting toggle in the toolbar. */
.sort-price-btn.active {
  color: var(--accent);
  background: rgba(0,113,227,.10);
  box-shadow: inset 0 0 0 1px rgba(0,113,227,.12);
}
.sort-price-btn.active:hover:not(:disabled) {
  background: rgba(0,113,227,.14);
}


/* ---------- Header: search + controls only ---------- */
.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: 52px;
}
.topbar-title { display: none !important; }
.utility-row {
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  justify-self: stretch;
}
.topbar-user {
  grid-column: 2;
  grid-row: 1;
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 44px;
    min-height: var(--header-h);
    gap: 8px;
    padding: 7px 10px;
  }
  .utility-row { grid-column: 1; grid-row: 1; width: 100%; }
  .topbar-user { grid-column: 2; grid-row: 1; }
}

/* Admin password icon button. Keep it consistent with the other compact header controls. */
.admin-password-btn {
  width: 38px !important;
  min-width: 38px !important;
  height: 38px !important;
  min-height: 38px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 50% !important;
  font-size: 16px !important;
  line-height: 1 !important;
}
.admin-password-btn::before,
.admin-password-btn::after {
  content: none !important;
  display: none !important;
}
.admin-password-btn > i.fa-solid {
  display: inline-block !important;
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
  font-style: normal !important;
  font-size: 16px !important;
  line-height: 1 !important;
}
@media (max-width: 560px) {
  .admin-password-btn {
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    flex-basis: 36px !important;
  }
  .admin-password-btn > i.fa-solid { font-size: 15px !important; }
}

/* Admin password controls now live inside Manage users. */
.admin-password-section {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid rgba(0,0,0,.07);
  border-radius: 14px;
  background: rgba(248,248,246,.8);
}
.admin-password-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.admin-password-section-header > div:first-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.admin-password-section-header strong { font-size: 13px; }
.admin-password-section-header .muted { font-size: 11px; }
.admin-password-inline-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}
.admin-password-inline-btn > i.fa-solid { font-size: 13px; }
.admin-password-form {
  margin-top: 12px;
  padding-top: 12px;
}
@media (max-width: 560px) {
  .admin-password-section-header { align-items: flex-start; }
  .admin-password-inline-btn span { display: none; }
  .admin-password-inline-btn { width: 38px; min-width: 38px; height: 38px; padding: 0; border-radius: 19px; }
  .admin-password-inline-btn > i.fa-solid { font-size: 15px; }
}

/* ---------- iOS Safari stability mode ----------
   WebKit can terminate the WebContent process when a page contains many
   simultaneous 3D transforms, backdrop filters and blend-mode layers. Keep
   the same layout and controls, but use flat compositing on iPhone/iPad.
*/
.ios-lightweight .topbar,
.ios-lightweight .view-filter-row,
.ios-lightweight .who-modal,
.ios-lightweight .card-top .category-badge,
.ios-lightweight .card-more,
.ios-lightweight .card-controls {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

.ios-lightweight .topbar { background: rgba(255,255,255,.97); }
.ios-lightweight .view-filter-row { background: rgba(245,245,247,.97); }
.ios-lightweight .item-card,
.ios-lightweight .thumbnail-tile,
.ios-lightweight .card-motion,
.ios-lightweight .thumbnail-motion {
  transform: none !important;
  animation: none !important;
  transition: none !important;
  will-change: auto !important;
  transform-style: flat !important;
  -webkit-transform-style: flat !important;
}

.ios-lightweight .item-card::after,
.ios-lightweight .thumbnail-tile::after {
  display: none !important;
  animation: none !important;
}

.ios-lightweight .card-motion,
.ios-lightweight .thumbnail-motion {
  -webkit-backface-visibility: visible;
  backface-visibility: visible;
}

/* ---------- iOS modal blur ----------
   Keep the lightweight page/card compositing that prevents Safari crashes,
   but restore the frosted backdrop when a modal is actually open. The blur
   is limited to the single modal overlay; modal panels remain flat. */
.ios-lightweight .who-modal {
  background: rgba(0,0,0,.28) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  backdrop-filter: blur(8px) !important;
}


/* iOS active-card repaint fix: keep the active state explicit rather than
 relying only on Safari's class/transition repaint after scroll-snap. */
.ios-lightweight .item-card {
  transition: none !important;
}
.ios-lightweight .item-card.is-center {
  opacity: 1 !important;
}
.ios-lightweight .item-card:not(.is-center) {
  opacity: .48 !important;
}
