/* CSS Variables for Design System - MacOS Inspired */
:root {
  /* Colors - Muted MacOS-inspired palette */
  --primary: #2D5A3D;
  --primary-dark: #2D5A3D;
  --primary-light: rgba(45, 90, 61, 0.08);
  --background: #f5f7fa;
  --surface: #ffffff;
  --surface-elevated: #fafbfc;
  --text-primary: #1a1d23;
  --text-secondary: #636770;
  --text-tertiary: #8e8e93;
  --border: #e1e5e9;
  --border-light: #f0f2f5;
  --danger: #ff3b30;
  --danger-dark: #d70015;
  --warning: #ff9500;
  --success: #2D5A3D;
  --accent-blue: #2D5A3D;
  
  /* Typography */
  --font-stack: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-2xl: 24px;
  --space-3xl: 32px;
  
  /* Border Radius - More pronounced */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-pill: 50px;
  
  /* Shadows - MacOS style */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.06);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.08);
  
  /* Transitions */
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: all 0.35s cubic-bezier(0.2, 0, 0, 1);
  --header-height: 76px;
  --sidebar-width: 240px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-stack);
  margin: 0;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 14px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================================= */
/* FIX 1: ADD VISUAL STYLES FOR SERVING SCALE ISOLATION */
/* PURPOSE: Make Serving Scale state visually obvious */
/* ============================================================================= */

/* Serving Scale input visual states */
#servingScale {
    transition: all 0.3s ease;
    border: 1px solid var(--border);
}

/* Visual indicator when Serving Scale is active (≠ 1) */
#servingScale[value]:not([value="1"]) {
    border: 2px solid var(--warning);
    background: rgba(255, 149, 0, 0.05);
    box-shadow: 0 0 0 3px rgba(255, 149, 0, 0.1);
}

/* Focus state for Serving Scale */
#servingScale:focus {
    border-color: var(--warning);
    box-shadow: 0 0 0 3px rgba(255, 149, 0, 0.15);
}

/* ============================================================================= */
/* FIX 2: ADD STYLES FOR INFORMATION PANELS */
/* PURPOSE: Make educational content stand out */
/* ============================================================================= */

.info-panel {
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
}

.info-panel h4 {
    margin: 0 0 var(--space-sm) 0;
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
}

.info-panel p {
    margin: 0;
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.4;
}

/* ============================================================================= */
/* FIX: SUMMARY CONTROLS GRID ALIGNMENT */
/* PURPOSE: Create consistent, aligned layout for all summary controls */
/* ============================================================================= */

.summary-controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
  align-items: start;
}

.summary-control-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: var(--transition);
  min-height: 120px;
  justify-content: space-between;
}

.summary-control-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Serving Scale visual highlight */
.serving-scale-highlight {
  border-left: 4px solid var(--warning);
  background: linear-gradient(135deg, var(--surface-elevated) 0%, rgba(255, 149, 0, 0.03) 100%);
}

.serving-scale-highlight:focus-within {
  box-shadow: 0 0 0 3px rgba(255, 149, 0, 0.1);
}

/* Consistent label styling */
.control-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.4;
}

.label-text {
  flex: 1;
  margin-right: var(--space-sm);
}

/* Consistent input group styling */
.input-with-suffix {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.input-with-suffix:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.15);
}

.input-with-suffix input {
  flex: 1;
  border: none;
  padding: var(--space-md);
  background: transparent;
  font-family: var(--font-stack);
  font-size: 14px;
  min-width: 0;
}

.input-with-suffix input:focus {
  outline: none;
  box-shadow: none;
}

.suffix {
  padding: var(--space-md) var(--space-lg);
  background: var(--primary-light);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  border-left: 1px solid var(--border-light);
}

/* Helper text styling */
.helper-text {
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.4;
  margin: var(--space-xs) 0 0 0;
}

/* Field help button consistency */
.field-help {
  background: none;
  border: none;
  color: var(--primary);
  cursor: help;
  font-size: 12px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.field-help:hover {
  background: var(--primary-light);
  transform: scale(1.1);
}

/* ============================================================================= */
/* FIX: MOBILE VIEW TABLE BUTTON VISIBILITY AND LAYOUT */
/* PURPOSE: Ensure edit/delete buttons are visible and properly sized on mobile */
/* ============================================================================= */

@media (max-width: 768px) {
  /* Master Raw Materials Table - Mobile Button Fix */
  #rawMaterialsTable td:last-child,
  #directLaborTable td:last-child {
    display: flex !important;
    flex-direction: row !important;
    gap: var(--space-sm) !important;
    justify-content: center !important;
    align-items: center !important;
    min-width: 140px !important;
    padding: var(--space-sm) !important;
  }

  #rawMaterialsTable td:last-child button,
  #directLaborTable td:last-child button {
    flex: 1 !important;
    min-width: 180px !important;
    padding: var(--space-sm) !important;
    font-size: 12px !important;
    min-height: 44px !important;
    white-space: nowrap !important;
  }

  /* Consistent row heights with Main Recipe table */
  #rawMaterialsTable tr,
  #directLaborTable tr {
    min-height: 60px !important;
  }

  #rawMaterialsTable td,
  #directLaborTable td {
    padding: var(--space-md) !important;
    min-height: 52px !important;
    vertical-align: middle !important;
  }
}

/* ============================================================================= */
/* FIX: HEIGHT AND MARGIN CONSISTENCY */
/* PURPOSE: Ensure proper spacing matches Main Recipe table */
/* ============================================================================= */

@media (max-width: 768px) {
  /* Ensure proper spacing matches Main Recipe table */
  .table-container {
    margin-bottom: var(--space-lg) !important;
    border: 1px solid var(--border-light) !important;
    border-radius: var(--radius-md) !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Maintain minimum table width for readability */
  #rawMaterialsTable,
  #directLaborTable {
    min-width: 600px !important;
  }

  /* Consistent touch targets across all tables */
  #rawMaterialsTable button,
  #directLaborTable button,
  #recipeTable button,
  #directLaborRecipeTable button {
    min-height: 44px !important;
    padding: var(--space-sm) var(--space-md) !important;
  }
}

/* ============================================================================= */
/* FIX: CONSISTENT TABLE COLUMN WIDTHS ACROSS ALL SECTIONS */
/* PURPOSE: Ensure all tables have uniform column distribution */
/* ============================================================================= */

/* Master Raw Materials Table - Match Main Recipe structure */
#rawMaterialsTable th:nth-child(1) { width: 180px; }    /* Raw Material */
#rawMaterialsTable th:nth-child(2) { width: 120px; }   /* Category */
#rawMaterialsTable th:nth-child(3) { width: 100px; }   /* Yield % */
#rawMaterialsTable th:nth-child(4) { width: 140px; }   /* Cost/Unit */
#rawMaterialsTable th:nth-child(5) { width: 180px; }   /* Actions */

/* Direct Labor Table - Consistent with Recipe structure */
#directLaborTable th:nth-child(1) { width: 180px; }     /* Labor Name */
#directLaborTable th:nth-child(2) { width: 140px; }    /* Shift Duration */
#directLaborTable th:nth-child(3) { width: 140px; }    /* Rate */
#directLaborTable th:nth-child(4) { width: 160px; }    /* Total Cost */
#directLaborTable th:nth-child(5) { width: 140px; }    /* Actions */

/* Mobile column width adjustments */
@media (max-width: 768px) {
  #rawMaterialsTable th:nth-child(2) { width: 100px; }   /* Category - reduced */
  #rawMaterialsTable th:nth-child(3) { width: 80px; }    /* Yield % - reduced */
  #rawMaterialsTable th:nth-child(4) { width: 120px; }   /* Cost/Unit - reduced */
  #rawMaterialsTable th:nth-child(5) { width: 160px; }   /* Actions - reduced */
  
  #directLaborTable th:nth-child(2) { width: 120px; }    /* Shift Duration - reduced */
  #directLaborTable th:nth-child(3) { width: 120px; }    /* Rate - reduced */
  #directLaborTable th:nth-child(4) { width: 140px; }    /* Total Cost - reduced */
  #directLaborTable th:nth-child(5) { width: 120px; }    /* Actions - reduced */
}

/* ============================================================================= */
/* FIX: ENHANCED TABLE CONTAINER BEHAVIOR FOR MOBILE */
/* PURPOSE: Ensure consistent scrolling and overflow handling */
/* ============================================================================= */

@media (max-width: 768px) {
  /* Enhanced table container for better mobile experience */
  .table-container {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    
  }
  
  @media (max-width: 768px) {
    /* Target the first column (Labor Item / Labor Name) of both Direct Labor tables */
    /* FIX: Prevent all Direct Labor columns from shrinking excessively on mobile */
    /* Targeting both Recipe Labor Table and Master Labor Table */
    
    /* 1. Labor Item / Labor Name (Needs the most space) */
    /* FIX: Prevent Labor Item column from shrinking */
    #directLaborRecipeTable th:nth-child(1),
    #directLaborRecipeTable td:nth-child(1),
    #directLaborTable th:nth-child(1),
    #directLaborTable td:nth-child(1) {
        min-width: 200px; 
        width: 200px; /* Set explicit width to complement min-width */
    }

    /* 2. Time Required */
    #directLaborRecipeTable th:nth-child(2),
    #directLaborRecipeTable td:nth-child(2),
    #directLaborTable th:nth-child(2),
    #directLaborTable td:nth-child(2) {
        min-width: 120px; 
    }

    /* 3. Rate */
    #directLaborRecipeTable th:nth-child(3),
    #directLaborRecipeTable td:nth-child(3),
    #directLaborTable th:nth-child(3),
    #directLaborTable td:nth-child(3) {
        min-width: 120px; 
    }
    
    /* 4. Total Cost */
    #directLaborRecipeTable th:nth-child(4),
    #directLaborRecipeTable td:nth-child(4),
    #directLaborTable th:nth-child(4),
    #directLaborTable td:nth-child(4) {
        min-width: 140px; 
    }
    
    /* 5. Action (Buttons) */
    #directLaborRecipeTable th:nth-child(5),
    #directLaborRecipeTable td:nth-child(5),
    #directLaborTable th:nth-child(5),
    #directLaborTable td:nth-child(5) {
        min-width: 100px; 
    }
    
    /* FIX: Prevent all Raw Materials Recipe columns from shrinking excessively on mobile */
    /* Target: #rawMaterialsRecipeTable (The Add Item to Recipe table in the modal) */
    
    /* 1. Item */
    #rawMaterialsRecipeTable th:nth-child(1),
    #rawMaterialsRecipeTable td:nth-child(1) {
        min-width: 200px; 
        width: 200px;
    }

    /* 2. Qty */
    #rawMaterialsRecipeTable th:nth-child(2),
    #rawMaterialsRecipeTable td:nth-child(2) {
        min-width: 100px; 
    }

    /* 3. Unit Cost */
    #rawMaterialsRecipeTable th:nth-child(3),
    #rawMaterialsRecipeTable td:nth-child(3) {
        min-width: 120px; 
    }
    
    /* 4. Total Cost */
    #rawMaterialsRecipeTable th:nth-child(4),
    #rawMaterialsRecipeTable td:nth-child(4) {
        min-width: 140px; 
    }
    
    /* 5. Action (Buttons) */
    #rawMaterialsRecipeTable th:nth-child(5),
    #rawMaterialsRecipeTable td:nth-child(5) {
        min-width: 100px; 
    }

  }
  /* Visual indicator for scrollable tables */
  .table-container::after {
    content: '→';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 16px;
    opacity: 0.7;
    pointer-events: none;
  }
  
  /* Ensure tables don't break layout */
  #rawMaterialsTable,
  #directLaborTable,
  #recipeTable,
  #directLaborRecipeTable {
    width: 100%;
    table-layout: fixed;
  }
}

/* ============================================================================= */
/* FIX: BUTTON STATE CONSISTENCY ACROSS ALL TABLES */
/* PURPOSE: Uniform hover, active, and focus states */
/* ============================================================================= */

/* Consistent button states for all table action buttons */
#rawMaterialsTable .btn-secondary.small,
#directLaborTable .btn-secondary.small,
#recipeTable .btn-secondary.small,
#directLaborRecipeTable .btn-secondary.small {
  transition: all 0.2s ease;
  border: 1px solid var(--border);
}

#rawMaterialsTable .btn-secondary.small:hover,
#directLaborTable .btn-secondary.small:hover,
#recipeTable .btn-secondary.small:hover,
#directLaborRecipeTable .btn-secondary.small:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border-color: var(--primary);
}

#rawMaterialsTable .btn-danger.small,
#directLaborTable .btn-danger.small,
#recipeTable .btn-danger.small,
#directLaborRecipeTable .btn-danger.small {
  transition: all 0.2s ease;
}

#rawMaterialsTable .btn-danger.small:hover,
#directLaborTable .btn-danger.small:hover,
#recipeTable .btn-danger.small:hover,
#directLaborRecipeTable .btn-danger.small:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(255, 59, 48, 0.3);
}

@media (max-width: 768px) {
  /* Stack buttons vertically on very small screens */
  @media (max-width: 480px) {
    #rawMaterialsTable td:last-child,
    #directLaborTable td:last-child {
      flex-direction: column !important;
      gap: 4px !important;
    }
    
    #rawMaterialsTable td:last-child button,
    #directLaborTable td:last-child button {
      width: 100% !important;
      min-width: auto !important;
    }
  }
}

/* ============================================================================= */
/* RESPONSIVE ADJUSTMENTS FOR SUMMARY GRID */
/* ============================================================================= */

@media (max-width: 1024px) {
  .summary-controls-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-md);
  }
  
  .summary-control-item {
    padding: var(--space-md);
    min-height: 110px;
  }
}

