/* =========================================================================
   1) GLOBAL RESET & BASE BODY STYLING
   ========================================================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Georgia, serif;
  background-image: url('background.jpg');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  background-attachment: fixed;
  color: #EEE;                    /* Lightened global text color */
  line-height: 1.4;
  min-height: 100vh;
}

/* Utility to hide elements */
.hidden {
  display: none !important;
}

/* =========================================================================
   2) OVERLAYS (LOGIN, UPLOAD, BULK, EDIT, DASHBOARD)
   ========================================================================= */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5); /* Semi‐transparent black */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.overlay-content-small {
  background: rgba(255, 255, 255, 0.95);
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 450px;
  max-height: 85vh;      /* Limit height so you can always scroll if needed */
  overflow-y: auto;      /* Allow scrolling inside overlay */
  position: relative;
}

.overlay-content-small h2 {
  margin-bottom: 10px;
  color: #444;           /* Slightly darker heading for contrast */
  text-align: center;
}

.overlay-content-small input[type="text"],
.overlay-content-small input[type="email"],
.overlay-content-small input[type="password"],
.overlay-content-small input[type="number"],
.overlay-content-small select,
.overlay-content-small textarea,
.overlay-content-small button {
  width: 100%;
  margin: 8px 0;
  padding: 8px;
  border: 1px solid #aaa;
  border-radius: 4px;
  font-family: Georgia, serif;
  font-size: 1rem;
  color: #444;           /* Darker text inside forms for readability */
}

.overlay-content-small input[type="file"] {
  cursor: pointer;
}

.overlay-content-small label {
  display: block;
  font-size: 0.95rem;
  margin: 6px 0;
  color: #444;
}

.overlay-content-small button {
  background: rgba(244, 225, 161, 0.95);  /* Parchment tone */
  border: 2px solid rgba(217, 196, 138, 0.95);
  cursor: pointer;
  font-size: 1rem;
}

.overlay-content-small button:hover {
  background: rgba(200, 200, 200, 0.9);
}

.overlay-content-small .form-buttons {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
}

/* =========================================================================
   3) HEADER & SIGN OUT BUTTON
   ========================================================================= */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.3);
  padding: 12px 20px;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.7);
}

header h1 {
  font-size: 1.8rem;
  color: #FFF;
}

#signOutButton {
  background: rgba(224, 122, 95, 0.9);
  border: 2px solid rgba(212, 80, 63, 0.9);
  color: #FFF;
  padding: 8px 14px;
  border-radius: 5px;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 0.95rem;
}

/* =========================================================================
   4) ASSISTANT NAV BUTTONS & SELECT (FLEX WRAP)
   ========================================================================= */
nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 0;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.7);
}

nav button,
nav select {
  background: rgba(244, 225, 161, 0.95);
  border: 2px solid rgba(217, 196, 138, 0.95);
  color: #444;           /* Darker for readability */
  padding: 6px 10px;
  margin: 4px 6px;
  border-radius: 5px;
  font-family: Georgia, serif;
  font-size: 1rem;
  cursor: pointer;
}

nav button:hover,
nav select:hover {
  background: rgba(200, 200, 200, 0.9);
}

#shoeboxSelect {
  min-width: 180px;      /* Slightly wider so text never cuts off */
  padding-right: 10px;
}

/* =========================================================================
   5) DASHBOARD MODAL (Analytics)
   ========================================================================= */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none !important;
}

.modal-content {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  padding: 20px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-content h2 {
  color: #444;          /* Slightly darker */
  margin-bottom: 12px;
}

.close {
  font-size: 28px;
  cursor: pointer;
  position: absolute;
  top: 12px;
  right: 20px;
  color: #555;          /* Lightened from #333 */
}

/* Dashboard summary (counts) */
.summary {
  font-size: 1rem;
  margin-bottom: 12px;
  color: #222;
  text-align: center;
}

/* Chart Containers */
.chart-container {
  background: rgba(244, 225, 161, 0.9);
  border-radius: 8px;
  padding: 12px;
  margin: 20px auto;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
}

.chart-container h3 {
  color: #000;           /* Pure black for maximum contrast */
  margin-bottom: 8px;
}

.chart-container.small {
  max-width: 600px;
}

/* =========================================================================
   6) SHOEBOX VIEW PAGE (Dedicated Page)
   ========================================================================= */
#shoeboxPage {
  padding: 20px 10px;
  display: block;
}

#shoeboxViewHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

#backToAssistantButton {
  background: rgba(244, 225, 161, 0.95);
  border: 2px solid rgba(217, 196, 138, 0.95);
  color: #444;
  padding: 6px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
}

#currentShoeboxHeader {
  font-size: 1.6rem;
  color: #EEE;           /* Lightened */
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.7);
}

#deleteCurrentShoeboxButton {
  background: rgba(224, 122, 95, 0.9);
  border: 2px solid rgba(212, 80, 63, 0.9);
  color: #FFF;
  padding: 6px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
}

/* Filter Bar */
#filterBar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 0;
  margin-bottom: 12px;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.7);
}

#filterBar input[type="text"] {
  width: 180px;
  padding: 6px;
  margin: 4px;
  border: 1px solid #aaa;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: Georgia, serif;
  color: #444;          /* Darker for readability */
}

#filterBar select {
  padding: 6px;
  margin: 4px 8px;
  border: 1px solid #aaa;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: Georgia, serif;
  color: #444;
}

#viewModeSelect {
  min-width: 138px;
}

/* Card Grid */
#shoeboxList {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 168px));
  justify-content: center;
  align-items: start;
  gap: 10px;
  margin: 0 auto 18px;
  padding: 4px 2px 18px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 0;
  background:
    linear-gradient(180deg, rgba(255, 250, 235, 0.985) 0%, rgba(246, 236, 208, 0.975) 100%);
  border: 2px solid rgba(72, 52, 34, 0.9);
  border-radius: 12px;
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.18),
    inset 0 0 0 2px rgba(201, 163, 92, 0.48);
  padding: 8px 8px 10px;
  text-align: center;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(201, 163, 92, 0.38);
  border-radius: 8px;
  pointer-events: none;
}

