/* Unified stat / summary cards — reference: Treatments / Patient Report */



.stats-grid,

.table-stats,

.stats-row {

  display: grid;

  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));

  gap: 16px;

  margin-top: 8px;

  margin-bottom: 16px;

}



.stat-card {

  background: #fff;

  border-radius: 12px;

  padding: 20px;

  border: 1px solid #e8ecf0;

  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);

  transition: border-color 0.2s, box-shadow 0.2s;

  display: flex;

  align-items: center;

  justify-content: space-between;

  gap: 16px;

  min-height: 96px;

  position: relative;

  overflow: hidden;

}



.stat-card:hover {

  border-color: #d8dee8;

  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);

}



.stat-card-body,

.stat-card > .stat-content {

  flex: 1;

  min-width: 0;

  display: flex;

  flex-direction: column;

  justify-content: center;

  gap: 4px;

}



.stat-card > .stat-content {

  flex-direction: column-reverse;

}



.stat-card .stat-value,

.stat-card .stat-content h3 {

  font-size: 32px;

  font-weight: 700;

  line-height: 1.1;

  margin: 0;

  color: #111827 !important;

}



.stat-card .stat-label,

.stat-card .stat-content p,

.stat-card .stat-card-title {

  font-size: 13px;

  font-weight: 500;

  color: #6b7280 !important;

  margin: 0;

  line-height: 1.35;

}



.stat-card .stat-content h3 {

  margin: 0;

}



.stat-card .stat-sublabel {

  font-size: 12px;

  color: #9ca3af;

  margin: 0;

  line-height: 1.3;

}



.stat-card-inner-header {

  display: none;

}



.stat-card .stat-icon {

  flex-shrink: 0;

  display: inline-flex;

  align-items: center;

  justify-content: center;

  width: 48px;

  height: 48px;

  border-radius: 10px;

  background: #eef2ff;

  color: #5b4efc;

  margin: 0;

  font-size: 0;

}



.stat-card .stat-icon .app-icon svg,

.stat-card .stat-icon > svg {

  width: 24px;

  height: 24px;

  stroke: currentColor;

}



.stat-card[data-tone="success"] .stat-icon,

.stat-card.tone-success .stat-icon {

  background: rgba(16, 185, 129, 0.12);

  color: #10b981;

}



.stat-card[data-tone="warning"] .stat-icon,

.stat-card.tone-warning .stat-icon {

  background: rgba(245, 158, 11, 0.14);

  color: #f59e0b;

}



.stat-card[data-tone="danger"] .stat-icon,

.stat-card.tone-danger .stat-icon {

  background: rgba(239, 68, 68, 0.12);

  color: #ef4444;

}



.stat-card[data-tone="info"] .stat-icon,

.stat-card.tone-info .stat-icon {

  background: #eef2ff;

  color: #5b4efc;

}



.stat-card.success::before,

.stat-card.danger::before,

.stat-card.warning::before,

.stat-card.info::before {

  display: none;

}



.stat-card.clickable {

  cursor: pointer;

}



.stat-card.clickable:hover {

  background: #fafbfc;

  border-color: #c7d2fe;

}



.stat-card.active-filter,

.stat-card.filter-active {

  border-color: #5b4efc;

  box-shadow: 0 0 0 1px #5b4efc;

  background: #f8faff;

}



/* Override legacy per-page inline stat rules (desktop only) */