@media (max-width: 768px) {
  .summary-controls-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  .summary-control-item {
    min-height: auto;
    padding: var(--space-lg);
  }
  
  /* FIXED: Keep input-with-suffix in row layout on mobile */
  .input-with-suffix {
    flex-direction: row;
    align-items: center;
  }
  
  .input-with-suffix input {
    width: auto;
    flex: 1;
    text-align: left;
    min-width: 60px;
    padding: var(--space-md);
  }
  
  .suffix {
    border-left: 1px solid var(--border-light);
    border-top: none;
    text-align: center;
    padding: var(--space-sm) var(--space-md);
    min-width: 80px;
    flex-shrink: 0;
  }
}

@media (max-width: 480px) {
  .summary-control-item {
    padding: var(--space-md);
  }
  
  .control-label {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }
  
  .label-text {
    margin-right: 0;
  }
}

/* ============================================================================= */
/* DARK MODE ADJUSTMENTS FOR SUMMARY CONTROLS */
/* ============================================================================= */

body.dark-mode .summary-control-item {
  background: var(--surface-elevated);
  border-color: var(--border);
}

body.dark-mode .serving-scale-highlight {
  background: linear-gradient(135deg, var(--surface-elevated) 0%, rgba(255, 149, 0, 0.08) 100%);
  border-left-color: var(--warning);
}

body.dark-mode .input-with-suffix {
  background: var(--surface);
  border-color: var(--border);
}

body.dark-mode .suffix {
  background: rgba(45, 90, 61, 0.2);
  color: var(--text-secondary);
  border-left-color: var(--border);
}

body.dark-mode .input-with-suffix:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.2);
}

/* ============================================================================= */
/* FIX 3: ENHANCE SUMMARY TAB VISUAL HIERARCHY */
/* PURPOSE: Clearly separate Serving Scale from other controls */
/* ============================================================================= */

.summary-controls {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
    align-items: flex-end;
    position: relative;
}

/* Visual separator for Serving Scale section */
.summary-controls > :last-child {
    border-left: 2px solid var(--primary);
    padding-left: var(--space-md);
    margin-left: var(--space-sm);
}

/* ============================================================================= */
/* FIX 4: ADD RESPONSIVE STYLES FOR MOBILE */
/* PURPOSE: Ensure visual cues work on all devices */
/* ============================================================================= */

@media (max-width: 768px) {
    .summary-controls > :last-child {
        border-left: none;
        border-top: 2px solid var(--primary);
        padding-left: 0;
        padding-top: var(--space-md);
        margin-left: 0;
        margin-top: var(--space-sm);
    }
    
    #servingScale[value]:not([value="1"]) {
        border-width: 1px;
        box-shadow: 0 0 0 2px rgba(255, 149, 0, 0.1);
    }
}

/* ============================================================================= */
/* FIX 5: DARK MODE ADJUSTMENTS */
/* PURPOSE: Ensure visual cues work in dark mode */
/* ============================================================================= */

body.dark-mode #servingScale[value]:not([value="1"]) {
    border-color: var(--warning);
    background: rgba(255, 149, 0, 0.1);
    box-shadow: 0 0 0 3px rgba(255, 149, 0, 0.15);
}

body.dark-mode .info-panel {
    background: rgba(45, 90, 61, 0.2);
    border-color: var(--primary);
}

/* ============================================================================= */
/* ENHANCEMENT: Better visual feedback for auth and labor integration */
/* ============================================================================= */

.header-icon-btn:active {
    transform: scale(0.95);
}

/* Enhancement for labor select dropdown */
#directLaborSelect option:checked {
    background: var(--primary-light);
    color: var(--primary);
}

/* Visual indicator for successful labor addition */
.labor-row.added {
    animation: highlightFade 2s ease;
}

@keyframes highlightFade {
    0% { background-color: rgba(52, 199, 89, 0.3); }
    100% { background-color: transparent; }
}

/* Better loading states */
.btn-primary.loading {
    position: relative;
    color: transparent;
}

.btn-primary.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ============================================================================= */
/* FIX: ENHANCED BUTTON STATES AND VISUAL FEEDBACK */
/* PURPOSE: Make button interactions more obvious */
/* ============================================================================= */

/* Base button enhancements */
.btn-primary, .btn-secondary, .add-btn, .print-btn, .header-icon-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

/* Ripple effect on click */
.btn-primary:active::after, 
.btn-secondary:active::after,
.add-btn:active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    to {
        width: 200px;
        height: 200px;
        opacity: 0;
    }
}

/* Loading states for async operations */
.btn-primary.loading, .btn-secondary.loading {
    position: relative;
    color: transparent;
}

.btn-primary.loading::after, .btn-secondary.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================================================= */
/* FIX: ENHANCED MODAL INTERACTIONS */
/* PURPOSE: Better visual feedback for modal actions */
/* ============================================================================= */

.modal-content {
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Close button hover effects */
.close-btn {
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--primary-light);
    transform: rotate(90deg);
}

/* ============================================================================= */
/* FIX: ENHANCED TABLE INTERACTIONS */
/* PURPOSE: Better feedback for table actions */
/* ============================================================================= */

/* Edit and Delete button states */
.btn-secondary.small, .btn-danger.small {
    transition: all 0.2s ease;
    position: relative;
}

.btn-secondary.small:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-danger.small:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.3);
}

/* ============================================================================= */
/* FIX: RESPONSIVE IMPROVEMENTS FOR MOBILE */
/* PURPOSE: Better touch targets and mobile UX */
/* ============================================================================= */

@media (max-width: 768px) {
    /* Larger touch targets for mobile */
    .btn-primary, .btn-secondary, .add-btn, .print-btn {
        min-height: 48px;
        padding: var(--space-md) var(--space-lg);
    }
    
    /* Better spacing for mobile forms */
    .input-group {
        margin-bottom: var(--space-lg);
    }
    
    /* Improved mobile table actions */
    #recipeTable td:last-child, 
    #directLaborRecipeTable td:last-child {
        display: flex;
        flex-direction: row;
        gap: var(--space-sm);
        justify-content: center;
    }
    
    .btn-secondary.small, 
    .btn-danger.small {
        flex: 1;
        min-width: 70px;
        padding: var(--space-sm);
    }
}



/* ============================================================================= */
/* FIX: ACCESSIBILITY IMPROVEMENTS */
/* PURPOSE: Better focus states for keyboard navigation */
/* ============================================================================= */

/* Enhanced focus styles */
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.add-btn:focus-visible,
.print-btn:focus-visible,
.header-icon-btn:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.3);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn-primary, .add-btn, .print-btn {
        border: 2px solid currentColor;
    }
    
    .btn-secondary {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .btn-primary, .btn-secondary, .add-btn, .print-btn,
    .modal-content, .close-btn {
        transition: none;
        animation: none;
    }
}

/* ============================================================================= */
/* FIX: ENHANCED DIRECT LABOR SECTION STYLING */
/* PURPOSE: Accommodate new rate display field and improve layout */
/* ============================================================================= */

/* Enhanced direct labor section layout */
.add-labor-section {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: var(--space-md);
    padding: var(--space-xl);
    background: var(--surface-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    margin: var(--space-lg) 0;
    align-items: end;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.add-labor-section:hover {
    box-shadow: var(--shadow-lg);
}

.add-labor-section h4 {
    grid-column: 1 / -1;
    margin: 0 0 var(--space-md) 0;
    color: var(--primary);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.1px;
}

/* ===== FIXED WIDTH FOR DIRECT LABOR MODAL ===== */
/* Target the specific form groups in direct labor modal */
#directLaborModal .form-row .form-group:nth-child(2) { /* Time Unit */
    width: 120px;
    min-width: 120px;
    max-width: 120px;
}

#directLaborModal .form-row .form-group:nth-child(2) .select-input {
    width: 100%;
    min-width: 100%;
}

#directLaborModal .form-row .form-group:nth-child(4) { /* Cost Unit */
    width: 120px;
    min-width: 120px;
    max-width: 120px;
}

#directLaborModal .form-row .form-group:nth-child(4) .select-input {
    width: 100%;
    min-width: 100%;
}

/* Make the flexible fields expand */
#directLaborModal .form-row .form-group:nth-child(1), /* Shift Duration */
#directLaborModal .form-row .form-group:nth-child(3) { /* Cost Per Unit */
    flex: 1;
    min-width: 0; /* Important for flex shrinking */
}

/* Form row layout for direct labor modal */
#directLaborModal .form-row {
    display: flex;
    gap: var(--space-sm);
    align-items: flex-end;
    margin-bottom: var(--space-md);
}

#directLaborModal .form-group {
    margin-bottom: 0;
}

/* Rate display styling */
#selectedLaborRate {
    background-color: var(--surface-elevated);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    cursor: not-allowed;
    font-weight: 600;
}

#selectedLaborRate:not(:placeholder-shown) {
    color: var(--text-primary);
    border-color: var(--primary);
    background-color: rgba(45, 90, 61, 0.05);
}

/* Enhanced select dropdown styling */
#directLaborSelect option:checked {
    background: linear-gradient(45deg, var(--primary-light), var(--primary));
    color: var(--primary-dark);
    font-weight: 600;
}

/* Visual feedback for labor row addition */
.labor-row.added {
    animation: highlightSuccess 1.5s ease;
}

@keyframes highlightSuccess {
    0% { 
        background-color: rgba(52, 199, 89, 0.3);
        transform: scale(1.02);
    }
    70% { 
        background-color: rgba(52, 199, 89, 0.1);
        transform: scale(1.01);
    }
    100% { 
        background-color: transparent;
        transform: scale(1);
    }
}

/* ===================================================================== */
/* --- NEW GLOBAL STYLING: POSITION UNIT INSIDE INPUT FIELD --- */
/* This section must be outside of any @media query to apply globally. */
/* ===================================================================== */

.input-with-unit {
    /* 1. Crucial: Sets the wrapper as the reference point for absolute positioning */
    position: relative; 
    display: flex; /* Maintains layout integrity with input */
    align-items: center;
    width: 100%;
}

.input-with-unit input[type="number"],
.input-with-unit input[type="text"] {
    /* 2. Crucial: Adds space inside the input for the unit display */
    padding-right: 60px; /* Adjust from default padding to make room for unit text */
}

.input-with-unit .unit-display-small {
    /* 3. Crucial: Positions the unit relative to the .input-with-unit wrapper */
    position: absolute; 
    right: var(--space-md); /* Aligns unit text to the right, inside the input area */
    top: 50%; /* Center vertically */
    transform: translateY(-50%);
    
    /* 4. Crucial: Prevents text wrapping and user interaction */
    white-space: nowrap;      /* Prevents text like "milliliters" from wrapping */
    pointer-events: none;     /* Allows mouse/touch events to pass through to the input */
    flex-shrink: 0;           /* Prevents the unit element from being compressed */

    /* Aesthetic Styling */
    color: var(--text-secondary); /* Use a muted color for the unit text */
    font-size: 0.9em;
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
    z-index: 1; /* Ensure unit is above the input field */
}

/* Mobile responsive adjustments for direct labor section */
@media (max-width: 768px) {
    .add-labor-section {
        grid-template-columns: 1fr !important;
        gap: var(--space-md);
        padding: var(--space-lg);
    }
    
    .add-labor-section h4 {
        grid-column: 1;
    }
    
    .add-labor-section .input-group {
        margin-bottom: var(--space-md);
    }
    
    /* FIXED: Keep input-with-unit in row layout on mobile - OBSOLETE RULES REMOVED */
    /* .add-labor-section .input-with-unit {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-sx);
    } */
    
    /* .add-labor-section .input-with-unit input {
        width: auto;
        flex: 1;
        text-align: left;
        min-width: 80px;
    } */
    
    /* .add-labor-section .unit-display-small {
        align-self: center;
        margin-top: 0;
        min-width: 60px;
        flex-shrink: 0;
        text-align: left;
    } */
}

/* Print-specific enhancements */
@media print {
    .add-labor-section {
        display: none !important;
    }
    
    .labor-row {
        break-inside: avoid;
    }
}

/* Dark mode adjustments */
body.dark-mode #selectedLaborRate {
    background-color: var(--surface);
    border-color: var(--border);
    color: var(--text-secondary);
}

body.dark-mode #selectedLaborRate:not(:placeholder-shown) {
    color: var(--text-primary);
    border-color: var(--primary);
    background-color: rgba(45, 90, 61, 0.2);
}

/* Enhanced button states for better UX */
.btn-primary:active, 
.btn-secondary:active,
.add-btn:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* ============================================================================= */
/* NEW: EXPLICIT READONLY STYLING FOR LABOR RATE FIELD AND HELP ICONS */
/* PURPOSE: Make readonly fields visually distinct and improve accessibility */
/* ============================================================================= */

/* Make selected labor rate read-only styling more explicit */
#selectedLaborRate[readonly] {
  background-color: var(--surface-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: not-allowed;
  padding: var(--space-sm);
  border-radius: var(--radius-md);
}
#selectedLaborRate[readonly]:focus-visible {
  outline: 3px solid rgba(45,90,61,0.12);
  outline-offset: 2px;
}

/* Help icon consistent focus state */
.help-icon, .field-help {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.help-icon:focus-visible, .field-help:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Make readonly inputs within add-labor-section clearer when they have value */
.add-labor-section .readonly-input[readonly] {
  background: rgba(45,90,61,0.04);
  color: var(--text-primary);
  border-color: var(--primary);
}

/* ============================================================================= */
/* NEW: INVALID STATE STYLES AND EMPTY READONLY FIELD VISUALS */
/* PURPOSE: Provide explicit invalid-state styles and improve feedback on empty read-only fields */
/* ============================================================================= */

/* Visual indicator for invalid fields (used by JS when validation fails) */
.field-invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.1) !important;
  background: rgba(255, 59, 48, 0.02) !important;
}

/* Readonly input that is visually empty (JS toggles .empty if value is blank) */
input.readonly-input[readonly].empty {
  color: var(--danger);
  opacity: 0.95;
  background: rgba(255, 59, 48, 0.03) !important;
}

/* Apply invalid styles to specific sub-recipe fields when missing */
#subRecipeCostPerUnit.field-invalid,
#subRecipeCostUnit.field-invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.1) !important;
  background: rgba(255, 59, 48, 0.02) !important;
}