.card img {
  position: relative;
  width: 100%;
  max-height: 160px;
  aspect-ratio: 5 / 6.25;
  object-fit: cover;
  object-position: center;
  border-radius: 9px;
  border: 2px solid rgba(91, 67, 43, 0.72);
  background: rgba(236, 230, 214, 0.95);
  box-shadow:
    inset 0 0 0 2px rgba(255, 244, 214, 0.48),
    0 2px 6px rgba(0, 0, 0, 0.14);
  margin-bottom: 6px;
}

.card h3 {
  font-size: 0.88rem;
  line-height: 1.12;
  margin: 0 0 3px;
  color: #2f2418;
  font-weight: 700;
  min-height: 1.7em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card p {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.12;
  color: #4c3b28;
}

.card p:nth-of-type(1) {
  font-size: 0.74rem;
  color: #5b4731;
  min-height: 1.1em;
}

.card p:nth-of-type(2) {
  font-size: 0.71rem;
  color: #7a6245;
  min-height: 1.1em;
}

.card .card-meta-primary {
  font-size: 0.74rem;
  color: #5b4731;
  min-height: 1.1em;
}

.card .card-meta-secondary {
  font-size: 0.71rem;
  color: #7a6245;
  min-height: 1.1em;
}

.card-view-compact .card-badge-row {
  margin-top: 3px;
}

.card-view-compact .tag-summary {
  padding: 2px 7px;
}

.card-view-detailed .card-badge-row {
  margin-top: 4px;
}

.card-value {
  margin-top: 3px !important;
  font-size: 0.79rem !important;
  color: #2f2418 !important;
  font-style: normal;
  font-weight: 700;
}

.card-notes {
  margin-top: 3px !important;
  font-size: 0.68rem !important;
  color: #6d5841 !important;
  font-style: italic;
  min-height: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-notes:empty {
  display: none;
}

.card-badge-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin-top: 4px;
}

.card .tag-summary {
  display: inline-flex !important;
  flex: 0 0 auto;
  width: auto !important;
  align-items: center;
  justify-content: center;
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  margin: 0;
  border-radius: 999px;
  color: #3a2d1e;
  background: #eee4c8;
  border: 1px solid rgba(91, 67, 43, 0.22);
  min-height: 18px;
  line-height: 1;
  white-space: nowrap;
  cursor: default;
}

.card .tag-summary.tag-review {
  background: linear-gradient(180deg, rgba(244, 232, 191, 0.98) 0%, rgba(232, 214, 154, 0.98) 100%);
  color: #6a5328;
  border-color: rgba(150, 123, 60, 0.34);
}

.card .tag-summary.tag-auto {
  background: linear-gradient(180deg, rgba(234, 210, 198, 0.98) 0%, rgba(223, 190, 176, 0.98) 100%);
  color: #6a3424;
  border-color: rgba(141, 84, 63, 0.30);
}

.card .tag-summary.tag-patch {
  background: linear-gradient(180deg, rgba(219, 231, 242, 0.98) 0%, rgba(199, 218, 236, 0.98) 100%);
  color: #2f4f74;
  border-color: rgba(84, 116, 148, 0.28);
}

.card .tag-summary.tag-refractor {
  background: linear-gradient(180deg, rgba(216, 238, 232, 0.98) 0%, rgba(194, 226, 217, 0.98) 100%);
  color: #246151;
  border-color: rgba(77, 137, 120, 0.28);
}

.card .tag-summary.tag-rookie {
  background: linear-gradient(180deg, rgba(232, 225, 199, 0.98) 0%, rgba(220, 210, 177, 0.98) 100%);
  color: #695423;
  border-color: rgba(141, 118, 67, 0.28);
}

.card button.editButton {
  margin-top: 4px;
  align-self: center;
  min-width: 84px;
  background: linear-gradient(180deg, rgba(244, 225, 161, 0.98) 0%, rgba(220, 192, 120, 0.98) 100%);
  border: 2px solid rgba(124, 92, 43, 0.95);
  color: #3a2d1e;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.card button.editButton:hover {
  background: linear-gradient(180deg, rgba(250, 233, 176, 0.98) 0%, rgba(228, 199, 126, 0.98) 100%);
}

@media (max-width: 900px) {
  #shoeboxList {
    grid-template-columns: repeat(auto-fill, minmax(154px, 154px));
    gap: 9px;
  }

  .card {
    min-height: 0;
  }
}

@media (max-width: 600px) {
  #shoeboxList {
    grid-template-columns: repeat(auto-fill, minmax(138px, 138px));
    gap: 8px;
  }

  .card {
    min-height: 0;
    padding: 7px 7px 9px;
  }

  .card img {
    max-height: 128px;
  }

  .card h3 {
    font-size: 0.82rem;
  }

  .card p {
    font-size: 0.71rem;
  }

  .card button.editButton {
    min-width: 74px;
    font-size: 0.78rem;
    padding: 5px 9px;
  }
}

/* =========================================================================
   7) EDIT MODAL CONTENT
   ========================================================================= */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none !important;
}

.modal-content {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  padding: 20px;
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

.modal-content h2 {
  margin-bottom: 12px;
  color: #444;
}

.modal-content label {
  display: block;
  margin: 8px 0;
  font-size: 0.95rem;
  color: #444;
}

.modal-content input[type="text"],
.modal-content input[type="number"],
.modal-content select,
.modal-content textarea,
.modal-content input[type="file"] {
  width: 100%;
  padding: 8px;
  margin: 6px 0;
  border: 1px solid #aaa;
  border-radius: 4px;
  font-size: 1rem;
  font-family: Georgia, serif;
  color: #444;
  cursor: pointer;
}

.modal-content .thumb {
  width: 100%;
  border-radius: 4px;
  margin: 8px 0;
}

.modal-content .close {
  font-size: 28px;
  cursor: pointer;
  position: absolute;
  top: 12px;
  right: 20px;
  color: #555;
}

.modal-content .modal-buttons {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
}

/* =========================================================================
   8) SAVE BUTTON (green) & DELETE BUTTON (red + trash icon)
   ========================================================================= */
.saveButton {
  background: #4CAF50;           /* Green */
  border: 2px solid #388E3C;
  color: #FFF;
  padding: 6px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
}

.saveButton:hover {
  background: #45A049;
}

/* De-emphasized Delete Card button (smaller but includes trash icon) */
#deleteCardButton {
  background: rgba(224, 122, 95, 0.8); /* Slightly dimmer red */
  border: 2px solid rgba(212, 80, 63, 0.8);
  color: #FFF;
  padding: 4px 8px;      /* Smaller padding */
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.8rem;     /* Smaller font-size */
}

