/* ============================================================
   VARIABLES
   ============================================================ */
:root {
  --navy: #17365d;
  --blue: #2f75b5;
  --blue-light: #eef4fb;
  --green: #2e7d32;
  --orange: #d97706;
  --red: #b91c1c;
  --text: #243447;
  --text-muted: #6c7a89;
  --border: #d7dee8;
  --bg: #f4f7fb;
  --white: #fff;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow: 0 2px 8px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12);

  --sidebar-w: 250px;
  --topbar-h: 62px;
  --transition: .25s ease;
}

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

/* ============================================================
   PAGE DE LOGIN
   ============================================================ */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 1000px;
  width: 100%;
  background: var(--white);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  min-height: 560px;
}

.auth-card {
  padding: 45px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Page de login seule (sans colonne latérale) */
.auth-container-single {
  grid-template-columns: 1fr;
  max-width: 460px;
  min-height: 0;
}

.auth-brand {
  text-align: center;
  margin-bottom: 30px;
}
.auth-title {
  font-size: 22px;
  margin: 0 0 4px;
  color: var(--navy);
}
.auth-logo {
  width: 62px;
  height: 62px;
  margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  color: white;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 1px;
}
img.auth-logo {
  display: block;
  background: transparent;
  object-fit: contain;
}
.auth-brand h1 {
  font-size: 22px;
  margin: 0 0 4px;
  color: var(--navy);
}
.auth-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}

.auth-form .form-group {
  margin-bottom: 16px;
}
.auth-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: white;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47,117,181,.15);
}

.password-wrapper {
  position: relative;
}
.toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 18px;
  opacity: .5;
  padding: 6px;
}
.toggle-password:hover { opacity: 1; }

.form-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.auth-link {
  font-size: 13px;
  color: var(--blue);
  text-decoration: none;
}
.auth-link:hover { text-decoration: underline; }