/* Sub-recipe validation message (ensure visible when shown) */
#subRecipeValidationMessage {
  margin-top: var(--space-sm);
  display: block;
}

/* ============================================================================= */
/* FIX: CONSISTENT HEADER SPACING AND LAYOUT */
/* ============================================================================= */

/* Enhanced section header spacing */
.section-header {
  margin-bottom: var(--space-2xl) !important;
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border-light);
}

/* Consistent spacing for main content headings */
.current-recipe h3,
.labor-section h3,
.recipe-list > h3 {
  font-size: 1.3rem !important;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.1px;
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--primary-light);
}

/* Improve header-top spacing in mobile */
.header-top {
  padding-bottom: var(--space-lg);
  margin-bottom: var(--space-sx);
}

/* Ensure proper gap between header and first content section */
.content-area {
  margin-top: var(--space-md);
}

/* ============================================================================= */
/* TIP MESSAGE STYLING FOR RAW MATERIALS SECTION */
/* ============================================================================= */

.tip-message {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin: var(--space-lg) 0 var(--space-xl) 0;
  font-size: 13px;
  color: var(--text-primary);
  border-left: 4px solid var(--primary);
  line-height: 1.4;
}

.tip-message strong {
  color: var(--primary-dark);
  font-weight: 600;
}

/* Dark mode adjustment */
body.dark-mode .tip-message {
  background: rgba(45, 90, 61, 0.2);
  border-color: var(--primary);
  color: var(--text-primary);
}

/* ============================================================================= */
/* FIX: STANDARDIZED HEADING HIERARCHY AND FONT SIZES */
/* ============================================================================= */

/* Standardize all main section headings */
.current-recipe h3,
.labor-section h3,
.recipe-list > h3 {
  font-size: 1.3rem !important;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.1px;
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--primary-light);
}

/* Ensure current recipe name display is consistent */
#currentRecipeName {
  font-size: 1.3rem !important;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: var(--space-lg);
}

/* Sub-section headings consistency */
.add-ingredient-section h4,
.add-labor-section h4,
.recipe-column h4 {
  font-size: 1.1rem !important;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  letter-spacing: -0.05px;
}

/* Saved recipes heading specific styling */
.saved-recipes-heading {
  font-size: 1.3rem !important;
  font-weight: 700;
  color: var(--primary);
  margin: var(--space-xl) 0 var(--space-lg) 0;
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--primary-light);
}

/* Updated Header Styles */
.header {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  padding: var(--space-lg) var(--space-lg);
  border-bottom: 1px solid var(--border-light);
  z-index: 100;
  gap: 0;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  gap: var(--space-lg);
  width: 100%;
  padding-bottom: var(--space-lg);
}

/* Ensure site name adjusts to logo height */
.site-name {
  margin: 0;
  font-size: 20px;
  color: var(--primary);
  font-weight: 700;
  font-family: var(--font-stack);
  letter-spacing: -0.2px;
  line-height: 1.2; /* Better line height */
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
  flex-shrink: 0;
  min-height: auto; /* Ensure enough height for logo + text */
}

.site-slogan {
  font-family: var(--font-stack);
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 0;
  margin-top: var(--space-xs);
  font-style: italic;
  font-weight: 400;
}

.left-group {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.right-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: nowrap;
  margin-left: auto;
  flex-shrink: 0;
  overflow-x: auto;
}

/* Header item styles */
.header-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-stack);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.header-icon-btn:hover {
  background: var(--surface-elevated);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.header-select {
  width: 120px;
  padding: var(--space-sm) var(--space-md);
}

/* Theme toggle in header */
.header-icon .theme-toggle-label {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* Auth section in header */
.auth-section {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.auth-buttons {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.user-email {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
  font-family: var(--font-stack);
  font-size: 14px;
  padding: 0;
}

.link-btn:hover {
  color: var(--primary-dark);
}

.error-message {
  background: rgba(255, 59, 48, 0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin: var(--space-md) 0;
  font-size: 13px;
}

.auth-switch {
  text-align: center;
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 13px;
}

/* NEW: Password Reset Modal Styles */
.success-message {
  background-color: var(--success-light);
  color: var(--success);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--success);
  margin: var(--space-sm) 0;
  font-size: 14px;
}

.password-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-group .text-input {
  padding-right: 40px;
  flex: 1;
}

.password-toggle {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}

.password-toggle:hover {
  background: var(--primary-light);
  color: var(--text-primary);
}

/* FIXED: Sidebar Navigation - Ensure proper display */
.sidebar {
  position: fixed;
  left: 0;
  top: var(--header-height);
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--surface);
  border-right: 1px solid var(--border-light);
  padding: var(--space-xl) 0;
  z-index: 90;
  overflow-y: auto;
  display: none; /* Hidden by default on mobile */
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: 0 var(--space-lg);
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-stack);
  font-size: 14px;
  transition: var(--transition);
  font-weight: 500;
  text-align: left;
  width: 100%;
}

.sidebar-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  transform: translateX(4px);
}

.sidebar-btn.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.sidebar-btn svg {
  flex-shrink: 0;
}

/* FIXED: Password Input Group */
.password-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-group input {
  padding-right: 40px;
  width: 100%;
}

.password-toggle {
  position: absolute;
  right: var(--space-sm);
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.password-toggle:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* FIXED: Auth Options */
.auth-options {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-md);
}

.auth-options .link-btn.small {
  font-size: 12px;
  padding: 0;
}

/* FIXED: Success Message */
.success-message {
  background: rgba(52, 199, 89, 0.1);
  border: 1px solid var(--success);
  color: var(--success);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin: var(--space-md) 0;
  font-size: 13px;
}

/* Mobile Tabs */
.mobile-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  flex-wrap: nowrap;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  position: sticky;
  top: 0;
  z-index: 90;
  width: 100%;
}

.mobile-tabs::-webkit-scrollbar {
  height: 4px;
}

.mobile-tabs::-webkit-scrollbar-track {
  background: transparent;
}

.mobile-tabs::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-pill);
}

.mobile-tabs button {
  border: none;
  background: transparent;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  flex: 0 0 auto;
  color: var(--text-secondary);
  position: relative;
  transition: var(--transition);
  font-family: var(--font-stack);
  white-space: nowrap;
  font-size: 14px;
  min-height: 44px;
}

.mobile-tabs button:hover {
  color: var(--surface);
  background: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.mobile-tabs button.active {
  color: var(--surface);
  background: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Layout - Updated for sidebar */
.app-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-lg) var(--space-xl);
  box-sizing: border-box;
  margin-left: 0;
  transition: var(--transition);
}

.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  padding: 0;
  width: 100%;
}

/* Panel */
.panel {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  border: 1px solid var(--border-light);
  transition: var(--transition);
}

.panel:hover {
  box-shadow: var(--shadow-xl);
  transform: translateY(-1px);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.section-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.2px;
}

/* Tables - More refined */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-md);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

th {
  text-align: left;
  padding: var(--space-md);
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  background: var(--surface-elevated);
  font-size: 13px;
  font-weight: 600;
}

td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  min-width: 0;
  font-family: var(--font-stack);
  white-space: nowrap;
  background: var(--surface);
  transition: var(--transition);
}

tr:hover td {
  background: var(--primary-light);
}

td input[type="text"],
td input[type="number"],
td select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-sizing: border-box;
  font-family: var(--font-stack);
  font-size: 14px;
  transition: var(--transition);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

td input[type="text"]:focus,
td input[type="number"]:focus,
td select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.15);
}

/* Table container for horizontal scrolling */
.table-container {
  overflow-x: auto;
  width: 100%;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--space-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.table-container table {
  box-shadow: none;
  border-radius: 0;
}

/* Ensure tables don't collapse on mobile */
table {
  min-width: 600px;
}

/* Yield cell input group */
.yield-input {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
  flex-wrap: nowrap;
  width: 100%;
}

.yield-input input {
  width: 70px;
  text-align: left;
  font-family: var(--font-stack);
}

/* Adaptive no-wrap labels */
.unit-display,
.unit-suffix,
.yield-input span,
td span:not(:has(input, select)) {
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  vertical-align: middle;
  font-family: var(--font-stack);
  color: var(--text-secondary);
}

.unit-cost-cell .unit-display {
  color: var(--text-secondary);
  font-size: 13px;
  vertical-align: middle;
  margin-left: var(--space-xs);
}

.unit-suffix {
  margin-left: var(--space-sm);
  color: var(--text-secondary);
  font-size: 13px;
}

.table-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
  flex-wrap: wrap;
}

.add-btn {
  background: var(--primary);
  color: var(--surface);
  border: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-stack);
  font-weight: 600;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  letter-spacing: -0.1px;
  min-height: 44px;
}

.add-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-stack);
  font-weight: 600;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  min-height: 44px;
}

.btn-danger:hover {
  background: var(--danger-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.total-cost {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-lg);
  font-weight: 700;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.total-cost:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.accent-total {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* Search and Inputs */
.search-container {
  margin-bottom: var(--space-lg);
}

.search-input {
  width: 100%;
  padding: var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 14px;
  background: var(--surface);
  padding-left: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23636770'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 16px;
  transition: var(--transition);
  font-family: var(--font-stack);
  box-shadow: var(--shadow-sm);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.15);
}

.text-input,
.number-input,
.select-input {
  width: 100%;
  padding: var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: var(--surface);
  transition: var(--transition);
  font-family: var(--font-stack);
  box-shadow: var(--shadow-sm);
}

.text-input:focus,
.number-input:focus,
.select-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.15);
}

.number-input.small,
.select-input.small {
  padding: var(--space-sm);
  font-size: 13px;
}

/* Buttons - Enhanced */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
  font-family: var(--font-stack);
  box-shadow: var(--shadow-sm);
  letter-spacing: -0.1px;
  min-height: 44px;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
  font-family: var(--font-stack);
  box-shadow: var(--shadow-sm);
  min-height: 44px;
}

.btn-secondary:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ADDED: Styles for Edit and Delete buttons in tables */
.btn-secondary.small,
.btn-danger.small {
  padding: 6px 12px;
  font-size: 12px;
  min-height: 32px;
}

/* Recipe Controls */
.add-ingredient-section {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: var(--space-md);
  padding: var(--space-xl);
  background: var(--surface-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin: var(--space-xl) 0;
  align-items: end;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.add-ingredient-section:hover {
  box-shadow: var(--shadow-lg);
}

.add-ingredient-section h4 {
  grid-column: 1 / -1;
  margin: 0 0 var(--space-md) 0;
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.1px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.input-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.help-icon {
  background: none;
  border: none;
  color: var(--primary);
  cursor: help;
  font-size: 12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.help-icon:hover {
  background: var(--primary-light);
  transform: scale(1.1);
}

.input-with-unit {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.input-with-unit input {
  flex: 1;
}

.unit-display-small {
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
}

/* Summary Section */
.summary-controls {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
  align-items: flex-end;
}

.input-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.input-wrap input {
  width: 110px;
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-family: var(--font-stack);
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.input-wrap input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.15);
}

.input-wrap span {
  position: relative;
  margin-left: var(--space-sm);
  color: var(--text-secondary);
  font-family: var(--font-stack);
}

.summary-grid {
  display: grid;
  gap: var(--space-sm);
}

.summary-item {
  display: flex;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px dashed var(--border-light);
  flex-wrap: wrap;
  transition: var(--transition);
  border-radius: var(--radius-sm);
}

.summary-item:hover {
  background: var(--primary-light);
}

.print-btn {
  background: var(--primary);
  color: var(--surface);
  border: none;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  cursor: pointer;
  margin-top: var(--space-md);
    font-family: var(--font-stack);
  font-weight: 600;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  min-height: 44px;
}

.print-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Recipe List */
.recipe-list {
  margin-top: var(--space-xl);
}

.recipe-item {
  background: var(--surface);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  margin-bottom: var(--space-sm);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  box-shadow: var(--shadow-sm);
  min-height: 80px;
  overflow: hidden;
}

.recipe-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.recipe-item h4 {
  margin-bottom: var(--space-xs);
  padding-right: 100px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipe-item p {
  color: var(--text-secondary);
  font-size: 13px;
  padding-right: 100px;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipe-actions {
  position: absolute;
  right: var(--space-lg);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: var(--space-sm);
}

/* Save recipe buttons */
.save-recipe-buttons {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  /* FIXED: Increased spacing between total cost and save buttons */
  margin-top: var(--space-2xl);
  padding-top: var(--space-md);
}

.save-recipe-buttons button {
  flex: 1;
  min-width: 150px;
}

/* Direct Labor section styles */
.labor-section {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-light);
}

.labor-section h3 {
  color: var(--primary);
  margin-bottom: var(--space-lg);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.1px;
}

.add-labor-section {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: var(--space-md);
  padding: var(--space-xl);
  background: var(--surface-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin: var(--space-lg) 0;
  align-items: end;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.add-labor-section:hover {
  box-shadow: var(--shadow-lg);
}

.add-labor-section h4 {
  grid-column: 1 / -1;
  margin: 0 0 var(--space-md) 0;
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.1px;
}

.labor-row {
  background: var(--surface-elevated);
}

.labor-row td {
  border-color: var(--border-light);
}

/* FIX: Direct Labor table action buttons wrapping */
#directLaborTable td:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  justify-content: flex-start;
  align-items: center;
  min-width: 120px;
}

#directLaborTable td:last-child button {
  flex: 1;
  min-width: 60px;
  white-space: nowrap;
}

/* Enhanced Reset Button Styling */
.reset-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-stack);
  font-weight: 600;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  min-height: 44px;
}

.reset-btn:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.reset-btn:active {
  transform: translateY(0);
}

.reset-btn svg {
  flex-shrink: 0;
}

/* Tooltip Styles */
.tooltip-container {
  position: relative;
  display: inline-block;
}

.tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--surface);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 1000;
  margin-bottom: var(--space-sm);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}

.tooltip-container:hover .tooltip {
  opacity: 1;
  visibility: visible;
}

.tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--text-primary);
}

