/* =============================================
   ManufactureIQ - Global Design System
   Track B: AI Optimization Engine
   ============================================= */

:root {
    /* Color Palette */
    --bg-primary: #0a0e1a;
    --bg-secondary: #0f1628;
    --bg-card: #131d30;
    --bg-card-hover: #1a2540;
    --bg-elevated: #1e2d47;
    --border: rgba(255, 255, 255, 0.07);
    --border-accent: rgba(0, 212, 170, 0.3);

    /* Brand Colors */
    --teal: #00d4aa;
    --teal-dim: rgba(0, 212, 170, 0.12);
    --purple: #6c63ff;
    --purple-dim: rgba(108, 99, 255, 0.12);
    --red: #ff6b6b;
    --red-dim: rgba(255, 107, 107, 0.12);
    --gold: #ffd93d;
    --gold-dim: rgba(255, 217, 61, 0.12);
    --blue: #4ecdc4;
    --orange: #ff9f43;

    /* KPI Theme Colors */
    --energy-color: #00d4aa;
    --carbon-color: #6c63ff;
    --quality-color: #4ecdc4;
    --yield-color: #ffd93d;
    --perf-color: #ff9f43;
    --health-color: #a8e6cf;

    /* Text */
    --text-primary: #e8edf5;
    --text-secondary: #8b9bb4;
    --text-muted: #5a6a84;
    --text-accent: #00d4aa;

    /* Semantic */
    --success: #00d4aa;
    --warning: #ffd93d;
    --danger: #ff6b6b;
    --info: #6c63ff;

    /* Sizing */
    --sidebar-width: 240px;
    --topbar-height: 60px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --glow-teal: 0 0 20px rgba(0, 212, 170, 0.25);
    --glow-purple: 0 0 20px rgba(108, 99, 255, 0.25);

    /* Animation */
    --transition: all 0.2s ease;
    --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========== LAYOUT ========== */
#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ---- Sidebar ---- */
#sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    transition: var(--transition-slow);
    z-index: 100;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px;
    border-bottom: 1px solid var(--border);
}

.brand-icon svg {
    width: 32px;
    height: 32px;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.brand-sub {
    font-size: 10px;
    font-weight: 500;
    color: var(--teal);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: 0;
    transition: var(--transition);
    position: relative;
    border-left: 2px solid transparent;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item:hover svg {
    opacity: 1;
}

.nav-item.active {
    background: var(--teal-dim);
    color: var(--teal);
    border-left-color: var(--teal);
}

.nav-item.active svg {
    opacity: 1;
    color: var(--teal);
}

.nav-badge {
    margin-left: auto;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.nav-badge.alert {
    background: rgba(255, 107, 107, 0.2);
    color: var(--red);
}

.nav-badge.warning {
    background: rgba(255, 217, 61, 0.2);
    color: var(--gold);
}

.sidebar-footer {
    padding: 16px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.active {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse-dot 2s infinite;
}

.status-dot.warning {
    background: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

.status-dot.danger {
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.engine-version {
    font-size: 10px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* ---- Main Content ---- */
#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ---- Topbar ---- */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
    gap: 16px;
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    position: relative;
}

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

.icon-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-accent);
}

.page-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.bc-root {
    color: var(--text-muted);
}

.page-breadcrumb svg {
    width: 12px;
    height: 12px;
    color: var(--text-muted);
}

.bc-current {
    color: var(--text-primary);
    font-weight: 600;
}

.batch-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    color: var(--text-secondary);
}

.batch-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--teal);
    box-shadow: 0 0 6px var(--teal);
}

.batch-dot.pulse {
    animation: pulse-dot 1.5s infinite;
}

.topbar-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--text-muted);
    min-width: 70px;
    text-align: right;
}

.notification-btn {
    position: relative;
}

.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--red);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- Page Content ---- */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

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

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    white-space: nowrap;
    text-decoration: none;
}

.btn svg {
    width: 14px;
    height: 14px;
}

.btn-primary {
    background: var(--teal);
    color: #0a0e1a;
    border-color: var(--teal);
}

.btn-primary:hover {
    background: #00f0c2;
    box-shadow: var(--glow-teal);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--purple);
    color: #fff;
    border-color: var(--purple);
}

.btn-secondary:hover {
    background: #7b74ff;
    box-shadow: var(--glow-purple);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-accent);
}

.btn-danger {
    background: var(--red-dim);
    color: var(--red);
    border-color: rgba(255, 107, 107, 0.3);
}

.btn-danger:hover {
    background: rgba(255, 107, 107, 0.2);
}

.btn-gold {
    background: var(--gold-dim);
    color: var(--gold);
    border-color: rgba(255, 217, 61, 0.3);
}

