:root {
    --bg: #f5f6f9;
    --panel: #ffffff;
    --ink: #101322;
    --muted: #6b7280;
    --muted-2: #9aa0ad;
    --line: #e6e8ee;
    --line-soft: #eef0f4;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eef2ff;
    --primary-ink: #fff;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --success: #16a34a;
    --success-soft: #ecfdf5;
    --warning: #d97706;
    --warning-soft: #fffbeb;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-md: 0 6px 20px rgba(16, 24, 40, .08);
    --sidebar-w: 232px;
    --topbar-h: 56px;
}

* { box-sizing: border-box; }
body { margin: 0; font: 14.5px/1.55 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 .35rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 650; margin: 1.8rem 0 .8rem; }
h3 { margin: 0 0 .7rem; font-size: .95rem; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- Page hors-session (login, erreurs) ---------- */
body.bare { background: radial-gradient(circle at 20% 0%, #eef2ff 0%, var(--bg) 45%); }
.bare-logo { display: block; height: 32px; width: auto; margin: 0 auto 1.4rem; }
.bare .centered { display: flex; flex-direction: column; align-items: center; }
.bare { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.centered { width: 100%; max-width: 380px; }

/* ---------- Coquille admin (sidebar + contenu) ---------- */
.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    background: var(--panel); border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
    transition: transform .25s ease;
}
.admin-brand { display: flex; align-items: center; padding: 1.2rem 1.3rem; border-bottom: 1px solid var(--line-soft); }
.admin-brand img { height: 26px; width: auto; display: block; }

.admin-nav { flex: 1; padding: .9rem .8rem; display: flex; flex-direction: column; gap: .15rem; overflow-y: auto; }
.admin-nav a {
    display: flex; align-items: center; gap: .65rem;
    padding: .55rem .7rem; border-radius: 8px;
    color: var(--muted); font-size: .88rem; font-weight: 500;
    transition: background-color .12s ease, color .12s ease;
}
.admin-nav a svg { width: 17px; height: 17px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; }
.admin-nav a:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.admin-nav a.is-active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 650; }

.admin-sidebar-foot { padding: .9rem .8rem 1.1rem; border-top: 1px solid var(--line-soft); }
.admin-user { padding: .3rem .7rem .6rem; display: flex; flex-direction: column; }
.admin-user-name { font-size: .85rem; font-weight: 600; }
.admin-user-role { font-size: .74rem; color: var(--muted-2); }
.admin-logout button {
    width: 100%; display: flex; align-items: center; gap: .6rem;
    padding: .55rem .7rem; border: 0; border-radius: 8px; background: none;
    color: var(--muted); font: inherit; font-size: .85rem; font-weight: 500; cursor: pointer;
}
.admin-logout button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.admin-logout button:hover { background: var(--danger-soft); color: var(--danger); }

.sidebar-backdrop { display: none; }

.admin-main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }
.admin-topbar {
    display: none; align-items: center; gap: .8rem;
    height: var(--topbar-h); padding: 0 1.1rem;
    background: var(--panel); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
}
.admin-topbar-logo { height: 22px; width: auto; }
.sidebar-toggle { border: 0; background: none; color: var(--ink); padding: .3rem; cursor: pointer; display: flex; }

.admin-content { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 2rem 2rem 4rem; }

@media (max-width: 900px) {
    .admin-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-md); }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .admin-topbar { display: flex; }
    .admin-content { padding: 1.4rem 1.1rem 3rem; }
    .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(16, 20, 30, .4); z-index: 35; }
    .sidebar-backdrop.open { display: block; }
}