.auth-back-link {
  margin-top: 18px;
  text-align: center;
}
.auth-back-link a {
  color: var(--blue);
  text-decoration: none;
}
.auth-back-link a:hover { text-decoration: underline; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 16px;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-note {
  background: var(--blue-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.auth-note .auth-subtitle { margin: 0 0 12px; }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
}

/* ============================================================
   FORMULAIRES (tous contexts, pas seulement .auth-form)
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.form-control {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: white;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47,117,181,.15);
}
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c7a89' d='M6 8.5 1.5 4h9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.field-error {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  color: var(--red);
}
.form-help {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-muted);
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
}
.inline-form { display: inline; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-weight: 600;
  font-size: 14px;
  transition: all var(--transition);
  cursor: pointer;
}
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: #245d92; }
.btn-secondary {
  background: white;
  color: var(--navy);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); text-decoration: none; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.auth-footer {
  margin-top: 25px;
  text-align: center;
}
.small { font-size: 12px; }
.text-muted { color: var(--text-muted); }

/* Navigation feedback adapts to the browser's reported network quality. */
.navigation-progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 2000;
  height: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.navigation-progress.is-active { opacity: 1; }
.navigation-progress__bar {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 0 999px 999px 0;
  background: linear-gradient(90deg, #2f75b5, #54b7ee);
  box-shadow: 0 1px 8px rgba(47, 117, 181, .35);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .24s cubic-bezier(.22, 1, .36, 1);
  will-change: transform;
}
.navigation-progress.is-offline .navigation-progress__bar {
  background: linear-gradient(90deg, #ef4444, #f97316);
  box-shadow: 0 0 14px rgba(239, 68, 68, .45);
}
.navigation-loader {
  position: fixed;
  inset: 0;
  z-index: 1999;
  display: grid;
  place-items: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease, visibility .18s ease;
}
.navigation-loader.is-active {
  opacity: 1;
  visibility: visible;
}
.navigation-loader__content {
  display: grid;
  place-items: center;
  width: 5.75rem;
  height: 5.75rem;
  border: 1px solid rgba(15, 23, 42, .06);
  border-radius: 50%;
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 18px 40px rgba(15, 23, 42, .14);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transform: translateY(4px) scale(.96);
  transition: transform .2s ease;
}
.navigation-loader.is-active .navigation-loader__content {
  transform: translateY(0) scale(1);
}
.navigation-loader__ring {
  width: 3.75rem;
  height: 3.75rem;
  border-radius: 50%;
  background: conic-gradient(
    from 90deg,
    rgba(47, 117, 181, .12) 0deg,
    rgba(47, 117, 181, .12) 90deg,
    #2f75b5 250deg,
    #54b7ee 360deg
  );
  filter: drop-shadow(0 2px 6px rgba(47, 117, 181, .22));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 6px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 6px));
  animation: navigation-spin .8s linear infinite;
}
.navigation-loader.is-offline .navigation-loader__ring {
  background: conic-gradient(
    from 90deg,
    rgba(239, 68, 68, .12) 0deg,
    rgba(239, 68, 68, .12) 90deg,
    #ef4444 250deg,
    #f97316 360deg
  );
  filter: drop-shadow(0 2px 6px rgba(239, 68, 68, .2));
}
@keyframes navigation-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .navigation-progress__bar { transition: none; }
  .navigation-loader__content { transform: none; transition: none; }
  .navigation-loader__ring { animation-duration: 1.6s; }
}
.text-danger { color: var(--red); }

.auth-side {
  background: linear-gradient(135deg, var(--navy), var(--blue));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 45px 35px;
}
.auth-side-content h2 {
  font-size: 24px;
  margin: 0 0 15px;
}
.auth-side-content p {
  opacity: .9;
  line-height: 1.6;
  margin-bottom: 25px;
}
.auth-features {
  list-style: none;
  padding: 0;
  margin: 0;
}
.auth-features li {
  padding: 8px 0;
  font-size: 14px;
  opacity: .95;
}

/* Alerts */
.alert {
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  margin-bottom: 15px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.alert-success { background: #e8f5e9; color: var(--green); border-left: 4px solid var(--green); }
.alert-error, .alert-danger { background: #ffebee; color: var(--red); border-left: 4px solid var(--red); }
.alert-warning { background: #fff8e1; color: var(--orange); border-left: 4px solid var(--orange); }
.alert-info { background: var(--blue-light); color: var(--blue); border-left: 4px solid var(--blue); }
.alert-close {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  opacity: .5;
}
.alert-close:hover { opacity: 1; }

/* ============================================================
   LAYOUT APPLICATION (après login)
   ============================================================ */
.app-layout {
  min-height: 100vh;
}

.sidebar {
  width: 100%;
  background: var(--navy);
  color: white;
  display: flex;
  align-items: stretch;
  z-index: 100;
}
.sidebar-brand {
  flex: 0 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: white;
  text-decoration: none;
}
.sidebar-brand:hover,
.sidebar-brand:focus-visible {
  color: white;
  text-decoration: none;
}
.brand-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--blue), #4a90d9);
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  overflow: hidden;
}
.brand-logo img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  display: block;
}

.pwa-install-button {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1200;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  color: white;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
}
.pwa-install-button:hover {
  filter: brightness(1.08);
}
.pwa-install-button:focus-visible {
  outline: 3px solid white;
  outline-offset: 3px;
}
@media print {
  .pwa-install-button { display: none; }
}
.brand-text strong { display: block; font-size: 15px; }
.brand-text small { opacity: .7; font-size: 11px; }

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 15px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex: 0 0 auto;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: white;
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  transition: background var(--transition), border-color var(--transition);
}
.back-button:hover,
.back-button:focus-visible {
  background: var(--bg);
  border-color: var(--blue);
  color: var(--navy);
  text-decoration: none;
}
.back-button > span:first-child {
  font-size: 19px;
  line-height: 1;
}
.topbar-title {
  font-size: 18px;
  margin: 0;
  color: var(--navy);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}
.topbar-clock {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.user-dropdown { position: relative; }
.user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 25px;
  padding: 5px 12px 5px 5px;
  transition: all var(--transition);
}
.user-btn:hover { background: var(--bg); }
.user-btn .user-avatar { width: 30px; height: 30px; font-size: 13px; }
.user-btn .user-name { font-size: 13px; color: var(--text); }
.caret { font-size: 10px; color: var(--text-muted); }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: 6px;
  display: none;
  z-index: 200;
}
.dropdown-menu.open { display: block; }
.dropdown-menu a {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
}
.dropdown-menu a:hover {
  background: var(--bg);
  text-decoration: none;
}
.dropdown-menu hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.app-content {
  padding: 25px;
  flex: 1;
}

