:root {
    --bg-base: #0a0d14;
    --bg-surface: #111726;
    --bg-surface-elevated: #182238;
    --bg-glass: rgba(17, 23, 38, 0.75);
    --border-subtle: rgba(255, 255, 255, 0.07);
    --border-focus: rgba(99, 102, 241, 0.5);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --brand-primary: #6366f1;
    --brand-primary-hover: #4f46e5;
    --brand-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --brand-glow: 0 0 25px rgba(99, 102, 241, 0.35);

    --status-healthy: #10b981;
    --status-healthy-bg: rgba(16, 185, 129, 0.12);
    --status-warning: #f59e0b;
    --status-warning-bg: rgba(245, 158, 11, 0.12);
    --status-high: #f97316;
    --status-high-bg: rgba(249, 115, 22, 0.12);
    --status-critical: #ef4444;
    --status-critical-bg: rgba(239, 68, 68, 0.15);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
    background: #25334d;
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: #3b4e6f;
}

/* Top Navbar */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: var(--bg-glass);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
}

.brand-icon {
    width: 34px;
    height: 34px;
    background: var(--brand-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--brand-glow);
}

.brand-title {
    background: linear-gradient(135deg, #ffffff 40%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: #fff;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Status Pill */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.775rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.status-pill.healthy {
    background: var(--status-healthy-bg);
    color: var(--status-healthy);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.status-pill.warning {
    background: var(--status-warning-bg);
    color: var(--status-warning);
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.status-pill.danger {
    background: var(--status-high-bg);
    color: var(--status-high);
    border: 1px solid rgba(249, 115, 22, 0.25);
}

.status-pill.critical {
    background: var(--status-critical-bg);
    color: var(--status-critical);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 10px currentColor;
    animation: pulseGlow 1.8s infinite;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

/* User & Logout */
.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.btn-logout {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fff;
}

/* Main Container */
.main-wrapper {
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
    padding: 1.75rem;
    flex: 1;
}

/* Page Headers */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: #fff;
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Cards & Grid Layouts */
.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

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

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.35rem;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.card-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.metric-number {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: #fff;
    line-height: 1.1;
}

.metric-subtext {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.4rem;
}

/* Health Gauge & Score Hero */
.health-hero {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1.75rem;
    background: linear-gradient(135deg, rgba(30, 41, 69, 0.6) 0%, rgba(17, 23, 38, 0.9) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    margin-bottom: 1.75rem;
    position: relative;
}

.gauge-container {
    width: 130px;
    height: 130px;
    position: relative;
    flex-shrink: 0;
}

.gauge-svg {
    transform: rotate(-90deg);
}

.gauge-circle-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 10;
}

.gauge-circle-val {
    fill: none;
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease-in-out;
}

.gauge-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 1.85rem;
    font-weight: 800;
    color: #fff;
    line-height: 1;
}

.gauge-text span {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.health-hero-info {
    flex: 1;
}

.health-hero-title {
    font-size: 1.45rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 0.35rem;
}

.health-hero-desc {
    font-size: 0.925rem;
    color: var(--text-secondary);
    max-width: 650px;
}

/* Recommendations Card */
.guidance-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.guidance-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    background: var(--bg-surface-elevated);
    border-left: 4px solid var(--brand-primary);
}

.guidance-item.critical {
    border-left-color: var(--status-critical);
    background: rgba(239, 68, 68, 0.06);
}

.guidance-item.warning {
    border-left-color: var(--status-warning);
    background: rgba(245, 158, 11, 0.06);
}

.guidance-item.healthy {
    border-left-color: var(--status-healthy);
    background: rgba(16, 185, 129, 0.06);
}

.guidance-text h4 {
    font-size: 0.925rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.2rem;
}

.guidance-text p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.guidance-action-btn {
    align-self: center;
    flex-shrink: 0;
    padding: 0.45rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    transition: all 0.2s ease;
}

.guidance-action-btn:hover {
    background: var(--brand-primary);
}

/* Tables & Data Grids */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

.data-table th {
    background: var(--bg-surface-elevated);
    padding: 0.85rem 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.data-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
}

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

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Log Badges */
.badge-level {
    display: inline-flex;
    padding: 0.2rem 0.55rem;
    font-size: 0.725rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-level.EMERGENCY,
.badge-level.ALERT,
.badge-level.CRITICAL,
.badge-level.ERROR,
.badge-level.FATAL {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-level.WARNING {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-level.NOTICE,
.badge-level.INFO {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-level.DEBUG {
    background: rgba(148, 163, 184, 0.15);
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

/* Interactive Forms & Controls */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.form-input, .form-select {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: #fff;
    padding: 0.55rem 0.9rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.form-input:focus, .form-select:focus {
    border-color: var(--brand-primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--brand-primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--brand-primary-hover);
    box-shadow: var(--brand-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #fff;
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.775rem;
}

/* Terminal Console View */
.terminal-window {
    background: #06090f;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.terminal-header {
    background: #0e1422;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.terminal-dots {
    display: flex;
    gap: 6px;
}
.terminal-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
}
.terminal-dot.red { background: #ef4444; }
.terminal-dot.yellow { background: #f59e0b; }
.terminal-dot.green { background: #10b981; }

.terminal-body {
    padding: 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.825rem;
    line-height: 1.6;
    height: 520px;
    overflow-y: auto;
    color: #e2e8f0;
}

.terminal-line {
    word-break: break-all;
    white-space: pre-wrap;
    padding: 0.15rem 0;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.terminal-line.error {
    color: #f87171;
}

.terminal-line.warning {
    color: #fbbf24;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    padding: 1.75rem;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    position: relative;
}

/* Alert banners */
.alert {
    padding: 0.9rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
}
