body {
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    background: #f3f5f9;
    color: #202124;
}

body.sidebar-open {
    overflow: hidden;
}

a {
    color: #1a73e8;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.page {
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 20px 40px;
}

.admin-shell {
    min-height: 100vh;
    display: flex;
    background: #f3f5f9;
}

.admin-page {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px 40px 264px;
    box-sizing: border-box;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 220px;
    height: 100vh;
    background: #ffffff;
    border-right: 2px solid #111111;
    padding: 24px 18px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    z-index: 1200;
}

.sidebar-nav {
    display: grid;
    gap: 10px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    appearance: none;
    padding: 12px 14px;
    border-radius: 12px;
    color: #202124;
    font-weight: 700;
    text-decoration: none;
    background: #f5f6f8;
    border: 2px solid #111111;
    text-align: left;
    cursor: pointer;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: #e8edf5;
    text-decoration: none;
}

.sidebar-link-danger {
    background: #d93025;
    color: #ffffff;
    border-color: #111111;
}

.sidebar-link-danger:hover {
    background: #b3261e;
    color: #ffffff;
}

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 12px;
    background: #111111;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    z-index: 1300;
}

.sidebar-overlay {
    display: none;
}

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

.brand {
    font-size: 28px;
    font-weight: 700;
}

.muted {
    color: #6f7278;
}

.card {
    background: #ffffff;
    border: 2px solid #111111;
    border-radius: 16px;
    padding: 22px;
    box-shadow: 0 8px 20px rgba(17, 24, 39, 0.06);
}

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

.flash {
    border-radius: 12px;
    padding: 14px 16px;
    font-weight: 600;
    margin-bottom: 18px;
}

.login-card .flash {
    text-align: center;
}

.flash-success {
    background: #e8f4ea;
    color: #1c6b2f;
    border: 1px solid #b9dec0;
}

.flash-error {
    background: #fdecea;
    color: #b9382d;
    border: 1px solid #efc0bb;
}

.form-grid {
    display: grid;
    gap: 14px;
}

.grid-two {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

input,
select,
textarea,
button {
    font: inherit;
}

input[type="text"],
input[type="password"],
input[type="date"],
textarea,
select {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 12px;
    border-radius: 10px;
    border: 1px solid #cfd5df;
    background: #ffffff;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

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

.checkbox-row input {
    width: 18px;
    height: 18px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 10px;
    border: 2px solid #111111;
    background: #1a73e8;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

.btn-secondary {
    background: #e8edf5;
    color: #202124;
}

.btn-danger {
    background: #d64545;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.btn-row-nowrap {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
}

.btn-row-nowrap .btn {
    white-space: nowrap;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.stat-box {
    background: #ffffff;
    border: 2px solid #111111;
    border-radius: 14px;
    padding: 18px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    border: 2px solid #111111;
    border-radius: 12px;
    background: #f5f6f8;
    font-size: 20px;
}

.stat-number {
    font-size: 28px;
    font-weight: 800;
    margin-top: 8px;
}

.table-wrap {
    overflow-x: auto;
    width: 100%;
}

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

th,
td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid #e6eaf0;
    vertical-align: top;
    white-space: nowrap;
}

th {
    color: #6f7278;
    font-size: 14px;
    white-space: nowrap;
}

.tag {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
}

.tag-active {
    background: #e8f4ea;
    color: #1c6b2f;
}

.tag-inactive {
    background: #fdecea;
    color: #b9382d;
}

.login-shell {
    max-width: 420px;
    margin: 60px auto;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
}

body.admin-login-page {
    min-height: 100vh;
}

body.admin-login-page .page {
    max-width: none;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    box-sizing: border-box;
    overflow-x: hidden;
}

body.admin-login-page .login-shell {
    width: min(100%, 390px);
    max-width: 390px;
    margin: 0;
}

.login-card {
    width: 100%;
    box-sizing: border-box;
    padding: 28px 24px 24px;
    overflow: hidden;
    max-width: 100%;
}

.login-logo-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 210px;
    margin-bottom: 16px;
    overflow: hidden;
}

.login-logo {
    max-width: 100%;
    max-height: 182px;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
}

.password-shell {
    position: relative;
}

.password-shell input {
    padding-right: 46px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: #202124;
    font-weight: 700;
    font-size: 10px;
    cursor: pointer;
    padding: 0;
}

.date-input {
    min-height: 46px;
    font-weight: 600;
    color: #202124;
    background: #ffffff;
}

.date-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.85;
}

.users-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px;
    gap: 12px;
    margin-bottom: 18px;
}

