* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #f3f4f6; }

/* Global Header & Navigation */
.global-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-bottom: 2px solid #e2e8f0;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 20px;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.nav-bar .nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 22px;
  font-size: 1.2rem;
  font-weight: 550;
  line-height: 1.3;
  color: #1e293b;
  text-decoration: none;
  border-radius: 14px;
  border: 2px solid #7c8fec;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: inset 0 0 0 0 rgba(14, 165, 233, 0.15);
  transition: all 0.25s ease;
  min-height: 44px;
  cursor: pointer;
}

.nav-bar .nav-link:hover,
.nav-bar .nav-link:focus-visible {
  color: #0e7490;
  border-color: #7c8fec;
  background: rgba(124, 143, 236, 0.12);
  box-shadow: 0 2px 8px rgba(124, 143, 236, 0.2);
  text-decoration: none;
}

.nav-bar .nav-link-action {
  background: rgba(255, 255, 255, 0.6);
  border: 2px solid #7c8fec;
  box-shadow: inset 0 0 0 0 rgba(14, 165, 233, 0.15);
}

@media (max-width: 880px) {
  .nav-bar {
    position: static !important;
    top: auto !important;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: 8px 12px;
    justify-content: flex-start;
    gap: 12px;
  }

  .nav-bar .nav-link {
    flex: 0 0 auto;
    padding: 10px 16px;
    min-width: auto;
    font-size: 1rem;
    white-space: nowrap;
    border: 2px solid #7c8fec !important;
  }
  
  .nav-bar .nav-link-action {
    border: 2px solid #7c8fec !important;
  }
}

@media (max-width: 480px) {
  .nav-bar {
    padding: 8px 10px;
    gap: 10px;
  }

  .nav-bar .nav-link {
    flex: 0 0 auto;
    min-width: auto;
    padding: 8px 12px;
    font-size: 0.9rem;
    border: 2px solid #7c8fec !important;
  }
  
  .nav-bar .nav-link-action {
    border: 2px solid #7c8fec !important;
  }
}