#deleteCardButton:hover {
  background: rgba(200, 80, 50, 0.8);
}

#editProgressContainer,
#uploadProgressContainer,
#bulkProgressContainer {
  margin-top: 12px;
  text-align: center;
}

#editProgress,
#uploadProgress {
  width: 100%;
}

/* =========================================================================
   9) FOOTER (Emulator Warning)
   ========================================================================= */
footer {
  text-align: center;
  padding: 10px;
  background: rgba(0, 0, 0, 0.3);
}

.emulatorWarning {
  font-size: 0.9rem;
  color: #EEE;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.7);
}

/* =========================================================================
   Glasses Bridge helper styles
   ========================================================================= */
.modalCard.wide { max-width: 820px; }
.muted { opacity: 0.85; font-size: 0.95rem; margin-top: 6px; }
.modalList { margin: 12px 0 14px 18px; line-height: 1.45; }
.modalRow { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; flex-wrap: wrap; }
.codeBox {
  width: 100%;
  min-height: 130px;
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.25);
  background: rgba(255,255,255,0.92);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
}

/* =========================================================================
   10) COLLECTOR IMAGE MATTE + CROP MODAL
   ========================================================================= */
.card img {
  padding: 6px;
  background:
    linear-gradient(180deg, rgba(248, 243, 229, 0.98) 0%, rgba(230, 220, 193, 0.98) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 249, 234, 0.95),
    inset 0 0 0 7px rgba(240, 232, 212, 0.95),
    inset 0 0 14px rgba(70, 48, 28, 0.13),
    0 2px 6px rgba(0, 0, 0, 0.14);
}

.card img::after {
  content: "";
}

.crop-modal-content {
  max-width: 620px;
}

.crop-help-text {
  font-size: 0.92rem;
  color: #5a4631;
  text-align: center;
  margin-bottom: 10px;
}

.crop-canvas-shell {
  width: 100%;
  max-width: 420px;
  margin: 0 auto 14px;
  padding: 10px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(248, 243, 229, 0.98) 0%, rgba(230, 220, 193, 0.98) 100%);
  border: 2px solid rgba(84, 61, 38, 0.88);
  box-shadow:
    inset 0 0 0 2px rgba(203, 169, 99, 0.45),
    0 6px 16px rgba(0, 0, 0, 0.18);
}

#cropCanvas {
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 7;
  display: block;
  border-radius: 10px;
  border: 2px solid rgba(88, 63, 40, 0.85);
  background: rgba(36, 28, 20, 0.95);
}

.crop-controls {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.crop-controls label {
  color: #4a3826;
  font-size: 0.92rem;
  font-weight: 700;
}

.crop-controls input[type="range"] {
  width: 100%;
  margin-top: 4px;
}

.crop-preview-note {
  margin-top: 10px;
  font-size: 0.88rem;
  color: #5d4830;
  text-align: center;
}

@media (max-width: 600px) {
  .crop-canvas-shell {
    max-width: 330px;
    padding: 8px;
  }
}

/* --- local-crop-ui-polish: crop usability overrides --- */
#cropModal .crop-modal-content {
  width: min(92vw, 960px) !important;
  max-width: 960px !important;
  max-height: 92vh !important;
}

#cropModal .crop-canvas-shell {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

#cropCanvas {
  width: 100%;
  max-width: 720px;
  height: auto;
  max-height: 62vh;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.upload-status-panel {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 247, 226, 0.98) 0%, rgba(239, 227, 191, 0.98) 100%);
  border: 2px solid rgba(118, 88, 52, 0.88);
  box-shadow:
    inset 0 0 0 1px rgba(255, 252, 242, 0.95),
    0 4px 12px rgba(0, 0, 0, 0.12);
}

.upload-status-sticky {
  position: sticky;
  top: 0;
  z-index: 5;
}

#uploadStatusTitle,
#editStatusTitle {
  font-size: 0.95rem;
  font-weight: 700;
  color: #4a3724;
  margin-bottom: 8px;
  text-align: center;
}

#uploadProgressContainer progress,
#editProgressContainer progress {
  width: 100%;
  height: 16px;
  display: block;
}

#uploadPercentText,
#editPercentText {
  margin-top: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #4e3b29;
  text-align: center;
}

.edit-status-top {
  margin-bottom: 14px;
}

.overlay-content-small {
  max-height: 78vh;
  padding: 16px;
}

.modal-content {
  max-width: 470px;
  max-height: 78vh;
}

.modal-content .thumb {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border-radius: 4px;
  margin: 8px 0;
}

.overlay-content-small form,
.modal-content form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.overlay-content-small label,
.modal-content label {
  margin: 4px 0;
}

.modal-buttons,
.form-buttons {
  position: sticky;
  bottom: 0;
  background: rgba(255, 255, 255, 0.96);
  padding-top: 8px;
}

/* =========================================================================
   12) DISPLAY MODES: portrait / horizontal / memorabilia
   ========================================================================= */
.card.card-mode-horizontal {
  min-height: 0;
}

.card.card-mode-horizontal .card-image {
  aspect-ratio: 7 / 5;
  max-height: 136px;
  object-fit: contain;
  object-position: center;
  padding: 8px;
  background:
    linear-gradient(180deg, rgba(248, 243, 229, 0.98) 0%, rgba(230, 220, 193, 0.98) 100%);
}

.card.card-mode-horizontal h3 {
  min-height: auto;
  margin-top: 1px;
}

.card.card-mode-horizontal .card-notes {
  min-height: 0;
}

.card.card-mode-memorabilia {
  min-height: 0;
}

