* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

:root {
    --primary: #1e3c72;
    --primary-dark: #0f2b4f;
    --success: #2a9d8f;
    --danger: #e76f51;
    --warning: #e9c46a;
    --info: #4a9eff;
    --light: #f8f9fa;
    --dark: #212529;
    --gray: #6c757d;
    --border-radius: 12px;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

body {
    background: #f0f2f5;
    min-height: 100vh;
}

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

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--primary-dark), var(--primary));
    color: white;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    transition: transform 0.3s ease;
}

/* Collapsed sidebar state */
body.sidebar-collapsed .sidebar {
    width: 88px;
}
body.sidebar-collapsed .main-content {
    margin-left: 88px;
}
body.sidebar-collapsed .nav-label { display: none; }
body.sidebar-collapsed .sidebar-header p { display: none; }


.sidebar-header {
    padding: 28px 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.sidebar-header p {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 4px;
}

.sidebar-nav {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.7);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke-width: 1.8;
    display: inline-block;
    background: rgba(255,255,255,0.06);
    padding: 6px;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.9);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
}
.sidebar-toggle svg { width: 20px; height: 20px; }

.sidebar-header { display: flex; justify-content: space-between; align-items: center; }
.sidebar-title { display: flex; flex-direction: column; }
.nav-label { display: inline-block; }

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.active {
    background: rgba(255,255,255,0.15);
    color: white;
    box-shadow: inset 3px 0 0 var(--warning);
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 24px;
    min-height: 100vh;
}

.container { max-width: 100%; margin: 0; }

.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 20px 28px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    box-shadow: var(--shadow-lg);
}

.header h1 { font-size: 28px; font-weight: 700; }
.header h1 span { color: var(--warning); font-size: 16px; margin-left: 12px; }
.header p { font-size: 14px; opacity: 0.85; margin-top: 4px; }

.online-status {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.15);
    padding: 10px 20px;
    border-radius: 40px;
}

.status-dot { width: 12px; height: 12px; border-radius: 50%; background-color: var(--success); }
.status-dot.offline { background-color: var(--danger); }

.tabs {
    display: flex;
    gap: 8px;
    background: white;
    padding: 12px 20px;
    border-radius: 60px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}

.tab {
    padding: 10px 24px;
    border: none;
    background: transparent;
    border-radius: 40px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray);
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover { background: var(--light); color: var(--primary); }
.tab.active { background: var(--primary); color: white; }

.subpanel { display: none; }
.subpanel.active { display: block; animation: fadeIn 0.3s ease; }

.subtabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--light);
    padding-bottom: 12px;
}

.subtab {
    padding: 8px 20px;
    border: none;
    background: transparent;
    border-radius: 40px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray);
    cursor: pointer;
    transition: all 0.2s;
}

.subtab:hover { background: var(--light); color: var(--primary); }
.subtab.active { background: var(--primary); color: white; }

.panel {
    display: none;
    background: white;
    border-radius: var(--border-radius);
    padding: 28px;
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
}

.panel.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--light);
    flex-wrap: wrap;
    gap: 16px;
}

