:root {
  --bg-top: #f2efe8;
  --bg-bottom: #d7e6e8;
  --paper: rgba(255, 255, 255, 0.9);
  --paper-strong: #ffffff;
  --ink: #1d2933;
  --ink-soft: #5a6671;
  --line: #d6dde3;
  --line-strong: #bcc8d2;
  --brand: #1f5f69;
  --brand-strong: #16474f;
  --brand-soft: #e2f2f4;
  --accent: #cc6a13;
  --accent-strong: #ad560b;
  --danger: #9f2b2b;
  --success: #206b3f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 8%, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 28%),
    radial-gradient(circle at 90% 18%, rgba(224, 176, 126, 0.25) 0%, rgba(224, 176, 126, 0) 33%),
    linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
  min-height: 100vh;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(20px);
}

.bg-shape.one {
  width: 340px;
  height: 340px;
  background: rgba(40, 114, 126, 0.24);
  top: -130px;
  right: -30px;
}

.bg-shape.two {
  width: 390px;
  height: 390px;
  background: rgba(204, 106, 19, 0.2);
  bottom: -180px;
  left: -110px;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1340px;
  margin: 0 auto;
  padding: 22px 22px 120px;
}

.hero {
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 20px;
  padding: 22px;
  background:
    linear-gradient(155deg, rgba(31, 95, 105, 0.12), rgba(255, 255, 255, 0.8)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0.92));
  box-shadow: 0 18px 40px rgba(16, 24, 40, 0.1);
  backdrop-filter: blur(10px);
}

.hero h1 {
  margin: 0;
  font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif;
  font-weight: 700;
  font-size: clamp(1.65rem, 3vw, 2.15rem);
  letter-spacing: 0.01em;
}

.hero p {
  margin: 10px 0 0;
  font-size: 0.98rem;
  color: var(--ink-soft);
  max-width: 84ch;
}

.hero-meta {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-meta span {
  display: inline-flex;
  align-items: center;
  border: 1px solid #cee0e4;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  color: #31545b;
  background: #f4fafb;
}

.tally-live-status {
  gap: 7px;
}

.tally-live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #94a3b8;
  flex: 0 0 auto;
}

.tally-live-status.is-active {
  color: #166534;
  border-color: #bbf7d0;
  background: #ecfdf3;
}

.tally-live-status.is-active .tally-live-dot {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.22);
  animation: tally-live-pulse 1.8s ease-in-out infinite;
}

.tally-live-status.is-inactive {
  color: #b42318;
  border-color: #fecdca;
  background: #fef3f2;
}

.tally-live-status.is-inactive .tally-live-dot {
  background: #f04438;
  box-shadow: 0 0 0 3px rgba(240, 68, 56, 0.18);
}

.tally-live-status.is-checking {
  color: #92610a;
  border-color: #fde68a;
  background: #fffbeb;
}

.tally-live-status.is-checking .tally-live-dot {
  background: #f59e0b;
  animation: tally-live-pulse 1.2s ease-in-out infinite;
}

.tally-live-status.is-degraded {
  color: #9a6700;
  border-color: #f0d060;
  background: #fffbeb;
}

.tally-live-status.is-degraded .tally-live-dot {
  background: #d97706;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.18);
}

@keyframes tally-live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.top-workbench {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}

.left-tools,
.upload-panel,
.status-wrap,
.pane {
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 12px 28px rgba(14, 19, 26, 0.08);
  backdrop-filter: blur(6px);
}

.left-tools {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  z-index: 40;
  overflow: visible;
}

