:root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --ink: #17202a;
    --muted: #647182;
    --line: #dfe4ea;
    --brand: #0078a8;
    --brand-dark: #005f86;
    --brand-soft: #e7f5fb;
    --warn: #b45309;
    --warn-bg: #fff7ed;
    --danger: #b91c1c;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    letter-spacing: 0;
}

a {
    color: var(--brand-dark);
    text-decoration: none;
}

button,
.button {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    font: inherit;
    font-weight: 700;
}

.danger-button {
    border-color: #fecaca;
    color: var(--danger);
}

.danger-button:hover {
    background: #fef2f2;
}

.primary {
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    border-right: 1px solid var(--line);
    background: #fff;
    display: flex;
    flex-direction: column;
    padding: 22px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
}

.brand-logo {
    width: 42px;
    height: 42px;
    max-width: 42px;
    object-fit: contain;
    flex: 0 0 auto;
    display: block;
}

.nav {
    display: grid;
    gap: 6px;
    margin-top: 34px;
}

.nav a {
    border-radius: 7px;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    padding: 11px 12px;
    font-weight: 700;
}

.nav a.active,
.nav a:hover {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.nav span {
    background: var(--brand);
    border-radius: 999px;
    color: #fff;
    min-width: 24px;
    padding: 1px 7px;
    text-align: center;
}

.logout {
    margin-top: auto;
}

.logout button {
    width: 100%;
}

.shell {
    margin-left: 250px;
    min-height: 100vh;
    padding: 28px;
}

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

.eyebrow {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    margin: 0 0 5px;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 18px;
}

.user-pill {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    padding: 8px 13px;
    color: var(--muted);
    font-weight: 700;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat,
.panel,
.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.stat {
    min-height: 112px;
    padding: 18px;
}

.stat span {
    color: var(--muted);
    display: block;
    font-weight: 700;
    margin-bottom: 14px;
}

.stat strong {
    display: block;
    font-size: 26px;
}

.stat.danger strong {
    color: var(--danger);
}

.panel {
    padding: 18px;
}

.section-gap {
    margin-top: 18px;
}

.panel-head {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 13px 10px;
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

td small {
    color: var(--muted);
    display: block;
    margin-top: 4px;
}

.actions {
    text-align: right;
    white-space: nowrap;
}

.badge {
    background: #eef2f7;
    border-radius: 999px;
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    padding: 3px 10px;
    color: var(--muted);
    font-weight: 800;
}

.badge.warning {
    background: var(--warn-bg);
    color: var(--warn);
}

.form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form.single {
    grid-template-columns: 1fr;
}

label {
    display: grid;
    gap: 7px;
}

label span {
    color: var(--muted);
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    font: inherit;
    min-height: 42px;
    padding: 9px 11px;
}

textarea {
    resize: vertical;
}

.wide,
.form-actions {
    grid-column: 1 / -1;
}

.toggle {
    align-items: center;
    display: flex;
    gap: 10px;
}

.toggle input {
    width: 18px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 6px;
}

.inline-form {
    align-items: center;
    display: flex;
    gap: 8px;
}

.inline-form input {
    min-width: 120px;
}

.notification-list {
    display: grid;
    gap: 10px;
}

.notification {
    align-items: center;
    background: #fbfcfd;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 14px;
}

.notification.read {
    opacity: .58;
}

.notification p {
    margin: 5px 0;
    color: var(--muted);
}

.notification small {
    color: var(--muted);
}

.notification > span {
    color: var(--warn);
    font-weight: 800;
    white-space: nowrap;
}

.empty {
    color: var(--muted);
    padding: 18px 0;
    text-align: center;
}

.alert {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 7px;
    color: var(--danger);
    margin: 0 0 14px;
    padding: 11px 12px;
}

.hint {
    color: var(--muted);
    margin: -6px 0 0;
}

.permissions-box {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 0;
    padding: 14px;
}

.permissions-box legend {
    color: var(--muted);
    font-weight: 800;
    padding: 0 6px;
}

.permissions-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.checkbox-card {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    display: flex;
    gap: 10px;
    min-height: 44px;
    padding: 10px;
}

.checkbox-card input {
    min-height: auto;
    width: 18px;
}

.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(440px, 100%);
    padding: 28px;
}

.login-brand {
    margin-bottom: 22px;
    text-align: center;
    width: 100%;
    height: 135px;
    display: grid;
    place-items: center;
    overflow: hidden;
}

.login-brand .login-logo {
    width: 180px !important;
    height: 135px !important;
    max-width: 180px !important;
    max-height: 135px !important;
    object-fit: contain !important;
    display: block;
    margin: 0 auto;
}

@media (max-width: 520px) {
    .login-brand {
        height: 112px;
    }

    .login-brand .login-logo {
        width: 150px !important;
        height: 112px !important;
        max-width: 150px !important;
        max-height: 112px !important;
    }
}

.login-panel h1 {
    margin-bottom: 18px;
}

@media (max-width: 900px) {
    .sidebar {
        position: static;
        width: 100%;
        min-height: auto;
    }

    .nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-top: 18px;
    }

    .shell {
        margin-left: 0;
        padding: 18px;
    }

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

    .topbar,
    .panel-head,
    .notification {
        align-items: stretch;
        flex-direction: column;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}
