:root {
    /* --- CSS Variables for Theming --- */

    /* === Main menu view === */
    #viewMenu {
    /* use same flex base as data-layout but we ensure it's full height */
    height: calc(100vh - 56px); /* adjust if header is taller */
    overflow: auto;             /* internal scroll if content too tall */
    }

    /* Better spacing for the sidebar content on the menu */
    #viewMenu .data-sidebar {
    padding: 16px 24px;
    gap: 16px;
    overflow-y: auto;
    }

    #viewMenu .data-sidebar h2 {
    margin-bottom: 8px;
    }

    #viewMenu .data-sidebar h3 {
    margin: 12px 0 4px;
    }

    #viewMenu .data-sidebar p {
    margin: 0 0 6px;
    font-size: 14px;
    }

    /* Login inputs more usable */
    #viewMenu #loginUsername,
    #viewMenu #loginPassword {
    width: 100%;
    max-width: 260px;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-subtle, #ccc);
    font-size: 14px;
    }

    /* Menu main panel text spacing */
    #viewMenu .data-main {
    padding: 32px 40px;
    }

    /* Light Theme (Default) */
    --bg-app: #ffffff;
    --bg-panel: #f8fafc;
    --bg-header: #ffffff;
    --border-subtle: #e2e8f0;
    --border-strong: #cbd5e1;
    --day-separator-color: #3b82f6;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --text-inverse: #ffffff;

    /* Functional Colors */
    --primary: #3b82f6;
    --primary-dim: #dbeafe;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --hover-bg: #f1f5f9;

    /* Block Colors */
    --block-setup-bg: rgba(203, 213, 225, 0.85);
    --block-run-bg: rgba(112, 128, 144, 0.85);
    --block-setup-warning-bg: rgba(239, 68, 68, 0.5);

    --block-worker: rgba(34, 197, 94, 0.15);
    --block-worker-border: rgba(34, 197, 94, 0.4);
    --text-worker: #15803d;

    /* Dynamic Block Alpha */
    --block-alpha: 0.85;

    /* Dimensions */
    --header-height: 64px;
    --machine-col-width: 320px;
    --row-height: 110px;
    --sidebar-width: 360px;
    --footer-height: 32px;
    --border-radius: 1px;
    /* Status Outlines */
    --block-running-outline: var(--success);   /* finished (green) */
    --block-attention-outline: var(--warning); /* planned but needs attention (orange) */
    --block-launched-outline: #fde047;         /* launched (yellow) */
}


/* Priority Badges */
.badge-priority {
    font-weight: 700 !important;
    border: 1px solid transparent;
}

.badge-p1 {
    background-color: #fee2e2 !important;
    color: #dc2626 !important;
    border-color: #fecaca !important;
}

.badge-p2 {
    background-color: #ffedd5 !important;
    color: #ea580c !important;
    border-color: #fed7aa !important;
}

.badge-p3 {
    background-color: #fef9c3 !important;
    color: #ca8a04 !important;
    border-color: #fde047 !important;
}

.badge-p4 {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
    border-color: #cbd5e1 !important;
}

/* Dark Theme Overrides */
body.theme-dark {
    --bg-app: #0f172a;
    --bg-panel: #1e293b;
    --bg-header: #1e293b;
    --border-subtle: #334155;
    --border-strong: #475569;
    --day-separator-color: #60a5fa;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-light: #64748b;
    
    --primary-dim: #1e3a8a;
    --hover-bg: #334155;

    --block-setup-bg: rgba(71, 85, 105, 0.85);
    --block-run-bg: rgba(56, 189, 248, 0.6);

    --text-worker: #4ade80;
    --block-worker: rgba(34, 197, 94, 0.2);
}

/* Density Overrides */
body.density-compact {
    --row-height: 80px;
}

/* Corner Style Overrides */
body.corners-soft {
    --border-radius: 6px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-main);
    background: var(--bg-app);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background 0.3s, color 0.3s;
}

/* --- Layout --- */
/* CSS: Header History Buttons */
.history-controls {
    display: flex;
    gap: 2px; /* Compact gap */
    margin-right: 8px; /* Reduced from 20px */
    border-left: 1px solid var(--border-subtle);
    padding-left: 8px; /* Reduced from 10px */
    height: 32px;
    align-items: center;
}

.nav-icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 50%;
    width: 28px; /* Slightly smaller hit area to save space visually */
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.nav-icon-btn:hover:not(:disabled) {
    background-color: var(--hover-bg);
    color: var(--primary);
}

.nav-icon-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

/* --- Header Layout --- */
.app-header {
    height: 64px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: var(--bg-header);
    flex-shrink: 0;
    z-index: 20;
    gap: 8px; /* Tighter gap between main sections */
    overflow: hidden;
}

/* Sidebar Toggle & History Arrows */
.history-controls {
    display: flex;
    gap: 2px;
    margin-right: 4px;
    border-left: 1px solid var(--border-subtle);
    padding-left: 8px;
    height: 32px;
    align-items: center;
    flex-shrink: 0;
}

.nav-icon-btn {
    color: var(--text-main); /* Black instead of gray */
}

.app-title {
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: -0.025em;
    margin-right: 4px;
    white-space: nowrap;
    flex-shrink: 0;
    color: #000;
}

/* --- Navigation Buttons (Blue Ones) --- */
.app-nav {
    display: flex;
    gap: 6px;
    /* Removed margin-right: auto to stop pushing controls away */
    flex-shrink: 0;
}