.users-toolbar-search,
.users-toolbar-filter {
    min-width: 0;
}

.users-toolbar-search input,
.users-toolbar-filter select {
    width: 100%;
}

.user-identity {
    display: grid;
    gap: 4px;
}

.user-name {
    font-size: 16px;
}

.user-value {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
}

.btn-login-dark {
    background: #111111;
    color: #ffffff;
}

.btn-login-dark:hover {
    background: #000000;
}

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

.page-header h2,
.page-header p {
    margin: 0;
}

.delete-modal {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1500;
}

.delete-modal.open {
    display: flex;
}

.delete-modal-card {
    width: min(100%, 420px);
    background: #ffffff;
    border: 2px solid #111111;
    border-radius: 16px;
    padding: 22px;
    box-shadow: 0 20px 40px rgba(17, 24, 39, 0.18);
}

@media (max-width: 900px) {
    .admin-page {
        padding: 88px 16px 28px;
    }

    .sidebar {
        width: min(280px, calc(100vw - 32px));
        padding: 84px 18px 24px;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

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

    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    body.sidebar-open .sidebar-toggle {
        left: calc(min(280px, 100vw - 32px) - 58px);
        background: #ffffff;
        color: #111111;
        border: 2px solid #111111;
        font-size: 32px;
        line-height: 1;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(17, 24, 39, 0.28);
        z-index: 1100;
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
    }
}

@media (max-width: 640px) {
    .admin-page {
        padding: 84px 12px 24px;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-header .btn-row {
        width: 100%;
    }

    .page-header .btn-row .btn {
        width: 100%;
    }

    .users-toolbar {
        grid-template-columns: 1fr;
    }

    th,
    td {
        padding: 10px 8px;
        font-size: 14px;
    }

    .users-table {
        min-width: 0;
    }

    .users-table thead {
        display: none;
    }

    .users-table,
    .users-table tbody,
    .users-table tr,
    .users-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    .users-table tbody {
        display: grid;
        gap: 14px;
    }

    .users-table tr {
        background: #ffffff;
        border: 2px solid #111111;
        border-radius: 16px;
        padding: 16px 14px;
        box-shadow: 0 10px 22px rgba(17, 24, 39, 0.06);
    }

    .users-table td {
        display: grid;
        grid-template-columns: 92px minmax(0, 1fr);
        align-items: center;
        gap: 12px;
        padding: 0 0 10px;
        margin-bottom: 10px;
        border-bottom: 0;
        white-space: normal;
    }

    .users-table td:last-child {
        margin-bottom: 0;
        padding-bottom: 0;
    }

    .users-table td::before {
        content: attr(data-label);
        display: block;
        line-height: 1.35;
        color: #6f7278;
        font-size: 12px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .users-table td[data-label="Username"] {
        grid-template-columns: 92px minmax(0, 1fr);
        padding-bottom: 12px;
        border-bottom: 1px solid #eceff3;
    }

    .users-table td[data-label="Username"]::before {
        margin-bottom: 0;
    }

    .users-table td[data-label="Name"],
    .users-table td[data-label="Role"],
    .users-table td[data-label="Status"],
    .users-table td[data-label="Expires"],
    .users-table td[data-label="Last Login"] {
        min-height: 34px;
    }

    .users-table td[data-label="Actions"] .btn-row-nowrap {
        flex-wrap: wrap;
        width: 100%;
    }

    .users-table td[data-label="Actions"] {
        grid-template-columns: 1fr;
        padding-top: 4px;
    }

    .users-table td[data-label="Actions"]::before {
        margin-bottom: 8px;
    }

    .users-table td[data-label="Status"] .tag {
        justify-self: start;
    }

    .users-table td[data-label="Actions"] .btn-row-nowrap .btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 120px;
    }
}

@media (max-width: 480px) {
    body.admin-login-page .page {
        padding: 14px 10px;
    }

    body.admin-login-page .login-shell {
        width: calc(100vw - 20px);
        max-width: 390px;
    }

    .login-card {
        padding: 22px 16px 18px;
    }

    .login-logo-wrap {
        height: 192px;
    }

    .login-logo {
        max-height: 166px;
    }
}
