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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #111111;
    color: #e0e0e0;
    line-height: 1.6;
}

a { color: inherit; }

h1 { font-size: 1.6rem; font-weight: 600; margin-bottom: 1.5rem; color: #fff; }
h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.4rem; color: #fff; }

code { font-family: "SF Mono", Consolas, monospace; font-size: 0.8rem; color: #a5b4fc; }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th { text-align: left; padding: 0.5rem 0.75rem; color: #6b7280; border-bottom: 1px solid #2a2a2a; font-weight: 500; }
td { padding: 0.5rem 0.75rem; border-bottom: 1px solid #1e1e1e; }
tr:last-child td { border-bottom: none; }

.status-active   { color: #34d399; font-weight: 500; }
.status-inactive,
.status-failed   { color: #f87171; font-weight: 500; }
.status-unknown  { color: #6b7280; }

/* ── Sidebar layout ─────────────────────────────────────────────────── */
:root {
    --sidebar-width: 232px;
}

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: #161616;
    border-right: 1px solid #222222;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-brand {
    display: block;
    padding: 18px 20px 14px;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid #222222;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.sidebar-section-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #4a4a5a;
    padding: 16px 12px 6px;
    margin: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    border-radius: 6px;
    color: #9ca3af;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.sidebar-link svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.sidebar-link:hover { background: #1e1e1e; color: #e0e0e0; }
.sidebar-link.is-active {
    background: rgba(79, 110, 247, 0.12);
    color: #a5b4fc;
}
.sidebar-link.is-active svg { color: #4f6ef7; }

.sidebar-footer {
    padding: 10px;
    border-top: 1px solid #222222;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}
.sidebar-user:hover { background: #1e1e1e; }

.sidebar-user-avatar {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #1e1e2e;
    color: #a5b4fc;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.sidebar-user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}
.sidebar-user-name {
    font-size: 0.82rem;
    color: #e0e0e0;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-email {
    font-size: 0.7rem;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-signout {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.sidebar-signout svg { width: 15px; height: 15px; }
.sidebar-signout:hover { background: #1e1e1e; color: #f87171; }

/* ── Main content area ──────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* ── Cards on dashboard (legacy) ────────────────────────────────────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }

/* Login page (overrides for unauthenticated layout) */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-box {
    background: #1c1c1c;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 360px;
}
.login-box .brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.05em;
    margin-bottom: 1.75rem;
    text-align: center;
}
.login-box label {
    display: block;
    font-size: 0.8rem;
    color: #9ca3af;
    margin-bottom: 0.3rem;
    margin-top: 1rem;
}
.login-box input {
    width: 100%;
    background: #111111;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 0.9rem;
    padding: 0.55rem 0.75rem;
    outline: none;
}
.login-box input:focus { border-color: #4f6ef7; }
.login-box button {
    margin-top: 1.5rem;
    width: 100%;
    background: #4f6ef7;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.65rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.login-box button:hover { background: #3b5bdb; }
.flash-error {
    background: #3b1111;
    border: 1px solid #7f1d1d;
    border-radius: 6px;
    color: #fca5a5;
    font-size: 0.85rem;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
}

/* ── Autofill override ──────────────────────────────────────────────── */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px #111111 inset !important;
    -webkit-text-fill-color: #e0e0e0 !important;
    caret-color: #e0e0e0;
    transition: background-color 5000s ease-in-out 0s;
}

@media (max-width: 768px) {
    :root { --sidebar-width: 0px; }
    .sidebar { transform: translateX(-100%); }
}
