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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #0f0f1e 0%, #1a1a2e 100%);
    color: #e0e0e0;
    min-height: 100vh;
    padding: 20px;
    transition: box-shadow 0.5s ease;
    position: relative;
}

.trigger-zone {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    z-index: 10499;
    pointer-events: auto;
}

@keyframes glow-pulse-green {
    0%, 100% {
        box-shadow: inset 0 0 60px rgba(0, 255, 0, 0.4),
                    inset 0 0 120px rgba(0, 255, 0, 0.2);
    }
    50% {
        box-shadow: inset 0 0 80px rgba(0, 255, 0, 0.6),
                    inset 0 0 140px rgba(0, 255, 0, 0.3);
    }
}

@keyframes glow-pulse-red {
    0%, 100% {
        box-shadow: inset 0 0 60px rgba(255, 0, 0, 0.4),
                    inset 0 0 120px rgba(255, 0, 0, 0.2);
    }
    50% {
        box-shadow: inset 0 0 80px rgba(255, 0, 0, 0.6),
                    inset 0 0 140px rgba(255, 0, 0, 0.3);
    }
}

body.running-good {
    animation: glow-pulse-green 3s ease-in-out infinite;
}

body.running-bad {
    animation: glow-pulse-red 3s ease-in-out infinite;
}

body.not-running {
    box-shadow: none;
    animation: none;
}

.line-selector-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 1800px;
    width: calc(100% - 40px);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: rgba(30, 30, 46, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(99, 102, 241, 0.2);
    opacity: 1;
    transition: opacity 0.5s ease, transform 0.5s ease;
    z-index: 10500;
}

.dashboard-control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dashboard-control-group.hidden {
    display: none;
}

.compact-select {
    min-width: 170px;
    font-size: 14px;
    padding: 8px 12px;
}

.line-selector-spacer {
    flex: 1;
}

.line-selector-container.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
    pointer-events: none;
}

