/* ============================================
   BAMBU FILAMENT TRACKER - MAIN STYLESHEET
   ============================================ */

/* --- THEMES & VARIABLES --- */
:root {
  --sidebar-width: 270px;
  --primary: #00ae42;
  --wishlist: #5c9aff;
  --error: #d32f2f;

  /* Light Theme (Default) */
  --bg: #f5f5f7;
  --card-bg: #fff;
  --ui-bg: #fff;
  --text-primary: #333;
  --text-secondary: #888;
  --border-color: #e1e1e1;
  --border-color-light: #eee;
  --input-bg: #fff;
  --input-border: #ddd;
}

html[data-theme='dark'] {
  --bg: #1a1a1a;
  --card-bg: #2c2c2c;
  --ui-bg: #2c2c2c;
  --text-primary: #f0f0f0;
  --text-secondary: #9e9e9e;
  --border-color: #424242;
  --border-color-light: #383838;
  --input-bg: #333;
  --input-border: #555;
}

/* ============================================
   GLOBAL / BODY
   ============================================ */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  display: flex;
  height: 100vh;
  overflow: hidden;
  transition: padding-left 0.3s ease;
}

/* Desktop Collapsed State */
body.sidebar-collapsed {
  padding-left: 0;
}

body.sidebar-collapsed .sidebar {
  margin-left: calc(-1 * var(--sidebar-width));
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--ui-bg);
  border-right: 1px solid var(--border-color);
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  flex-shrink: 0;
  transition: margin-left 0.3s ease;
  z-index: 100;
  position: relative;
}

.sidebar.open {
  transform: translateX(0);
  position: absolute;
  height: 100%;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

/* Sidebar Header & Actions */
.brand {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 5px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Sync Status Indicator */
#syncIndicatorDot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  margin-left: 4px;
  background-color: var(--text-secondary); /* Grey - Inactive */
  transition: background-color 0.5s ease, transform 0.2s ease;
  cursor: help;
  display: inline-block;
  align-self: anchor-center;  
}

#syncIndicatorDot.connected {
  background-color: var(--primary); /* Green - Connected */
}

#syncIndicatorDot.error {
  background-color: var(--error);
}

#syncIndicatorDot.data-in {
  animation: sync-flash 0.7s ease-out;
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}

.sidebar-actions .button-group {
  display: flex;
  gap: 8px;
}

.sidebar-actions .button-group .btn-xs {
  flex: 1;
}

.sidebar-action-buttons {
  display: flex;
  gap: 4px;
  width: 100%;
}

.sidebar-action-buttons .btn-xs {
  flex: 1;
  font-weight: 600;
  background: var(--bg);
}

.threemf-colour-row {
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.threemf-colour-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 14px;
}

.threemf-colour-swatch {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--input-border);
  flex-shrink: 0;
}

.threemf-colour-label {
  color: var(--text-secondary);
  font-weight: 400;
  font-size: 12px;
}

.threemf-match-type {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-secondary);
}

.threemf-cards-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.threemf-cards-row .card {
  min-width: 260px;
  max-width: 300px;
  flex-shrink: 0;
}

.threemf-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  margin: 8px 12px 12px 12px;
  font-size: 13px;
  position: sticky;
  top: -12px;
  z-index: 10;
  transition: top 0.3s ease;
}

.threemf-banner-row-1 {
  display: flex;
  align-items: center;
  gap: 12px;
}

