:root {
    --green: #2e7d32;
    --green-dark: #1b5e20;
    --green-light: #e8f5e9;
    --bg: #f4f6f5;
    --text: #1c1c1c;
    --muted: #6b7280;
    --border: #e2e5e2;
    --danger: #c0392b;
    --warn: #d97706;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
    background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
    color: white;
}
.site-header .wrap {
    display: flex; align-items: center; justify-content: space-between;
    padding-top: 16px; padding-bottom: 16px;
}
.logo { color: white; font-weight: 700; font-size: 1.2rem; text-decoration: none; }
.site-header nav { display: flex; align-items: center; gap: 16px; }
.site-header nav a { color: white; text-decoration: none; opacity: 0.9; }
.site-header nav a:hover { opacity: 1; text-decoration: underline; }
.user-pill {
    background: rgba(255,255,255,0.15);
    padding: 4px 12px; border-radius: 20px; font-size: 0.9rem;
}

/* Hero */
.hero { padding: 40px 0 20px; }
.hero h1 { margin: 0 0 8px; font-size: 1.8rem; }
.hero p { color: var(--muted); margin: 0; }

/* Downloads grid */
.downloads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    padding: 20px 0 60px;
}
.download-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.download-icon { font-size: 2.2rem; }
.download-body h2 { margin: 0 0 6px; font-size: 1.1rem; }
.download-body .desc { color: var(--muted); font-size: 0.92rem; margin: 0 0 10px; }
.meta { display: flex; align-items: center; gap: 10px; }
.size { font-size: 0.85rem; color: var(--muted); background: var(--green-light); padding: 3px 10px; border-radius: 12px; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 8px;
    text-decoration: none;
    text-align: center;
    font-weight: 600;
    font-size: 0.92rem;
    border: 1px solid var(--border);
    color: var(--text);
    background: white;
    cursor: pointer;
}
.btn-primary { background: var(--green); border-color: var(--green); color: white; }
.btn-primary:hover { background: var(--green-dark); }

/* Badges */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: 0.8rem; border: none; cursor: pointer;
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-off { background: #f3f4f6; color: #6b7280; }
.badge-warn { background: #fef3c7; color: var(--warn); margin-left: 6px; }

/* Empty state */
.empty-state { padding: 60px 0; text-align: center; color: var(--muted); }

/* Flash messages */
.flash { padding: 14px 18px; border-radius: 8px; margin: 20px 0; font-size: 0.92rem; }
.flash-ok { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: var(--danger); }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin: 24px 0;
}
.stat-card {
    background: white; border: 1px solid var(--border); border-radius: 12px;
    padding: 20px; text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--green-dark); }
.stat-label { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

/* Admin sections */
.admin-section { margin: 40px 0; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.admin-table { width: 100%; border-collapse: collapse; background: white; border-radius: 12px; overflow: hidden; }
.admin-table th, .admin-table td {
    padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem;
}
.admin-table th { background: var(--green-light); color: var(--green-dark); font-weight: 600; }
.admin-table .actions a, .admin-table .actions button { margin-right: 10px; font-size: 0.85rem; }
.link-danger { background: none; border: none; color: var(--danger); cursor: pointer; padding: 0; font-size: 0.85rem; }
.inline-form { display: inline; }

/* Forms */
.admin-form { display: flex; flex-direction: column; gap: 16px; max-width: 560px; margin: 20px 0 60px; }
.admin-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; font-weight: 600; }
.admin-form input, .admin-form textarea, .admin-form select {
    font-family: inherit; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-weight: 400;
}
.checkbox-label { flex-direction: row !important; align-items: center; gap: 8px !important; }
.form-actions { display: flex; gap: 10px; }

/* Footer */
.site-footer { padding: 30px 0; color: var(--muted); font-size: 0.85rem; text-align: center; }

code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; }

/* Logo (image) */
.logo-img { height: 34px; width: auto; max-height: 34px; display: block; object-fit: contain; }

/* Centrage des textes sur les pages publiques de téléchargement (index, fiche) */
.page-center .hero { text-align: center; }
.page-center .download-card { text-align: center; align-items: center; }
.page-center .download-card .meta { justify-content: center; }
.page-center .empty-state { text-align: center; }
.page-center .code-form { margin-left: auto; margin-right: auto; text-align: center; }
.page-center .fiche-card { text-align: center; align-items: center; margin-left: auto; margin-right: auto; }
.page-center .fiche-card .meta { justify-content: center; }
.page-center .hint-link { text-align: center; }

/* Lien discret (ex: "vous avez un code d'accès ?") */
.hint-link { margin: 10px 0 40px; }
.hint-link a { color: var(--green-dark); font-size: 0.9rem; }

/* Fiche de téléchargement (page de détail avant téléchargement) */
.fiche-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 40px;
    max-width: 560px;
    margin: 20px 0 60px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.fiche-card .download-icon { font-size: 3rem; }
.fiche-card h1 { margin: 0; font-size: 1.4rem; }
.fiche-card .desc { color: var(--muted); }
.fiche-card .actions { margin-top: 10px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* Formulaire code d'accès */
.code-form {
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 40px;
    max-width: 420px;
    margin: 20px 0 60px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.code-form input[type="text"] {
    font-size: 1.1rem;
    letter-spacing: 1px;
    text-align: center;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

/* Popup de consentement */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center; justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: white; border-radius: 12px; padding: 28px;
    max-width: 440px; width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-box h3 { margin: 0 0 12px; }
.modal-box p { color: var(--muted); font-size: 0.92rem; margin: 0 0 16px; }
.modal-consent {
    display: flex; align-items: flex-start; gap: 10px;
    background: var(--green-light); border-radius: 8px; padding: 12px 14px;
    font-size: 0.9rem; margin-bottom: 20px; text-align: left;
}
.modal-consent input { margin-top: 3px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn-disabled { opacity: 0.5; pointer-events: none; cursor: not-allowed; }

.badge-hidden { background: #ede9fe; color: #6d28d9; margin-left: 6px; }
.badge-consent { background: #fef3c7; color: var(--warn); margin-left: 6px; }