.workspace-modules {
  max-width: 960px;
  margin: 0 auto;
  padding-bottom: 16px;
}
.workspace-modules-intro {
  margin: 8px 0 18px;
}
.workspace-modules-eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.workspace-modules-intro h1 {
  margin: 0 0 6px;
  color: var(--navy);
  font-size: 22px;
  font-weight: 600;
  text-transform: uppercase;
}
.workspace-modules-intro p:last-child {
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 13px;
}
.workspace-module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.workspace-module-card {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "icon title state"
    "icon description state";
  align-items: center;
  column-gap: 14px;
  row-gap: 3px;
  padding: 16px 17px;
  border: 1px solid #e5eaf1;
  border-left: 4px solid #c7d2fe;
  border-radius: 6px;
  background: linear-gradient(90deg, #f8fbff 0%, #fff 55%);
  color: #475569;
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
}
.workspace-module-card:hover,
.workspace-module-card:focus-visible {
  transform: translateX(4px);
  border-color: var(--blue);
  border-left-color: var(--blue);
  background: white;
  box-shadow: var(--shadow-sm);
  color: var(--navy);
  text-decoration: none;
}
.workspace-module-card:focus-visible {
  outline: 3px solid rgba(47, 117, 181, .3);
  outline-offset: 2px;
}
.workspace-module-icon {
  grid-area: icon;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: #eef4ff;
  color: var(--blue);
  font-size: 22px;
  line-height: 1;
}
.workspace-module-title {
  grid-area: title;
  min-width: 0;
  color: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}
.workspace-module-description {
  grid-area: description;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}
.workspace-module-state {
  grid-area: state;
  align-self: center;
  color: var(--blue);
  font-size: 12px;
  white-space: nowrap;
}
.workspace-module-state span {
  margin-left: 3px;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  margin-bottom: 22px;
}
.page-header h1 {
  font-size: 24px;
  margin: 0 0 5px;
  color: var(--navy);
}

/* ============================================================
   STATS CARDS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat-icon {
  font-size: 28px;
  width: 54px;
  height: 54px;
  background: var(--blue-light);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}
.stat-body { min-width: 0; }
.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
}

/* ============================================================
   CARTES & GRILLES
   ============================================================ */
.footer {
  padding: 18px 25px;
  border-top: 1px solid var(--border);
  background: white;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.card-title {
  font-size: 17px;
  margin: 0 0 16px;
  color: var(--navy);
}
.card-narrow {
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.detail-list {
  display: grid;
  grid-template-columns: minmax(120px, 40%) 1fr;
  gap: 0;
  margin: 0;
  font-size: 14px;
}
.detail-list dt {
  font-weight: 600;
  color: var(--text-muted);
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--border);
}
.detail-list dd {
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}
.detail-list dt:last-of-type,
.detail-list dd:last-of-type { border-bottom: 0; }

/* ============================================================
   PANELS
   ============================================================ */
.panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.panel h2 {
  font-size: 17px;
  margin: 0 0 15px;
  color: var(--navy);
}

/* ============================================================
   MESSAGES
   ============================================================ */
.messages-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 300;
  max-width: 380px;
  width: calc(100% - 40px);
}
.messages-container .alert {
  box-shadow: var(--shadow-lg);
  background: white;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablette */
@media (max-width: 992px) {
  .auth-container {
    grid-template-columns: 1fr;
    max-width: 460px;
    min-height: 0;
  }
  .auth-side { display: none; }
  .auth-card { padding: 35px 28px; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    min-height: 60px;
  }
  .topbar-clock { display: none; }
  .user-btn .user-name { display: none; }
  .back-button { padding: 6px 10px; }
  .app-content { padding: 18px 14px; }
  .footer { padding: 15px 14px; }
  .page-header h1 { font-size: 20px; }
  .stat-value { font-size: 20px; }

  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .workspace-module-grid { grid-template-columns: 1fr; }
  .page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .page-header .btn { width: 100%; }
  .card-narrow { max-width: 100%; }
  .detail-list { grid-template-columns: 1fr; }
  .detail-list dt {
    padding-bottom: 0;
    border-bottom: 0;
  }
  .detail-list dd { padding-top: 2px; }
}

/* Petit mobile */
@media (max-width: 480px) {
  .auth-page { padding: 12px; }
  .auth-card { padding: 28px 20px; }
  .auth-brand h1 { font-size: 19px; }
  .auth-title { font-size: 19px; }
  .stats-grid { grid-template-columns: 1fr; }
  .messages-container { top: auto; bottom: 15px; right: 15px; left: 15px; }
  .card { padding: 18px 15px; }
  .stat-card { padding: 16px; gap: 12px; }
  .stat-icon { width: 44px; height: 44px; font-size: 22px; }
  .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .form-actions .btn,
  .form-actions .inline-form { width: 100%; }
  .form-actions .inline-form .btn { width: 100%; }
  .btn { padding: 12px 16px; }
}

/* ============================================================
   PAGE PROFIL
   ============================================================ */
.profile-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: start;
}

/* Carte identité */
.profile-sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + 20px);
}

