/* src/styles/main.css - Core Design System */
:root {
    /* Premium Color Palette - Factory Floor meets High Tech */
    /* Base Backgrounds - Deep Charcoal/Slate */
    --color-bg-base: #0F172A;
    /* Slate 900 */
    --color-bg-surface: #1E293B;
    /* Slate 800 */
    --color-bg-elevated: #334155;
    /* Slate 700 */

    /* Glassmorphism Variables */
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-blur: blur(12px);

    /* Text Colors */
    --color-text-primary: #F8FAFC;
    /* Slate 50 */
    --color-text-secondary: #94A3B8;
    /* Slate 400 */
    --color-text-muted: #64748B;
    /* Slate 500 */

    /* Accent & Semantic Colors */
    --color-primary: #006EA7;
    /* Brand Blue */
    --color-primary-glow: rgba(0, 110, 167, 0.5);

    --color-accent-1: #A4CA67;
    /* Brand Green */
    --color-accent-2: #D2A844;
    /* Brand Mustard */
    --color-accent-3: #8B461F;
    /* Brand Brown */

    /* Typography */
    --font-family-primary: 'Work Sans', system-ui, -apple-system, sans-serif;
    --font-family-heading: 'Raleway', system-ui, -apple-system, sans-serif;

    /* Spacing & Layout */
    --sidebar-width: 260px;
    --header-height: 70px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Borders */
    --border-radius-sm: 6px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body.dark-theme {
    background-color: var(--color-bg-base);
    color: var(--color-text-primary);
    font-family: var(--font-family-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    /* Prevent body scroll, handle within app-container */
}

/* =========================================
   Layout Infrastructure
   ========================================= */
#app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* =========================================
   Sidebar Navigation
   ========================================= */
#sidebar {
    width: var(--sidebar-width);
    background-color: var(--color-bg-surface);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: var(--spacing-lg) 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.logo-icon {
    color: var(--color-accent-1);
    font-size: 32px;
    margin-right: var(--spacing-sm);
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.brand h2 {
    font-family: var(--font-family-heading);
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
    display: flex;
    align-items: baseline;
}

.gen-tag {
    font-size: 0.65rem;
    background: var(--color-primary);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    font-weight: 600;
}

.nav-menu {
    flex-grow: 1;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: var(--spacing-lg);
}

.nav-header {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-text-muted);
    letter-spacing: 1px;
    padding: 0 var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-lg);
    color: var(--color-text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-fast);
    position: relative;
    cursor: pointer;
}

.nav-item:hover {
    color: var(--color-text-primary);
    background-color: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
    color: var(--color-primary);
    background-color: rgba(59, 130, 246, 0.08);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: var(--color-primary);
    box-shadow: 0 0 8px var(--color-primary-glow);
}

.nav-item .material-symbols-outlined {
    margin-right: var(--spacing-md);
    font-size: 20px;
}

.badge {
    margin-left: auto;
    background-color: var(--color-bg-elevated);
    color: var(--color-text-primary);
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.badge.alarm {
    background-color: var(--color-accent-3);
    color: white;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.user-profile {
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    margin-top: auto;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), #8B5CF6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    margin-right: var(--spacing-sm);
}

.user-info .name {
    font-size: 0.85rem;
    font-weight: 500;
}

.user-info .role {
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

/* =========================================
   Main Content Area & Header
   ========================================= */
#main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Subtle background glow effect */
#main-content::before {
    content: '';
    position: absolute;
    top: -20%;
    left: -10%;
    width: 50vw;
    height: 50vh;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.05) 0%, rgba(15, 23, 42, 0) 70%);
    z-index: 0;
    pointer-events: none;
}

#top-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-xl);
    border-bottom: 1px solid var(--glass-border);
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: var(--glass-blur);
    z-index: 5;
}

.context-breadcrumbs {
    display: flex;
    align-items: center;
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.context-breadcrumbs .icon-small {
    font-size: 16px;
    margin-right: var(--spacing-sm);
    color: var(--color-accent-1);
}

.context-breadcrumbs .highlight {
    color: var(--color-text-primary);
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.system-status {
    display: flex;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--border-radius-lg);
    background-color: rgba(255, 255, 255, 0.05);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
}

.system-status.healthy .status-dot {
    background-color: var(--color-accent-1);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--color-text-primary);
}

