/* ========================================
   ENTERPRISE DESIGN SYSTEM
   Rafiki auction pricing and My Herd
   ======================================== */

/* ========================================
   CSS VARIABLES
   ======================================== */
:root {
  /* Navy Palette */
  --color-navy-dark: #1a365d;
  --color-navy-light: #2c5282;
  --color-blue-primary: #2563eb;
  --color-blue-hover: #1d4ed8;
  --color-blue-light: #3b82f6;

  /* Backgrounds */
  --color-bg-dark: #1e293b;
  --color-bg-card: #ffffff;
  --color-bg-light: #f1f5f9;
  --color-bg-alt: #f8fafc;
  --color-bg-hover: #e2e8f0;

  /* Text */
  --color-text-primary: #1e293b;
  --color-text-secondary: #475569;
  --color-text-muted: #64748b;
  --color-text-on-dark: #e2e8f0;
  --color-text-on-navy: #ffffff;

  /* Borders */
  --color-border: #e2e8f0;
  --color-border-light: #f1f5f9;

  /* Status Colors */
  --color-success: #16a34a;
  --color-success-bg: #dcfce7;
  --color-danger: #dc2626;
  --color-danger-bg: #fee2e2;
  --color-warning: #d97706;
  --color-warning-bg: #fef3c7;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 10px 15px rgba(0, 0, 0, 0.1);

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, Monaco, monospace;
  --letter-spacing-tight: -0.02em;
  --line-height: 1.7;
}

/* ========================================
   BASE STYLES
   ======================================== */
html,
body {
  background-color: var(--color-paper) !important;
  color: var(--color-text-primary);
  font-family: var(--font-family);
  line-height: var(--line-height);
}

/* Override Bulma's dark backgrounds */
.has-background-dark,
.has-background-grey-darker {
  background-color: var(--color-paper) !important;
}

/* ========================================
   ENTERPRISE NAVBAR
   ======================================== */
.enterprise-navbar {
  background: var(--color-bg-card) !important;
  box-shadow: none;
  border-bottom: 1px solid var(--color-border);
  padding: 0.25rem 0;
}

.enterprise-navbar .navbar-brand .navbar-item {
  color: var(--color-ink) !important;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: var(--letter-spacing-tight);
}

.enterprise-navbar .navbar-brand .navbar-item::after {
  display: none;
}

.enterprise-navbar .navbar-item {
  color: var(--color-text-primary) !important;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.75rem 1rem;
  position: relative;
  transition: var(--transition);
}

.enterprise-navbar .navbar-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--color-blue-primary);
  transition: var(--transition);
  transform: translateX(-50%);
}

.enterprise-navbar .navbar-item:hover {
  color: var(--color-ink) !important;
  background: var(--color-bg-hover) !important;
}

.enterprise-navbar .navbar-item:hover::after {
  width: calc(100% - 2rem);
}

.enterprise-navbar .navbar-item.is-active {
  color: var(--color-blue-primary) !important;
  background: transparent !important;
}

.enterprise-navbar .navbar-item.is-active::after {
  width: calc(100% - 2rem);
  background: var(--color-blue-primary);
}

.enterprise-navbar .navbar-burger {
  color: var(--color-ink);
}

/* ========================================
   SECTION STYLING
   ======================================== */
.section {
  background-color: transparent;
  padding: 2rem 1.5rem;
}

/* ========================================
   ENTERPRISE CARDS
   ======================================== */
.enterprise-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
}

.enterprise-card-header {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.enterprise-card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-navy-dark);
  letter-spacing: var(--letter-spacing-tight);
  margin: 0;
}

.enterprise-card-subtitle {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* ========================================
   ENTERPRISE TABLES
   ======================================== */
.enterprise-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.enterprise-table thead {
  background: linear-gradient(135deg, var(--color-navy-dark) 0%, var(--color-navy-light) 100%);
}

.enterprise-table th {
  color: var(--color-text-on-navy) !important;
  font-weight: 600;
  text-align: left;
  padding: 0.875rem 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: none !important;
  background: transparent !important;
}

.auction-age-missing {
  display: block;
  color: var(--color-text-muted);
  font-style: italic;
}

.auction-age-cue {
  display: block;
  margin-top: 2px;
  font-size: 0.75rem;
  font-style: italic;
  color: var(--color-text-muted);
}

.enterprise-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-primary);
  background: var(--color-bg-card) !important;
}

