@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Plus Jakarta Sans', 'Poppins', Arial, sans-serif;
    color: #1f2937;
    background:
        radial-gradient(1100px 600px at 10% -8%, #e7f0ff 0%, rgba(231,240,255,0) 60%),
        radial-gradient(900px 520px at 100% 0%, #f2eaff 0%, rgba(242,234,255,0) 58%),
        linear-gradient(145deg, #f8fbff 0%, #eef3ff 100%);
}

.content {
    max-width: 1240px;
    margin: 0 auto;
    padding: 20px;
    display: grid;
    gap: 18px;
}

h1 {
    margin: 10px 0 0;
    text-align: center;
    font-size: clamp(1.45rem, 3.2vw, 2.1rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 800;
    color: #3f434a;
}

h2,
h3 {
    margin: 0 0 14px;
    color: #1e293b;
    letter-spacing: -0.01em;
}

.page-warning {
    margin: 0;
    text-align: center;
    color: #6d28d9;
    font-weight: 700;
}

.success-message,
.error-message {
    max-width: 900px;
    margin: 0 auto;
    padding: 13px 14px;
    border-radius: 10px;
    text-align: center;
    font-weight: 600;
}

.success-message {
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    color: #166534;
    box-shadow: 0 8px 20px rgba(22, 101, 52, 0.12);
}

.error-message {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
    box-shadow: 0 8px 20px rgba(153, 27, 27, 0.12);
}

.user-info,
.client-form,
.table-container,
.stats-section {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.user-info {
    padding: 14px 16px;
    text-align: center;
    font-size: 0.98rem;
}

.online-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    background: #16a34a;
    margin-right: 8px;
}

.logout-link {
    margin-left: 12px;
    font-weight: 700;
    color: #dc2626;
    text-decoration: none;
    padding: 4px 9px;
    border-radius: 7px;
    transition: all 0.2s ease;
}

.logout-link:hover {
    color: #fff;
    background: #dc2626;
}

.client-form,
.stats-section {
    padding: 22px;
}

.client-form {
    border: 1px solid #dbe7ff;
    background:
        linear-gradient(180deg, rgba(239, 246, 255, 0.82) 0%, rgba(255, 255, 255, 0.97) 44%),
        #ffffff;
}

.client-form h3 {
    margin: 0 0 16px;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    font-weight: 800;
    letter-spacing: 0.01em;
    color: #1e3a8a;
}

.client-form form {
    display: grid;
    gap: 12px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-col-full {
    grid-column: 1 / -1;
}

form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #334155;
    font-size: 0.86rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

form input[type="text"],
form input[type="password"],
form select,
form textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1.5px solid #d6e2f6;
    border-radius: 10px;
    background: #f8fbff;
    font: inherit;
    color: #0f172a;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

form select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    padding-right: 42px;
    background-image:
        linear-gradient(45deg, transparent 50%, #64748b 50%),
        linear-gradient(135deg, #64748b 50%, transparent 50%),
        linear-gradient(to right, #dbe3f0, #dbe3f0);
    background-position:
        calc(100% - 18px) calc(50% - 3px),
        calc(100% - 12px) calc(50% - 3px),
        calc(100% - 34px) 50%;
    background-size: 6px 6px, 6px 6px, 1px 20px;
    background-repeat: no-repeat;
}

form select:hover {
    border-color: #b9cdef;
    background-color: #f1f6ff;
}

form input:focus,
form select:focus,
form textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
    background: #ffffff;
}

.btn-primary {
    margin-top: 12px;
    width: 100%;
    border: none;
    border-radius: 10px;
    padding: 12px 16px;
    font: inherit;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: #fff;
    background: linear-gradient(90deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.35);
}

.table-container {
    margin: 6px 0;
    padding: 10px;
    border: 1px solid #dbe7ff;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.08);
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 1260px;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 12px;
    text-align: center;
    font-size: 0.84rem;
    vertical-align: middle;
}

th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #f3f7ff;
    color: #334155;
    border-bottom: 1px solid #dbe5f5;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.72rem;
    font-weight: 800;
    box-shadow: inset 0 -1px 0 #dbe5f5;
}

tbody td {
    background: transparent;
    border-bottom: 1px solid #e8eef8;
}

tbody td:nth-child(1) {
    font-weight: 800;
    color: #1e3a8a;
    font-size: 0.8rem;
}

tbody td:nth-child(2) {
    font-weight: 700;
    color: #0f172a;
}

tbody td:nth-child(4) {
    color: #334155;
    font-weight: 600;
    white-space: nowrap;
}

tbody tr {
    background: #ffffff;
    transition: background-color 0.18s ease;
}

tbody tr:hover {
    background: #f7faff;
}

th:last-child,
td:last-child {
    min-width: 250px;
    text-align: center;
}

tr.current-user-row td {
    background: #edf5ff !important;
    border-bottom-color: #d6e5fb;
    font-weight: 700;
}

.status-online {
    color: #166534;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    font-size: 0.73rem;
}

.status-offline {
    color: #475569;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: #f1f5f9;
    border: 1px solid #dbe4f0;
    font-size: 0.73rem;
}

.role-badge {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.user-info .role-badge {
    margin-left: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    line-height: 1;
    background: #dc3545;
    color: #ffffff;
    box-shadow: none;
}

.role-Entreprise { background: linear-gradient(135deg, #dc3545, #c82333); }
.role-Dirigeant { background: linear-gradient(135deg, #fd7e14, #e55a00); }
.role-Lieutenant { background: linear-gradient(135deg, #6f42c1, #5a2d91); }
.role-Responsable { background: linear-gradient(135deg, #20c997, #198754); }
.role-Vendeur { background: linear-gradient(135deg, #0d6efd, #0b5ed7); }
.role-Livreur { background: linear-gradient(135deg, #198754, #146c43); }
.role-Guetteur { background: linear-gradient(135deg, #ffc107, #ffca2c); color: #111827; }
.role-Préparateur { background: linear-gradient(135deg, #6610f2, #520dc2); }
.role-Ravitailleur { background: linear-gradient(135deg, #d63384, #b02a5b); }
.role-Standartdiste { background: linear-gradient(135deg, #495057, #343a40); }
.role-badge.role-none { background: linear-gradient(135deg, #6c757d, #5a6268); }

.action-btns {
    display: grid;
    gap: 7px;
    justify-items: center;
}

.action-inline-form {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex-wrap: wrap;
    padding: 4px 0;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid #e2eaf8;
    border-radius: 11px;
    padding: 7px;
}

.action-inline-single {
    justify-content: flex-start;
}

.role-select,
.action-password-input {
    border-radius: 10px;
    min-height: 32px;
}

.role-select {
    min-width: 132px;
    max-width: 170px;
    border: 1.5px solid #c9d8f3;
    background-color: #f7faff;
    padding: 6px 34px 6px 10px;
    font: inherit;
    font-size: 0.72rem;
    color: #1e293b;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    background-image:
        linear-gradient(45deg, transparent 50%, #4b70b8 50%),
        linear-gradient(135deg, #4b70b8 50%, transparent 50%),
        linear-gradient(180deg, #f7faff 0%, #edf4ff 100%);
    background-position:
        calc(100% - 16px) calc(50% + 1px),
        calc(100% - 10px) calc(50% + 1px),
        0 0;
    background-size:
        6px 6px,
        6px 6px,
        100% 100%;
    background-repeat: no-repeat;
}

.action-password-input {
    border: 1px solid #d6e0f2;
    background: linear-gradient(180deg, #ffffff 0%, #f5f9ff 100%);
    padding: 6px 9px;
    font-size: 0.71rem;
    font-weight: 600;
    color: #1e293b;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    width: 122px;
}

.action-inline-form .custom-select.is-compact {
    width: 140px;
    max-width: 180px;
}

.action-inline-form .role-select:hover {
    border-color: #9bb5e8;
    background-image:
        linear-gradient(45deg, transparent 50%, #35589f 50%),
        linear-gradient(135deg, #35589f 50%, transparent 50%),
        linear-gradient(180deg, #ffffff 0%, #edf4ff 100%);
}

.action-inline-form .action-password-input:hover {
    border-color: #b7caea;
    background: #ffffff;
}

.action-inline-form .role-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
    background: #ffffff;
}

.client-form #new_role {
    border: 1.5px solid #c9d8f3;
    background-image:
        linear-gradient(45deg, transparent 50%, #4b70b8 50%),
        linear-gradient(135deg, #4b70b8 50%, transparent 50%),
        linear-gradient(180deg, #f7faff 0%, #edf4ff 100%);
    background-position:
        calc(100% - 20px) calc(50% + 1px),
        calc(100% - 14px) calc(50% + 1px),
        0 0;
    background-size:
        6px 6px,
        6px 6px,
        100% 100%;
    background-repeat: no-repeat;
    color: #1e293b;
}

.client-form #new_role:hover {
    border-color: #9bb5e8;
    background-image:
        linear-gradient(45deg, transparent 50%, #35589f 50%),
        linear-gradient(135deg, #35589f 50%, transparent 50%),
        linear-gradient(180deg, #ffffff 0%, #edf4ff 100%);
}

.client-form #new_role:focus,
.action-inline-form .role-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
    background: #ffffff;
}

.action-inline-form .action-password-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.native-select-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.custom-select {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0.78rem 0.85rem;
    border: 1.5px solid #c9d8f3;
    border-radius: 10px;
    font-size: 0.99rem;
    font-family: inherit;
    font-weight: 500;
    color: #1e293b;
    background: linear-gradient(180deg, #f7faff 0%, #edf4ff 100%);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.custom-select-trigger:hover {
    border-color: #9bb5e8;
    background: linear-gradient(180deg, #ffffff 0%, #edf4ff 100%);
}

.custom-select-trigger:focus {
    outline: none;
    border-color: #3b82f6;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.custom-select-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select-chevron {
    width: 10px;
    height: 10px;
    border-right: 2px solid #4b70b8;
    border-bottom: 2px solid #4b70b8;
    transform: rotate(45deg);
    margin-top: -3px;
    flex-shrink: 0;
    transition: transform 0.18s ease;
}

.custom-select-trigger[aria-expanded="true"] .custom-select-chevron {
    transform: rotate(-135deg);
    margin-top: 3px;
}

.custom-select-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 20;
    display: grid;
    gap: 3px;
    max-height: 260px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid #d8e4f7;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.18);
}

.custom-select-menu[hidden] {
    display: none !important;
    pointer-events: none;
}

.custom-option {
    width: 100%;
    text-align: left;
    border: 0;
    border-radius: 9px;
    padding: 0.62rem 0.72rem;
    background: #ffffff;
    color: #1e293b;
    font-size: 0.96rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.custom-option:hover {
    background: #edf4ff;
    color: #1d4ed8;
}

.custom-option.is-selected {
    background: #dbeafe;
    color: #1e40af;
    font-weight: 700;
}

.custom-option.placeholder {
    color: #64748b;
}

.custom-select.is-compact {
    width: 132px;
    max-width: 170px;
}

.custom-select.is-compact .custom-select-trigger {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 0.72rem;
    font-weight: 600;
}

.custom-select.is-compact .custom-select-chevron {
    width: 8px;
    height: 8px;
}

.custom-select.is-compact .custom-select-menu {
    top: calc(100% + 6px);
    padding: 6px;
}

.custom-select.is-compact .custom-option {
    padding: 0.5rem 0.55rem;
    font-size: 0.78rem;
}

.btn-action {
    border: none;
    border-radius: 9px;
    min-height: 32px;
    padding: 6px 11px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    box-shadow: 0 5px 12px rgba(15, 23, 42, 0.12);
    cursor: pointer;
    transition: transform 0.16s ease, filter 0.16s ease, box-shadow 0.16s ease;
}

.action-inline-form .btn-action {
    margin-left: 0;
}

.action-inline-single .btn-action {
    margin-left: 0;
}

.btn-action:hover {
    transform: translateY(-1px);
    filter: brightness(0.98);
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.16);
}

.btn-action.btn-view { background: #2563eb; color: #fff; }
.btn-action.btn-edit { background: #f59e0b; color: #1f2937; }
.btn-action.btn-delete { background: #dc2626; color: #fff; }

.current-account-label {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    font-size: 0.72rem;
    color: #0f766e;
    border: 1px solid #99f6e4;
    background: #ecfeff;
    border-radius: 999px;
    font-weight: 700;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(2px);
}

.modal-overlay[hidden] {
    display: none !important;
}

.modal-card {
    width: 100%;
    max-width: 430px;
    background: #ffffff;
    border: 1px solid #dbe7ff;
    border-radius: 16px;
    box-shadow: 0 20px 42px rgba(15, 23, 42, 0.26);
    padding: 20px;
    position: relative;
}

.modal-warning {
    border-color: #fecaca;
}

.modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    font-size: 1.45rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.modal-close:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.modal-card h3 {
    margin: 0;
    color: #0f172a;
    font-size: 1.16rem;
    font-weight: 800;
}

.modal-subtitle {
    margin: 6px 0 14px;
    color: #475569;
    font-size: 0.9rem;
    font-weight: 600;
}

.modal-confirm-text {
    margin: 0 0 14px;
    padding: 10px 11px;
    border-radius: 10px;
    background: #fff1f2;
    border: 1px solid #fecdd3;
    color: #9f1239;
    font-size: 0.88rem;
    font-weight: 600;
}

.modal-form {
    display: grid;
    gap: 10px;
}

.modal-form label {
    margin: 0;
    color: #334155;
    font-size: 0.84rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.modal-form input[type="password"] {
    width: 100%;
    border: 1.5px solid #d7e2f6;
    border-radius: 10px;
    padding: 10px 11px;
    font: inherit;
    background: #f8fbff;
    color: #0f172a;
}

.modal-form input[type="password"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
    background: #ffffff;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 6px;
}

.btn-action.btn-cancel {
    background: #f1f5f9;
    color: #334155;
    box-shadow: none;
    border: 1px solid #dbe3ee;
}

.btn-action.btn-cancel:hover {
    background: #e8eef7;
}

.stats-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.stats-list li {
    background: linear-gradient(135deg, #f8fafc, #eef2ff);
    border: 1px solid #e2e8f0;
    border-left: 5px solid #3b82f6;
    padding: 12px 14px;
    border-radius: 10px;
}

.roles-title {
    margin-top: 20px;
}

.roles-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

@media (max-width: 980px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-col-full {
        grid-column: auto !important;
    }
}

@media (max-width: 768px) {
    .content {
        padding: 12px;
        gap: 14px;
    }

    .client-form,
    .stats-section {
        padding: 16px;
    }

    .user-info {
        font-size: 0.86rem;
        line-height: 1.5;
    }

    .role-badge {
        margin-top: 6px;
    }

    .logout-link {
        display: inline-block;
        margin-left: 0;
        margin-top: 8px;
    }

    table {
        min-width: 1120px;
    }

    th:last-child,
    td:last-child {
        min-width: 260px;
    }
}

@media (max-width: 520px) {
    h1 {
        font-size: 1.2rem;
    }

    th,
    td {
        padding: 9px 7px;
        font-size: 0.75rem;
    }

    table {
        min-width: 930px;
    }

    .btn-primary {
        font-size: 0.9rem;
    }
}