#view-container {
    flex-grow: 1;
    padding: var(--spacing-xl);
    overflow-y: auto;
    position: relative;
    z-index: 1;
}

/* =========================================
   Global Components (Cards, Buttons, etc.)
   ========================================= */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: var(--spacing-xl);
}

.view-header h1 {
    font-family: var(--font-family-heading);
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    margin-bottom: var(--spacing-xs);
}

.view-header .subtitle {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.card {
    background-color: var(--color-bg-surface);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-lg);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.card.glass {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    transform: translateY(0);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.card.glass:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.card h3 {
    font-family: var(--font-family-heading);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    transition: var(--transition-fast);
}

.btn.secondary {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--color-text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn.secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.btn .material-symbols-outlined {
    font-size: 18px;
    margin-left: 8px;
}

/* =========================================
   View Specific Styles: Macro Map
   ========================================= */
.dashboard-grid.layout-map {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: var(--spacing-xl);
    height: calc(100vh - var(--header-height) - 120px);
}

.map-container {
    position: relative;
    padding: 0;
    margin: 0;
    overflow: hidden;
    background: #111827;
    /* Darker for map backdrop */
    min-height: 400px;
}

.map-overlay-controls {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    display: flex;
    gap: var(--spacing-sm);
    z-index: 2;
}

.layer-toggle {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.layer-toggle.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

/* Leaflet Map Specific Resets & Premium Overrides */
.leaflet-container {
    background: transparent;
    /* Remove dark background matching the theme so tiles can be seen */
    font-family: var(--font-family-primary);
}

/* Auth Based Display Toggles */
.fruitscout-only {
    display: none;
    /* Toggled on via app.js for @fruitscout.ai users */
}

/* Force Tile Visibility to beat opacity race conditions */
.leaflet-pane.leaflet-tile-pane {
    opacity: 1 !important;
    z-index: 200 !important;
}

.leaflet-layer {
    opacity: 1 !important;
}

.leaflet-control-attribution {
    background: rgba(15, 23, 42, 0.6) !important;
    backdrop-filter: blur(4px);
    color: var(--color-text-muted) !important;
}

.leaflet-control-attribution a {
    color: var(--color-text-secondary) !important;
}

/* Custom Hierarchy Overlays */
.hierarchy-overlay {
    position: absolute;
    top: var(--spacing-md);
    left: var(--spacing-md);
    z-index: 1000;
    /* above leaflet 400 */
    padding: 8px 16px;
    border-radius: 20px;
}

.inventory-overlay {
    position: absolute;
    bottom: var(--spacing-lg);
    right: 60px;
    /* Offset from default leaflet controls */
    z-index: 1000;
    padding: 16px;
    border-radius: var(--border-radius-md);
    width: 200px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(16, 185, 129, 0.3);
    /* Green tint for inventory */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.breadcrumb {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 500;
}

.breadcrumb .step {
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: var(--transition-fast);
}

.breadcrumb .step:hover {
    color: var(--color-text-primary);
}

.breadcrumb .step.active {
    color: var(--color-primary);
    font-weight: 600;
    pointer-events: none;
}

.breadcrumb .separator {
    color: var(--color-text-muted);
    font-size: 16px;
    margin: 0 4px;
}

/* Custom Farm Markers */
.leaflet-custom-div-icon {
    background: transparent;
    border: none;
}

.custom-farm-marker {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.custom-farm-marker .marker-core {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    transition: transform var(--transition-fast);
}

.custom-farm-marker:hover .marker-core {
    transform: scale(1.1);
}

.custom-farm-marker .material-symbols-outlined {
    font-size: 18px;
    color: white;
}

.marker-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    z-index: 1;
    opacity: 0;
    animation: marker-ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes marker-ping {

    75%,
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* --- Labor Plan Markers --- */
.labor-marker {
    position: relative;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.labor-marker .marker-core {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-bg-surface);
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    transition: transform var(--transition-fast);
}

.labor-marker:hover .marker-core {
    transform: scale(1.15);
}

.labor-marker .material-symbols-outlined {
    font-size: 16px;
    color: white;
}

/* Tractor / Heavy Equipment Style */
.labor-marker-tractor .marker-core {
    border-color: var(--color-accent-2);
    background: rgba(245, 158, 11, 0.2);
}

.labor-marker-tractor .marker-pulse {
    background: var(--color-accent-2);
}

/* Hand Crew Style */
.labor-marker-hand .marker-core {
    border-color: var(--color-primary);
    background: rgba(0, 110, 167, 0.2);
}

.labor-marker-hand .marker-pulse {
    background: var(--color-primary);
}

/* Maintenance Style */
.labor-marker-maintenance .marker-core {
    border-color: var(--color-accent-3);
    background: rgba(239, 68, 68, 0.2);
}

.labor-marker-maintenance .marker-pulse {
    background: var(--color-accent-3);
}

/* --- Labor Management Plan List --- */
.labor-plan-item {
    padding: 12px;
    border-radius: var(--border-radius-sm);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: var(--transition-fast);
}

.labor-plan-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(4px);
}

.labor-plan-item.active {
    background: rgba(0, 110, 167, 0.15);
    border-color: var(--color-primary);
    border-left: 4px solid var(--color-primary);
}

.labor-plan-title {
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 4px;
    font-size: 0.95rem;
}

.labor-plan-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* Marker Status Colors */
.custom-farm-marker.status-optimal .marker-pulse {
    background: var(--color-accent-1);
}

.custom-farm-marker.status-optimal .marker-core {
    border-color: var(--color-accent-1);
}

.custom-farm-marker.status-optimal .material-symbols-outlined {
    color: var(--color-accent-1);
}

.custom-farm-marker.status-warning .marker-pulse {
    background: var(--color-accent-2);
}

.custom-farm-marker.status-warning .marker-core {
    border-color: var(--color-accent-2);
}

.custom-farm-marker.status-warning .material-symbols-outlined {
    color: var(--color-accent-2);
}

.custom-farm-marker.status-critical .marker-pulse {
    background: var(--color-accent-3);
    animation-duration: 1s;
}

.custom-farm-marker.status-critical .marker-core {
    border-color: var(--color-accent-3);
}

.custom-farm-marker.status-critical .material-symbols-outlined {
    color: var(--color-accent-3);
}

/* Field Polygon Styles & Tooltip overrides */
.interactive-polygon {
    cursor: pointer;
    transition: fill-opacity var(--transition-fast), stroke-width var(--transition-fast);
}

.interactive-polygon:hover {
    fill-opacity: 0.4;
}

.leaflet-tooltip.dark-tooltip.glass {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    color: var(--color-text-primary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    border-radius: var(--border-radius-sm);
    padding: 6px 12px;
}

/* Remove default tooltip arrow completely for cleaner look */
.leaflet-tooltip.dark-tooltip::before {
    display: none;
}

/* Mock Spatial Map Visualization */
.mock-map-visual {
    width: 100%;
    height: 100%;
    position: relative;
    /* Aerial Image Background is set inline in index.html to prevent caching */
}

.map-block {
    position: absolute;
    border: 3px solid;
    background: rgba(0, 0, 0, 0.15);
    /* Light overlay */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-normal);
}

.map-block:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.02);
}

.map-block.status-optimal {
    border-color: var(--color-accent-1);
    box-shadow: inset 0 0 20px rgba(16, 185, 129, 0.2);
}

.map-block.status-warning {
    border-color: var(--color-accent-2);
    box-shadow: inset 0 0 20px rgba(245, 158, 11, 0.2);
}

.map-block.status-critical {
    border-color: var(--color-accent-3);
    box-shadow: inset 0 0 20px rgba(239, 68, 68, 0.3);
}

.map-block.status-unregistered {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    border-style: dashed;
}

.map-block.status-unregistered .block-label {
    color: var(--color-text-muted);
}

.block-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
}

/* Pulse Animation for Critical Blocks */
.pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 4px;
    border: 2px solid var(--color-accent-3);
    animation: pulsate 2s infinite ease-out;
}

@keyframes pulsate {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 0;
    }
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.kpi-large {
    display: flex;
    flex-direction: column;
    margin-bottom: var(--spacing-xs);
}

.kpi-large .value {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.1;
}

.kpi-large .unit {
    font-size: 1rem;
    font-weight: 500;
    opacity: 0.8;
}

.accent-green {
    color: var(--color-accent-1);
}

.accent-orange {
    color: var(--color-accent-2);
}

.accent-blue {
    color: var(--color-primary);
}

.kpi-large .trend {
    display: inline-flex;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: var(--spacing-xs);
}

.trend.up {
    color: var(--color-accent-1);
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

/* Alarm List */
.alarm-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.alarm-item {
    display: flex;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius-sm);
    border-left: 3px solid;
}

.alarm-item.critical {
    border-left-color: var(--color-accent-3);
}

.alarm-item.warning {
    border-left-color: var(--color-accent-2);
}

.alarm-item .icon {
    font-size: 20px;
    margin-right: var(--spacing-sm);
}

.alarm-item.critical .icon {
    color: var(--color-accent-3);
}

.alarm-item.warning .icon {
    color: var(--color-accent-2);
}

.alarm-item .details {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.alarm-item .title {
    font-size: 0.85rem;
    font-weight: 600;
}

.alarm-item .loc {
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

.btn-micro {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-micro:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* =========================================
   View Specific Styles: Digital Twins
   ========================================= */
.search-bar {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 8px 16px;
    width: 300px;
}

.search-bar input {
    background: none;
    border: none;
    color: white;
    outline: none;
    margin-left: 8px;
    width: 100%;
    font-family: inherit;
}

.phase-tabs {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xl);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: var(--spacing-sm);
}

.tab-btn {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 16px;
    cursor: pointer;
    position: relative;
    transition: var(--transition-fast);
}

.tab-btn:hover {
    color: var(--color-text-primary);
}

.tab-btn.active {
    color: var(--color-primary);
    font-weight: 600;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -9px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--color-primary);
    border-radius: 2px 2px 0 0;
    box-shadow: 0 -2px 8px var(--color-primary-glow);
}

.dashboard-grid.layout-twins {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: var(--spacing-xl);
}

.profile-card {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.plant-id-header {
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: var(--spacing-md);
}

.plant-id-header h3 {
    margin: 0 0 0 8px;
    color: white;
}

.plant-id-header .badge {
    margin-left: auto;
    background: rgba(16, 185, 129, 0.2);
    color: var(--color-accent-1);
    border: 1px solid var(--color-accent-1);
}

.mock-plant-img {
    height: 200px;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border-radius: var(--border-radius-sm);
    position: relative;
    overflow: hidden;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--color-primary);
    box-shadow: 0 0 10px 2px var(--color-primary-glow);
    animation: scan 3s infinite linear;
}

@keyframes scan {
    0% {
        top: 0;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        top: 100%;
        opacity: 0;
    }
}

.scan-overlay {
    font-size: 0.75rem;
    color: var(--color-primary);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    z-index: 2;
}

.metrics-grid.mini .metric {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.metrics-grid.mini .label {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.metrics-grid.mini .val {
    font-weight: 500;
    font-size: 0.85rem;
}

.phase-data {
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xl);
}

.card-header h3 {
    margin: 0;
}

.eta {
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 4px;
}

.stats-row {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.stat-box {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-sm);
    display: flex;
    flex-direction: column;
}

.stat-box.alert-box {
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
}

.stat-box .title {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.stat-box .value {
    font-size: 1.5rem;
    font-weight: 600;
}

.chart-container {
    flex-grow: 1;
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
}

.chart-title {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-md);
}

.svg-mock-chart {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Plant Digital Twin Metrics --- */
.metric-card {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    padding: var(--spacing-xl);
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: var(--spacing-sm);
}

.metric-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--color-text-secondary);
}

.metric-header .icon {
    color: var(--color-primary);
    background: rgba(59, 130, 246, 0.1);
    padding: 8px;
    border-radius: 50%;
}

.metric-body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.metric-body .current-value .val {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1;
}

.metric-body .current-value .unit {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin-left: 4px;
}

.baseline-comparison {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.baseline-comparison .label-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

.baseline-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
}

.baseline-bar {
    height: 100%;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transform-origin: left;
    animation: barFill 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes barFill {
    from {
        transform: scaleX(0);
    }

    to {
        transform: scaleX(1);
    }
}

.trend-section {
    margin-top: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
}

.trend-title {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--spacing-sm);
}

.sparkline-container {
    width: 100%;
    height: 45px;
    position: relative;
}

.sparkline-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.sparkline-path {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: dashDraw 2s cubic-bezier(0.4, 0, 0.2, 1) forwards 0.2s;
}

@keyframes dashDraw {
    to {
        stroke-dashoffset: 0;
    }
}

.sparkline-point {
    opacity: 0;
    animation: fadeInPoint 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards 1.2s;
}

@keyframes fadeInPoint {
    from {
        opacity: 0;
        transform: scale(0);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Financial Ledger Layout */
.layout-financial {
    grid-template-columns: 3fr 2fr;
    height: 100%;
    min-height: 0;
}

/* =========================================
   LOGIN LANDING PAGE
========================================= */
.login-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--color-bg-base) 0%, #031e21 100%);
    z-index: 9999;
}

.login-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xl);
    width: 100%;
    max-width: 450px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: fadeInScale 0.4s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.login-header .logo-icon-large {
    font-size: 64px;
    color: var(--color-accent-1);
    margin-bottom: var(--spacing-md);
    filter: drop-shadow(0 0 12px rgba(16, 185, 129, 0.3));
}

.login-header h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: var(--spacing-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.login-header h1 .gen-tag {
    font-size: 14px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-accent-1);
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid rgba(16, 185, 129, 0.2);
    transform: translateY(-4px);
}

.login-header .subtitle {
    color: var(--color-text-secondary);
    font-size: 16px;
    margin-bottom: var(--spacing-xl);
}

.login-instruction {
    color: var(--color-text-muted);
    font-size: 14px;
    margin-bottom: var(--spacing-lg);
}

.google-signin-container {
    display: flex;
    justify-content: center;
    margin-bottom: var(--spacing-lg);
    min-height: 44px;
    /* Prevent layout shift while loading */
}

.login-footer p {
    color: var(--color-text-muted);
    font-size: 12px;
    margin-top: var(--spacing-xl);
}

.error-message {
    color: var(--color-accent-3);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    margin-top: var(--spacing-md);
    text-align: left;
}

/* =========================================
   MAP ZOOM STATE OVERRIDES
========================================= */
#interactive-map.macro-zoom path.interactive-polygon {
    fill-opacity: 0 !important;
}

/* =========================================
   Manager Hub (Plan Management) Orchestration UI
========================================= */

/* Travel Time Spatial Bar */
.travel-time-bar {
    position: absolute;
    height: 100%;
    background: repeating-linear-gradient(45deg,
            rgba(255, 255, 255, 0.05),
            rgba(255, 255, 255, 0.05) 10px,
            rgba(0, 0, 0, 0.2) 10px,
            rgba(0, 0, 0, 0.2) 20px);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: 0.7rem;
    pointer-events: none;
    z-index: 1;
}

/* Bi-Directional Hover States */
.gantt-task-bar:hover {
    filter: brightness(1.2);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.3);
}

