/* ========================================
   CleanTrace - Bootstrap Extension Styles

   This stylesheet extends Bootstrap 5.3 with:
   - Custom brand colors via CSS variables
   - Sidebar navigation styling (uses Bootstrap offcanvas)
   - Application-specific component styles

   Layout uses Bootstrap's standard document flow.
   Sidebar uses Bootstrap offcanvas-lg for responsive behavior.
   ======================================== */

/* ========================================
   CSS CUSTOM PROPERTIES (Brand Colors)
   Override Bootstrap's default colors
   ======================================== */
:root {
    /* Primary brand color */
    --bs-primary: #3183ff;
    --bs-primary-rgb: 49, 131, 255;

    /* CleanTrace specific colors */
    --ct-primary: #3183ff;
    --ct-primary-hover: #2670e8;
    --ct-sidebar-bg: #33475b;
    --ct-sidebar-border: #2c3e50;
    --ct-header-bg: #33475b;
    --ct-body-bg: #f5f6f8;
    --ct-text-primary: #33475b;
    --ct-text-muted: #6b7280;

    /* Health status colors */
    --ct-health-excellent: #10b981;
    --ct-health-good: #84cc16;
    --ct-health-fair: #f59e0b;
    --ct-health-poor: #ef4444;
}

/* ========================================
   BASE STYLES
   Minimal overrides to Bootstrap defaults
   ======================================== */
body {
    background: var(--ct-body-bg);
    color: var(--ct-text-primary);
}

/* ========================================
   LAYOUT STRUCTURE
   Uses Bootstrap's offcanvas-lg for sidebar
   ======================================== */

/* Wrapper for sidebar + main content */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Main content area - flows naturally on desktop, full width on mobile */
.main-content {
    flex: 1;
    min-width: 0; /* Prevent flex item overflow */
    background: var(--ct-body-bg);
    min-height: 100vh;
}

/* On desktop (lg+), add left margin to account for fixed sidebar */
@media (min-width: 992px) {
    .main-content {
        margin-left: 300px;
    }

}

/* ========================================
   SIDEBAR STYLES
   Extends Bootstrap offcanvas component
   ======================================== */

/* Override offcanvas width and make it fixed on desktop */
#sidebar {
    --bs-offcanvas-width: 300px;
    background: var(--ct-sidebar-bg) !important;
}

/* On desktop, sidebar is always visible and fixed */
@media (min-width: 992px) {
    #sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        width: 300px;
        height: 100vh;
        transform: none !important;
        visibility: visible !important;
        border-right: 1px solid var(--ct-sidebar-border);
        z-index: 1030; /* Above sticky header (1020) */
    }
}

/* Sidebar navigation links - extend Bootstrap nav-pills */
#sidebar .nav-link {
    color: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    padding: 12px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}

#sidebar .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

#sidebar .nav-link.active {
    background: var(--ct-primary);
    color: #ffffff;
}

/* ========================================
   HEADER/NAVBAR STYLES
   Extends Bootstrap navbar component
   ======================================== */

/* Search input in dark navbar */
.navbar-dark .form-control {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.navbar-dark .form-control::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.navbar-dark .form-control:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--ct-primary);
    color: #fff;
    box-shadow: 0 0 0 0.25rem rgba(49, 131, 255, 0.25);
}

.navbar-dark .input-group-text {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
}

/* ========================================
   PAGE STRUCTURE
   ======================================== */