.nav-btn {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-main); /* Dark text */
    padding: 6px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: var(--hover-bg);
}

.nav-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* --- The Scrollable Toolbar Strip --- */
.app-controls {
    display: flex;
    align-items: center;
    gap: 10px; /* Space between the groups */
    height: 100%;
    
    flex-wrap: nowrap; 
    overflow-x: auto; 
    overflow-y: hidden;
    scrollbar-width: none; 
    -ms-overflow-style: none;
    
    /* Push slightly left, but allow growth */
    margin-left: 12px; 
    padding-right: 4px;
}
.app-controls::-webkit-scrollbar { display: none; }

/* --- Control Groups --- */
.control-group {
    display: flex;
    align-items: center;
    gap: 0; /* Touching buttons */
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    height: 38px;
    padding: 0;
    flex-shrink: 0;
    overflow: hidden;
}

/* --- Buttons Inside Groups --- */
.control-btn {
    background: transparent;
    border: none;
    border-right: 1px solid var(--border-subtle);
    cursor: pointer;
    
    /* FORCE BLACK TEXT */
    color: var(--text-main); 
    font-weight: 600; /* Make text bolder/blacker */
    
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 0;
    
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    
    height: 100%;
    min-width: 40px;
    max-width: 120px;
    
    white-space: normal; 
    line-height: 1.1; 
    text-align: center;
    transition: all 0.2s ease;
}
.control-btn.btn-stacked {
    white-space: normal !important; 
    max-width: 82px;                
    line-height: 1.1;               
    text-align: center;             
    padding: 2px 2px;               
    font-size: 0.7rem;              
    height: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;                      
}

/* Ensure the icon stays inline or wraps nicely */
.control-btn.btn-stacked span[role="img"],
.control-btn.btn-stacked svg {
    flex-shrink: 0;
}
.control-btn:last-child {
    border-right: none;
}

/* Specific Override for Arrows to be compact */
.control-btn.btn-arrow {
    min-width: 24px;  /* Much smaller */
    width: 24px;
    padding: 0;
    font-size: 10px; /* Smaller triangle */
    font-weight: 900;
    color: #000;
}

.control-btn.save-btn {
    font-weight: 700;
    color: var(--text-main);
}

.control-btn:hover {
    background: var(--hover-bg);
    color: var(--primary);
}

/* Prevent icons from shrinking */
.control-btn svg, .control-btn span[role="img"] {
    flex-shrink: 0;
    font-size: 1.1em;
}

/* Data View Checkbox Group */
#dataImportControls label {
    font-weight: 600;
    color: var(--text-main);
}

/* Minimalistic Save Button Overrides */
.control-btn.save-btn {
    background: transparent;
    color: var(--text-light);
    border: 1px solid transparent;
    border-right-color: var(--border-subtle);
    padding: 2px 8px;
    font-weight: 600;
}

.control-btn.save-btn:hover {
    background: var(--hover-bg);
    color: var(--primary);
}

/* State: Unsaved Changes (Dirty) */
.control-btn.save-btn.is-dirty {
    color: var(--primary);
    /* Highlight color */
    border-color: var(--primary-dim);
    background: var(--bg-panel);
}

/* Add a small dot to indicate unsaved changes */
.control-btn.save-btn.is-dirty::after {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background-color: var(--danger);
    border-radius: 50%;
}

.control-btn:hover {
    background: var(--hover-bg);
    color: var(--primary);
}

/* --- Filter Menu Styles --- */
.filter-popup {
    position: absolute;
    background: var(--bg-panel);
    
    border: 1px solid var(--border-strong);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: var(--border-radius);
    padding: 12px;
    z-index: 3000;
    min-width: 200px;
    max-height: 300px;
    display: flex;
    flex-direction: column;
}

.filter-header {
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filter-options {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 12px;
}

.filter-option-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    margin-bottom: 4px;
    cursor: pointer;
}

.filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.filter-search {
    width: 100%;
    padding: 6px;
    margin-bottom: 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    box-sizing: border-box;
    /* Prevents padding from breaking layout */
}

.filter-search:focus {
    outline: none;
    border-color: var(--primary);
}

.th-filtered {
    background-color: var(--primary-dim);
    /* Highlight header if filtered */
    border-bottom: 2px solid var(--primary) !important;
}

.clickable-label {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-main);
    padding: 0 4px;
    min-width: 80px;
    text-align: center;
}

.clickable-label:hover {
    color: var(--primary);
    text-decoration: underline;
}

input[type="range"] {
    cursor: pointer;
}

/* --- View Container --- */
.view-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Crucial: Stops the container from expanding beyond the screen */
    position: relative;
    min-height: 0;    /* Crucial: Allows flex children to shrink properly */
}

/* --- Planner View --- */
.planner-layout {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden; /* Ensure Planner doesn't trigger body scroll */
}

.gantt-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}
/* =========================================
   PHASE 3: TRAFFIC LIGHT VISUALS (GLOWS)
   ========================================= */

/* 1. ORANGE: Planned / Attention Needed */
.gantt-block.status-attention {
    box-shadow: 0 0 0 2px #f97316, 0 0 12px rgba(249, 115, 22, 0.6); /* Orange Glow */
    z-index: 30;
    border-color: #f97316 !important;
}
.gantt-block.status-attention .block-ticker {
    background-color: #f97316;
    border-color: white;
    color: white;
}