.card.card-mode-memorabilia .card-image {
  aspect-ratio: auto;
  height: 172px;
  object-fit: contain;
  object-position: center;
  padding: 8px;
  background:
    linear-gradient(180deg, rgba(248, 243, 229, 0.98) 0%, rgba(230, 220, 193, 0.98) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 249, 234, 0.95),
    inset 0 0 0 7px rgba(240, 232, 212, 0.95),
    inset 0 0 14px rgba(70, 48, 28, 0.1),
    0 2px 6px rgba(0, 0, 0, 0.12);
}

.card.card-mode-memorabilia h3 {
  min-height: auto;
}

.card.card-mode-memorabilia .card-notes {
  min-height: 0;
}

#cardOrientationWrap {
  display: block;
}

#cardOrientationWrap.hidden {
  display: none !important;
}

/* =========================================================================
   14) OCR ASSIST UI
   ========================================================================= */
.ocr-action-row {
  margin: 6px 0 8px;
}

#readCardFromImageButton {
  width: 100%;
  background: linear-gradient(180deg, rgba(233, 216, 168, 0.98) 0%, rgba(212, 190, 129, 0.98) 100%);
  border: 2px solid rgba(124, 92, 43, 0.95);
  color: #3a2d1e;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 700;
}

#readCardFromImageButton:hover {
  filter: brightness(1.03);
}

.ocr-results-box {
  margin: 8px 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 249, 236, 0.98) 0%, rgba(244, 235, 207, 0.98) 100%);
  border: 2px solid rgba(118, 88, 52, 0.72);
  color: #4a3724;
}

#ocrResultsTitle {
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 6px;
}

#ocrResultsText {
  font-size: 0.88rem;
  line-height: 1.35;
  white-space: pre-wrap;
}

/* --- sleek-crop-modal-tightening-2026-04-03 --- */
#cropModal .crop-modal-content {
  width: min(90vw, 760px) !important;
  max-width: 760px !important;
  max-height: 86vh !important;
  padding: 12px 16px 14px !important;
  border-radius: 18px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

#cropModal h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  line-height: 1.1;
}

#cropModal .crop-help-text {
  margin: 0 0 8px;
  font-size: 0.84rem;
  line-height: 1.25;
  color: #5a4631;
}

#cropModal .crop-canvas-shell {
  max-width: 500px !important;
  margin: 0 auto 10px !important;
  padding: 8px !important;
  border-radius: 12px;
}

#cropModal #cropCanvas {
  width: 100%;
  max-width: 500px !important;
  height: auto;
  max-height: 46vh !important;
  display: block;
  margin: 0 auto;
}

#cropModal .crop-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 12px;
  margin-top: 4px;
  align-items: end;
}

#cropModal .crop-controls label {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: #4a3826;
}

#cropModal .crop-controls input[type="range"] {
  width: 100%;
  margin-top: 2px;
}

#cropModal .crop-preview-note {
  margin-top: 8px;
  font-size: 0.82rem;
  line-height: 1.25;
}

#cropModal .form-buttons {
  position: static !important;
  display: flex;
  gap: 10px;
  margin-top: 10px;
  padding-top: 0 !important;
  background: transparent !important;
}

#cropModal .form-buttons button {
  width: auto !important;
  flex: 1 1 0;
  margin: 0 !important;
  padding: 9px 12px;
  font-size: 0.95rem;
}

@media (max-width: 760px) {
  #cropModal .crop-modal-content {
    width: min(94vw, 560px) !important;
    max-height: 88vh !important;
    padding: 12px !important;
  }

  #cropModal .crop-canvas-shell {
    max-width: 360px !important;
  }

  #cropModal #cropCanvas {
    max-width: 360px !important;
    max-height: 42vh !important;
  }

  #cropModal .crop-controls {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  #cropModal .form-buttons {
    flex-direction: column;
  }
}

/* --- upload-workspace-refresh-v2 --- */
#uploadOverlay.overlay {
  overflow-y: auto;
  overflow-x: hidden;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 14px;
  overscroll-behavior: contain;
}

#uploadOverlay .overlay-content-small {
  width: min(96vw, 980px) !important;
  max-width: 980px !important;
  max-height: none !important;
  margin: 0 auto 28px !important;
  padding: 0 !important;
  overflow: hidden !important;
  border-radius: 22px;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.28);
  background: linear-gradient(180deg, rgba(255, 251, 240, 0.985) 0%, rgba(248, 241, 222, 0.985) 100%);
  border: 1px solid rgba(118, 88, 52, 0.24);
}

#uploadOverlay .dialog-header {
  padding: 18px 22px 12px !important;
  background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(252,247,235,0.98) 100%) !important;
  border-bottom: 1px solid rgba(118, 88, 52, 0.14) !important;
}

#uploadOverlay .dialog-header h2 {
  margin: 0 0 10px !important;
  text-align: left !important;
  color: #342519;
}

#uploadOverlay .dialog-body {
  padding: 16px 22px 12px !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
}

#uploadOverlay .dialog-footer {
  padding: 12px 22px 18px !important;
  background: rgba(255,255,255,0.96) !important;
  border-top: 1px solid rgba(118, 88, 52, 0.12) !important;
}

#uploadForm {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.workspace-section {
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(118, 88, 52, 0.18);
  border-radius: 16px;
  padding: 14px 14px 12px;
  box-shadow: 0 3px 10px rgba(70, 48, 24, 0.05);
}

.workspace-section-intake {
  background: linear-gradient(180deg, rgba(255,250,239,0.96) 0%, rgba(246,236,206,0.9) 100%);
  border-color: rgba(118, 88, 52, 0.24);
}

.workspace-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b5238;
  margin-bottom: 10px;
}

.workspace-grid {
  display: grid;
  gap: 10px 12px;
}

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

.workspace-field {
  display: flex !important;
  flex-direction: column;
  gap: 4px;
  margin: 0 !important;
}

.workspace-field-span-2 {
  grid-column: 1 / -1;
}

.workspace-image-picker {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.82);
  border: 1px dashed rgba(118, 88, 52, 0.42);
}

.field-help-text {
  font-size: 0.82rem;
  line-height: 1.35;
  color: #6a5742;
  margin-top: 2px;
}