/* Animation for loading spinner */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Animation for toast messages */
@keyframes slideUp {
  0% { transform: translateY(100px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* Validation message styles */
.validation-error {
  color: #dc2626;
  font-size: 0.8rem;
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.validation-success {
  color: #059669;
  font-size: 0.8rem;
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.validation-warning {
  color: #d97706;
  font-size: 0.8rem;
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Responsive Progress Layout */
@media (max-width: 768px) {
  .progress-layout-container {
    grid-template-columns: 1fr !important;
    gap: 15px !important;
  }
}

/* Responsive Period Analysis Report Grid */
.period-analysis-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 10px;
}

.period-analysis-grid-item {
  grid-column: span 3;
}

@media (max-width: 992px) {
  .period-analysis-grid {
    grid-template-columns: repeat(6, 1fr) !important;
  }
  .period-analysis-grid-item {
    grid-column: span 3 !important;
  }
}

@media (max-width: 768px) {
  .period-analysis-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }
  .period-analysis-grid-item {
    grid-column: span 2 !important;
  }
}

@media (max-width: 480px) {
  .period-analysis-grid {
    grid-template-columns: 1fr !important;
  }
  .period-analysis-grid-item {
    grid-column: span 1 !important;
  }
}

/* Women's Health Section - Ensure proper fit */
#womensHealthSection {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow-x: hidden !important;
}

#womensHealthCalendarContainer {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow-x: hidden !important;
}

#womensHealthCalendarGrid {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

#womensHealthCalendarGrid > div {
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

#periodAnalysisReport {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow-x: hidden !important;
}

#periodAnalysisReport > div {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* ============================================ */
/* PHASE 1: RESPONSIVE CORE LAYOUT & STRUCTURE */
/* ============================================ */

/* Calendar Header - Responsive */
.calendar-header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.calendar-header-title {
  flex: 1;
  min-width: 200px;
}

.calendar-header-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.calendar-header-button {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  padding: 8px 15px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.3s;
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.calendar-header-button:hover {
  background: rgba(255,255,255,0.3);
}

/* Month Navigation - Responsive */
.month-navigation-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.month-nav-button {
  background: white;
  border: 2px solid #10b981;
  color: #10b981;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
  min-height: 44px;
  white-space: nowrap;
}

.month-nav-button:hover {
  background: #10b981;
  color: white;
}

.month-title {
  margin: 0;
  color: #1f2937;
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  flex: 1;
}

/* Tab Navigation - Responsive */
.tab-navigation-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.tab-button {
  padding: 15px 20px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  font-size: 1.05rem;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  border: none;
}

.tab-button-active {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
}

.tab-button-active-health-diary {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  border: none;
}

.tab-button-active-womens-health {
  background: linear-gradient(135deg, #ec4899, #db2777);
  color: white;
  border: none;
}

.tab-button-inactive {
  background: white;
  color: #374151;
  border: 2px solid #e5e7eb;
}

.tab-button:hover {
  transform: translateY(-2px);
}

.tab-icon {
  font-size: 1.8rem;
}

/* Tablet Styles (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 768px) {
  .calendar-header-container {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .calendar-header-buttons {
    width: 100%;
    justify-content: flex-start;
  }
  
  .calendar-header-button {
    font-size: 0.8rem;
    padding: 8px 12px;
  }
  
  .month-title {
    font-size: 1.2rem;
  }
  
  .tab-navigation-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
  
  .tab-button {
    padding: 12px 16px;
    font-size: 0.95rem;
  }
  
  .tab-icon {
    font-size: 1.5rem;
  }
}

/* Mobile Styles (< 768px) */
@media (max-width: 767px) {
  /* Calendar Header */
  .calendar-header-container {
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
  }
  
  .calendar-header-title h2 {
    font-size: 1.2rem !important;
  }
  
  .calendar-header-title p {
    font-size: 0.8rem !important;
  }
  
  .calendar-header-buttons {
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }
  
  .calendar-header-button {
    width: 100%;
    font-size: 0.85rem;
    padding: 12px 15px;
    justify-content: center;
  }
  
  /* Month Navigation */
  .month-navigation-container {
    flex-direction: column;
    gap: 12px;
    padding: 12px 15px !important;
  }
  
  .month-nav-button {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.9rem;
  }
  
  .month-title {
    font-size: 1.1rem;
    order: -1;
  }
  
  /* Tab Navigation */
  .tab-navigation-container {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px !important;
  }
  
  .tab-button {
    width: 100%;
    padding: 14px 18px;
    font-size: 1rem;
    justify-content: flex-start;
  }
  
  .tab-icon {
    font-size: 1.6rem;
  }
}

/* Small Mobile Styles (< 480px) */
@media (max-width: 479px) {
  /* Calendar Header */
  #healthCalendarPanel {
    margin: 0 !important;
    box-shadow: none !important;
  }
  
  .calendar-header-container {
    padding: 15px !important;
  }
  
  .calendar-header-title h2 {
    font-size: 1.1rem !important;
  }
  
  .calendar-header-title p {
    font-size: 0.75rem !important;
  }
  
  .calendar-header-button {
    font-size: 0.8rem;
    padding: 10px 12px;
  }
  
  /* Calendar Content */
  .calendar-content {
    padding: 15px !important;
  }
  
  /* Month Navigation */
  .month-title {
    font-size: 1rem;
  }
  
  .month-nav-button {
    font-size: 0.85rem;
    padding: 10px 14px;
  }
  
  /* Tab Navigation */
  .tab-button {
    padding: 12px 16px;
    font-size: 0.95rem;
  }
  
  .tab-icon {
    font-size: 1.4rem;
  }
}

/* Mobile Content Padding Adjustments */
@media (max-width: 767px) {
  #healthCalendarPanel > div[style*="padding: 25px"] {
    padding: 15px !important;
  }
  
  .calendar-header-container {
    padding: 15px 20px !important;
  }
}

/* ============================================ */
/* PHASE 2: RESPONSIVE CALENDAR GRIDS */
/* ============================================ */

/* Calendar Grid Base Styles */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  width: 100%;
  box-sizing: border-box;
}

.calendar-days-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  width: 100%;
  box-sizing: border-box;
  font-weight: 700;
  color: #6b7280;
  text-align: center;
}

.calendar-day-cell {
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: start;
  padding: 15px 8px 10px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  overflow: hidden;
  max-width: 100%;
  box-sizing: border-box;
  word-wrap: break-word;
  font-size: 1rem;
  font-weight: 600;
}

.calendar-day-number {
  font-size: 1rem;
  font-weight: 600;
}

.calendar-day-content {
  margin-top: 4px;
  width: 100%;
  font-size: 0.6rem;
}

