:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --text: #172033;
    --muted: #697386;
    --line: #e6e9ef;
    --primary: #5b4df5;
    --primary-dark: #493be0;
    --success: #198754;
    --danger: #b42318;
    --sidebar: #111827;
    --sidebar-muted: #9ca3af;
    --radius: 18px;
    --shadow: 0 18px 50px rgba(23, 32, 51, .08);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

body {
    min-height: 100vh;
}

a {
    color: inherit;
}

.auth-page {
    display: grid;
    place-items: center;
    padding: 32px;
    background:
        radial-gradient(circle at top left, rgba(91,77,245,.12), transparent 38%),
        var(--bg);
}

.auth-shell {
    width: min(980px, 100%);
    min-height: 620px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 28px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.auth-shell.wide {
    width: min(1080px, 100%);
}

.brand-panel {
    padding: 64px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: linear-gradient(145deg, #161a30 0%, #24205d 100%);
    color: white;
}

.brand-mark {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: white;
    color: var(--primary);
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 28px;
}

.brand-mark.small {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    font-size: 20px;
    margin: 0;
}

.eyebrow {
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: 12px;
    font-weight: 800;
    color: #8b8df7;
}

.brand-panel .eyebrow {
    color: #b8b9ff;
}

.brand-panel h1,
.auth-card h2,
.topbar h1,
.panel h2 {
    margin: 0;
}

.brand-panel h1 {
    font-size: clamp(42px, 6vw, 68px);
    letter-spacing: -.04em;
}

.brand-copy {
    max-width: 420px;
    margin: 18px 0 0;
    font-size: 18px;
    line-height: 1.6;
    color: rgba(255,255,255,.74);
}

.auth-card {
    padding: 64px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 28px;
}

.install-card {
    justify-content: flex-start;
    overflow-y: auto;
}

.auth-card h2 {
    font-size: 32px;
    letter-spacing: -.025em;
}

.muted {
    color: var(--muted);
    line-height: 1.6;
    margin: 8px 0 0;
}

.form-stack {
    display: grid;
    gap: 18px;
}

.form-stack h3 {
    margin: 10px 0 -4px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

label {
    display: grid;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
}

input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid #d9dee8;
    border-radius: 11px;
    font: inherit;
    color: var(--text);
    background: white;
    outline: none;
    transition: .18s ease;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(91,77,245,.12);
}

.primary-button {
    border: 0;
    border-radius: 12px;
    padding: 13px 18px;
    background: var(--primary);
    color: white;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: .18s ease;
}

.primary-button:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.primary-button:disabled {
    opacity: .48;
    cursor: not-allowed;
}

.alert {
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.alert.error {
    background: #fff1f0;
    color: var(--danger);
    border: 1px solid #ffd2cc;
}

.alert.success {
    background: #edf9f2;
    color: var(--success);
    border: 1px solid #c9efd9;
}

.alert ul {
    margin-bottom: 0;
}

.app-page {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: var(--sidebar);
    color: white;
    padding: 26px 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.sidebar-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 38px;
}

.sidebar-brand > div:last-child {
    display: grid;
}

.sidebar-brand span {
    color: var(--sidebar-muted);
    font-size: 12px;
    margin-top: 3px;
}

.sidebar nav {
    display: grid;
    gap: 6px;
}

.sidebar nav a,
.logout-link {
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 10px;
    color: #d1d5db;
    font-weight: 650;
}

.sidebar nav a.active {
    background: rgba(255,255,255,.1);
    color: white;
}

.sidebar nav a.disabled {
    opacity: .45;
    pointer-events: none;
}

.logout-link {
    margin-top: auto;
    color: #c4c9d2;
}

.main-content {
    padding: 42px;
    max-width: 1500px;
    width: 100%;
    margin: 0 auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
    margin-bottom: 30px;
}

.topbar h1 {
    font-size: clamp(30px, 4vw, 46px);
    letter-spacing: -.04em;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 28px rgba(23,32,51,.04);
}

.stat-card {
    padding: 22px;
    display: grid;
    gap: 6px;
}

.stat-card span {
    color: var(--muted);
    font-size: 14px;
}

.stat-card strong {
    font-size: 30px;
}

.status-ok {
    color: var(--success);
}

.panel {
    padding: 26px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.panel h2 {
    font-size: 26px;
}

.empty-state {
    min-height: 280px;
    display: grid;
    place-items: center;
    align-content: center;
    text-align: center;
    border: 1px dashed #d6dbe5;
    border-radius: 14px;
    padding: 30px;
}

.empty-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: #f0efff;
    color: var(--primary);
    font-size: 28px;
    margin-bottom: 14px;
}

.empty-state h3 {
    margin: 0;
}

.empty-state p {
    color: var(--muted);
    margin-bottom: 0;
}

.event-list {
    display: grid;
}

.event-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0;
    border-top: 1px solid var(--line);
}

.event-row:first-child {
    border-top: 0;
}

.event-row > div {
    display: grid;
    gap: 4px;
}

.event-row span {
    color: var(--muted);
    font-size: 14px;
}

@media (max-width: 820px) {
    .auth-page {
        padding: 16px;
    }

    .auth-shell,
    .auth-shell.wide {
        grid-template-columns: 1fr;
    }

    .brand-panel {
        padding: 40px 30px;
    }

    .brand-panel h1 {
        font-size: 44px;
    }

    .auth-card {
        padding: 38px 30px;
    }

    .app-page {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;
        padding: 16px;
    }

    .sidebar nav,
    .logout-link {
        display: none;
    }

    .sidebar-brand {
        margin: 0;
    }

    .main-content {
        padding: 24px 16px;
    }

    .topbar {
        flex-direction: column;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }
}