#uploadOverlay input[type="text"],
#uploadOverlay input[type="number"],
#uploadOverlay input[type="file"],
#uploadOverlay select,
#uploadOverlay textarea {
  width: 100%;
  margin: 0 !important;
  border-radius: 10px;
  border: 1px solid rgba(118, 88, 52, 0.26);
  background: rgba(255,255,255,0.92);
  padding: 10px 11px;
}

#uploadOverlay #cardImage,
#editModal #editCardImage {
  padding: 10px;
  border-style: dashed;
}

.workspace-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.workspace-chip-row label,
.workspace-toggle-field {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  margin: 0 !important;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(244, 225, 161, 0.36);
  border: 1px solid rgba(118, 88, 52, 0.2);
  font-size: 0.92rem;
}

#uploadOverlay .ocr-action-row {
  margin: 0 !important;
}

#uploadOverlay #readCardFromImageButton {
  width: auto !important;
  min-width: 180px;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
}

#uploadOverlay .ocr-results-box {
  margin: 0 !important;
  border-radius: 14px;
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(118, 88, 52, 0.18);
}

#uploadOverlay .form-buttons {
  display: flex;
  gap: 10px;
  margin-top: 0 !important;
}

#uploadOverlay .form-buttons button {
  flex: 1 1 0;
  margin: 0 !important;
  border-radius: 12px;
  padding: 11px 14px;
}

#uploadOverlay .progress-panel {
  margin: 0 0 10px 0 !important;
}

/* Edit workspace polish */
#editModal .modal-content {
  width: min(94vw, 980px);
  max-width: 980px;
  max-height: 88vh;
  border-radius: 22px;
  padding: 18px 20px 18px;
  background: linear-gradient(180deg, rgba(255,251,240,0.985) 0%, rgba(248,241,222,0.985) 100%);
  border: 1px solid rgba(118, 88, 52, 0.24);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.28);
}

#editModal h2 {
  margin-bottom: 10px;
}

#editForm {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#editForm .workspace-grid {
  gap: 10px 12px;
}

#editForm input[type="text"],
#editForm input[type="number"],
#editForm input[type="file"],
#editForm select,
#editForm textarea {
  width: 100%;
  margin: 0 !important;
  border-radius: 10px;
  border: 1px solid rgba(118, 88, 52, 0.26);
  background: rgba(255,255,255,0.92);
  padding: 10px 11px;
}

.thumb-panel {
  background: rgba(255,255,255,0.72);
  border: 1px dashed rgba(118, 88, 52, 0.28);
  border-radius: 14px;
  padding: 12px;
}

#editImageThumb.thumb {
  margin: 0 auto;
  max-height: 220px;
  object-fit: contain;
}

#editForm .modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 0 !important;
}

#editForm .modal-buttons button {
  flex: 1 1 0;
  margin: 0 !important;
  border-radius: 12px;
  padding: 11px 14px;
}

#editForm #deleteCardButton {
  font-size: 0.95rem;
}

@media (max-width: 760px) {
  #uploadOverlay.overlay {
    padding: 14px 8px;
  }

  #uploadOverlay .overlay-content-small {
    width: 100% !important;
    border-radius: 18px;
  }

  #uploadOverlay .dialog-header,
  #uploadOverlay .dialog-body,
  #uploadOverlay .dialog-footer {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  .workspace-grid-2 {
    grid-template-columns: 1fr;
  }

  .workspace-chip-row {
    gap: 8px;
  }

  #uploadOverlay .form-buttons,
  #editForm .modal-buttons {
    flex-direction: column;
  }

  #editModal .modal-content {
    width: min(96vw, 720px);
    padding: 16px 14px;
  }
}

.filter-status-text {
  width: min(980px, calc(100% - 16px));
  margin: -2px auto 10px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 248, 229, 0.88);
  border: 1px solid rgba(118, 88, 52, 0.18);
  color: #5a4631;
  font-size: 0.82rem;
  line-height: 1.3;
  text-align: center;
}

.tag-review {
  background: #f2dfb7;
  color: #6b4a12;
  border-color: rgba(138, 103, 35, 0.32);
}

.card-batch {
  margin-top: 4px !important;
  font-size: 0.68rem !important;
  line-height: 1.2 !important;
  color: #8a6a47 !important;
  font-style: normal !important;
  min-height: 1.6em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- compact-view-v2-stronger-pass --- */
#shoeboxList.shoebox-grid-compact {
  grid-template-columns: repeat(auto-fill, minmax(150px, 150px));
  gap: 8px;
}

#shoeboxList.shoebox-grid-detailed {
  grid-template-columns: repeat(auto-fill, minmax(172px, 172px));
  gap: 10px;
}

.card-view-compact {
  padding: 6px 6px 8px;
  border-radius: 10px;
}

.card-view-compact::before {
  inset: 5px;
  border-radius: 7px;
}

.card-view-compact .card-image {
  max-height: 136px;
  margin-bottom: 4px;
  padding: 5px;
}

.card-view-compact h3 {
  font-size: 0.8rem;
  line-height: 1.08;
  margin-bottom: 2px;
  min-height: 1.55em;
}

.card-view-compact .card-meta-primary {
  font-size: 0.67rem;
  min-height: 0;
}

.card-view-compact .card-meta-secondary {
  display: none;
}

.card-view-compact .card-value {
  margin-top: 2px !important;
  font-size: 0.72rem !important;
}

.card-view-compact .card-badge-row {
  margin-top: 3px;
  gap: 3px;
}

.card-view-compact .tag-summary {
  font-size: 0.5rem;
  min-height: 16px;
  padding: 1px 6px;
}

.card-view-compact .editButton {
  min-width: 70px;
  padding: 4px 8px;
  font-size: 0.74rem;
  margin-top: 4px;
}

@media (max-width: 900px) {
  #shoeboxList.shoebox-grid-compact {
    grid-template-columns: repeat(auto-fill, minmax(140px, 140px));
    gap: 8px;
  }

  #shoeboxList.shoebox-grid-detailed {
    grid-template-columns: repeat(auto-fill, minmax(158px, 158px));
    gap: 9px;
  }
}

