:root {
  --page-bg: #eef5f9;
  --surface: #ffffff;
  --surface-soft: #f6fafc;
  --ink: #2f3d4a;
  --muted: #99abb4;
  --line: #d9e4ea;
  --brand: #1976d2;
  --brand-dark: #0e4c91;
  --sidebar-bg: #1f2d3d;
  --sidebar-bg-deep: #17212b;
  --success: #26c6da;
  --warning: #ffb22b;
  --danger: #ef5350;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--page-bg);
  font-family: "Comic Neue", "Trebuchet MS", sans-serif;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Bangers", "Impact", sans-serif;
  letter-spacing: 0.04em;
}

p {
  margin-top: 0;
}

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

button {
  border: 1px solid #2a5f9e;
  background: linear-gradient(180deg, #3b8de6 0%, #2c77cf 100%);
  color: #f8fcff;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 36px;
  line-height: 1.2;
  padding: 0.52rem 0.86rem;
  cursor: pointer;
  border-radius: 5px;
  box-shadow: 0 1px 2px rgba(20, 54, 92, 0.2);
  vertical-align: middle;
}

button:hover {
  filter: brightness(1.04);
}

button:active {
  transform: translateY(1px);
  box-shadow: 0 0 0 rgba(20, 54, 92, 0.2);
}

.login-wrap {
  width: min(440px, 92%);
  margin: 10vh auto;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(46, 61, 73, 0.08);
  border-radius: 6px;
  padding: 1.3rem;
}

.login-card h1 {
  margin-bottom: 0.6rem;
}

.login-form {
  display: grid;
  gap: 0.6rem;
}

.login-form h2 {
  margin: 0.45rem 0 0.2rem;
  color: #33536a;
  font-size: 1.2rem;
}

.login-form input {
  border: 1px solid #cfd9df;
  padding: 0.56rem 0.62rem;
  border-radius: 4px;
}

.login-links {
  margin-top: 0.65rem;
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
}

.login-link {
  color: #1f5f9f;
  font-weight: 700;
  text-decoration: none;
  font-size: 0.9rem;
}

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

.reset-form {
  margin-top: 0.95rem;
  padding-top: 0.9rem;
  border-top: 1px solid #d9e4ea;
}

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

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-deep) 100%);
  color: #c8d4dd;
  padding: 1rem;
}

.sidebar__brand {
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar__kicker {
  margin-bottom: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: #7f95a6;
}

.sidebar__brand h2 {
  color: #fff;
  font-size: 1.5rem;
}

.sidebar__user {
  margin: 0.95rem 0;
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
}

.sidebar__label {
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  color: #8ea4b3;
  text-transform: uppercase;
}

.sidebar__name {
  margin: 0;
  font-weight: 700;
  color: #fff;
}

.side-nav {
  display: grid;
  gap: 0.35rem;
}

.side-nav__link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #c7d6e2;
  text-decoration: none;
  padding: 0.56rem 0.62rem;
  border-radius: 4px;
  border: 1px solid transparent;
}

.side-nav__icon {
  width: 1.4rem;
  color: #88a8bf;
  text-align: center;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.side-nav__icon svg {
  width: 1.32rem;
  height: 1.32rem;
  display: block;
  fill: currentColor;
}

.side-nav__link:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}

.side-nav__link.is-active {
  background: rgba(25, 118, 210, 0.24);
  border-color: rgba(80, 162, 245, 0.45);
  color: #fff;
}

.side-nav__link.is-active .side-nav__icon {
  color: #ffffff;
}

.main-pane {
  min-width: 0;
  padding: 1rem 1.1rem;
}

.topbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(46, 61, 73, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1rem;
}

.topbar h1 {
  color: #455a64;
  margin-bottom: 0.18rem;
}

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

.topbar__actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}

.mobile-admin-nav {
  display: none;
  margin-top: 0.7rem;
  padding: 0.48rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbff;
  gap: 0.4rem;
  overflow-x: auto;
  white-space: nowrap;
}

.mobile-admin-nav__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0.42rem 0.62rem;
  border-radius: 6px;
  border: 1px solid #c7d7e2;
  background: #fff;
  color: #36556b;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.8rem;
}

.mobile-admin-nav__link.is-active {
  border-color: #5ea1d7;
  background: #eaf4ff;
  color: #1b4d7c;
}

.site-mode-form {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7fbff;
}