.threemf-banner-row-2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.threemf-banner-text {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.threemf-filename {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.threemf-close-btn {
  background: rgba(255,255,255,0.2) !important;
  color: white !important;
  border-color: rgba(255,255,255,0.3) !important;
}

.threemf-close-btn:hover {
  background: rgba(255,255,255,0.35) !important;
}

.threemf-toggle-btn {
  margin-left: 8px;
  font-size: 10px !important;
  padding: 2px 8px !important;
  height: 24px !important;
}

#threemfResultsContainer {
  padding: 12px;
}

.btn-xs {
  font-size: 11px;
  padding: 4px 8px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-primary);
  border-radius: 4px;
  cursor: pointer;
  height: 30px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-xs:hover {
  background: var(--bg);
}

/* Sidebar Contact Widget */
.contact-box {
  font-size: 12px;
  border: 1px dashed var(--input-border);
  padding: 10px;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-contact-hint {
  margin-top: 0;
  width: 100%;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px dashed var(--input-border);
  border-radius: 6px;
  padding: 9px 10px;
  cursor: pointer;
}

.sidebar-contact-hint:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.copy-btn {
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.copy-btn:hover {
  background: #eee;
}

.copy-btn:active {
  background: #dcdcdc;
}

/* Sidebar Footer & I/O */
.io-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.btn-io {
  flex: 1;
  font-size: 11px;
  padding: 6px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  color: var(--text-primary);
}

.btn-io:hover {
  background: var(--bg);
  border-color: var(--text-secondary);
}

/* Sidebar Category List */
.category-group {
  margin-bottom: 15px;
}

.cat-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  font-weight: 700;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-color-light);
  padding-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cat-select-all {
  font-size: 9px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: 1px solid var(--border-color-light);
  border-radius: 4px;
  padding: 1px 6px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.cat-select-all:hover {
  opacity: 1;
}

.cat-select-all.all-selected {
  color: var(--accent);
  border-color: var(--accent);
  opacity: 0.8;
}

.cat-item {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 2px;
  position: relative;
}

.cat-item:hover {
  background: var(--bg);
}

.cat-item.active {
  background: rgba(0, 174, 66, 0.1);
  color: var(--primary);
  font-weight: 600;
}

.cat-item input {
  margin-right: 8px;
  cursor: pointer;
  accent-color: var(--primary);
}

.indicators {
  margin-left: auto;
  display: flex;
  gap: 4px;
  align-items: center;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.dot-owned {
  background: var(--primary);
}

.dot-wish {
  background: var(--wishlist);
}

/* ============================================
   MAIN CONTENT & LAYOUT
   ============================================ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding-bottom: 40px;
}

/* ============================================
   TOP BAR & FILTERS
   ============================================ */
.top-bar {
  background: var(--ui-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 20px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
  z-index: 10;
}

.top-bar.library-view-hidden {
  display: none;
}

.content-area.library-view-active {
  padding-top: 0;
}

/* Generic Form Controls */
select,
input[type="text"] {
  padding: 6px 10px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: var(--input-bg);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

select:focus,
input:focus {
  border-color: var(--primary);
}

select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239e9e9e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

/* Mobile & Desktop Toggles */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-primary);
  padding: 0 10px 0 0;
}

.desktop-toggle {
  display: none;
  background: none;
  border: none;
  padding: 0 10px 0 0;
  font-size: 20px;
  color: var(--text-primary);
  cursor: pointer;
}

.desktop-toggle:hover {
  color: var(--primary);
}

.mobile-compact-toggle-container {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.mobile-compact-toggle-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.mobile-compact-toggle-container .toggle-switch {
  width: 34px;
  height: 18px;
}

.mobile-compact-toggle-container .toggle-slider:before {
  width: 12px;
  height: 12px;
  left: 3px;
  bottom: 3px;
}

.mobile-compact-toggle-container .toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(16px);
}

/* ETA Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-color);
  transition: 0.3s;
  border-radius: 20px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* ============================================
   CARD STYLES
   ============================================ */
.card {
  background: var(--card-bg);
  border-radius: 10px;
  border: 1px solid var(--border-color);
  padding: 12px;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: all 0.1s;
}

.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.card.owned {
  border: 2px solid var(--primary);
}

.card.wishlist {
  border: 2px solid var(--wishlist);
}

.card img {
  width: 100%;
  height: 140px;
  object-fit: contain;
  cursor: pointer;
  background: #fafafa;
  border-radius: 6px;
  margin-bottom: 10px;
}

html[data-theme='dark'] .card img {
  background: #383838;
}

/* Card Layout Containers */
.card-top-section {
  display: flex;
  flex-direction: column;
}

.card-bottom-section {
  display: flex;
  flex-direction: column;
  min-height: 44px;
}

.grid.mobile-compact-grid {
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 451px) {
  .grid.mobile-compact-grid {
    /* Keep compact cards on predictable 200px tracks on larger mobile/tablet widths */
    grid-template-columns: repeat(auto-fill, minmax(200px, 200px));
    justify-content: flex-start;
  }
}

.card.mobile-compact-card {
  padding: 8px;
  align-items: center;
  gap: 8px;
}

.card.mobile-compact-card:hover {
  transform: none;
  box-shadow: none;
}

.mobile-compact-heading {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.3;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-compact-image-trigger {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  justify-content: center;
}

.mobile-compact-image-trigger .library-filament-indicator {
  width: min(200px, 100%);
  height: 120px;
  border-radius: 10px;
}

.card.mobile-compact-card .library-filament-indicator {
  border: 0;
}

.mobile-compact-image-trigger .library-filament-indicator img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fafafa;
}

html[data-theme='dark'] .mobile-compact-image-trigger .library-filament-indicator img {
  background: #383838;
}

.card-image-container {
  position: relative;
}

.image-loading-slot {
  position: relative;
  overflow: hidden;
}

.image-loading-slot::before,
.image-loading-slot::after {
  content: '';
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.image-loading-slot::before {
  inset: 0;
  background: rgba(255, 255, 255, 0.45);
  z-index: 1;
}

.image-loading-slot::after {
  width: 18px;
  height: 18px;
  top: 50%;
  left: 50%;
  margin-top: -9px;
  margin-left: -9px;
  border-radius: 50%;
  border: 2px solid rgba(130, 130, 130, 0.35);
  border-top-color: var(--primary);
  animation: spin 0.9s linear infinite;
  z-index: 2;
}

.image-loading-slot.is-loading::before,
.image-loading-slot.is-loading::after {
  opacity: 1;
}

.image-loading-slot > img {
  transition: opacity 0.18s ease;
}

.image-loading-slot.is-loading > img {
  opacity: 0.15;
}

html[data-theme='dark'] .image-loading-slot::before {
  background: rgba(20, 20, 20, 0.45);
}

.card-details-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height:80px;
}

.custom-supplier-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
}

.library-indicator-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--primary);
  color: white;
  border-radius: 4px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  z-index: 3;
}

.library-indicator-badge svg {
  display: block;
}

/* Card Header & Status */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.colour-name {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.3;
  max-width: 200px;
}

.status-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 5px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.meta .product-type-label {
  font-weight: 700;
  font-size: 12px;
  color: var(--text-primary);
}

.print-status-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border-color-light);
  background: var(--input-bg);
  color: #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-right: 6px;
  position: relative;
  overflow: hidden;
  z-index: 0;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}

.print-status-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  transform: scaleX(0);
  transform-origin: left;
  z-index: -1;
  pointer-events: none;
}

.print-status-btn.print-status-to-print::before {
  background: #9e9e9e;
}

.print-status-btn.print-status-loaded::before {
  background: #ff9800;
}

.print-status-btn.long-press-active::before {
  transform: scaleX(1);
  transition: transform 0.4s linear;
}

.print-status-btn.long-press-done.print-status-to-print {
  background: #9e9e9e;
  border-color: #9e9e9e;
  color: #fff;
}

.print-status-btn.long-press-done.print-status-loaded {
  background: #ff9800;
  border-color: #ff9800;
  color: #fff;
}

.print-status-btn:hover {
  background: var(--bg);
  color: #999;
}

.print-status-btn.print-status-to-print {
  background: #ff9800;
  color: #fff;
  border-color: #ff9800;
}

.print-status-btn.print-status-loaded {
  background: #4caf50;
  color: #fff;
  border-color: #4caf50;
}

.buy-more-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border-color-light);
  background: var(--input-bg);
  color: #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.buy-more-btn:hover {
  background: var(--bg);
  color: #999;
}

.buy-more-btn.active {
  background: var(--wishlist);
  color: #fff;
  border-color: var(--wishlist);
}

.status-pill {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid var(--input-border);
  cursor: pointer;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--input-bg);
  color: var(--text-
  primary);
  user-select: none;
  max-height:22px;
  min-width:65px;
  text-align:center;
}

.s-owned {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.s-wishlist {
  background: var(--wishlist);
  color: white;
  border-color: var(--wishlist);
  position: relative;
  overflow: hidden;
  z-index: 0;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}

.s-wishlist::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #d32f2f;
  transform: scaleX(0);
  transform-origin: left;
  z-index: -1;
  pointer-events: none;
}

.s-wishlist.long-press-active::before {
  transform: scaleX(1);
  transition: transform 0.4s linear;
}

.s-wishlist.long-press-done {
  background: #d32f2f;
  border-color: #d32f2f;
}