/* 2. YELLOW: Setup Started */
.gantt-block.status-setup-started {
    box-shadow: 0 0 0 2px #eab308, 0 0 12px rgba(234, 179, 8, 0.6); /* Yellow Glow */
    z-index: 31;
    border-color: #eab308 !important;
}
.gantt-block.status-setup-started .block-ticker {
    background-color: #eab308;
    border-color: black;
    color: black;
}

/* 3. BLUE: Run Started (Pulse Animation) */
@keyframes pulse-blue {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

.gantt-block.status-run-started {
    box-shadow: 0 0 0 2px #3b82f6; 
    animation: pulse-blue 2s infinite; /* The Blue Pulse */
    z-index: 32;
    border-color: #3b82f6 !important;
}
.gantt-block.status-run-started .block-ticker {
    background-color: #3b82f6;
    border-color: white;
    color: white;
}

/* 4. GREEN: Finished */
.gantt-block.status-finished {
    box-shadow: 0 0 0 2px #22c55e; 
    opacity: 0.9;
    z-index: 29;
    border-color: #22c55e !important;
}
.gantt-block.status-finished .block-ticker {
    background-color: #22c55e;
    border-color: white;
    color: white;
}


/* =========================================
   TICKER BUTTON (The Clickable Dot)
   ========================================= */
.block-ticker {
    position: absolute;
    left: 0px; 
    top: 90%;
    transform: translateY(-50%);
    
    /* Force Circle Dimensions */
    width: 8px;
    height: 8px;
    min-width: 8px;  /* Prevents squishing */
    min-height: 8px;
    
    /* CRITICAL FIX: Kill browser default button styles */
    padding: 0;
    margin: 0;
    border: 2px solid white;
    border-radius: 50%; /* Makes it a circle */
    
    background: #94a3b8; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    
    /* Center the dot */
    display: flex;
    align-items: center;
    justify-content: center;
    
    font-size: 0px; /* Hide text visually (optional, keeps dot clean) */
    line-height: 1;
    color: transparent; /* Or 'white' if you want to see the text inside */
    
    cursor: pointer;
    z-index: 40;
    transition: all 0.2s ease;
}

.block-ticker:hover {
    transform: translateY(-50%) scale(1.2);
}

/* =========================================
   POPOVER MENU (The Traffic Light Controller)
   ========================================= */
.ticker-popover {
    position: fixed;
    z-index: 10000;
    background: white;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 16px;
    width: 240px;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    animation: popIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.95) translateY(5px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.ticker-popover h4 {
    margin: 0 0 12px 0;
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 8px;
}

.ticker-popover button {
    display: block;
    width: 100%;
    padding: 10px 12px;
    margin-top: 8px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    color: white;
    text-align: left;
    transition: filter 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ticker-popover button:hover { filter: brightness(1.1); }
.ticker-popover button:active { transform: scale(0.98); }

.btn-start-setup { background-color: #eab308; } /* Yellow */
.btn-start-run   { background-color: #3b82f6; } /* Blue */
.btn-finish      { background-color: #22c55e; } /* Green */
.btn-reset       { background-color: #64748b; margin-top: 16px !important; opacity: 0.8; } /* Slate Grey */

.block-ticker.disabled {
    opacity: 0.0; /* Hidden if not yet time */
    pointer-events: none;
}
/* Show disabled ticker slightly on hover to indicate it exists but isn't ready */
.gantt-block:hover .block-ticker.disabled {
    opacity: 0.3;
}

.block-ticker.status-launched {
  border-color: var(--block-launched-outline);
  color: var(--block-launched-outline);
}

.block-ticker.status-running {
  border-color: var(--block-launched-outline);
  color: var(--block-launched-outline);
}

.block-ticker.status-finished {
  border-color: var(--success);
  color: var(--success);
}

.timeline-header {
    display: flex;
    height: 48px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-header);
    flex-shrink: 0;
}

.header-col-machine {
    width: var(--machine-col-width);
    flex-shrink: 0;
    border-right: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding-left: 24px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    background: var(--bg-panel);
}

.header-col-time {
    flex: 1;
    position: relative;
    overflow: hidden;
}
/* --- Time Axis Alignment Fix --- */

.time-marker {
    position: absolute;
    bottom: 0;
    top: 24px; /* Align with the bottom of the header row */
    border-left: 1px solid var(--border-strong);
    font-size: 0.7rem;
    color: var(--text-light);
    pointer-events: none;
    line-height: 1;

    /* Force 0 width so 'left' is the precise anchor point */
    width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    
    display: flex;
    align-items: flex-start;
    overflow: visible;
}

/* Default: Center text on the tick */
.time-marker span {
    position: relative;
    top: 3px; 
    transform: translateX(-50%);
    background-color: var(--bg-header); /* Optional: cleaner look over grid lines */
    padding: 0 3px;
    white-space: nowrap;
}

/* 1. Start (00:00): Align Left to prevent cut-off */
.time-marker:first-child span {
    transform: translateX(0%);
    padding-left: 2px;
}

/* 2. End (24:00): Align Right to prevent cut-off */
.time-marker:last-child span {
    transform: translateX(-100%);
    padding-right: 2px;
}

/* 3. End Tick: Pull back 1px so the line sits inside the border */
.time-marker:last-child {
    transform: translateX(-1px);
}
.gantt-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    background: var(--bg-app);
}

.gantt-footer {
    height: var(--footer-height);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-panel);
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

.time-cursor-overlay {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--machine-col-width);
    right: 0;
    pointer-events: none;
    z-index: 40;
}

.cursor-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--danger);
    transform: translateX(-1px);
}

.cursor-label {
    position: absolute;
    top: 0;
    left: 4px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    padding: 2px 4px;
    border-radius: 0 0 4px 0;
    font-weight: 600;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

th.sortable:hover {
    color: var(--primary);
}

th.sortable span {
    margin-left: 5px;
    font-size: 0.7rem;
}

/* UPDATED / NEW CSS FOR CONTINUOUS MODE */

/* Make the body the scroll container & Hide Native Scrollbar */
.gantt-body.gantt-body-continuous {
    overflow-x: auto;
    cursor: grab;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE 10+ */
}

.gantt-body.gantt-body-continuous::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.gantt-body.gantt-body-continuous.is-dragging {
    cursor: grabbing;
    user-select: none;
}

/* Sticky Machine Column Logic */
.gantt-body.gantt-body-continuous .machine-row {
    position: relative;
    width: fit-content;
    min-width: 100%;
}

/* FIX: Increased z-index to 60 to stay ABOVE the blocks (which are z-index 20) */
.gantt-body.gantt-body-continuous .machine-info-cell {
    position: sticky;
    left: 0;
    z-index: 60;
    background: var(--bg-app);
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
    border-right: 2px solid var(--border-strong);
    /* Stronger border to hide sliding blocks */
}

.continuous-scroll-wrapper {
    height: 100%;
    position: relative;
    /* Grid lines will be drawn by axis wrapper, remove from track to avoid misalignment */
    background: none;
}

/* Continuous Axis & Day Separators */
.continuous-axis-wrapper {
    height: 100%;
    position: relative;
    /* No background here, handled by markers/labels */
}

.continuous-day-label {
    position: absolute;
    top: 0;
    font-size: 0.75rem;
    font-weight: 700;
    padding-left: 8px;
    border-left: 2px solid var(--day-separator-color);
    height: 100%;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.5);
    z-index: 5;
    display: flex;
    align-items: center;
}

.theme-dark .continuous-day-label {
    background: rgba(30, 41, 59, 0.5);
}

/* NEW: Grid lines for the row track (Background Image trick) */
.continuous-scroll-wrapper {
    height: 100%;
    position: relative;
    /* Layer 1: Blue Day Separator (every 600px)
       Layer 2: Gray Hour Marker (every 25px -> 600px / 24h)
    */
    background-image:
        linear-gradient(to right, var(--day-separator-color) 2px, transparent 2px),
        linear-gradient(to right, var(--border-subtle) 1px, transparent 1px);

    background-size:
        600px 100%,
        /* Day Width */
        25px 100%;
    /* Hour Width (600 / 24) */

    background-position:
        0 0,
        0 0;
}

/* --- SIDEBAR COLLAPSED STATE --- */
#sidebar.sidebar-collapsed {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    padding: 0;
    border-left: 1px solid var(--border-subtle);
    align-items: center;
    overflow: hidden;
}

#sidebar.sidebar-collapsed .sidebar-scroll,
#sidebar.sidebar-collapsed .message-bar {
    display: none;
}