/* ---------- Cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.3rem 1.4rem; margin-bottom: 1.2rem; box-shadow: var(--shadow-sm); }
.auth-card { text-align: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Formulaires ---------- */
label { display: block; margin-bottom: .9rem; font-size: .85rem; color: var(--muted); font-weight: 500; }
label.inline { display: flex; align-items: center; gap: .5rem; }
input, select, textarea {
    width: 100%; padding: .58rem .7rem; border: 1px solid var(--line); border-radius: 8px;
    font: inherit; font-size: .9rem; color: var(--ink); background: #fff; margin-top: .3rem;
    transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
label.inline input { width: auto; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1rem; margin-bottom: .9rem; }
legend { padding: 0 .4rem; color: var(--muted); font-size: .82rem; font-weight: 600; }
.form-actions { display: flex; gap: .6rem; margin-top: .5rem; }
.inline-form { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: .8rem; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .52rem .95rem; border: 1px solid var(--line); border-radius: 8px;
    background: #fff; color: var(--ink); cursor: pointer; font: inherit; font-size: .87rem; font-weight: 500;
    transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: transparent; background: none; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-link { border: 0; background: none; color: var(--primary); padding: .3rem .4rem; }
.btn-link:hover { background: none; }
.toolbar { display: flex; gap: .6rem; margin: 1rem 0; flex-wrap: wrap; }
.toolbar.between { justify-content: space-between; align-items: center; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.table th, .table td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--line-soft); }
.table th { background: #fafbfd; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-2); font-weight: 650; }
.table tbody tr:hover { background: #fafbfd; }
.table tr:last-child td { border-bottom: 0; }

/* ---------- Divers ---------- */
.alert { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .88rem; }
.alert-success { background: var(--success-soft); color: #065f46; }
.alert-error { background: var(--danger-soft); color: #991b1b; }
.badge { font-size: .7rem; font-weight: 650; padding: .2rem .55rem; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.badge-draft { background: var(--warning-soft); color: var(--warning); }
.badge-published { background: var(--success-soft); color: var(--success); }
.badge-archived { background: var(--line); color: var(--muted); }
.badge-expired { background: var(--danger-soft); color: var(--danger); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin: 1.2rem 0; }
@media (max-width: 720px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.1rem; text-align: center; box-shadow: var(--shadow-sm); }
.stat-value { display: block; font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-size: .82rem; }
a.stat { display: block; color: inherit; transition: border-color .15s ease, box-shadow .15s ease; }
a.stat:hover { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); text-decoration: none; }

.share-box { display: flex; gap: .5rem; margin-bottom: .6rem; }
.share-box input { flex: 1; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.photo-card { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.photo-card img { width: 100%; aspect-ratio: 3/2; object-fit: cover; display: block; }
.photo-card .no-thumb { aspect-ratio: 3/2; display: grid; place-items: center; color: var(--muted); background: var(--bg); }
.photo-card figcaption { padding: .55rem .65rem; font-size: .82rem; display: flex; flex-direction: column; gap: .3rem; }
.tag { font-size: .68rem; background: var(--primary-soft); color: #3730a3; padding: .12rem .45rem; border-radius: 5px; }
.tag-cover { background: var(--success-soft); color: var(--success); }
.row-actions { display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; }
.row-actions form { display: inline; }

.danger-zone { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }

/* ---------- Dépôt multiple de photos ---------- */
.dropzone {
    border: 2px dashed var(--line);
    border-radius: var(--radius-lg);
    padding: 2rem 1rem;
    text-align: center;
    background: #fafbfd;
    transition: border-color .15s ease, background-color .15s ease;
    cursor: pointer;
}
.dropzone.is-drag { border-color: var(--primary); background: var(--primary-soft); }
.dropzone-hint { display: flex; flex-direction: column; gap: .35rem; align-items: center; pointer-events: none; }
.dropzone-hint strong { font-size: 1rem; }
.dropzone-hint .btn-link { pointer-events: auto; padding: 0; }
#dropzone-browse { border: 0; background: none; color: var(--primary); cursor: pointer; font: inherit; text-decoration: underline; }

.upload-queue { margin-top: 1rem; }
.upload-summary { display: flex; align-items: center; gap: .8rem; margin-bottom: .6rem; font-size: .9rem; }
.progress { flex: 1; height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .25s ease; }

.upload-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); max-height: 320px; overflow-y: auto; }
.upload-row { display: grid; grid-template-columns: 1fr auto auto; gap: .5rem 1rem; align-items: center;
    padding: .5rem .8rem; border-bottom: 1px solid var(--line-soft); font-size: .85rem; position: relative; }
.upload-row:last-child { border-bottom: 0; }
.upload-row .u-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-row .u-size { color: var(--muted); font-variant-numeric: tabular-nums; }
.upload-row .u-state { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.upload-row[data-status="done"] .u-state { color: var(--success); }
.upload-row[data-status="error"] .u-state { color: var(--danger); }
.upload-row[data-status="skipped"] .u-state { color: var(--warning); }
.upload-row .u-bar { grid-column: 1 / -1; height: 3px; background: var(--line); overflow: hidden; }
.upload-row .u-bar > span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .2s ease; }
.upload-row[data-status="done"] .u-bar > span { background: var(--success); }
.upload-row[data-status="pending"] .u-bar, .upload-row[data-status="skipped"] .u-bar { visibility: hidden; }

.manual-add { margin-top: 1rem; }
.manual-add summary { cursor: pointer; color: var(--muted); font-size: .88rem; }
.manual-add[open] summary { margin-bottom: .8rem; }

/* ---------- Sections / sous-sections ---------- */
.folder-tree, .folder-tree ul { list-style: none; margin: 0; padding: 0; }
.folder-tree > li { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .8rem; margin-bottom: .6rem; }
.folder-tree ul { margin-top: .5rem; padding-left: 1rem; border-left: 2px solid var(--line); }
.folder-tree ul li { padding: .25rem 0; }
.folder-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.folder-rename, .folder-add { display: flex; gap: .4rem; align-items: center; }
.folder-rename input, .folder-add input[name="name"] { padding: .35rem .5rem; min-width: 12rem; }
.folder-add { margin-top: .6rem; }
.folder-pass { display: flex; gap: .4rem; align-items: center; margin-top: .4rem; }
.folder-pass input { padding: .35rem .5rem; min-width: 20rem; max-width: 100%; }

.section-heading { display: flex; align-items: baseline; gap: .5rem; margin: 1.6rem 0 .6rem;
    padding-bottom: .3rem; border-bottom: 1px solid var(--line); }
.section-heading.section-level-2 { margin-left: 1rem; font-size: 1rem; border-bottom-style: dashed; }
.section-heading.section-level-2::before { content: "›"; color: var(--muted); }

.move-form select { width: 100%; font-size: .78rem; padding: .3rem; }