.btn-gold:hover {
    background: rgba(255, 217, 61, 0.2);
}

.btn-lg {
    padding: 12px 24px;
    font-size: 14px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-running {
    background: var(--teal-dim) !important;
    color: var(--teal) !important;
    cursor: not-allowed !important;
    animation: btn-pulse 1.5s infinite;
}

@keyframes btn-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* ========== CHIP BUTTONS ========== */
.chip {
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.chip.active,
.chip:hover {
    background: var(--teal-dim);
    color: var(--teal);
    border-color: rgba(0, 212, 170, 0.3);
}

/* ========== KPI GRID ========== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
}

.energy-card::before {
    background: var(--energy-color);
}

.carbon-card::before {
    background: var(--carbon-color);
}

.quality-card::before {
    background: var(--quality-color);
}

.yield-card::before {
    background: var(--yield-color);
}

.performance-card::before {
    background: var(--perf-color);
}

.health-card::before {
    background: var(--health-color);
}

.kpi-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.kpi-icon.energy {
    background: var(--teal-dim);
    color: var(--energy-color);
}

.kpi-icon.carbon {
    background: var(--purple-dim);
    color: var(--carbon-color);
}

.kpi-icon.quality {
    background: rgba(78, 205, 196, 0.12);
    color: var(--quality-color);
}

.kpi-icon.yield {
    background: var(--gold-dim);
    color: var(--yield-color);
}

.kpi-icon.performance {
    background: rgba(255, 159, 67, 0.12);
    color: var(--perf-color);
}

.kpi-icon.health {
    background: rgba(168, 230, 207, 0.12);
    color: var(--health-color);
}

.kpi-delta {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.kpi-delta.positive {
    color: var(--success);
    background: rgba(0, 212, 170, 0.1);
}

.kpi-delta.negative {
    color: var(--success);
    background: rgba(0, 212, 170, 0.1);
}

.kpi-delta.neutral {
    color: var(--text-muted);
    background: var(--bg-elevated);
}

.kpi-delta.bad {
    color: var(--danger);
    background: rgba(255, 107, 107, 0.1);
}

.kpi-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1;
}

.kpi-unit {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-muted);
}

.kpi-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.kpi-target-bar {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.target-track {
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 2px;
    overflow: hidden;
}

.target-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.energy-fill {
    background: var(--energy-color);
}

.carbon-fill {
    background: var(--carbon-color);
}

.quality-fill {
    background: var(--quality-color);
}

.yield-fill {
    background: var(--yield-color);
}

.perf-fill {
    background: var(--perf-color);
}

.health-fill {
    background: var(--health-color);
}

.target-pct {
    font-size: 11px;
    color: var(--text-muted);
}

/* ========== CHART CARDS ========== */
.chart-row {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 16px;
}

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

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

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

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chart-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.chart-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.chart-controls {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

canvas {
    max-width: 100%;
}

/* ========== PANELS ========== */
.bottom-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

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

.panel-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.panel-link {
    font-size: 12px;
    color: var(--teal);
    text-decoration: none;
    font-weight: 500;
}

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

.badge-count {
    background: var(--red-dim);
    color: var(--red);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

/* ========== ALERT ITEMS ========== */
.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.alert-item:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.alert-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}

.alert-dot.critical {
    background: var(--red);
    box-shadow: 0 0 6px var(--red);
}

.alert-dot.warning {
    background: var(--gold);
    box-shadow: 0 0 6px var(--gold);
}

.alert-dot.info {
    background: var(--blue);
    box-shadow: 0 0 6px var(--blue);
}

.alert-body {
    flex: 1;
    min-width: 0;
}

.alert-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.alert-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.alert-time {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ========== ALERT BANNER ========== */
.alert-banner {
    background: rgba(255, 107, 107, 0.1);
    border-bottom: 1px solid rgba(255, 107, 107, 0.3);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--red);
}

.alert-banner.hidden {
    display: none;
}

/* ========== FORM ELEMENTS ========== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-input,
.form-select,
.form-textarea {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    transition: var(--transition);
    width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 2px rgba(0, 212, 170, 0.15);
}

.form-select {
    cursor: pointer;
}

/* Range Sliders */
.slider-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.slider-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.slider-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--teal);
    font-family: 'JetBrains Mono', monospace;
    min-width: 40px;
    text-align: right;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-elevated);
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--teal);
    cursor: pointer;
    border: 2px solid var(--bg-card);
    box-shadow: 0 0 8px rgba(0, 212, 170, 0.4);
    transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type="range"].purple-range::-webkit-slider-thumb {
    background: var(--purple);
    box-shadow: 0 0 8px rgba(108, 99, 255, 0.4);
}