/* Dark mode support for tooltip */
body.dark-mode .tooltip {
  background: var(--surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

body.dark-mode .tooltip::after {
  border-top-color: var(--surface-elevated);
}

/* Modals - Enhanced */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  padding: var(--space-lg);
}

.modal .modal-content {
  background: var(--surface);
  padding: var(--space-xl);
  border-radius: var(--radius-xl);
  width: 92%;
  max-width: 720px;
  line-height: 1.5;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-light);
  animation: modalAppear 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xl);
  /* FIXED: Recipe Builder Modal header spacing */
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
  letter-spacing: -0.1px;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  min-height: 44px;
  min-width: 44px;
}

.close-btn:hover {
  background: var(--primary-light);
  color: var(--text-primary);
  transform: scale(1.1);
}

.modal-close {
  background: var(--primary);
  color: white;
  border: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-stack);
  font-weight: 600;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  min-height: 44px;
}

.modal-close:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Forms */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-sm);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

.modal-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-xl);
}

.modal-actions button {
  flex: 1;
}

.hidden {
  display: none !important;
}

/* Cost Calculation Display */
.cost-calculation {
  background: var(--surface-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin: var(--space-md) 0;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}

.cost-calculation h4 {
  margin: 0 0 var(--space-sm) 0;
  font-size: 14px;
  color: var(--primary);
  font-weight: 700;
}

.calculation-formula {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  background: var(--surface);
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  margin: var(--space-sm) 0;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Quantity input with unit display */
.quantity-input-group {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  width: 100%;
  min-width: 120px;
  max-width: 200px;
  flex-wrap: nowrap;
}

.quantity-input-group input {
  width: 100% !important;
  min-width: 80px;
  flex: 1;
}

.quantity-unit {
  color: var(--text-secondary);
  font-size: 13px;
  margin-left: var(--space-xs);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Yield input */
.yield-input-group {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  width: 100%;
  min-width: 120px;
  max-width: 200px;
  flex-wrap: nowrap;
}

.yield-input-group input {
  width: 100% !important;
  min-width: 80px;
  flex: 1;
}

.yield-percent {
  color: var(--text-secondary);
  font-size: 13px;
  margin-left: var(--space-xs);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Recipe name and reset button in recipe tab */
.recipe-header-controls {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  align-items: center;
}

.recipe-header-controls input {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  min-width: 200px;
  flex: 1;
  font-family: var(--font-stack);
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.recipe-header-controls input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.15);
}

.recipe-header-controls button {
  white-space: nowrap;
}

/* Servings control in recipe header */
.servings-control {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.servings-control label {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  margin: 0;
}

/* Sub-recipe display in recipe table */
.sub-recipe-row {
  background: var(--surface-elevated);
  border-left: 4px solid var(--primary);
}

.sub-recipe-row td {
  border-left: none !important;
}

.sub-recipe-badge {
  background: var(--primary);
  color: white;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  margin-left: var(--space-sm);
  font-weight: 600;
}

/* Sub-recipe breakdown */
.sub-recipe-breakdown {
  background: var(--surface-elevated);
  padding: var(--space-md);
  margin: var(--space-sm) 0;
  border-radius: var(--radius-md);
  border-left: 3px solid var(--primary);
  box-shadow: var(--shadow-sm);
}

.sub-recipe-breakdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 1px dashed var(--border-light);
}

.toggle-breakdown {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--primary);
  transition: var(--transition);
  min-height: 44px;
  min-width: 44px;
}

.toggle-breakdown:hover {
  transform: scale(1.1);
}

/* Recipe columns layout */
.recipe-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  margin-top: var(--space-lg);
}

.recipe-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.recipe-column h4 {
  color: var(--primary);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-light);
  font-weight: 700;
  letter-spacing: -0.1px;
}

/* Read-only input styling */
.readonly-input {
  background-color: var(--surface-elevated);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  cursor: not-allowed;
}

/* ADDED: Style for readonly inputs */
input[readonly] {
  background-color: var(--surface-elevated);
  border-color: var(--border-light);
  color: var(--text-secondary);
  cursor: not-allowed;
}

/* ============================================================================= */
/* NEW: ENHANCED DISABLED STATE STYLES FOR RAW MATERIAL EDIT MODAL */
/* PURPOSE: Make disabled fields visually distinct and provide user feedback */
/* ============================================================================= */

/* Enhanced disabled state for inputs and selects */
input:disabled, select:disabled {
  background-color: var(--surface-elevated);
  border-color: var(--border-light);
  color: var(--text-secondary);
  cursor: not-allowed;
  opacity: 0.8;
}

/* Specific styling for disabled select elements in edit mode */
#modalMeasurementCategory:disabled,
#modalPurchaseUnit:disabled,
#modalCostUnit:disabled {
  background-color: var(--surface-elevated);
  border-color: var(--border-light);
  color: var(--text-tertiary);
  cursor: not-allowed;
  position: relative;
}

/* Visual indicator for disabled fields with tooltip */
.disabled-field-group {
  position: relative;
}

.disabled-field-group::after {
  content: "Cannot be changed for existing materials";
  position: absolute;
  top: -30px;
  left: 0;
  background: var(--text-primary);
  color: var(--surface);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 1000;
  pointer-events: none;
}

.disabled-field-group:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Edit Prompt Modal */
#editPromptModal {
  z-index: 2001;
}

/* Field definition help styles */
.field-help {
  background: none;
  border: none;
  color: var(--primary);
  cursor: help;
  font-size: 12px;
  margin-left: var(--space-xs);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.field-help:hover {
  background: var(--primary-light);
  transform: scale(1.1);
}

/* Example styling for field definitions */
.field-example {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  padding: var(--space-sm) var(--space-md);
  margin: var(--space-sm) 0;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.field-example strong {
  color: var(--primary);
}

/* Edit Prompt Modal Styles */
.edit-prompt-modal .modal-content {
  max-width: 500px;
}

.edit-prompt-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin: var(--space-xl) 0;
}

.edit-prompt-options button {
  flex: 1;
  padding: var(--space-md);
  font-size: 14px;
}

/* Print Preview Modal */
.print-preview {
  max-width: 90%;
  width: 800px;
  max-height: 85vh;
}

.print-preview-content {
  background: white;
  padding: var(--space-xl);
  border: 1px solid var(--border-light);
  max-height: 70vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
}

.print-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
  margin-top: var(--space-lg);
}

/* NEW: Scaling Info Styles for Print Preview */
.scaling-info {
  background: #f0f8f0;
  padding: 10px;
  border-radius: 5px;
  margin: 10px 0;
  color: #1a1d23;
  border: 1px solid rgba(45, 90, 61, 0.08);
}

/* Dark-mode styles for scaling-info so print preview inside modal respects theme */
body.dark-mode .scaling-info {
  background: rgba(45, 90, 61, 0.18);
  color: var(--text-primary);
  border-color: rgba(110, 215, 157, 0.08);
}

/* Small utility to make print HTML use theme-friendly text colors inside modal preview */
.print-preview-content.theme-dark {
  background: var(--surface);
  color: var(--text-primary);
}

/* Cost Breakdown Preview Styles */
.cost-breakdown-preview {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-xl);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.breakdown-section {
  border-bottom: 1px solid var(--border-light);
}

.breakdown-section:last-child {
  border-bottom: none;
}

.breakdown-header {
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  background: var(--surface-elevated);
  cursor: pointer;
  transition: var(--transition);
}

.breakdown-header:hover {
  background: var(--primary-light);
}

.breakdown-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  letter-spacing: -0.1px;
}

.breakdown-count {
  background: var(--primary);
  color: white;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
}

.breakdown-total {
  font-weight: 700;
  color: var(--primary);
}

.breakdown-chevron {
  transition: var(--transition);
  color: var(--text-secondary);
}

.breakdown-header.collapsed .breakdown-chevron {
  transform: rotate(-90deg);
}

.breakdown-content {
  padding: var(--space-lg);
  background: var(--surface);
}

.breakdown-table {
  width: 100%;
  font-size: 13px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.breakdown-table th {
  background: var(--surface-elevated);
  font-weight: 600;
  color: var(--text-primary);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-light);
}

.breakdown-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  background: var(--surface);
}

.breakdown-table tr:last-child td {
  border-bottom: none;
}

.breakdown-table tr:hover td {
  background: var(--primary-light);
}

.breakdown-subtotal {
  font-weight: 700;
  color: var(--text-primary);
  background: var(--surface-elevated) !important;
}

/* Summary Recipe Loader Styles */
.summary-recipe-selector {
  background: var(--surface-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-md);
}

.load-recipe-controls {
  display: flex;
  gap: var(--space-md);
  align-items: flex-end;
  flex-wrap: wrap;
}

.load-recipe-controls select {
  flex: 1;
  min-width: 200px;
}

.loaded-recipe-info {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-top: var(--space-lg);
}

.loaded-recipe-info h4 {
  margin: 0 0 var(--space-md) 0;
  color: var(--text-primary);
  font-weight: 700;
}

.recipe-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-md);
}

.recipe-meta p {
  margin: 0;
  font-size: 13px;
  color: var(--text-primary);
}

.recipe-meta strong {
  color: var(--primary-dark);
}

/* FIXED: Total Profit Analysis - Updated Terminology */
.total-profit-analysis {
  background: var(--surface-elevated);
  border-left: 3px solid var(--accent-blue);
}

.total-profit-analysis:first-of-type {
  border-top: 2px solid var(--accent-blue);
  font-weight: bold;
}

/* FIX: Remove old horizontal scrolling from .current-recipe and .labor-section */
.current-recipe {
  /* Remove overflow-x: auto since we're using table-container */
}

.labor-section {
  /* Remove overflow-x: auto since we're using table-container */
}

/* FIXED: Ad Space - Improved Width, Alignment and Sidebar Overlap Prevention */
.ad-space {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  text-align: center;
  min-height: 150px;
  border: 1px solid var(--border-light);
  transition: var(--transition);
  
  /* FIX: Ensure proper width and prevent sidebar overlap */
  width: 100%;
  max-width: 100%;
  margin: var(--space-lg) auto;
  box-sizing: border-box;
  
  /* FIX: Proper z-index to stay below sidebar */
  z-index: 10;
  position: relative;
}

.ad-space:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

.ad-space h3 {
  margin-top: 0;
  color: var(--primary);
  font-size: 1.1rem;
  margin-bottom: var(--space-md);
  font-weight: 600;
}

.ad-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--background);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  
  /* FIX: Ensure content doesn't cause overflow */
  max-width: 100%;
  box-sizing: border-box;
}

/* Remove old theme toggle styles */
.theme-toggle-container,
.theme-toggle-label,
.theme-toggle,
.theme-slider,
.theme-icon {
  display: none;
}

/* Dark mode adjustments */
body.dark-mode .header {
  background: rgba(37, 41, 50, 0.85);
  border-bottom-color: var(--border);
}

body.dark-mode .header-icon-btn {
  border-color: var(--border);
  color: var(--text-primary);
}

body.dark-mode .header-icon-btn:hover {
  background: var(--surface-elevated);
  border-color: var(--primary);
}

/* ========================================================================== */
/* YIELD % MIGRATION & ALPHABETICAL SORTING STYLES */
/* ========================================================================== */

/* ADJUST: Recipe table column widths after removing yield column */
#recipeTable th:nth-child(1) { width: 180px; } /* Item */
#recipeTable th:nth-child(2) { width: 160px; } /* Qty - increased */
#recipeTable th:nth-child(3) { width: 160px; } /* Unit Cost - increased */
#recipeTable th:nth-child(4) { width: 160px; } /* Total Cost - increased */
#recipeTable th:nth-child(5) { width: 120px; } /* Actions - increased */

/* ADJUST: Raw materials table column widths after adding yield column */
#rawMaterialsTable th:nth-child(1) { width: 180px; } /* Raw Material */
#rawMaterialsTable th:nth-child(2) { width: 120px; } /* Category */
#rawMaterialsTable th:nth-child(3) { width: 100px; } /* Yield % - new column */
#rawMaterialsTable th:nth-child(4) { width: 140px; } /* Cost/Unit */
#rawMaterialsTable th:nth-child(5) { width: 180px; } /* Actions */

/* ADJUST: Summary breakdown table column widths */
.breakdown-table th:nth-child(1) { width: 180px; }   /* Item */
   .breakdown-table th:nth-child(2) { width: 160px; }  /* Qty - increased */
   .breakdown-table th:nth-child(3) { width: 160px; }  /* Unit Cost - increased */
   .breakdown-table th:nth-child(4) { width: 160px; }  /* Total Cost - increased */

/* ========================================================================== */
/* RESPONSIVE DESIGN */
/* ========================================================================== */

/* Desktop Styles */
@media (min-width: 1024px) {
  .sidebar {
    display: block; /* Show on desktop */
  }
  
  .mobile-tabs {
    display: none;
  }
  
  .app-layout {
    margin-left: var(--sidebar-width);
    padding: 0 var(--space-xl) var(--space-xl);
    max-width: calc(1400px - var(--sidebar-width));
    
    /* FIX: Ensure ad space aligns properly */
    align-items: center;
  }
  
  /* FIXED: Ad Space Overlap - Improved Desktop Layout */
  .ad-space {
    /* FIX: Proper width calculation with sidebar */
    max-width: calc(1400px - var(--sidebar-width) - var(--space-xl) * 2);
    margin-left: auto;
    margin-right: auto;
    
    /* FIX: Ensure proper spacing with sidebar layout */
    margin-top: var(--space-lg);
    margin-bottom: var(--space-lg);
    
    /* FIX: Clear sidebar overlap */
    position: relative;
    left: 0;
  }
  
  /* FIX: Ensure sidebar stays above content */
  .sidebar {
    z-index: 100;
  }
  
  /* FIX: Ensure main content doesn't overlap */
  .app-layout {
    position: relative;
    z-index: 1;
  }
}