.enterprise-table tbody tr:nth-child(even) td {
  background: var(--color-bg-alt) !important;
}

.enterprise-table tbody tr:hover td {
  background: var(--color-bg-hover) !important;
}

.enterprise-table tbody tr:last-child td {
  border-bottom: none;
}

/* Sortable columns */
.enterprise-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}

.enterprise-table th.sortable:hover {
  background: rgba(255, 255, 255, 0.1) !important;
}

.enterprise-table th.sorted-asc::after {
  content: ' \25B2';
  font-size: 0.7em;
  opacity: 0.8;
}

.enterprise-table th.sorted-desc::after {
  content: ' \25BC';
  font-size: 0.7em;
  opacity: 0.8;
}

/* Table totals row */
.enterprise-table .totals-row td {
  font-weight: 600;
  background: var(--color-bg-light) !important;
  border-top: 2px solid var(--color-navy-dark);
  color: var(--color-navy-dark);
}

/* Numeric alignment */
.guide-window-empty-cell {
  text-align: center;
  padding: 1.5rem 1rem;
  color: #64748b;
  font-weight: 500;
}

.enterprise-table td.text-right,
.enterprise-table th.text-right {
  text-align: right;
}

/* 24-Month Price Change Badges (FIFO #9) */
.price-change-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
  white-space: nowrap;
}

.price-change-badge.price-up {
  color: var(--color-delta-up, #2e7d32);
  background-color: var(--color-delta-up-bg, rgba(46, 125, 50, 0.12));
}

.price-change-badge.price-down {
  color: var(--color-delta-down, #dc2626);
  background-color: var(--color-delta-down-bg, rgba(220, 38, 38, 0.1));
}

.price-change-badge.price-flat {
  color: var(--color-text-muted);
  background-color: rgba(107, 114, 128, 0.1);
}

.price-stale-mark {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2;
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
  vertical-align: middle;
  color: #9a3412;
  background-color: rgba(234, 88, 12, 0.14);
}

.price-change-badge.price-na {
  color: var(--color-text-muted);
  background-color: rgba(107, 114, 128, 0.05);
  font-size: 0.65rem;
}

/* ========================================
   ENTERPRISE BUTTONS
   ======================================== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: linear-gradient(135deg, var(--color-blue-primary) 0%, var(--color-blue-hover) 100%);
  color: var(--color-text-on-navy) !important;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--color-blue-hover) 0%, #1e40af 100%);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
  color: var(--color-text-on-navy) !important;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: var(--color-bg-card);
  color: var(--color-text-primary) !important;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-secondary:hover {
  background: var(--color-bg-light);
  border-color: var(--color-text-muted);
  transform: translateY(-1px);
  color: var(--color-text-primary) !important;
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: linear-gradient(135deg, var(--color-danger) 0%, #b91c1c 100%);
  color: var(--color-text-on-navy) !important;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-success {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: linear-gradient(135deg, var(--color-success) 0%, #15803d 100%);
  color: var(--color-text-on-navy) !important;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-success:hover {
  background: linear-gradient(135deg, #15803d 0%, #166534 100%);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

/* Small buttons */
.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
}

/* Button groups */
.btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ========================================
   ENTERPRISE FORMS
   ======================================== */
.enterprise-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
}

.enterprise-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--color-bg-card) !important;
  color: var(--color-text-primary) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  transition: var(--transition);
}