/* ============================================
   INVENTORY CONTROLS
   ============================================ */
.inv-panel {
  position: relative;
  overflow: visible;
  border-top: 1px dashed var(--border-color-light);
  background: var(--bg);
  border-radius: 0 0 8px 8px;
  margin: 10px -12px -12px -12px;
  padding: 10px 12px;
  opacity: 0.2;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
}

.card.owned .inv-panel {
  opacity: 1;
  pointer-events: auto;
}

.inv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.spares-ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 4px;
  padding: 2px;
}

.btn-qty {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-weight: bold;
  color: var(--text-primary);
}

.btn-qty:hover {
  background: var(--border-color);
}

.qty-display {
  min-width: 20px;
  text-align: center;
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type=range] {
  flex: 1;
  accent-color: var(--primary);
  height: 4px;
}

.slider-val {
  font-size: 11px;
  color: var(--primary);
  font-weight: 700;
  width: 40px;
  text-align: right;
}

/* ============================================
   MULTI-SPOOL CONTROLS
   ============================================ */
.multi-spool-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  color: var(--primary);
  opacity: 0.7;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.multi-spool-toggle-btn:hover {
  opacity: 1;
}

.multi-spool-summary {
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
  flex: 1;
  line-height: 1.4;
}

/* Shared base styles for card slide-up modals */
.card-modal-base {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  background: var(--card-bg);
  border-radius: 0 0 8px 8px;
  border-top: 1px solid var(--border-color-light);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
  padding: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, padding 0.3s ease;
}

.card-modal-base.open {
  max-height: 400px;
  opacity: 1;
  padding: 10px 12px;
  overflow-y: auto;
}

.multi-spool-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.multi-spool-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.multi-spool-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 22px;
}

.multi-spool-delete {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  transition: color 0.15s;
  flex-shrink: 0;
}

.multi-spool-delete:hover {
  color: var(--error);
}

.multi-spool-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 6px;
  margin-top: 4px;
  background: var(--bg);
  border: 1px dashed var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.multi-spool-add-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* Keep in-card "+ Add Spool" height aligned with slider rows. */
.inv-row .multi-spool-add-btn {
  margin-top: 0;
  padding: 2px 8px;
  min-height: 20px;
  line-height: 1.1;
}

/* .stock-location-modal uses .card-modal-base */

.stock-location-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.stock-location-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 90px;
  flex-shrink: 0;
}

.stock-location-select {
  flex: 1;
  padding: 4px 6px;
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-primary);
  cursor: pointer;
}

.stock-location-summary {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

.stock-location-summary-complete {
  color: var(--primary);
}

.stock-location-summary-partial {
  color: var(--text-secondary);
}

.stock-location-filter-btn {
  background: var(--bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.stock-location-filter-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.stock-location-delete {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  transition: color 0.15s;
  flex-shrink: 0;
}

.stock-location-delete:hover {
  color: var(--error);
}

/* ============================================
   INLINE DETAILS (Full details on card)
   ============================================ */
.inline-spool-details,
.inline-location-details {
  background: var(--card-bg);
  border: 1px solid var(--border-color-light);
  border-radius: 6px;
  padding: 8px;
  margin-top: 4px;
}

.inline-spool-details .multi-spool-row,
.inline-location-details .stock-location-row {
  margin-bottom: 6px;
}

.inline-spool-details .multi-spool-row:last-of-type,
.inline-location-details .stock-location-row:last-of-type {
  margin-bottom: 0;
}

.inline-spool-details .multi-spool-add-btn {
  margin-top: 6px;
}

.inline-location-details .stock-location-row {
  padding: 4px 0;
  border-bottom: 1px solid var(--border-color-light);
}

.inline-location-details .stock-location-row:last-child {
  border-bottom: none;
}

/* .item-selection-modal uses .card-modal-base */

.item-selection-modal-body {
  padding: 8px 0;
}

.item-selection-btn {
  width: 100%;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.15s;
  text-align: left;
  margin-bottom: 6px;
}

.item-selection-btn:hover {
  background: var(--card-bg);
  border-color: var(--primary);
}

.item-selection-btn.has-location {
  border-left: 3px solid var(--primary);
}

.item-selection-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.item-selection-location {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
}

/* .opening-spool-modal uses .card-modal-base with overrides */
.opening-spool-modal {
  z-index: 11;
}

.opening-spool-modal.open {
  max-height: 200px;
}

.loaded-relocation-modal {
  z-index: 11;
}

.loaded-relocation-modal.open {
  max-height: 260px;
}

.loaded-relocation-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.loaded-relocation-item {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border-color-light);
  border-radius: 4px;
  padding: 5px 7px;
}

.loaded-relocation-select {
  width: 100%;
  box-sizing: border-box;
}

/* ============================================
   CARD TYPES & BADGES
   ============================================ */
.type-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.badges {
  display: flex;
  gap: 4px;
}

.badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  border: 1px solid var(--border-color-light);
  text-decoration: none;
  color: inherit;
  background: var(--input-bg);
}

.history-bars .badge {
  width: 45px;
  text-align: center;
  flex-shrink: 0;
}

.history-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.in-stock {
  background: rgba(0, 174, 66, 0.1);
  border-color: var(--primary);
  color: var(--primary);
}



/* ============================================
   HISTORY SPARK BARS
   ============================================ */
.badge-custom {
  background: rgba(92, 154, 255, 0.15);
  border-color: var(--wishlist);
  color: var(--wishlist);
}

.spark-bar-container {
  display: flex;
  gap: 4px;
  align-items: center;
  font-size: 10px;
  color: var(--text-secondary);
  text-decoration: none;
  min-height: 12px;
}

.spark-bar-container.empty-container {
  visibility: hidden;
  pointer-events: none;
  height: 20px;
}

.spark-bar {
  display: flex;
  height: 12px;
  border: 1px solid;
  border-radius: 2px;
  flex-grow: 1;
}

.spark-segment {
  flex: 1;
}

/* ============================================
   SORT CONTROLS
   ============================================ */
.sort-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  padding: 4px 8px;
  border-radius: 16px;
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 500;
  cursor: grab;
  transition: background-color 0.2s;
}

.sort-pill:active {
  cursor: grabbing;
}

.sort-pill.dragging {
  opacity: 0.5;
  background: var(--border-color);
}

.remove-pill {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s;
}

.remove-pill:hover {
  background: rgba(0, 0, 0, 0.3);
}