/* Machine Rows */
.machine-row {
    display: flex;
    height: var(--row-height);
    border-bottom: 1px solid var(--border-subtle);
}

.machine-info-cell {
    width: var(--machine-col-width);
    flex-shrink: 0;
    border-right: 1px solid var(--border-subtle);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--bg-app);
    transition: background 0.2s;
    position: relative;
}

.machine-info-cell.drag-over {
    background: var(--primary-dim);
}

.info-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.machine-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}

.machine-name-input {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    border: 1px solid var(--primary);
    background: var(--bg-app);
    padding: 2px 4px;
    border-radius: var(--border-radius);
    width: 100%;
    outline: none;
}

.runtime-config {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.runtime-input {
    width: 40px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-app);
    color: var(--text-main);
    border-radius: var(--border-radius);
    padding: 2px 4px;
    font-size: 0.8rem;
    text-align: center;
}

.worker-summary {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-height: 18px;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.worker-pill {
    display: inline-block;
    color: var(--text-worker);
    background: var(--block-worker);
    border: 1px solid var(--block-worker-border);
    padding: 1px 4px;
    border-radius: var(--border-radius);
    margin-right: 4px;
    font-size: 0.7rem;
}

.utilization-bar {
    font-size: 0.7rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.utilization-text.warning {
    color: var(--danger);
    font-weight: 600;
}

.gantt-track-cell {
    flex: 1;
    position: relative;
    height: 100%;
    background-image: linear-gradient(to right, var(--border-subtle) 1px, transparent 1px);
    background-size: calc(100% / 24) 100%;
}

.block-controls {
    position: absolute;
    top: 2px;
    right: 2px;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 50;
}

.gantt-block:hover .block-controls,
.worker-band:hover .block-controls {
    opacity: 1;
}

.btn-icon {
    background: rgba(0, 0, 0, 0.3);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
}

.btn-icon:hover {
    background: rgba(0, 0, 0, 0.6);
}

.btn-icon.remove:hover {
    background: var(--danger);
}

.gantt-block {
    position: absolute;
    height: 50%;
    top: 40%;
    border-radius: var(--border-radius);
    display: flex;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    font-size: 0.75rem;
    color: white;
    transition: transform 0.15s, box-shadow 0.15s;
    z-index: 20;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.gantt-block.draggable {
    cursor: grab;
}

.gantt-block.draggable:active {
    cursor: grabbing;
}

.gantt-block.locked {
    cursor: not-allowed;
    opacity: 0.7;
    filter: grayscale(0.5);
}

.gantt-block:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
    z-index: 30;
}

.block-segment-setup {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    letter-spacing: 0.5px;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
}

.block-segment-run {
    background-color: var(--block-run-bg);
    height: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.setup-warning-overlay {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    pointer-events: none;
    z-index: 25;
}

.worker-band {
    position: absolute;
    height: 24px;
    top: 6px;
    background: var(--block-worker);
    border: 1px solid var(--block-worker-border);
    border-radius: var(--border-radius);
    color: var(--text-worker);
    display: flex;
    align-items: center;
    justify-content: center; 
    padding: 0; 
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    z-index: 10;
    transition: opacity 0.2s;
}
.worker-band.draggable {
    cursor: grab;
}

.worker-band.locked {
    cursor: default;
}

.worker-band:not(.locked):hover {
    background-color: rgba(34, 197, 94, 0.25);
}

.ghost-preview {
    position: absolute;
    height: 50%;
    top: 40%;
    border-radius: var(--border-radius);
    background: rgba(59, 130, 246, 0.15);
    border: 1px dashed var(--primary);
    pointer-events: none;
    z-index: 5;
}

.ghost-preview.invalid {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-panel);
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 30;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.sidebar-drop-active {
    background-color: var(--primary-dim);
    border-left: 2px dashed var(--primary);
}

.section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-group {
    margin-bottom: 32px;
}

.draggable-card {
    background: var(--bg-app);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    padding: 12px;
    margin-bottom: 8px;
    cursor: grab;
    transition: all 0.2s;
    position: relative;
}

.draggable-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.draggable-card:active {
    cursor: grabbing;
}

.card-accent {
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 2px 2px 0;
}

.card-worker .card-accent {
    background-color: var(--success);
}

.card-fo .card-accent {
    background-color: var(--primary);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: var(--border-radius);
    background: var(--bg-panel);
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.btn-edit {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    padding: 2px;
    transition: color 0.2s;
}

.btn-edit:hover {
    color: var(--primary);
}

.btn-add {
    width: 100%;
    padding: 8px;
    border: 1px dashed var(--border-strong);
    background: none;
    color: var(--text-muted);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.8rem;
    margin-top: 8px;
    transition: all 0.2s;
}

.btn-add:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-dim);
}

.edit-form {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-row {
    display: flex;
    gap: 8px;
}

.form-row>div {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.form-input {
    width: 100%;
    padding: 6px;
    border: 1px solid var(--border-strong);
    background: var(--bg-app);
    color: var(--text-main);
    border-radius: var(--border-radius);
    font-size: 0.8rem;
}

.form-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

.btn-sm {
    padding: 4px 10px;
    border-radius: var(--border-radius);
    border: none;
    font-size: 0.75rem;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-cancel {
    background: var(--border-subtle);
    color: var(--text-main);
}

.message-bar {
    background: var(--bg-app);
    border-top: 1px solid var(--border-subtle);
    padding: 10px 20px;
    font-size: 0.85rem;
    min-height: 40px;
    display: flex;
    align-items: center;
    color: var(--text-muted);
}

.message-bar.error {
    color: var(--danger);
    font-weight: 500;
}

.message-bar.success {
    color: var(--success);
    font-weight: 500;
}

.tooltip {
    position: fixed;
    background: #0f172a;
    color: white;
    padding: 10px 14px;
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    pointer-events: none;
    z-index: 1000;
    display: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    line-height: 1.5;
}

/* NEW: Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: var(--bg-app);
    width: 450px;
    max-width: 90%;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    justify-content: space-between;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: 70vh;
}

.modal-footer {
    padding: 16px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-separator {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    margin: 20px 0;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.modal-separator::before,
.modal-separator::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-separator::before {
    margin-right: 10px;
}

.modal-separator::after {
    margin-left: 10px;
}

.tooltip strong {
    color: #e2e8f0;
    display: block;
    margin-bottom: 4px;
}

.tooltip span {
    color: #94a3b8;
    margin-right: 8px;
}

/* --- Settings View --- */
.settings-layout {
    display: flex;
    width: 100%;
    height: 100%;
    background: var(--bg-app);
    overflow: hidden; /* Lock the layout wrapper */
    min-height: 0;    /* Prevent flex expansion */
}

.settings-sidebar {
    width: 240px;
    border-right: 1px solid var(--border-subtle);
    background: var(--bg-panel);
    padding: 20px;
    overflow-y: auto; /* Sidebar scrolls independently */
}

.settings-nav-item {
    display: block;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: var(--border-radius);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
}

.settings-nav-item:hover {
    background: var(--hover-bg);
    color: var(--text-main);
}

.settings-nav-item.active {
    background: var(--primary-dim);
    color: var(--primary);
}

.settings-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto; /* THIS handles the scroll */
    height: 100%;     /* Force it to fill available space only */
    scroll-behavior: smooth;
    min-width: 0;     /* Prevents flex items from overflowing horizontally */
}

.settings-section {
    max-width: 600px;
    margin-bottom: 40px;
    scroll-margin-top: 20px;
    padding-bottom: 40px; /* Add space at bottom for scrolling */
}
.settings-section h2 {
    font-size: 1.2rem;
    margin: 0 0 20px 0;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 10px;
}

.setting-card {
    background: var(--bg-app);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 16px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.setting-row:last-child {
    margin-bottom: 0;
}

.setting-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

.setting-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

select,
.setting-toggle,
input[type="color"] {
    padding: 4px 8px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-strong);
    background: var(--bg-app);
    color: var(--text-main);
    font-size: 0.85rem;
}

input[type="color"] {
    height: 32px;
    width: 60px;
    padding: 2px;
    cursor: pointer;
}

/* Simple Text Input dropdown for floor selector */
.floor-selector-input {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    padding: 2px 6px;
    border-radius: var(--border-radius);
    width: 100px;
    font-size: 0.85rem;
    text-align: center;
    font-weight: 600;
}

/* --- Data View --- */
.data-layout {
    display: flex;
    width: 100%;
    height: 100%;
    background: var(--bg-app);
}

.data-sidebar {
    width: 200px;
    border-right: 1px solid var(--border-subtle);
    background: var(--bg-panel);
    padding: 20px;
}

.data-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.data-section {
    margin-bottom: 40px;
    scroll-margin-top: 20px;
}

.data-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 8px;
}

.data-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-main);
}

.data-controls {
    display: flex;
    gap: 8px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th {
    text-align: left;
    padding: 8px;
    border-bottom: 2px solid var(--border-subtle);
    color: var(--text-muted);
    font-weight: 600;
}

.data-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-main);
    vertical-align: middle;
}

