/* === Reset & Base === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }
body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: #0f1117;
    color: #e1e4e8;
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }

/* === Variables === */
:root {
    --bg-primary: #0f1117;
    --bg-card: #161b22;
    --bg-card-hover: #1c2129;
    --bg-input: #1c2129;
    --border: #30363d;
    --text-primary: #e1e4e8;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-blue: #58a6ff;
    --accent-green: #3fb950;
    --accent-red: #f85149;
    --accent-yellow: #d29922;
    --accent-purple: #bc8cff;
    --accent-cyan: #39d2c0;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --sidebar-width: 220px;
}

.hidden { display: none !important; }

/* === Login === */
.login-screen {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px;
}
.login-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 40px; width: 100%; max-width: 380px;
    text-align: center;
}
.login-logo {
    font-size: 2rem; font-weight: 700; color: var(--accent-blue);
    margin-bottom: 4px;
}
.login-card h2 { color: var(--text-secondary); font-size: 1rem; font-weight: 400; margin-bottom: 28px; }
.login-card input {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--bg-input); color: var(--text-primary);
    font-size: 0.95rem; margin-bottom: 12px; outline: none; transition: border 0.2s;
}
.login-card input:focus { border-color: var(--accent-blue); }
.login-error { color: var(--accent-red); font-size: 0.85rem; margin-top: 12px; }

/* === Buttons === */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; border: none; border-radius: var(--radius); cursor: pointer;
    font-size: 0.9rem; font-weight: 500; transition: all 0.2s;
}
.btn-primary { background: var(--accent-blue); color: #fff; }
.btn-primary:hover { background: #4090e0; }
.btn-danger { background: var(--accent-red); color: #fff; }
.btn-danger:hover { background: #d63e3a; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-full { width: 100%; padding: 11px; }

/* === Dashboard Layout === */
.dashboard { display: flex; min-height: 100vh; }

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width); background: var(--bg-card);
    border-right: 1px solid var(--border); display: flex; flex-direction: column;
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 100;
}
.sidebar-logo {
    padding: 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: baseline; gap: 6px;
}
.logo-text { font-size: 1.4rem; font-weight: 700; color: var(--accent-blue); }
.logo-sub { font-size: 0.85rem; color: var(--text-muted); }
.nav-list { list-style: none; padding: 12px 0; flex: 1; }
.nav-link {
    display: flex; align-items: center; gap: 10px; padding: 10px 20px;
    color: var(--text-secondary); transition: all 0.15s; font-size: 0.95rem;
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.nav-link.active { color: var(--accent-blue); background: rgba(88,166,255,0.08); }
.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }

/* === Main Content === */
.main-content {
    margin-left: var(--sidebar-width); flex: 1; padding: 24px 28px;
    min-height: 100vh;
}

/* === Page Header === */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 1.5rem; font-weight: 600; }
.page-header p { color: var(--text-secondary); margin-top: 4px; }

/* === Grid === */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
}

/* === Cards === */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px;
    transition: border-color 0.2s;
}
.card:hover { border-color: #444c56; }
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.card-title { font-size: 1rem; font-weight: 600; }
.card-subtitle { color: var(--text-secondary); font-size: 0.8rem; }

/* === Metric Card === */
.metric-card { cursor: pointer; }
.metric-card .metric-label { color: var(--text-secondary); font-size: 0.8rem; margin-bottom: 4px; }
.metric-card .metric-value { font-size: 1.8rem; font-weight: 700; }
.metric-card .metric-sub { color: var(--text-muted); font-size: 0.8rem; margin-top: 2px; }

/* === Status Dot === */
.status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    display: inline-block; margin-right: 6px;
}
.status-dot.active { background: var(--accent-green); box-shadow: 0 0 6px var(--accent-green); }
.status-dot.inactive { background: var(--accent-red); box-shadow: 0 0 6px var(--accent-red); }
.status-dot.unknown { background: var(--accent-yellow); }

