* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.5;
}

header {
    background: #2c3e50;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 { font-size: 1.3rem; }
.header-right { display: flex; gap: 1rem; align-items: center; }
.header-right a { color: #ecf0f1; text-decoration: none; }

.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 2rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.login-container h1 { text-align: center; color: #2c3e50; margin-bottom: 0.5rem; }
.login-container h2 { text-align: center; color: #7f8c8d; font-weight: normal; margin-bottom: 1.5rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-weight: 500; }
.form-group input {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

button, .btn-retry, .btn-retry-all {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.login-container button {
    width: 100%;
    background: #2c3e50;
    color: white;
    font-size: 1rem;
    margin-top: 0.5rem;
}

.flash { padding: 0.7rem 1rem; border-radius: 4px; margin-bottom: 1rem; }
.flash.error { background: #fde8e8; color: #c0392b; }
.flash.success { background: #e8f8e8; color: #27ae60; }
.flash-container { padding: 1rem 2rem 0; }

.stats {
    display: flex;
    gap: 1rem;
    padding: 1.5rem 2rem;
    flex-wrap: wrap;
}

.stat-card {
    flex: 1;
    min-width: 120px;
    background: white;
    padding: 1.2rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-top: 3px solid #bdc3c7;
}
.stat-card.sent { border-top-color: #27ae60; }
.stat-card.pending { border-top-color: #f39c12; }
.stat-card.error { border-top-color: #e74c3c; }
.stat-card.waiting { border-top-color: #3498db; }
.stat-card.total { border-top-color: #2c3e50; }
.stat-value { font-size: 2rem; font-weight: 700; }
.stat-label { color: #7f8c8d; font-size: 0.85rem; margin-top: 0.3rem; }

.filters {
    padding: 0 2rem 1rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.filters a {
    padding: 0.4rem 1rem;
    border-radius: 20px;
    text-decoration: none;
    color: #555;
    background: white;
    border: 1px solid #ddd;
    font-size: 0.85rem;
}
.filters a.active { background: #2c3e50; color: white; border-color: #2c3e50; }

.table-container {
    margin: 0 2rem 2rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow-x: auto;
}
.table-container h2 { padding: 1rem 1.5rem 0; font-size: 1.1rem; color: #2c3e50; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.7rem 1rem; text-align: left; border-bottom: 1px solid #eee; font-size: 0.85rem; }
th { background: #f8f9fa; font-weight: 600; color: #555; }

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge.sent { background: #e8f8e8; color: #27ae60; }
.badge.pending { background: #fef5e7; color: #f39c12; }
.badge.sending { background: #eaf2f8; color: #2980b9; }
.badge.error { background: #fde8e8; color: #e74c3c; }
.badge.waiting_pdf { background: #ebf5fb; color: #3498db; }

.error-msg { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #e74c3c; font-size: 0.8rem; }

.btn-action { display: inline-block; padding: 0.4rem 0.8rem; font-size: 0.8rem; font-weight: 500; color: white; border: none; border-radius: 4px; cursor: pointer; text-decoration: none; line-height: 1.2; vertical-align: middle; box-sizing: border-box; }
.btn-action.download { background: #3498db; }
.btn-action.download:hover { background: #2980b9; }
.btn-action.retry { background: #f39c12; }
.btn-action.resend { background: #27ae60; }
.btn-retry-all { background: #e74c3c; color: white; margin-left: auto; }
.inline-form { display: inline; }

.pagination { padding: 1rem 1.5rem; display: flex; justify-content: center; gap: 1rem; align-items: center; }
.pagination a { color: #2c3e50; text-decoration: none; }

.active-nav { font-weight: 600; text-decoration: underline !important; }

.user-form { padding: 1rem 1.5rem 1.5rem; }
.form-row { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 150px; }
.form-row select { width: 100%; padding: 0.6rem; border: 1px solid #ddd; border-radius: 4px; font-size: 1rem; }

.btn-create { background: #27ae60; color: white; padding: 0.6rem 1.5rem; font-size: 0.9rem; }
.btn-delete { background: #e74c3c; color: white; padding: 0.3rem 0.8rem; font-size: 0.8rem; }

.password-form { display: flex; gap: 0.3rem; align-items: center; }
.password-form input { width: 160px; padding: 0.3rem 0.5rem; border: 1px solid #ddd; border-radius: 4px; font-size: 0.8rem; }

td select { padding: 0.3rem; border: 1px solid #ddd; border-radius: 4px; font-size: 0.8rem; }

.pdf-link { color: #2980b9; text-decoration: none; font-weight: 600; }
.pdf-link:hover { text-decoration: underline; }

.actions-cell { display: flex; gap: 0.3rem; align-items: center; }

.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.modal-content { background: white; border-radius: 8px; padding: 2rem; width: 450px; max-width: 90%; box-shadow: 0 4px 20px rgba(0,0,0,0.2); }
.modal-content h3 { margin-bottom: 1rem; color: #2c3e50; }
.modal-content small { color: #7f8c8d; font-size: 0.8rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.5rem; }
.btn-cancel { background: #95a5a6; color: white; padding: 0.6rem 1.2rem; border: none; border-radius: 4px; cursor: pointer; font-size: 0.9rem; }

/* --- Publié + filtres + actions en masse --- */
.stat-card.published { border-top-color: #8e44ad; }
.badge.published { background: #f4ecf7; color: #8e44ad; }

.filter-form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; padding: 1rem 1.5rem 0.5rem; }
.filter-form label { display: flex; flex-direction: column; font-size: 0.8rem; color: #555; gap: 0.2rem; }
.filter-form select { padding: 0.45rem; border: 1px solid #ddd; border-radius: 4px; font-size: 0.85rem; min-width: 150px; max-width: 260px; }
.btn-reset { padding: 0.45rem 1rem; border: 1px solid #ddd; border-radius: 4px; text-decoration: none; color: #555; background: white; font-size: 0.85rem; }

.toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; padding: 0.5rem 1.5rem; border-bottom: 1px solid #eee; }
.bulk-actions { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; font-size: 0.85rem; }
.btn-send-bulk { background: #8e44ad; color: white; padding: 0.5rem 1.1rem; font-weight: 600; }
.btn-send-bulk:hover { background: #7d3c98; }
.sel-count { color: #8e44ad; font-weight: 600; }
.empty { text-align: center; color: #7f8c8d; padding: 1.5rem; }
.pagination span { color: #555; font-size: 0.85rem; }
