/* ========================================================================== */
/* BACTIZAD FORMULATOR - OPTIMIZED GUI                                       */
/* Version: 3.6.0 - Enhanced for optimal UX and visual hierarchy             */
/* ========================================================================== */

/* ========================================================================== */
/* BASE & RESET                                                              */
/* ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 15px; /* Slightly reduced for better density */
    scroll-behavior: smooth;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6; /* Improved readability */
    color: #1f2937;
    background: linear-gradient(180deg, #f9fafb 0%, #f8f9fa 100%);
    background-attachment: fixed;
    direction: ltr;
    text-align: left;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================================================== */
/* LAYOUT & CONTAINERS                                                       */
/* ========================================================================== */

#appRoot {
    opacity: 0;
    transition: opacity 0.5s ease-in;
}

#appRoot[style*="display: block"] {
    opacity: 1;
}

.container {
    max-width: 1600px; /* Increased for better full-screen utilization */
    margin: 0 auto;
    padding: 0 1.5rem;
}

.layout {
    display: block;
    padding-top: 65px; /* Reduced header padding */
    min-height: calc(100vh - 65px);
    background: #f8f9fa;
}

.main {
    width: 100%;
}

/* ========================================================================== */
/* HEADER - Fixed & Compact                                                  */
/* ========================================================================== */

.header {
    background: #ffffff;
    color: #111827;
    padding: 0.875rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.08);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    border-bottom: 1px solid #e5e7eb;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo {
    height: 42px; /* Reduced from 50px */
    width: auto;
    border-radius: 6px;
}

.title-section h1 {
    font-size: 1.5rem; /* Reduced from 1.8rem */
    font-weight: 600;
    margin-bottom: 0;
    line-height: 1.2;
    color: #111827;
}

.subtitle {
    font-size: 0.8rem; /* Reduced from 0.9rem */
    opacity: 0.7;
    font-weight: 400;
    margin-top: 0.125rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.user-box {
    font-size: 0.85rem;
}

/* ========================================================================== */
/* TYPOGRAPHY                                                                */
/* ========================================================================== */

h1 {
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.75rem;
}

h2 {
    font-size: 1.35rem; /* Reduced from 1.5rem */
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.5rem;
    color: #111827;
}

h3 {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.5rem;
    color: #1f2937;
}

h4 {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.5rem;
    color: #374151;
}

/* ========================================================================== */
/* BUTTONS - Compact & Consistent                                            */
/* ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem; /* Reduced from 0.5rem */
    padding: 0.5rem 1rem; /* Reduced from 0.75rem 1.5rem */
    border: none;
    border-radius: 6px; /* Reduced from 8px */
    font-size: 0.85rem; /* Reduced from 0.9rem */
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    justify-content: center;
    position: relative;
    overflow: hidden;
    line-height: 1.4;
}

.btn i {
    font-size: 0.85rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25), 0 1px 3px rgba(37, 99, 235, 0.2);
    border: 1px solid #2563eb;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(29, 78, 216, 0.35), 0 2px 8px rgba(29, 78, 216, 0.25);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
}

.btn-secondary:hover:not(:disabled) {
    background: #e5e7eb;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    color: #111827;
}

.btn-outline {
    background: transparent;
    color: #2563eb;
    border: 1.5px solid #2563eb; /* Reduced border width */
}

.btn-outline:hover:not(:disabled) {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 1px 3px rgba(16, 185, 129, 0.2);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 1px 3px rgba(239, 68, 68, 0.2);
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    top: 50%;
    left: 50%;
    margin-left: -7px;
    margin-top: -7px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: btnSpinner 0.6s linear infinite;
}

@keyframes btnSpinner {
    to { transform: rotate(360deg); }
}

/* ========================================================================== */
/* CONTENT AREAS                                                             */
/* ========================================================================== */