.data-table input,
.data-table select {
    width: 100%;
    padding: 4px;
    border: 1px solid var(--border-strong);
    border-radius: var(--border-radius);
    background: var(--bg-app);
    color: var(--text-main);
}

.data-table tr:hover {
    background-color: var(--hover-bg);
}

/* NEW: Gantt Slide Animations */

@keyframes slideInRight {
    0% {
        transform: translateX(80px);
        box-shadow: -6px 0 0 0 #1e3a8a;
        opacity: 0.5;
    }

    100% {
        transform: translateX(0);
        box-shadow: 0 0 0 0 transparent;
        opacity: 1;
    }
}

@keyframes slideInLeft {
    0% {
        transform: translateX(-80px);
        box-shadow: 6px 0 0 0 #1e3a8a;
        opacity: 0.5;
    }

    100% {
        transform: translateX(0);
        box-shadow: 0 0 0 0 transparent;
        opacity: 1;
    }
}

/* Updated Footer & Slider CSS */
.gantt-footer {
    height: var(--footer-height);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-panel);
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
    position: relative;
    /* Ensure z-index context */
    z-index: 5;
}

input[type=range].day-scrollbar {
    -webkit-appearance: none;
    width: 100%;
    height: 32px;
    /* Full footer height for easy grabbing */
    margin: 0;
    background: transparent;
    position: relative;
    z-index: 10;
    /* Float above everything else in footer */
    cursor: grab;
}