.sort-builder select {
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px dashed var(--input-border);
  background-color: var(--bg);
}

.sort-builder select:hover {
  border-color: var(--text-secondary);
  background-color: var(--card-bg);
}

/* ============================================
   UTILITY & HELPERS
   ============================================ */
.loading-box {
  padding: 40px;
  text-align: center;
  color: var(--text-secondary);
}

.no-transition {
  transition: none !important;
}

.error {
  color: var(--error);
  background: #ffebee;
  padding: 10px;
  border-radius: 6px;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sync-flash {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.6);
    opacity: 0.7;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes devSplashFadeOut {
  from {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  to {
    opacity: 0;
    transform: translate(-50%, 40px);
  }
}

/* ============================================
   MODAL STYLES
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1003;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--card-bg);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 24px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  animation: popIn 0.3s ease-out;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-header .icon {
  color: var(--primary);
}

.modal-body {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.6;
  overflow-y: auto;
}

.modal-body ul {
  list-style: none;
  padding-left: 0;
  margin: 16px 0;
}

.modal-body li {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-body li .li-icon {
  color: var(--primary);
  font-weight: bold;
  margin-top: 3px;
}

.modal-body li strong {
  color: var(--text-primary);
}

.modal-footer {
  margin-top: 24px;
  text-align: right;
}

.modal-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}

.modal-btn:hover {
  opacity: 0.9;
}

.modal-body .modal-btn {
  color: white;
}

.sync-login-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.sync-login-spinner {
  width: 13px;
  height: 13px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: sync-login-spinner 0.8s linear infinite;
}

.modal-btn.is-loading {
  cursor: wait;
  opacity: 0.95;
}

@keyframes sync-login-spinner {
  to {
    transform: rotate(360deg);
  }
}

/* Modal Details/Summary for changelog */
.modal-body details {
  margin-top: 20px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.modal-body summary {
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  list-style-position: inside;
}

.modal-body summary:hover {
  color: var(--text-primary);
}

.modal-body details[open] summary {
  margin-bottom: 12px;
}

.modal-body details ul {
  margin-top: 0;
}

/* Modal Input Styles */
.modal-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: var(--input-bg);
  color: var(--text-primary);
}

.modal-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.modal-input-wrapper .modal-input {
  padding-right: 35px;
}

/* Privacy Policy Modal Styles */
.privacy-section {
  margin-bottom: 24px;
}

.privacy-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
}

.privacy-intro {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 12px 0;
  font-style: italic;
}

.privacy-subsection {
  margin-bottom: 12px;
  padding-left: 16px;
}

.privacy-subsection h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 6px 0;
  color: var(--primary);
}

.privacy-subsection p {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.6;
  margin: 0;
}

.modal-input-wrapper .clear-input-btn {
  position: absolute;
  right: 1px;
  top: 5px;
  bottom: 1px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  padding: 0 10px;
}

/* Inline-style replacement utilities (#202) */
.u-hidden {
  display: none;
}

.u-hidden-mt-6 {
  display: none;
  margin-top: 6px;
}

.u-w-full {
  width: 100%;
}

.u-w-300 {
  width: 300px;
}

.u-w-full-box {
  width: 100%;
  box-sizing: border-box;
}

.u-flex-1 {
  flex: 1;
}

.u-nowrap {
  white-space: nowrap;
}

.u-text-center {
  text-align: center;
}

.u-text-11-secondary {
  font-size: 11px;
  color: var(--text-secondary);
}

.u-text-12-secondary {
  font-size: 12px;
  color: var(--text-secondary);
}

.u-text-13-primary {
  font-size: 13px;
  color: var(--text-primary);
}

.u-fw-600 {
  font-weight: 600;
}

.u-mt-8 {
  margin-top: 8px;
}

.u-mt-12 {
  margin-top: 12px;
}