.controls {
  margin-top: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.sync-meta {
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: #4a5c69;
}

.sync-meta[data-state="changed"] {
  color: #9a3412;
}

.sync-meta[data-state="unchanged"] {
  color: #166534;
}

.sync-meta[data-state="checking"] {
  color: #0f4c81;
}

.refresh-recommended-banner {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #fcd34d;
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  color: #92400e;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.refresh-recommended-banner[hidden] {
  display: none !important;
}

.refresh-recommended-banner button {
  font-size: 12px;
  padding: 6px 12px;
}

.refresh-recommended-banner .link-btn {
  background: transparent;
  border: none;
  color: #92400e;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.filters {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  font-size: 13px;
  color: #455666;
  position: relative;
  z-index: 50;
  overflow: visible;
}

.filters label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.filters input[type="number"],
.filters input[type="text"],
.filters select,
.upload-row input[type="text"],
.upload-row input[type="file"] {
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 8px 9px;
  font-size: 13px;
  background: #ffffff;
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.filters input[type="number"]:focus,
.filters input[type="text"]:focus,
.filters select:focus,
.upload-row input[type="text"]:focus,
.upload-row input[type="file"]:focus {
  outline: none;
  border-color: #6ea8b1;
  box-shadow: 0 0 0 3px rgba(31, 95, 105, 0.15);
}

.filters .inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 2px;
  font-weight: 700;
}

.filters .inline-check input[type="checkbox"] {
  margin: 0;
  accent-color: var(--brand);
}

.apply-filters-btn {
  align-self: end;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 13px;
  background: linear-gradient(180deg, #1f7f8d, #1a6672);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(26, 102, 114, 0.22);
}

.apply-filters-btn:hover {
  filter: brightness(1.05);
}

.apply-filters-btn.pending {
  background: linear-gradient(180deg, #d97706, #b45309);
  box-shadow: 0 8px 18px rgba(180, 83, 9, 0.22);
}

.apply-filters-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

#filterCategory {
  min-width: 220px;
}

.search-field-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.search-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #c9d7df;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 45, 58, 0.14);
}

.search-suggestions button {
  display: flex;
  width: 100%;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid #edf2f6;
  background: #fff;
  color: #17343d;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.search-suggestions button:last-child {
  border-bottom: 0;
}

.search-suggestions button:hover,
.search-suggestions button:focus {
  background: #f2f8fa;
}

.search-suggestions .suggestion-meta {
  color: #5f7380;
  font-size: 11px;
  white-space: nowrap;
}

#filterLimit {
  width: 88px;
}

.upload-panel {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.upload-panel h3 {
  margin: 0;
  font-size: 17px;
  font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif;
}

.upload-panel p,
.upload-note {
  margin: 4px 0 6px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.35;
}

.storage-summary {
  margin: 0;
  padding: 11px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, #f7fbfd 0%, #edf5f8 100%);
  border: 1px solid #d4e1e8;
}

.storage-summary__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-size: 12px;
  color: #2f4251;
  margin-bottom: 8px;
}

#storageText {
  font-weight: 600;
}

.storage-meter {
  width: 100%;
  height: 10px;
  background: #d8e5ed;
  border-radius: 999px;
  overflow: hidden;
}

.storage-meter__fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #1f5f69 0%, #3f8792 100%);
  transition: width 0.25s ease;
}

.upload-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
}

.upload-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #4a5c69;
}

#uploadImagesFiles {
  min-width: 270px;
}

.edit-images-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid #c8d8df;
  background: #fff;
  color: #1f5f69;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.edit-images-link:hover {
  background: #f3fafb;
  border-color: #9ec5cf;
}

.image-library-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.image-library-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.image-library-header h1 {
  margin: 0 0 6px;
  font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif;
  font-size: 28px;
}

.image-library-header p {
  margin: 0;
  color: var(--ink-soft);
}

.image-library-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.image-library-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #4a5c69;
  min-width: 260px;
  flex: 1;
}

.image-library-toolbar input[type="search"] {
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid #c8d8df;
  font: inherit;
}

.image-library-meta {
  margin: 0 0 16px;
  color: #4a5c69;
  font-size: 13px;
}

