:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --primary: #14a96d;
  --primary-dark: #0c7d50;
  --danger: #b42318;
  --border: #d8dee8;
  --shadow: 0 16px 40px rgba(16, 24, 40, .10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at top, #eafff5, var(--bg) 42%); }
button, input { font: inherit; }
.page-shell { width: min(1080px, calc(100% - 28px)); margin: 0 auto; padding: 24px 0 56px; display: flex; flex-direction: column; gap: 24px; }
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.hero.compact .hero-logo { max-width: 420px; }
.hero-logo { display: block; width: min(620px, 100%); height: auto; object-fit: contain; margin-inline: auto; }
h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 3rem); }
h2, h3, p { margin-top: 0; }
.hero p { max-width: 720px; color: var(--muted); margin-bottom: 0; }
.card { background: var(--card); border: 1px solid rgba(216, 222, 232, .8); border-radius: 22px; padding: clamp(20px, 4vw, 36px); box-shadow: var(--shadow); }
.form-grid { display: flex; gap: 18px; flex-wrap: wrap; }
.form-grid > label { flex: 1 1 260px; }
label { display: flex; flex-direction: column; gap: 8px; font-weight: 700; }
input[type="text"], input[type="date"], input[type="password"], input:not([type]) { width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 13px 14px; background: #fff; color: var(--text); }
input:focus { outline: 3px solid rgba(20, 169, 109, .18); border-color: var(--primary); }
.file-picker { margin-top: 20px; border: 2px dashed #9dd7bd; background: #f4fff9; border-radius: 16px; padding: 20px; }
.file-picker input { max-width: 100%; }
small, .muted { color: var(--muted); font-weight: 400; }
.actions, .admin-toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.actions { margin-top: 22px; }
button { border: 0; border-radius: 12px; padding: 12px 18px; color: #fff; background: var(--primary); font-weight: 800; cursor: pointer; }
button:hover { background: var(--primary-dark); }
button:disabled { opacity: .55; cursor: not-allowed; }
.secondary-link, .danger-link { text-decoration: none; font-weight: 800; }
.secondary-link { color: var(--primary-dark); }
.danger-link { color: var(--danger); }
.dialog-card { width: min(560px, calc(100% - 24px)); border: 0; border-radius: 20px; padding: 0; box-shadow: 0 24px 70px rgba(0,0,0,.24); }
.dialog-card::backdrop { background: rgba(15, 23, 42, .62); }
.dialog-content { padding: 26px; }
progress { width: 100%; height: 18px; accent-color: var(--primary); }
.progress-row { display: flex; justify-content: space-between; margin: 6px 0 14px; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 20px; }
.report-list { max-height: 300px; overflow: auto; padding-left: 22px; }
.report-list .success { color: #067647; }
.report-list .error, .alert.error { color: var(--danger); }
.stack-form { display: flex; flex-direction: column; gap: 16px; }
.auth-card { max-width: 560px; width: 100%; align-self: center; }
.alert { padding: 12px 14px; border-radius: 10px; background: #eff8ff; }
.alert.error { background: #fef3f2; }
.alert.success { background: #ecfdf3; color: #067647; }
.admin-toolbar { align-items: flex-start; }
.photo-browser { display: flex; flex-direction: column; gap: 18px; margin-top: 22px; }
.photo-group { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.group-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px; background: #f8fafc; }
.group-heading h3, .group-heading p { margin-bottom: 0; }
.select-all { flex-direction: row; align-items: center; white-space: nowrap; }
.file-list { display: flex; flex-direction: column; }
.file-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid #eef1f5; font-weight: 500; }
.file-row:hover { background: #fbfffd; }
.file-name { overflow-wrap: anywhere; }
.file-size { color: var(--muted); white-space: nowrap; }
.sticky-actions { position: sticky; bottom: 10px; margin-top: 22px; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 14px; padding: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; box-shadow: 0 8px 30px rgba(16,24,40,.12); }
@media (max-width: 640px) {
  .page-shell { width: min(100% - 18px, 1080px); padding-top: 12px; }
  .card { border-radius: 16px; padding: 18px; }
  .actions > *, .sticky-actions > * { width: 100%; text-align: center; }
  .sticky-actions { flex-direction: column; }
  .group-heading { align-items: flex-start; flex-direction: column; }
  .file-row { grid-template-columns: auto 1fr; }
  .file-size { grid-column: 2; }
}

/* Galerie administrateur */
.admin-page-shell { width: min(1500px, calc(100% - 28px)); }
.viewer-toolbar { display: flex; align-items: end; gap: 14px; flex-wrap: wrap; margin-top: 22px; padding: 14px; background: #f8fafc; border: 1px solid var(--border); border-radius: 14px; }
.search-control { flex: 1 1 250px; }
.search-control input { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.density-control { display: grid; grid-template-columns: auto minmax(110px, 180px) 24px; align-items: center; gap: 10px; }
.density-control input { accent-color: var(--primary); }
.secondary-button { background: #e8f7f0; color: var(--primary-dark); }
.secondary-button:hover { background: #d8f0e5; }
.admin-browser-layout { display: flex; min-height: 560px; margin-top: 18px; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.folder-panel { flex: 0 0 260px; background: #f8fafc; border-right: 1px solid var(--border); overflow: auto; }
.folder-panel-title { position: sticky; top: 0; z-index: 1; padding: 16px; background: #eef3f7; border-bottom: 1px solid var(--border); font-weight: 900; }
.folder-tree { padding: 9px; display: flex; flex-direction: column; gap: 3px; }
.tree-item { width: 100%; display: flex; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: 9px; background: transparent; color: var(--text); text-align: left; font-weight: 650; }
.tree-item:hover { background: #eaf7f1; }
.tree-item.active { background: var(--primary); color: #fff; }
.tree-item small { color: inherit; opacity: .75; }
.tree-children { margin-left: 15px; padding-left: 8px; border-left: 1px solid #cbd5e1; }
.tree-date { font-size: .9rem; }
.gallery-panel { min-width: 0; flex: 1 1 auto; padding: 18px; background: #fff; }
.gallery-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.gallery-heading h3, .gallery-heading p { margin-bottom: 0; }
.photo-gallery { --gallery-columns: 4; display: grid; grid-template-columns: repeat(var(--gallery-columns), minmax(0, 1fr)); gap: 14px; align-content: start; }
.photo-card { position: relative; min-width: 0; border: 2px solid transparent; border-radius: 14px; overflow: hidden; background: #f8fafc; box-shadow: 0 3px 12px rgba(16,24,40,.08); transition: transform .15s, border-color .15s; }
.photo-card:hover { transform: translateY(-2px); }
.photo-card.selected { border-color: var(--primary); background: #effcf5; }
.photo-select { position: absolute; z-index: 2; top: 8px; left: 8px; width: 28px; height: 28px; border-radius: 8px; background: rgba(255,255,255,.92); box-shadow: 0 2px 8px rgba(0,0,0,.2); display: grid; place-items: center; }
.photo-select input { width: 18px; height: 18px; accent-color: var(--primary); }
.photo-preview-button { width: 100%; padding: 0; border-radius: 0; background: #e9eef3; aspect-ratio: 4 / 3; overflow: hidden; }
.photo-preview-button:hover { background: #dce4eb; }
.photo-preview-button img { width: 100%; height: 100%; display: block; object-fit: cover; }
.photo-preview-button:disabled { opacity: 1; cursor: default; }
.unsupported-preview { height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 7px; color: var(--muted); }
.unsupported-preview strong { font-size: 1.35rem; }
.photo-meta { padding: 10px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.photo-meta strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .92rem; }
.photo-meta small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .78rem; }
.empty-gallery { grid-column: 1 / -1; padding: 40px; text-align: center; color: var(--muted); }
.preview-dialog { width: min(1100px, calc(100% - 24px)); height: min(88vh, 850px); }
.preview-header { height: 54px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); }
.preview-header strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-button { width: 38px; height: 38px; padding: 0; border-radius: 50%; font-size: 1.7rem; line-height: 1; }
.preview-stage { height: calc(100% - 54px); display: grid; place-items: center; padding: 14px; background: #111827; }
.preview-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
@media (max-width: 900px) {
  .admin-browser-layout { flex-direction: column; }
  .folder-panel { flex-basis: auto; max-height: 240px; border-right: 0; border-bottom: 1px solid var(--border); }
  .photo-gallery { --gallery-columns: 3 !important; }
}
@media (max-width: 640px) {
  .density-control { width: 100%; grid-template-columns: auto 1fr 24px; }
  .viewer-toolbar .secondary-button { width: 100%; }
  .gallery-panel { padding: 10px; }
  .photo-gallery { --gallery-columns: 2 !important; gap: 9px; }
  .photo-meta { padding: 8px; }
  .admin-browser-layout { min-height: 420px; }
}