.u-stack-10 {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.u-stack-8 {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.u-stack-12-mb-20 {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.u-grid-2-gap-10 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.u-row-center-8 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.u-row-center-8-text-13 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.u-row-wrap-16-text-13 {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
}

.u-row-between-mb-10 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.u-stats-row {
  display: flex;
  gap: 15px;
  padding: 12px;
  background: var(--bg);
  border-radius: 6px;
}

.u-summary-margin {
  margin: 0 0 15px 0;
}

.modal-content-tall {
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-content-wide {
  max-width: 90vw;
  width: 900px;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  padding: 0;
  position: relative;
}

.modal-body-scroll {
  overflow-y: auto;
  flex-grow: 1;
}

.modal-grid-scroll {
  overflow-y: auto;
  flex-grow: 1;
  padding: 16px 24px;
}

.modal-header-tight {
  padding: 0;
  margin-bottom: 8px;
}

.modal-preview-top-panel {
  padding: 24px 24px 16px 24px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color-light);
}

.modal-preview-top-panel-anim {
  padding: 24px 24px 16px 24px;
  transition: transform 0.3s ease-in-out;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color-light);
}

.modal-preview-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  padding: 16px 24px 24px 24px;
  border-top: 1px solid var(--border-color-light);
  background: var(--card-bg);
}

.modal-footer-divider {
  border-top: 1px solid var(--border-color-light);
  padding-top: 16px;
}

.modal-btn-secondary {
  background: var(--text-secondary);
}

.modal-btn-neutral {
  background: var(--bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.modal-actions-end {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-section-divider {
  margin-top: 20px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.modal-section-divider-lg {
  margin-top: 20px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  font-size: 14px;
}

.modal-scroll-max-200 {
  max-height: 200px;
  overflow-y: auto;
}

.modal-checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.modal-checkbox-row-mb {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin-bottom: 10px;
}

.modal-checkbox-input {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
}

.modal-help-text {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.modal-row-gap-8-mb-10 {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.modal-link-primary {
  color: var(--primary);
}

.modal-inline-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.modal-filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.stack-10-mt-20 {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.settings-panel {
  padding: 15px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border-color-light);
}

.settings-panel-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.settings-panel-description {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.topbar-label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.topbar-control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 10px;
}

.autofill-decoy {
  display: none !important;
  position: absolute;
  left: -9999px;
}

.modal-body label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

#addFilamentModal .modal-footer {
  margin-top: 16px;
}

/* ============================================
   TABBED MODAL STYLES
   ============================================ */
.tabbed-modal {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.tabbed-modal .modal-header {
  flex-shrink: 0;
}

.tabbed-modal-container {
  display: flex;
  gap: 0;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.tabbed-modal .modal-footer {
  flex-shrink: 0;
}

.tabbed-modal-sidebar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 0;
  border-right: 1px solid var(--border-color-light);
  min-width: 120px;
  background: var(--bg);
  flex-shrink: 0;
  overflow-y: auto;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  background: var(--card-bg);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--card-bg);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}

.tab-icon {
  font-size: 18px;
  line-height: 1;
}

.tab-label {
  flex: 1;
}

.tabbed-modal-content {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  background: var(--card-bg);
  min-height: 0;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.2s ease-in;
}

.tab-panel.active {
  display: block;
}

.tab-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 8px 0;
}

.tab-description {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 20px 0;
  line-height: 1.5;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile responsiveness */
@media (max-width: 600px) {
  .tabbed-modal-sidebar {
    min-width: 90px;
  }

  .tab-btn {
    flex-direction: column;
    gap: 4px;
    padding: 10px 8px;
    font-size: 11px;
  }

  .tab-icon {
    font-size: 20px;
  }

  .tab-label {
    text-align: center;
  }

  .tabbed-modal-content {
    padding: 16px;
  }

  .tab-title {
    font-size: 16px;
  }

  .tab-description {
    font-size: 12px;
  }
}

/* ============================================
   CUSTOM DROPDOWN STYLES
   ============================================ */
.custom-dropdown {
  position: relative;
  display: inline-block;
  width: 300px;
}

.custom-dropdown-display {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: var(--input-bg);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239e9e9e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

.custom-dropdown-display:focus,
.custom-dropdown-display:hover {
  border-color: var(--primary);
}

.custom-dropdown-options {
  display: none;
  position: absolute;
  background-color: var(--ui-bg);
  min-width: 100%;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 20;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  max-height: 200px;
  overflow-y: auto;
  margin-top: 4px;
}

.custom-dropdown-options.show {
  display: block;
}

.custom-dropdown-item {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
}

.custom-dropdown-item:hover {
  background-color: var(--bg);
}

.custom-dropdown-item input[type="checkbox"] {
  margin-right: 8px;
  accent-color: var(--primary);
}

/* ============================================
   IMPORT PREVIEW STYLES
   ============================================ */
#importCustomPreviewModal .grid {
  max-height: 60vh;
  overflow-y: auto;
}

#customImagePreview {
  width: 80px;
  height: 80px;
  object-fit: contain;
  background: #fafafa;
  border-radius: 6px;
  margin-top: 5px;
  border: 1px solid var(--border-color);
}

.custom-supplier-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color-light);
}

.import-preview-card-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--card-bg);
  padding: 12px;
}

.import-preview-card-wrapper.duplicate {
  opacity: 0.7;
  border-color: var(--wishlist);
}

.import-options-container {
  position: absolute;
  top: auto;
  bottom: 12px;
  left: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  padding: 10px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.import-options-container input[type="checkbox"],
.import-options-container input[type="radio"] {
  margin-right: 5px;
  accent-color: var(--primary);
}

.import-options-container label {
  font-weight: 500;
  font-size: 13px;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Toggle Switch Styles (Import Options - scoped to avoid conflicts with ETA toggle) */
.import-options-container .toggle-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 20px;
}

.import-options-container .toggle-switch {
  width: 34px;
  flex-shrink: 0;
}

.import-options-container .toggle-slider {
  background-color: var(--error);
}

.import-options-container .toggle-slider:before {
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
}

.import-options-container input:checked + .toggle-slider:before {
  transform: translateX(14px);
}

.import-preview-card-wrapper .card {
  border: none;
  box-shadow: none;
  padding: 0;
  background: transparent;
}

/* Export Preview Styles (similar to import preview) */
.export-preview-card-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--card-bg);
  padding: 12px;
}

.export-options-container {
  position: absolute;
  top: auto;
  bottom: 12px;
  left: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  padding: 10px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.export-options-container input[type="checkbox"] {
  margin-right: 5px;
  accent-color: var(--primary);
}

.export-options-container label {
  font-weight: 500;
  font-size: 13px;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.export-preview-card-wrapper .card {
  border: none;
  box-shadow: none;
  padding: 0;
  background: transparent;
}

/* ============================================
   DEVELOPMENT SPLASH
   ============================================ */
.dev-splash {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: #ffc107;
  color: #333;
  padding: 5px 15px;
  border-radius: 15px;
  font-size: 12px;
  font-weight: 700;
  z-index: 9999;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.dev-splash.fade-out {
  animation: devSplashFadeOut 0.5s ease-in forwards;
}

/* ============================================
   SEARCH & CLEAR BUTTON
   ============================================ */
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  flex-grow: 1;
}

.search-wrapper #textFilter {
  width: 100%;
  padding-right: 30px;
}

.clear-search-btn {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  padding: 0 10px;
}


/* ============================================
   SHEPHERD TOUR STYLES
   ============================================ */
.shepherd-element {
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  width: 340px;
  max-width: 90vw;
}

.shepherd-header {
  background-color: var(--primary);
  padding: 10px 15px;
  border-radius: 8px 8px 0 0;
}

.shepherd-title {
  font-weight: 700;
  font-size: 16px;
}

.shepherd-cancel-icon {
  color: rgba(255, 255, 255, 0.7);
}

.shepherd-text {
  padding: 15px;
  font-size: 14px;
  line-height: 1.5;
  color: #444;
}

.shepherd-button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

/* ============================================
   RESPONSIVE - MOBILE CARD LAYOUT
   ============================================ */
@media (max-width: 768px) {
  .card-top-section {
    flex-direction: row;
    gap: 12px;
    margin-bottom: 8px;
  }

  .card-image-container {
    flex: 0 0 45%;
    max-width: 45%;
    display: flex;
    flex-direction: column;
  }

  .card-image-container img {
    width: 100%;
    height: 100px;
    object-fit: contain;
    background: #fafafa;
    border-radius: 6px;
    margin-bottom: 0;
  }

  .card-details-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .card-details-container .card-header {
    margin-bottom: 6px;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 4px;
  }

  .card-details-container .card-header .colour-name {
    width: 100%;
    text-align: left;
  }

  .card-details-container .meta {
    margin-bottom: 0;
  }

  .card-details-container .meta br {
    display: inline;
  }

  .card-bottom-section {
    width: 100%;
  }

  .custom-supplier-badge {
    top: 4px;
    right: 4px;
  }

  .library-indicator-badge {
    top: 4px;
    left: 4px;
  }
}

/* ============================================
   RESPONSIVE - TABLET & MOBILE
   ============================================ */
@media (max-width: 999px) {
  .menu-toggle {
    display: block;
  }

  .sidebar {
    position: fixed;
    height: 100%;
    z-index: 999;
    transform: translateX(-100%);
    width: 280px;
    box-shadow: none;
    transition: transform 0.4s ease;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 10px 0 20px rgba(0, 0, 0, 0.1);
  }

  .overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 998;
  }

  .overlay.active {
    display: block;
  }

  .top-bar {
    gap: 8px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    transition: transform 0.3s ease-in-out;
  }

  .top-bar.hidden-on-scroll {
    transform: translateY(-100%);
  }

  .threemf-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    margin: 0;
    border-radius: 0;
    z-index: 9;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .threemf-banner.banner-below-topbar {
    top: var(--topbar-height, 0px);
  }

  .threemf-banner-row-1 {
    justify-content: space-between;
  }

  input[type="text"] {
    width: 100% !important;
    order: 10;
    margin-top: 5px;
  }

  body.sidebar-collapsed {
    padding-left: 0;
  }

  body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
  }

  #importCustomPreviewModal .modal-top-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color, #e1e1e1);
    z-index: 1001;
  }

  html[data-theme='dark'] #importCustomPreviewModal .modal-top-panel {
    background: rgba(44, 44, 44, 0.9);
  }

  #importCustomPreviewModal .modal-top-panel.hidden-on-scroll {
    transform: translateY(-100%);
  }
}

