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

:root {
    --bg: #0f1117;
    --bg-card: #1a1d29;
    --bg-sidebar: #141620;
    --bg-input: #252836;
    --border: #2d3045;
    --text: #e4e6f0;
    --text-muted: #8b8fa3;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.1);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.1);
    --orange: #f59e0b;
    --orange-bg: rgba(245, 158, 11, 0.1);
    --blue: #3b82f6;
    --blue-bg: rgba(59, 130, 246, 0.1);
    --purple: #a855f7;
    --purple-bg: rgba(168, 85, 247, 0.1);
    --cyan: #06b6d4;
    --cyan-bg: rgba(6, 182, 212, 0.1);
    --yellow: #eab308;
    --yellow-bg: rgba(234, 179, 8, 0.1);
    --radius: 10px;
    --radius-sm: 6px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

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);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-muted);
    transition: all 0.2s;
    gap: 10px;
    font-size: 14px;
}

.nav-item:hover {
    color: var(--text);
    background: rgba(99, 102, 241, 0.08);
}

.nav-item.active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.12);
    border-right: 3px solid var(--primary);
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px 0;
    border-top: 1px solid var(--border);
}

.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 24px;
    min-height: 100vh;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 700;
}

.refresh-hint {
    color: var(--text-muted);
    font-size: 12px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.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: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 32px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
}

.stat-value small {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.stat-blue { border-left: 3px solid var(--blue); }
.stat-green { border-left: 3px solid var(--green); }
.stat-orange { border-left: 3px solid var(--orange); }
.stat-red { border-left: 3px solid var(--red); }
.stat-purple { border-left: 3px solid var(--purple); }
.stat-cyan { border-left: 3px solid var(--cyan); }
.stat-yellow { border-left: 3px solid var(--yellow); }

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

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* Grid */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 16px;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

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

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(45, 48, 69, 0.5);
    font-size: 13px;
}

.data-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.04);
}

.info-table {
    width: 100%;
}

.info-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(45, 48, 69, 0.3);
}

.info-table td:first-child {
    color: var(--text-muted);
    width: 40%;
}

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

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

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

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

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

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

.btn-green:hover { background: #16a34a; color: white; }

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

.btn-red:hover { background: #dc2626; color: white; }

.btn-yellow {
    background: var(--yellow);
    color: #000;
}

.btn-yellow:hover { background: #ca8a04; color: #000; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-block { display: block; width: 100%; }

/* Forms */
.form-group {
    margin-bottom: 16px;
}

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

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="email"],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.2s;
    outline: none;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
}

.input-full { width: 100%; }
.input-sm { width: auto; min-width: 120px; padding: 6px 10px; font-size: 12px; }
.input-xs { padding: 3px 6px; font-size: 11px; }

textarea {
    resize: vertical;
    font-family: monospace;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-error {
    background: var(--red-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--red);
}

.alert-success {
    background: var(--green-bg);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--green);
}

.alert-warning {
    background: var(--orange-bg);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--orange);
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-online {
    background: var(--green-bg);
    color: var(--green);
}

.status-offline {
    background: var(--red-bg);
    color: var(--red);
}

.status-maintenance {
    background: var(--yellow-bg);
    color: var(--yellow);
}

/* Text */
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-muted { color: var(--text-muted); }
.text-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-bar form {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

/* Action Buttons */
.action-btns {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 0 4px;
}

.page-info {
    color: var(--text-muted);
    font-size: 13px;
}

/* Chart */
.chart-bar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 160px;
    padding: 10px 0;
}

.chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.chart-bar-inner {
    width: 100%;
    max-width: 50px;
    background: linear-gradient(180deg, var(--primary), var(--primary-hover));
    border-radius: 4px 4px 0 0;
    position: relative;
    min-height: 4px;
    transition: height 0.3s;
}

.chart-bar-inner:hover {
    opacity: 0.85;
}

.chart-tooltip {
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--text);
    white-space: nowrap;
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 3px;
    display: none;
}

.chart-bar-inner:hover .chart-tooltip {
    display: block;
}

.chart-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Code Block */
.code-block {
    background: var(--bg-input);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.code-block code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    color: var(--green);
    word-break: break-all;
}

.code-block p {
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

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

.login-box {
    width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 32px;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 24px;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
}

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

.install-box {
    width: 440px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 32px;
    text-align: center;
}

.install-box h1 {
    font-size: 22px;
    margin-bottom: 20px;
}

.install-info p {
    padding: 6px 0;
    font-size: 14px;
    text-align: left;
}

.install-creds {
    background: var(--bg-input);
    padding: 16px;
    border-radius: var(--radius-sm);
    margin: 20px 0;
    text-align: left;
}

.install-creds h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.install-creds p {
    font-size: 14px;
    padding: 2px 0;
}

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