* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: #fff;
    min-height: 100vh;
    display: flex;
}
.mobile-menu-button, .sidebar-overlay { display: none; }
.sidebar {
    width: 260px;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255,255,255,0.05);
    padding: 20px 0 0 0;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 25px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 10px;
    flex-shrink: 0;
}
.brand-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, #00d2ff, #3a7bd5);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: bold;
    flex-shrink: 0;
}
.brand-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 8px;
    flex-shrink: 0;
}
.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 20px;
}
.sidebar-nav a {
    display: block;
    padding: 11px 25px;
    color: #aaa;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    margin: 2px 0;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
    color: #fff;
    background: rgba(0,210,255,0.1);
    border-left: 3px solid #00d2ff;
}
.sidebar-footer {
    flex-shrink: 0;
    padding: 15px 25px;
    border-top: 1px solid rgba(255,255,255,0.05);
    background: rgba(0,0,0,0.2);
}
.logout-link {
    display: block;
    color: #ff6b6b;
    text-decoration: none;
    font-size: 14px;
    padding: 8px 0;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: opacity 0.2s;
}
.logout-link:hover {
    opacity: 0.8;
}
.clock { font-size: 18px; font-weight: bold; color: #00d2ff; }
.online-count { font-size: 12px; color: #888; margin-top: 5px; }
.main-content {
    margin-left: 260px;
    padding: 30px;
    width: calc(100% - 260px);
}
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}
.page-header h1 { font-size: 28px; }
.date-range {
    display: flex;
    align-items: center;
    gap: 10px;
}
.date-range input, .date-range select {
    padding: 8px 12px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: #fff;
}
.date-range button {
    padding: 8px 20px;
    background: linear-gradient(90deg, #00d2ff, #3a7bd5);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
}
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.kpi-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 20px;
}
.kpi-card.highlight {
    border-color: #00d2ff;
    background: rgba(0,210,255,0.08);
}
.kpi-label { font-size: 13px; color: #888; margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: bold; }
.kpi-change { font-size: 13px; margin-top: 5px; }
.kpi-change.up { color: #1dd1a1; }
.kpi-change.down { color: #ff6b6b; }
.kpi-change.same { color: #a7a7b8; }
.chart-container {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 20px;
    height: 350px;
    margin-bottom: 20px;
}
.data-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.data-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 20px;
}
.data-card h3 { margin-bottom: 15px; font-size: 16px; }
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 13px;
}
.data-table th { color: #888; font-weight: 500; }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 12px; }
.badge-admin { background: rgba(255,107,107,0.2); color: #ff6b6b; }
.badge-editor { background: rgba(254,202,87,0.2); color: #feca57; }
.badge-viewer { background: rgba(0,210,255,0.2); color: #00d2ff; }
.btn-primary {
    padding: 10px 24px;
    background: linear-gradient(90deg, #00d2ff, #3a7bd5);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
}
.btn-secondary {
    padding: 10px 24px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    margin-right: 10px;
}
.btn-small {
    padding: 5px 12px;
    font-size: 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    background: rgba(0,210,255,0.2);
    color: #00d2ff;
}
.btn-danger {
    background: rgba(255,107,107,0.2);
    color: #ff6b6b;
}
.form-group { margin-bottom: 15px; }
.form-group label { display: block; color: #aaa; margin-bottom: 6px; font-size: 13px; }
.form-group input, .form-group select {
    width: 100%;
    padding: 10px 12px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: #fff;
}
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.inline-form input, .inline-form select { width: auto; min-width: 150px; }
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; }
.alert.success { background: rgba(29,209,161,0.15); color: #1dd1a1; border: 1px solid rgba(29,209,161,0.3); }
.alert.error { background: rgba(255,107,107,0.15); color: #ff6b6b; border: 1px solid rgba(255,107,107,0.3); }
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    display: none; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal.active { display: flex; }
.modal-content {
    background: #1a1a2e;
    padding: 30px;
    border-radius: 16px;
    width: 90%; max-width: 400px;
    border: 1px solid rgba(255,255,255,0.1);
}
.live-badge {
    color: #ff6b6b;
    font-size: 14px;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.info-box {
    background: rgba(0,210,255,0.08);
    border: 1px solid rgba(0,210,255,0.2);
    border-radius: 12px;
    padding: 15px 20px;
    margin-bottom: 20px;
    color: #aaa;
    font-size: 14px;
}
.badge-auto {
    background: rgba(29,209,161,0.15);
    color: #1dd1a1;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    border: 1px solid rgba(29,209,161,0.3);
}
.logo-preview {
    max-width: 120px;
    max-height: 60px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: block;
}
.logo-header {
    max-height: 40px;
    max-width: 120px;
    border-radius: 6px;
    vertical-align: middle;
}

@media (max-width: 768px) {
    body { display: block; overflow-x: hidden; }
    body.menu-open { overflow: hidden; }
    .mobile-menu-button {
        display: flex;
        position: fixed;
        top: max(12px, env(safe-area-inset-top));
        left: 12px;
        z-index: 301;
        width: 44px;
        height: 44px;
        align-items: center;
        justify-content: center;
        border: 1px solid rgba(255,255,255,0.15);
        border-radius: 12px;
        background: #171536;
        color: #fff;
        font-size: 24px;
        cursor: pointer;
        box-shadow: 0 8px 24px rgba(0,0,0,0.28);
        transition: left .25s ease;
    }
    body.menu-open .mobile-menu-button { left: calc(min(82vw, 300px) - 56px); }
    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 199;
        background: rgba(0,0,0,0.6);
        opacity: 0;
        visibility: hidden;
        transition: opacity .2s ease, visibility .2s ease;
    }
    .sidebar-overlay.active { opacity: 1; visibility: visible; }
    .sidebar {
        width: min(82vw, 300px);
        height: 100dvh;
        z-index: 300;
        transform: translateX(-105%);
        transition: transform .25s ease;
        box-shadow: 12px 0 35px rgba(0,0,0,0.35);
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .sidebar-footer {
        padding-bottom: max(15px, env(safe-area-inset-bottom));
    }
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: calc(72px + env(safe-area-inset-top)) 16px 24px;
    }
    .page-header {
        display: block;
        margin-bottom: 20px;
    }
    .page-header h1 { font-size: 25px; margin-bottom: 16px; }
    .date-range {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto;
        gap: 5px;
        width: 100%;
    }
    .date-range input, .date-range select, .date-range .form-control {
        width: 100%;
        min-width: 0;
        padding: 9px 7px;
        font-size: 12px;
        text-align: center;
        min-height: 44px;
    }
    .date-range button {
        width: auto;
        min-width: 0;
        padding: 9px 8px;
        font-size: 12px;
        white-space: nowrap;
    }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
    .kpi-card { padding: 16px 14px; border-radius: 13px; min-width: 0; }
    .kpi-value { font-size: 25px; overflow-wrap: anywhere; }
    .kpi-change { font-size: 11px; line-height: 1.35; }
    .chart-container { height: 280px; padding: 12px; }
    .data-grid { grid-template-columns: 1fr; gap: 14px; }
    .data-card { padding: 15px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 520px; }
    .inline-form { display: block; }
    .inline-form .form-group, .inline-form input, .inline-form select, .inline-form button { width: 100%; }
    .btn-primary, .btn-secondary { min-height: 44px; }
    .modal-content { max-height: 90vh; overflow-y: auto; padding: 22px 18px; }
    .flatpickr-calendar { max-width: calc(100vw - 24px); }
    .login-box { width: calc(100% - 32px) !important; padding: 28px 22px !important; }
}

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