@media (max-width: 600px) {
  #shoeboxList.shoebox-grid-compact {
    grid-template-columns: repeat(auto-fill, minmax(126px, 126px));
    gap: 7px;
  }

  #shoeboxList.shoebox-grid-detailed {
    grid-template-columns: repeat(auto-fill, minmax(140px, 140px));
    gap: 8px;
  }

  .card-view-compact .card-image {
    max-height: 118px;
  }

  .card-view-compact h3 {
    font-size: 0.76rem;
  }

  .card-view-compact .card-meta-primary {
    font-size: 0.63rem;
  }

  .card-view-compact .card-value {
    font-size: 0.68rem !important;
  }

  .card-view-compact .editButton {
    min-width: 64px;
    font-size: 0.7rem;
    padding: 4px 7px;
  }
}

/* --- location-line-display --- */
.card-location {
  margin-top: 2px !important;
  font-size: 0.64rem !important;
  line-height: 1.15 !important;
  color: #8a6a47 !important;
  font-style: normal !important;
  min-height: 0 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-view-compact .card-location {
  font-size: 0.58rem !important;
  margin-top: 2px !important;
}

.card-view-detailed .card-location {
  font-size: 0.66rem !important;
}

/* --- edit-context-panel --- */
.edit-context-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 0 12px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 248, 229, 0.88);
  border: 1px solid rgba(118, 88, 52, 0.16);
}

.edit-context-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5b4731;
  background: rgba(244, 232, 191, 0.95);
  border: 1px solid rgba(150, 123, 60, 0.24);
  white-space: nowrap;
}

.edit-context-text {
  flex: 1 1 auto;
  text-align: right;
  font-size: 0.78rem;
  line-height: 1.2;
  color: #7a6245;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .edit-context-panel {
    flex-direction: column;
    align-items: flex-start;
  }

  .edit-context-text {
    text-align: left;
    white-space: normal;
  }
}

.edit-context-chip.edit-context-review {
  background: linear-gradient(180deg, rgba(244, 232, 191, 0.98) 0%, rgba(232, 214, 154, 0.98) 100%);
  color: #6a5328;
  border-color: rgba(150, 123, 60, 0.34);
}

.edit-context-chip.edit-context-reviewed {
  background: linear-gradient(180deg, rgba(216, 238, 232, 0.98) 0%, rgba(194, 226, 217, 0.98) 100%);
  color: #246151;
  border-color: rgba(77, 137, 120, 0.28);
}

/* OCR results boxes restored for local smoke testing */

/* --- collector-polish-dashboard-and-status --- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
  margin-top: 2px;
}

.summary-card {
  padding: 12px 10px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 250, 235, 0.98) 0%, rgba(246, 236, 208, 0.98) 100%);
  border: 1px solid rgba(118, 88, 52, 0.18);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.summary-card-wide {
  grid-column: span 2;
}

.summary-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7a6245;
  margin-bottom: 6px;
}

.summary-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: #2f2418;
}

.card .tag-summary.tag-reviewed {
  background: linear-gradient(180deg, rgba(216, 238, 232, 0.98) 0%, rgba(194, 226, 217, 0.98) 100%);
  color: #246151;
  border-color: rgba(77, 137, 120, 0.28);
}

.card-view-detailed .card-badge-row {
  justify-content: flex-start;
}

.card-view-detailed .tag-summary {
  font-size: 0.58rem;
  padding: 3px 9px;
}

@media (max-width: 760px) {
  .summary-card-wide {
    grid-column: span 1;
  }
}

/* --- collector-file-button-polish --- */
#cardImage,
#editCardImage {
  color: #5b4731;
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(118, 88, 52, 0.26);
  border-radius: 12px;
  padding: 10px 12px;
}

#cardImage::file-selector-button,
#editCardImage::file-selector-button {
  background: linear-gradient(180deg, rgba(244, 225, 161, 0.98) 0%, rgba(220, 192, 120, 0.98) 100%);
  border: 2px solid rgba(124, 92, 43, 0.95);
  color: #3a2d1e;
  padding: 8px 14px;
  margin-right: 12px;
  border-radius: 10px;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 0.92rem;
  font-weight: 700;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease, filter 0.15s ease;
}

#cardImage::file-selector-button:hover,
#editCardImage::file-selector-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

#cardImage::-webkit-file-upload-button,
#editCardImage::-webkit-file-upload-button {
  background: linear-gradient(180deg, rgba(244, 225, 161, 0.98) 0%, rgba(220, 192, 120, 0.98) 100%);
  border: 2px solid rgba(124, 92, 43, 0.95);
  color: #3a2d1e;
  padding: 8px 14px;
  margin-right: 12px;
  border-radius: 10px;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 0.92rem;
  font-weight: 700;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
}

#editCropCurrentImageButton,
#editReadCurrentImageButton,
#readCardFromImageButton {
  background: linear-gradient(180deg, rgba(244, 225, 161, 0.98) 0%, rgba(220, 192, 120, 0.98) 100%) !important;
  border: 2px solid rgba(124, 92, 43, 0.95) !important;
  color: #3a2d1e !important;
  padding: 10px 16px !important;
  border-radius: 12px !important;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

#editCropCurrentImageButton:hover,
#editReadCurrentImageButton:hover,
#readCardFromImageButton:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

/* --- phase1-shell-dashboard-modal-polish --- */
#dashboardModal .modal-content {
  width: min(94vw, 1080px);
  max-width: 1080px;
  max-height: 88vh;
  padding: 26px 24px 22px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 251, 240, 0.985) 0%, rgba(246, 236, 208, 0.985) 100%);
  border: 1px solid rgba(118, 88, 52, 0.24);
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.30);
}

#dashboardModal h2 {
  margin-bottom: 6px;
  color: #2f2418;
  font-size: 1.55rem;
  letter-spacing: 0.02em;
}

.dashboard-intro {
  margin: 0 0 18px;
  color: #6d5841;
  font-size: 0.95rem;
  line-height: 1.4;
  text-align: center;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
}

#dashboardSummary.summary {
  margin-bottom: 0;
}

.dashboard-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  align-items: stretch;
}

#dashboardModal .chart-container {
  position: relative;
  margin: 0;
  min-height: 320px;
  padding: 18px 18px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(248, 243, 229, 0.98) 0%, rgba(235, 224, 195, 0.98) 100%);
  border: 2px solid rgba(92, 71, 50, 0.72);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.16),
    inset 0 0 0 1px rgba(255, 249, 234, 0.92);
}