@media (min-width: 769px) {

  body .stats-grid,

  body .stats-row,

  body .table-stats {

    margin-top: 8px;

    margin-bottom: 16px;

    gap: 16px;

  }



  body .stats-grid .stat-card,

  body .stats-row .stat-card,

  body .table-stats .stat-card {

    background: #fff !important;

    border: 1px solid #e8ecf0 !important;

    border-radius: 12px !important;

    padding: 20px !important;

    min-height: 96px !important;

    height: auto !important;

    display: flex !important;

    align-items: center !important;

    justify-content: space-between !important;

    gap: 16px !important;

    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06) !important;

    transform: none !important;

    overflow: hidden !important;

  }



  body .stats-grid .stat-card:hover,

  body .stats-row .stat-card:hover,

  body .table-stats .stat-card:hover {

    transform: none !important;

  }



  body .stats-grid .stat-card .stat-value,

  body .stats-row .stat-card .stat-value,

  body .table-stats .stat-card .stat-value,

  body .stats-grid .stat-card .stat-content h3,

  body .stats-row .stat-card .stat-content h3,

  body .table-stats .stat-card .stat-content h3 {

    font-size: 32px !important;

    font-weight: 700 !important;

    color: #111827 !important;

    margin: 0 !important;

    position: static !important;

  }



  body .stats-grid .stat-card .stat-icon,

  body .stats-row .stat-card .stat-icon,

  body .table-stats .stat-card .stat-icon {

    width: 48px !important;

    height: 48px !important;

    min-width: 48px !important;

    margin: 0 !important;

    margin-top: 0 !important;

    border-radius: 10px !important;

    background: #eef2ff !important;

    font-size: 0 !important;

  }



  body .stats-grid .stat-card[data-tone="warning"] .stat-icon,

  body .stats-row .stat-card[data-tone="warning"] .stat-icon,

  body .table-stats .stat-card[data-tone="warning"] .stat-icon {

    background: rgba(245, 158, 11, 0.14) !important;

    color: #f59e0b !important;

  }



  body .stats-grid .stat-card[data-tone="success"] .stat-icon,

  body .stats-row .stat-card[data-tone="success"] .stat-icon,

  body .table-stats .stat-card[data-tone="success"] .stat-icon {

    background: rgba(16, 185, 129, 0.12) !important;

    color: #10b981 !important;

  }



  body .stats-grid .stat-card[data-tone="danger"] .stat-icon,

  body .stats-row .stat-card[data-tone="danger"] .stat-icon,

  body .table-stats .stat-card[data-tone="danger"] .stat-icon {

    background: rgba(239, 68, 68, 0.12) !important;

    color: #ef4444 !important;

  }

}



/* Mobile: fixed 2-column grid, readable labels, no icon overlap */

@media (max-width: 768px) {

  body .stats-grid,

  body .stats-row,

  body .table-stats {

    display: grid !important;

    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;

    gap: 8px !important;

    margin-top: 6px !important;

    margin-bottom: 10px !important;

  }



  body .stats-grid .stat-card,

  body .stats-row .stat-card,

  body .table-stats .stat-card {

    display: flex !important;

    flex-direction: row !important;

    align-items: flex-start !important;

    justify-content: flex-start !important;

    gap: 8px !important;

    padding: 12px 10px !important;

    min-height: 78px !important;

    height: auto !important;

    overflow: visible !important;

    border-radius: 10px !important;

    transform: none !important;

    background: #fff !important;

    border: 1px solid #e8ecf0 !important;

    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06) !important;

  }



  body .stats-grid .stat-card:hover,

  body .stats-row .stat-card:hover,

  body .table-stats .stat-card:hover {

    transform: none !important;

  }



  body .stats-grid .stat-card-body,

  body .stats-row .stat-card-body,

  body .table-stats .stat-card-body,

  body .stats-grid .stat-card > .stat-content,

  body .stats-row .stat-card > .stat-content,

  body .table-stats .stat-card > .stat-content {

    flex: 1 1 auto !important;

    min-width: 0 !important;

    width: auto !important;

    gap: 3px !important;

    display: flex !important;

    flex-direction: column !important;

    justify-content: center !important;

  }



  body .stats-grid .stat-card > .stat-content,

  body .stats-row .stat-card > .stat-content,

  body .table-stats .stat-card > .stat-content {

    flex-direction: column-reverse !important;

  }



  body .stats-grid .stat-card .stat-value,

  body .stats-row .stat-card .stat-value,

  body .table-stats .stat-card .stat-value,

  body .stats-grid .stat-card .stat-content h3,

  body .stats-row .stat-card .stat-content h3,

  body .table-stats .stat-card .stat-content h3 {

    font-size: 22px !important;

    font-weight: 700 !important;

    line-height: 1.1 !important;

    position: static !important;

    margin: 0 !important;

    color: #111827 !important;

  }



  body .stats-grid .stat-card .stat-label,

  body .stats-row .stat-card .stat-label,

  body .table-stats .stat-card .stat-label,

  body .stats-grid .stat-card .stat-content p,

  body .stats-row .stat-card .stat-content p,

  body .table-stats .stat-card .stat-content p,

  body .stats-grid .stat-card .stat-card-title,

  body .stats-row .stat-card .stat-card-title,

  body .table-stats .stat-card .stat-card-title {

    font-size: 11px !important;

    line-height: 1.3 !important;

    white-space: normal !important;

    overflow: visible !important;

    text-overflow: clip !important;

    word-break: break-word !important;

    hyphens: auto !important;

    color: #6b7280 !important;

  }



  body .stats-grid .stat-card .stat-icon,

  body .stats-row .stat-card .stat-icon,

  body .table-stats .stat-card .stat-icon {

    flex: 0 0 34px !important;

    width: 34px !important;

    height: 34px !important;

    min-width: 34px !important;

    margin: 0 !important;

    margin-top: 0 !important;

    border-radius: 8px !important;

    align-self: flex-start !important;

    background: #eef2ff !important;

    font-size: 0 !important;

  }



  body .stats-grid .stat-card .stat-icon .app-icon svg,

  body .stats-row .stat-card .stat-icon .app-icon svg,

  body .table-stats .stat-card .stat-icon .app-icon svg,

  body .stats-grid .stat-card .stat-icon > svg,

  body .stats-row .stat-card .stat-icon > svg,

  body .table-stats .stat-card .stat-icon > svg {

    width: 16px !important;

    height: 16px !important;

  }



  body .stats-grid .stat-card[data-tone="warning"] .stat-icon,

  body .stats-row .stat-card[data-tone="warning"] .stat-icon,

  body .table-stats .stat-card[data-tone="warning"] .stat-icon {

    background: rgba(245, 158, 11, 0.14) !important;

    color: #f59e0b !important;

  }



  body .stats-grid .stat-card[data-tone="success"] .stat-icon,

  body .stats-row .stat-card[data-tone="success"] .stat-icon,

  body .table-stats .stat-card[data-tone="success"] .stat-icon {

    background: rgba(16, 185, 129, 0.12) !important;

    color: #10b981 !important;

  }



  body .stats-grid .stat-card[data-tone="danger"] .stat-icon,

  body .stats-row .stat-card[data-tone="danger"] .stat-icon,

  body .table-stats .stat-card[data-tone="danger"] .stat-icon {

    background: rgba(239, 68, 68, 0.12) !important;

    color: #ef4444 !important;

  }



  body .stats-grid .stat-card[data-tone="info"] .stat-icon,

  body .stats-row .stat-card[data-tone="info"] .stat-icon,

  body .table-stats .stat-card[data-tone="info"] .stat-icon {

    background: #eef2ff !important;

    color: #5b4efc !important;

  }



  /* 5th stat on its own row — half width, left aligned */

  body .stats-row .stat-card:last-child:nth-child(odd),

  body .stats-grid .stat-card:last-child:nth-child(odd),

  body .table-stats .stat-card:last-child:nth-child(odd) {

    grid-column: 1 / -1;

    max-width: calc(50% - 4px);

  }

}