/* Tablet Styles */
@media (max-width: 1023px) and (min-width: 769px) {
  .sidebar {
    display: none;
  }
  
  .mobile-tabs {
    display: flex;
  }
  
  .app-layout {
    margin-left: 0;
  }
  
  /* FIX: Consistent tablet width for ad space */
  .ad-space {
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
    
    /* FIX: Proper spacing */
    margin-top: var(--space-xl);
    margin-bottom: var(--space-lg);
  }
  

}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  
  .mobile-tabs {
    display: flex;
  }
  
  .app-layout {
    margin-left: 0;
    padding: 0 var(--space-md) var(--space-xl);
    gap: var(--space-lg);
  }

  .content-area {
    gap: var(--space-lg);
    padding: 0;
  }

  .header {
    padding: var(--space-xl);
    flex-direction: column;
  }

  .header-top {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: var(--space-sx);
    padding: var(--space-lg) var(--space-lg);
  }

  .mobile-tabs {
    margin-top: var(--space-md);
    justify-content: center;
    padding: var(--space-md) var(--space-lg);
    gap: var(--space-sm);
  }

  .header input[type="text"] {
    min-width: 160px;
    flex: 1 1 auto;
  }

  /* Improved header layout */
  .right-group {
    flex-direction: row;
    align-items: center;
    gap: var(--space-sm);
    margin-top: 0;
    flex-shrink: 0;
  }
  
  /* Header item responsive adjustments */
  .header-item {
    gap: var(--space-xs);
  }

  .header-icon-btn {
    width: 36px;
    height: 36px;
    padding: var(--space-xs);
  }

  .header-select {
    width: 90px;
    padding: var(--space-xs) var(--space-sm);
    font-size: 12px;
  }

  .user-email {
    max-width: 120px;
    font-size: 12px;
  }

  .mobile-tabs button {
    font-size: 13px;
    padding: var(--space-sm) var(--space-md);
    min-height: 44px;
  }

  .panel {
    padding: var(--space-lg);
  }

  /* FIX: Mobile ad space adjustments */
  .ad-space {
    /* FIX: Mobile width constraints */
    width: calc(100% - var(--space-md) * 2);
    max-width: none;
    margin: var(--space-lg) var(--space-md);
    
    /* FIX: Mobile spacing */
    padding: var(--space-md);
    min-height: 120px;
  }
  
  .ad-content {
    padding: var(--space-sm);
  }
  
  .ad-space h3 {
    font-size: 1rem;
    margin-bottom: var(--space-sm);
  }

  @media (max-width: 768px) {
  .btn-secondary.small, 
  .btn-danger.small {
    flex: 1;
    min-width: 70px;
    padding: var(--space-sm);
    font-size: 12px; /* Ensure this is included */
  }
}

  /* ADJUST: Mobile recipe table column widths */
  #recipeTable th:nth-child(2) { width: 140px; } /* Qty */
  #recipeTable th:nth-child(3) { width: 140px; } /* Unit Cost */
  #recipeTable th:nth-child(4) { width: 140px; } /* Total Cost */
  #recipeTable th:nth-child(5) { width: 100px; } /* Actions */
  
  /* ADJUST: Mobile raw materials table column widths */
  #rawMaterialsTable th:nth-child(3) { width: 80px; } /* Yield % */
  #rawMaterialsTable th:nth-child(4) { width: 120px; } /* Cost/Unit */
  #rawMaterialsTable th:nth-child(5) { width: 160px; } /* Actions */

  /* FIX: Recipe rows should scroll horizontally instead of stacking */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: var(--space-lg);
  }

  table {
    min-width: 600px;
  }

  /* REMOVED: Mobile table stacking styles that were breaking horizontal layout */
  #recipeTable thead {
    display: table-header-group;
  }

  #recipeTable tbody {
    display: table-row-group;
  }

  #recipeTable tr {
    display: table-row;
  }

  #recipeTable td {
    display: table-cell;
    text-align: left;
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
  }

  #recipeTable td::before {
    display: none;
  }

  /* Improved table input widths */
  #recipeTable td input[type="text"],
  #recipeTable td input[type="number"],
  #recipeTable td select {
    width: 100%;
    min-width: 80px;
    max-width: 120px;
  }

  /* Improved yield input adjustment for mobile */
  .yield-input-group {
    width: 100%;
    min-width: 100px;
    max-width: 200px;
  }

  .yield-input-group input {
    width: 100%;
  }

  /* Improved quantity input adjustment for mobile */
  .quantity-input-group {
    width: 100%;
    min-width: 100px;
    max-width: 200px;
  }

  .quantity-input-group input {
    width: 100%;
  }

  /* Unit cost cell adjustment */
  .unit-cost-cell {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .unit-cost-cell .unit-currency {
    margin-right: var(--space-sm);
  }

  .unit-cost-cell input {
    flex: 1;
    max-width: 100px;
  }

  .unit-cost-cell .unit-display {
    margin-left: var(--space-sm);
  }

  /* ADDED: Ensure action buttons don't wrap in tables */
  #recipeTable td:last-child,
  #directLaborRecipeTable td:last-child {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
    align-items: center;
    min-width: 140px;
  }

  /* Delete button adjustment */
  #recipeTable td:last-child {
    justify-content: center;
  }

  #recipeTable td:last-child button {
    width: auto;
  }

  /* ADDED: Responsive adjustments for action buttons */
  #recipeTable td:last-child,
  #directLaborRecipeTable td:last-child {
    flex-direction: column;
    gap: 4px;
  }
  
  .btn-secondary.small,
  .btn-danger.small {
    width: 100%;
    min-width: 60px;
  }

  /* FIXED: Mobile Layout for Add Item to Recipe */
  .add-ingredient-section {
    grid-template-columns: 1fr !important;
    gap: var(--space-lg);
    padding: var(--space-lg);
  }
  
  .add-ingredient-section h4 {
    grid-column: 1;
    margin-bottom: var(--space-md);
  }
  
  .add-ingredient-section .input-group {
    margin-bottom: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sx);
  }
  
  /* FIXED: Keep input-with-unit in row layout on mobile - OBSOLETE RULES REMOVED */
  /* .add-ingredient-section .input-with-unit {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sx);
  } */
  
  /* .add-ingredient-section .input-with-unit input {
    width: auto;
    flex: 1;
    text-align: left;
    min-width: 50px;
  } */
  
  /* .add-ingredient-section .unit-display-small {
    align-self: center;
    margin-top: 0;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    width: auto !important;
    width: auto !important;
    min-width: 60px;
    flex-shrink: 0;
    text-align: left;
  } */
  
  /* Ensure the Add button has proper spacing */
  .add-ingredient-section .input-group:last-child {
    margin-top: var(--space-sm);
  }
  
  .add-ingredient-section .input-group:last-child button {
    width: 100%;
    margin-top: var(--space-sm);
  }

  .add-labor-section {
    grid-template-columns: 1fr !important;
    gap: var(--space-md);
    padding: var(--space-lg);
  }

  .add-labor-section h4 {
    grid-column: 1;
  }

  .save-recipe-buttons {
    flex-direction: column;
  }

  /* Improved summary controls */
  .summary-controls {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-md);
  }
  
  .summary-controls label {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .input-wrap {
    margin-left: var(--space-md);
  }

  .control-group .number-input.small {
    width: 100%;
  }

  /* Mobile recipe header controls */
  .recipe-header-controls {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-md);
  }
  
  .servings-control {
    justify-content: space-between;
  }

  /* Mobile load recipe controls */
  .load-recipe-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .load-recipe-controls select {
    min-width: auto;
  }

  /* FIXED: Form-row layouts in modals - keep two columns where possible */
  .form-row {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
  }
  
  /* Ensure form groups with input+unit stay compact */
  .form-group .input-with-unit,
  .form-group .input-with-suffix {
    display: flex;
    flex-direction: row;
    align-items: center;
  }

  .modal-content {
    margin: var(--space-sm);
    padding: var(--space-lg);
    width: calc(100% - var(--space-lg));
  }
  
  #subRecipeSaveModal .modal-content {
    max-height: 85vh;
    overflow-y: auto;
  }

  .auth-section {
    margin-left: 0;
    margin-top: 0;
    width: auto;
    justify-content: flex-end;
  }

  .recipe-item h4,
  .recipe-item p {
    padding-right: 0;
  }

  /* Improved recipe actions */
  .recipe-actions {
    position: static;
    transform: none;
    margin-top: var(--space-md);
    justify-content: flex-start;
    width: 100%;
  }
  
  .recipe-actions button {
    flex: 1;
    min-width: 80px;
  }

  /* Mobile view for raw material list actions */
  #rawMaterialsTable td:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    justify-content: flex-end;
  }

  #rawMaterialsTable td:last-child button {
    flex: 1;
    min-width: 60px;
    font-size: 12px;
    padding: var(--space-xs) var(--space-sm);
  }

  /* FIX: Direct Labor table action buttons on mobile */
  #directLaborTable td:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    justify-content: flex-end;
  }

  #directLaborTable td:last-child button {
    flex: 1;
    min-width: 60px;
    font-size: 12px;
    padding: var(--space-xs) var(--space-sm);
  }

  /* Ensure labels and inputs stay on one line in mobile */
  .quantity-input-group,
  .yield-input-group {
    flex-wrap: nowrap;
    min-width: 140px;
  }

  .quantity-unit,
  .yield-percent {
    flex-shrink: 0;
  }

  /* Recipe columns mobile layout */
  .recipe-columns {
    grid-template-columns: 1fr !important;
    gap: var(--space-lg);
  }
  
  .recipe-column {
    margin-bottom: var(--space-xl);
  }

  .recipe-column h4 {
    font-size: 1.1rem;
  }

  /* Direct Labor section mobile adjustments */
  .modal {
    padding: var(--space-md);
  }

  /* Improved touch targets */
  button, .tab-btn, .add-btn, .delRow, .btn-primary, .btn-secondary {
    min-height: 44px;
    padding: var(--space-md) var(--space-lg);
  }
  
  input, select {
    font-size: 16px;
  }

  /* Enhanced Mobile Touch Targets & Vertical Rhythm */
  .recipe-header-controls {
    gap: var(--space-md);
  }
  
  .servings-control {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-xs);
  }
  
  .servings-control label {
    margin-bottom: 0;
  }
  
  .servings-control .input-wrap {
    margin-left: 0;
    width: 100%;
  }
  
  /* Improve form group spacing */
  .input-group {
    margin-bottom: var(--space-md);
  }

  /* Cost breakdown mobile styles */
  .breakdown-table {
    display: block;
    overflow-x: auto;
  }

  .breakdown-content {
    padding: var(--space-md);
  }

  .breakdown-header {
    padding: var(--space-md);
  }

  .breakdown-table th,
  .breakdown-table td {
    padding: var(--space-sm);
    font-size: 12px;
  }

  /* Mobile recipe meta */
  .recipe-meta {
    grid-template-columns: 1fr !important;
    gap: var(--space-sm);
  }

  /* Summary grid mobile improvements */
  .summary-grid {
    display: flex;
    flex-direction: column;
  }
  
  .summary-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  
  .cost-breakdown-preview {
    overflow-x: auto;
  }
}

/* ============================================================================= */
/* UNIFIED CARD STYLING FOR ALL SECTIONS */
/* PURPOSE: Consistent card behavior across Raw Materials, Direct Labor, and Recipes */
/* ============================================================================= */

/* Base card styles for all list items */
.material-card,
.labor-card,
.recipe-item {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  position: relative;
  min-height: auto !important;
  overflow: visible;
}

.material-card:hover,
.labor-card:hover,
.recipe-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Card header styling */
.material-card h4,
.labor-card h4,
.recipe-item h4 {
  margin: 0 0 var(--space-xs) 0;
  font-weight: 600;
  color: var(--text-primary);
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
  line-height: 1.4;
  padding-right: 0;
}

/* Card content styling - simplified display */
.material-card .card-content,
.labor-card .card-content,
.recipe-item .card-content {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0;
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
  line-height: 1.4;
  padding-right: 0;
}

/* Unified card actions */
.material-card .card-actions,
.labor-card .card-actions,
.recipe-item .recipe-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-light);
  justify-content: flex-end;
  position: static;
  transform: none;
}

/* Button styling within cards */
.material-card .card-actions .btn-secondary.small,
.labor-card .card-actions .btn-secondary.small,
.recipe-item .recipe-actions .btn-secondary.small,
.material-card .card-actions .btn-danger.small,
.labor-card .card-actions .btn-danger.small,
.recipe-item .recipe-actions .btn-danger.small {
  padding: 6px 12px;
  font-size: 12px;
  min-height: 32px;
  white-space: nowrap;
}

/* Cards container improvements */
.cards-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: none;
  overflow-y: visible;
  padding-right: 0;
}

/* ============================================================================= */
/* MOBILE RESPONSIVE FIXES FOR UNIFIED CARDS */
/* ============================================================================= */

@media (max-width: 768px) {
  /* Unified mobile card layout */
  .material-card,
  .labor-card,
  .recipe-item {
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
  }

  .material-card h4,
  .labor-card h4,
  .recipe-item h4 {
    font-size: 16px;
    margin-bottom: var(--space-xs);
  }

  .material-card .card-content,
  .labor-card .card-content,
  .recipe-item .card-content {
    font-size: 14px;
  }

  /* Stack card actions vertically on mobile */
  .material-card .card-actions,
  .labor-card .card-actions,
  .recipe-item .recipe-actions {
    flex-direction: column;
    gap: var(--space-xs);
    margin-top: var(--space-md);
  }

  .material-card .card-actions button,
  .labor-card .card-actions button,
  .recipe-item .recipe-actions button {
    width: 100%;
    min-height: 44px;
  }

  /* Ensure recipe columns stack on mobile */
  .recipe-columns {
    grid-template-columns: 1fr !important;
    gap: var(--space-lg);
  }

  .recipe-column {
    margin-bottom: var(--space-xl);
  }
}