#dashboardModal .chart-container::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(212, 184, 138, 0.42);
  border-radius: 13px;
  pointer-events: none;
}

#dashboardModal .chart-container.small {
  max-width: none;
}

#dashboardModal .chart-container h3 {
  margin-bottom: 14px;
  color: #2f2418;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-align: center;
}

#dashboardModal canvas {
  width: 100% !important;
  min-height: 240px;
}

footer {
  border-top: 1px solid rgba(212, 184, 138, 0.24);
  background: rgba(24, 18, 13, 0.38);
}

.emulatorWarning {
  color: #f4ead1;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
}

.modalOverlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.58);
  z-index: 1100;
}

.modalOverlay.hidden {
  display: none !important;
}

.modalCard {
  width: min(94vw, 720px);
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px 20px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 251, 240, 0.985) 0%, rgba(246, 236, 208, 0.985) 100%);
  border: 2px solid rgba(92, 71, 50, 0.72);
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.30);
  color: #3a2d1e;
}

.modalCard h2 {
  margin-bottom: 10px;
  color: #2f2418;
}

.btnPrimary,
.btnSecondary {
  border-radius: 12px;
  padding: 10px 14px;
  font-family: Georgia, serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.btnPrimary {
  background: linear-gradient(180deg, rgba(244, 225, 161, 0.98) 0%, rgba(220, 192, 120, 0.98) 100%);
  border: 2px solid rgba(124, 92, 43, 0.95);
  color: #3a2d1e;
}

.btnSecondary {
  background: rgba(255, 255, 255, 0.86);
  border: 2px solid rgba(118, 88, 52, 0.38);
  color: #5b4731;
}

#uploadOverlay .overlay-content-small,
#editModal .modal-content {
  backdrop-filter: blur(2px);
}

#uploadOverlay h2,
#editModal h2 {
  color: #2f2418;
  font-size: 1.45rem;
  letter-spacing: 0.02em;
}

#uploadOverlay .workspace-section,
#editModal .workspace-section {
  padding: 16px 16px 14px;
  border-radius: 18px;
  box-shadow: 0 4px 14px rgba(70, 48, 24, 0.08);
}

#uploadOverlay .workspace-section-title,
#editModal .workspace-section-title {
  margin-bottom: 12px;
  font-size: 0.8rem;
  letter-spacing: 0.10em;
}

#uploadOverlay .workspace-grid,
#editModal .workspace-grid {
  gap: 12px 14px;
}

#uploadOverlay .workspace-field,
#editModal .workspace-field {
  gap: 6px;
}

#uploadOverlay .workspace-chip-row,
#editModal .workspace-chip-row {
  gap: 10px;
  margin-top: 14px;
}

.edit-image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.edit-image-actions button {
  flex: 1 1 180px;
  margin: 0 !important;
}

#uploadOverlay .form-buttons,
#editModal .modal-buttons {
  margin-top: 4px !important;
  padding-top: 12px;
  border-top: 1px solid rgba(118, 88, 52, 0.14);
  box-shadow: 0 -8px 18px rgba(255, 255, 255, 0.92);
}

#uploadOverlay .form-buttons button,
#editModal .modal-buttons button {
  min-height: 46px;
}

#editModal .modal-buttons {
  flex-wrap: wrap;
}

#editModal .modal-buttons button {
  flex: 1 1 180px;
}

#editModal .muted {
  font-size: 0.84rem;
  color: #6d5841;
  line-height: 1.35;
}

@media (max-width: 900px) {
  #dashboardModal .modal-content {
    width: min(96vw, 900px);
  }

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

@media (max-width: 760px) {
  #dashboardModal .modal-content {
    padding: 20px 16px 18px;
    border-radius: 20px;
  }

  #dashboardModal .chart-container {
    min-height: 280px;
    padding: 16px 14px 12px;
  }

  #dashboardModal canvas {
    min-height: 220px;
  }
}

/* --- phase1-hotfix-dashboard-and-edit --- */
#dashboardModal .chart-container {
  min-height: 0;
}

#dashboardModal canvas {
  min-height: 0 !important;
  height: 240px !important;
  max-height: 240px;
}

#dashboardModal .dashboard-charts {
  align-items: start;
}

@media (max-width: 760px) {
  #dashboardModal canvas {
    height: 200px !important;
    max-height: 200px;
  }

  #uploadOverlay .form-buttons button,
  #editForm .modal-buttons button {
    flex: 0 0 auto !important;
    width: 100%;
    min-height: 46px;
  }
}

/* --- pm-edit-modal-density-pass --- */
#editModal .modal-content {
  width: min(96vw, 1160px) !important;
  max-width: 1160px !important;
  max-height: 90vh !important;
  padding: 16px 18px 16px !important;
}

#editModal h2 {
  margin-bottom: 8px !important;
}

#editModal #editContextPanel {
  position: sticky;
  top: 0;
  z-index: 6;
  margin: 0 0 10px !important;
  padding: 6px 10px !important;
  background: rgba(255, 248, 229, 0.96) !important;
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.92);
}

#editForm {
  display: grid !important;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr) !important;
  gap: 10px 12px !important;
  align-items: start;
}

#editForm > .workspace-section {
  margin: 0 !important;
  padding: 12px 12px 10px !important;
}

#editForm > .workspace-section:first-of-type {
  grid-column: 1 / 2;
}

#editForm > .workspace-section:nth-of-type(2) {
  grid-column: 2 / 3;
}

#editProgressContainer,
#editForm .modal-buttons,
#editForm > .muted {
  grid-column: 1 / -1 !important;
}

#editProgressContainer {
  margin-bottom: 2px !important;
}

#editForm .workspace-grid {
  gap: 8px 10px !important;
}

#editForm .workspace-chip-row {
  gap: 8px !important;
  margin-top: 10px !important;
}

#editForm .workspace-chip-row label {
  padding: 6px 10px !important;
  font-size: 0.86rem !important;
}

#editForm input[type="text"],
#editForm input[type="number"],
#editForm input[type="file"],
#editForm select,
#editForm textarea {
  padding: 8px 10px !important;
  font-size: 0.94rem !important;
}