.page-header {
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    padding: 24px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.content-area {
    padding: 32px;
}

@media (max-width: 768px) {
    .page-header {
        padding: 16px 20px;
    }

    .page-title {
        font-size: 22px;
    }

    .content-area {
        padding: 20px;
    }
}

/* ========================================
   BUTTONS - Bootstrap overrides
   ======================================== */
.btn-primary {
    background: var(--ct-primary);
    border-color: var(--ct-primary);
}

.btn-primary:hover {
    background: var(--ct-primary-hover);
    border-color: var(--ct-primary-hover);
}

.btn-ct-primary {
    display: inline-flex;
    align-items: center;
    padding: 10px 20px;
    background: var(--ct-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-ct-primary:hover {
    background: var(--ct-primary-hover);
    box-shadow: 0 2px 8px rgba(49, 131, 255, 0.3);
    color: white;
}

.btn-ct-secondary {
    padding: 10px 20px;
    background: #ffffff;
    color: var(--ct-text-muted);
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-ct-secondary:hover {
    border-color: #9ca3af;
    color: #374151;
}

/* ========================================
   CARDS
   ======================================== */
.card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.card-ct {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #e5e7eb;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e5e7eb;
    transition: all 0.2s;
    cursor: pointer;
    text-decoration: none;
    display: block;
}

.stat-card:hover {
    border-color: var(--ct-primary);
    box-shadow: 0 4px 12px rgba(49, 131, 255, 0.15);
    transform: translateY(-2px);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.stat-icon svg {
    width: 20px;
    height: 20px;
}

.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #dcfce7; color: #16a34a; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.purple { background: #f3e8ff; color: #9333ea; }
.stat-icon.amber { background: #fef3c7; color: #d97706; }

.stat-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ct-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.2;
}

.stat-subtitle {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 4px;
}

/* ========================================
   TABLES - Bootstrap enhancement
   ======================================== */
.table-ct {
    width: 100%;
    border-collapse: collapse;
}

.table-ct thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ct-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e5e7eb;
}

.table-ct tbody td {
    padding: 16px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 14px;
    color: #4b5563;
}

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

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

/* ========================================
   FILTERS
   ======================================== */
.filters-section {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.filters-label {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.filter-dropdown-wrapper {
    position: relative;
}

.filter-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 180px;
    justify-content: space-between;
}

.filter-button:hover {
    border-color: #9ca3af;
    background: #f9fafb;
}

.filter-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 220px;
    z-index: 100;
    display: none;
}

.filter-dropdown-menu.open {
    display: block;
}

.filter-dropdown-item {
    padding: 10px 14px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    transition: background 0.15s;
}

.filter-dropdown-item:first-child {
    border-radius: 6px 6px 0 0;
}

.filter-dropdown-item:last-child {
    border-radius: 0 0 6px 6px;
}

.filter-dropdown-item:hover {
    background: #f3f4f6;
}

.filter-dropdown-item.selected {
    background: #eff6ff;
    color: var(--ct-primary);
    font-weight: 500;
}

/* ========================================
   HEALTH INDICATORS
   ======================================== */
.health-excellent { background: var(--ct-health-excellent); }
.health-good { background: var(--ct-health-good); }
.health-fair { background: var(--ct-health-fair); }
.health-poor { background: var(--ct-health-poor); }

.health-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.health-badge.excellent {
    background: rgba(16, 185, 129, 0.1);
    color: var(--ct-health-excellent);
}

.health-badge.good {
    background: rgba(132, 204, 22, 0.1);
    color: var(--ct-health-good);
}

.health-badge.fair {
    background: rgba(245, 158, 11, 0.1);
    color: var(--ct-health-fair);
}

.health-badge.poor {
    background: rgba(239, 68, 68, 0.1);
    color: var(--ct-health-poor);
}

/* ========================================
   PEN CARDS
   ======================================== */
.pen-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

.pen-card {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    padding: 20px;
    min-height: 400px;
}

.pen-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--ct-primary);
}

.pen-card-title {
    font-weight: 600;
    font-size: 16px;
    color: #1f2937;
}

.pen-card-type {
    font-style: italic;
    color: var(--ct-text-muted);
    font-size: 13px;
    margin-left: 6px;
}

.pen-card-count {
    font-size: 14px;
    color: var(--ct-primary);
    font-weight: 600;
}

.pen-card-pigs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-content: flex-start;
}

/* ========================================
   PIG ICONS
   ======================================== */
.pig-wrapper {
    position: relative;
    width: 40px;
    height: 40px;
}

.pig-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--ct-health-excellent);
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 2;
}

.pig-icon:hover {
    transform: translate(-50%, -50%) scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.health-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    transform: rotate(-90deg);
}

.health-ring circle {
    fill: none;
    stroke-width: 3;
}