.image-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.image-library-card {
  border: 1px solid #d4e1e8;
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.image-library-card__preview {
  aspect-ratio: 4 / 3;
  background: #f4f8fa;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-library-card__preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-library-card__body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.image-library-card__title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  word-break: break-word;
}

.image-library-card__meta {
  margin: 0;
  font-size: 12px;
  color: #64748b;
}

.image-library-card__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.image-library-card__actions button,
.image-library-card__actions label.replace-btn {
  flex: 1;
  min-width: 90px;
  min-height: 36px;
  border-radius: 10px;
  border: 1px solid #c8d8df;
  background: #fff;
  color: #1f5f69;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.image-library-card__actions label.replace-btn {
  position: relative;
  overflow: hidden;
}

.image-library-card__actions label.replace-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.image-library-card__actions button.danger {
  color: #b42318;
  border-color: #f1c0bb;
}

.image-library-empty,
.image-library-status {
  padding: 18px;
  border-radius: 12px;
  background: #f7fbfd;
  border: 1px solid #d4e1e8;
  color: #334155;
}

.image-library-status.is-error {
  background: #fff5f5;
  border-color: #f1c0bb;
  color: #b42318;
}

.image-library-load-more {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

.image-library-load-more button {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid #c8d8df;
  background: #fff;
  color: #1f5f69;
  font-weight: 600;
  cursor: pointer;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid #c8d8df;
  background: #fff;
  color: #1f5f69;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.selected-images-preview {
  margin-top: 4px;
}

.selected-file-summary {
  margin: 0 0 6px;
  font-size: 12px;
  color: #4a5c69;
  font-weight: 600;
}

.upload-progress-wrap[hidden] {
  display: none !important;
}

.upload-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.upload-progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e7eef2;
  overflow: hidden;
}

.upload-progress-bar__fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #1f5f69 0%, #3f8792 100%);
  transition: width 0.15s ease;
}

.upload-progress-text {
  font-size: 12px;
  color: #4a5c69;
  font-weight: 600;
}

.selected-file-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.selected-file-item {
  font-size: 12px;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.35;
}

.selected-file-size {
  color: #6b7280;
  font-size: 11px;
}

button,
#downloadLink {
  appearance: none;
  border: none;
  border-radius: 11px;
  padding: 10px 16px;
  font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

button {
  background: linear-gradient(180deg, #27737f, var(--brand));
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(22, 71, 79, 0.25);
}

button:hover {
  transform: translateY(-1px);
  filter: saturate(1.05);
  box-shadow: 0 10px 18px rgba(22, 71, 79, 0.3);
}

button:active {
  transform: translateY(0);
}

button:focus-visible,
#downloadLink:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(31, 95, 105, 0.22);
}

button:disabled {
  cursor: not-allowed;
  background: #95a1af;
  transform: none;
  box-shadow: none;
}

#generatePdfBtn {
  background: linear-gradient(180deg, #d97d2b, var(--accent));
  box-shadow: 0 6px 14px rgba(173, 86, 11, 0.28);
}

#generatePdfBtn:hover {
  box-shadow: 0 10px 18px rgba(173, 86, 11, 0.34);
}

#downloadLink {
  text-decoration: none;
  background: var(--brand-strong);
  color: #fff;
  display: inline-flex;
  align-items: center;
}

.hidden {
  display: none;
}

.context-hidden {
  display: none !important;
}

.status-wrap {
  margin-top: 12px;
  padding: 11px 14px;
}

.mode-dock {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(960px, calc(100vw - 24px));
  z-index: 50;
  margin-top: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 30px rgba(14, 19, 26, 0.16);
  align-items: center;
}

.mode-tab {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #ffffff;
  color: #30495a;
    flex-wrap: wrap;
  font-weight: 700;
  padding: 9px 16px;
  cursor: pointer;
  min-width: 180px;
    flex: 1 1 30%;
}

.mode-tab.active {

  .tally-source-dock {
    width: 100%;
    justify-content: flex-end;
    padding-left: 0;
    padding-top: 2px;
  }

  .tally-source-toggle {
    width: 132px;
    height: 34px;
  }
  background: linear-gradient(180deg, #1f5f69, #184c54);
  border-color: #1f5f69;
  color: #ffffff;
}

.tally-source-dock {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 6px;
}

.tally-source-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #2f3f52;
}

.tally-source-locked {
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e8f4f6;
  color: #1f5f69;
  border: 1px solid #b9dde3;
}

.tally-source-toggle {
  position: relative;
  width: 146px;
  height: 36px;
  border: 1px solid #a8bfd8;
  border-radius: 999px;
  background: #f8fbff;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tally-source-option {
  position: relative;
  z-index: 2;
  width: 50%;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: #5d6b79;
  user-select: none;
}