.profile-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 25px 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.profile-avatar-lg {
  width: 90px;
  height: 90px;
  margin: 0 auto 15px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  color: white;
  display: grid;
  place-items: center;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 1px;
  box-shadow: 0 4px 14px rgba(47,117,181,.35);
}

.profile-name {
  font-size: 17px;
  margin: 0 0 4px;
  color: var(--navy);
}

.profile-username {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 12px;
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.badge-role {
  background: var(--blue-light);
  color: var(--blue);
  margin-bottom: 18px;
}

.badge-success {
  background: #e8f5e9;
  color: var(--green);
}

.badge-danger {
  background: #ffebee;
  color: var(--red);
}

.profile-meta-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.profile-meta-item:first-of-type {
  border-top: 0;
}
.meta-label {
  color: var(--text-muted);
}
.meta-value {
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

/* Formulaire */
.profile-main {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

.form-group {
  display: flex;
  flex-direction: column;
}
.form-group-full {
  grid-column: 1 / -1;
}
.form-group label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.form-group input {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: white;
}
.form-group input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47,117,181,.15);
}
.form-group input:disabled {
  background: #f5f7fa;
  color: var(--text-muted);
  cursor: not-allowed;
}
.form-group-readonly input,
.form-group-readonly input:disabled {
  background: #f5f7fa;
  color: var(--text-muted);
  border-style: dashed;
}
.form-group small {
  margin-top: 4px;
  font-size: 11px;
}

.form-actions {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Bouton warning */
.btn-warning {
  background: var(--orange);
  color: white;
}
.btn-warning:hover {
  background: #b45a00;
}

.btn-danger {
  background: var(--red);
  color: white;
}
.btn-danger:hover {
  background: #991b1b;
}

/* Panel danger */
.panel-danger {
  border-left: 4px solid var(--red);
}

/* Responsive profil */
@media (max-width: 992px) {
  .profile-layout {
    grid-template-columns: 1fr;
  }
  .profile-sidebar {
    position: static;
  }
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .profile-avatar-lg {
    width: 75px;
    height: 75px;
    font-size: 30px;
  }
}

/* ============================================================
   TABLEAU DE BORD « VRAI » (mêmes chiffres que l'app mobile)
   ============================================================ */
.text-navy { color: var(--navy); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-blue { color: var(--blue); }

/* En-tête en dégradé (équivalent du header Flutter) */
.dash-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%);
  color: white;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.dash-hero h1 {
  font-size: 22px;
  margin: 0;
  color: white;
  font-weight: 700;
}
.dash-hero-sub {
  margin: 8px 0 0;
  opacity: .85;
  font-size: 13px;
}
.dash-hero-stat {
  text-align: right;
  min-width: 170px;
}
.dash-hero-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  opacity: .8;
}
.dash-hero-value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.15;
}

/* Barre de progression */
.progress {
  height: 10px;
  background: #e3eaf2;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}
.progress .progress-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--green);
  transition: width var(--transition);
}
.progress .progress-bar.warn { background: var(--orange); }
.progress-inverse {
  background: rgba(255, 255, 255, .28);
  margin: 12px 0 0;
}
.progress-inverse .progress-bar {
  background: white;
}

/* Lignes « Total dû / Encaissé / Reste dû » */
.mini-stat { padding: 10px 0 0; }
.mini-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}
.mini-value {
  font-size: 20px;
  font-weight: 700;
}

/* Titre de panneau aligné (comme un SectionCard Flutter) */
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}
.panel-head h2 { margin: 0; }

/* Groupe de cartes sans marge basse (dans un panneau) */
.stats-grid.no-margin { margin-bottom: 0; }