.panel-header h2 { color: var(--primary); font-size: 22px; font-weight: 700; }
.panel-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 40px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-2px); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #248277; transform: translateY(-2px); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #d45a3a; transform: translateY(-2px); }
.btn-warning { background: var(--warning); color: var(--dark); }
.btn-info { background: var(--info); color: white; }
.btn-breakdown { background: #e67e22; color: white; }
.btn-setting { background: #9b59b6; color: white; }
.btn-cleaning { background: #1abc9c; color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.filters-bar {
    background: var(--light);
    border-radius: 16px;
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

.filter-group { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.filter-group label { font-weight: 600; color: var(--dark); font-size: 13px; }

.filter-select {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 40px;
    background: white;
    font-size: 13px;
    cursor: pointer;
}

.filter-badge {
    background: var(--primary);
    color: white;
    padding: 6px 14px;
    border-radius: 40px;
    font-size: 12px;
    font-weight: 600;
}

.lines-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
    gap: 24px;
}

.line-card {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.05);
    transition: all 0.2s;
}

.line-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.line-card.running { border-left: 4px solid var(--success); }
.line-card.breakdown { border-left: 4px solid #e67e22; background: #fff8f0; }
.line-card.paused { border-left: 4px solid var(--warning); background: #fffef7; }
.line-card.cleaning { border-left: 4px solid #1abc9c; background: #e8f8f5; }
.line-card.setting { border-left: 4px solid #9b59b6; background: #f4ecf7; }
.line-card.idle { border-left: 4px solid var(--gray); background: #f8f9fa; }

.line-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.line-title { font-size: 18px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 8px; }

.line-badge { padding: 4px 12px; border-radius: 40px; font-size: 11px; font-weight: 600; background: var(--light); }
.line-badge.online { background: var(--success); color: white; }
.line-badge.breakdown { background: #e67e22; color: white; }
.line-badge.paused { background: var(--warning); color: var(--dark); }
.line-badge.cleaning { background: #1abc9c; color: white; }
.line-badge.setting { background: #9b59b6; color: white; }

.line-status { font-size: 13px; color: var(--gray); margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--light); }
.line-details { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; font-size: 14px; }

.progress-bar { width: 100%; height: 8px; background: var(--light); border-radius: 4px; margin: 12px 0; overflow: hidden; }
.progress-fill { height: 100%; background: var(--success); border-radius: 4px; transition: width 0.3s; }

.line-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

.estimation-box {
    background: #f8fafc;
    border-radius: 12px;
    padding: 12px;
    margin: 12px 0;
    border-left: 3px solid var(--primary);
}

.estimation-title {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 6px;
    font-size: 12px;
}

.estimation-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.line-card.locked { border-left: 4px solid var(--primary); background: #f5f7fc; }

.table-responsive { overflow-x: auto; border-radius: 12px; }

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

th {
    background: var(--primary);
    color: white;
    padding: 14px 16px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

td { padding: 12px 16px; border-bottom: 1px solid var(--light); }
tr:hover { background: #f8fafc; }

.stats-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--light); border-radius: 16px; padding: 16px; text-align: center; }
.stat-card .stat-label { font-size: 12px; color: var(--gray); margin-bottom: 8px; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; color: var(--primary); }

.badge-batch { background: var(--primary); color: white; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; display: inline-block; }

.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
}

.modal.active { display: flex; justify-content: center; align-items: center; }

.modal-content {
    background: white;
    border-radius: 24px;
    padding: 32px;
    max-width: 550px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-header h3 { color: var(--primary); font-size: 22px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 28px; cursor: pointer; color: var(--gray); }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: var(--dark); font-size: 13px; }

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    font-size: 14px;
    transition: all 0.2s;
}

.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,60,114,0.1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.duration-toggle { display: flex; gap: 10px; margin-bottom: 20px; }
.duration-option { flex: 1; padding: 12px; text-align: center; border: 2px solid #e0e0e0; border-radius: 12px; cursor: pointer; transition: all 0.2s; }
.duration-option.active { border-color: var(--primary); background: #e8f0fe; }

.toast-container {
    position: fixed;
    top: 24px; right: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
}

.toast {
    background: white;
    border-radius: 12px;
    padding: 14px 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    animation: slideInRight 0.3s ease;
    border-left: 4px solid;
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-info { border-left-color: var(--info); }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.footer {
    margin-top: 40px;
    padding: 24px;
    background: white;
    border-radius: var(--border-radius);
    text-align: center;
    color: var(--gray);
    font-size: 13px;
}

.text-center { text-align: center; }
.w-100 { width: 100%; }

.master-table { width: 100%; border-collapse: collapse; font-size: 13px; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-sm); }
.master-table th { background: var(--primary); color: white; padding: 12px 16px; font-weight: 600; text-align: left; }
.master-table td { padding: 10px 16px; border-bottom: 1px solid var(--light); }
.master-table tr:hover { background: #f8fafc; }
.master-table .btn-sm { padding: 4px 10px; font-size: 11px; margin: 0 2px; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 16px; }
.section-header h3 { color: var(--primary); font-size: 18px; font-weight: 700; }

.modern-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.modern-table thead th { background: #1e3c72; color: white; padding: 14px 16px; font-weight: 600; text-align: left; white-space: nowrap; position: sticky; top: 0; z-index: 10; }
.modern-table tbody tr { transition: all 0.2s ease; }
.modern-table tbody tr:nth-child(even) { background: #f8f9fa; }
.modern-table tbody tr:hover { background: #e8f0fe !important; cursor: pointer; }
.modern-table tbody td { padding: 12px 16px; border-bottom: 1px solid #e9ecef; vertical-align: middle; }

.pagination-wrapper { margin-top: 20px; padding-top: 16px; border-top: 1px solid #e9ecef; }
.pagination-container { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.pagination-info { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #666; }
.pagination-info select { padding: 6px 12px; border: 1px solid #ddd; border-radius: 8px; background: white; font-size: 13px; cursor: pointer; outline: none; }
.pagination-controls { display: flex; gap: 4px; align-items: center; }
.pagination-controls button { padding: 6px 12px; border: 1px solid #ddd; background: white; border-radius: 6px; cursor: pointer; font-size: 13px; transition: all 0.2s; min-width: 36px; text-align: center; }
.pagination-controls button:hover:not(:disabled) { background: var(--primary); color: white; border-color: var(--primary); }
.pagination-controls button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination-controls button:disabled { opacity: 0.4; cursor: not-allowed; }

.status-active { background: #e67e22; color: white; padding: 4px 12px; border-radius: 20px; font-size: 11px; }
.status-completed { background: #27ae60; color: white; padding: 4px 12px; border-radius: 20px; font-size: 11px; }

.pause-option:hover { border-color: #1e3c72; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(30,60,114,0.15); }
.pause-option.selected { border-color: #1e3c72; background: #e8f0fe; box-shadow: 0 0 0 3px rgba(30,60,114,0.2); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
::-webkit-scrollbar-thumb { background: #c1c7cd; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #a0a7ad; }

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

@media (max-width: 768px) {
    body { padding: 16px; }
    .header { padding: 16px 20px; flex-direction: column; align-items: flex-start; }
    .header h1 { font-size: 22px; }
    .tabs { border-radius: 16px; padding: 8px 12px; gap: 4px; overflow-x: auto; flex-wrap: nowrap; }
    .tab { padding: 6px 12px; font-size: 12px; white-space: nowrap; }
    .panel { padding: 16px; }
    .panel-header { flex-direction: column; align-items: flex-start; }
    .panel-header h2 { font-size: 18px; }
    .lines-grid { grid-template-columns: 1fr; gap: 16px; }
    .line-card { padding: 16px; }
    .line-details { grid-template-columns: 1fr; gap: 8px; }
    .stats-summary { grid-template-columns: 1fr 1fr; gap: 12px; }
    .filters-bar { flex-direction: column; align-items: stretch; padding: 12px 16px; }
    .form-row { grid-template-columns: 1fr; }
    .modal-content { padding: 20px; max-width: 95%; }
    .duration-toggle { flex-direction: column; }
    .pagination-container { flex-direction: column; align-items: stretch; gap: 8px; }
}

@media print {
    .header, .tabs, .filters-bar, .panel-actions, .line-actions { display: none !important; }
    .panel { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
    body { background: white !important; padding: 16px !important; }
}
