:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a1f35;
    --bg-card-hover: #1e2440;
    --bg-input: #0f1525;
    --border: #2a3050;
    --border-focus: #e94560;
    --text-primary: #e2e8f0;
    --text-secondary: #8892b0;
    --text-muted: #5a6380;
    --accent: #e94560;
    --accent-hover: #d63050;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --purple: #8b5cf6;
    --cyan: #06b6d4;
    --sidebar-width: 220px;
    --topbar-height: 56px;
    --radius: 10px;
    --radius-sm: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.hidden { display: none !important; }

/* ===== LOGIN ===== */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at top, #1a1f3520 0%, var(--bg-primary) 70%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px rgba(0,0,0,0.4);
}

.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-icon { color: var(--accent); margin-bottom: 16px; }
.login-logo h1 { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.login-subtitle { color: var(--text-secondary); font-size: 14px; }

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

.form-group input[type="email"],
.form-group input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus { border-color: var(--accent); }

/* MFA Code inputs */
.code-inputs {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.code-digit {
    width: 48px !important;
    height: 56px;
    text-align: center;
    font-size: 24px !important;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    padding: 0 !important;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 2px solid var(--border);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.code-digit:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.15);
}

.mfa-info {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
    line-height: 1.6;
}

.mfa-info strong { color: var(--text-primary); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: white;
    font-size: 15px;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--text-secondary); color: var(--text-primary); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

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

.btn-link {
    background: none;
    color: var(--text-secondary);
    width: 100%;
    margin-top: 12px;
    font-size: 13px;
}
.btn-link:hover { color: var(--accent); }

.btn-loader {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.form-error {
    margin-top: 12px;
    padding: 10px 14px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 13px;
    text-align: center;
}

/* ===== DASHBOARD LAYOUT ===== */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    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;
    z-index: 100;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-left h2 { font-size: 16px; font-weight: 600; }
.logo-small { color: var(--accent); display: flex; }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-info { font-size: 12px; color: var(--text-secondary); }

.badge {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    font-weight: 500;
}
.badge.error { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    overflow-y: auto;
    z-index: 90;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    transition: all 0.15s;
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: rgba(233, 69, 96, 0.1); color: var(--accent); }

.content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    padding: 24px;
    min-height: calc(100vh - var(--topbar-height));
}

/* ===== SECTIONS ===== */
.section { display: none; }
.section.active { display: block; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.section-header h3 { font-size: 18px; font-weight: 600; }
.last-update { font-size: 12px; color: var(--text-muted); }

/* ===== PERIOD SELECTOR ===== */
.period-selector {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
    width: fit-content;
}

.period-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.period-btn:hover { color: var(--text-primary); background: var(--bg-card); }
.period-btn.active { background: var(--accent); color: white; }

/* ===== STAT CARDS ===== */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s;
}
.stat-card:hover { border-color: var(--border-focus); transform: translateY(-1px); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon.cpu { background: rgba(233, 69, 96, 0.1); color: var(--accent); }
.stat-icon.memory { background: rgba(139, 92, 246, 0.1); color: var(--purple); }
.stat-icon.disk { background: rgba(59, 130, 246, 0.1); color: var(--info); }
.stat-icon.db { background: rgba(6, 182, 212, 0.1); color: var(--cyan); }
.stat-icon.queries { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.stat-icon.uptime { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.stat-icon.websites { background: rgba(233, 69, 96, 0.1); color: var(--accent); }

.stat-value { display: block; font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-label { display: block; font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.card-body { padding: 20px; }

.loading-placeholder {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
}

/* ===== CHARTS ===== */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.chart-container { position: relative; height: 280px; }

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

.data-table th {
    text-align: left;
    padding: 10px 16px;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.data-table tr:hover td { background: var(--bg-card-hover); }

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

/* ===== SERVER GRID ===== */
.server-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ===== PROGRESS BAR ===== */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-fill.green { background: var(--success); }
.progress-fill.yellow { background: var(--warning); }
.progress-fill.red { background: var(--danger); }
.progress-fill.blue { background: var(--info); }
.progress-fill.purple { background: var(--purple); }

/* ===== SERVICE STATUS ===== */
.service-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }

.service-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.service-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.service-dot.active { background: var(--success); box-shadow: 0 0 8px rgba(16, 185, 129, 0.4); }
.service-dot.inactive { background: var(--danger); box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }

.service-name { font-weight: 500; font-size: 14px; }
.service-status { font-size: 12px; color: var(--text-secondary); margin-left: auto; }

/* ===== METRIC ROW ===== */
.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(42, 48, 80, 0.5);
}
.metric-row:last-child { border-bottom: none; }
.metric-label { color: var(--text-secondary); font-size: 13px; }
.metric-value { font-weight: 600; font-size: 14px; font-family: 'Courier New', monospace; }

/* ===== ANALYTICS ===== */
.stat-icon.analytics { background: rgba(16, 185, 129, 0.1); color: var(--success); }

.analytics-filters {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.analytics-select {
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    cursor: pointer;
}
.analytics-select:focus { border-color: var(--accent); }
.analytics-select option { background: var(--bg-card); }

.realtime-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-left: auto;
}

.realtime-dot {
    width: 8px; height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

.referrer-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}
.referrer-badge.search { background: rgba(59,130,246,0.15); color: var(--info); }
.referrer-badge.social { background: rgba(139,92,246,0.15); color: var(--purple); }
.referrer-badge.website { background: rgba(16,185,129,0.15); color: var(--success); }
.referrer-badge.direct { background: rgba(138,148,176,0.15); color: var(--text-secondary); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .chart-grid { grid-template-columns: 1fr; }
    .server-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .content { margin-left: 0; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .topbar-info { display: none; }
}