input[type=range].day-scrollbar:active {
    cursor: grabbing;
}

/* Track Styling */
input[type=range].day-scrollbar::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: var(--border-subtle);
    border-radius: 3px;
    margin-top: 13px;
    /* Center within 32px height */
}

/* Thumb Styling - Larger Hitbox */
input[type=range].day-scrollbar::-webkit-slider-thumb {
    height: 20px;
    width: 40px;
    border-radius: 10px;
    background: var(--text-muted);
    cursor: grab;
    -webkit-appearance: none;
    margin-top: -7px;
    /* Center on track */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    border: 2px solid var(--bg-panel);
    transition: background 0.2s, transform 0.1s;
}

input[type=range].day-scrollbar:hover::-webkit-slider-thumb {
    background: var(--primary);
    transform: scale(1.1);
}

/* --- PRINT STYLES --- */
@media print {
    @page {
        size: landscape;
        margin: 10mm;
    }

    /* Reset global layout constraints */
    body,
    html,
    .view-container,
    .planner-layout,
    .gantt-container,
    .gantt-body {
        height: auto !important;
        width: 100% !important;
        overflow: visible !important;
        display: block !important;
        position: static !important;
        background: white !important;
    }

    /* Hide UI Elements */
    .app-header,
    .app-nav,
    .app-controls,
    .sidebar,
    .gantt-footer,
    .tooltip,
    .modal-overlay,
    .filter-popup,
    .time-cursor-overlay,
    /* Optionnel: masquer le curseur rouge "NOW" */
    ::-webkit-scrollbar {
        display: none !important;
    }

    /* Show Print Header */
    #printHeader {
        display: block !important;
    }

    /* Gantt Specifics */
    .gantt-body {
        border: 1px solid #ccc;
    }

    /* Avoid breaking inside a machine row */
    .machine-row {
        break-inside: avoid;
        page-break-inside: avoid;
        border-bottom: 1px solid #000 !important;
        /* Lignes plus nettes */
    }

    /* Fix colors for printing (browsers remove background colors by default) */
    .gantt-block,
    .worker-band,
    .block-segment-setup,
    .block-segment-run,
    .machine-info-cell {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    /* Ensure text is black */
    body {
        color: #000 !important;
    }
}

/* ========================================= */
/* === REDESIGNED LOGIN / MAIN MENU VIEW === */
/* ========================================= */

/* 1. Global Menu Mode Overrides */
body.view-mode-menu .app-header {
    display: none !important; /* Hide toolbar completely on login screen */
}

body.view-mode-menu .view-container {
    height: 100vh; /* Full height since header is gone */
}

/* 2. Layout Structure */
#viewMenu.login-layout {
    display: flex;
    width: 100%;
    height: 100%;
    background-color: #0f172a; /* Midnight Blue Base */
    color: #f8fafc;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
}

