:root {
    --bg: #0c1018;
    --panel: #121928;
    --panel-2: #172033;
    --card: rgba(255, 255, 255, 0.055);
    --card-border: rgba(255, 255, 255, 0.12);
    --text: #eef4ff;
    --muted: #94a3b8;
    --accent: #71f6b6;
    --accent-2: #44c7ff;
    --danger: #ff6b7a;
    --warning: #ffd166;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
    --radius: 24px;
    --radius-sm: 14px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 10% 10%, rgba(68, 199, 255, 0.18), transparent 36%),
        radial-gradient(circle at 90% 0%, rgba(113, 246, 182, 0.14), transparent 34%),
        linear-gradient(135deg, #070a10 0%, #0c1018 55%, #101827 100%);
    min-height: 100vh;
}

a { color: inherit; }
code {
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.06);
    padding: 2px 6px;
    border-radius: 8px;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 305px;
    gap: 22px;
    padding: 22px;
}

.main-panel {
    border: 1px solid var(--card-border);
    background: rgba(12, 16, 24, 0.72);
    backdrop-filter: blur(18px);
    border-radius: 32px;
    padding: 28px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.side-menu {
    position: sticky;
    top: 22px;
    align-self: start;
    min-height: calc(100vh - 44px);
    border: 1px solid var(--card-border);
    background: rgba(18, 25, 40, 0.86);
    backdrop-filter: blur(18px);
    border-radius: 32px;
    padding: 22px;
    box-shadow: var(--shadow);
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 26px;
}
.brand-logo {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-weight: 900;
    letter-spacing: -0.05em;
    color: #071018;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 12px 30px rgba(68, 199, 255, 0.24);
}
.brand strong { display: block; font-size: 17px; }
.brand span { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; }

.side-menu nav {
    display: flex;
    flex-direction: column;
    gap: 9px;
}
.side-menu nav a {
    text-decoration: none;
    padding: 13px 14px;
    border-radius: 15px;
    color: #d8e4f7;
    border: 1px solid transparent;
    transition: .2s ease;
}
.side-menu nav a:hover,
.side-menu nav a.active {
    background: rgba(255,255,255,.075);
    border-color: rgba(255,255,255,.12);
}
.side-menu nav a.danger { color: #ffd6dc; }
.menu-note {
    margin-top: 24px;
    padding: 14px;
    border-radius: 18px;
    background: rgba(255,255,255,.06);
    color: var(--muted);
    line-height: 1.45;
    font-size: 13px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 24px;
}
.eyebrow {
    color: var(--accent);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: .12em;
    margin-bottom: 8px;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(30px, 3vw, 48px); letter-spacing: -0.055em; }
h2 { font-size: 22px; letter-spacing: -0.025em; margin-bottom: 10px; }
h3 { font-size: 20px; margin-bottom: 5px; }
.user-pill {
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 999px;
    color: #dce9f9;
    background: rgba(255,255,255,.055);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.stat-card, .card, .resource-card {
    border: 1px solid var(--card-border);
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 18px 45px rgba(0,0,0,.16);
}
.stat-card { padding: 20px; }
.stat-card span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.stat-card strong { font-size: 34px; letter-spacing: -0.045em; }

.card {
    padding: 22px;
    margin-bottom: 18px;
}
.narrow-card { max-width: 820px; }
.card-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 16px;
}
.muted-text { color: var(--muted); line-height: 1.55; }

.btn {
    border: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    min-height: 43px;
    padding: 11px 16px;
    border-radius: 14px;
    font-weight: 750;
    color: var(--text);
    transition: transform .16s ease, opacity .16s ease, background .16s ease;
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #061017; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn-secondary { background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.13); }
.btn-ghost { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); }
.btn-danger { background: rgba(255, 107, 122, .16); color: #ffd6dc; border: 1px solid rgba(255, 107, 122, .35); }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }

.form-stack, .form-grid { display: grid; gap: 16px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.form-grid button[type="submit"] { grid-column: 1 / -1; }
.export-form .button-row { grid-column: 1 / -1; }
label span, .snippet-label {
    display: block;
    margin-bottom: 8px;
    color: #d6e2f5;
    font-weight: 700;
    font-size: 14px;
}
input, select, textarea {
    width: 100%;
    border: 1px solid rgba(255,255,255,.13);
    background: rgba(255,255,255,.075);
    color: var(--text);
    border-radius: 15px;
    padding: 13px 14px;
    outline: none;
    font: inherit;
}
select option { color: #111827; }
textarea { min-height: 96px; resize: vertical; }
.code-textarea {
    min-height: 128px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #bafdd9;
    background: rgba(2, 6, 12, .52);
}
.code-textarea.compact { min-height: 86px; }

.alert {
    border-radius: 16px;
    padding: 13px 15px;
    margin: 0 0 18px;
    border: 1px solid rgba(255,255,255,.13);
}
.alert-danger { background: rgba(255, 107, 122, .14); color: #ffd3da; border-color: rgba(255, 107, 122, .35); }
.alert-success { background: rgba(113, 246, 182, .12); color: #c9ffe4; border-color: rgba(113, 246, 182, .28); }
.alert-warning { background: rgba(255, 209, 102, .13); color: #ffeab2; border-color: rgba(255, 209, 102, .34); }
.hint-box {
    margin-top: 12px;
    padding: 13px 15px;
    border-radius: 16px;
    color: #dbeafe;
    background: rgba(68, 199, 255, .08);
    border: 1px solid rgba(68, 199, 255, .18);
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 14px 12px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.09); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
td { color: #e6eefc; }
.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}
.badge.good { color: #071018; background: var(--accent); }
.badge.muted { color: #d8e4f7; background: rgba(255,255,255,.11); }

.bar-chart {
    height: 250px;
    display: grid;
    grid-template-columns: repeat(14, minmax(26px, 1fr));
    gap: 10px;
    align-items: end;
    padding-top: 16px;
}
.bar-item { height: 100%; display: grid; grid-template-rows: 1fr auto; gap: 8px; align-items: end; }
.bar {
    min-height: 4px;
    border-radius: 14px 14px 6px 6px;
    background: linear-gradient(180deg, var(--accent-2), var(--accent));
    position: relative;
    box-shadow: 0 10px 25px rgba(68, 199, 255, .18);
}
.bar span {
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--muted);
    font-size: 12px;
}
.bar-item small { color: var(--muted); text-align: center; font-size: 12px; }

.resource-list { display: grid; gap: 14px; }
.resource-card { padding: 18px; }
.resource-main {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}
.resource-main p { color: var(--muted); margin-bottom: 0; }
.resource-metrics { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; align-items: flex-start; }
.resource-metrics span {
    padding: 9px 11px;
    border-radius: 13px;
    background: rgba(255,255,255,.06);
    color: #dce9f9;
}
.status-on { color: var(--accent); }
.status-off { color: var(--warning); }
.resource-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.resource-actions form { display: inline; }
.empty-state {
    padding: 26px;
    text-align: center;
    border: 1px dashed rgba(255,255,255,.18);
    border-radius: var(--radius-sm);
    color: var(--muted);
}
.empty-state strong { color: var(--text); display: block; margin-bottom: 8px; }

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}
.login-card {
    width: min(100%, 460px);
    border: 1px solid var(--card-border);
    background: rgba(18, 25, 40, 0.78);
    backdrop-filter: blur(18px);
    border-radius: 32px;
    padding: 28px;
    box-shadow: var(--shadow);
}
.brand-login { margin-bottom: 24px; }
.login-card h1 { font-size: 36px; margin-bottom: 8px; }
.login-card p { color: var(--muted); line-height: 1.55; }
.login-help {
    margin-top: 18px;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.5;
}

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; padding: 14px; }
    .side-menu { position: static; min-height: auto; order: -1; border-radius: 24px; }
    .side-menu nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .menu-note { display: none; }
    .main-panel { padding: 20px; border-radius: 24px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 650px) {
    .topbar, .card-head, .resource-main { flex-direction: column; }
    .stats-grid, .form-grid, .side-menu nav { grid-template-columns: 1fr; }
    .stat-card strong { font-size: 28px; }
    .bar-chart { gap: 6px; overflow-x: auto; }
    .bar-item { min-width: 34px; }
    .btn { width: 100%; }
    .resource-actions { display: grid; grid-template-columns: 1fr; }
    .resource-actions form, .resource-actions button { width: 100%; }
}

.user-pill {
    display: inline-flex;
    flex-direction: column;
    gap: 3px;
    align-items: flex-end;
}
.user-pill b {
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
}
.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 850;
    border: 1px solid rgba(255,255,255,.13);
}
.role-admin { color: #071018; background: var(--accent); }
.role-moderator { color: #e8f8ff; background: rgba(68, 199, 255, .18); border-color: rgba(68, 199, 255, .34); }
.role-guest { color: #d8e4f7; background: rgba(255,255,255,.10); }
.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 280px;
}
.inline-form select,
.inline-form input {
    min-width: 150px;
}
.inline-form .btn {
    min-height: 40px;
    padding: 9px 12px;
}
@media (max-width: 650px) {
    .inline-form { min-width: 0; flex-direction: column; align-items: stretch; }
    .inline-form select,
    .inline-form input { min-width: 0; }
}