/* Bulk Text Import Styles */
.bulk-text-import-item {
  display: block;
}

.bulk-text-import-item input[type="checkbox"] {
  accent-color: var(--primary);
  cursor: pointer;
}

.badge-new {
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.badge-exists {
  background: var(--text-secondary);
  color: var(--card-bg);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

/* Top bar row wrapper */
.top-bar-row-1 {
  display: contents;
}

@media (max-width: 499px) {
  .top-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .top-bar-row-1 {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  #colourGroupFilter {
    flex-grow: 1;
  }

  .top-bar > * {
    width: 100%;
  }

  #textFilter {
    margin-top: 0;
    order: initial;
  }

}

@media (max-width: 450px) {
  .mobile-compact-toggle-container {
    display: flex;
  }
}

@media (min-width: 1000px) {
  .desktop-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Image Viewer Modal */
.image-viewer {
  display: none;
  position: fixed;
  z-index: 1100; /* Higher than compact card modal */
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.85);
  justify-content: center;
  align-items: center;
}
.image-viewer-content {
  margin: auto;
  display: block;
  max-width: 90%;
  max-height: 90vh;
}
@media (min-width: 900px) {
  .image-viewer-content {
    max-width: 800px;
    max-height: 800px;
  }
}
.close-viewer {
  position: absolute;
  top: 15px;
  right: 35px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  transition: 0.3s;
  cursor: pointer;
}
.close-viewer:hover, .close-viewer:focus { color: #bbb; }

body.mobile-compact-modal-open {
  overflow: hidden;
}

.mobile-compact-modal {
  position: fixed;
  inset: 0;
  z-index: 1002;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 8px;
}

.mobile-compact-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.mobile-compact-modal-panel {
  width: min(400px, calc(100% - 8px));
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  transform: translateY(16px);
  transition: transform 0.25s ease;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.25);
}

.mobile-compact-modal.active .mobile-compact-modal-panel {
  transform: translateY(0);
}

.mobile-compact-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color-light);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.mobile-compact-modal-close {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.mobile-compact-modal-card-host {
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 10px 12px 12px;
}

.mobile-compact-modal-card-host .card {
  max-width: 100%;
  margin: 0;
}

/* ============================================
   RESTOCK NOTIFICATION
   ============================================ */
.restock-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--card-bg);
  border: 1px solid var(--primary);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 16px 20px;
  z-index: 10000;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 350px;
  user-select: none;
}

.restock-notification.show {
  opacity: 1;
  transform: translateY(0);
}

.restock-notification:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.restock-notification-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.restock-notification-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}

.restock-notification-text {
  flex: 1;
}

.restock-notification-text strong {
  display: block;
  color: var(--text-primary);
  font-size: 15px;
  margin-bottom: 4px;
}

.restock-notification-text div {
  color: var(--text-secondary);
  font-size: 13px;
}

/* Mobile adjustments */
@media (max-width: 999px) {
  .restock-notification {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }
}

/* Sync Connectivity Warning */
.sync-connection-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(460px, calc(100% - 40px));
  background: #8b1f1f;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  z-index: 10001;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.sync-connection-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.sync-connection-toast-icon {
  font-size: 16px;
  line-height: 1.2;
  margin-top: 1px;
}

.sync-connection-toast-text {
  font-size: 12px;
  line-height: 1.45;
  font-weight: 600;
}

@media (max-width: 999px) {
  .sync-connection-toast {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
    padding: 10px 12px;
  }
}

/* ============================================
   FAQ / HELP MODAL STYLES
   ============================================ */
#helpModal {
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding-top: 12px;
  padding-bottom: 12px;
}

.help-modal-content {
  max-width: 900px;
  width: 95%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.help-modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

/* Help Navigation */
.help-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color-light);
  flex-shrink: 0;
}

.help-nav-btn {
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.help-nav-btn:hover {
  background: var(--card-bg);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.help-nav-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Help Content Area */
.help-content {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
  min-height: 0;
}

.help-section {
  display: none;
  animation: fadeIn 0.2s ease-in;
}

.help-section.active {
  display: block;
}

.help-section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 20px 0;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary);
}

/* Help Items */
.help-item {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color-light);
}

.help-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.help-item h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 10px 0;
}

.help-item p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  margin: 0 0 10px 0;
}

.help-item p:last-child {
  margin-bottom: 0;
}

.help-item em {
  color: var(--text-secondary);
  font-size: 13px;
}

/* Inline Badge Examples */
.help-badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  vertical-align: middle;
  margin: 0 2px;
}

.help-badge-stock {
  background: rgba(0, 174, 66, 0.1);
  border: 1px solid var(--primary);
  color: var(--primary);
}

.help-badge-oos {
  background: var(--input-bg);
  border: 1px solid var(--border-color-light);
  color: var(--text-secondary);
}

