/* ==================== VARIABLES ==================== */
: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);
}

/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
}

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

.container {
    max-width: 1600px;
    margin: 0 auto;
}

/* ==================== HEADER ==================== */
.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 24px 32px;
    border-radius: var(--border-radius);
    margin-bottom: 24px;
    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 ==================== */
.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; }

/* ==================== PANELS ==================== */
/* Panel styles */
.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;
}

/* Subpanel styles */
.subpanel {
    display: none;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* ==================== BUTTONS ==================== */
.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-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: var(--dark); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ==================== FILTERS BAR ==================== */
.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; font-size: 13px; }
.filter-select {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 40px;
    background: white;
    font-size: 13px;
}

/* ==================== DASHBOARD GRID ==================== */
.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.cleaning { border-left: 4px solid #1abc9c; background: #e8f8f5; }
.line-card.setting { border-left: 4px solid #9b59b6; background: #f4ecf7; }

/* ==================== TABLES ==================== */
.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; }

/* ==================== STAT CARDS ==================== */
.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); }

/* ==================== MODALS ==================== */
.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; }

/* ==================== FORM ==================== */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 13px; }
.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    font-size: 14px;
}
.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;
}

/* ==================== NOTIFICATION TOAST ==================== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.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); }
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ==================== LOADING ==================== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 20px;
}
.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== PAGINATION ==================== */
.btn-pagination {
    padding: 8px 16px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}
.btn-pagination:hover:not(:disabled) {
    background: #0056b3;
    transform: translateY(-1px);
}
.btn-pagination:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

/* ==================== MASTER DATA GRID ==================== */
.master-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.master-card {
    background: var(--light);
    border-radius: 16px;
    padding: 16px;
    border: 1px solid #e0e0e0;
    transition: all 0.2s;
}
.master-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.master-card h4 { color: var(--primary); margin-bottom: 8px; }
.master-actions { margin-top: 12px; display: flex; gap: 8px; justify-content: flex-end; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    body { padding: 12px; }
    .header { flex-direction: column; text-align: center; padding: 16px 20px; }
    .tabs { overflow-x: auto; white-space: nowrap; flex-wrap: nowrap; }
    .lines-grid { grid-template-columns: 1fr; }
    .stats-summary { grid-template-columns: repeat(2, 1fr); }
    .btn { padding: 8px 16px; font-size: 12px; }
}

/* ==================== UTILITIES ==================== */
.text-center { text-align: center; }
.w-100 { width: 100%; }
.badge-batch {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.timer-display {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: bold;
    color: #1e3c72;
    background: #e8f0fe;
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-block;
    margin-top: 8px;
}
.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;
}