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

:root {
    --bg:           #0e0e10;
    --surface:      #1a1a1f;
    --surface2:     #24242b;
    --border:       #2e2e38;
    --accent:       #3ecf8e;
    --accent-dim:   #2ba870;
    --text:         #e8e8f0;
    --text-muted:   #7a7a90;
    --green:        #4ade80;
    --yellow:       #facc15;
    --red:          #f87171;
    --sidebar-w:    220px;
    --header-h:     52px;
}

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
}

/* ── App layout ── */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: #141418;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 50;
}

.sidebar-brand {
    height: var(--header-h);
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand-icon {
    flex-shrink: 0;
    color: var(--accent);
    opacity: .9;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
}

.sidebar-title {
    display: block;
    font-weight: 700;
    font-size: 15px;
    background: linear-gradient(135deg, var(--accent), #a8f0d0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.sidebar-sub {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 2px;
}

.nav-list {
    list-style: none;
    padding: 8px 6px;
    flex: 1;
    overflow-y: auto;
}

.nav-list::-webkit-scrollbar { width: 3px; }
.nav-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    border: 1px solid transparent;
    transition: background 0.15s, color 0.15s;
    margin-bottom: 2px;
}

.nav-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon { opacity: 1; }

.nav-item:hover {
    background: var(--surface2);
    color: var(--text);
}

.nav-item.active {
    background: var(--surface2);
    border-color: var(--border);
    color: var(--text);
}

.sidebar-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.sidebar-version {
    font-size: 10px;
    color: var(--text-muted);
    opacity: .45;
    letter-spacing: .04em;
}

.sidebar-user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-user {
    font-size: 13px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-btn {
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: none;
    flex-shrink: 0;
    transition: color 0.15s;
}

.logout-btn:hover { color: var(--red); }

/* ── Main content ── */

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

.main-content--full {
    margin-left: 0;
    width: 100%;
}

.page-header {
    height: var(--header-h);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
}

.page-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

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

.page-error {
    color: var(--red);
    padding: 20px;
}

/* ── Login ── */

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

.login-wrap {
    width: 100%;
    max-width: 380px;
    padding: 16px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px;
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.login-brand .sidebar-title {
    font-size: 22px;
    display: block;
    margin-bottom: 2px;
}

.login-error {
    background: #2a0a0a;
    border: 1px solid #4a1a1a;
    color: var(--red);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 18px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Forms ── */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    padding: 9px 12px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
    width: 100%;
}

.form-group select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a7a90' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

/* ── Buttons ── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    text-decoration: none;
    -webkit-appearance: none;
    appearance: none;
}

.btn-primary {
    background: var(--accent);
    color: #0e0e10;
    border-color: var(--accent);
}

.btn-primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); }

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border-color: var(--border);
}

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

.btn-danger {
    background: transparent;
    color: var(--red);
    border-color: #4a1a1a;
}

.btn-danger:hover { background: #2a0a0a; }

.btn-full { width: 100%; }

.btn-sm {
    padding: 5px 12px;
    font-size: 13px;
}

/* ── Cards ── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 20px;
}

.card-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* ── Tables ── */

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: fixed;
}

td, th {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

thead th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }

/* ── Badges ── */

.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    padding: 2px 7px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-running { background: #0a1f15; color: var(--accent);  border: 1px solid #1a4030; }
.badge-stopped { background: #2a0a0a; color: var(--red);     border: 1px solid #4a1a1a; }
.badge-warning  { background: #2a2000; color: var(--yellow); border: 1px solid #4a3800; }
.badge-ok       { background: #0a1f15; color: var(--green);  border: 1px solid #1a4030; }
.badge-admin    { background: #0a1f15; color: var(--accent);  border: 1px solid #1a4030; }
.badge-user     { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Utility ── */

.text-muted { color: var(--text-muted); font-size: 14px; }
.text-ok    { color: var(--green); }
.text-warn  { color: var(--yellow); }
.text-crit  { color: var(--red); }
.text-accent { color: var(--accent); }

.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.flex          { display: flex; }
.flex-center   { display: flex; align-items: center; }
.flex-between  { display: flex; align-items: center; justify-content: space-between; }
.flex-gap-8    { display: flex; gap: 8px; }
.flex-gap-12   { display: flex; gap: 12px; }

/* ── Status panel ── */

.status-panel {
    width: 260px;
    flex-shrink: 0;
    background: #13131a;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.status-panel-header {
    height: var(--header-h);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: #13131a;
    border-bottom: 1px solid var(--border);
}

.status-panel-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.status-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.status-panel-body::-webkit-scrollbar { width: 3px; }
.status-panel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.status-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
}

.status-block-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    margin-bottom: 4px;
}

.stat-name { color: var(--text-muted); }

.stat-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-val.ok   { color: var(--green); }
.stat-val.warn { color: var(--yellow); }
.stat-val.crit { color: var(--red); }
.stat-val.accent { color: var(--accent); }

.bar-wrap {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--accent);
    transition: width 0.6s ease;
}

.bar-fill.ok   { background: var(--green); }
.bar-fill.warn { background: var(--yellow); }
.bar-fill.crit { background: var(--red); }

.status-placeholder {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
}

.status-updated {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    padding: 4px 0 8px;
}

/* ── Icon button ── */

.icon-btn {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    font-size: 13px;
}

.icon-btn:hover { background: var(--surface2); color: var(--text); }

/* ── Status toggle (mobile) ── */

.status-toggle-btn { margin-left: auto; display: none; }
#status-close-btn  { display: none; }

.status-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

.status-overlay.visible { display: block; }

/* ── Burger (mobile) ── */

.burger-btn {
    display: none;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.burger-btn:hover { background: var(--surface2); color: var(--text); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 49;
}

.sidebar-overlay.visible { display: block; }

/* ── Modal ── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 340px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.modal-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
}

.modal-body {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ── Mobile ── */

@media (max-width: 768px) {
    .burger-btn        { display: flex; }
    .status-toggle-btn { display: flex; }
    #status-close-btn  { display: flex; }

    .sidebar {
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: 260px;
    }

    .sidebar.open { transform: translateX(0); }

    .status-panel {
        position: fixed;
        right: 0; top: 0; bottom: 0;
        z-index: 100;
        transform: translateX(100%);
        transition: transform 0.25s ease;
        width: 280px;
    }

    .status-panel.open { transform: translateX(0); }

    .main-content { margin-left: 0; }
    .page-body { padding: 16px; }
}