/* Left Panel: Graphic / Illustration */
.login-left-panel {
    flex: 6; /* Takes 60% of width */
    background-color: #1e293b;
    position: relative;
    overflow: hidden;
    /* Industrial Abstract Gradient + Pattern */
    background-image: 
        linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(30, 58, 138, 0.8)),
        url('../img/ProductionLine.jpg');
    background-size: cover;
    background-position: center;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 60px;
}

.login-hero-text h1 {
    font-size: 3rem;
    font-weight: 800;
    margin: 0 0 10px 0;
    letter-spacing: -1px;
    color: white;
    text-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.login-hero-text p {
    font-size: 1.1rem;
    color: #cbd5e1;
    max-width: 500px;
    line-height: 1.5;
}

/* Right Panel: Login Form */
.login-right-panel {
    flex: 4; /* Takes 40% of width */
    min-width: 450px;
    background: #0f172a;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
    box-shadow: -10px 0 30px rgba(0,0,0,0.2); /* Shadow over image */
    z-index: 10;
}

.login-container {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Branding Section */
.login-brand {
    margin-bottom: 20px;
}

.brand-logo-area {
    width: 64px;
    height: 64px;
    background: #334155;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-weight: 800;
    font-size: 1.5rem;
    color: #60a5fa;
    border: 1px solid #475569;
    
    /* If you have a real logo, uncomment and add URL: */
    /* background-image: url('logo.png'); */
    /* background-size: cover; */
}

.login-brand h2 {
    font-size: 2.2rem;
    font-weight: 800;
    margin: 0;
    color: #f8fafc; 
    text-transform: uppercase;
    letter-spacing: -0.02em; 
    line-height: 1.1;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; 
}

.login-brand p {
    margin: 8px 0 0 0;
    color: #64748b; 
    font-size: 0.85rem;
    letter-spacing: 1.5px; 
    text-transform: uppercase;
    font-weight: 600;
}
.brand-logo-area {
    display: none !important;
}

#viewMenu.login-layout {
    height: 100vh;
    position: absolute; /* Force it to cover everything */
    top: 0;
    left: 0;
    width: 100vw;
    z-index: 9999; /* Ensure it sits on top of everything */
}

/* Inputs */
.input-group label {
    display: block;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 6px;
    font-weight: 500;
}

.input-styled {
    width: 100%;
    padding: 12px 14px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    color: white;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.input-styled:focus {
    outline: none;
    border-color: #3b82f6;
    background: #25334d;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Main Action Button */
.btn-login-action {
    width: 100%;
    padding: 12px;
    background: linear-gradient(to right, #2563eb, #1d4ed8);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, filter 0.2s;
}

.btn-login-action:hover {
    filter: brightness(1.1);
}

.btn-login-action:active {
    transform: scale(0.98);
}

/* Divider */
.login-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: #475569;
    font-size: 0.8rem;
    margin: 10px 0;
}

.login-divider::before, .login-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #334155;
}
.login-divider span {
    padding: 0 10px;
}

/* Sandbox Button */
.btn-sandbox-ghost {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid #475569;
    color: #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-sandbox-ghost:hover {
    background: rgba(255,255,255,0.05);
    border-color: #94a3b8;
    color: white;
}

.sandbox-note {
    text-align: center;
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 8px;
}

/* Error Message */
.login-error-msg {
    min-height: 20px;
    color: #ef4444;
    font-size: 0.85rem;
    margin-top: 10px;
    text-align: center;
}
/* Add this block to the end of app.css */
.worker-band .resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    z-index: 15;
    opacity: 0; /* Hidden unless hovering */
    transition: opacity 0.2s;
}
.worker-band:hover .resize-handle {
    opacity: 1;
}
.worker-band .resize-handle.left {
    left: 0;
    border-left: 3px solid var(--primary);
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}
.worker-band .resize-handle.right {
    right: 0;
    border-right: 3px solid var(--primary);
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}
/* Ensure the band text doesn't overlap handles */
.worker-band .worker-name-text {
    display: block;
    overflow: hidden;
    text-overflow: clip; /* "clip" saves space over "ellipsis" */
    white-space: nowrap;
    margin: 0;
    padding: 0;
    pointer-events: none;
    text-align: center;
    /* responsive font size for tiny boxes */
    font-size: 11px; 
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.2px; /* Tighten letters */
    z-index: 20; /* Ensure text sits above background */
}

/* Responsive: Stack on small screens */
@media (max-width: 900px) {
    #viewMenu.login-layout {
        flex-direction: column;
    }
    .login-left-panel {
        flex: 1;
        padding: 30px;
        min-height: 200px;
    }
    .login-right-panel {
        flex: 2;
        padding: 24px;
        justify-content: flex-start;
        min-width: auto;
    }
}
/* Context Menu */
.custom-context-menu {
    position: fixed;
    z-index: 9999;
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    border-radius: var(--border-radius);
    padding: 6px 0;
    min-width: 180px;
    display: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    animation: fadeIn 0.1s ease-out;
}

