*, *::before, *::after {
    box-sizing: border-box;
}

a,
a:visited,
a:active {
    text-decoration: none;
    color: inherit;
}

a:hover,
a:focus {
    text-decoration: none;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f4f5fb;
    color: #111827;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.9rem 1.8rem;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-left {
    flex-shrink: 0;
}

.topbar-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
}

.main-nav {
    display: flex;
    align-items: center;
}

/* Bloc utilisateur (visible dans la topbar sur grand écran) */
.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-left: 1rem;
    margin-left: 0.5rem;
    border-left: 1px solid #e5e7eb;
}

.topbar-right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.logo-small {
    height: 32px;
    object-fit: contain;
}

.logo-placeholder {
    font-weight: 700;
    font-size: 1.2rem;
}

.main-nav a {
    color: #4b5563;
    text-decoration: none;
    margin: 0 0.6rem;
    font-size: 0.95rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    transition: background 0.15s ease-out, color 0.15s ease-out;
}

.main-nav a:hover {
    background: #eef2ff;
    color: #4338ca;
}

.notif-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: #eef2ff;
}

.notif-icon {
    position: relative;
    width: 18px;
    height: 18px;
    box-sizing: border-box;
}

.notif-icon::before,
.notif-icon::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

/* Corps de la cloche */
.notif-icon::before {
    bottom: 3px;
    width: 14px;
    height: 12px;
    border-radius: 7px 7px 3px 3px;
    border: 2px solid #4f46e5;
    border-top-width: 2px;
    background: transparent;
}

/* Battant de la cloche */
.notif-icon::after {
    bottom: 0;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #4f46e5;
}

.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #ffffff;
    border-radius: 999px;
    padding: 0 6px;
    font-size: 0.7rem;
    font-weight: 600;
}

.user-name {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.btn-link {
    color: #4b5563;
    text-decoration: none;
    font-size: 0.9rem;
}

.btn-link:hover {
    text-decoration: underline;
}

.main-container {
    padding: 1.8rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.card {
    background: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 12px 30px rgba(148, 163, 184, 0.25);
    padding: 1.6rem 1.8rem;
    margin-bottom: 1.6rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.1rem;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 600;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.8rem 1.6rem;
    border: none;
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 500;
    transition: transform 0.08s ease-out, box-shadow 0.12s ease-out, background 0.15s;
}

.btn-primary {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #ffffff;
}

.btn-primary *,
.btn-primary span {
    color: #ffffff;
}

.btn-primary:hover {
    transform: none;
}

.btn-secondary {
    background: #eef2ff;
    color: #111827;
    border: 1px solid #e5e7eb;
}

.btn-secondary:hover {
    background: #e0e7ff;
    border-color: #c7d2fe;
}

.btn-sm {
    padding: 0.7rem 1.3rem;
    font-size: 1rem;
}

.btn + .btn {
    margin-left: 0.6rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.9rem;
}

.form-group label {
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
    color: #6b7280;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    padding: 0.6rem 0.75rem;
    border-radius: 0.65rem;
    border: 1px solid #d1d5db;
    font-size: 0.94rem;
    font-family: inherit;
    background: #f9fafb;
    color: #111827;
    outline: none;
    transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out, background 0.15s;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.45);
    background: #ffffff;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th,
td {
    padding: 0.7rem 0.75rem;
    text-align: left;
}

thead {
    background: #f3f4f6;
}

thead th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
}

tbody tr:nth-child(even) {
    background: #f9fafb;
}

tbody tr:hover {
    background: #e0e7ff;
    cursor: pointer;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    min-width: 88px;
    text-align: center;
    white-space: nowrap;
}

.status-non_demarre {
    background: #e5e7eb;
    color: #374151;
}

.status-en_cours {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-attente_precision {
    background: #fef3c7;
    color: #b45309;
}

.status-termine {
    background: #dcfce7;
    color: #15803d;
}

.badge-archived {
    background: #e5e7eb;
    color: #4b5563;
    border-radius: 999px;
    padding: 0.12rem 0.55rem;
    font-size: 0.75rem;
}

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mt-1 { margin-top: 0.3rem; }
.mt-2 { margin-top: 0.6rem; }
.mt-3 { margin-top: 1.1rem; }

.text-muted {
    color: #6b7280;
}

.link {
    color: #111827;
    text-decoration: none;
}

.link:hover {
    text-decoration: none;
    color: #111827;
}

.alert {
    padding: 0.7rem 0.9rem;
    border-radius: 0.75rem;
    font-size: 0.9rem;
    margin-bottom: 0.9rem;
}

.alert-success {
    background: #ecfdf3;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.12rem 0.6rem;
    font-size: 0.8rem;
    background: #eff6ff;
    color: #1d4ed8;
}

.table-actions {
    white-space: nowrap;
    display: flex;
    gap: 0.5rem;
}

/* Groupe de boutons d'action (ex: retour / éditer / terminer) */
.task-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.85rem 0;
}

/* Ligne de boutons filtres */
.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Bouton hamburger (invisible par défaut sur desktop) */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 0.5rem;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: #374151;
    border-radius: 2px;
    transition: transform 0.2s ease, opacity 0.15s ease;
}

.hamburger-btn.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.hamburger-btn.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