/* Histogramme d'évolution des paiements (pur CSS, sans CDN) */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 190px;
  padding-top: 22px;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
}
.bar-fill {
  width: 100%;
  max-width: 46px;
  background: linear-gradient(180deg, #4a90d9, var(--blue));
  border-radius: 6px 6px 0 0;
  min-height: 2px;
}
.bar-value {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  white-space: nowrap;
}
.bar-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Répartition par régime / niveau */
.repart-row { margin-bottom: 14px; }
.repart-row:last-child { margin-bottom: 0; }
.repart-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 6px;
}
.repart-label { font-weight: 600; color: var(--text); }
.repart-row .progress { margin-bottom: 0; }

/* Derniers recouvrements */
.recov-list { display: flex; flex-direction: column; }
.recov-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 0;
  border-top: 1px solid var(--border);
}
.recov-item:first-child { border-top: 0; }
.recov-main strong {
  display: block;
  font-size: 14px;
  color: var(--text);
}
.recov-meta { font-size: 12px; color: var(--text-muted); }
.recov-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.recov-amounts { text-align: right; }
.recov-amount { font-size: 14px; font-weight: 700; }

/* Badges de statut supplémentaires */
.badge-warning { background: #fff8e1; color: var(--orange); }
.badge-danger { background: #ffebee; color: var(--red); }
.badge-info { background: var(--blue-light); color: var(--blue); }

/* Mobile : empilement des paquets */
@media (max-width: 768px) {
  .dash-hero { padding: 18px; }
  .dash-hero-stat { text-align: left; min-width: 0; }
  .dash-hero-value { font-size: 26px; }
  .bar-chart { height: 150px; gap: 6px; }
  .bar-value { font-size: 10px; }
  .recov-item { align-items: flex-start; }
  .recov-right { justify-content: space-between; width: 100%; }
  .recov-amounts { text-align: right; }
}

/* ============================================================
   ADMINISTRATION (hub, liste et formulaires utilisateurs)
   ============================================================ */

/* En-tête avec bouton d'action */
.page-header.with-action {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.page-header.with-action .btn { flex-shrink: 0; }

/* Sous-navigation de la section administration */
.admin-subnav {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  flex-wrap: wrap;
}
.admin-subnav-item {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}
.admin-subnav-item:hover { background: var(--bg); text-decoration: none; }
.admin-subnav-item.active {
  background: var(--blue-light);
  color: var(--blue);
}

/* Accessibilité : labels de filtres masqués visuellement */
.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;
}

/* Barre de filtres */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-field input,
.filter-field select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  font-size: 13px;
  color: var(--text);
  min-width: 150px;
}
.filter-field input:focus,
.filter-field select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(74, 144, 217, .15);
}
.filter-grow { flex: 1 1 240px; }
.filter-grow input { width: 100%; }

/* Tableau de données */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table .col-actions { text-align: right; }
.cell-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.cell-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cell-actions form { display: inline; }
.row-muted td { opacity: .6; }

/* Boutons compacts */
.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 7px;
}

/* État vide */
.empty-state {
  text-align: center;
  padding: 34px 16px;
}
.empty-state .btn { margin-top: 10px; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 18px;
  font-size: 13px;
}
.page-link {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: white;
}
.page-link:hover {
  border-color: var(--blue);
  color: var(--blue);
  text-decoration: none;
}
.page-info { color: var(--text-muted); }

/* Erreurs de formulaire */
.field-errors { margin-top: 6px; }
.field-errors p {
  color: var(--red);
  font-size: 12px;
  margin: 0 0 3px;
}
.form-error-summary {
  background: #ffebee;
  border: 1px solid #ffcdd2;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.form-error-summary ul {
  margin: 0;
  padding-left: 18px;
  color: var(--red);
  font-size: 13px;
}
.form-group-check { grid-column: 1 / -1; }
.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}
.checkbox-line input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

/* Modules du hub administration */
.admin-modules {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.admin-module-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
}
a.admin-module-card:hover {
  border-color: var(--blue);
  text-decoration: none;
  background: #f8fafc;
}
.admin-module-icon { font-size: 24px; }
.admin-module-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
}
.admin-module-disabled { opacity: .55; }

/* Mobile : tableau et filtres */
@media (max-width: 768px) {
  .filters-bar .btn { flex: 1 1 auto; }
  .filter-field { flex: 1 1 140px; }
  .filter-field input,
  .filter-field select { width: 100%; min-width: 0; }
  .data-table { font-size: 12px; }
  .data-table th,
  .data-table td { padding: 8px; }
}