.line-selector-label {
    font-size: 14px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.line-selector {
    padding: 10px 16px;
    background: rgba(30, 30, 46, 0.8);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    min-width: 300px;
    transition: all 0.3s ease;
}

.line-selector:hover {
    border-color: rgba(99, 102, 241, 0.6);
    background: rgba(30, 30, 46, 0.95);
}

.line-selector:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.line-selector option {
    background: #1a1a2e;
    color: #e0e0e0;
    padding: 10px;
}

.dashboard {
    max-width: 1800px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    height: calc(100vh - 40px);
}

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

.card {
    background: rgba(30, 30, 46, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.header-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.header-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.line-info h1 {
    font-size: 48px;
    font-weight: 700;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.line-leader {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 22px;
    color: #e0e0e0;
}

.line-leader-label {
    font-size: 16px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.line-leader-name {
    font-weight: 600;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 22px;
    color: #e0e0e0;
    font-weight: 600;
}

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

.meta-item {
    display: flex;
    flex-direction: column;
}

.meta-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    margin-bottom: 4px;
}

.meta-value {
    font-size: 16px;
    font-weight: 600;
    color: #e0e0e0;
}

.fill-card-info {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    margin-top: 12px;
}

.fill-stat {
    text-align: center;
}

.fill-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    margin-bottom: 6px;
}

.fill-stat-value {
    font-size: 18px;
    font-weight: 600;
    color: #6366f1;
    line-height: 1.3;
}

.fill-stat-value.target {
    color: #10b981;
}

.fill-stat-value.efficiency {
    color: #f59e0b;
}

.chart-card {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.line-insights-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.line-insights-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.line-insights-title {
    font-size: 18px;
    font-weight: 700;
    color: #e0e0e0;
}

.line-insights-subtitle {
    font-size: 13px;
    color: #9ca3af;
    margin-top: 4px;
}

.line-state-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    min-width: 140px;
}

.line-state-badge.good {
    background: rgba(16, 185, 129, 0.18);
    color: #10b981;
}

.line-state-badge.warn {
    background: rgba(245, 158, 11, 0.18);
    color: #f59e0b;
}

.line-state-badge.bad {
    background: rgba(239, 68, 68, 0.18);
    color: #ef4444;
}

.line-state-badge.neutral {
    background: rgba(148, 163, 184, 0.18);
    color: #cbd5e1;
}

.line-insights-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.insight-metric {
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
    min-height: 96px;
}

.insight-label {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.insight-value {
    font-size: 28px;
    font-weight: 700;
    color: #f8fafc;
    line-height: 1.1;
}

.line-insights-note {
    font-size: 14px;
    color: #cbd5e1;
}

.compare-chart-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.compare-chart-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 12px;
}

.compare-scroll-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.compare-scroll-toggle input {
    accent-color: #6366f1;
}

.compare-insights-header {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-bottom: 4px;
}

.compare-insights-summary {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.compare-insights-grid {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.compare-empty-state {
    padding: 18px 20px;
    border-radius: 12px;
    background: rgba(245, 158, 11, 0.12);
    border: 1px dashed rgba(245, 158, 11, 0.5);
    color: #fcd34d;
    font-size: 14px;
}

.compare-chart-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

.compare-chart-grid.hidden {
    display: none;
}

.compare-chart-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.compare-chart-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.compare-chart-panel-title {
    font-size: 15px;
    font-weight: 700;
    color: #e5e7eb;
}

.compare-chart-target {
    font-size: 12px;
}

.compare-chart-wrapper {
    min-height: 190px;
}

@media (max-width: 640px) {
    .compare-insights-summary {
        flex-direction: column;
    }

    .compare-insights-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .compare-chart-grid {
        grid-template-columns: 1fr;
    }
}

.view-hidden {
    display: none !important;
}

.chart-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chart-title-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-title-with-subtitle {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chart-shift-time {
    font-size: 12px;
    font-weight: 400;
    color: #888;
    letter-spacing: 0.5px;
}

.chart-target {
    font-size: 14px;
    font-weight: 700;
    color: #f7f800;
}

.chart-title-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6366f1;
}

.chart-container {
    position: relative;
    flex: 1;
    min-height: 0;
}

/* Scrollable Hour Chart */
.chart-scroll-wrapper {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.chart-scroll-wrapper.compare-chart-wrapper {
    flex: 0 0 190px;
    height: 190px;
    min-height: 190px;
}

.chart-scroll-wrapper::-webkit-scrollbar {
    height: 8px;
}

.chart-scroll-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.chart-scroll-wrapper::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.5);
    border-radius: 4px;
}

.chart-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.7);
}

.chart-scroll-inner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    min-width: 100%;
}

.chart-scroll-wrapper.with-scrollbar-space .chart-scroll-inner {
    bottom: 20px;
}

.right-panel {
    display: flex;
    flex-direction: column;
}

.gaps-card {
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

.gaps-title {
    font-size: 18px;
    font-weight: 600;
    color: #e0e0e0;
}

.gaps-count {
    font-size: 14px;
    padding: 6px 12px;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 20px;
    color: #ef4444;
    font-weight: 600;
}

.current-time {
    font-size: 18px;
    font-weight: 600;
    color: #e0e0e0;
}

.gaps-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gaps-list::-webkit-scrollbar {
    width: 6px;
}

.gaps-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.gaps-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.gaps-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.gap-item {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 12px 16px;
    border-left: 4px solid #f59e0b;
    transition: all 0.3s ease;
}

.gap-item.critical {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    animation: pulse 2s ease-in-out infinite;
}

.gap-stream-label {
    color: #f8fafc;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

.gaps-count.all-clear {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.gap-duration {
    font-size: 18px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 8px;
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.gap-item.critical .gap-duration {
    background: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.gap-details {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    font-size: 13px;
    color: #888;
}

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

.gap-detail-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.gap-detail-value {
    color: #e0e0e0;
    font-weight: 500;
}

.status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #10b981;
    margin-right: 8px;
    animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.no-gaps {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #888;
    font-size: 16px;
}

.no-gaps-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* No Fill Card Overlay */
.no-fill-card-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 15, 30, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    display: none;
    pointer-events: none; /* Keep UI (dropdown) clickable while showing message */
}

.no-fill-card-overlay.active {
    display: flex;
}

.no-fill-card-message {
    text-align: center;
    padding: 60px;
}

.no-fill-card-icon {
    font-size: 96px;
    margin-bottom: 32px;
    opacity: 0.5;
}

.no-fill-card-title {
    font-size: 48px;
    font-weight: 700;
    color: #888;
    margin-bottom: 16px;
}

.no-fill-card-subtitle {
    font-size: 24px;
    color: #666;
}

/* Debug Info */
.debug-info {
    position: fixed;
    bottom: 5px;
    right: 5px;
    color: #444;
    font-size: 10px;
    z-index: 9999;
}

/* ============================
   PBOM Light Theme (Overrides)
   ============================ */

html.theme-pbom body {
    background: linear-gradient(180deg, #f8fafc 0%, #f3f4f6 100%);
    color: #111827;
}

html.theme-pbom body.running-good,
html.theme-pbom body.running-bad {
    animation: none;
    box-shadow: none;
}

html.theme-pbom .line-selector-container {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(17, 24, 39, 0.12);
    box-shadow: 0 12px 28px rgba(16, 24, 40, 0.10);
}

html.theme-pbom #lineSelector {
    background: #ffffff;
    color: #111827;
    border: 1px solid rgba(17, 24, 39, 0.16);
}

html.theme-pbom #lineSelector:hover {
    border-color: rgba(37, 99, 235, 0.40);
}

html.theme-pbom #lineSelector:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

html.theme-pbom #lineSelector option {
    background: #ffffff;
    color: #111827;
}

html.theme-pbom .settings-btn {
    background: #ffffff;
    border: 1px solid rgba(17, 24, 39, 0.16);
    color: #2563eb;
}

html.theme-pbom .settings-btn:hover {
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.35);
}

html.theme-pbom .logout-btn {
    background: #ffffff;
    border: 1px solid rgba(220, 38, 38, 0.22);
    color: #dc2626;
}

html.theme-pbom .logout-btn:hover {
    background: rgba(220, 38, 38, 0.06);
    border-color: rgba(220, 38, 38, 0.35);
}

html.theme-pbom .settings-modal {
    background: rgba(17, 24, 39, 0.45);
}

html.theme-pbom .settings-panel {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(17, 24, 39, 0.12);
    box-shadow: 0 22px 60px rgba(16, 24, 40, 0.18);
}

html.theme-pbom .settings-header {
    border-bottom: 1px solid rgba(17, 24, 39, 0.10);
}

html.theme-pbom .settings-title {
    color: #111827;
}

html.theme-pbom .settings-close {
    color: #6b7280;
}

html.theme-pbom .settings-close:hover {
    color: #111827;
}

html.theme-pbom .settings-section-title {
    color: #6b7280;
}

html.theme-pbom .settings-row {
    background: rgba(17, 24, 39, 0.03);
    border: 1px solid rgba(17, 24, 39, 0.08);
}

html.theme-pbom .settings-row-title {
    color: #111827;
}

html.theme-pbom .settings-row-desc {
    color: #6b7280;
}

html.theme-pbom .toggle-slider {
    background: rgba(17, 24, 39, 0.12);
}

html.theme-pbom .toggle-slider:before {
    background: #9ca3af;
}

html.theme-pbom .toggle-switch input:checked + .toggle-slider {
    background: rgba(37, 99, 235, 0.45);
}

html.theme-pbom .toggle-switch input:checked + .toggle-slider:before {
    background: #2563eb;
}

html.theme-pbom .card {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(17, 24, 39, 0.10);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 18px 38px rgba(16, 24, 40, 0.10);
}

html.theme-pbom .header-card {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(37, 99, 235, 0.22);
}

html.theme-pbom .line-info h1 {
    background: none;
    -webkit-text-fill-color: initial;
    color: #111827;
}

html.theme-pbom .line-leader,
html.theme-pbom .status-item {
    color: #111827;
}

html.theme-pbom .line-leader-label,
html.theme-pbom .meta-label {
    color: #6b7280;
}

html.theme-pbom .meta-value {
    color: #111827;
}

html.theme-pbom .fill-card-info {
    background: rgba(17, 24, 39, 0.03);
    border: 1px solid rgba(17, 24, 39, 0.08);
}

html.theme-pbom .fill-stat-value {
    color: #2563eb;
}

html.theme-pbom .chart-title {
    color: #111827;
}

html.theme-pbom .chart-shift-time {
    color: #6b7280;
}

html.theme-pbom .chart-target {
    color: #2563eb;
}

html.theme-pbom .chart-scroll-wrapper::-webkit-scrollbar-track,
html.theme-pbom .gaps-list::-webkit-scrollbar-track {
    background: rgba(17, 24, 39, 0.06);
}

html.theme-pbom .chart-scroll-wrapper::-webkit-scrollbar-thumb,
html.theme-pbom .gaps-list::-webkit-scrollbar-thumb {
    background: rgba(17, 24, 39, 0.20);
}

html.theme-pbom .chart-scroll-wrapper::-webkit-scrollbar-thumb:hover,
html.theme-pbom .gaps-list::-webkit-scrollbar-thumb:hover {
    background: rgba(17, 24, 39, 0.32);
}

html.theme-pbom .gaps-title,
html.theme-pbom .current-time {
    color: #111827;
}

html.theme-pbom .gap-item {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(17, 24, 39, 0.10);
    border-left-color: #f59e0b;
}

html.theme-pbom .gap-item.critical {
    background: rgba(220, 38, 38, 0.06);
    border-left-color: #dc2626;
    animation: none;
}

html.theme-pbom .gap-details {
    color: #6b7280;
}

html.theme-pbom .gap-stream-label {
    color: #111827;
}

html.theme-pbom .gap-detail-value {
    color: #111827;
}

html.theme-pbom .status-indicator {
    animation: none;
}

html.theme-pbom .hour-toggle {
    background: rgba(17, 24, 39, 0.04);
    border: 1px solid rgba(17, 24, 39, 0.08);
}

html.theme-pbom .hour-toggle-btn {
    color: #6b7280;
}

html.theme-pbom .hour-toggle-btn:hover {
    color: #111827;
}

html.theme-pbom .hour-toggle-btn.active {
    background: #2563eb;
    color: #ffffff;
}

html.theme-pbom .line-insights-title,
html.theme-pbom .compare-chart-panel-title,
html.theme-pbom .insight-value {
    color: #111827;
}

html.theme-pbom .line-insights-subtitle,
html.theme-pbom .line-insights-note {
    color: #4b5563;
}

html.theme-pbom .compare-scroll-toggle {
    color: #4b5563;
}

html.theme-pbom .insight-metric {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(17, 24, 39, 0.10);
}

html.theme-pbom .compare-empty-state {
    background: rgba(245, 158, 11, 0.10);
    border-color: rgba(245, 158, 11, 0.45);
    color: #92400e;
}

html.theme-pbom .line-state-badge.neutral {
    background: rgba(100, 116, 139, 0.12);
    color: #475569;
}

html.theme-pbom .no-fill-card-overlay {
    background: rgba(243, 244, 246, 0.95);
}

html.theme-pbom .no-fill-card-title {
    color: #111827;
}

html.theme-pbom .no-fill-card-subtitle {
    color: #6b7280;
}