.health-ring .ring-bg {
    stroke: #e5e7eb;
}

/* Pig Tooltip */
.pig-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 12px 16px;
    background: #1f2937;
    color: white;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 280px;
}

.pig-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1f2937;
}

.pig-wrapper:hover .pig-tooltip {
    opacity: 1;
}

.tooltip-pig-id {
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--ct-primary);
    font-size: 14px;
}

.tooltip-health {
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tooltip-health-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.tooltip-ai-insight {
    font-style: italic;
    color: #d1d5db;
    font-size: 12px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #374151;
}

/* ========================================
   LEGEND
   ======================================== */
.legend-compact {
    background: #f9fafb;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #e5e7eb;
}

.legend-row {
    display: flex;
    gap: 32px;
    align-items: center;
    flex-wrap: wrap;
}

.legend-section-compact {
    display: flex;
    align-items: center;
    gap: 12px;
}

.legend-title-compact {
    font-size: 13px;
    font-weight: 600;
    color: var(--ct-text-muted);
}

.legend-indicators {
    display: flex;
    gap: 6px;
}

.legend-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
    cursor: help;
}

/* ========================================
   CHART CARDS
   ======================================== */
.chart-card {
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    padding: 20px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.chart-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.chart-subtitle {
    font-size: 13px;
    color: var(--ct-text-muted);
    margin-top: 2px;
}

.chart-link {
    font-size: 13px;
    color: var(--ct-primary);
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chart-link:hover {
    text-decoration: underline;
}

.chart-container {
    position: relative;
    height: 260px;
}

.chart-container.tall {
    height: 320px;
}

/* ========================================
   AI INSIGHTS SIDEBAR
   ======================================== */
.ai-insights-sidebar {
    position: fixed;
    top: 0;
    right: -480px;
    width: 460px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.ai-insights-sidebar.open {
    right: 0;
}

.ai-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
}

.ai-sidebar-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-sidebar-header h2 svg {
    width: 20px;
    height: 20px;
    color: #60a5fa;
}

.ai-sidebar-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ai-sidebar-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.ai-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.ai-insight-card {
    background: #f9fafb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    border-left: 4px solid transparent;
}

.ai-insight-card:last-child {
    margin-bottom: 0;
}

.ai-insight-card.critical {
    border-left-color: var(--ct-health-poor);
    background: #fef2f2;
}

.ai-insight-card.warning {
    border-left-color: var(--ct-health-fair);
    background: #fffbeb;
}

.ai-insight-card.success {
    border-left-color: var(--ct-health-excellent);
    background: #f0fdf4;
}

.ai-insight-card.info {
    border-left-color: #3b82f6;
    background: #eff6ff;
}

.ai-insight-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.ai-insight-card-header svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.ai-insight-card.critical .ai-insight-card-header svg { color: var(--ct-health-poor); }
.ai-insight-card.warning .ai-insight-card-header svg { color: var(--ct-health-fair); }
.ai-insight-card.success .ai-insight-card-header svg { color: var(--ct-health-excellent); }
.ai-insight-card.info .ai-insight-card-header svg { color: #3b82f6; }

.ai-insight-card h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.ai-insight-card p {
    margin: 0;
    font-size: 13px;
    color: #4b5563;
    line-height: 1.6;
}

.ai-insight-card .action-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    font-size: 13px;
    color: var(--ct-primary);
    text-decoration: none;
    font-weight: 500;
}

.ai-insight-card .action-link:hover {
    text-decoration: underline;
}

.ai-sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    background: white;
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.open {
    opacity: 1;
    pointer-events: all;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1200px) {
    .pen-cards-grid {
        grid-template-columns: 1fr;
    }

    .ai-insights-sidebar {
        width: 100%;
        right: -100%;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .top-header,
    .main-content {
        left: 0 !important;
    }

    .filters-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-button {
        width: 100%;
    }

    .filter-dropdown-menu {
        width: 100%;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .user-email {
        display: none;
    }
}

/* ========================================
   TAB NAVIGATION - Shared across pages
   ======================================== */
.tab-content-custom {
    display: none;
}

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

/* ========================================
   TABLE SORTING - Shared across pages
   ======================================== */
th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable::after {
    content: " ↕";
    opacity: 0.3;
}

th.sorted-asc::after {
    content: " ↑";
    opacity: 1;
    color: var(--ct-primary);
}

th.sorted-desc::after {
    content: " ↓";
    opacity: 1;
    color: var(--ct-primary);
}

/* ========================================
   BADGES - Shared styles
   ======================================== */
.pen-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.pen-badge.badge-farrowing { background: #fef3c7; color: #92400e; }
.pen-badge.badge-nursery { background: #dbeafe; color: #1e40af; }
.pen-badge.badge-finisher { background: #dcfce7; color: #166534; }

.activity-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.activity-badge.activity-recent { background: #dbeafe; color: #1d4ed8; }
.activity-badge.activity-stale { background: #f3f4f6; color: #6b7280; }

.health-badge.health-excellent { background: rgba(16, 185, 129, 0.1); color: var(--ct-health-excellent); }
.health-badge.health-good { background: rgba(132, 204, 22, 0.1); color: var(--ct-health-good); }
.health-badge.health-fair { background: rgba(245, 158, 11, 0.1); color: var(--ct-health-fair); }
.health-badge.health-poor { background: rgba(239, 68, 68, 0.1); color: var(--ct-health-poor); }

/* ========================================
   PIGS PAGE STYLES
   ======================================== */
/* Health Distribution */
.health-chart-container {
    width: 160px;
    height: 160px;
    flex-shrink: 0;
}

/* Attention List */
.attention-list {
    max-height: 300px;
    overflow-y: auto;
}

.attention-item {
    transition: all 0.2s;
}

.attention-item:hover {
    transform: translateX(4px);
}

/* Age Distribution Bar */
.age-group-bar {
    height: 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    min-width: 40px;
    transition: width 0.3s;
}

.age-group-bar.farrowing { background: linear-gradient(90deg, #fbbf24 0%, #f59e0b 100%); }
.age-group-bar.nursery { background: linear-gradient(90deg, #60a5fa 0%, #3b82f6 100%); }
.age-group-bar.finisher { background: linear-gradient(90deg, #34d399 0%, #10b981 100%); }

/* Small chart container */
.chart-container-sm {
    height: 220px;
    position: relative;
}

/* ========================================
   PENS PAGE STYLES
   ======================================== */
/* Health bar segments */
.pen-health-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: #e5e7eb;
}

.pen-health-segment {
    height: 100%;
    transition: width 0.3s;
}

.pen-health-segment.excellent { background: var(--ct-health-excellent); }
.pen-health-segment.good { background: var(--ct-health-good); }
.pen-health-segment.fair { background: var(--ct-health-fair); }
.pen-health-segment.poor { background: var(--ct-health-poor); }

/* ========================================
   BARN LAYOUT PAGE STYLES
   ======================================== */
/* Insight cards */
.insight-card {
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    border-left: 4px solid transparent;
}

.insight-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.insight-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.insight-card h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.insight-card p {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #4b5563;
    line-height: 1.5;
}

.insight-list {
    margin: 0;
    padding-left: 20px;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.6;
}

.insight-list li {
    margin-bottom: 6px;
}

.insight-critical {
    border-left-color: var(--ct-health-poor);
    background: #fef2f2;
}

.insight-critical .insight-icon { color: var(--ct-health-poor); }

.insight-warning {
    border-left-color: var(--ct-health-fair);
    background: #fffbeb;
}

.insight-warning .insight-icon { color: var(--ct-health-fair); }

.insight-positive {
    border-left-color: var(--ct-health-excellent);
    background: #f0fdf4;
}

.insight-positive .insight-icon { color: var(--ct-health-excellent); }

.insight-info {
    border-left-color: #3b82f6;
    background: #eff6ff;
}

.insight-info .insight-icon { color: #3b82f6; }

/* ========================================
   HOME/DASHBOARD PAGE STYLES
   ======================================== */
/* Charts row */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

@media (max-width: 900px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
}

/* Pen Overview */
.pen-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pen-card-mini {
    background: #f9fafb;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 12px;
}

.pen-card-mini:hover {
    background: #f3f4f6;
    border-color: var(--ct-primary);
}

.pen-card-mini .pen-name {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    width: 80px;
    flex-shrink: 0;
}

.pen-card-mini .pen-count {
    font-size: 16px;
    font-weight: 700;
    color: var(--ct-primary);
    width: 70px;
    flex-shrink: 0;
}

.pen-card-mini .pen-count span {
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
}

.health-bar {
    flex: 1;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    display: flex;
}

.health-bar .segment {
    height: 100%;
}

.health-bar .excellent { background: var(--ct-health-excellent); }
.health-bar .good { background: var(--ct-health-good); }
.health-bar .fair { background: var(--ct-health-fair); }
.health-bar .poor { background: var(--ct-health-poor); }

/* AI Panel (dark theme) */
.ai-panel {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-radius: 12px;
    padding: 20px;
    color: white;
}

.ai-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.ai-panel-header svg {
    width: 24px;
    height: 24px;
    color: #60a5fa;
}

.ai-panel-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.ai-insight-item {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 12px;
    border-left: 3px solid transparent;
}

.ai-insight-item:last-child {
    margin-bottom: 0;
}

.ai-insight-item.critical { border-left-color: var(--ct-health-poor); background: rgba(239, 68, 68, 0.15); }
.ai-insight-item.warning { border-left-color: var(--ct-health-fair); background: rgba(245, 158, 11, 0.15); }
.ai-insight-item.success { border-left-color: var(--ct-health-excellent); background: rgba(16, 185, 129, 0.15); }
.ai-insight-item.info { border-left-color: #3b82f6; background: rgba(59, 130, 246, 0.15); }

.ai-insight-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-insight-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.5;
}

.ai-insight-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    font-size: 12px;
    color: #60a5fa;
    text-decoration: none;
    font-weight: 500;
}

.ai-insight-action:hover {
    text-decoration: underline;
    color: #93c5fd;
}

/* Pipeline Status */
.pipeline-status {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 10px;
    margin-top: 16px;
}

.pipeline-icon {
    width: 48px;
    height: 48px;
    background: #dbeafe;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2563eb;
}

.pipeline-info {
    flex: 1;
}

.pipeline-info .label {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 2px;
}

.pipeline-info .value {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
}

.pipeline-link {
    color: var(--ct-primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}

.pipeline-link:hover {
    text-decoration: underline;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 20px;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

.quick-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.quick-action-btn svg {
    width: 16px;
    height: 16px;
}

/* ========================================
   PIG DETAIL PAGE STYLES
   ======================================== */
/* Back link styling */
.back-link:hover {
    color: var(--ct-primary);
}

/* Pig Header */
.pig-header {
    background: white;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #e5e7eb;
    margin-bottom: 24px;
    display: flex;
    align-items: flex-start;
    gap: 24px;
}

.pig-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    position: relative;
}

.pig-avatar .health-ring-large {
    position: absolute;
    top: -4px;
    left: -4px;
    width: 88px;
    height: 88px;
    transform: rotate(-90deg);
}

.pig-avatar .health-ring-large circle {
    fill: none;
    stroke-width: 4;
}

.pig-avatar .health-ring-large .ring-bg {
    stroke: #e5e7eb;
}

.pig-header-info {
    flex: 1;
}

.pig-header-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.pig-name {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.pig-status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pig-status-badge.live { background: #dcfce7; color: #16a34a; }
.pig-status-badge.dead { background: #fee2e2; color: #dc2626; }
.pig-status-badge.processing { background: #dbeafe; color: #2563eb; }
.pig-status-badge.historical { background: #f3e8ff; color: #9333ea; }

.pig-rfid {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 12px;
}

.pig-meta {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.pig-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #4b5563;
}

.pig-meta-item svg {
    width: 16px;
    height: 16px;
    color: #9ca3af;
}

.pig-header-actions {
    display: flex;
    gap: 8px;
}

/* Quick Stats Grid */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

@media (max-width: 1000px) {
    .quick-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 500px) {
    .quick-stats { grid-template-columns: 1fr; }
}

.quick-stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e5e7eb;
}

.quick-stat-card.highlight {
    border-color: transparent;
}

.quick-stat-card.excellent { background: linear-gradient(135deg, var(--ct-health-excellent) 0%, #34d399 100%); color: white; }
.quick-stat-card.good { background: linear-gradient(135deg, var(--ct-health-good) 0%, #a3e635 100%); color: white; }
.quick-stat-card.fair { background: linear-gradient(135deg, var(--ct-health-fair) 0%, #fbbf24 100%); color: white; }
.quick-stat-card.poor { background: linear-gradient(135deg, var(--ct-health-poor) 0%, #f87171 100%); color: white; }

.quick-stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    margin-bottom: 4px;
}

.quick-stat-card.highlight .quick-stat-label {
    color: rgba(255,255,255,0.8);
}

.quick-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
}

.quick-stat-card.highlight .quick-stat-value {
    color: white;
}

.quick-stat-sub {
    font-size: 13px;
    color: #9ca3af;
    margin-top: 4px;
}

.quick-stat-card.highlight .quick-stat-sub {
    color: rgba(255,255,255,0.7);
}

/* Main Content Grid */
.detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

@media (max-width: 1000px) {
    .detail-grid { grid-template-columns: 1fr; }
}

/* Detail Cards */
.detail-card {
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    margin-bottom: 24px;
}

.detail-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-card-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-card-title svg {
    width: 18px;
    height: 18px;
    color: #6b7280;
}

.detail-card-body {
    padding: 20px;
}

/* Activity Timeline */
.activity-timeline {
    position: relative;
    padding-left: 24px;
}

.activity-timeline::before {
    content: "";
    position: absolute;
    left: 7px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: #e5e7eb;
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -24px;
    top: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--ct-primary);
}

.timeline-dot.success { border-color: var(--ct-health-excellent); }
.timeline-dot.warning { border-color: var(--ct-health-fair); }
.timeline-dot.error { border-color: var(--ct-health-poor); }

.timeline-time {
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 2px;
}

.timeline-content {
    font-size: 14px;
    color: #374151;
}

/* AI Insight Panel */
.ai-insight-panel {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-radius: 12px;
    padding: 20px;
    color: white;
    margin-bottom: 24px;
}

.ai-insight-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.ai-insight-header svg {
    width: 20px;
    height: 20px;
    color: #60a5fa;
}

.ai-insight-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

/* Info List */
.info-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-size: 14px;
    color: #6b7280;
}

.info-value {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.info-value.good { color: var(--ct-health-excellent); }
.info-value.warning { color: var(--ct-health-fair); }
.info-value.bad { color: var(--ct-health-poor); }

/* Related Pigs */
.related-pigs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.related-pig-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #f9fafb;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s;
}

.related-pig-item:hover {
    background: #f3f4f6;
    transform: translateX(4px);
}

.related-pig-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.related-pig-info {
    flex: 1;
}

.related-pig-id {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.related-pig-health {
    font-size: 12px;
    color: #6b7280;
}

.related-pig-arrow {
    color: #9ca3af;
}

/* Processing Timeline */
.processing-stages {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin: 20px 0;
}

.processing-stages::before {
    content: "";
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    height: 4px;
    background: #e5e7eb;
    z-index: 0;
}

.processing-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

.stage-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    color: #9ca3af;
}

.stage-dot.completed {
    background: var(--ct-health-excellent);
    color: white;
}

.stage-dot.current {
    background: var(--ct-primary);
    color: white;
    box-shadow: 0 0 0 4px rgba(49, 131, 255, 0.2);
}

.stage-dot svg {
    width: 18px;
    height: 18px;
}

.stage-label {
    font-size: 12px;
    color: #6b7280;
    text-align: center;
}

.stage-label.active {
    color: var(--ct-primary);
    font-weight: 600;
}

/* Death Info */
.death-info-card {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.death-info-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    color: #dc2626;
}

.death-info-header svg {
    width: 20px;
    height: 20px;
}

.death-info-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.death-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.death-info-item {
    display: flex;
    flex-direction: column;
}

.death-info-label {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 2px;
}

.death-info-value {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

/* Not Found State */
.not-found {
    text-align: center;
    padding: 60px 20px;
}

.not-found h2 {
    font-size: 24px;
    color: #1f2937;
    margin-bottom: 8px;
}

.not-found p {
    color: #6b7280;
    margin-bottom: 20px;
}

/* ========================================
   MORTALITY PAGE STYLES
   ======================================== */
/* Cause legend */
.cause-legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}

.cause-legend-item:last-child {
    border-bottom: none;
}

.cause-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

/* Stage bars */
.stage-bar {
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    min-width: 40px;
    transition: width 0.5s ease;
}

.stage-bar.farrowing { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.stage-bar.nursery { background: linear-gradient(90deg, #60a5fa, #3b82f6); }
.stage-bar.finisher { background: linear-gradient(90deg, #34d399, #10b981); }

/* Cause chart container */
.cause-chart-container {
    width: 160px;
    height: 160px;
    flex-shrink: 0;
}

/* Death item */
.death-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #fef2f2;
    border-radius: 8px;
    border-left: 4px solid var(--ct-health-poor);
    cursor: pointer;
    transition: all 0.2s;
}

.death-item:hover {
    background: #fee2e2;
    transform: translateX(4px);
}

/* Risk cards */
.risk-card {
    text-align: center;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    background: white;
}

.risk-card.elevated {
    border-color: var(--ct-health-fair);
    background: #fffbeb;
}

.risk-card.high {
    border-color: var(--ct-health-poor);
    background: #fef2f2;
}

.risk-card.low {
    border-color: var(--ct-health-excellent);
    background: #ecfdf5;
}

.risk-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

.risk-card.elevated .risk-icon { background: #fef3c7; color: #d97706; }
.risk-card.high .risk-icon { background: #fee2e2; color: #dc2626; }
.risk-card.low .risk-icon { background: #dcfce7; color: #16a34a; }

.risk-value {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.risk-card.elevated .risk-value { color: #d97706; }
.risk-card.high .risk-value { color: #dc2626; }
.risk-card.low .risk-value { color: #16a34a; }

/* ========================================
   PROCESSING PAGE STYLES
   ======================================== */
/* Summary stat icon colors */
.summary-stat-icon.blue { background: #dbeafe; color: #2563eb; }
.summary-stat-icon.green { background: #dcfce7; color: #16a34a; }
.summary-stat-icon.amber { background: #fef3c7; color: #d97706; }
.summary-stat-icon.purple { background: #f3e8ff; color: #9333ea; }

/* Stage Pipeline */
.stage-pipeline {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

@media (max-width: 1200px) {
    .stage-pipeline { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 700px) {
    .stage-pipeline { grid-template-columns: 1fr; }
}

.stage-card {
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    padding: 20px;
    text-align: center;
    position: relative;
}

.stage-card::after {
    content: "";
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 8px solid #d1d5db;
}

.stage-card:last-child::after {
    display: none;
}

@media (max-width: 1200px) {
    .stage-card:nth-child(3)::after { display: none; }
}

@media (max-width: 700px) {
    .stage-card::after { display: none; }
}

.stage-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

.stage-icon svg {
    width: 24px;
    height: 24px;
}

.stage-card.receiving .stage-icon { background: #dbeafe; color: #2563eb; }
.stage-card.holding .stage-icon { background: #fef3c7; color: #d97706; }
.stage-card.processing .stage-icon { background: #fee2e2; color: #dc2626; }
.stage-card.chilling .stage-icon { background: #e0e7ff; color: #4f46e5; }
.stage-card.packaging .stage-icon { background: #dcfce7; color: #16a34a; }

.stage-name {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.stage-count {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
}

/* Live indicator */
.live-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #dcfce7;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #166534;
}

.live-dot {
    width: 8px;
    height: 8px;
    background: var(--ct-health-excellent);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

.rfid-tag {
    font-size: 12px;
    color: #6b7280;
    font-family: "Courier New", monospace;
}

.stage-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.stage-badge.receiving { background: #dbeafe; color: #1e40af; }
.stage-badge.holding { background: #fef3c7; color: #92400e; }
.stage-badge.processing { background: #fee2e2; color: #991b1b; }
.stage-badge.chilling { background: #e0e7ff; color: #3730a3; }
.stage-badge.packaging { background: #dcfce7; color: #166534; }

.grade-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.grade-badge.prime { background: #dcfce7; color: #166534; }
.grade-badge.choice { background: #ecfdf5; color: #065f46; }
.grade-badge.select { background: #fef3c7; color: #92400e; }
.grade-badge.standard { background: #f3f4f6; color: #6b7280; }

.qa-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.qa-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.qa-dot.complete { background: var(--ct-health-excellent); }
.qa-dot.pending { background: var(--ct-health-fair); }

.qa-values {
    font-size: 11px;
    color: #6b7280;
}

.qa-value.in-range { color: var(--ct-health-excellent); }
.qa-value.out-of-range { color: var(--ct-health-poor); }

.tattoo-cell {
    font-family: "Courier New", monospace;
    font-weight: 600;
    color: #6366f1;
}

/* ========================================
   HISTORICAL DATA PAGE STYLES
   ======================================== */
/* KPI Summary Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

.kpi-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e5e7eb;
}

.kpi-card.highlight {
    background: linear-gradient(135deg, #059669 0%, var(--ct-health-excellent) 100%);
    color: white;
    border: none;
}

.kpi-card.highlight .kpi-label,
.kpi-card.highlight .kpi-change {
    color: rgba(255,255,255,0.85);
}

.kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    background: #f3f4f6;
    color: #6b7280;
}

.kpi-card.highlight .kpi-icon {
    background: rgba(255,255,255,0.2);
    color: white;
}

.kpi-icon svg {
    width: 18px;
    height: 18px;
}

.kpi-label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.2;
}

.kpi-card.highlight .kpi-value {
    color: white;
}

/* Filters bar */
.filters-bar {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 24px;
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-item label {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    white-space: nowrap;
}

.filter-item select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    min-width: 140px;
}

.filter-item select:focus {
    outline: none;
    border-color: var(--ct-primary);
}

.filters-bar .btn {
    margin-left: auto;
}

/* Main Layout - 2/3 + 1/3 */
.main-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

@media (max-width: 1100px) {
    .main-grid { grid-template-columns: 1fr; }
}

.left-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.secondary-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 700px) {
    .secondary-row { grid-template-columns: 1fr; }
}

/* Performance Panel */
.performance-panel {
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    height: fit-content;
}

.panel-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.panel-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.panel-subtitle {
    font-size: 13px;
    color: #6b7280;
    margin-top: 2px;
}

.quality-section {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.quality-chart-container {
    height: 160px;
    margin-bottom: 16px;
}

.quality-legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.quality-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #f9fafb;
    border-radius: 6px;
}

.quality-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.quality-info {
    flex: 1;
}

.quality-name {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
}

.quality-value {
    font-size: 11px;
    color: #6b7280;
}

/* Metrics List */
.metrics-section {
    padding: 20px;
}

.metrics-section h4 {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f3f4f6;
}

.metric-row:last-child {
    border-bottom: none;
}

.metric-label {
    font-size: 13px;
    color: #374151;
}

.metric-value {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
}

.metric-value.good { color: #059669; }
.metric-value.warning { color: #d97706; }


/* --- Layout alignment fixes for Razor Pages port --- */

/* If your theme already defines these, these overrides will "tighten" spacing */
.main-content {
    padding: 24px;
}

/* Make page header match the PHP look: clean row, no big white slab */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    /* Remove any card-like feel */
    background: transparent;
    border: 0;
    box-shadow: none;
    /* Tighten spacing */
    padding: 0;
    margin: 0 0 16px 0;
}

.page-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* Ensure content blocks below have consistent spacing */
.content-area > .row:first-child {
    margin-top: 0;
}

/* Optional: keep the global header bar from adding extra vertical bulk */
header.top-header .border-bottom,
header.border-bottom {
    margin: 0;
}