/* Tablet Styles (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 768px) {
  .calendar-grid {
    gap: 6px;
  }
  
  .calendar-days-header {
    gap: 6px;
    font-size: 0.9rem;
    margin-bottom: 10px;
  }
  
  .calendar-day-cell {
    min-height: 90px;
    padding: 12px 6px 8px 6px;
    font-size: 0.95rem;
  }
  
  .calendar-day-number {
    font-size: 0.95rem;
  }
  
  .calendar-day-content {
    font-size: 0.55rem;
  }
}

/* Mobile Styles (< 768px) */
@media (max-width: 767px) {
  .calendar-grid {
    gap: 4px;
    min-height: 350px !important;
  }
  
  .calendar-days-header {
    gap: 4px;
    font-size: 0.85rem;
    margin-bottom: 10px;
    padding: 0 2px;
  }
  
  .calendar-day-cell {
    min-height: 60px;
    padding: 8px 4px 6px 4px;
    font-size: 0.85rem;
    border-width: 1.5px !important;
    border-radius: 6px;
  }
  
  .calendar-day-number {
    font-size: 0.85rem;
  }
  
  .calendar-day-content {
    font-size: 0.5rem;
    margin-top: 2px;
  }
  
  /* Ensure calendar containers don't overflow */
  #goalTrackingCalendarContainer,
  #healthDiaryCalendarContainer,
  #womensHealthCalendarContainer {
    padding: 12px !important;
    overflow-x: hidden;
  }
}

  /* Small Mobile Styles (< 480px) */
  @media (max-width: 479px) {
    .calendar-grid {
      gap: 2px;
      min-height: 300px !important;
    }
    
    .calendar-days-header {
      gap: 2px;
      font-size: 0.75rem;
      margin-bottom: 8px;
      padding: 0;
    }
    
    .calendar-day-cell {
      min-height: 50px;
      padding: 6px 2px 4px 2px;
      font-size: 0.75rem;
      border-width: 1px !important;
      border-radius: 4px;
    }
    
    .calendar-day-number {
      font-size: 0.75rem;
    }
    
    .calendar-day-content {
      font-size: 0.45rem;
      margin-top: 1px;
    }
    
    /* Override inline styles for calendar cells on mobile */
    #goalTrackingCalendarGrid > div,
    #healthDiaryCalendarGrid > div,
    #womensHealthCalendarGrid > div {
      min-height: 50px !important;
      padding: 6px 2px 4px 2px !important;
      font-size: 0.75rem !important;
      border-width: 1px !important;
      border-radius: 4px !important;
    }
    
    #goalTrackingCalendarGrid > div > div:first-child,
    #healthDiaryCalendarGrid > div > div:first-child,
    #womensHealthCalendarGrid > div > div:first-child {
      font-size: 0.75rem !important;
    }
    
    /* Hide some content on very small screens */
    #goalTrackingCalendarGrid > div div[style*="font-size: 0.6rem"],
    #goalTrackingCalendarGrid > div div[style*="font-size: 0.65rem"],
    #healthDiaryCalendarGrid > div div[style*="font-size: 0.6rem"],
    #healthDiaryCalendarGrid > div div[style*="font-size: 0.65rem"],
    #womensHealthCalendarGrid > div div[style*="font-size: 0.6rem"],
    #womensHealthCalendarGrid > div div[style*="font-size: 0.65rem"] {
      font-size: 0.4rem !important;
      line-height: 1.2 !important;
    }
    
    /* Ensure calendar containers are compact */
    #goalTrackingCalendarContainer,
    #healthDiaryCalendarContainer,
    #womensHealthCalendarContainer {
      padding: 8px !important;
    }
  }
  
  /* Override inline styles for calendar cells on mobile (< 768px) */
  @media (max-width: 767px) {
    #goalTrackingCalendarGrid > div,
    #healthDiaryCalendarGrid > div,
    #womensHealthCalendarGrid > div {
      min-height: 60px !important;
      padding: 8px 4px 6px 4px !important;
      font-size: 0.85rem !important;
      border-width: 1.5px !important;
      border-radius: 6px !important;
    }
    
    #goalTrackingCalendarGrid > div > div:first-child,
    #healthDiaryCalendarGrid > div > div:first-child,
    #womensHealthCalendarGrid > div > div:first-child {
      font-size: 0.85rem !important;
    }
    
    #goalTrackingCalendarGrid > div div[style*="font-size: 0.6rem"],
    #healthDiaryCalendarGrid > div div[style*="font-size: 0.6rem"],
    #womensHealthCalendarGrid > div div[style*="font-size: 0.6rem"] {
      font-size: 0.5rem !important;
    }
  }
  
  /* Override inline styles for calendar cells on tablet (768px - 1024px) */
  @media (max-width: 1024px) and (min-width: 768px) {
    #goalTrackingCalendarGrid > div,
    #healthDiaryCalendarGrid > div,
    #womensHealthCalendarGrid > div {
      min-height: 90px !important;
      padding: 12px 6px 8px 6px !important;
      font-size: 0.95rem !important;
    }
    
    #goalTrackingCalendarGrid > div > div:first-child,
    #healthDiaryCalendarGrid > div > div:first-child,
    #womensHealthCalendarGrid > div > div:first-child {
      font-size: 0.95rem !important;
    }
  }