.content {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
    border: 1px solid #e5e7eb;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.content:hover {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.06);
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* ========================================================================== */
/* TAB NAVIGATION - Compact & Modern                                         */
/* ========================================================================== */

.tab-nav {
    display: flex;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    overflow-x: auto;
    scrollbar-width: thin;
}

.tab-btn {
    flex: 1;
    padding: 0.75rem 1.25rem; /* Reduced from 1rem 1.5rem */
    border: none;
    background: transparent;
    color: #6b7280;
    font-weight: 500;
    font-size: 0.9rem; /* Reduced from default */
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.tab-btn i {
    font-size: 0.9rem;
}

.tab-btn:hover {
    background: #f9fafb;
    color: #111827;
}

.tab-btn.active {
    color: #2563eb;
    background: #ffffff;
    border-bottom-color: #2563eb;
    font-weight: 600;
    position: relative;
}

.tab-btn.active::before {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    border-radius: 2px 2px 0 0;
}

/* ========================================================================== */
/* TAB PANELS                                                                */
/* ========================================================================== */

.tab-content {
    min-height: 500px; /* Reduced from 600px */
}

.tab-panel {
    display: none;
    padding: 1.25rem; /* Reduced from 2rem */
    background: #ffffff;
}

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

/* ========================================================================== */
/* PANEL HEADERS - More Compact                                              */
/* ========================================================================== */

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f3f4f6;
    flex-wrap: wrap;
    gap: 1rem;
    position: relative;
}

.panel-header::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    border-radius: 2px;
}

.panel-header h2 {
    font-size: 1.25rem; /* Reduced from 1.5rem */
    font-weight: 600;
    color: #111827;
    margin-bottom: 0;
}

.panel-actions {
    display: flex;
    gap: 0.5rem; /* Reduced from 0.75rem */
    align-items: center;
    flex-wrap: wrap;
}

/* ========================================================================== */
/* FORM ELEMENTS - Compact & Consistent                                      */
/* ========================================================================== */

.form-group {
    margin-bottom: 1rem; /* Reduced from 1.25rem */
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem; /* Reduced from 0.5rem */
    font-weight: 500;
    color: #374151;
    font-size: 0.85rem; /* Reduced from 0.95rem */
    line-height: 1.4;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem; /* Reduced from 0.75rem */
    border: 1.5px solid #d1d5db; /* Reduced from 2px */
    border-radius: 6px; /* Reduced from 10px */
    font-size: 0.85rem; /* Reduced from 0.95rem */
    transition: all 0.2s ease;
    background: #ffffff;
    color: #111827;
    line-height: 1.4;
}

.form-control:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12), 0 2px 8px rgba(37, 99, 235, 0.08);
    transform: translateY(-1px);
    transition: all 0.2s ease;
}

.form-control:disabled {
    background-color: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
    opacity: 0.6;
}

.form-control.is-valid {
    border-color: #10b981;
}

.form-control.is-invalid {
    border-color: #ef4444;
}

.form-feedback {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.8rem;
    font-weight: 500;
}

.form-feedback.valid-feedback {
    color: #059669;
}

.form-feedback.invalid-feedback {
    color: #dc2626;
}

/* Input Groups */
.input-group {
    display: flex;
    position: relative;
}

.input-addon {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
}

/* Checkboxes */
input[type="checkbox"] {
    width: 16px; /* Reduced from 18px */
    height: 16px;
    margin-left: 0.5rem;
    accent-color: #2563eb;
    cursor: pointer;
}

/* ========================================================================== */
/* DATA TABLES - Optimized for Screen Space                                  */
/* ========================================================================== */

.data-table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    margin-bottom: 1.5rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 0.85rem; /* Reduced from 0.9rem */
}

.data-table th {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    color: #111827;
    font-weight: 600;
    padding: 0.75rem 0.85rem;
    text-align: left;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
    font-size: 0.75rem;
    line-height: 1.4;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

.data-table th.numeric {
    text-align: right !important;
    padding-right: 0.85rem;
}

.data-table td {
    padding: 0.5rem 0.85rem; /* Reduced from 0.75rem 1rem */
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
    background: #ffffff;
    color: #374151;
    text-align: left;
    line-height: 1.4;
}

.data-table td.numeric {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    padding-right: 0.85rem;
}

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

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

/* Table Actions */
.table-actions {
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
}

.table-actions .btn {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
}

/* ========================================================================== */
/* METRICS CARDS - Compact Layout                                            */
/* ========================================================================== */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); /* Reduced from 200px */
    gap: 0.85rem; /* Reduced from 1rem */
    margin-top: 1.25rem;
}