@media (max-width: 400px) {

  body .stats-grid,

  body .stats-row,

  body .table-stats {

    gap: 6px !important;

  }



  body .stats-grid .stat-card,

  body .stats-row .stat-card,

  body .table-stats .stat-card {

    padding: 10px 8px !important;

    min-height: 72px !important;

    gap: 6px !important;

  }



  body .stats-grid .stat-card .stat-value,

  body .stats-row .stat-card .stat-value,

  body .table-stats .stat-card .stat-value,

  body .stats-grid .stat-card .stat-content h3,

  body .stats-row .stat-card .stat-content h3,

  body .table-stats .stat-card .stat-content h3 {

    font-size: 20px !important;

  }



  body .stats-grid .stat-card .stat-label,

  body .stats-row .stat-card .stat-label,

  body .table-stats .stat-card .stat-label,

  body .stats-grid .stat-card .stat-content p,

  body .stats-row .stat-card .stat-content p,

  body .table-stats .stat-card .stat-content p,

  body .stats-grid .stat-card .stat-card-title,

  body .stats-row .stat-card .stat-card-title,

  body .table-stats .stat-card .stat-card-title {

    font-size: 10px !important;

  }



  body .stats-grid .stat-card .stat-icon,

  body .stats-row .stat-card .stat-icon,

  body .table-stats .stat-card .stat-icon {

    flex: 0 0 30px !important;

    width: 30px !important;

    height: 30px !important;

    min-width: 30px !important;

  }



  body .stats-grid .stat-card .stat-icon .app-icon svg,

  body .stats-row .stat-card .stat-icon .app-icon svg,

  body .table-stats .stat-card .stat-icon .app-icon svg,

  body .stats-grid .stat-card .stat-icon > svg,

  body .stats-row .stat-card .stat-icon > svg,

  body .table-stats .stat-card .stat-icon > svg {

    width: 14px !important;

    height: 14px !important;

  }

}