/* === Product Cards (Overview) === */
.product-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px; cursor: pointer;
    transition: all 0.2s;
}
.product-card:hover { border-color: var(--accent-blue); transform: translateY(-1px); }
.product-card .product-name {
    font-size: 1.1rem; font-weight: 600; margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}
.product-card .product-metrics { display: flex; flex-direction: column; gap: 6px; }
.product-card .product-metric {
    display: flex; justify-content: space-between; font-size: 0.9rem;
}
.product-card .product-metric .pm-label { color: var(--text-secondary); }
.product-card .product-metric .pm-value { font-weight: 600; }
.product-card .product-status { margin-top: 12px; font-size: 0.85rem; }

/* === Server Bar (Overview) === */
.server-bar {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 16px 20px;
    display: flex; gap: 24px; align-items: center; flex-wrap: wrap;
}
.server-stat { text-align: center; }
.server-stat .ss-label { color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; }
.server-stat .ss-value { font-size: 1.1rem; font-weight: 600; margin-top: 2px; }

/* === Progress Bar === */
.progress-bar {
    height: 6px; background: var(--bg-input); border-radius: 3px;
    overflow: hidden; margin-top: 4px;
}
.progress-bar .fill { height: 100%; border-radius: 3px; transition: width 0.5s; }
.progress-bar .fill.green { background: var(--accent-green); }
.progress-bar .fill.yellow { background: var(--accent-yellow); }
.progress-bar .fill.red { background: var(--accent-red); }

/* === Tables === */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th {
    text-align: left; padding: 10px 12px; color: var(--text-muted);
    font-weight: 500; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.data-table tr:hover td { background: var(--bg-card-hover); }

/* === Badge === */
.badge {
    display: inline-block; padding: 2px 8px; border-radius: 12px;
    font-size: 0.75rem; font-weight: 500;
}
.badge-green { background: rgba(63,185,80,0.15); color: var(--accent-green); }
.badge-red { background: rgba(248,81,73,0.15); color: var(--accent-red); }
.badge-yellow { background: rgba(210,153,34,0.15); color: var(--accent-yellow); }
.badge-blue { background: rgba(88,166,255,0.15); color: var(--accent-blue); }
.badge-purple { background: rgba(188,140,255,0.15); color: var(--accent-purple); }

/* === Section === */
.section { margin-bottom: 24px; }
.section-title {
    font-size: 1rem; font-weight: 600; margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}

/* === Chart Container === */
.chart-container {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px;
}
.chart-container svg { width: 100%; height: 200px; }

/* === Logs === */
.log-viewer {
    background: #0d1117; border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px;
    font-family: 'Menlo', 'Monaco', monospace; font-size: 0.8rem;
    color: var(--text-secondary); max-height: 400px; overflow-y: auto;
    white-space: pre-wrap; word-break: break-all; line-height: 1.5;
}

/* === Funnel === */
.funnel { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.funnel-step {
    flex: 1; text-align: center; padding: 12px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); min-width: 100px;
}
.funnel-step .fs-value { font-size: 1.3rem; font-weight: 700; }
.funnel-step .fs-label { color: var(--text-muted); font-size: 0.75rem; margin-top: 2px; }
.funnel-arrow { color: var(--text-muted); font-size: 1.2rem; }

/* === Confirm Dialog === */
.confirm-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.confirm-dialog {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 24px; max-width: 400px; width: 90%;
}
.confirm-dialog h3 { margin-bottom: 12px; }
.confirm-dialog p { color: var(--text-secondary); margin-bottom: 20px; }
.confirm-dialog .btn-group { display: flex; gap: 8px; justify-content: flex-end; }

/* === Loading === */
.loading {
    display: flex; align-items: center; justify-content: center;
    padding: 40px; color: var(--text-muted);
}
.spinner {
    width: 24px; height: 24px; border: 2px solid var(--border);
    border-top-color: var(--accent-blue); border-radius: 50%;
    animation: spin 0.8s linear infinite; margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Services List === */
.service-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.service-item:last-child { border-bottom: none; }
.service-info { display: flex; align-items: center; gap: 10px; }
.service-name { font-weight: 500; }