.metric-card {
    background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
    padding: 1.25rem 1rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.metric-card:hover::before {
    transform: scaleX(1);
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.06);
    border-color: #cbd5e1;
}

.metric-value {
    font-size: 1.5rem; /* Reduced from 1.8rem */
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.35rem;
    line-height: 1.2;
}

.metric-label {
    font-size: 0.75rem; /* Reduced from 0.85rem */
    color: #6b7280;
    font-weight: 500;
    line-height: 1.3;
}

/* ========================================================================== */
/* FORMULATION CONTROLS                                                      */
/* ========================================================================== */

.formulation-controls {
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    padding: 1.25rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.5);
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
}

.formulation-controls:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.optimization-controls {
    background: #f9fafb;
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); /* Reduced from 200px */
    gap: 0.85rem; /* Reduced from 1rem */
    margin-bottom: 0.85rem;
}

/* ========================================================================== */
/* MANUAL FORMULATION                                                        */
/* ========================================================================== */

/* ========================================================================== */
/* MANUAL FORMULATION - TWO-COLUMN LAYOUT                                   */
/* ========================================================================== */

.manual-formulation-container {
    margin-bottom: 1.5rem;
}

.manual-formulation-layout {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* Left Column: Available Ingredients */
.manual-formulation-left {
    background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    padding: 1rem;
    max-height: 600px;
    display: flex;
    flex-direction: column;
}

/* Right Column: Selected Ingredients */
.manual-formulation-right {
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
    border-radius: 12px;
    border: 1px solid #bbf7d0;
    padding: 1rem;
    max-height: 600px;
    display: flex;
    flex-direction: column;
}

/* Column Headers */
.formulation-column-header {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e5e7eb;
}

.formulation-column-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.formulation-column-header h3 i {
    color: #3b82f6;
}

.selected-count-badge {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    margin-left: 0.5rem;
    min-width: 24px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

/* Ingredients Lists */
.ingredients-list,
.selected-ingredients-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem;
}

.ingredients-list::-webkit-scrollbar,
.selected-ingredients-list::-webkit-scrollbar {
    width: 6px;
}

.ingredients-list::-webkit-scrollbar-track,
.selected-ingredients-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.ingredients-list::-webkit-scrollbar-thumb,
.selected-ingredients-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.ingredients-list::-webkit-scrollbar-thumb:hover,
.selected-ingredients-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Ingredient Items */
.ingredient-item {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.ingredient-item:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
    transform: translateX(2px);
}

.ingredient-item.selected {
    background: #eff6ff;
    border-color: #3b82f6;
}

.selected-ingredient-item {
    background: #ffffff;
    border: 1px solid #86efac;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s ease;
}

.selected-ingredient-item:hover {
    border-color: #22c55e;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.15);
}

/* Ingredient Checkbox Label */
.ingredient-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.ingredient-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.ingredient-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
}

.ingredient-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ingredient-meta {
    font-size: 0.8rem;
    color: #6b7280;
}

/* Percentage Input for Selected Ingredients */
.ingredient-percentage {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.ingredient-percentage input {
    width: 80px;
    padding: 0.5rem 0.65rem;
    font-size: 0.875rem;
    text-align: right;
}

.percentage-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
}

/* Remove Button */
.remove-ingredient-btn {
    background: #fee2e2;
    color: #dc2626;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.remove-ingredient-btn:hover {
    background: #fecaca;
    transform: scale(1.1);
}

/* Action Buttons (Middle) */
.manual-formulation-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    justify-content: center;
    padding-top: 3rem;
}