.help-status-pill {
  display: inline-block;
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  vertical-align: middle;
  margin: 0 2px;
}

.help-status-owned {
  background: var(--primary);
  color: white;
}

.help-status-wishlist {
  background: var(--wishlist);
  color: white;
}

.help-status-none {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-primary);
}

.help-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 11px;
  vertical-align: middle;
  margin: 0 2px;
}

.help-icon-btn-inactive {
  background: var(--input-bg);
  border: 1px solid var(--border-color-light);
  color: #ccc;
}

.help-icon-btn-toprint {
  background: #ff9800;
  color: white;
}

.help-icon-btn-loaded {
  background: #4caf50;
  color: white;
}

.help-icon-btn-buymore {
  background: var(--wishlist);
  color: white;
}

.help-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
  margin: 0 4px;
}

.help-dot-owned {
  background: var(--primary);
}

.help-dot-wishlist {
  background: var(--wishlist);
}

.help-dot-sync-grey {
  background: var(--text-secondary);
}

.help-dot-sync-green {
  background: var(--primary);
}

.help-dot-sync-red {
  background: var(--error);
}

/* Help Lists */
.help-list {
  list-style: none;
  padding: 0;
  margin: 10px 0;
}

.help-list li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
}

.help-list li:before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
}

.help-list li:last-child {
  margin-bottom: 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  #helpModal {
    padding-top: 0;
    padding-bottom: 0;
  }

  .help-modal-content {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .help-nav {
    gap: 6px;
    padding: 8px 0;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .help-nav::-webkit-scrollbar {
    display: none;
  }

  .help-nav-btn {
    padding: 6px 12px;
    font-size: 12px;
    flex-shrink: 0;
  }

  .help-section-title {
    font-size: 18px;
    margin-bottom: 16px;
  }

  .help-item {
    margin-bottom: 20px;
    padding-bottom: 16px;
  }

  .help-item h4 {
    font-size: 14px;
  }

  .help-item p,
  .help-list li {
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .help-nav-btn {
    padding: 5px 10px;
    font-size: 11px;
  }

  .help-modal-content .modal-header {
    font-size: 18px;
  }

  .help-modal-content .modal-footer {
    flex-direction: column;
    gap: 8px;
  }

  .help-modal-content .modal-footer .modal-btn {
    width: 100%;
  }
}

/* ============================================
   3MF LIBRARY STYLES
   ============================================ */

/* Library Toggle Button */
.library-toggle-btn {
  background: var(--bg);
  border: 1px solid var(--border-color);
  font-weight: 600;
}

.library-toggle-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Library Container */
.library-container {
  padding: 20px;
}

.library-mobile-controls {
  display: none;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.library-mobile-controls .btn-xs {
  flex: 1;
  height: 34px;
  font-weight: 600;
}

/* Library Filter Toolbar */
.library-filter-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.library-filter-select {
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-primary);
  cursor: pointer;
  min-width: 180px;
}

.library-filter-select:hover {
  border-color: var(--primary);
}

.library-filter-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 174, 66, 0.1);
}

.library-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.library-empty-icon {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.5;
}

.library-empty h3 {
  font-size: 20px;
  color: var(--text-primary);
  margin: 0 0 12px 0;
}

.library-empty p {
  margin: 0;
  font-size: 14px;
  max-width: 400px;
  margin: 0 auto;
}

/* Library Category */
.library-category {
  margin-bottom: 30px;
}

.library-category-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
}

.library-category.uncategorized .library-category-header {
  border-bottom-color: var(--text-secondary);
}

.library-category-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.library-category-count {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 10px;
}

/* Library Items Grid */
.library-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 16px;
}

/* Library Item Card */
.library-item-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
  transition: all 0.2s;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
}

.library-item-thumbnail {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  margin-bottom: 12px;
  background: var(--bg);
}

.library-item-thumbnail.library-item-thumbnail-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg) 86%, var(--text-primary) 14%);
}

.library-item-thumbnail.library-item-thumbnail-placeholder span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.library-item-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.library-item-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.library-item-card.status-ready {
  border-left: 4px solid var(--primary);
}

.library-item-card.status-partial {
  border-left: 4px solid var(--wishlist);
}

.library-item-card.status-missing {
  border-left: 4px solid var(--text-secondary);
}

.library-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.library-item-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  max-width: min(36ch, 100%);
  margin-right: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.library-item-meta {
  margin-bottom: 12px;
}

.library-item-filename {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-item-stats {
  display: flex;
  align-items: flex-start;
  margin-bottom: 12px;
}

.library-filament-indicators {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.library-filament-indicator {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 8px;
  border: 3px solid transparent;
  box-sizing: border-box;
  overflow: hidden;
  background-color: var(--bg);
}

.library-filament-indicator img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library-filament-indicator.indicator-owned {
  border-color: var(--primary);
}

.library-filament-indicator.indicator-wishlist {
  border-color: var(--wishlist);
}

.library-filament-indicator.indicator-unowned {
  border-color: var(--error);
}

.library-filament-indicator.indicator-missing {
  border-color: var(--text-secondary);
  opacity: 0.5;
}

.library-indicator-instock-tick {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  background: #4CAF50;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.library-indicator-loaded-badge {
  position: absolute;
  bottom: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #4CAF50;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.library-indicator-print-badge {
  position: absolute;
  bottom: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  margin-right: 0;
  border: none;
  cursor: default;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.library-indicator-print-badge svg {
  width: 11px;
  height: 11px;
}

.library-item-counts {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
}

.library-item-counts .count-owned {
  color: var(--primary);
}

.library-item-counts .count-wishlist {
  color: var(--wishlist);
}

.library-item-counts .count-total {
  color: var(--text-primary);
}

.library-item-counts .count-divider {
  color: var(--text-secondary);
}

.library-item-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: auto;
}

.library-status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
}

.library-status-badge.status-ready {
  background: rgba(0, 174, 66, 0.1);
  color: var(--primary);
}

.library-status-badge.status-partial {
  background: rgba(92, 154, 255, 0.1);
  color: var(--wishlist);
}

.library-status-badge.status-missing {
  background: var(--bg);
  color: var(--text-secondary);
}

/* Library Item Modal Filament List */
.library-filament-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  min-width: 0;
  max-width: 100%;
}

.library-filament-image {
  position: relative;
  width: clamp(70px, 24vw, 100px);
  height: clamp(70px, 24vw, 100px);
  border-radius: 8px;
  border: 3px solid transparent;
  flex-shrink: 0;
  overflow: hidden;
  background-color: var(--border-color);
}

