/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    color: #1a1a2e;
    background: #f4f6fb;
    line-height: 1.5;
}

a { color: #3b5bdb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== NAV ===== */
nav {
    background: #1a1a2e;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand { color: #fff; font-weight: 700; font-size: 1.1rem; }
.nav-links a { color: #ccd5f0; margin-left: 1.5rem; font-size: 0.9rem; }
.nav-links a:hover { color: #fff; text-decoration: none; }
.nav-logout { color: #ff6b6b !important; }

/* ===== CONTAINER ===== */
.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ===== ALERTS ===== */
.alert {
    padding: .75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: .9rem;
}
.alert-success { background: #d3f9d8; color: #1b4332; border: 1px solid #b2f2bb; }
.alert-warning { background: #fff3cd; color: #7c5e0a; border: 1px solid #ffd966; }
.alert-danger  { background: #ffe0e0; color: #7c1d1d; border: 1px solid #ffa8a8; }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.6rem; font-weight: 700; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    padding: .45rem .9rem;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 500;
    border: 1px solid #d0d7de;
    background: #fff;
    cursor: pointer;
    color: #1a1a2e;
    transition: background .15s;
}
.btn:hover { background: #f0f2f5; text-decoration: none; }
.btn-primary { background: #3b5bdb; color: #fff; border-color: #3b5bdb; }
.btn-primary:hover { background: #2f4ac7; }
.btn-danger { background: #e03131; color: #fff; border-color: #e03131; }
.btn-danger:hover { background: #c92a2a; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 1.25rem;
    text-align: center;
    border: 1px solid #e8eaf0;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.stat-number { display: block; font-size: 2rem; font-weight: 700; color: #1a1a2e; }
.stat-label  { display: block; font-size: .8rem; color: #6b7280; margin-top: .25rem; }
.stat-blue .stat-number { color: #3b5bdb; }
.stat-green .stat-number { color: #2f9e44; }
.stat-red .stat-number   { color: #e03131; }

/* ===== TABLE ===== */
table { width: 100%; border-collapse: collapse; background: #fff;
        border-radius: 10px; overflow: hidden;
        border: 1px solid #e8eaf0; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
th { background: #f8f9fc; padding: .75rem 1rem; text-align: left;
     font-size: .8rem; font-weight: 600; color: #6b7280;
     text-transform: uppercase; letter-spacing: .04em;
     border-bottom: 1px solid #e8eaf0; }
td { padding: .75rem 1rem; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8f9fc; }
td.actions { display: flex; gap: .4rem; }
td.notes-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    background: #e8eaf0;
    color: #3b3f5c;
}
.badge-warning { background: #fff3cd; color: #7c5e0a; }
.badge-à-envoyer  { background: #e8eaf0; color: #3b3f5c; }
.badge-envoyée    { background: #dbe4ff; color: #1e3a8a; }
.badge-relance    { background: #fff3cd; color: #7c5e0a; }
.badge-entretien  { background: #d3f9d8; color: #1b4332; }
.badge-refus      { background: #ffe0e0; color: #7c1d1d; }
.badge-abandonné  { background: #f0f0f0; color: #6b7280; }

/* ===== STATUT HTMX ===== */
.statut-wrapper { display: flex; align-items: center; gap: .5rem; }
.statut-select {
    font-size: .75rem;
    border: 1px solid #d0d7de;
    border-radius: 5px;
    padding: .2rem .4rem;
    background: #fff;
    cursor: pointer;
    color: #1a1a2e;
}

/* ===== FILTERS ===== */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.filter-btn {
    padding: .35rem .8rem;
    border-radius: 20px;
    font-size: .8rem;
    border: 1px solid #d0d7de;
    background: #fff;
    color: #1a1a2e;
}
.filter-btn:hover, .filter-btn.active {
    background: #3b5bdb;
    color: #fff;
    border-color: #3b5bdb;
    text-decoration: none;
}

/* ===== FORMS ===== */
.form-card {
    background: #fff;
    border-radius: 10px;
    padding: 2rem;
    border: 1px solid #e8eaf0;
    max-width: 720px;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 600; font-size: .875rem; margin-bottom: .4rem; }
.form-group small { display: block; margin-top: .3rem; color: #6b7280; font-size: .8rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
input[type="text"], input[type="url"], input[type="email"],
input[type="date"], input[type="password"], select, textarea {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    font-size: .9rem;
    background: #fff;
    color: #1a1a2e;
    transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #3b5bdb;
    box-shadow: 0 0 0 3px rgba(59,91,219,.1);
}
textarea { resize: vertical; }
.form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; }

/* ===== DETAIL PAGE ===== */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 2rem; }
.card {
    background: #fff;
    border-radius: 10px;
    padding: 1.5rem;
    border: 1px solid #e8eaf0;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.card h2 { font-size: 1rem; font-weight: 700; margin-bottom: 1rem;
           padding-bottom: .75rem; border-bottom: 1px solid #f0f2f5; }
dl { display: grid; grid-template-columns: 140px 1fr; gap: .5rem .75rem; }
dt { font-size: .8rem; font-weight: 600; color: #6b7280; padding-top: .1rem; }
dd { font-size: .9rem; }

/* ===== SECTIONS ===== */
.section { margin-top: 2rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.section h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; }

/* ===== MISC ===== */
.empty-state { text-align: center; padding: 3rem; color: #6b7280; }
.context-banner {
    background: #dbe4ff;
    border-radius: 8px;
    padding: .75rem 1rem;
    margin-bottom: 1.5rem;
    font-size: .9rem;
    color: #1e3a8a;
}
.danger-zone { border-top: 2px solid #ffe0e0; padding-top: 1.5rem; }
.danger-zone h2 { color: #e03131; }

/* ===== LOGIN PAGE ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f4f6fb;
}
.login-box {
    background: #fff;
    border-radius: 12px;
    padding: 2.5rem;
    width: 360px;
    border: 1px solid #e8eaf0;
    box-shadow: 0 4px 20px rgba(0,0,0,.08);
    text-align: center;
}
.login-box h1 { font-size: 1.8rem; margin-bottom: .5rem; }
.login-box p  { color: #6b7280; margin-bottom: 1.5rem; }
.login-box input { margin-bottom: 1rem; }
.login-box button { width: 100%; padding: .65rem; font-size: 1rem; }

/* ===== CHARTS ===== */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.chart-card h2 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid #f0f2f5;
}
.chart-wrapper {
    position: relative;
    height: 260px;
    width: 100%;
}
@media (max-width: 640px) {
    .charts-grid { grid-template-columns: 1fr; }
}