/* ============================================ */
/* PHASE 4: RESPONSIVE FORMS AND INPUT FIELDS */
/* ============================================ */

/* Form Input Base Styles */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  box-sizing: border-box;
  font-size: 16px; /* Prevents iOS zoom */
  padding: 12px;
  min-height: 44px; /* Touch-friendly */
  border-radius: 8px;
  transition: all 0.3s;
}

/* Tablet Styles (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 768px) {
  .form-input,
  .form-select,
  .form-textarea {
    padding: 11px;
    font-size: 15px;
    min-height: 42px;
  }
}

/* Mobile Styles (< 768px) */
@media (max-width: 767px) {
  /* All inputs, selects, and textareas */
  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="email"],
  input[type="tel"],
  input[type="time"],
  select,
  textarea {
    width: 100% !important;
    font-size: 16px !important; /* Prevents iOS zoom */
    padding: 12px !important;
    min-height: 44px !important; /* Touch-friendly */
    box-sizing: border-box !important;
    border-radius: 8px !important;
  }
  
  /* Textareas specific */
  textarea {
    min-height: 80px !important;
    resize: vertical;
  }
  
  /* Labels */
  label {
    display: block !important;
    margin-bottom: 6px !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
  }
  
  /* Form groups and containers */
  .form-group,
  div[style*="margin-bottom"] {
    margin-bottom: 15px !important;
  }
  
  /* Checkboxes and radio buttons - larger touch targets */
  input[type="checkbox"],
  input[type="radio"] {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    margin-right: 8px !important;
    cursor: pointer;
  }
  
  /* Checkbox/Radio labels */
  label[for*="period"],
  label[for*="pregnancy"],
  label[for*="diary"],
  label[for*="modal"] {
    display: flex !important;
    align-items: center !important;
    cursor: pointer;
    padding: 8px 0 !important;
  }
  
  /* Button adjustments */
  button[type="submit"],
  button[onclick*="save"],
  button[onclick*="Save"],
  button[onclick*="submit"],
  button[onclick*="Submit"] {
    width: 100% !important;
    min-height: 44px !important;
    padding: 12px 20px !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    margin-top: 10px !important;
  }
  
  /* Button groups - stack vertically */
  div[style*="display: flex"][style*="gap"] button,
  div[style*="justify-content: space-between"] button {
    flex: 1 1 100% !important;
    margin-bottom: 8px !important;
  }
  
  /* Grid layouts in forms - stack vertically */
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns: 2fr 1fr"],
  div[style*="grid-template-columns: repeat(2"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  
  /* Form sections with borders */
  div[style*="border:"] {
    padding: 12px !important;
    margin-bottom: 15px !important;
  }
  
  /* Specific Modal Form Adjustments */
  /* Goal Entry Modal */
  #modalGoalType,
  #modalCurrentValue,
  #modalTargetValue,
  #modalStartDate,
  #modalEndDate,
  #modalDailyValue,
  #modalNotes {
    width: 100% !important;
    font-size: 16px !important;
    padding: 12px !important;
    min-height: 44px !important;
  }
  
  #modalNotes {
    min-height: 80px !important;
  }
  
  /* Health Diary Modal */
  #diaryTemplateSelect,
  #diaryCustomEntry {
    width: 100% !important;
    font-size: 16px !important;
    padding: 12px !important;
    min-height: 44px !important;
  }
  
  #diaryCustomEntry {
    min-height: 100px !important;
  }
  
  /* Women's Health Modal */
  #periodDay,
  #flowIntensity,
  #symptoms,
  #painLevel,
  #moodLevel,
  #periodSymptoms,
  #pregnancyWeek,
  #pregnancyWeight {
    width: 100% !important;
    font-size: 16px !important;
    padding: 12px !important;
    min-height: 44px !important;
  }
  
  #periodSymptoms {
    min-height: 80px !important;
  }
  
  /* Reminder Form Modal */
  #reminderFormModal input,
  #reminderFormModal select,
  #reminderFormModal textarea {
    width: 100% !important;
    font-size: 16px !important;
    padding: 12px !important;
    min-height: 44px !important;
  }
}