/* Extra small screen optimizations */
@media (max-width: 480px) {
  .material-card,
  .labor-card,
  .recipe-item {
    padding: var(--space-sm);
  }

  .material-card h4,
  .labor-card h4,
  .recipe-item h4 {
    font-size: 15px;
  }

  .material-card .card-content,
  .labor-card .card-content,
  .recipe-item .card-content {
    font-size: 13px;
  }
}

/* ============================================================================= */
/* DARK MODE COMPATIBILITY FOR UNIFIED CARDS */
/* ============================================================================= */

body.dark-mode .material-card,
body.dark-mode .labor-card,
body.dark-mode .recipe-item {
  background: var(--surface);
  border-color: var(--border);
}

body.dark-mode .material-card:hover,
body.dark-mode .labor-card:hover,
body.dark-mode .recipe-item:hover {
  background: rgba(45, 90, 61, 0.2);
  border-color: var(--primary);
}

body.dark-mode .material-card .card-actions,
body.dark-mode .labor-card .card-actions,
body.dark-mode .recipe-item .recipe-actions {
  border-top-color: var(--border);
}

/* Print Styles */
@media print {
  /* Hide everything except the print preview */
  body * {
    visibility: hidden;
  }

  #printPreviewModal,
  #printPreviewModal * {
    visibility: visible;
  }

  #printPreviewModal {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: white !important;
    z-index: 9999 !important;
    overflow: visible !important;
  }

  .modal-content.print-preview {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    overflow: visible !important;
  }

  .print-preview-content {
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    padding: 20px !important;
  }

  .modal-header,
  .print-actions {
    display: none !important;
  }

  /* Print-specific styling for better readability */
  .print-header {
    text-align: center;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px;
    margin-bottom: 20px;
  }

  .print-section {
    margin-bottom: 20px;
    page-break-inside: avoid;
  }

  .print-section h3 {
    background: var(--surface-elevated);
    padding: 8px;
    margin: 0 0 10px 0;
    border-left: 4px solid var(--primary);
  }

  .cost-breakdown {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
  }

  .cost-breakdown th {
    background: var(--surface-elevated);
    font-weight: bold;
  }

  .summary-highlight {
    background: var(--surface-elevated) !important;
    font-weight: bold;
  }

  .totals-row {
    border-top: 2px solid #000 !important;
    font-weight: bold;
  }

  .page-break {
    page-break-before: always;
  }

  /* Ensure tables don't break across pages */
  table {
    page-break-inside: avoid;
  }

  /* Print footer */
  .print-footer {
    margin-top: 30px;
    font-size: 10pt;
    color: #666;
    text-align: center;
    border-top: 1px solid #ddd;
    padding-top: 10px;
  }
}

/* ========================================================================== */
/* DARK MODE STYLES - UPDATED FOR REQUESTED CHANGES */
/* ========================================================================== */

body.dark-mode {
  --background: #1a1d23;
  --surface: #252932;
  --surface-elevated: #2d3139;
  --text-primary: #dbdbdb; /* Changed to light gray as requested */
  --text-secondary: #b0b3b8;
  --text-tertiary: #8e8e93;
  --border: #3a3d45;
  --border-light: #2d3139;
  --primary-light: rgba(45, 90, 61, 0.2);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.1);
}

/* Keep logo green in dark mode */
body.dark-mode .site-name {
  color: var(--primary) !important; /* Logo stays green */
}

/* Keep buttons green in dark mode */
body.dark-mode .btn-primary,
body.dark-mode .add-btn,
body.dark-mode .print-btn {
  background: var(--primary) !important; /* Buttons stay green */
  color: white !important;
}

body.dark-mode .btn-primary:hover,
body.dark-mode .add-btn:hover,
body.dark-mode .print-btn:hover {
  background: var(--primary-dark) !important; /* Button hover stays green */
}

/* Keep primary elements that should remain green */
body.dark-mode .sidebar-btn.active {
  background: var(--primary) !important; /* Active sidebar stays green */
  color: white !important;
}

body.dark-mode .mobile-tabs button.active {
  background: var(--primary) !important; /* Active mobile tab stays green */
  color: white !important;
}

body.dark-mode .mobile-tabs button:hover {
  background: var(--primary) !important; /* Mobile tab hover stays green */
  color: white !important;
}

/* Update text colors that were using primary to use light gray */
body.dark-mode .info-panel h4,
body.dark-mode .section-header h2,
body.dark-mode .add-ingredient-section h4,
body.dark-mode .add-labor-section h4,
body.dark-mode .recipe-column h4,
body.dark-mode .labor-section h3,
body.dark-mode .modal-header h3,
body.dark-mode .breakdown-header h3,
body.dark-mode .ad-space h3,
body.dark-mode .total-cost,
body.dark-mode .accent-total,
body.dark-mode .breakdown-total,
body.dark-mode .summary-item,
body.dark-mode .loaded-recipe-info h4,
body.dark-mode .cost-calculation h4 {
  color: var(--text-primary) !important; /* Changed to light gray */
}

/* Update other elements that were using primary color for text */
body.dark-mode .help-icon,
body.dark-mode .field-help,
body.dark-mode .link-btn {
  color: var(--text-primary) !important; /* Changed to light gray */
}

body.dark-mode .link-btn:hover {
  color: var(--text-secondary) !important; /* Lighter gray on hover */
}

/* Update borders that were using primary color */
body.dark-mode .summary-controls > :last-child {
  border-left-color: var(--text-primary) !important; /* Changed to light gray */
}

@media (max-width: 768px) {
  body.dark-mode .summary-controls > :last-child {
    border-top-color: var(--text-primary) !important; /* Changed to light gray */
  }
}

/* Keep focus states using primary (green) for accessibility */
body.dark-mode .btn-primary:focus-visible,
body.dark-mode .btn-secondary:focus-visible,
body.dark-mode .add-btn:focus-visible,
body.dark-mode .print-btn:focus-visible,
body.dark-mode .header-icon-btn:focus-visible {
  outline: 3px solid var(--primary) !important; /* Focus stays green */
  box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.3) !important;
}

/* Update the rest of dark mode styles to use the new text colors */
body.dark-mode .header {
  background: rgba(37, 41, 50, 0.85);
  border-bottom-color: var(--border);
}

body.dark-mode .sidebar {
  background: var(--surface);
  border-right-color: var(--border);
}

body.dark-mode .mobile-tabs {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

body.dark-mode .mobile-tabs button {
  color: var(--text-secondary);
}

body.dark-mode .mobile-tabs button:hover,
body.dark-mode .mobile-tabs button.active {
  color: #ffffff;
  background: var(--primary);
}

body.dark-mode .modal {
  background: rgba(0, 0, 0, 0.6);
}

body.dark-mode .print-preview-content {
  background: var(--surface);
  color: var(--text-primary);
}

body.dark-mode .panel,
body.dark-mode .ad-space,
body.dark-mode .add-ingredient-section,
body.dark-mode .add-labor-section,
body.dark-mode .total-cost,
body.dark-mode .recipe-item,
body.dark-mode .cost-breakdown-preview,
body.dark-mode .data-format,
body.dark-mode .cost-calculation,
body.dark-mode .sub-recipe-breakdown,
body.dark-mode .modal .modal-content,
body.dark-mode .search-input,
body.dark-mode .text-input,
body.dark-mode .number-input,
body.dark-mode .select-input {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
}

/* FIX: Dark mode ad space styling */
body.dark-mode .ad-space {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
}

body.dark-mode .ad-content {
  background: var(--surface-elevated);
  border-color: var(--border);
}

/* Tables & borders in dark mode */
body.dark-mode table,
body.dark-mode th,
body.dark-mode td {
  border-color: var(--border) !important;
}

body.dark-mode th {
  background: var(--surface-elevated) !important;
  color: var(--text-primary) !important;
}

body.dark-mode td {
  background: var(--surface) !important;
  color: var(--text-secondary) !important;
}

body.dark-mode tr:hover td {
  background: rgba(110, 215, 157, 0.08) !important;
}

/* Inputs and selects in dark mode */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
  color: var(--text-secondary);
}

/* FIX: Make green elements white text in dark mode */
body.dark-mode .accent-total {
  background: rgba(45, 90, 61, 0.35);
  border-color: #6ed79d;
  color: #ffffff;
}

/* FIX: Make the text in loaded-recipe-info white in dark mode */
body.dark-mode .loaded-recipe-info {
  background: rgba(45, 90, 61, 0.35);
  border-color: #6ed79d;
  color: #ffffff;
}

body.dark-mode .loaded-recipe-info h4 {
  color: #ffffff;
}

body.dark-mode .loaded-recipe-info p {
  color: #ffffff;
}

body.dark-mode .loaded-recipe-info strong {
  color: #ffffff;
}

/* Dark mode green button styling */
body.dark-mode .btn-primary,
body.dark-mode .add-btn,
body.dark-mode .print-btn {
  background: var(--primary);
  color: white;
}

body.dark-mode .btn-primary:hover,
body.dark-mode .add-btn:hover,
body.dark-mode .print-btn:hover {
  background: var(--primary-dark);
}

/* Menu styles in dark mode */
body.dark-mode .menu-toggle {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-primary);
}

body.dark-mode .menu-dropdown {
  background: var(--surface);
  border-color: var(--border);
}

body.dark-mode .menu-btn {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-primary);
}

body.dark-mode .menu-btn:hover {
  background: var(--surface-elevated);
  border-color: var(--primary);
}

body.dark-mode .menu-btn.primary {
  background: var(--primary);
  color: white;
}

body.dark-mode .sidebar-btn {
  color: var(--text-secondary);
}

body.dark-mode .sidebar-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

body.dark-mode .sidebar-btn.active {
  background: var(--primary);
  color: white;
}

/* FIXED: Dark mode total profit analysis styling */
body.dark-mode .total-profit-analysis {
  background: var(--surface-elevated);
  border-left: 3px solid var(--accent-blue);
}

body.dark-mode .total-profit-analysis:first-of-type {
  border-top: 2px solid var(--accent-blue);
}

@media (min-width: 1024px) {
  body.dark-mode .mobile-tabs button:hover,
  body.dark-mode .mobile-tabs button.active {
    background: var(--primary);
    color: white;
  }
}

/* Additional MacOS-inspired refinements */
::selection {
  background: rgba(45, 90, 61, 0.2);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--surface-elevated);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Focus styles for accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Loading animation for better UX */
@keyframes shimmer {
  0% {
    background-position: -468px 0;
  }
  100% {
    background-position: 468px 0;
  }
}

.loading {
  animation-duration: 1.25s;
  animation-fill-mode: forwards;
  animation-iteration-count: infinite;
  animation-name: shimmer;
  animation-timing-function: linear;
  background: var(--surface-elevated);
  background: linear-gradient(to right, var(--surface-elevated) 8%, var(--border-light) 18%, var(--surface-elevated) 33%);
  background-size: 800px 104px;
  position: relative;
}

/* ============================================================================= */
/* UNIFIED EDIT PROMPT MODAL STYLES */
/* ============================================================================= */

/* Unified Edit Prompt Styles */
.unified-prompt-item {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin: var(--space-md) 0;
    border-left: 4px solid var(--primary);
}

.unified-prompt-item .item-name {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: var(--space-xs);
    font-size: 14px;
}

.unified-prompt-item .item-details {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Enhanced prompt options with better visual hierarchy */
.edit-prompt-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin: var(--space-xl) 0;
}

.edit-prompt-options button {
    padding: var(--space-lg);
    font-size: 14px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
}

.edit-prompt-options .btn-secondary {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-primary);
}

.edit-prompt-options .btn-secondary:hover {
    background: var(--surface-elevated);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.edit-prompt-options .btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.edit-prompt-options .btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.option-content strong {
    display: block;
    margin-bottom: var(--space-xs);
    font-size: 15px;
    font-weight: 600;
}

.option-content small {
    font-size: 12px;
    opacity: 0.8;
    line-height: 1.3;
    max-width: 200px;
}

/* Auto-rename notification */
.auto-rename-notice {
    background: rgba(255, 149, 0, 0.1);
    border: 1px solid var(--warning);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin: var(--space-md) 0;
    font-size: 13px;
    border-left: 3px solid var(--warning);
}

.auto-rename-notice strong {
    color: var(--warning);
    font-weight: 600;
}

.auto-rename-notice.hidden {
    display: none;
}

/* Edit prompt message styling */
.edit-prompt-message {
    line-height: 1.5;
    color: var(--text-primary);
}

.edit-prompt-message p {
    margin-bottom: var(--space-md);
}

.edit-prompt-message strong {
    color: var(--primary);
}

/* Responsive design for prompt modal */
@media (max-width: 768px) {
    .edit-prompt-options {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
    
    .edit-prompt-options button {
        min-height: 70px;
        padding: var(--space-md);
    }
    
    .unified-prompt-item {
        padding: var(--space-md);
    }
}

/* Dark mode adjustments */
body.dark-mode .unified-prompt-item {
    background: var(--surface-elevated);
    border-color: var(--border);
}

body.dark-mode .edit-prompt-options .btn-secondary {
    background: var(--surface);
    border-color: var(--border);
}

body.dark-mode .edit-prompt-options .btn-secondary:hover {
    background: var(--surface-elevated);
    border-color: var(--primary);
}

body.dark-mode .auto-rename-notice {
    background: rgba(255, 149, 0, 0.15);
    border-color: var(--warning);
}

/* ============================================================================= */
/* FIX: ENHANCED MODAL AND BUTTON STYLES FOR BETTER UX */
/* ============================================================================= */

/* Enhanced loading states for buttons */
.btn-primary.loading, 
.btn-secondary.loading,
.add-btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-primary.loading::after, 
.btn-secondary.loading::after,
.add-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Enhanced error states for inputs */
.input-with-suffix.error,
.input-with-unit.error {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.15) !important;
}

/* Enhanced success states */
.input-with-suffix.success,
.input-with-unit.success {
    border-color: var(--success) !important;
    box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.15) !important;
}

/* Improved modal backdrop */
.modal {
    backdrop-filter: blur(8px) saturate(180%);
    -webkit-backdrop-filter: blur(8px) saturate(180%);
    background: rgba(0, 0, 0, 0.5) !important;
}