input[type="range"].gold-range::-webkit-slider-thumb {
    background: var(--gold);
    box-shadow: 0 0 8px rgba(255, 217, 61, 0.4);
}

input[type="range"].orange-range::-webkit-slider-thumb {
    background: var(--orange);
    box-shadow: 0 0 8px rgba(255, 159, 67, 0.4);
}

input[type="range"].red-range::-webkit-slider-thumb {
    background: var(--red);
    box-shadow: 0 0 8px rgba(255, 107, 107, 0.4);
}

/* Toggle Switch */
.toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-elevated);
    border-radius: 24px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--teal-dim);
    border-color: var(--teal);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(20px);
    background: var(--teal);
}

/* ========== TABLE ========== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
}

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

.data-table tr:hover td {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.data-table .mono {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

/* ========== TAGS/BADGES ========== */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.tag-teal {
    background: var(--teal-dim);
    color: var(--teal);
}

.tag-purple {
    background: var(--purple-dim);
    color: var(--purple);
}

.tag-gold {
    background: var(--gold-dim);
    color: var(--gold);
}

.tag-red {
    background: var(--red-dim);
    color: var(--red);
}

.tag-blue {
    background: rgba(78, 205, 196, 0.12);
    color: var(--blue);
}

.tag-orange {
    background: rgba(255, 159, 67, 0.12);
    color: var(--orange);
}

.tag-gray {
    background: var(--bg-elevated);
    color: var(--text-muted);
}

/* ========== PROGRESS ========== */
.progress-bar {
    height: 8px;
    background: var(--bg-elevated);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== TOAST NOTIFICATIONS ========== */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    min-width: 280px;
    max-width: 380px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition: opacity 0.3s, transform 0.3s;
}

.toast.removing {
    opacity: 0;
    transform: translateX(100%);
}

.toast-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-body {
    flex: 1;
}

.toast-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.toast-msg {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
}

.toast.success {
    border-color: rgba(0, 212, 170, 0.3);
}

.toast.success .toast-icon {
    color: var(--teal);
}

.toast.warning {
    border-color: rgba(255, 217, 61, 0.3);
}

.toast.warning .toast-icon {
    color: var(--gold);
}

.toast.error {
    border-color: rgba(255, 107, 107, 0.3);
}

.toast.error .toast-icon {
    color: var(--red);
}

.toast.info {
    border-color: rgba(108, 99, 255, 0.3);
}

.toast.info .toast-icon {
    color: var(--purple);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(80px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fade-in 0.2s ease;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 28px;
    min-width: 400px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modal-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ========== METRIC ROW ========== */
.metric-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.metric-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    min-width: 80px;
    text-align: center;
}

.metric-pill-value {
    font-size: 16px;
    font-weight: 700;
}

.metric-pill-label {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ========== TABS ========== */
.tab-header {
    display: flex;
    border-bottom: 1px solid var(--border);
    gap: 0;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: -1px;
}

.tab-btn.active {
    color: var(--teal);
    border-bottom-color: var(--teal);
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-content {
    display: none;
    padding-top: 16px;
}

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

/* ========== LOADING / SKELETON ========== */
.skeleton {
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-card-hover) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ========== DIVIDER ========== */
.divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ========== GOLDEN SIGNATURE CARD ========== */
.signature-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.signature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--gold), var(--teal));
}

.signature-card:hover {
    border-color: rgba(255, 217, 61, 0.3);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(255, 217, 61, 0.1);
}

.signature-card.active-sig {
    border-color: rgba(0, 212, 170, 0.4);
    background: rgba(0, 212, 170, 0.04);
}

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

.sig-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.sig-metrics {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.sig-metric-item {
    text-align: center;
}

.sig-metric-val {
    font-size: 14px;
    font-weight: 700;
}

.sig-metric-lbl {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

/* ========== PARETO FRONT ========== */
.pareto-wrapper {
    position: relative;
    width: 100%;
    padding-top: 60%;
}

.pareto-wrapper canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1400px) {
    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

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

    .bottom-row {
        grid-template-columns: 1fr 1fr;
    }

    .sig-metrics {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 56px;
    }

    .brand-text,
    .nav-item span,
    .nav-badge,
    .sidebar-footer span,
    .engine-version {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: 12px;
    }

    .nav-item svg {
        opacity: 1;
    }

    .bottom-row {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    .page-content {
        padding: 16px;
    }
}

/* ========== ANIMATION UTILITIES ========== */
.fade-in {
    animation: fade-in 0.4s ease forwards;
}

.slide-up {
    animation: slide-up 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.glow-teal {
    box-shadow: var(--glow-teal);
}

.glow-purple {
    box-shadow: var(--glow-purple);
}

/* Optimization running animation */
@keyframes opt-spin {
    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: opt-spin 1s linear infinite;
}

/* ========== SIDEBAR COLLAPSE ========== */
#sidebar.collapsed {
    width: 56px;
}

#sidebar.collapsed .brand-text,
#sidebar.collapsed .nav-item span,
#sidebar.collapsed .nav-badge,
#sidebar.collapsed .sidebar-footer span,
#sidebar.collapsed .engine-version {
    display: none;
}

#sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px;
}

#sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: 16px 12px;
}

/* ========== LOCKED BADGE ========== */
.locked-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    background: rgba(255, 217, 61, 0.12);
    color: var(--gold);
    border: 1px solid rgba(255, 217, 61, 0.25);
}

/* ========== COMPARE METRICS ========== */
.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.compare-metric {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    text-align: center;
}

.compare-metric .metric-lbl {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 4px;
}

.compare-metric .batch-val {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.compare-metric .sig-val {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.compare-metric .diff-val {
    font-size: 11px;
    font-weight: 600;
    margin-top: 3px;
}

.compare-metric.better .diff-val {
    color: var(--teal);
}

.compare-metric.worse .diff-val {
    color: var(--red);
}

.compare-metric.neutral .diff-val {
    color: var(--text-muted);
}

/* ========== TARGET CARDS (Adaptive Targets page) ========== */
.target-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.target-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.target-big {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -.03em;
    line-height: 1;
}

.compliance-bar-wrap {
    height: 8px;
    background: var(--bg-elevated);
    border-radius: 4px;
    overflow: hidden;
}

.compliance-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s cubic-bezier(.4, 0, .2, 1);
}

.compliant-fill {
    background: var(--teal);
}

.warn-fill {
    background: var(--gold);
}

.danger-fill {
    background: var(--red);
}

/* ========== RECOMMENDATION CARDS (Human-in-Loop) ========== */
.rec-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: var(--transition);
}

.rec-card:hover {
    border-color: rgba(255, 255, 255, .1);
}

.rec-card.critical {
    border-left: 3px solid var(--red);
}

.rec-card.warning {
    border-left: 3px solid var(--gold);
}

.rec-card.info {
    border-left: 3px solid var(--purple);
}

.rec-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ========== TIMELINE (Decision History) ========== */
.timeline-item {
    display: flex;
    gap: 14px;
    padding-bottom: 16px;
    position: relative;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 18px;
    bottom: 0;
    width: 1px;
    background: var(--border);
}

.timeline-item:last-child::before {
    display: none;
}

.timeline-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 2px;
    border: 2px solid var(--bg-secondary);
}

.timeline-body {
    flex: 1;
}

.timeline-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.timeline-detail {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.timeline-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    font-family: 'JetBrains Mono', monospace;
}

/* ========== PARAM GRID (Optimization / Golden Sig) ========== */
.param-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.param-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.param-name {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.param-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    margin-top: 3px;
}

.param-unit {
    font-size: 11px;
    color: var(--text-muted);
}

/* ========== SENSITIVITY BARS ========== */
.sensitivity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.sensitivity-rank {
    width: 20px;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
}

.sensitivity-name {
    width: 140px;
    font-size: 12px;
    color: var(--text-secondary);
}

.sensitivity-track {
    flex: 1;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
}

.sensitivity-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--purple), var(--teal));
}

.sensitivity-val {
    width: 50px;
    text-align: right;
    font-size: 11px;
    font-weight: 700;
    color: var(--teal);
    font-family: 'JetBrains Mono', monospace;
}

/* ========== FRAMEWORK CARDS ========== */
.framework-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.framework-card:hover {
    border-color: rgba(0, 212, 170, .3);
    background: var(--bg-card);
}

.framework-card.active {
    border-color: var(--teal);
    background: var(--teal-dim);
}

.framework-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.framework-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.framework-limit {
    font-size: 11px;
    color: var(--teal);
    margin-top: 6px;
    font-weight: 600;
}

/* ========== SCORE BADGE ========== */
.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    border: 1px solid currentColor;
}

/* ========== RESPONSIVE for new pages ========== */
@media (max-width: 1200px) {
    .param-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

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

    .sig-score-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .learning-stats {
        grid-template-columns: repeat(3, 1fr);
    }

    .reliability-summary {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

    .sig-score-grid {
        grid-template-columns: 1fr 1fr;
    }

    .learning-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .param-grid {
        grid-template-columns: 1fr 1fr;
    }
}