.tally-source-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(50% - 2px);
  height: calc(100% - 4px);
  border-radius: 999px;
  background: linear-gradient(180deg, #f6fbff, #deecff);
  border: 1px solid #9ec1e8;
  box-shadow: 0 6px 12px rgba(30, 64, 110, 0.18);
  transform: translateX(0);
  transition: transform 0.2s ease;
}

.tally-source-toggle[data-source="local"] .tally-source-knob {
  transform: translateX(100%);
}

.tally-source-toggle[data-source="cloud"] {
  border-color: #80aee2;
  background: #eef6ff;
}

.tally-source-toggle[data-source="cloud"] .tally-source-option--cloud,
.tally-source-toggle[data-source="local"] .tally-source-option--local {
  color: #1a4f80;
}

/* Hide any legacy voucher-panel switch markup if still present in stale HTML. */
.tally-source-switch-wrap,
.tally-source-switch {
  display: none !important;
}

.dock-tally-switch {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #d4deea;
  background: #ffffff;
}

.dock-tally-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #6b7280;
  user-select: none;
}

.dock-tally-track {
  width: 56px;
  height: 28px;
  padding: 2px;
  border: 1px solid #9bb5cc;
  border-radius: 999px;
  background: linear-gradient(180deg, #eef3f8, #e2ebf5);
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
}

.dock-tally-thumb {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.25);
  transform: translateX(0);
  transition: transform 0.18s ease;
}

.dock-tally-switch[data-source="local"] .dock-tally-thumb {
  transform: translateX(28px);
}

.dock-tally-switch[data-source="cloud"] .dock-tally-label-cloud,
.dock-tally-switch[data-source="local"] .dock-tally-label-local {
  color: #134e57;
}

.mode-panel {
  margin-top: 10px;
  display: none;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 12px 28px rgba(14, 19, 26, 0.08);
  backdrop-filter: blur(6px);
  padding: 14px;
  position: relative;
}

.mode-panel[hidden] {
  display: none !important;
}

.mode-panel.active {
  display: block;
}

.mode-panel h3 {
  margin: 0 0 10px;
  font-size: 17px;
  font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif;
}

.mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.mode-row label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: #455666;
}

.mode-row input[type="text"],
.mode-row input[type="month"],
.mode-row select {
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 8px 9px;
  font-size: 13px;
  background: #ffffff;
  color: var(--ink);
}

.mode-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mode-results {
  margin-top: 10px;
  border: 1px solid #d5dee8;
  border-radius: 10px;
  background: #fff;
  min-height: 44px;
  max-height: 240px;
  overflow: auto;
  padding: 8px;
  font-size: 12px;
  color: #334155;
}

.qr-results-summary {
  margin: 0 0 10px;
  font-size: 13px;
  color: #5e636b;
}

.qr-results-list {
  max-height: 420px;
  overflow: auto;
}

.qr-result-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 6px;
  border-bottom: 1px solid #edf2f7;
}

.qr-result-item:last-child {
  border-bottom: 0;
}

.qr-result-item img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border: 1px solid #d5dee8;
  border-radius: 6px;
  background: #fff;
}

#statusText {
  margin: 0;
  font-size: 14px;
  color: #21303e;
  font-weight: 600;
}

#statusText[data-tone="error"] {
  color: var(--danger);
}

#statusText[data-tone="success"] {
  color: var(--success);
}

.split-view {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
  position: relative;
  z-index: 1;
}

.pane {
  padding: 12px;
  min-height: 600px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pane h2 {
  margin: 0 0 10px;
  font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif;
  font-size: 1.08rem;
  letter-spacing: 0.01em;
}

.product-select-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.product-select-bar button {
  padding: 8px 12px;
  font-size: 12px;
}

#selectedProductsCount {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 700;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
  flex: 1;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper-strong);
  position: relative;
  display: grid;
  grid-template-rows: auto auto;
  transition: transform 0.18s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.11);
}

.card-select {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #cbd5e1;
  font-size: 11px;
  font-weight: 700;
  color: #334155;
}

.card-select input {
  margin: 0;
  accent-color: var(--brand);
}

