:root {
    --bg-app: #f1f5f9;
    --bg-sidebar: #0f172a;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-sidebar: #94a3b8;
    --border-color: #e2e8f0;
    --primary: #3b82f6;

    /* ERP Colors */
    --accent-blue: #2563eb;
    --accent-purple: #7c3aed;
    --accent-red: #dc2626;
    --accent-emerald: #059669;
    --accent-amber: #d97706;

    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --sidebar-width: 260px;
    --header-height: 70px;
    --radius-lg: 12px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg-app);
    color: var(--text-main);
    font-size: 14px;
    overflow-x: hidden;
}

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.page-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-title h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: var(--text-main);
}

.badge-live {
    background: #dcfce7;
    color: #166534;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 99px;
    letter-spacing: 0.5px;
    border: 1px solid #bbf7d0;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-box {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    gap: 8px;
    width: 280px;
    transition: all 0.2s;
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    font-family: inherit;
    font-size: 13px;
    width: 100%;
}

.search-box i {
    color: #94a3b8;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: var(--radius-sm);
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: #f8fafc;
    color: var(--primary);
    border-color: #cbd5e1;
}

.modern-toggle-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    background: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    color: #475569;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-right: 15px;
    cursor: pointer;
    font-size: 1.1rem;
}

.modern-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    color: var(--primary, #3b82f6);
    border-color: var(--primary, #3b82f6);
}

/* Dashboard Grid */
.dashboard-grid {
    padding: 32px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* KPI Cards */
.kpi-section {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.kpi-card.accent-blue::before {
    background: var(--accent-blue);
}

.kpi-card.accent-purple::before {
    background: var(--accent-purple);
}

.kpi-card.accent-red::before {
    background: var(--accent-red);
}

.kpi-card.accent-emerald::before {
    background: var(--accent-emerald);
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.kpi-value-group {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}

.kpi-value-group .value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -1px;
    font-family: var(--font-mono);
}

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

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

.kpi-action button {
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
}

.kpi-action button:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: var(--primary);
}

/* Tables Section */
.tables-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.content-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tall-card {
    grid-row: span 1;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
}

.card-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header h3 i {
    color: #94a3b8;
}

.more-btn {
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    font-size: 14px;
}

.card-badge {
    background: #e0f2fe;
    color: #0369a1;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.table-responsive {
    overflow-x: auto;
    flex: 1;
}

.erp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.erp-table th {
    background: #f8fafc;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    padding: 12px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.erp-table td {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    color: #334155;
    font-weight: 500;
}

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

.erp-table tbody tr:hover {
    background: #f1f5f9;
}

.text-right {
    text-align: right;
}

/* Status dots */
.status-dot {
    height: 8px;
    width: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.status-dot.red {
    background: #ef4444;
}

.status-dot.green {
    background: #22c55e;
}

.status-dot.amber {
    background: #f59e0b;
}

/* Responsive */
@media (max-width: 1400px) {
    .tables-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

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

@media (max-width: 768px) {
    .main-content {
        margin-left: 0 !important;
    }

    .topbar {
        padding: 0 16px;
    }

    .page-title h1 {
        font-size: 16px;
    }

    .badge-live {
        display: none;
    }

    .search-box {
        display: none;
    }

    .dashboard-grid {
        padding: 16px;
    }

    .kpi-section {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .tables-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Section Divider */
.section-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 0 16px;
    margin-top: 12px;
    border-top: 2px solid var(--border-color);
}

.section-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

.section-title i {
    color: var(--accent-blue);
}

.section-badge {
    background: #ede9fe;
    color: #6d28d9;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Capacity Chart Bars */
.cap-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.cap-bar-label {
    width: 100px;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    text-align: right;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cap-bar-track {
    flex: 1;
    height: 22px;
    background: #f1f5f9;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.cap-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.6s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 6px;
    min-width: 28px;
}

.cap-bar-pct {
    font-size: 10px;
    font-weight: 700;
    color: white;
}

/* Capacity Efficiency Badge */
.cap-eff-badge {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.cap-eff-badge.fast {
    background: #dcfce7;
    color: #166534;
}

.cap-eff-badge.normal {
    background: #e0f2fe;
    color: #0369a1;
}

.cap-eff-badge.slow {
    background: #fef3c7;
    color: #92400e;
}

/* Capacity Detail Button */
.cap-detail-btn {
    border: 1px solid #e2e8f0;
    background: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    color: #3b82f6;
    cursor: pointer;
    transition: all 0.2s;
}

.cap-detail-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
}

/* Capacity Status Badge */
.cap-status {
    display: inline-flex;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.cap-status.ok {
    background: #dcfce7;
    color: #166534;
}

.cap-status.late {
    background: #fee2e2;
    color: #991b1b;
}

.cap-status.stok {
    background: #f1f5f9;
    color: #64748b;
}

.cap-status.warn {
    background: #fef3c7;
    color: #92400e;
}

/* Capacity Modal */
.cap-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.cap-modal-overlay.show {
    display: flex;
}

.cap-modal-box {
    background: white;
    border-radius: 12px;
    width: 700px;
    max-width: 95%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.cap-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}

.cap-modal-head h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #334155;
}

.cap-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: #94a3b8;
    cursor: pointer;
}

.cap-modal-close:hover {
    color: #1e293b;
}

/* Modern Searchable List Modal */
.recipe-search-box {
    position: relative;
    margin-bottom: 5px;
}

.recipe-search-input {
    width: 100%;
    padding: 12px 16px;
    padding-left: 40px;
    /* Space for icon */
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    color: #1e293b;
    background: #f8fafc;
    transition: all 0.2s;
}

.recipe-search-input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.recipe-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.recipe-list-container {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    background: white;
    margin-bottom: 20px;
}

.recipe-item {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
    color: #334155;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.recipe-item:hover {
    background: #f8fafc;
}

.recipe-item.selected {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 600;
}

.recipe-item.no-results {
    padding: 20px;
    text-align: center;
    color: #94a3b8;
    cursor: default;
}

/* Modern Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: white;
    color: #64748b;
    border: 1px solid #e2e8f0;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #f8fafc;
    color: #334155;
    border-color: #cbd5e1;
}

.btn-danger-outline {
    background: white;
    color: #ef4444;
    border: 1px solid #fee2e2;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger-outline:hover {
    background: #fef2f2;
    border-color: #fecaca;
}