.ctx-header {
    padding: 4px 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ctx-item {
    padding: 8px 16px;
    font-size: 0.85rem;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.1s;
}

.ctx-item:hover {
    background: var(--hover-bg);
    color: var(--primary);
}

.ctx-item.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

.ctx-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* =========================================
   PHASE 3: TRAFFIC LIGHT GLOWS (REQUIRED)
   ========================================= */

/* 1. ORANGE: Planned / Attention */
/* Matches JS: status-attention */
.gantt-block.status-attention {
    box-shadow: 0 0 0 2px #f97316, 0 0 12px rgba(249, 115, 22, 0.6);
    border-color: #f97316 !important;
    z-index: 30;
}
.gantt-block.status-attention .block-ticker {
    background-color: #f97316;
    border-color: white;
}

/* 2. YELLOW: Setup Started */
/* Matches JS: status-setup-started */
.gantt-block.status-setup-started {
    box-shadow: 0 0 0 2px #eab308, 0 0 12px rgba(234, 179, 8, 0.6);
    border-color: #eab308 !important;
    z-index: 31;
}
.gantt-block.status-setup-started .block-ticker {
    background-color: #eab308;
    border-color: black;
    color: black;
}

/* 3. BLUE: Production Running */
/* Matches JS: status-run-started */
.gantt-block.status-run-started {
    box-shadow: 0 0 0 2px #3b82f6; 
    border-color: #3b82f6 !important;
    animation: pulse-blue 2s infinite;
    z-index: 32;
}
.gantt-block.status-run-started .block-ticker {
    background-color: #3b82f6;
    border-color: white;
}

/* 4. GREEN: Finished */
/* Matches JS: status-finished */
.gantt-block.status-finished {
    box-shadow: 0 0 0 2px #22c55e; 
    border-color: #22c55e !important;
    opacity: 0.9;
    z-index: 29;
}
.gantt-block.status-finished .block-ticker {
    background-color: #22c55e;
    border-color: white;
}

/* Blue Pulse Animation */
@keyframes pulse-blue {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}


/* =========================================
   PHASE 3: COMMENTS SYSTEM
   ========================================= */

/* 1. The Icon on the Block */
.block-comment-icon {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 14px;
    height: 14px;
    font-size: 9px;
    background: rgba(255, 255, 255, 0.9);
    color: #334155;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 50; /* Above everything else on the block */
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    opacity: 0.6;
    transition: all 0.2s;
}
.block-comment-icon:hover {
    opacity: 1;
    transform: scale(1.2);
    background: white;
    color: #3b82f6;
}
/* Highlight if comments exist */
.block-comment-icon.has-comments {
    opacity: 1;
    color: #3b82f6; /* Blue icon if content exists */
    font-weight: bold;
}

/* 2. The Comment Popup */
.comment-popover {
    position: fixed;
    z-index: 10001; /* Above traffic light menu */
    background: white;
    border: 1px solid #cbd5e1;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    border-radius: 8px;
    width: 320px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    animation: popIn 0.15s ease-out;
}

.comment-header {
    background: #f8fafc;
    padding: 10px 14px;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* The Read-Only History Log */
.comment-history {
    background: #f1f5f9;
    padding: 12px;
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.8rem;
    color: #334155;
    border-bottom: 1px solid #e2e8f0;
    white-space: pre-wrap; /* Preserves newlines */
    line-height: 1.4;
}
.comment-history p { margin: 0 0 8px 0; }
.comment-history .meta {
    font-weight: 700;
    color: #475569;
    font-size: 0.75rem;
    margin-right: 4px;
}

.comment-form {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: white;
}

.comment-input {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: inherit;
    resize: vertical;
}
.comment-input:focus { outline: 2px solid #3b82f6; border-color: transparent; }

.comment-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}


/* The scrollable checkbox container */
.machines-list-container {
    max-height: 80px;
    overflow-y: auto;
    border: 1px solid var(--border-strong);
    padding: 4px;
    border-radius: var(--border-radius);
    background: var(--bg-app); /* Matches inputs */
    color: var(--text-main);
}

/* The separator text "OR IMPORT FROM FILE" */
.modal-separator-text {
    margin: 16px 0;
    border-top: 1px solid var(--border-subtle);
    padding-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* Ensure checkboxes have contrast in dark mode */
.machines-list-container label {
    color: var(--text-main);
    user-select: none;
}

.machines-list-container label:hover {
    color: var(--primary);
}

/* --- TOAST NOTIFICATIONS --- */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10000;
}

.toast {
    background: #333;
    color: #fff;
    padding: 12px 16px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 250px;
    animation: slideIn 0.3s ease-out forwards;
    cursor: pointer;
}

.toast.toast-info { border-left: 4px solid #3b82f6; }
.toast.toast-success { border-left: 4px solid #22c55e; }

.toast-header { font-weight: bold; margin-right: auto; }
.toast-close { background: none; border: none; color: #aaa; cursor: pointer; font-size: 16px; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut {
    to { opacity: 0; transform: translateX(10px); }
}

/* Header Notification Bell */
#btnNotifications {
    position: relative;
    overflow: visible; /* Allow badge to spill out */
}

.badge-count {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: white;
    font-size: 9px;
    font-weight: 700;
    height: 14px;
    min-width: 14px;
    padding: 0 3px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--bg-header);
    z-index: 10;
}

#btnNotifications.has-notifications {
    color: var(--danger);
    animation: swing 2s ease infinite;
}

@keyframes swing {
    0%, 100% { transform: rotate(0deg); }
    20% { transform: rotate(15deg); }
    40% { transform: rotate(-10deg); }
    60% { transform: rotate(5deg); }
    80% { transform: rotate(-5deg); }
}

/* Planner Block Icons */
.block-comment-icon.has-unread {
    color: #ef4444 !important; /* Red */
    opacity: 1 !important;
    transform: scale(1.1);
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