/* Ghost Preview for Drag and Drop */
.gantt-ghost-bar {
    opacity: 0.3 !important;
    border: 1px dashed rgba(255, 255, 255, 0.5) !important;
    pointer-events: none;
    transition: none !important;
    filter: grayscale(100%);
}

/* Live Constraint Checking Colors */
.task-constraint-amber {
    background: linear-gradient(90deg, #F59E0B, #D97706) !important;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.6) !important;
    border: 1px solid #FCD34D !important;
    color: white !important;
}

.task-constraint-red {
    background: linear-gradient(90deg, #EF4444, #B91C1C) !important;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.8) !important;
    border: 1px solid #FCA5A5 !important;
    color: white !important;
    animation: pulse-red-border 1s infinite alternate;
}

@keyframes pulse-red-border {
    from {
        border-color: #EF4444;
    }

    to {
        border-color: #FECACA;
    }
}

/* Split Task Bar (Time Progress + Quality Heatmap) */
.split-task-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

.split-task-progress {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    border-bottom: 1px solid rgba(0, 0, 0, 0.3);
}

.split-task-quality {
    height: 6px;
    /* Bottom portion */
    display: flex;
    width: 100%;
    border-radius: 0 0 4px 4px;
    overflow: hidden;
}

.split-task-quality>div {
    height: 100%;
}

/* Resolution Panel Animations */
.resolution-panel-modal {
    animation: slideUpFade 0.3s ease-out;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translate(-50%, -40%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}