:root {
  --navy: #071a38;
  --navy-2: #0e2e5c;
  --red: #c91f2b;
  --red-dark: #a91620;
  --ink: #172033;
  --muted: #5d687a;
  --line: #dce2ea;
  --surface: #ffffff;
  --canvas: #f4f6f9;
  --success: #17663a;
  --success-bg: #e4f4e9;
  --warning: #8a4c08;
  --warning-bg: #fff2d9;
  --danger: #9f1d28;
  --danger-bg: #fde8ea;
  --info: #1857a4;
  --info-bg: #e8f1fc;
  --radius: 10px;
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html { font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--canvas); }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: var(--sidebar); padding: 22px 16px; color: #fff; background: var(--navy); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 24px; text-decoration: none; }
.brand-mark { display: grid; width: 39px; height: 39px; place-items: center; border-radius: 9px; color: #fff; background: var(--red); font-size: .76rem; font-weight: 900; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: #b8c5d8; font-size: .75rem; }
.nav-label { margin: 13px 10px 7px; color: #8fa2bd; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.nav-link { display: flex; align-items: center; gap: 10px; min-height: 43px; margin: 3px 0; padding: 10px 12px; border-radius: 8px; color: #d7e0ec; font-size: .91rem; font-weight: 700; text-decoration: none; transition: background-color 180ms ease, color 180ms ease; }
.nav-link:hover, .nav-link:focus-visible { color: #fff; background: #153867; outline: none; }
.nav-link.active { color: #fff; background: var(--navy-2); box-shadow: inset 3px 0 var(--red); }
.sidebar-footer { position: absolute; right: 16px; bottom: 18px; left: 16px; padding-top: 14px; border-top: 1px solid #244465; }
.sidebar-user { margin: 0 8px 10px; color: #c8d3e2; font-size: .8rem; overflow-wrap: anywhere; }
.logout-button { width: 100%; border: 1px solid #46617f; color: #fff; background: transparent; }

.content { min-height: 100vh; margin-left: var(--sidebar); }
.topbar { display: flex; min-height: 68px; align-items: center; justify-content: space-between; gap: 20px; padding: 0 32px; border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar-title { font-size: .92rem; font-weight: 800; }
.site-link { color: var(--info); font-size: .84rem; font-weight: 800; text-decoration: none; }
.site-link:hover { text-decoration: underline; }
.page { width: min(1260px, calc(100% - 48px)); margin: 0 auto; padding: 30px 0 50px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-heading h1 { margin: 0; font-size: 1.65rem; line-height: 1.2; letter-spacing: -.025em; text-wrap: balance; }
.page-heading p { margin: 7px 0 0; color: var(--muted); font-size: .92rem; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 9px 15px; border: 0; border-radius: 8px; color: #fff; background: var(--red); font-size: .87rem; font-weight: 800; text-decoration: none; cursor: pointer; transition: background-color 160ms ease, transform 100ms ease; }
.button:hover { background: var(--red-dark); }
.button:focus-visible, .control:focus-visible { outline: 3px solid rgba(24, 87, 164, .24); outline-offset: 2px; }
.button:active { transform: translateY(1px); }
.button.secondary { border: 1px solid #bcc7d5; color: var(--ink); background: #fff; }
.button.secondary:hover { background: #f3f5f8; }
.button.danger { background: var(--danger); }
.button.small { min-height: 35px; padding: 7px 11px; font-size: .8rem; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-bottom: 24px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--line); }
.metric { padding: 20px; background: var(--surface); }
.metric span { color: var(--muted); font-size: .78rem; font-weight: 750; }
.metric strong { display: block; margin-top: 5px; font-size: 1.75rem; font-variant-numeric: tabular-nums; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.panel-header { display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 1rem; }
.panel-body { padding: 20px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 20px; }

.filters { display: grid; grid-template-columns: minmax(220px, 1fr) 190px 190px auto; gap: 10px; margin-bottom: 16px; }
.control { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #bcc7d5; border-radius: 8px; color: var(--ink); background: #fff; }
textarea.control { min-height: 118px; resize: vertical; }
textarea.compact-control { min-height: 84px; }
textarea.tall-control { min-height: 180px; }
textarea.article-editor { min-height: 360px; line-height: 1.65; }
label.field { display: grid; gap: 7px; color: #344054; font-size: .84rem; font-weight: 750; }
.field-label { display: block; margin-bottom: 7px; color: #344054; font-size: .84rem; font-weight: 750; }
.field-hint { color: var(--muted); font-size: .77rem; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid.single-column { grid-template-columns: 1fr; }
.check { display: flex; align-items: center; gap: 9px; min-height: 42px; font-size: .88rem; font-weight: 700; }
.check input { width: 18px; height: 18px; accent-color: var(--red); }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.heading-after-link { margin-top: 8px !important; }
.delete-form { margin-top: 18px; }
.narrow-panel { max-width: 680px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; border-bottom: 1px solid #e9edf2; text-align: left; vertical-align: middle; }
th { color: var(--muted); background: #f8f9fb; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
td { font-size: .87rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
.primary-cell { min-width: 205px; }
.primary-cell a { color: var(--ink); font-weight: 850; text-decoration: none; }
.primary-cell a:hover { color: var(--info); text-decoration: underline; }
.subtext { display: block; margin-top: 3px; color: var(--muted); font-size: .78rem; }
.status { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 9px; border-radius: 999px; color: var(--info); background: var(--info-bg); font-size: .74rem; font-weight: 850; white-space: nowrap; }
.status.inscrit { color: var(--success); background: var(--success-bg); }
.status.perdu { color: var(--danger); background: var(--danger-bg); }
.status.rendez_vous { color: var(--warning); background: var(--warning-bg); }
.status.published { color: var(--success); background: var(--success-bg); }
.status.scheduled { color: var(--warning); background: var(--warning-bg); }
.status.draft { color: var(--muted); background: #edf0f4; }

.flash, .errors { margin-bottom: 18px; padding: 13px 15px; border-radius: 8px; font-size: .87rem; }
.flash { color: var(--success); background: var(--success-bg); }
.errors { color: var(--danger); background: var(--danger-bg); }
.errors ul { margin: 6px 0 0; padding-left: 18px; }
.empty { padding: 38px 20px; color: var(--muted); text-align: center; }
.pagination { padding: 16px; border-top: 1px solid var(--line); }
.pagination nav > div:first-child { display: none; }
.pagination nav > div:last-child { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.pagination nav span, .pagination nav a { font-size: .82rem; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .6fr); gap: 20px; }
.identity { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0; }
.identity div { min-width: 180px; }
.identity dt { color: var(--muted); font-size: .74rem; font-weight: 800; text-transform: uppercase; }
.identity dd { margin: 5px 0 0; font-size: .92rem; overflow-wrap: anywhere; }
.message-box { margin-top: 20px; padding: 14px; border-radius: 8px; background: #f4f6f9; white-space: pre-wrap; }
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { position: relative; padding: 0 0 20px 22px; }
.timeline li::before { position: absolute; top: 5px; left: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); content: ""; }
.timeline li::after { position: absolute; top: 16px; bottom: 2px; left: 5px; width: 2px; background: var(--line); content: ""; }
.timeline li:last-child::after { display: none; }
.timeline p { margin: 0; font-size: .86rem; }
.timeline time { display: block; margin-top: 3px; color: var(--muted); font-size: .75rem; }

.login-body { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: var(--navy); }
.login-card { width: min(430px, 100%); padding: 32px; border-radius: 12px; background: #fff; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-card h1 { margin: 0; font-size: 1.45rem; letter-spacing: -.02em; }
.login-card > p { margin: -15px 0 24px; color: var(--muted); font-size: .9rem; }
.login-card .field + .field { margin-top: 16px; }
.login-card .button { width: 100%; margin-top: 20px; }
.password-control { position: relative; display: block; }
.password-control .control { padding-right: 50px; }
.password-toggle { position: absolute; top: 0; right: 0; display: grid; width: 44px; height: 42px; padding: 0; place-items: center; border: 0; border-radius: 0 8px 8px 0; color: var(--muted); background: transparent; cursor: pointer; transition: color 160ms ease, background-color 160ms ease; }
.password-toggle:hover { color: var(--ink); background: #f3f5f8; }
.password-toggle:focus-visible { color: var(--info); outline: 3px solid rgba(24, 87, 164, .24); outline-offset: 2px; }
.password-icon { width: 21px; height: 21px; }
.password-icon-hidden { display: none; }
.password-toggle[aria-pressed="true"] .password-icon-visible { display: none; }
.password-toggle[aria-pressed="true"] .password-icon-hidden { display: block; }

@media (max-width: 940px) {
  :root { --sidebar: 218px; }
  .dashboard-grid, .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  :root { --sidebar: 0px; }
  .sidebar { position: static; width: 100%; padding: 12px 16px; }
  .brand { justify-content: flex-start; padding: 0; }
  .brand > span:last-child { display: block; }
  .sidebar nav, .sidebar-footer { display: none; }
  .content { margin-left: 0; }
  .topbar { min-height: 56px; padding: 0 16px; }
  .page { width: min(100% - 28px, 1260px); padding-top: 22px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters, .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  th, td { padding: 11px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
.logo-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 92px;
  margin: 8px 0 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--canvas);
  color: var(--muted);
  font-size: .85rem;
}

.logo-preview img {
  width: auto;
  max-width: 180px;
  height: auto;
  max-height: 64px;
  object-fit: contain;
}

.portrait-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: .85rem;
}

.portrait-preview img {
  width: 80px;
  height: 96px;
  border: 1px solid var(--line);
  object-fit: cover;
}

.file-control {
  padding: 9px 10px;
}

.file-control::file-selector-button {
  min-height: 38px;
  margin-right: 12px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.file-control::file-selector-button:hover {
  border-color: var(--red);
  color: var(--red-dark);
}
