.header-usage-badge {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 10px;
  background: #ffffff;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  min-width: 180px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: all 0.2s ease;
  position: relative;
}

.header-usage-badge:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  border-color: #d1d5db;
}

.header-usage-badge .badge-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
}

.header-usage-badge .totals {
  font-weight: 600;
}

.header-usage-badge .progress-bar {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.header-usage-badge .progress-inner {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #0ea5e9);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.header-usage-badge .alert-badge {
  font-size: 11px;
  color: #dc2626;
  font-weight: 600;
}

/* Billing source selector dropdown in badge */
.billing-source-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: #3b82f6;
  background-image: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' 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, no-repeat;
  background-position: center, right 6px center;
  background-size: 100% 100%, auto;
  color: #ffffff !important;
  border: none;
  border-radius: 4px;
  padding: 4px 24px 4px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  min-width: 110px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

.billing-source-select:hover {
  background-color: #2563eb;
  background-image: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' 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");
}

.billing-source-select:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}

/* Credits selection - green color */
.billing-source-select.billing-source-credits {
  background-color: #10b981;
  background-image: linear-gradient(135deg, #10b981 0%, #059669 100%), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' 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");
}

.billing-source-select.billing-source-credits:hover {
  background-color: #059669;
  background-image: linear-gradient(135deg, #059669 0%, #047857 100%), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' 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");
}

.billing-source-select.billing-source-credits:focus {
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4);
}

.billing-source-select option {
  background: white;
  color: #1e293b;
  padding: 8px;
}

.usage-dropdown {
  position: fixed;
  /* left and top are set dynamically by JavaScript */
  width: 380px;
  max-height: 70vh;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.2);
  z-index: 999999;  /* Increased to ensure it's always on top */
  padding: 12px;
  display: none;
}

.usage-dropdown.visible {
  display: block;
  animation: slideDown 160ms ease;
}

.usage-dropdown-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e5e7eb;
}

.dropdown-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  line-height: 1.3;
}

.dropdown-subtitle {
  margin: 4px 0 0 0;
  font-size: 13px;
  color: #6b7280;
  line-height: 1.4;
}

.usage-dropdown .close-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6b7280;
  line-height: 1;
  padding: 0;
  margin-left: 12px;
  transition: color 0.2s ease;
}

.usage-dropdown .close-btn:hover {
  color: #1f2937;
}

.apps-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.app-usage-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

.app-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.green { background: #10b981; }
.status-dot.blue { background: #3b82f6; }
.status-dot.gray { background: #94a3b8; }

.subscription-info,
.credits-info {
  font-size: 13px;
  margin-bottom: 6px;
}

.app-usage-card progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
}

.app-usage-card progress::-webkit-progress-bar {
  background: #e2e8f0;
}

.app-usage-card progress::-webkit-progress-value {
  background: linear-gradient(90deg, #10b981, #0ea5e9);
}

.app-usage-card .actions {
  display: flex;
  gap: 6px;
}

.hidden {
  display: none !important;
}

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

@media (max-width: 768px) {
  .usage-dropdown {
    left: 12px !important;
    right: 12px;
    width: auto !important;
    max-height: 80vh;
  }
}

/* ============================================================================
   APP DETAILS MODAL
   ========================================================================= */

.app-details-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000000;  /* Highest z-index for modal overlay */
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-details-modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  width: 700px;
  max-width: 90vw;
  max-height: 90vh;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow-y: auto;
  z-index: 1;
}

/* Modal Header */
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px;
  border-bottom: 2px solid #e5e7eb;
  background: #f9fafb;
}

.modal-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #1f2937;
}

.modal-subtitle {
  margin: 4px 0 0 0;
  font-size: 14px;
  color: #6b7280;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: #6b7280;
  line-height: 1;
  padding: 0;
  margin-left: 16px;
  transition: color 0.2s ease;
}

.modal-close-btn:hover {
  color: #1f2937;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 24px;
  background: #ffffff;
}

.metric-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.metric-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 4px;
}

.metric-value.success-high {
  color: #10b981;
}

.metric-value.success-medium {
  color: #f59e0b;
}

.metric-value.success-low {
  color: #ef4444;
}

.metric-label {
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-sublabel {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 4px;
}

/* Chart Section */
.chart-section {
  padding: 24px;
  border-top: 1px solid #e5e7eb;
}

.chart-section h4 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

#usage-chart {
  width: 100%;
  height: 200px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
}

/* Operations Table */
.operations-section {
  padding: 24px;
  border-top: 1px solid #e5e7eb;
}

.operations-section h4 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

.operations-table-container {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.operations-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.operations-table thead {
  background: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 1;
}

.operations-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: #1f2937;
  border-bottom: 2px solid #e5e7eb;
}

.operations-table td {
  padding: 12px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
}

.operations-table tr:hover {
  background: #f9fafb;
}

.operations-table td.loading {
  text-align: center;
  color: #6b7280;
  font-style: italic;
  padding: 24px;
}

.status-icon {
  font-size: 16px;
}

/* Modal Actions */
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 24px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
}

/* REMOVED: Duplicate Button Styles - now in components.css */

/* Responsive */
@media (max-width: 768px) {
  .modal-content {
    width: 95vw;
    max-height: 95vh;
  }

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

  .modal-actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}