.site-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.site-mode-toggle__label {
  font-weight: 700;
  color: #546e7a;
}

.site-mode-toggle__control {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.site-mode-toggle__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.site-mode-toggle__track {
  position: relative;
  width: 52px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid #8b1f1f;
  background: linear-gradient(180deg, #ff8a8a, #d74141);
  transition: all 0.18s ease;
}

.site-mode-toggle__thumb {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(12, 21, 35, 0.35);
  transition: transform 0.18s ease;
}

.site-mode-toggle__input:checked + .site-mode-toggle__track {
  border-color: #19743f;
  background: linear-gradient(180deg, #72dd97, #2caa60);
}

.site-mode-toggle__input:checked + .site-mode-toggle__track .site-mode-toggle__thumb {
  transform: translateX(24px);
}

.site-mode-toggle__state {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.38rem;
  border-radius: 4px;
  border: 1px solid #adbbbb;
  color: #334a58;
  background: #f2f7fb;
}

.site-mode-toggle__state.is-online {
  border-color: #19743f;
  color: #116233;
  background: #e2f6ea;
}

.site-mode-toggle__state.is-offline {
  border-color: #8b1f1f;
  color: #7e1818;
  background: #ffe9e9;
}

.quick-link {
  display: inline-block;
  text-decoration: none;
  color: #4f6572;
  border: 1px solid #d4e0e6;
  background: #f8fbfd;
  border-radius: 4px;
  padding: 0.45rem 0.6rem;
  font-weight: 700;
  font-size: 0.82rem;
}

.quick-link:hover {
  border-color: #b7ccd7;
  background: #f0f7fc;
}

.btn-logout {
  min-width: 112px;
}

.admin-content {
  margin-top: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 2px 12px rgba(46, 61, 73, 0.05);
  padding: 1rem;
}

.diagnostics-panel {
  margin-top: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem;
  background: #fbfdff;
}

.diagnostics-panel__actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.diagnostics-panel__result {
  margin-top: 0.8rem;
  border: 1px solid #cfe0ec;
  border-radius: 6px;
  background: #ffffff;
  padding: 0.75rem;
}

.diagnostics-panel__result h3 {
  margin-bottom: 0.5rem;
  color: #435b6a;
}

.diagnostics-panel__result pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: #0f1720;
  color: #d3e6ff;
  border-radius: 6px;
  padding: 0.7rem;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
}

.ebay-oauth-status {
  margin: 0.35rem 0 0.8rem;
  border: 1px solid #c9d8e5;
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  background: #f6fbff;
  color: #244258;
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}

.ebay-oauth-status span {
  font-weight: 700;
}

.ebay-oauth-status small {
  color: #567082;
}

.ebay-oauth-status.is-validated {
  border-color: #9fc8ad;
  background: #edf7f0;
  color: #1f5a37;
}

.ebay-oauth-status.is-missing {
  border-color: #e0c2a7;
  background: #fff7ef;
  color: #7a4b1f;
}

.ebay-workflow h4 {
  margin: 0 0 0.35rem;
  color: #2c4d66;
}

.ebay-workflow p {
  margin: 0 0 0.55rem;
  color: #4a667a;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.8rem;
  margin-bottom: 0.85rem;
}

.page-head__title {
  color: #455a64;
  font-size: 1.7rem;
}

.page-head__crumb {
  color: var(--muted);
  margin: 0;
  font-size: 0.82rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 0.9rem;
}

.stat-card {
  border-radius: 6px;
  color: #fff;
  padding: 0.85rem;
  min-height: 102px;
}

.stat-card:nth-child(1) { background: linear-gradient(145deg, #03a9f3, #0288d1); }
.stat-card:nth-child(2) { background: linear-gradient(145deg, #7e57c2, #5e35b1); }
.stat-card:nth-child(3) { background: linear-gradient(145deg, #26c6da, #00acc1); }
.stat-card:nth-child(4) { background: linear-gradient(145deg, #ffb300, #fb8c00); }

.stat-card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
}

.stat-card p {
  margin: 0;
  font-size: 2rem;
  line-height: 1;
  font-weight: 700;
}

.dashboard-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 0.9rem;
}

.panel-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.9rem;
}

.panel-card h3 {
  color: #4a5f6b;
  margin-bottom: 0.65rem;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  line-height: 1.2;
  text-decoration: none;
  border: 1px solid #c8d7e4;
  background: linear-gradient(180deg, #ffffff 0%, #f1f7fd 100%);
  color: #3f5f74;
  border-radius: 5px;
  padding: 0.5rem 0.76rem;
  font-weight: 700;
  font-size: 0.84rem;
  box-shadow: 0 1px 2px rgba(27, 56, 84, 0.12);
  vertical-align: middle;
}

.action-btn:hover {
  background: linear-gradient(180deg, #fbfeff 0%, #e7f1fb 100%);
  border-color: #9fbed3;
  color: #304c61;
}

.action-btn.is-disabled,
.action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #e6edf3;
  border-color: #c8d6e1;
  color: #5f7788;
}

.snapshot-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid #dbe5ec;
  border-radius: 6px;
  overflow: hidden;
}

.snapshot-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.55rem 0.65rem;
  border-top: 1px solid #dbe5ec;
}

.snapshot-list li:first-child {
  border-top: 0;
}

.snapshot-list span {
  color: #627b8a;
}

.snapshot-list strong {
  color: #2f3d4a;
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 0.9rem;
}

.folder-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 0.85rem;
}

.folder-card h3 {
  color: #455a64;
  margin-bottom: 0.3rem;
}

.folder-path {
  margin: 0 0 0.65rem;
  color: #6f8795;
  font-size: 0.82rem;
  word-break: break-all;
}

.upload-form {
  display: grid;
  gap: 0.55rem;
}

.drop-zone {
  border: 1px dashed #90a4ae;
  border-radius: 6px;
  background: #fff;
  padding: 0.75rem;
  text-align: center;
  cursor: pointer;
}

.drop-zone.dragover {
  background: #eaf4ff;
  border-color: var(--brand);
}

.drop-zone.has-files {
  border-color: #1565c0;
  background: #f3f9ff;
}

.drop-zone.has-files span {
  color: #0d47a1;
  font-weight: 700;
}

.drop-zone input[type="file"] {
  display: none;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.thumb-grid-toggle {
  margin-top: 0.55rem;
  border: 1px solid #c1d3df;
  background: #f3f9ff;
  color: #2b5d8e;
  font-weight: 700;
  border-radius: 4px;
  padding: 0.34rem 0.58rem;
}

.thumb {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  padding: 0.3rem;
}

.thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 3px;
}

.thumb figcaption {
  margin: 0.3rem 0;
  font-size: 0.74rem;
  color: #607d8b;
  line-height: 1.2;
  word-break: break-all;
}

.delete-btn {
  width: 100%;
  border-color: #c62828;
  background: linear-gradient(145deg, #ef5350, #d32f2f);
}

.empty {
  grid-column: 1 / -1;
  color: #78909c;
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}

.admin-table {
  width: 100%;
  min-width: 740px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  border: 1px solid var(--line);
  padding: 0.48rem 0.55rem;
  text-align: left;
}

.admin-table thead th {
  background: #f4f8fa;
  color: #546e7a;
}

.notice {
  border: 1px solid #c8dce8;
  background: #f4fbff;
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.85rem;
  font-weight: 700;
}

.notice--success {
  border-color: #9ed7c1;
  background: #edf9f3;
  color: #1f7a53;
}

.notice--error {
  border-color: #f3b8b7;
  background: #fff0ef;
  color: #b84745;
}

.inventory-sections {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.9rem;
}

.inventory-toolbar {
  margin-top: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.inventory-toolbar .action-btn {
  border: 1px solid #c7d7e2;
  border-radius: 4px;
  background: #f4f9fd;
  color: #446273;
  font-weight: 700;
  padding: 0.55rem 0.62rem;
  cursor: pointer;
}

.inventory-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #4b6070;
  font-weight: 700;
  font-size: 0.82rem;
}

.inventory-filter select {
  border: 1px solid #c7d7e2;
  border-radius: 4px;
  background: #f4f9fd;
  color: #446273;
  font-weight: 700;
  padding: 0.46rem 0.52rem;
}

.inventory-section {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.inventory-section__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.62rem 0.72rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.inventory-section__head h3 {
  color: #4b5f6b;
  font-size: 1.24rem;
}

.inventory-section__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 28px;
  padding: 0 0.45rem;
  border-radius: 14px;
  background: #edf2f7;
  color: #4e6674;
  font-weight: 700;
}

.inventory-section__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.inventory-section__chevron {
  color: #4e6674;
  font-size: 0.85rem;
  transition: transform 0.18s ease;
}

.inventory-section.is-collapsed .inventory-section__chevron {
  transform: rotate(-90deg);
}

.inventory-section__body[hidden] {
  display: none;
}

.inventory-section--active .inventory-section__head { background: #ecfbff; }
.inventory-section--pending .inventory-section__head { background: #fff8ea; }
.inventory-section--reserved .inventory-section__head { background: #f3f3ff; }
.inventory-section--shipped .inventory-section__head { background: #f2f8ff; }
.inventory-section--sold .inventory-section__head { background: #edf8ef; }
.inventory-section--archived .inventory-section__head { background: #f7f7f7; }
.inventory-section--draft .inventory-section__head { background: #f9fbfd; }

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-pill--active { background: #d4f7ff; color: #006a7a; }
.status-pill--pending { background: #fff2d6; color: #9a5d00; }
.status-pill--reserved { background: #e3e0ff; color: #4636aa; }
.status-pill--shipped { background: #dcecff; color: #1c4f94; }
.status-pill--sold { background: #daf5e1; color: #1f7a53; }
.status-pill--archived { background: #eceff2; color: #5e6b74; }
.status-pill--draft { background: #edf3f7; color: #607b8a; }

.inventory-list-thumb {
  display: block;
  width: 34px;
  height: 34px;
  max-width: 34px;
  max-height: 34px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #d3e0e9;
  background: #f8fbfd;
  margin: 0 auto;
}

.inventory-list-thumb--empty {
  width: 34px;
  height: 34px;
  line-height: 32px;
  text-align: center;
  color: #8aa0ad;
  font-weight: 700;
  margin: 0 auto;
}

.inventory-thumb-cell {
  width: 52px;
  min-width: 52px;
  text-align: center;
  vertical-align: middle;
}

.edit-item-btn {
  padding: 0.38rem 0.62rem;
}

.edit-item-btn--inline {
  display: none;
}

.inventory-title-cell {
  display: block;
}

.inventory-title-text {
  display: inline;
}

.edit-item-row td {
  background: #f9fcff;
}

.edit-item-form {
  display: grid;
  gap: 0.72rem;
}

.edit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.edit-grid label {
  display: grid;
  gap: 0.26rem;
  font-size: 0.8rem;
  color: #5f7684;
  font-weight: 700;
}

.inventory-checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 0.45rem;
  padding-top: 1.35rem;
  color: #2d4a5f;
}

.inventory-checkbox-label input[type="checkbox"] {
  appearance: auto;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #1b73ca;
  cursor: pointer;
}

.edit-grid input:not([type="checkbox"]),
.edit-grid select,
.edit-grid textarea {
  border: 1px solid #cdd8df;
  border-radius: 4px;
  padding: 0.45rem 0.52rem;
  color: #344b59;
  background: #fff;
}

.edit-grid__full {
  grid-column: 1 / -1;
}

.lookup-mode-wrap {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}

.lookup-mode-btn,
.lookup-fetch-btn {
  border: 1px solid #c7d7e2;
  border-radius: 4px;
  background: #f4f9fd;
  color: #446273;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.42rem 0.58rem;
  cursor: pointer;
}

.lookup-mode-btn.is-active {
  border-color: #1b73ca;
  background: #e1f0ff;
  color: #0f4f90;
}

.inventory-scan-wrap {
  border: 1px solid #d7e6ef;
  border-radius: 6px;
  background: #f6fbff;
  padding: 0.55rem;
}

.inventory-scan-wrap[hidden] {
  display: none !important;
}

#inventoryBarcodeScannerVideo {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #c9dbe7;
  background: #0f1720;
}

.inventory-scan-actions {
  margin-top: 0.45rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#inventoryBarcodeScannerStatus {
  color: #3b5668;
  font-size: 0.82rem;
  font-weight: 600;
}

.watermark-form {
  display: grid;
  gap: 0.62rem;
  max-width: 760px;
}

.watermark-form label {
  display: grid;
  gap: 0.28rem;
  color: #3e5a70;
  font-weight: 700;
}

.watermark-form input[type="text"],
.watermark-form input[type="number"],
.watermark-form input[type="file"] {
  border: 1px solid #cdd8df;
  border-radius: 4px;
  padding: 0.48rem 0.55rem;
  color: #344b59;
  background: #fff;
}

.watermark-form input[type="checkbox"] {
  margin-right: 0.38rem;
}

.watermark-overlay-current {
  border: 1px dashed #c6d6e3;
  background: #f7fbff;
  border-radius: 8px;
  padding: 0.55rem;
}

.watermark-overlay-current p {
  margin: 0 0 0.4rem;
  color: #4b6679;
  font-weight: 700;
}

.watermark-overlay-current img {
  max-width: min(360px, 100%);
  max-height: 180px;
  width: auto;
  height: auto;
  display: block;
  background:
    linear-gradient(45deg, #e6eef5 25%, transparent 25%) 0 0 / 20px 20px,
    linear-gradient(-45deg, #e6eef5 25%, transparent 25%) 0 10px / 20px 20px,
    linear-gradient(45deg, transparent 75%, #e6eef5 75%) 10px -10px / 20px 20px,
    linear-gradient(-45deg, transparent 75%, #e6eef5 75%) -10px 0 / 20px 20px,
    #f8fcff;
  border: 1px solid #c7d8e6;
  border-radius: 6px;
  padding: 0.3rem;
}

.edit-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.btn-delete-item {
  border-color: #b71c1c !important;
  background: linear-gradient(145deg, #ef5350, #c62828) !important;
  color: #fff !important;
}

.btn-cancel-edit {
  border-color: #9baeb9;
  background: #ecf2f6;
  color: #425762;
}

.inline-delete-confirm {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid #f4b3b3;
  background: #fff3f3;
  color: #7a1f1f;
  border-radius: 6px;
  padding: 0.35rem 0.45rem;
}

.inline-delete-confirm > span {
  font-size: 0.82rem;
  font-weight: 700;
}

.inline-delete-confirm[hidden] {
  display: none !important;
}

.item-media-manager {
  border: 1px solid #dce7ee;
  border-radius: 6px;
  background: #fff;
  padding: 0.68rem;
}

.item-media-manager h4 {
  margin: 0 0 0.5rem;
  color: #4c6573;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.item-upload-form {
  display: grid;
  gap: 0.5rem;
}

.item-thumb-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.delete-item-image-btn {
  width: 100%;
  border-color: #c62828;
  background: linear-gradient(145deg, #ef5350, #d32f2f);
}

.inline-photo-delete-confirm {
  margin-top: 0.35rem;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #f4b3b3;
  border-radius: 5px;
  background: #fff3f3;
  color: #7a1f1f;
  padding: 0.3rem 0.35rem;
}

.inline-photo-delete-confirm[hidden] {
  display: none !important;
}

.inline-photo-delete-confirm > span {
  font-size: 0.72rem;
  font-weight: 700;
}

.user-row {
  cursor: pointer;
}

.user-row:hover td {
  background: #f0f8ff;
}

.user-edit-open {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  color: #1565c0;
  font-weight: 700;
  cursor: pointer;
}

.shadowbox-modal {
  position: fixed;
  inset: 0;
  z-index: 75;
}

.shadowbox-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 24, 36, 0.72);
}

.shadowbox-modal__card {
  position: relative;
  width: min(560px, 92%);
  margin: 11vh auto 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 32px rgba(18, 35, 58, 0.28);
  padding: 1rem;
}

.shadowbox-modal__card--wide {
  width: min(980px, 96%);
  max-height: 84vh;
  overflow: auto;
}

.shadowbox-modal__card h3 {
  margin: 0 0 0.72rem;
  color: #2b4a63;
}

.user-edit-form {
  display: grid;
  gap: 0.62rem;
}

.user-edit-form label {
  display: grid;
  gap: 0.26rem;
  font-size: 0.84rem;
  font-weight: 700;
  color: #4b6679;
}

.user-edit-form input,
.user-edit-form select {
  border: 1px solid #cdd8df;
  border-radius: 4px;
  padding: 0.48rem 0.55rem;
  color: #344b59;
  background: #fff;
}

.user-edit-form textarea {
  border: 1px solid #cdd8df;
  border-radius: 4px;
  padding: 0.48rem 0.55rem;
  color: #344b59;
  background: #fff;
  min-height: 120px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 0.82rem;
}

.af411-filter-shell {
  display: grid;
  gap: 0.7rem;
}

.af411-filter-row {
  display: grid;
  gap: 0.35rem;
}

.af411-filter-row strong {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #47627a;
}

.af411-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.af411-chip {
  border: 1px solid #9bb8d0;
  background: linear-gradient(165deg, #ffffff, #ebf4fd);
  color: #24527a;
  border-radius: 999px;
  padding: 0.3rem 0.72rem;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.1;
  cursor: pointer;
  transition: opacity 180ms ease, transform 180ms ease, background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.af411-chip:hover {
  border-color: #4a89c0;
  transform: translateY(-1px);
}

.af411-chip.is-active {
  border-color: #115695;
  background: linear-gradient(165deg, #2f95f8, #1a70c4);
  color: #fff;
}

.af411-chip.is-faded {
  opacity: 0.26;
  transform: scale(0.98);
  pointer-events: none;
}

.af411-live-region {
  position: relative;
  overflow: hidden;
}

.af411-live-pane {
  width: 100%;
}

.af411-live-pane.fade-in {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  opacity: 0;
  transform: scale(0.995);
  transition: opacity 240ms ease, transform 240ms ease;
}

.af411-live-pane.fade-out {
  position: relative;
  transform: scale(1);
  opacity: 1;
  transition: opacity 200ms ease, transform 200ms ease;
}

.af411-live-pane.is-enter-active.fade-in {
  opacity: 1;
  transform: scale(1);
}

.af411-live-region.is-loading .af411-live-pane.fade-out {
  transform: scale(0.998);
  opacity: 0.12;
}

.main-pane .panel-card a {
  color: #1b5f9d;
  text-decoration: none;
  border-bottom: 1px solid rgba(27, 95, 157, 0.28);
  transition: color 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.main-pane .panel-card a:hover {
  color: #0d3c66;
  border-color: rgba(13, 60, 102, 0.55);
  background: rgba(13, 60, 102, 0.06);
}

.main-pane .panel-card a:visited {
  color: #2d5b86;
}

.main-pane .panel-card .action-btn,
.main-pane .panel-card .af411-chip {
  border-bottom: none;
}

.diagnostics-panel--validated {
  background: #edf5ef;
  border-color: #b7d3bd;
}

.shadowbox-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 0.2rem;
}

.ui-toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: 360px;
  padding: 0.72rem 0.86rem;
  border: 1px solid #a7c8eb;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 16px rgba(46, 61, 73, 0.18);
  color: #2f3d4a;
  font-weight: 700;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
}

.ui-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.ui-toast.is-error {
  border-color: #ef9a9a;
}

.ui-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
}

.ui-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 33, 43, 0.62);
}

.ui-modal__card {
  position: relative;
  width: min(500px, 92%);
  margin: 14vh auto 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 24px rgba(46, 61, 73, 0.24);
  padding: 1rem;
}

.ui-modal__title {
  margin-bottom: 0.45rem;
  font-size: 1.35rem;
  color: #455a64;
}

.ui-modal__message {
  margin-bottom: 0.9rem;
}

.ui-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
}

.ui-btn {
  border: 1px solid #2a5f9e;
  border-radius: 5px;
  background: linear-gradient(180deg, #3b8de6 0%, #2c77cf 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  line-height: 1.2;
  padding: 0.5rem 0.78rem;
  box-shadow: 0 1px 2px rgba(20, 54, 92, 0.2);
  vertical-align: middle;
}

.ui-btn--ghost {
  border-color: #90a4ae;
  background: #f4f8fa;
  color: #455a64;
}

.ui-btn--danger {
  border-color: #c62828;
  background: linear-gradient(145deg, #ef5350, #d32f2f);
}

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

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

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

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

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

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

  .sidebar {
    display: none;
  }

  .main-pane {
    padding: 0.75rem;
    padding-top: 0.7rem;
  }

  .mobile-admin-nav {
    display: flex;
  }
}

@media (max-width: 700px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.72rem 0.8rem;
  }

  .topbar__actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .topbar__actions > * {
    width: 100%;
  }

  .topbar__actions .quick-link,
  .topbar__actions .btn-logout,
  .topbar__actions .site-mode-form {
    justify-content: center;
  }

  .folder-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .page-head__title {
    font-size: 1.45rem;
  }

  .admin-content {
    margin-top: 0.72rem;
    padding: 0.72rem;
  }

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

  .inventory-section .table-wrap {
    overflow-x: visible;
  }

  .inventory-section .admin-table {
    min-width: 0;
  }

  .inventory-section .admin-table th:nth-child(2),
  .inventory-section .admin-table td:nth-child(2),
  .inventory-section .admin-table th:nth-child(4),
  .inventory-section .admin-table td:nth-child(4),
  .inventory-section .admin-table th:nth-child(5),
  .inventory-section .admin-table td:nth-child(5),
  .inventory-section .admin-table th:nth-child(6),
  .inventory-section .admin-table td:nth-child(6),
  .inventory-section .admin-table th:nth-child(7),
  .inventory-section .admin-table td:nth-child(7),
  .inventory-section .admin-table th:nth-child(8),
  .inventory-section .admin-table td:nth-child(8),
  .inventory-section .admin-table th:nth-child(9),
  .inventory-section .admin-table td:nth-child(9),
  .inventory-section .admin-table th:nth-child(10),
  .inventory-section .admin-table td:nth-child(10),
  .inventory-section .admin-table th:nth-child(11),
  .inventory-section .admin-table td:nth-child(11),
  .inventory-section .admin-table th:nth-child(12),
  .inventory-section .admin-table td:nth-child(12),
  .inventory-section .admin-table th:nth-child(13),
  .inventory-section .admin-table td:nth-child(13),
  .inventory-section .admin-table th:nth-child(14),
  .inventory-section .admin-table td:nth-child(14) {
    display: none;
  }

  .inventory-section .admin-table th:nth-child(1),
  .inventory-section .admin-table td:nth-child(1) {
    width: 54px;
    min-width: 54px;
  }

  .inventory-section .admin-table th:nth-child(3),
  .inventory-section .admin-table td:nth-child(3) {
    width: auto;
  }

  .inventory-title-cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
  }

  .inventory-title-text {
    display: block;
    font-weight: 700;
    color: #26495f;
    overflow-wrap: anywhere;
  }

  .edit-item-btn--inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
  }

  .shadowbox-modal__card {
    width: min(960px, 98vw);
    margin: 2vh auto 0;
    padding: 0.72rem;
  }

  .shadowbox-modal__card--wide {
    max-height: 92vh;
    overflow: auto;
  }

  .inventory-toolbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .inventory-toolbar .action-btn,
  .inventory-filter,
  .inventory-filter select {
    width: 100%;
  }

  .inventory-filter {
    justify-content: space-between;
  }

  .admin-content > .table-wrap {
    overflow-x: visible;
  }

  .admin-content > .table-wrap .admin-table {
    min-width: 0;
  }

  .admin-content > .table-wrap .admin-table th:nth-child(1),
  .admin-content > .table-wrap .admin-table td:nth-child(1),
  .admin-content > .table-wrap .admin-table th:nth-child(2),
  .admin-content > .table-wrap .admin-table td:nth-child(2),
  .admin-content > .table-wrap .admin-table th:nth-child(3),
  .admin-content > .table-wrap .admin-table td:nth-child(3),
  .admin-content > .table-wrap .admin-table th:nth-child(7),
  .admin-content > .table-wrap .admin-table td:nth-child(7) {
    display: none;
  }

  .admin-content > .table-wrap .admin-table th,
  .admin-content > .table-wrap .admin-table td {
    padding: 0.44rem 0.48rem;
  }

  .user-edit-open {
    display: inline-flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    font-size: 0.95rem;
  }

  .edit-grid input:not([type="checkbox"]),
  .edit-grid select,
  .edit-grid textarea,
  .lookup-mode-btn,
  .lookup-fetch-btn,
  #inventoryBarcodeScannerStatus {
    font-size: 16px;
  }

  .lookup-mode-wrap {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .lookup-mode-btn,
  .lookup-fetch-btn {
    width: 100%;
    text-align: center;
  }

  .inventory-scan-wrap {
    padding: 0.45rem;
  }

  .watermark-form input[type="text"],
  .watermark-form input[type="number"],
  .watermark-form input[type="file"],
  .user-edit-form input,
  .user-edit-form select {
    font-size: 16px;
  }

  .upload-form button,
  .item-upload-form button {
    width: 100%;
  }

  .shadowbox-modal__actions,
  .edit-actions,
  .ui-modal__actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .shadowbox-modal__actions .ui-btn,
  .edit-actions button,
  .edit-actions .btn-cancel-edit,
  .ui-modal__actions .ui-btn {
    width: 100%;
  }

  #inventoryBarcodeScannerVideo {
    max-height: 220px;
  }

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

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

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