#editForm textarea {
  min-height: 82px;
}

#editImageThumb.thumb {
  max-height: 150px !important;
}

#editForm .thumb-panel {
  padding: 8px 10px !important;
}

#editForm .edit-image-actions {
  gap: 8px !important;
  margin-top: 8px !important;
}

#editForm .edit-image-actions button {
  flex: 1 1 140px !important;
  min-height: 40px !important;
  padding: 8px 10px !important;
  font-size: 0.88rem !important;
}

#editForm .workspace-section-title {
  margin-bottom: 8px !important;
  font-size: 0.74rem !important;
}

#editForm .modal-buttons {
  gap: 8px !important;
  padding-top: 10px !important;
}

#editForm .modal-buttons button {
  flex: 1 1 150px !important;
  min-height: 42px !important;
  padding: 9px 10px !important;
  font-size: 0.9rem !important;
}

#editForm > .muted {
  margin-top: 0 !important;
  font-size: 0.78rem !important;
}

#editModal .ocr-results-box {
  padding: 8px 10px !important;
  margin: 0 !important;
}

#editOcrResultsTitle,
#editOcrResultsText {
  font-size: 0.82rem;
  line-height: 1.3;
}

@media (max-width: 900px) {
  #editModal .modal-content {
    width: min(96vw, 940px) !important;
  }

  #editForm {
    grid-template-columns: 1fr !important;
  }

  #editForm > .workspace-section:first-of-type,
  #editForm > .workspace-section:nth-of-type(2) {
    grid-column: 1 / -1 !important;
  }
}

@media (max-width: 760px) {
  #editModal .modal-content {
    width: min(97vw, 720px) !important;
    padding: 14px 12px 14px !important;
  }

  #editModal #editContextPanel {
    position: static;
  }

  #editForm .modal-buttons button {
    width: 100%;
  }
}

/* --- phase6-edit-footprint-pass --- */
#editModal .modal-content {
  width: min(92vw, 920px) !important;
  max-width: 920px !important;
  max-height: 84vh !important;
  padding: 14px 14px 12px !important;
}

#editModal h2 {
  margin-bottom: 6px !important;
  font-size: 1.26rem !important;
}

#editModal #editContextPanel {
  margin: 0 0 8px !important;
  padding: 5px 8px !important;
  gap: 8px !important;
}

#editModal .edit-context-chip {
  min-height: 18px !important;
  padding: 2px 8px !important;
  font-size: 0.62rem !important;
}

#editModal .edit-context-text {
  font-size: 0.72rem !important;
  line-height: 1.15 !important;
}

#editForm {
  grid-template-columns: minmax(0, 1.02fr) minmax(300px, 0.88fr) !important;
  gap: 8px 10px !important;
}

#editForm > .workspace-section {
  padding: 10px 10px 8px !important;
  border-radius: 14px !important;
}

#editForm .workspace-section-title {
  margin-bottom: 6px !important;
  font-size: 0.7rem !important;
  letter-spacing: 0.09em !important;
}

#editForm .workspace-grid {
  gap: 7px 8px !important;
}

#editForm label {
  font-size: 0.84rem !important;
}

#editForm input[type="text"],
#editForm input[type="number"],
#editForm input[type="file"],
#editForm select,
#editForm textarea {
  padding: 7px 9px !important;
  font-size: 0.9rem !important;
}

#editForm textarea {
  min-height: 68px !important;
}

#editForm .workspace-chip-row {
  gap: 6px !important;
  margin-top: 8px !important;
}

#editForm .workspace-chip-row label {
  padding: 5px 9px !important;
  font-size: 0.8rem !important;
}

#editForm .thumb-panel {
  padding: 6px 8px !important;
}

#editImageThumb.thumb {
  max-height: 112px !important;
}

#editForm .edit-image-actions {
  gap: 6px !important;
  margin-top: 6px !important;
}

#editForm .edit-image-actions button {
  flex: 1 1 118px !important;
  min-height: 34px !important;
  padding: 7px 9px !important;
  font-size: 0.82rem !important;
}

#editModal .ocr-results-box {
  padding: 7px 9px !important;
  border-radius: 10px !important;
}

#editModal #editOcrResultsTitle,
#editModal #editOcrResultsText {
  font-size: 0.78rem !important;
  line-height: 1.25 !important;
}

#editModal .phase6-summary {
  margin-top: 6px !important;
  padding: 8px 9px !important;
  border-radius: 10px !important;
}

#editModal .phase6-summary-title {
  font-size: 0.82rem !important;
}

#editModal .phase6-summary-subtitle {
  display: none !important;
}

#editModal .phase6-summary-line {
  margin-top: 4px !important;
  font-size: 0.74rem !important;
}

#editModal .phase6-summary-actions {
  gap: 6px !important;
  margin-top: 7px !important;
}

#editModal .phase6-summary-btn {
  padding: 5px 9px !important;
  font-size: 0.74rem !important;
}

#editModal .phase6-badge {
  font-size: 0.66rem !important;
  padding: 2px 6px !important;
}

#editModal .phase6-detail-heading {
  font-size: 0.74rem !important;
}

#editModal .phase6-detail-item {
  padding: 5px 7px !important;
}

#editModal .phase6-detail-label,
#editModal .phase6-detail-value {
  font-size: 0.72rem !important;
}

#editForm .modal-buttons {
  gap: 7px !important;
  padding-top: 8px !important;
}

#editForm .modal-buttons button {
  flex: 1 1 140px !important;
  min-height: 38px !important;
  padding: 8px 9px !important;
  font-size: 0.84rem !important;
}

#editForm > .muted {
  margin-top: 0 !important;
  font-size: 0.7rem !important;
  line-height: 1.15 !important;
}

@media (max-width: 900px) {
  #editModal .modal-content {
    width: min(95vw, 760px) !important;
  }
  #editForm {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 760px) {
  #editModal .modal-content {
    width: min(97vw, 680px) !important;
    max-height: 88vh !important;
    padding: 12px 10px 10px !important;
  }
  #editModal #editContextPanel {
    position: static !important;
  }
  #editForm .modal-buttons button {
    width: 100% !important;
  }
}
