/* ============================================
   EXPENSES PAGE KPI OVERRIDE
   Fixes KPI card layout to display 3 cards per row on desktop
   ============================================ */

/* Extra Large Desktop: 4 columns (1920px+) */
@media (min-width: 1920px) {
  .kpi-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
    width: 100%;
    box-sizing: border-box;
  }
}

/* Large Desktop: 3 columns (1200px - 1919px) - CENTERED */
@media (min-width: 1200px) and (max-width: 1919px) {
  .kpi-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    width: 100%;
    box-sizing: border-box;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    justify-content: center;
  }
}

/* Desktop: 3 columns (1025px - 1199px) */
@media (min-width: 1025px) and (max-width: 1199px) {
  .kpi-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
    width: 100%;
    box-sizing: border-box;
  }
}

/* Tablet: 3 columns (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .kpi-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
    width: 100%;
    box-sizing: border-box;
  }
}

/* Mobile: 3 columns (max 768px) */
@media (max-width: 768px) {
  .kpi-summary {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
  }
}

/* ============================================
   KPI CARD - VERTICAL LAYOUT
   ============================================ */

.kpi-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0.5rem;
  background: white;
  border: 2px solid #4A90E2;
  border-radius: 12px;
  padding: 1.25rem;
  transition: all 0.3s ease;
  width: 100%;
  box-sizing: border-box;
  min-height: auto;
  height: auto;
  text-align: left;
  overflow: visible;
  min-width: 0;
}

.kpi-card:hover {
  border-color: #00CED1;
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.15);
  transform: translateY(-2px);
}

.kpi-card.kpi-expense {
  border-color: #E74C3C;
  background: linear-gradient(135deg, #fff5f5 0%, #fff 100%);
}

.kpi-card.kpi-expense:hover {
  border-color: #C0392B;
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.15);
}

.kpi-card.kpi-income {
  border-color: #27AE60;
  background: linear-gradient(135deg, #f0fff4 0%, #fff 100%);
}

.kpi-card.kpi-income:hover {
  border-color: #1E8449;
  box-shadow: 0 4px 12px rgba(39, 174, 96, 0.15);
}

/* ============================================
   KPI HEADER - ICON AND LABEL
   ============================================ */

.kpi-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  width: 100%;
}

/* ============================================
   KPI ICON - FIXED SIZE
   ============================================ */

.kpi-icon {
  font-size: 2rem;
  width: 50px;
  height: 50px;
  min-width: 50px;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4A90E2 0%, #00CED1 100%);
  border-radius: 10px;
  flex-shrink: 0;
  flex-grow: 0;
  margin: 0;
  padding: 0;
}

.kpi-card.kpi-expense .kpi-icon {
  background: linear-gradient(135deg, #E74C3C 0%, #C0392B 100%);
}

.kpi-card.kpi-income .kpi-icon {
  background: linear-gradient(135deg, #27AE60 0%, #2ECC71 100%);
}

/* ============================================
   KPI LABEL - TITLE
   ============================================ */

.kpi-label {
  font-size: 0.8rem;
  color: #7F8C8D;
  margin: 0;
  padding: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* ============================================
   KPI CONTENT - VALUE CONTAINER
   ============================================ */

.kpi-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
  min-width: 0;
  margin: 0;
  padding: 0;
}

/* ============================================
   KPI VALUE - LARGE DISPLAY
   ============================================ */

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #2C3E50;
  margin: 0;
  padding: 0;
  text-align: left;
  word-break: break-word;
  overflow-wrap: break-word;
  width: 100%;
  display: block;
}

/* ============================================
   TABLET LAYOUT (769px - 1024px)
   ============================================ */

@media (min-width: 769px) and (max-width: 1024px) {
  .kpi-card {
    flex-direction: column;
    text-align: center;
    align-items: center;
    justify-content: center;
  }

  .kpi-header {
    justify-content: center;
    width: 100%;
  }

  .kpi-content {
    text-align: center;
  }

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

  .kpi-value {
    text-align: center;
  }
}

/* ============================================
   MOBILE LAYOUT (max 768px)
   ============================================ */

@media (max-width: 768px) {
  .kpi-summary {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  .kpi-card {
    flex-direction: column;
    text-align: center;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    gap: 0.5rem;
  }

  .kpi-header {
    justify-content: center;
    width: 100%;
  }

  .kpi-content {
    text-align: center;
  }

  .kpi-label {
    text-align: center;
    font-size: 0.65rem;
  }

  .kpi-value {
    text-align: center;
    font-size: 1rem;
  }

  .kpi-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 1.5rem;
  }
}

/* ============================================
   SMALL MOBILE (max 480px)
   ============================================ */

@media (max-width: 480px) {
  .kpi-summary {
    gap: 0.4rem;
    margin-bottom: 0.75rem;
  }

  .kpi-card {
    padding: 0.5rem;
    gap: 0.25rem;
  }

  .kpi-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    font-size: 1.25rem;
    border-radius: 8px;
  }

  .kpi-label {
    font-size: 0.55rem;
  }

  .kpi-value {
    font-size: 0.85rem;
  }
}