/* Enhanced auth modal specific styles */
#authModal .modal-content {
    max-width: 400px;
}

#authModal .password-input-group {
    position: relative;
}

#authModal .password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
}

#authModal .password-toggle:hover {
    background: var(--primary-light);
    color: var(--text-primary);
}

/* Enhanced duplicate prompt modal */
.edit-prompt-modal .modal-content {
    max-width: 500px;
}

.edit-prompt-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin: var(--space-xl) 0;
}

.edit-prompt-options button {
    padding: var(--space-md);
    font-size: 14px;
    font-weight: 600;
}

/* Enhanced direct labor section */
.add-labor-section .input-with-unit {
    transition: all 0.3s ease;
}

.add-labor-section .readonly-input {
    background-color: var(--surface-elevated);
    border-color: var(--border-light);
    color: var(--text-secondary);
    cursor: not-allowed;
}

/* Enhanced focus states for accessibility */
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.add-btn:focus-visible,
.header-icon-btn:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.3);
}

/* Enhanced notification styles */
.global-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    box-shadow: var(--shadow-xl);
    z-index: 10000;
    animation: slideInRight 0.3s ease;
    max-width: 400px;
}

.global-notification.success {
    border-left: 4px solid var(--success);
}

.global-notification.error {
    border-left: 4px solid var(--danger);
}

.global-notification.info {
    border-left: 4px solid var(--accent-blue);
}

.global-notification.warning {
    border-left: 4px solid var(--warning);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Mobile responsive improvements */
@media (max-width: 768px) {
    .edit-prompt-options {
        grid-template-columns: 1fr;
    }
    
    .global-notification {
        left: 20px;
        right: 20px;
        max-width: none;
    }
}

/* ============================================================================= */
/* ENHANCED VISUAL FEEDBACK FOR FIXES */
/* ============================================================================= */

/* Success state for labor rate display */
#selectedLaborRate.success {
    border-color: var(--success);
    background-color: rgba(52, 199, 89, 0.05);
}

/* Error state for inputs */
input.error {
    border-color: var(--danger) !important;
    background-color: rgba(255, 59, 48, 0.05) !important;
}

/* Auto-save indicator */
.auto-save-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-sm) var(--space-md);
    font-size: 12px;
    color: var(--text-secondary);
    z-index: 1000;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.auto-save-indicator.saving {
    color: var(--warning);
    border-color: var(--warning);
}

.auto-save-indicator.saved {
    color: var(--success);
    border-color: var(--success);
}

/* Enhanced password toggle styles */
.password-toggle {
    transition: var(--transition);
}

.password-toggle:hover {
    background: var(--primary-light);
    transform: scale(1.1);
}

.password-toggle:active {
    transform: scale(0.95);
}

/* Sub-recipe modal validation styles */
#subRecipeNameDisplay:valid {
    border-color: var(--success);
}

#subRecipeNameDisplay:invalid {
    border-color: var(--danger);
}

/* Direct labor selection feedback */
#directLaborSelect option:checked {
    background: linear-gradient(45deg, var(--primary-light), var(--primary));
    color: var(--primary-dark);
    font-weight: 600;
}

/* Loading states for async operations */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

/* Enhanced notification styles */
.global-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    box-shadow: var(--shadow-xl);
    z-index: 10000;
    animation: slideInRight 0.3s ease;
    max-width: 400px;
    border-left: 4px solid var(--accent-blue);
}

.global-notification.success {
    border-left-color: var(--success);
}

.global-notification.error {
    border-left-color: var(--danger);
}

.global-notification.warning {
    border-left-color: var(--warning);
}

.notification-content {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
}

.notification-message {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
}

.notification-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.notification-close:hover {
    background: var(--primary-light);
    color: var(--text-primary);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================================================= */
/* MOBILE RESPONSIVE ADJUSTMENTS FOR NEW FEATURES */
/* ============================================================================= */

@media (max-width: 768px) {
  /* TIP message mobile adjustments */
  .tip-message {
    margin: var(--space-md) 0 var(--space-lg) 0;
    padding: var(--space-md);
    font-size: 12px;
  }
  
  /* Header spacing adjustments */
  .section-header {
    margin-bottom: var(--space-xl) !important;
    padding-bottom: var(--space-md);
  }
  
  /* Heading size adjustments */
  .current-recipe h3,
  .labor-section h3,
  .recipe-list > h3,
  .saved-recipes-heading {
    font-size: 1.2rem !important;
    margin-bottom: var(--space-lg);
  }
  
  /* Sub-heading adjustments */
  .add-ingredient-section h4,
  .add-labor-section h4,
  .recipe-column h4 {
    font-size: 1rem !important;
    margin-bottom: var(--space-sm);
  }
  
  /* Content area spacing */
  .content-area {
    margin-top: var(--space-sm);
  }
}

@media (max-width: 480px) {
  /* Extra small device adjustments */
  .current-recipe h3,
  .labor-section h3,
  .recipe-list > h3 {
    font-size: 1.1rem !important;
    margin-bottom: var(--space-md);
  }
}

/* ============================================================================= */
/* ENHANCED CARD LAYOUT FOR SIMPLIFIED DISPLAY */
/* ============================================================================= */

/* Raw Materials and Direct Labor Cards - Simplified Layout */
.material-card,
.labor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.material-card:hover,
.labor-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card-header {
  display: flex;
  justify-content: between;
  align-items: flex-start;
  margin-bottom: var(--space-sm);
}

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

/* Simplified Card Details - Only Cost Display */
.card-details {
  margin-bottom: var(--space-md);
}

.cost-display {
  font-size: 14px;
  color: var(--text-secondary);
  padding: var(--space-xs) 0;
}

/* Card Actions - Consistent with Saved Recipes */
.card-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  border-top: 1px solid var(--border-light);
  padding-top: var(--space-md);
}

.card-actions .btn-secondary.small,
.card-actions .btn-danger.small {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-md);
}

/* Ensure consistency with Saved Recipes list styling */
.recipe-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  transition: all 0.2s ease;
}

.recipe-item:hover {
  box-shadow: var(--shadow-md);
}

.recipe-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-light);
}

/* Responsive adjustments for simplified layout */
@media (max-width: 768px) {
  .material-card,
  .labor-card {
    padding: var(--space-sm);
  }
  
  .card-actions {
    flex-direction: column;
  }
  
  .card-actions button {
    width: 100%;
  }
}

/* Two-column layout enhancements for simplified cards */
.two-column-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  align-items: start;
}

@media (max-width: 1024px) {
  .two-column-layout {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }
}

/* Search container styling */
.search-container {
  margin-bottom: var(--space-lg);
}

.search-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 14px;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* Cards container layout */
.cards-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  max-height: 100vh;
  overflow-y: auto;
  padding-right: var(--space-sm);
}

/* Scrollbar styling for cards container */
.cards-container::-webkit-scrollbar {
  width: 6px;
}

.cards-container::-webkit-scrollbar-track {
  background: var(--background);
  border-radius: 3px;
}

.cards-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.cards-container::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* ============================================================================= */
/* NEW: RECIPE CALCULATOR TAB MODAL STYLES */
/* ============================================================================= */

.modal-content.large {
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-body {
  padding: var(--space-lg);
}

.create-recipe-section {
  text-align: center;
  padding: var(--space-xl);
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-xl);
}

.add-btn.large {
  padding: var(--space-md) var(--space-lg);
  font-size: 18px;
  font-weight: 600;
}

.helper-text {
  margin-top: var(--space-sm);
  color: var(--text-secondary);
  font-size: 14px;
}

/* Adjust the recipe list in the recipe calculator tab */
.recipe-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  margin-top: var(--space-lg);
}

.recipe-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.recipe-column h4 {
  color: var(--primary);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-light);
  font-weight: 700;
  letter-spacing: -0.1px;
}

/* Ensure the recipe list in the modal is styled correctly */
#recipeBuilderModal .current-recipe,
#recipeBuilderModal .labor-section {
  margin-top: 0;
}

/* Dark mode adjustments for new elements */
body.dark-mode .material-card,
body.dark-mode .labor-card {
  background: var(--surface);
  border-color: var(--border);
}

body.dark-mode .create-recipe-section {
  background: var(--surface);
  border-color: var(--border);
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .two-column-layout {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .cards-container {
    grid-template-columns: 1fr;
  }

  .recipe-columns {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .modal-content.large {
    width: 95%;
    margin: var(--space-sm);
  }
}

/* ============================================================================= */
/* NEW: RECIPE CALCULATOR MODAL UPDATES - SECTION HEADER WITH TOTALS */
/* ============================================================================= */

/* Dark mode color update for saved recipes */
body.dark-mode .saved-recipes-heading {
  color: var(--text-primary) !important;
}

/* Ensure Main Recipe and Sub-recipe labels use consistent color */
body.dark-mode .recipe-column h4 {
  color: var(--text-primary) !important;
}

/* New Section Header with Total Layout */
.section-header-with-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  padding: 0;
  background: transparent;
  border: none;
}

.section-header-with-total .section-title h4 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.section-header-with-total .section-total {
  margin: 0;
}

.section-header-with-total .total-cost {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-weight: 700;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  margin: 0;
  white-space: nowrap;
}

/* Remove margins from totals when in header position */
.section-header-with-total .total-cost {
  margin-bottom: 0 !important;
}

/* Update Add Section Layouts (Remove Headers) */
.add-ingredient-section h4,
.add-labor-section h4 {
  display: none;
}

/* Update spacing for add sections without headers */
.add-ingredient-section,
.add-labor-section {
  padding-top: var(--space-md);
  margin-top: 0;
}

.add-ingredient-section {
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--surface-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin: 0 0 var(--space-xl) 0;
  align-items: end;
}

.add-labor-section {
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--surface-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin: 0 0 var(--space-xl) 0;
  align-items: end;
}

/* Remove Old Total Footer Styles */
.labor-section .table-footer,
.current-recipe .table-footer:first-of-type {
  display: none;
}

/* Responsive Design for New Layout */
@media (max-width: 768px) {
  .section-header-with-total {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-md);
  }
  
  .section-header-with-total .section-total {
    align-self: center;
  }
  
  .section-header-with-total .total-cost {
    text-align: center;
    padding: var(--space-sm);
  }
  
  .add-ingredient-section,
  .add-labor-section {
    grid-template-columns: 1fr !important;
    gap: var(--space-md);
  }
}

/* Dark Mode Styling for New Elements */
body.dark-mode .section-header-with-total .section-title h4 {
  color: var(--text-primary) !important;
}

body.dark-mode .section-header-with-total .total-cost {
  background: var(--surface-elevated);
  border-color: var(--border);
  color: var(--text-primary);
}

/* EMERGENCY CSS - Force disabled state visibility */
.sub-recipe-field-disabled,
#modalSubRecipeCategory:disabled,
#modalSubRecipeYieldUnit:disabled, 
#modalSubRecipeCostUnit:disabled {
    opacity: 0.7 !important;
    cursor: not-allowed !important;
    background-color: #f5f5f5 !important;
    border-color: #ccc !important;
    color: #666 !important;
    pointer-events: none !important;
}

.field-disabled-note {
    font-size: 0.8em !important;
    color: #666 !important;
    font-style: italic !important;
    margin-top: 4px !important;
    padding: 4px 8px !important;
    background: #f0f0f0 !important;
    border-radius: 4px !important;
    border: 1px solid #ddd !important;
}

.menu-toggle {
  /* Ensure the header menu button remains visible (if present in DOM) */
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  border: 1px solid var(--border) !important;
  width: 44px !important;
  height: 44px !important;
  padding: 6px !important;
  border-radius: var(--radius-md) !important;
  cursor: pointer !important;
  box-shadow: var(--shadow-sm);
}

/* ============================================================================= */
/* FIX: MOBILE VIEW DIRECT LABOR TABLE EMPTY SPACE */
/* PURPOSE: Remove annoying empty space on right side of labor item table */
/* ============================================================================= */

@media (max-width: 768px) {
  /* Fix Direct Labor table container width */
  #directLaborPreview .table-container {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
  }

  /* Ensure Direct Labor table uses exact column widths without extra space */
  #directLaborPreview .breakdown-table {
    width: auto !important;
    min-width: 100% !important;
    table-layout: auto !important;
  }

  /* Adjust Direct Labor column widths for mobile */
  #directLaborPreview .breakdown-table th:nth-child(1),
  #directLaborPreview .breakdown-table td:nth-child(1) {
    width: 35% !important; /* Labor Item */
    min-width: 120px !important;
    max-width: 35% !important;
  }

  #directLaborPreview .breakdown-table th:nth-child(2),
  #directLaborPreview .breakdown-table td:nth-child(2) {
    width: 25% !important; /* Time Required */
    min-width: 90px !important;
    max-width: 25% !important;
  }

  #directLaborPreview .breakdown-table th:nth-child(3),
  #directLaborPreview .breakdown-table td:nth-child(3) {
    width: 20% !important; /* Rate */
    min-width: 80px !important;
    max-width: 20% !important;
  }

  #directLaborPreview .breakdown-table th:nth-child(4),
  #directLaborPreview .breakdown-table td:nth-child(4) {
    width: 20% !important; /* Total Cost */
    min-width: 80px !important;
    max-width: 20% !important;
  }

  /* Remove any right padding/margin that creates empty space */
  #directLaborPreview .breakdown-content,
  #directLaborPreview .table-container,
  #directLaborPreview .breakdown-table {
    padding-right: 0 !important;
    margin-right: 0 !important;
  }

  /* Ensure the table container doesn't have unnecessary scroll space */
  #directLaborPreview .table-container::-webkit-scrollbar {
    display: none !important;
  }

  #directLaborPreview .table-container {
    -ms-overflow-style: none !important;
    scrollbar-width: none !important;
  }
}

