.history-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.vault-tabs {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  margin-bottom: 2rem;

  .tab-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;

    &:hover {
      background: rgba(255, 255, 255, 0.1);
      transform: translateY(-2px);
    }

    &.active {
      background: var(--accent-green);
      color: white;
      border-color: var(--accent-green);
      box-shadow: 0 4px 15px rgba(0, 166, 81, 0.3);
    }

    &.tab-disabled {
      opacity: 0.4;
      cursor: not-allowed;
      pointer-events: none;
      transform: none;
    }
  }
}

// Status dot inside the Cloud tab button
.nest-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;

  &.dot-live { background: #00a651; box-shadow: 0 0 5px rgba(0,166,81,0.7); }
  &.dot-off  { background: #dc3545; box-shadow: 0 0 5px rgba(220,53,69,0.6); }
}

// Offline warning banner below the tab row
.cloud-offline-banner {
  margin-bottom: 1.5rem;
  padding: 10px 16px;
  background: rgba(220, 53, 69, 0.1);
  border: 1px solid rgba(220, 53, 69, 0.35);
  border-radius: 8px;
  color: #f8a8ae;
  font-size: 0.82rem;
  font-weight: 600;
}

// Tab row: tabs on the left, Clear All button on the right
.vault-tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0; // cloud-offline-banner provides spacing when visible
}

// "Clear All" button — destructive, muted by default
.btn-clear-all {
  padding: 0.6rem 1.2rem;
  border-radius: 10px;
  border: 1px solid rgba(220, 53, 69, 0.4);
  background: rgba(220, 53, 69, 0.08);
  color: #f8a8ae;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;

  &:hover {
    background: rgba(220, 53, 69, 0.2);
    border-color: rgba(220, 53, 69, 0.7);
  }

  // Remote variant — slightly different label colour to hint at server-side impact
  &--remote {
    border-color: rgba(255, 152, 0, 0.4);
    background: rgba(255, 152, 0, 0.08);
    color: #ffcc80;

    &:hover {
      background: rgba(255, 152, 0, 0.2);
      border-color: rgba(255, 152, 0, 0.7);
    }
  }
}

// Card header: summary badges + expand chevron + delete button in a row
.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

// Per-item ✕ delete button
.btn-delete-item {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(220, 53, 69, 0.35);
  background: rgba(220, 53, 69, 0.06);
  color: #f8a8ae;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;

  &:hover {
    background: rgba(220, 53, 69, 0.25);
    border-color: rgba(220, 53, 69, 0.7);
    transform: scale(1.1);
  }
}

.badge {
  background: rgba(0, 166, 81, 0.1);
  color: #00A651;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  border: 1px solid rgba(0, 166, 81, 0.2);
  margin-right: 5px;
  font-weight: 600;
}

.history-item {
  background: var(--input-bg);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.3s ease;
  
  &:hover {
    border-color: var(--accent-green);
  }

  &.expanded {
    border-color: var(--accent-green);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    
    .expand-icon {
      transform: rotate(180deg);
    }
  }
}

.item-header {
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  background: transparent;
  transition: background 0.2s ease;
  
  &:hover {
    background: rgba(255, 255, 255, 0.02);
  }
}

.record-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  
  .record-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
  }
  
  .record-filename {
    font-size: 1.1rem;
    font-weight: 700;
  }
}

.summary-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.badge-item {
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--panel-color);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 600;
}

.record-meta {
  display: flex;
  gap: 24px;
  align-items: center;
  
  .meta-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: right;
    
    .meta-label {
      font-size: 0.65rem;
      text-transform: uppercase;
      font-weight: 700;
      color: var(--text-secondary);
    }
    
    .meta-value {
      font-weight: 600;
      color: var(--accent-gold);
    }
  }
}

.expand-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  .chevron {
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-secondary);
    border-bottom: 2px solid var(--text-secondary);
    transform: rotate(45deg);
    margin-top: -4px;
  }
}

.item-details {
  background: var(--panel-color);
  padding: 0 24px 24px 24px;
  border-top: 1px solid var(--border-color);
  animation: slideDown 0.3s ease-out;
}

.result-visualization {
  margin-top: 24px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  background: #000;
  
  .image-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    
    .result-img {
      display: block;
      width: 100%;
      height: auto;
      max-height: 500px;
      object-fit: contain;
    }
  }
}

.box-overlay {
  position: absolute;
  border: 3px solid #ff0000;
  pointer-events: none;
  
  &.ripe { border-color: #00ff00; }
  &.alert { border-color: #ff4444; }

  .box-label {
    position: absolute;
    top: -24px;
    left: -3px;
    background: inherit;
    color: white;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    border-radius: 3px 3px 0 0;
    
    // Fallback if background: inherit doesn't solve color
    background-color: inherit;
  }
  
  &.ripe { .box-label { background-color: #00ff00; color: #000; } }
  &.alert { .box-label { background-color: #ff4444; color: #fff; } }
}

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

// ── Batch Session Card ─────────────────────────────────────────────────────────
.batch-session-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-gold);
}

.batch-details {
  padding: 16px;
}

// ── Thumbnail Grid ─────────────────────────────────────────────────────────────
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.thumb-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s ease;

  &:hover { border-color: var(--accent-green); }
}

.thumb-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: #000;
  overflow: hidden;
}

.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-no-img {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.thumb-box {
  position: absolute;
  border-width: 2px;
  border-style: solid;
  pointer-events: none;
}

.thumb-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  flex-wrap: wrap;
}

.thumb-filename {
  font-size: 0.65rem;
  color: var(--text-secondary);
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 90px;
}

.thumb-count {
  font-size: 0.65rem;
  color: var(--accent-green);
  font-weight: 600;
  white-space: nowrap;
}
