:root {
    --red: #e5231f;
    --red-dark: #c91e1b;
    --blue: #168bd2;
    --text: #172235;
    --muted: #6f7d90;
    --line: #e7ebf0;
    --bg: #f7f9fb;
    --success: #198754;
    --danger: #c62828;
    --warning: #c77700;
    --white: #ffffff;
    --shadow: 0 10px 30px rgba(25, 42, 70, .08);
}

* {
    box-sizing: border-box;
}

html {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
}

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

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    color: var(--red);
    font-weight: 800;
    font-size: 28px;
    letter-spacing: -1px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-chip {
    font-size: 14px;
    color: var(--muted);
}

.content {
    max-width: 1180px;
    margin: 0 auto;
    padding: 30px 20px 60px;
}

.auth-wrap {
    max-width: 520px;
    margin: 40px auto;
    padding: 0 18px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 24px;
}

.auth-brand .brand {
    font-size: 42px;
}

.card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 24px;
}

h1, h2, h3 {
    margin-top: 0;
}

.page-title {
    margin-bottom: 20px;
}

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

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

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

.form-group.full {
    grid-column: 1 / -1;
}

label {
    font-weight: 650;
    font-size: 14px;
}

input,
select {
    width: 100%;
    border: 1px solid #d8dee7;
    border-radius: 10px;
    min-height: 46px;
    padding: 10px 12px;
    outline: none;
    background: #fff;
}

input:focus,
select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(22, 139, 210, .12);
}

.btn {
    border: 0;
    border-radius: 10px;
    min-height: 44px;
    padding: 11px 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.btn-primary {
    background: var(--red);
    color: #fff;
}

.btn-primary:hover {
    background: var(--red-dark);
}

.btn-secondary {
    background: #eef6fb;
    color: var(--blue);
}

.btn-outline {
    border: 1px solid #cfd7e2;
    color: var(--text);
    background: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-block {
    width: 100%;
}

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

.alert {
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
}

.alert-danger {
    background: #fff0f0;
    color: #8e1d1d;
    border: 1px solid #ffd3d3;
}

.alert-success {
    background: #edf9f2;
    color: #176d41;
    border: 1px solid #cfeedd;
}

.error {
    color: var(--danger);
    font-size: 13px;
}

.auth-links {
    margin-top: 18px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.admin-layout {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    min-height: calc(100vh - 72px);
}

.sidebar {
    background: #fff;
    border-right: 1px solid var(--line);
    padding: 24px 14px;
}

.sidebar a {
    display: block;
    padding: 12px 14px;
    border-radius: 10px;
    color: var(--text);
    margin-bottom: 7px;
    font-weight: 650;
}

.sidebar a.active {
    color: var(--red);
    background: #fff0ef;
}

.admin-main {
    padding: 28px;
    min-width: 0;
}

.table-wrap {
    overflow-x: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 850px;
}

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

th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    background: #fbfcfd;
}

.filters {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 10px;
    margin-bottom: 16px;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 700;
}

.badge-success {
    background: #eaf8ef;
    color: #167244;
}

.badge-danger {
    background: #fff0f0;
    color: #a62525;
}

.badge-warning {
    background: #fff6e8;
    color: #9b6500;
}

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
}

.switch-row:last-child {
    border-bottom: 0;
}

.checkbox {
    width: 20px;
    height: 20px;
}

.audit-item {
    border-top: 1px solid var(--line);
    padding: 12px 0;
    font-size: 14px;
}

.mobile-heading {
    text-align: center;
    margin-bottom: 20px;
}

.mobile-heading .brand {
    margin-bottom: 14px;
}

.logout-form {
    margin: 0;
}

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

    .brand {
        font-size: 24px;
    }

    .user-chip {
        display: none;
    }

    .content {
        padding: 18px 14px 40px;
    }

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

    .form-group.full {
        grid-column: auto;
    }

    .admin-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: 10px;
    }

    .sidebar a {
        white-space: nowrap;
        margin: 0;
    }

    .admin-main {
        padding: 18px 14px 40px;
    }

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

    .auth-wrap {
        margin-top: 20px;
    }

    .auth-brand .brand {
        font-size: 36px;
    }

    .card {
        padding: 18px;
        border-radius: 14px;
    }
}