tbody tr:hover .table-actions .btn-secondary {
    background: #ffffff;
    border-color: #e5e7eb;
}

tbody tr:hover .table-actions .btn-secondary:hover {
    background: #eef2ff;
}

.progress-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.22rem 0.65rem;
    border-radius: 999px;
    background: #f3f4ff;
    border: 1px solid #e5e7eb;
}

.progress-pill-track {
    position: relative;
    width: 130px;
    height: 8px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

.progress-pill-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #4f46e5, #22c55e);
    transition: width 0.25s ease-out;
}

.progress-pill-text {
    font-size: 0.8rem;
    font-weight: 500;
    color: #374151;
    min-width: 2.5rem;
    text-align: right;
}

/* ── Tablette large ────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .main-container {
        padding: 1.4rem 1.2rem;
    }
}

/* ── Tablette + Mobile : hamburger actif ≤ 900px ──────────────── */
@media (max-width: 900px) {
    .main-container {
        max-width: 100%;
        padding: 1rem 1rem;
        margin: 0;
    }

    .card {
        border-radius: 0.8rem;
        box-shadow: 0 6px 18px rgba(148, 163, 184, 0.18);
    }

    /* Topbar : une seule ligne, hamburger actif */
    .topbar {
        flex-wrap: nowrap;
        gap: 0.5rem;
        padding: 0.75rem 1.2rem;
        position: relative;
    }

    /* Nav cachée par défaut → dropdown au clic */
    .topbar-center {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #ffffff;
        border-bottom: 1px solid #e5e7eb;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
        padding: 0.5rem 1rem 0.9rem;
        z-index: 19;
    }

    .topbar-center.nav-open {
        display: flex;
    }

    .main-nav {
        flex-direction: column;
        width: 100%;
        gap: 0.1rem;
    }

    .main-nav a {
        margin: 0;
        font-size: 0.95rem;
        padding: 0.65rem 0.9rem;
        border-radius: 0.6rem;
        white-space: nowrap;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .notif-link {
        width: auto;
        height: auto;
        border-radius: 0.6rem;
        background: none;
        padding: 0.65rem 0.9rem;
    }

    /* Bloc utilisateur dans le dropdown */
    .nav-user {
        border-left: none;
        border-top: 1px solid #e5e7eb;
        padding-left: 0.9rem;
        padding-top: 0.7rem;
        margin-left: 0;
        margin-top: 0.4rem;
        width: 100%;
        gap: 0.5rem;
    }

    .topbar-right {
        flex: 1;
        justify-content: flex-end;
    }

    /* Hamburger visible */
    .hamburger-btn {
        display: flex;
    }
}

/* ── Mobile uniquement (≤ 640px) ──────────────────────────────── */
@media (max-width: 640px) {
    body {
        font-size: 14px;
    }

    .topbar {
        padding: 0.6rem 0.8rem;
        gap: 0.4rem;
    }

    .main-nav a {
        font-size: 0.9rem;
        padding: 0.6rem 0.75rem;
    }

    .topbar-right {
        gap: 0.4rem;
    }

    /* ── Conteneur pleine largeur ── */
    .main-container {
        padding: 0.75rem 0.75rem 1.4rem;
    }

    /* ── Cards ── */
    .card {
        padding: 1rem 1rem;
        margin-bottom: 0.9rem;
        border-radius: 0.85rem;
        box-shadow: 0 4px 14px rgba(148, 163, 184, 0.22);
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.7rem;
    }

    /* ── Boutons pleine largeur dans les formulaires et headers ── */
    .form-group .btn,
    .card-header .btn,
    .btn-row .btn,
    .task-btn-group .btn {
        width: 100%;
        justify-content: center;
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    .task-btn-group {
        flex-direction: column;
    }

    .btn-row {
        flex-direction: column;
    }

    .btn + .btn {
        margin-left: 0;
    }

    /* ── Actions dans les tableaux ── */
    .table-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.4rem;
        white-space: normal;
    }

    .table-actions .btn {
        width: 100%;
        justify-content: center;
        text-align: center;
        white-space: nowrap;
    }

    /* ── Tableaux → mode cartes ── */
    table {
        border: 0;
    }

    thead {
        display: none;
    }

    tbody tr {
        display: block;
        margin-bottom: 0.8rem;
        background: #ffffff;
        border-radius: 0.9rem;
        box-shadow: 0 4px 16px rgba(148, 163, 184, 0.2);
        padding: 0.75rem 0.85rem 0.6rem;
    }

    tbody tr:nth-child(even) {
        background: #ffffff;
    }

    tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.35rem 0;
        border-bottom: 1px solid #f3f4f6;
        gap: 0.5rem;
    }

    tbody td:last-child {
        border-bottom: none;
        padding-top: 0.6rem;
        flex-direction: column;
        align-items: stretch;
    }

    tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.75rem;
        color: #6b7280;
        flex-shrink: 0;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    tbody td:last-child::before {
        margin-bottom: 0.4rem;
    }

    .status-pill {
        min-width: 0;
        font-size: 0.78rem;
        padding: 0.18rem 0.55rem;
    }

    .progress-pill {
        gap: 0.3rem;
    }

    .progress-pill-track {
        width: 80px;
    }

    .progress-pill-text {
        font-size: 0.78rem;
        min-width: 2rem;
    }
}