.btn-action {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-action.btn-add {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

.btn-action.btn-add:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: scale(1.1) translateX(5px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-action.btn-remove {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.btn-action.btn-remove:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: scale(1.1) translateX(-5px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: #6b7280;
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    color: #cbd5e1;
}

.empty-state p {
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .manual-formulation-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .manual-formulation-actions {
        flex-direction: row;
        padding-top: 0;
        padding: 1rem 0;
    }

    .btn-action.btn-add:hover {
        transform: scale(1.1) translateY(-5px);
    }

    .btn-action.btn-remove:hover {
        transform: scale(1.1) translateY(5px);
    }
}

/* ========================================================================== */
/* RESULTS SECTION                                                           */
/* ========================================================================== */

.results-section {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    padding: 1.75rem;
    border-radius: 16px;
    border: 1px solid #a7f3d0;
    margin-top: 2rem;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.1), 0 2px 8px rgba(16, 185, 129, 0.08);
    animation: fadeIn 0.4s ease-out;
    position: relative;
    overflow: hidden;
}

.results-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #10b981, #059669);
}

.results-section h3 {
    color: #065f46;
    margin-bottom: 1rem; /* Reduced from 1.5rem */
    font-size: 1.15rem; /* Reduced from 1.3rem */
}

/* ========================================================================== */
/* INFO & MESSAGE BOXES                                                      */
/* ========================================================================== */

.info-box {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #bfdbfe;
    border-left: 4px solid #3b82f6;
    border-radius: 8px;
    padding: 0.875rem 1rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.08);
    transition: all 0.2s ease;
}

.info-box:hover {
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.12);
    transform: translateX(2px);
}

.info-box small {
    color: #1e40af;
    font-weight: 500;
    line-height: 1.6;
}

.info-box h4 {
    color: #1e40af;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

/* Database tab: connection state */
.database-connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 1rem;
}
.database-connection-status.connected {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border: 1px solid #6ee7b7;
    color: #065f46;
}
.database-connection-status.disconnected {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border: 1px solid #f87171;
    color: #991b1b;
}
.database-connection-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.database-connection-status.connected .status-dot {
    background: #059669;
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.3);
}
.database-connection-status.disconnected .status-dot {
    background: #dc2626;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.3);
}

.success-message {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border: 1px solid #6ee7b7;
    border-left: 4px solid #10b981;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.12);
    animation: slideIn 0.3s ease-out;
}

.success-message i {
    font-size: 1.25rem;
    color: #059669;
}

/* ========================================================================== */
/* MODALS                                                                    */
/* ========================================================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem; /* Reduced from 1.5rem */
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
    font-size: 1.15rem; /* Reduced from 1.3rem */
    font-weight: 600;
    color: #111827;
    margin-bottom: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #9ca3af;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #6b7280;
}