.enterprise-input:focus {
  outline: none;
  border-color: var(--color-blue-primary) !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.enterprise-input::placeholder {
  color: var(--color-text-muted);
}

/* Select styling */
.enterprise-select {
  width: 100%;
  padding: 0.625rem 2rem 0.625rem 0.875rem;
  background: var(--color-bg-card) !important;
  color: var(--color-text-primary) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23475569' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}

.enterprise-select:focus {
  outline: none;
  border-color: var(--color-blue-primary) !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Textarea */
.enterprise-textarea {
  width: 100%;
  min-height: 100px;
  padding: 0.75rem;
  background: var(--color-bg-card) !important;
  color: var(--color-text-primary) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  transition: var(--transition);
}

.enterprise-textarea:focus {
  outline: none;
  border-color: var(--color-blue-primary) !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Form groups */
.form-group {
  margin-bottom: 1.25rem;
}

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-row > * {
  flex: 1;
  min-width: 200px;
}

/* ========================================
   PAGE TITLES
   ======================================== */
.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-navy-dark);
  letter-spacing: var(--letter-spacing-tight);
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 3px solid var(--color-blue-primary);
}

.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-navy-light);
  margin: 2rem 0 1rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

/* ========================================
   TOOLTIPS (Bulma enhancement)
   ======================================== */
[data-tooltip]::before {
  background: var(--color-bg-dark);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
}

/* ========================================
   STATUS INDICATORS
   ======================================== */
.status-positive {
  color: var(--color-delta-up, #2e7d32);
  font-weight: 600;
}

.status-negative {
  color: var(--color-delta-down, #dc2626);
  font-weight: 600;
}

.status-neutral {
  color: var(--color-text-muted);
}

/* ========================================
   LOADING STATES
   ======================================== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-blue-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* ========================================
   MODAL ENHANCEMENTS
   ======================================== */
.modal-card {
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.modal-card-head {
  background: linear-gradient(135deg, var(--color-navy-dark) 0%, var(--color-navy-light) 100%);
  border-bottom: none;
  padding: 1.25rem 1.5rem;
}

.modal-card-title {
  color: var(--color-text-on-navy) !important;
  font-weight: 600;
  font-size: 1.1rem;
}

.modal-card-body {
  background: var(--color-bg-card);
  padding: 1.5rem;
}

.modal-card-foot {
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  padding: 1rem 1.5rem;
}

/* ========================================
   ALERTS & MESSAGES
   ======================================== */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.alert-info {
  background: #eff6ff;
  border-left: 4px solid var(--color-blue-primary);
  color: #1e40af;
}

.alert-success {
  background: var(--color-success-bg);
  border-left: 4px solid var(--color-success);
  color: #15803d;
}

.alert-warning {
  background: var(--color-warning-bg);
  border-left: 4px solid var(--color-warning);
  color: #92400e;
}

.alert-danger {
  background: var(--color-danger-bg);
  border-left: 4px solid var(--color-danger);
  color: #991b1b;
}

/* ========================================
   PROGRESS BAR
   ======================================== */
.enterprise-progress {
  height: 8px;
  background: var(--color-border);
  border-radius: 4px;
  overflow: hidden;
}

.enterprise-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-blue-primary), var(--color-blue-light));
  transition: width 0.3s ease;
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
  body {
    background: white !important;
  }

  .enterprise-navbar,
  .no-print {
    display: none !important;
  }

  .enterprise-card {
    box-shadow: none;
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }

  .enterprise-table {
    box-shadow: none;
  }

  .enterprise-table thead {
    background: var(--color-navy-dark) !important;
  }

  .enterprise-table th {
    color: white !important;
  }

  .page-break-before {
    page-break-before: always;
  }

  .page-break-after {
    page-break-after: always;
  }
}

/* ========================================
   NESTED TABLE ENHANCEMENTS
   Ensure breakdown and detail tables inherit styling
   ======================================== */
.breakdown-table.enterprise-table,
.detail-table.enterprise-table {
  box-shadow: var(--shadow-sm);
}

.breakdown-table.enterprise-table thead,
.detail-table.enterprise-table thead {
  background: linear-gradient(135deg, var(--color-navy-dark) 0%, var(--color-navy-light) 100%);
}

.breakdown-table.enterprise-table th,
.detail-table.enterprise-table th {
  color: var(--color-text-on-navy) !important;
}

.breakdown-table.enterprise-table tbody tr:nth-child(even) td,
.detail-table.enterprise-table tbody tr:nth-child(even) td {
  background: var(--color-bg-alt) !important;
}

.breakdown-table.enterprise-table tbody tr:hover td,
.detail-table.enterprise-table tbody tr:hover td {
  background: var(--color-bg-hover) !important;
}

/* Expand arrow consistency */
.expand-arrow,
.expand-arrow-detail {
  cursor: pointer;
  transition: transform 0.2s;
  user-select: none;
  display: inline-block;
}

.expand-arrow.expanded,
.expand-arrow-detail.expanded {
  transform: rotate(90deg);
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 1.5rem !important; }
.mb-4 { margin-bottom: 2rem !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mt-3 { margin-top: 1.5rem !important; }
.mt-4 { margin-top: 2rem !important; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--color-text-muted); }
.text-navy { color: var(--color-navy-dark); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-end { display: flex; justify-content: flex-end; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Filter panel (dark) */
.filter-panel {
  background: var(--color-bg-dark);
  color: var(--color-text-on-dark);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.filter-panel .enterprise-label {
  color: #94a3b8;
}

.filter-panel .enterprise-input,
.filter-panel .enterprise-select {
  background: #334155 !important;
  border-color: #475569 !important;
  color: var(--color-text-on-dark) !important;
}

.filter-panel .enterprise-input:focus,
.filter-panel .enterprise-select:focus {
  border-color: var(--color-blue-light) !important;
}

/* ========================================
   AUCTION SUMMARY PANEL
   ======================================== */
.auction-summary-panel {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Stat Cards Grid */
.summary-grid {
  display: grid;
  /* 280px fits a $14,231,050.00 stat value beside its icon; min() lets a phone go one column */
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.summary-grid:last-child {
  margin-bottom: 0;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(135deg, var(--color-bg-alt) 0%, var(--color-bg-light) 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-blue-light);
}

.stat-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-navy-dark) 0%, var(--color-navy-light) 100%);
  border-radius: var(--radius-md);
  color: var(--color-text-on-navy);
  font-size: 1.5rem;
}

.stat-content {
  flex: 1;
  min-width: 0;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-ink, #1a1a1a);
  line-height: 1.2;
}

.stat-value-sm {
  font-size: 1.1rem;
}

/* Composition Section */
.composition-section {
  border-top: 2px solid var(--color-border);
  padding-top: 1.5rem;
  margin-top: 1.5rem;
}

.composition-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, var(--color-bg-light) 0%, var(--color-bg-alt) 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.composition-toggle:hover {
  background: linear-gradient(135deg, var(--color-bg-alt) 0%, var(--color-border) 100%);
  border-color: var(--color-blue-light);
}

.composition-content {
  padding-top: 1.5rem;
}

.composition-subtitle {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-navy-light);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.composition-table {
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}

.composition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.composition-breakdown {
  background: var(--color-bg-alt);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.breakdown-bars {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.breakdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.breakdown-label {
  flex: 0 0 80px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.breakdown-bar-container {
  flex: 1;
  height: 24px;
  background: var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.breakdown-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-blue-primary), var(--color-blue-light));
  border-radius: var(--radius-sm);
  transition: width 0.3s ease;
}

.breakdown-value {
  flex: 0 0 100px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-primary);
  text-align: right;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .stat-card {
    flex-direction: column;
    text-align: center;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }

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

/* ========================================
   AUTO-REFRESH FILTER PANEL
   ======================================== */

/* Filter Count Badge */
.filter-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: linear-gradient(135deg, var(--color-blue-primary) 0%, var(--color-blue-hover) 100%);
  color: var(--color-text-on-navy);
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 10px;
  margin-left: 0.5rem;
  animation: badgePop 0.3s ease-out;
}

.filter-count-badge.hidden {
  display: none;
}

@keyframes badgePop {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

/* Active Filters Container */
.active-filters-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 0;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.active-filters-container:empty {
  display: none;
}

.active-filters-container.hidden {
  display: none;
}

/* Filter Chips */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.625rem;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  color: var(--color-text-on-dark);
  animation: chipSlideIn 0.2s ease-out;
}

.filter-chip .chip-label {
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.03em;
}

.filter-chip .chip-value {
  font-weight: 600;
}

.filter-chip .chip-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  color: var(--color-text-on-dark);
  font-size: 0.7rem;
  cursor: pointer;
  transition: var(--transition-fast);
  padding: 0;
  line-height: 1;
}

.filter-chip .chip-remove:hover {
  background: rgba(220, 38, 38, 0.8);
}

@keyframes chipSlideIn {
  0% { transform: translateX(-10px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

/* Clear All Filters Button */
.btn-clear-filters {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.375rem 0.75rem;
  background: transparent;
  color: #94a3b8;
  border: 1px dashed rgba(148, 163, 184, 0.5);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-clear-filters:hover {
  color: var(--color-text-on-dark);
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.05);
}

.btn-clear-filters.hidden {
  display: none;
}

/* Results Container Loading State */
.results-container {
  position: relative;
  overflow-x: auto; /* wide tables scroll inside, never the page (iPad portrait) */
  transition: opacity 0.2s ease;
}

.results-container.is-loading {
  opacity: 0.5;
  pointer-events: none;
}

/* Filter Loading Overlay */
.filter-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.filter-loading-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.filter-loading-overlay .loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-blue-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Summary Container for AJAX Updates */
.summary-container {
  transition: opacity 0.2s ease;
}

.summary-container.is-loading {
  opacity: 0.5;
}

/* Filter Panel Header with Badge */
.filter-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.filter-panel-title {
  display: flex;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

/* Auto-refresh indicator */
.auto-refresh-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: rgba(148, 163, 184, 0.7);
  font-weight: 500;
}

.auto-refresh-indicator i {
  font-size: 0.65rem;
}

/* Skeleton shimmer for loading placeholders */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-bg-alt) 25%,
    var(--color-border) 50%,
    var(--color-bg-alt) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-row {
  height: 48px;
  margin-bottom: 4px;
}

/* Results count display */
.results-count {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.results-count strong {
  color: var(--color-navy-dark);
  font-weight: 600;
}

/* ========================================
   COLUMN TOGGLE SECTION
   ======================================== */

/* Column Toggle Container */
.column-toggle-section {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 1rem;
  margin-top: 1rem;
}

/* Column Toggle Header (Clickable) */
.column-toggle-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: var(--color-text-on-dark);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.column-toggle-header:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.column-toggle-header i:first-child {
  margin-right: 0.5rem;
}

.column-toggle-header .toggle-icon {
  margin-left: auto;
  font-size: 0.75rem;
  opacity: 0.7;
  transition: transform var(--transition);
}

/* Column Toggle Content */
.column-toggle-content {
  padding: 1rem 0.5rem 0.5rem 0.5rem;
}

/* Checkbox Grid Layout */
.column-checkbox-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .column-checkbox-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Individual Checkbox Items */
.column-checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: var(--color-text-on-dark);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.column-checkbox-item:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.column-checkbox-item input[type="checkbox"] {
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

.column-checkbox-item span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Optional Column Styling */
.optional-column {
  /* Columns are hidden by default via inline style */
  /* Additional styling can be added here if needed */
}

/* Mobile: Add scroll shadow indicators */
@media (max-width: 768px) {
  .results-container {
    background:
      linear-gradient(90deg, var(--color-bg-card) 30%, rgba(255,255,255,0)),
      linear-gradient(90deg, rgba(255,255,255,0), var(--color-bg-card) 70%) 100% 0,
      radial-gradient(farthest-side at 0% 50%, rgba(0,0,0,.2), rgba(0,0,0,0)),
      radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.2), rgba(0,0,0,0)) 100% 0;
    background-repeat: no-repeat;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
  }
}

/* =============================================================================
 * Price History Sparkline (FIFO #10)
 * Inline sparkline showing median price trend over time in auction guide
 * ============================================================================= */

.median-cell-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.median-value,
.hammer-amount,
.enterprise-table td.hammer-amount {
    font-weight: 500;
    color: var(--color-ink, #1a1a1a);
}

.price-history-sparkline {
    width: 60px;
    height: 16px;
    color: #3498db;
    margin-top: 2px;
}

.price-history-sparkline.price-history-with-axis {
    width: 80px;
    height: 20px;
}

.price-history-sparkline .price-axis-label {
    font-size: 6px;
    fill: #6b7280;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.price-history-sparkline .price-axis-line {
    stroke: #d1d5db;
}

/* Color code sparklines based on trend */
.main-row:has(.price-up) .price-history-sparkline {
    color: var(--color-delta-up, #2e7d32);
}

.main-row:has(.price-down) .price-history-sparkline {
    color: var(--color-delta-down, #dc2626);
}

.main-row:has(.price-flat) .price-history-sparkline {
    color: #95a5a6;
}

/* =============================================================================
 * BUILD VERSION DISPLAY
 * Tiny muted text showing git SHA at bottom of page.
 * ============================================================================= */

.build-version {
    text-align: center;
    font-size: 11px;
    color: #999;
    padding: 16px 8px;
    margin-top: 24px;
    opacity: 0.6;
    letter-spacing: 0.02em;
}

/* Sire-horn gold/silver on the desktop My Herd pedigree cell.
   The SVG is the same medal the pocket price table uses.
   Nowrap keeps the medal on the tier-name line so the row does not grow. */
td.pedigree_tier {
    white-space: nowrap;
    vertical-align: middle;
}

td.pedigree_tier .pocket-pedigree-rank {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 4px;
    vertical-align: -3px;
}
