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

:root {
    --bg:          #0f1117;
    --bg2:         #1a1d27;
    --bg3:         #22263a;
    --border:      #2e3250;
    --accent:      #4f8ef7;
    --accent-dim:  #2a4a8a;
    --green:       #22c55e;
    --red:         #ef4444;
    --yellow:      #f59e0b;
    --text:        #e2e8f0;
    --text-muted:  #8892a4;
    --sidebar-w:   230px;
    --topbar-h:    56px;
    --radius:      8px;
    --shadow:      0 2px 12px rgba(0,0,0,.45);
}

html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

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

/* ── Layout ───────────────────────────────────────────────────────────────── */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 100;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 16px; font-weight: 700; letter-spacing: .3px;
}
.brand-icon { font-size: 22px; }

.nav-links { list-style: none; padding: 12px 0; flex: 1; }
.nav-links li { margin: 2px 8px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 14px; border-radius: var(--radius);
    color: var(--text-muted); font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

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

.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex; flex-direction: column;
}

.topbar {
    position: sticky; top: 0; z-index: 50;
    height: var(--topbar-h);
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-clock { color: var(--text-muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.status-badge { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px; background: var(--bg3); }
.status-badge.online  { color: var(--green); }
.status-badge.offline { color: var(--red); }
.status-badge.degraded{ color: var(--yellow); }

.page-body { padding: 28px; flex: 1; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
    padding: 12px 18px; border-radius: var(--radius);
    margin-bottom: 20px; font-weight: 500;
    transition: opacity .5s;
}
.alert-success { background: rgba(34,197,94,.15); border: 1px solid rgba(34,197,94,.4); color: var(--green); }
.alert-error   { background: rgba(239,68,68,.15);  border: 1px solid rgba(239,68,68,.4);  color: var(--red); }

/* ── Stat Cards ───────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px 22px;
}
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-value.green  { color: var(--green); }
.stat-value.accent { color: var(--accent); }
.stat-value.yellow { color: var(--yellow); }
.stat-value.red    { color: var(--red); }

/* ── Cards / Panels ───────────────────────────────────────────────────────── */
.card {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 24px;
    box-shadow: var(--shadow);
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 22px; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 22px; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left; padding: 10px 14px;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px;
    color: var(--text-muted); border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }
tbody td { padding: 11px 14px; vertical-align: middle; }
.empty-row td { text-align: center; color: var(--text-muted); padding: 32px; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-green  { background: rgba(34,197,94,.15);  color: var(--green); }
.badge-red    { background: rgba(239,68,68,.15);   color: var(--red); }
.badge-yellow { background: rgba(245,158,11,.15);  color: var(--yellow); }
.badge-blue   { background: rgba(79,142,247,.15);  color: var(--accent); }
.badge-gray   { background: rgba(136,146,164,.15); color: var(--text-muted); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: var(--radius);
    font-size: 13px; font-weight: 600; cursor: pointer;
    border: none; transition: opacity .15s, transform .1s;
    white-space: nowrap;
}
.btn:hover { opacity: .85; text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--accent);      color: #fff; }
.btn-success  { background: var(--green);        color: #fff; }
.btn-danger   { background: var(--red);          color: #fff; }
.btn-warning  { background: var(--yellow);       color: #000; }
.btn-ghost    { background: var(--bg3);          color: var(--text); border: 1px solid var(--border); }
.btn-sm       { padding: 5px 11px; font-size: 12px; }
.btn-icon     { padding: 6px 10px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
input[type=text], input[type=url], input[type=password], input[type=number], select, textarea {
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text);
    padding: 9px 12px; font-size: 14px; width: 100%;
    transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79,142,247,.2);
}
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check label { text-transform: none; font-size: 14px; color: var(--text); cursor: pointer; }
.field-error { color: var(--red); font-size: 12px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.65); z-index: 200;
    align-items: flex-start; justify-content: center;
    overflow-y: auto; padding: 40px 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 12px; width: 100%; max-width: 560px;
    box-shadow: 0 8px 40px rgba(0,0,0,.6);
    animation: slideUp .2s ease;
    margin: auto 0;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Search / Filter bar ──────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.search-box { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search-box input { padding-left: 34px; }
.search-box::before { content: '🔍'; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 13px; pointer-events: none; }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 6px; margin-top: 16px; justify-content: flex-end; }
.page-btn {
    padding: 5px 12px; border-radius: var(--radius);
    background: var(--bg3); border: 1px solid var(--border);
    color: var(--text); cursor: pointer; font-size: 13px;
}
.page-btn:hover { background: var(--accent-dim); border-color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: default; }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.mono { font-family: 'Cascadia Code', 'Consolas', monospace; font-size: 13px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.dot-green  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-red    { background: var(--red); }
.dot-yellow { background: var(--yellow); }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px; color: var(--text-muted); margin-bottom: 14px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