.modal-body {
    padding: 1.25rem; /* Reduced from 1.5rem */
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1.25rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

/* ========================================================================== */
/* FILE UPLOAD                                                               */
/* ========================================================================== */

.file-upload-area {
    border: 2px dashed #93c5fd;
    border-radius: 10px;
    padding: 2.5rem 2rem; /* Reduced from 3rem 2rem */
    text-align: center;
    background: #eff6ff;
    transition: all 0.2s ease;
    cursor: pointer;
}

.file-upload-area:hover {
    border-color: #3b82f6;
    background: #dbeafe;
}

.file-upload-area i {
    font-size: 2.5rem; /* Reduced from 3rem */
    color: #3b82f6;
    margin-bottom: 0.75rem; /* Reduced from 1rem */
}

.file-upload-area p {
    color: #6b7280;
    font-size: 0.95rem; /* Reduced from 1.1rem */
    margin: 0;
}

.file-info {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 8px;
    padding: 0.85rem; /* Reduced from 1rem */
    margin-top: 1rem;
}

.file-info p {
    margin: 0.25rem 0;
    color: #065f46;
    font-weight: 500;
    font-size: 0.85rem;
}

/* ========================================================================== */
/* PROGRESS BARS                                                             */
/* ========================================================================== */

.progress-container {
    margin: 0.85rem 0; /* Reduced from 1rem */
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.875rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
    border-radius: 4px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.step {
    font-size: 0.8rem; /* Reduced from 0.875rem */
    font-weight: 500;
    color: #9ca3af;
    padding: 0.4rem 0.85rem; /* Reduced from 0.5rem 1rem */
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.step.active {
    color: #1d4ed8;
    background-color: #dbeafe;
    font-weight: 600;
}

.step.completed {
    color: #059669;
    background-color: #d1fae5;
}

/* ========================================================================== */
/* INGREDIENT LIST                                                           */
/* ========================================================================== */

.ingredient-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.75rem;
    background: #ffffff;
    margin-top: 0.5rem;
}

.ingredient-list label {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    margin-bottom: 0.35rem;
    border-radius: 4px;
    transition: background 0.2s ease;
    cursor: pointer;
    font-size: 0.85rem;
}

.ingredient-list label:hover {
    background: #f9fafb;
}

.ingredient-list input[type="checkbox"] {
    margin-right: 0.65rem;
    margin-left: 0;
}

/* ========================================================================== */
/* BOUNDS EDITOR                                                             */
/* ========================================================================== */

.bounds-editor {
    display: grid;
    gap: 0.75rem;
}

.bounds-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 0.75rem;
    align-items: center;
    padding: 0.65rem;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.bounds-row label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #374151;
}

.bounds-row input {
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
}

/* ========================================================================== */
/* LOADING & SPINNERS                                                        */
/* ========================================================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    text-align: center;
    color: #3b82f6;
}

.loading-spinner i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.loading-spinner p {
    font-size: 1rem;
    font-weight: 500;
}

/* Database tab: full-cover refresh overlay */
#database {
    position: relative;
    min-height: 400px;
}
.database-refresh-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 8px;
    transition: opacity 0.25s ease;
}
.database-refresh-overlay-content {
    text-align: center;
    color: #1e40af;
}
.database-refresh-overlay-content i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
}
.database-refresh-overlay-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 0.35rem 0;
    color: #1e3a8a;
}
.database-refresh-overlay-subtitle {
    font-size: 0.875rem;
    margin: 0;
    color: #3b82f6;
    opacity: 0.9;
}

/* ========================================================================== */
/* TARGETS SIDEBAR - Fixed & Optimized                                       */
/* ========================================================================== */

.targets-sidebar {
    position: fixed !important;
    top: 65px !important; /* Matches reduced header height */
    right: 0 !important;
    bottom: 0 !important;
    left: auto !important;
    width: 320px; /* Reduced from 350px */
    height: calc(100vh - 65px) !important;
    max-height: calc(100vh - 65px);
    background: #ffffff;
    border-left: 1px solid #e5e7eb;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
    z-index: 999 !important;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    will-change: transform;
}

.targets-sidebar.open {
    transform: translateX(0);
}

.targets-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem; /* Reduced from 1.25rem 1.5rem */
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 2px solid #e5e7eb;
    flex-shrink: 0;
    min-height: 60px; /* Reduced from 70px */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.targets-header h3 {
    font-size: 1rem; /* Reduced from 1.1rem */
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

/* Floating toggle button (Show Targets) */
.targets-floating-toggle {
    position: fixed;
    right: 1rem;
    bottom: 2rem; /* Moved lower */
    z-index: 999;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.25rem;
    border-radius: 2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transition: all 0.3s ease;
}

.targets-floating-toggle:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
    transform: translateY(-2px);
}

.targets-floating-toggle.hidden {
    display: none;
}