/* Additional fix for very small screens */
@media (max-width: 480px) {
  #directLaborPreview .breakdown-table th:nth-child(1),
  #directLaborPreview .breakdown-table td:nth-child(1) {
    width: 40% !important; /* Labor Item - more space on very small screens */
    min-width: 100px !important;
  }

  #directLaborPreview .breakdown-table th:nth-child(2),
  #directLaborPreview .breakdown-table td:nth-child(2) {
    width: 25% !important; /* Time Required */
    min-width: 70px !important;
  }

  #directLaborPreview .breakdown-table th:nth-child(3),
  #directLaborPreview .breakdown-table td:nth-child(3) {
    width: 15% !important; /* Rate */
    min-width: 60px !important;
  }

  #directLaborPreview .breakdown-table th:nth-child(4),
  #directLaborPreview .breakdown-table td:nth-child(4) {
    width: 20% !important; /* Total Cost */
    min-width: 70px !important;
  }

  /* Reduce font size for better fit */
  #directLaborPreview .breakdown-table th,
  #directLaborPreview .breakdown-table td {
    font-size: 12px !important;
    padding: 8px 6px !important;
  }
}

/* Fix for Raw Materials table as well (prevent same issue) */
@media (max-width: 768px) {
  #rawMaterialsPreview .table-container {
    width: 100% !important;
    max-width: 100% !important;
  }

  #rawMaterialsPreview .breakdown-table {
    width: auto !important;
    min-width: 100% !important;
    table-layout: auto !important;
  }

  /* Adjust Raw Materials column widths */
  #rawMaterialsPreview .breakdown-table th:nth-child(1),
  #rawMaterialsPreview .breakdown-table td:nth-child(1) {
    width: 40% !important;
    min-width: 130px !important;
  }

  #rawMaterialsPreview .breakdown-table th:nth-child(3),
  #rawMaterialsPreview .breakdown-table td:nth-child(3) {
    width: 20% !important;
    min-width: 70px !important;
  }

  #rawMaterialsPreview .breakdown-table th:nth-child(4),
  #rawMaterialsPreview .breakdown-table td:nth-child(4) {
    width: 20% !important;
    min-width: 80px !important;
  }

  #rawMaterialsPreview .breakdown-table th:nth-child(5),
  #rawMaterialsPreview .breakdown-table td:nth-child(5) {
    width: 20% !important;
    min-width: 80px !important;
  }
}

/* ============================================================================= */
/* FIX: SUMMARY TAB COLUMN ALIGNMENT */
/* PURPOSE: Align specific columns left and right as requested */
/* ============================================================================= */

/* Raw Materials Table Alignment */
#rawMaterialsPreview .breakdown-table th:nth-child(1),  /* Raw Material */
#rawMaterialsPreview .breakdown-table td:nth-child(1) {
    text-align: left !important;
}

#rawMaterialsPreview .breakdown-table th:nth-child(3),  /* Qty */
#rawMaterialsPreview .breakdown-table td:nth-child(3),
#rawMaterialsPreview .breakdown-table th:nth-child(4),  /* Unit Cost */
#rawMaterialsPreview .breakdown-table td:nth-child(4),
#rawMaterialsPreview .breakdown-table th:nth-child(5),  /* Total Cost */
#rawMaterialsPreview .breakdown-table td:nth-child(5) {
    text-align: right !important;
}

/* Direct Labor Table Alignment */
#directLaborPreview .breakdown-table th:nth-child(1),  /* Labor Item */
#directLaborPreview .breakdown-table td:nth-child(1) {
    text-align: left !important;
}

#directLaborPreview .breakdown-table th:nth-child(2),  /* Time Required */
#directLaborPreview .breakdown-table td:nth-child(2),
#directLaborPreview .breakdown-table th:nth-child(3),  /* Rate */
#directLaborPreview .breakdown-table td:nth-child(3),
#directLaborPreview .breakdown-table th:nth-child(4),  /* Total Cost */
#directLaborPreview .breakdown-table td:nth-child(4) {
    text-align: right !important;
}

/* Ensure consistent padding for aligned columns */
#rawMaterialsPreview .breakdown-table td,
#directLaborPreview .breakdown-table td {
    padding-left: var(--space-md) !important;
    padding-right: var(--space-md) !important;
}

/* Add some right padding to right-aligned columns for better spacing */
#rawMaterialsPreview .breakdown-table td:nth-child(3),
#rawMaterialsPreview .breakdown-table td:nth-child(4),
#rawMaterialsPreview .breakdown-table td:nth-child(5),
#directLaborPreview .breakdown-table td:nth-child(2),
#directLaborPreview .breakdown-table td:nth-child(3),
#directLaborPreview .breakdown-table td:nth-child(4) {
    padding-right: var(--space-lg) !important;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    /* Reduce padding on mobile for right-aligned columns */
    #rawMaterialsPreview .breakdown-table td:nth-child(3),
    #rawMaterialsPreview .breakdown-table td:nth-child(4),
    #rawMaterialsPreview .breakdown-table td:nth-child(5),
    #directLaborPreview .breakdown-table td:nth-child(2),
    #directLaborPreview .breakdown-table td:nth-child(3),
    #directLaborPreview .breakdown-table td:nth-child(4) {
        padding-right: var(--space-md) !important;
    }
    
    /* Ensure text doesn't break alignment on small screens */
    #rawMaterialsPreview .breakdown-table td,
    #directLaborPreview .breakdown-table td {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
}

/* ============================================================================= */
/* ALTERNATIVE SUBTOTAL FIX - MORE SPECIFIC TARGETING */
/* ============================================================================= */

/* Target the specific subtotal cells by their content or position */
#rawMaterialsPreview tfoot tr td:last-child,
#directLaborPreview tfoot tr td:last-child {
    text-align: right !important;
    padding-right: var(--space-lg) !important;
    font-weight: 600 !important;
}

/* Ensure the label part remains left-aligned */
#rawMaterialsPreview tfoot tr td:first-child,
#directLaborPreview tfoot tr td:first-child {
    text-align: left !important;
    padding-left: var(--space-md) !important;
    font-weight: 600 !important;
}

/* ============================================================================= */
/* ADJUST COLUMN WIDTHS - RAW MATERIALS TABLE */
/* ============================================================================= */

#rawMaterialsPreview .breakdown-table th:nth-child(1),  /* Raw Material */
#rawMaterialsPreview .breakdown-table td:nth-child(1) {
    width: 40% !important;  /* Increase/Decrease this percentage */
    min-width: 200px !important;
    max-width: 300px !important;
}

#rawMaterialsPreview .breakdown-table th:nth-child(3),  /* Qty */
#rawMaterialsPreview .breakdown-table td:nth-child(3) {
    width: 20% !important;
    min-width: 100px !important;
    max-width: 140px !important;
}

#rawMaterialsPreview .breakdown-table th:nth-child(4),  /* Unit Cost */
#rawMaterialsPreview .breakdown-table td:nth-child(4) {
   width: 20% !important;
    min-width: 100px !important;
    max-width: 140px !important;
}

#rawMaterialsPreview .breakdown-table th:nth-child(5),  /* Total Cost */
#rawMaterialsPreview .breakdown-table td:nth-child(5) {
    width: 25% !important;
    min-width: 100px !important;
    max-width: 140px !important;
}

/* ============================================================================= */
/* ADJUST COLUMN WIDTHS - DIRECT LABOR TABLE */
/* ============================================================================= */

#directLaborPreview .breakdown-table th:nth-child(1),  /* Labor Item */
#directLaborPreview .breakdown-table td:nth-child(1) {
    width: 40% !important;
    min-width: 180px !important;
    max-width: 250px !important;
}

#directLaborPreview .breakdown-table th:nth-child(2),  /* Time Required */
#directLaborPreview .breakdown-table td:nth-child(2) {
    width: 20% !important;
    min-width: 100px !important;
    max-width: 140px !important;
}

#directLaborPreview .breakdown-table th:nth-child(3),  /* Rate */
#directLaborPreview .breakdown-table td:nth-child(3) {
    width: 20% !important;
    min-width: 100px !important;
    max-width: 140px !important;
}

#directLaborPreview .breakdown-table th:nth-child(4),  /* Total Cost */
#directLaborPreview .breakdown-table td:nth-child(4) {
    width: 25% !important;
    min-width: 100px !important;
    max-width: 140px !important;
}

/* ============================================================================= */
/* MOBILE COLUMN WIDTH ADJUSTMENTS */
/* ============================================================================= */

@media (max-width: 768px) {
    /* Raw Materials - Mobile */
    #rawMaterialsPreview .breakdown-table th:nth-child(1),
    #rawMaterialsPreview .breakdown-table td:nth-child(1) {
        width: 35% !important;
        min-width: 120px !important;
        max-width: 200px !important;
    }

    #rawMaterialsPreview .breakdown-table th:nth-child(3),
    #rawMaterialsPreview .breakdown-table td:nth-child(3) {
        width: 20% !important;
        min-width: 60px !important;
        max-width: 80px !important;
    }

    #rawMaterialsPreview .breakdown-table th:nth-child(4),
    #rawMaterialsPreview .breakdown-table td:nth-child(4) {
        width: 20% !important;
        min-width: 80px !important;
        max-width: 100px !important;
    }

    #rawMaterialsPreview .breakdown-table th:nth-child(5),
    #rawMaterialsPreview .breakdown-table td:nth-child(5) {
        width: 25% !important;
        min-width: 80px !important;
        max-width: 100px !important;
    }

    /* Direct Labor - Mobile */
    #directLaborPreview .breakdown-table th:nth-child(1),
    #directLaborPreview .breakdown-table td:nth-child(1) {
        width: 35% !important;
        min-width: 120px !important;
        max-width: 180px !important;
    }

    #directLaborPreview .breakdown-table th:nth-child(2),
    #directLaborPreview .breakdown-table td:nth-child(2) {
        width: 22% !important;
        min-width: 80px !important;
        max-width: 100px !important;
    }

    #directLaborPreview .breakdown-table th:nth-child(3),
    #directLaborPreview .breakdown-table td:nth-child(3) {
        width: 21% !important;
        min-width: 80px !important;
        max-width: 100px !important;
    }

    #directLaborPreview .breakdown-table th:nth-child(4),
    #directLaborPreview .breakdown-table td:nth-child(4) {
        width: 22% !important;
        min-width: 80px !important;
        max-width: 100px !important;
    }
}

.action-buttons-column {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.action-row-1, .action-row-2 {
  display: flex;
  justify-content: flex-end;
}

.action-row-1 button,
.action-row-2 button {
  width: 100%;
  min-width: 60px;
}

/* Card layout for 2-row structure */
.card-content-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  width: 100%;
}

.card-left-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-right-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: flex-start;
  min-width: 80px;
}

.card-title-row {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
}

.card-details-row {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.2;
}

.action-row-1,
.action-row-2 {
  display: flex;
  justify-content: flex-end;
}

/* Ensure consistent card height */
.recipe-item {
  min-height: 60px;
  display: flex;
  align-items: center;
}

/* --- New Logo and Branding Styles --- */

/* Group the logo and site name for horizontal layout */
.brand-title-group {
    display: flex;
    align-items: center; /* Vertically center the logo and text */
    gap: 0px; /* Space between the logo and the site name */
}

/* Style for the new logo image */
.brand-logo {
    /* Adjust height to align with the text, maintaining aspect ratio */
    height: 30px; 
    width: auto;
}

/* Ensure the site name and slogan have no conflicting margins */
.site-name {
    margin: 0;
    line-height: 1; /* Tighter line height for better vertical alignment */
}

.site-slogan {
    margin-top: 2px; /* Small space below the main title/logo group */
}

/* ============================================================================= */
/* SIMPLE FIX: LOGO + NAME IN SAME ROW */
/* ============================================================================= */

.brand-container {
    display: flex;
    flex-direction: column;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.logo {
    height: 30px;
    width: auto;
}

.name {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.slogan {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .brand-row {
        gap: 6px;
    }
    
    .logo {
        height: 24px;
    }
    
    .name {
        font-size: 17px;
    }
    
    .slogan {
        font-size: 11px;
    }
}

/* Custom splash screen styles */
@media all and (display-mode: standalone) {
  /* Custom splash screen styling when app is launched */
  body::before {
    content: '';
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #2D5A3D;
    background-image: url('./images/ProfitPerPlate Logo.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100px;
    z-index: 9999;
    transition: opacity 0.5s ease;
  }
  
  body.loaded::before {
    opacity: 0;
    pointer-events: none;
  }
}

/* Limit warning styles */
.limit-warning {
    color: #ff6b6b !important;
    font-weight: bold;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* Upgrade modal styles */
.upgrade-message {
    text-align: center;
    padding: 20px;
}

.upgrade-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.free-vs-premium {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 25px 0;
}

.free-vs-premium .plan {
    background: var(--surface);
    padding: 20px;
    border-radius: 10px;
    text-align: left;
}

.free-vs-premium .plan h5 {
    margin: 0 0 15px 0;
    text-align: center;
}

.free-vs-premium .plan.free {
    border: 2px solid var(--border-color);
}

.free-vs-premium .plan.premium {
    border: 2px solid var(--primary);
    background: linear-gradient(135deg, var(--primary-light), var(--surface));
}

.free-vs-premium .plan ul {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
}

.free-vs-premium .plan li {
    padding: 5px 0;
    display: flex;
    align-items: center;
}

.free-vs-premium .plan li:before {
    content: "✓";
    margin-right: 8px;
    font-weight: bold;
}

.pricing {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin: 25px 0;
}

.price-option {
    background: var(--surface);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.price-option .price {
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 15px;
}

.price-option .price span {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: normal;
}

.save-badge {
    background: #4CAF50;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    display: inline-block;
    margin-bottom: 10px;
}

.guarantee-note {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 15px;
}

/* Ad space in app */
.ad-space {
    margin-top: 30px;
    padding: 20px;
    background: var(--surface);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.ad-space h3 {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
}

.ad-unit {
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-secondary);
}

.ad-remove-note {
    font-size: 0.9rem;
    margin-top: 15px;
    color: var(--primary);
}

.limit-reached {
    color: #ff4757 !important;
    font-weight: bold !important;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}