.library-filament-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library-filament-image.indicator-owned {
  border-color: var(--primary);
}

.library-filament-image.indicator-wishlist {
  border-color: var(--wishlist);
}

.library-filament-image.indicator-unowned {
  border-color: var(--error);
}

.library-filament-image.indicator-missing {
  border-color: var(--text-secondary);
  opacity: 0.5;
}

.library-detail-instock-tick {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: #4CAF50;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Library View Toggle */
.library-view-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 3px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.library-view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.library-view-btn:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.library-view-btn.active {
  background: var(--primary);
  color: white;
}

/* Library Cards View Container */
.library-filaments-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 16px;
}

.library-filaments-cards .card {
  margin: 0;
  min-width: 0;
  max-width: 100%;
}

.library-filaments-cards .card img {
  height: clamp(100px, 34vw, 140px);
}

.library-filament-info {
  flex: 1;
  min-width: 0;
}

.library-filament-type {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

.library-filament-hex {
  font-size: 11px;
  color: var(--text-secondary);
}

.library-filament-selection {
  text-align: right;
  min-width: 0;
  max-width: 100%;
}

.library-filament-name {
  display: block;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-primary);
  margin-bottom: 2px;
  overflow-wrap: anywhere;
}

.library-filament-status {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 8px;
}

.library-filament-status.status-owned {
  background: var(--primary);
  color: white;
}

.library-filament-status.status-wishlist {
  background: var(--wishlist);
  color: white;
}

.library-filament-status.status-unowned {
  background: var(--text-secondary);
  color: white;
}

.library-filament-status.status-none {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.library-filament-instock {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  background: #4CAF50;
  color: white;
  margin-left: 4px;
  animation: pulse-stock 2s ease-in-out infinite;
}

.library-item-modal-thumbnail {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  cursor: zoom-in;
}

@keyframes pulse-stock {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* 3MF Selection Enhancements */
.threemf-banner-buttons {
  display: flex;
  gap: 8px;
}

.threemf-save-btn {
  background: rgba(255, 255, 255, 0.9) !important;
  color: var(--primary) !important;
  border-color: rgba(255, 255, 255, 0.9) !important;
  font-weight: 700 !important;
}

.threemf-save-btn:hover {
  background: white !important;
}

.threemf-filament-info {
  flex: 1;
}

.threemf-filament-title {
  font-weight: 600;
}

.threemf-selection {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  margin-left: auto;
  margin-right: 12px;
}

.threemf-selection.selection-owned {
  background: rgba(0, 174, 66, 0.1);
  border: 1px solid var(--primary);
}

.threemf-selection.selection-wishlist {
  background: rgba(92, 154, 255, 0.1);
  border: 1px solid var(--wishlist);
}

.threemf-selection.selection-unowned {
  background: rgba(211, 47, 47, 0.1);
  border: 1px solid var(--error);
}

.threemf-selection-name {
  font-weight: 600;
  font-size: 12px;
}

.threemf-selection-status {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 8px;
  color: white;
}

.selection-owned .threemf-selection-status {
  background: var(--primary);
}

.selection-wishlist .threemf-selection-status {
  background: var(--wishlist);
}

.selection-unowned .threemf-selection-status {
  background: var(--error);
}

.threemf-clear-selection {
  background: transparent !important;
  border: none !important;
  color: var(--text-secondary) !important;
  padding: 2px 6px !important;
  font-size: 14px !important;
  cursor: pointer;
}

.threemf-clear-selection:hover {
  color: var(--error) !important;
}

.threemf-no-selection {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
  margin-left: auto;
  margin-right: 12px;
}

/* 3MF Card Wrapper with Select Overlay */
.threemf-card-wrapper {
  position: relative;
  min-width: 260px;
  max-width: 300px;
  flex-shrink: 0;
}

.threemf-card-wrapper .card {
  margin: 0;
}

.threemf-select-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  padding: 30px 12px 12px 12px;
  border-radius: 0 0 10px 10px;
  display: flex;
  justify-content: center;
}

.threemf-select-overlay.selected {
  background: linear-gradient(transparent, rgba(0, 174, 66, 0.9));
}

.threemf-select-btn {
  background: white !important;
  color: #333333 !important;
  font-weight: 600 !important;
  padding: 8px 16px !important;
  border-radius: 6px !important;
}

.threemf-select-btn:hover {
  background: #f0f0f0 !important;
  color: #333333 !important;
}

.threemf-select-btn.selected {
  background: var(--primary) !important;
  color: white !important;
}

.threemf-select-btn.selected:hover {
  background: #009937 !important;
}

/* Library Save Toast */
.library-save-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--primary);
  color: white;
  padding: 16px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  z-index: 10000;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.library-save-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.library-save-toast-icon {
  font-size: 18px;
}

/* Save to Library Modal Summary */
.save-library-summary-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-color-light);
  font-size: 13px;
}

.save-library-summary-item:last-child {
  border-bottom: none;
}

.save-library-thumbnail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}

.save-library-thumbnail-btn {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
  text-align: left;
}

.save-library-thumbnail-btn:hover {
  border-color: var(--primary);
}

.save-library-thumbnail-btn.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(0, 174, 66, 0.3);
}

.save-library-thumbnail-btn img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
}

.save-library-thumbnail-label {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .library-items {
    grid-template-columns: 1fr;
  }

  .library-item-header {
    flex-direction: column;
    gap: 8px;
  }

  .library-item-actions {
    align-self: flex-end;
  }

  .library-item-name {
    max-width: min(28ch, 100%);
  }

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

  .threemf-selection {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .threemf-colour-header {
    flex-wrap: wrap;
  }
}

@media (max-width: 999px) {
  .library-mobile-controls {
    display: flex;
  }

  .library-save-toast {
    bottom: 10px;
    right: 10px;
    left: 10px;
  }
}

@media (max-width: 420px) {
  .library-container {
    padding: 12px;
  }

  .library-filter-toolbar {
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 12px;
  }

  .library-filter-select {
    min-width: 0;
    width: 100%;
  }

  .library-item-name {
    max-width: min(20ch, 100%);
  }

  .library-filament-row {
    gap: 10px;
    padding: 10px;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .library-filament-selection {
    width: 100%;
    text-align: left;
  }

  .library-filaments-cards {
    gap: 12px;
  }
}