.targets-toggle {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.targets-toggle:hover {
    background: #e5e7eb;
    color: #374151;
}

.targets-toggle i {
    transition: transform 0.3s ease;
}

.targets-sidebar.open .targets-toggle i {
    transform: rotate(180deg);
}

.targets-content {
    flex: 1 1 auto;
    padding: 1.25rem; /* Reduced from 1.5rem */
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.targets-content::-webkit-scrollbar {
    width: 6px; /* Reduced from 8px */
}

.targets-content::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.targets-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
    transition: background 0.3s ease;
}

.targets-content::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.targets-section {
    margin-bottom: 1.5rem; /* Reduced from 2rem */
}

.targets-section:last-child {
    margin-bottom: 0;
}

.targets-section h4 {
    font-size: 0.8rem; /* Reduced from 0.9rem */
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.85rem; /* Reduced from 1rem */
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #e5e7eb;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.targets-section .form-group {
    margin-bottom: 0.85rem; /* Reduced from 1rem */
}

.targets-section .form-group:last-child {
    margin-bottom: 0;
}

.targets-section label {
    font-size: 0.8rem; /* Reduced from 0.85rem */
    font-weight: 500;
    color: #4b5563;
    margin-bottom: 0.25rem;
    display: block;
}

.targets-section .form-control {
    width: 100%;
    padding: 0.45rem 0.65rem; /* Reduced from 0.5rem 0.75rem */
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.8rem; /* Reduced from 0.85rem */
    transition: all 0.2s ease;
    background: #ffffff;
}

.targets-section .form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.targets-section .info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 0.375rem;
    padding: 0.65rem;
    margin-top: 0.5rem;
}

.targets-section .info-box small {
    color: #1e40af;
    font-size: 0.75rem;
    font-weight: 500;
}

.tooltip-label {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tooltip {
    position: relative;
    cursor: help;
    color: #9ca3af;
    font-size: 0.75rem;
}

.tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.7rem;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    max-width: 200px;
    white-space: normal;
    text-align: center;
}

.tooltip:hover::before {
    content: '';
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1f2937;
}

