:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-sidebar: #141720;
    --bg-input: #232633;
    --border: #2a2d3a;
    --text: #e4e4e7;
    --text-muted: #9ca3af;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --success: #22c55e;
    --danger: #ef4444;
    --danger-hover: #f87171;
    --warning: #f59e0b;
    --info: #3b82f6;
    --radius: 8px;
}

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

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

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    position: fixed;
    top: 0;
    bottom: 0;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 0 1.5rem 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-brand svg {
    width: 24px;
    height: 24px;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: all 0.15s;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    color: var(--text);
    background: rgba(99, 102, 241, 0.1);
    border-right: 3px solid var(--primary);
}

.sidebar-footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.main {
    margin-left: 240px;
    flex: 1;
    padding: 2rem;
}

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.page-header p {
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Stat cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.stat-value.success { color: var(--success); }
.stat-value.info { color: var(--info); }
.stat-value.warning { color: var(--warning); }

/* Tables */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

tr:hover td {
    background: rgba(99, 102, 241, 0.04);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-info { background: rgba(59,130,246,0.15); color: var(--info); }

/* Tags */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    background: var(--bg-input);
    color: var(--text-muted);
    margin: 0.1rem;
}

.tag .remove-tag {
    cursor: pointer;
    opacity: 0.5;
    font-size: 0.85rem;
}

.tag .remove-tag:hover {
    opacity: 1;
    color: var(--danger);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover { opacity: 0.9; }

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

.btn-danger:hover { background: var(--danger-hover); }

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
}

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

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-group {
    display: flex;
    gap: 0.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s;
}

.form-control:focus {
    border-color: var(--primary);
}

.form-inline {
    display: flex;
    gap: 0.5rem;
    align-items: end;
}

/* Login page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 380px;
    max-width: 90vw;
}

.login-card h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.login-error {
    background: rgba(239,68,68,0.1);
    border: 1px solid var(--danger);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 1rem;
    color: var(--danger);
    font-size: 0.85rem;
}

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

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-success { background: rgba(34,197,94,0.1); border: 1px solid var(--success); color: var(--success); }
.alert-danger { background: rgba(239,68,68,0.1); border: 1px solid var(--danger); color: var(--danger); }
.alert-info { background: rgba(59,130,246,0.1); border: 1px solid var(--info); color: var(--info); }

/* Empty states */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 420px;
    max-width: 90vw;
}

.modal h2 {
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    .main {
        margin-left: 0;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Client status dot */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--text-muted); }

/* Data formatting */
.mono { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.85rem; }
