* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f6f8;
    color: #1f2937;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 64px;
    background: #111827;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
}

.topbar strong {
    margin-right: 16px;
    letter-spacing: 1px;
}

.topbar a {
    color: #ffffff;
    margin-left: 18px;
    text-decoration: none;
    font-weight: 600;
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 28px auto;
    padding: 0 20px;
    flex: 1;
}

.cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.card, .panel {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

.card {
    padding: 22px;
}

.card span {
    display: block;
    color: #6b7280;
    margin-bottom: 8px;
    font-size: 14px;
}

.card strong {
    display: block;
    font-size: 32px;
}

.panel {
    padding: 22px;
}

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

h1 {
    margin: 0 0 6px;
    font-size: 26px;
}

p {
    margin: 0;
    color: #6b7280;
}

.filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    align-items: end;
    margin: 18px 0 22px;
    padding: 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
}

.filters label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
}

.filters input, .filters select {
    width: 100%;
    height: 40px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 14px;
    background: #ffffff;
}

.filter-actions {
    display: flex;
    gap: 8px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #111827;
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

.btn.primary {
    background: #111827;
    color: #ffffff;
    border-color: #111827;
}

.btn.secondary {
    background: #f9fafb;
}

.btn.current {
    background: #111827;
    color: #ffffff;
    border-color: #111827;
}

.btn.disabled {
    background: #f3f4f6;
    color: #9ca3af;
    border-color: #e5e7eb;
    cursor: not-allowed;
}

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

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

th, td {
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    padding: 13px 12px;
    vertical-align: top;
    font-size: 14px;
}

th {
    background: #f9fafb;
    color: #374151;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.empty {
    text-align: center;
    color: #6b7280;
    padding: 32px;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 18px;
    color: #6b7280;
}

.pagination-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pagination-info strong {
    color: #111827;
}

.pagination-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.site-footer {
    margin-top: 32px;
    padding: 20px;
    text-align: center;
    font-size: 13px;
    color: #888;
    border-top: 1px solid #e5e5e5;
    background: #fafafa;
}

.site-footer a {
    color: #007bff;
    text-decoration: none;
    font-weight: 700;
}

.site-footer a:hover {
    text-decoration: underline;
}

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border-radius: 18px;
    padding: 34px;
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.14);
}

.login-card .brand {
    font-weight: 800;
    letter-spacing: 1.5px;
    margin-bottom: 14px;
}

.login-card h1 {
    margin-bottom: 6px;
}

.subtitle {
    margin-bottom: 22px;
}

.login-card label {
    display: block;
    margin: 16px 0 6px;
    font-weight: 700;
    font-size: 14px;
}

.login-card input {
    width: 100%;
    height: 44px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 9px 11px;
    font-size: 15px;
}

.login-card button {
    width: 100%;
    margin-top: 22px;
    height: 46px;
    border: 0;
    border-radius: 10px;
    background: #111827;
    color: #ffffff;
    font-weight: 800;
    cursor: pointer;
}

.alert {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 11px 12px;
    margin: 14px 0;
    font-size: 14px;
}

@media (max-width: 1000px) {
    .cards, .filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .cards, .filters {
        grid-template-columns: 1fr;
    }

    .topbar, .panel-header, .pagination {
        flex-direction: column;
        align-items: flex-start;
    }

    .pagination-actions {
        justify-content: flex-start;
    }
}

.topbar-brand, .topbar-user, .topbar-nav {
    display: flex;
    align-items: center;
}

.topbar-nav {
    gap: 10px;
}

.topbar-nav a {
    margin-left: 0;
    padding: 8px 11px;
    border-radius: 10px;
    color: #e5e7eb;
}

.topbar-nav a.active,
.topbar-nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.alert.success {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.alert ul {
    margin: 8px 0 0;
    padding-left: 20px;
}

.user-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    align-items: end;
    margin-top: 18px;
    padding: 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
}

.user-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
}

.user-form input,
.user-form select {
    width: 100%;
    height: 40px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 14px;
    background: #ffffff;
}

.user-form input[type="checkbox"] {
    width: auto;
    height: auto;
}

.checkbox-line {
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.form-actions {
    display: flex;
    align-items: end;
}

.users-panel {
    margin-top: 22px;
}

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

.badge-admin {
    background: #e0e7ff;
    color: #3730a3;
}

.badge-user {
    background: #e5e7eb;
    color: #374151;
}

.status-ok {
    color: #166534;
    font-weight: 800;
}

.status-ko {
    color: #991b1b;
    font-weight: 800;
}

@media (max-width: 1000px) {
    .user-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .topbar-nav {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}

@media (max-width: 640px) {
    .user-form {
        grid-template-columns: 1fr;
    }
}