.targets-actions {
    flex-shrink: 0;
    margin-top: auto;
    padding: 1rem 1.25rem; /* Reduced from 1.25rem 1.5rem */
    border-top: 2px solid #e5e7eb;
    background: linear-gradient(180deg, #f9fafb 0%, #f3f4f6 100%);
    display: flex;
    flex-direction: column;
    gap: 0.65rem; /* Reduced from 0.75rem */
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.btn-full {
    width: 100%;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1rem; /* Reduced from 0.75rem 1rem */
    font-size: 0.8rem; /* Reduced from 0.85rem */
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.btn-full i {
    font-size: 0.75rem;
}

/* Floating Toggle Button */
.targets-floating-toggle {
    position: fixed !important;
    top: 50% !important;
    right: 1rem !important;
    bottom: auto !important;
    left: auto !important;
    transform: translateY(-50%);
    min-width: 110px; /* Reduced from 120px */
    height: 44px; /* Reduced from 48px */
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 22px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    cursor: pointer;
    z-index: 1000 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem; /* Reduced from 0.9rem */
    font-weight: 500;
    transition: all 0.3s ease;
    gap: 0.4rem;
    padding: 0 0.85rem; /* Reduced from 1rem */
    will-change: transform;
}

.targets-floating-toggle:hover {
    background: #2563eb;
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.targets-floating-toggle i {
    transition: transform 0.3s ease;
    font-size: 0.9rem; /* Reduced from 1rem */
}

.targets-floating-toggle .toggle-text {
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.targets-sidebar.open + .targets-floating-toggle {
    right: 335px; /* Adjusted for reduced sidebar width */
    background: #f59e0b;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.targets-sidebar.open + .targets-floating-toggle:hover {
    background: #d97706;
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4);
}

.targets-sidebar.open + .targets-floating-toggle i {
    transform: rotate(180deg);
}

/* ========================================================================== */
/* UTILITY CLASSES                                                           */
/* ========================================================================== */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 3rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 3rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.p-5 { padding: 3rem; }

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

.mobile-only {
    display: none;
}

/* ========================================================================== */
/* SIDEBAR SECTIONS (FOR FUTURE USE)                                         */
/* ========================================================================== */

.sidebar {
    display: none;
}

.sidebar-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid #e5e7eb;
}

.sidebar-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.sidebar-section h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sidebar-section h3::before {
    content: '';
    width: 3px;
    height: 18px;
    background: #2563eb;
    border-radius: 2px;
}

.accordion-section .accordion-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.accordion-section .accordion-caret {
    font-size: 0.85rem;
    opacity: 0.8;
    transition: transform 0.2s ease;
}

.accordion-section .accordion-body {
    display: none;
    padding-top: 0.5rem;
}

.accordion-section.expanded .accordion-body {
    display: block;
}

.accordion-section.expanded .accordion-caret {
    transform: rotate(180deg);
}

/* ========================================================================== */
/* ANIMATIONS                                                                */
/* ========================================================================== */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

/* ========================================================================== */
/* INDVD RESULTS OPTIMIZATION                                                 */
/* ========================================================================== */

/* Key Result Display */
.indvd-key-result {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-radius: 16px;
    padding: 2rem;
    margin: 1.5rem 0;
    text-align: center;
    border: 2px solid #3b82f6;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.15);
    animation: fadeIn 0.4s ease-out;
}

.indvd-key-value {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.indvd-percentage-large {
    font-size: 4rem;
    font-weight: 700;
    color: #2563eb;
    line-height: 1;
    text-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.indvd-label-large {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e40af;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.indvd-digestibility-badge {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    border-radius: 2rem;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
    margin-top: 0.5rem;
}

.indvd-sample-name {
    margin-top: 1rem;
    font-size: 1rem;
    color: #475569;
    font-weight: 500;
}

/* Graph Grid Layout */
.indvd-graphs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.indvd-graph-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
}

.indvd-graph-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.graph-card-header {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #f3f4f6;
}

.graph-card-header h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.graph-card-header i {
    color: #3b82f6;
}

.indvd-donut-container,
.indvd-bar-container {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem 0;
    min-height: 350px;
}

#indvdDonutCanvas,
#indvdBarCanvas {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.graph-legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.graph-legend > div {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    color: #374151;
}

.graph-legend > div:hover {
    background: #f3f4f6;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.graph-legend > div > div {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Protocol Boxes */
.indvd-protocol-box {
    background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.indvd-protocol-box:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #d1d5db;
}

/* Details Grid */
.indvd-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.detail-section {
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.detail-section h5 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.detail-section h5 i {
    color: #3b82f6;
}

.detail-table {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
}

.detail-row:hover {
    background: #f9fafb;
    border-color: #cbd5e1;
    transform: translateX(2px);
}

.detail-row.highlight-row {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-color: #3b82f6;
    font-weight: 600;
}

.detail-label {
    font-size: 0.85rem;
    color: #6b7280;
    font-weight: 500;
}

.detail-value {
    font-size: 0.9rem;
    color: #111827;
    font-weight: 600;
    text-align: right;
}

.detail-value.highlight-value {
    color: #2563eb;
    font-size: 1rem;
    font-weight: 700;
}

.highlight-card {
    animation: pulseHighlight 0.5s ease-out;
}

/* ========================================================================== */
/* DATABASE FILTERS                                                           */
/* ========================================================================== */

.database-filters {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
    margin-bottom: 1.5rem;
}

.database-filters .form-group {
    margin-bottom: 0;
}

.database-filters label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.database-filters label i {
    color: #3b82f6;
    font-size: 0.875rem;
}

.database-filters .form-control {
    font-size: 0.875rem;
}

.database-filters .btn {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
}

/* Badge Styles */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.02em;
}

.badge-concentrate {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.badge-roughage {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #166534;
    border: 1px solid #86efac;
}

.badge-additive {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    border: 1px solid #fcd34d;
}

/* Fallback for any missing type badges */
.badge:not(.badge-concentrate):not(.badge-roughage):not(.badge-additive) {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    color: #374151;
    border: 1px solid #d1d5db;
}

@keyframes pulseHighlight {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* ========================================================================== */
/* LEGACY/SPECIAL STYLES                                                     */
/* ========================================================================== */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

/* ========================================================================== */
/* END OF OPTIMIZED STYLESHEET                                               */
/* ========================================================================== */