/* Small Mobile Styles (< 480px) */
@media (max-width: 479px) {
  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="email"],
  input[type="tel"],
  input[type="time"],
  select,
  textarea {
    padding: 10px !important;
    font-size: 16px !important;
    min-height: 44px !important;
  }
  
  textarea {
    min-height: 70px !important;
  }
  
  label {
    font-size: 0.85rem !important;
    margin-bottom: 5px !important;
  }
  
  button[type="submit"],
  button[onclick*="save"],
  button[onclick*="Save"],
  button[onclick*="submit"],
  button[onclick*="Submit"] {
    padding: 10px 16px !important;
    font-size: 0.95rem !important;
  }
}

/* ============================================ */
/* PHASE 5: RESPONSIVE PROGRESS REPORTS & STATISTICS */
/* ============================================ */

/* Progress Report Grid (3 columns) */
@media (max-width: 767px) {
  /* Progress Layout Container - Stack Report and Graph */
  .progress-layout-container {
    grid-template-columns: 1fr !important;
    gap: 15px !important;
  }
  
  /* Progress Report 3-column grid to 1 column */
  #progressReport div[style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  
  /* Progress Report Cards */
  #progressReport > div > div[style*="background: white"] {
    padding: 12px 10px !important;
    min-height: auto !important;
  }
  
  /* Progress Report Title and Buttons */
  #progressReport > div:first-child {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }
  
  #progressReport > div:first-child > div:last-child {
    width: 100% !important;
    display: flex !important;
    gap: 8px !important;
  }
  
  #progressReport button {
    flex: 1 !important;
    min-height: 44px !important;
    font-size: 0.85rem !important;
  }
  
  /* Progress Graph Container */
  #progressReport + div {
    width: 100% !important;
  }
  
  #progressGraphCanvas {
    width: 100% !important;
    height: 200px !important;
  }
}

/* Health Report Grid (4 columns) */
@media (max-width: 767px) {
  /* Health Report 4-column grid to 1 column */
  div[style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  
  /* Health Report Cards */
  div[style*="grid-template-columns: repeat(4, 1fr)"] > div {
    padding: 12px !important;
    min-height: auto !important;
  }
}

/* Small Mobile Adjustments */
@media (max-width: 479px) {
  #progressReport {
    padding: 15px !important;
  }
  
  #progressReport div[style*="grid-template-columns: repeat(3, 1fr)"] {
    gap: 10px !important;
  }
  
  #progressReport > div > div[style*="background: white"] {
    padding: 10px 8px !important;
  }
  
  #progressReport > div > div[style*="background: white"] > div:first-child {
    font-size: 0.7rem !important;
  }
  
  #progressReport > div > div[style*="background: white"] > div:last-child {
    font-size: 1.2rem !important;
  }
  
  #progressGraphCanvas {
    height: 180px !important;
  }
}

/* ============================================ */
/* PHASE 6: RESPONSIVE HISTORY SECTION */
/* ============================================ */