.card img {
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  max-height: 220px;
  object-fit: contain;
  object-position: center;
  background: #f7f9fc;
  border-bottom: 1px solid var(--line);
  padding: 8px;
}

.card-image-wrap {
  position: relative;
}

.subcat-flag {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  background: linear-gradient(180deg, var(--flag-from, #f59e0b), var(--flag-to, #d97706));
  color: #ffffff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  box-shadow: 0 6px 14px var(--flag-shadow, rgba(124, 45, 18, 0.3));
  max-width: 72%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-body {
  padding: 10px;
  overflow: auto;
}

.card-body h3 {
  margin: 0 0 6px;
  font-size: 13px;
  line-height: 1.24;
}

.card-body p {
  margin: 2px 0;
  font-size: 11px;
  line-height: 1.25;
  color: #3a4755;
}

#catalogueFrame {
  width: 100%;
  min-height: 560px;
  height: 100%;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #ffffff;
}

@media (max-width: 1150px) {
  .top-workbench {
    grid-template-columns: 1fr;
  }

  .split-view {
    grid-template-columns: 1fr;
  }

  .pane {
    min-height: 520px;
  }
}

@media (max-width: 780px) {
  .bg-shape {
    display: none;
  }

  .app-shell {
    padding: 10px 10px 132px;
  }

  .mode-dock {
    width: calc(100vw - 16px);
    bottom: 8px;
    gap: 6px;
    padding: 6px;
    flex-wrap: wrap;
  }

  .mode-tab {
    min-width: 0;
    flex: 1 1 31%;
    font-size: 13px;
    padding: 9px 10px;
  }

  .dock-tally-switch {
    width: 100%;
    justify-content: center;
    margin-left: 0;
  }

  .hero {
    padding: 14px;
    border-radius: 14px;
  }

  .hero p {
    font-size: 0.92rem;
  }

  .controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .controls button {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
  }

  .controls button:nth-child(3) {
    grid-column: 1 / -1;
  }

  .filters {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: stretch;
  }

  .filters label {
    width: 100%;
    justify-content: flex-start;
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .filters .inline-check {
    flex-direction: row;
    align-items: center;
    margin-left: 0;
    gap: 8px;
  }

  .filters input[type="number"],
  .filters input[type="text"],
  .filters select {
    width: 100%;
    min-width: 0;
  }

  #filterCategory,
  .filters select,
  .filters input[type="number"] {
    width: 100%;
  }

  .upload-row {
    align-items: stretch;
  }

  .upload-row label,
  #uploadImagesFiles,
  #uploadBulkImagesBtn {
    width: 100%;
  }

  .storage-summary__row {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .split-view {
    margin-top: 12px;
    gap: 10px;
  }

  .pane {
    min-height: auto;
    padding: 10px;
  }

  .product-select-bar {
    gap: 6px;
  }

  .product-select-bar button {
    flex: 1;
    min-height: 42px;
  }

  #selectedProductsCount {
    width: 100%;
    text-align: left;
    margin-top: 2px;
  }

  .products-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .card img {
    max-height: 200px;
    padding: 6px;
  }

  .subcat-flag {
    font-size: 10px;
    padding: 3px 8px;
    max-width: 66%;
  }

  #catalogueFrame {
    min-height: 62vh;
    height: 62vh;
    border-radius: 10px;
  }
}

@media (max-width: 520px) {
  .hero h1 {
    font-size: 1.45rem;
  }

  .hero-meta {
    gap: 8px;
  }

  .hero-meta span {
    width: 100%;
    justify-content: center;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .controls button,
  .product-select-bar button {
    width: 100%;
  }

  .product-select-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .card-body {
    padding: 8px;
  }

  .card-body h3 {
    font-size: 12px;
  }

  .card-body p {
    font-size: 11px;
  }

  .storage-summary__row {
    align-items: flex-start;
    flex-direction: column;
  }
}

.inline-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid rgba(15, 118, 110, 0.25);
  border-top-color: #0f766e;
  border-radius: 50%;
  animation: inline-spin 0.7s linear infinite;
}

@keyframes inline-spin {
  to {
    transform: rotate(360deg);
  }
}

button.is-busy {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

button.is-busy::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: inline-spin 0.7s linear infinite;
}