@media (max-width: 767px) {
  /* History Section */
  #historySection {
    padding: 15px !important;
  }
  
  #historySection h2 {
    font-size: 1.3rem !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }
  
  #historySection p {
    font-size: 0.9rem !important;
  }
  
  /* History Category Buttons - Stack vertically */
  #historySection div[style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  
  #historySection button[onclick*="showHistoryCategory"] {
    width: 100% !important;
    padding: 14px 18px !important;
    font-size: 0.95rem !important;
    min-height: 44px !important;
  }
  
  /* History Content Containers */
  #historyGoalTrackingContent,
  #historyHealthDiaryContent,
  #historyWomensHealthContent {
    padding: 15px !important;
  }
  
  #historyGoalTrackingContent > div,
  #historyHealthDiaryContent > div,
  #historyWomensHealthContent > div {
    padding: 15px !important;
  }
  
  /* History Lists */
  #historyGoalTrackingList,
  #historyHealthDiaryList,
  #historyWomensHealthList {
    max-height: 400px !important;
    padding: 10px !important;
  }
  
  /* History List Items */
  #historyGoalTrackingList > div,
  #historyHealthDiaryList > div,
  #historyWomensHealthList > div {
    padding: 12px !important;
    margin-bottom: 10px !important;
    font-size: 0.9rem !important;
  }
}

/* Small Mobile History Adjustments */
@media (max-width: 479px) {
  #historySection {
    padding: 12px !important;
  }
  
  #historySection h2 {
    font-size: 1.2rem !important;
  }
  
  #historySection button[onclick*="showHistoryCategory"] {
    padding: 12px 16px !important;
    font-size: 0.9rem !important;
  }
  
  #historyGoalTrackingList,
  #historyHealthDiaryList,
  #historyWomensHealthList {
    max-height: 350px !important;
  }
}

/* ============================================ */
/* PHASE 7: ENHANCE WOMEN'S HEALTH RESPONSIVENESS */
/* ============================================ */

@media (max-width: 767px) {
  /* Women's Health Section Containers */
  #womensHealthSection {
    padding: 15px !important;
  }
  
  /* Period Analysis Report - Already has responsive CSS, enhance it */
  #periodAnalysisReport {
    padding: 15px !important;
  }
  
  /* Women's Health Category Buttons */
  #womensHealthSection div[style*="grid-template-columns: repeat(auto-fit"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  
  #womensHealthSection button[onclick*="showWomensCategory"] {
    width: 100% !important;
    padding: 14px 18px !important;
    font-size: 0.95rem !important;
    min-height: 44px !important;
  }
  
  /* Cycle Status Content Grid */
  #cycleStatusContent {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
}

/* Small Mobile Women's Health Adjustments */
@media (max-width: 479px) {
  #womensHealthSection {
    padding: 12px !important;
  }
  
  #periodAnalysisReport {
    padding: 12px !important;
  }
  
  #womensHealthSection button[onclick*="showWomensCategory"] {
    padding: 12px 16px !important;
    font-size: 0.9rem !important;
  }
}

/* ============================================ */
/* FIX: How to Use Modal - Progress Report Grid */
/* ============================================ */

@media (max-width: 767px) {
  /* Understanding Your Progress Report Section - 3-column grid to 1 column */
  #howToUseGuideModal div[style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  
  /* Progress Report Cards in How to Use Modal */
  #howToUseGuideModal div[style*="grid-template-columns: repeat(3, 1fr)"] > div {
    padding: 10px !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  
  /* Ensure text doesn't overflow */
  #howToUseGuideModal div[style*="grid-template-columns: repeat(3, 1fr)"] > div h6,
  #howToUseGuideModal div[style*="grid-template-columns: repeat(3, 1fr)"] > div p {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    font-size: 0.85rem !important;
  }
  
  #howToUseGuideModal div[style*="grid-template-columns: repeat(3, 1fr)"] > div h6 {
    font-size: 0.85rem !important;
  }
  
  #howToUseGuideModal div[style*="grid-template-columns: repeat(3, 1fr)"] > div p {
    font-size: 0.75rem !important;
  }
  
  /* Icon size adjustment */
  #howToUseGuideModal div[style*="grid-template-columns: repeat(3, 1fr)"] > div > div:first-child {
    font-size: 1.2rem !important;
  }
}

/* Small Mobile How to Use Modal Adjustments */
@media (max-width: 479px) {
  #howToUseGuideModal div[style*="grid-template-columns: repeat(3, 1fr)"] {
    gap: 8px !important;
  }
  
  #howToUseGuideModal div[style*="grid-template-columns: repeat(3, 1fr)"] > div {
    padding: 8px !important;
  }
  
  #howToUseGuideModal div[style*="grid-template-columns: repeat(3, 1fr)"] > div h6 {
    font-size: 0.8rem !important;
  }
  
  #howToUseGuideModal div[style*="grid-template-columns: repeat(3, 1fr)"] > div p {
    font-size: 0.7rem !important;
  }
}