/* ============================================================
   Registre Central Helvetia — Styles
   ============================================================ */

:root {
  --primary: #6E1611;
  --primary-dark: #4A0E0B;
  --primary-light: #8B2E28;
  --primary-bg: #F5EDE0;
  --primary-bg-hover: #EDE4D5;
  --text: #1a1a1a;
  --text-secondary: #555;
  --text-muted: #8a7e72;
  --border: #ddd5c8;
  --border-light: #ece6da;
  --bg: #F5EDE0;
  --white: #FEFCF7;
  --success: #2d7a3a;
  --success-bg: #e8f5e9;
  --warning: #e67e22;
  --warning-bg: #fef3e2;
  --danger: #c0392b;
  --danger-bg: #fce8e6;
  --info: #2980b9;
  --info-bg: #e3f2fd;
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --sidebar-width: 260px;
  --sidebar-collapsed: 64px;
  --topbar-height: 56px;
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
input, select, textarea, button { font: inherit; }

/* ============================================================
   Layout: Sidebar + Main
   ============================================================ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition), transform var(--transition);
  overflow-x: hidden;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border-light);
  min-height: 72px;
  flex-shrink: 0;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.sidebar-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.2;
}

.sidebar-collapse-btn {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover { color: var(--text); background: var(--primary-bg); }
.sidebar-collapse-btn svg { width: 18px; height: 18px; }

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  color: var(--text-secondary);
  border-radius: var(--radius);
  margin-bottom: 2px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
  font-size: 0.9rem;
  position: relative;
}
.nav-item:hover { background: var(--primary-bg); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary); color: var(--white); }
.nav-item.active:hover { background: var(--primary-light); }
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }

/* Admin submenu group */
.nav-group-toggle {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  font: inherit;
}
.nav-group-toggle .chevron {
  margin-left: auto;
  transition: transform 0.2s;
  width: 16px; height: 16px;
}
.nav-group.open .nav-group-toggle .chevron { transform: rotate(90deg); }

.nav-group-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.nav-group.open .nav-group-items { max-height: 400px; }

.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px 7px 44px;
  color: var(--text-secondary);
  border-radius: var(--radius);
  margin-bottom: 1px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
  font-size: 0.85rem;
}
.nav-sub-item:hover { background: var(--primary-bg); color: var(--text); text-decoration: none; }
.nav-sub-item.active { background: var(--primary); color: var(--white); }
.nav-sub-item.active:hover { background: var(--primary-light); }

/* Sidebar doyen */
.sidebar-doyen {
  border-top: 1px solid var(--border-light);
  padding: 10px 12px;
  flex-shrink: 0;
  overflow-y: auto;
}
.sidebar-doyen:empty { display: none; }
.sidebar-doyen-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 4px 6px;
}
.sidebar-doyen-item {
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}
.sidebar-doyen-item:hover { background: var(--primary-bg); }
.sidebar-doyen-section {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  font-weight: 600;
}
.sidebar-doyen-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-doyen-detail {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.sidebar.collapsed .sidebar-doyen { display: none; }

/* Sidebar footer */
.sidebar-footer {
  border-top: 1px solid var(--border-light);
  padding: 12px 16px;
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Collapsed sidebar (desktop) ---- */
.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .sidebar-user-name,
.sidebar.collapsed .nav-group-items,
.sidebar.collapsed .chevron,
.sidebar.collapsed .badge { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 20px 8px 16px; gap: 0; }
.sidebar.collapsed .sidebar-collapse-btn { margin-left: 0; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .sidebar-footer { padding: 12px 8px; }
.sidebar.collapsed .sidebar-user { justify-content: center; }
.sidebar.collapsed .sidebar-footer-row { justify-content: center; }
.sidebar.collapsed .btn-logout span { display: none; }

/* Tooltip on collapsed hover */
.sidebar.collapsed .nav-item:hover::after,
.sidebar.collapsed .nav-sub-item:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--text);
  color: var(--white);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  white-space: nowrap;
  z-index: 200;
  pointer-events: none;
}

/* ---- Main content ---- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 28px 32px;
  min-height: 100vh;
  transition: margin-left var(--transition);
  max-width: 100%;
}
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed); }

.main-content > .page-wrapper {
  max-width: 1100px;
  margin: 0 auto;
}

/* ---- Mobile topbar ---- */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  z-index: 90;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.mobile-topbar-logo { width: 28px; height: 28px; }
.mobile-topbar-title { font-weight: 700; font-size: 0.9rem; color: var(--primary); }

.hamburger-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--primary);
  display: flex;
}
.hamburger-btn svg { width: 24px; height: 24px; stroke: var(--primary); }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}
.sidebar-backdrop.visible { display: block; }

/* ---- Mobile responsive ---- */
@media (max-width: 1023px) {
  .mobile-topbar { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar .sidebar-collapse-btn { display: none; }
  .main-content {
    margin-left: 0 !important;
    padding: 16px;
    padding-top: calc(var(--topbar-height) + 16px);
  }
}

@media (max-width: 640px) {
  .main-content { padding: 12px; padding-top: calc(var(--topbar-height) + 12px); }
  .form-row { flex-direction: column; }
  .directory-filters { flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .btn-group { flex-direction: column; }
  .table-wrap { font-size: 0.85rem; }
}

/* ============================================================
   Login Page (full-screen, no sidebar)
   ============================================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.login-box {
  background: var(--white);
  padding: 48px 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.login-box .logo img { width: 64px; margin-bottom: 16px; }
.login-box h1 { font-size: 1.3rem; color: var(--primary); margin-bottom: 8px; font-weight: 700; }
.login-box #login-subtitle { color: var(--text-muted); margin-bottom: 24px; font-size: 0.9rem; }

.otp-input {
  text-align: center;
  font-size: 1.8rem !important;
  letter-spacing: 8px;
  font-weight: 600;
  color: var(--primary);
}

/* ============================================================
   Components
   ============================================================ */

/* ---- Cards ---- */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.card-header h2 { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.card-header h3 { font-size: 1rem; font-weight: 600; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  border: none;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: var(--primary-bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--primary-bg-hover); }
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icon { padding: 6px; background: none; border: none; color: var(--text-muted); cursor: pointer; display: flex; }
.btn-icon:hover { color: var(--text); }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.8rem;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
}
.btn-logout:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.btn-logout svg { width: 16px; height: 16px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(110,22,17,0.1); }
textarea.form-control { resize: vertical; }
select.form-control { cursor: pointer; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; padding: 10px 12px; border-bottom: 2px solid var(--border); }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border-light); font-size: 0.9rem; }
tbody tr:hover { background: var(--primary-bg); }
td.actions { white-space: nowrap; }

/* ---- Tableur (editable grid) view for Members ---- */
.view-toggle { display: inline-flex; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.view-toggle button {
  background: var(--white);
  border: none;
  padding: 5px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s;
}
.view-toggle button + button { border-left: 1px solid var(--border); }
.view-toggle button:hover { background: var(--primary-bg); }
.view-toggle button.active { background: var(--primary); color: var(--white); }

.grid-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.grid-toolbar .btn-undo {
  background: var(--primary-bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.grid-toolbar .btn-undo:hover:not(:disabled) { background: var(--primary-bg-hover); }
.grid-toolbar .btn-undo:disabled { opacity: 0.4; cursor: not-allowed; }
.grid-toolbar .btn-undo .count {
  background: var(--primary);
  color: var(--white);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 0.7rem;
  font-weight: 700;
}

.grid-wrap {
  overflow: auto;
  max-height: calc(100vh - 260px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
}
table.grid {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}
table.grid thead th {
  position: sticky;
  top: 0;
  background: var(--primary-bg);
  z-index: 2;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border-light);
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
table.grid thead th.col-sticky {
  left: 0;
  z-index: 3;
}
table.grid tbody td {
  padding: 0;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  background: var(--white);
  vertical-align: middle;
  position: relative;
  min-width: 120px;
  max-width: 280px;
}
table.grid tbody td.col-sticky {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--white);
  font-weight: 600;
  padding: 6px 10px;
  white-space: nowrap;
}
table.grid tbody tr:hover td { background: #faf6ed; }
table.grid tbody tr:hover td.col-sticky { background: #faf6ed; }

.grid-cell-input,
.grid-cell-select,
.grid-cell-textarea {
  width: 100%;
  border: 2px solid transparent;
  padding: 6px 8px;
  background: transparent;
  font: inherit;
  color: inherit;
  outline: none;
  border-radius: 0;
  resize: none;
}
.grid-cell-textarea { min-height: 32px; max-height: 120px; overflow-y: auto; }
.grid-cell-input:focus,
.grid-cell-select:focus,
.grid-cell-textarea:focus {
  border-color: var(--primary);
  background: var(--white);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.grid-cell-select { cursor: pointer; appearance: none; padding-right: 20px; }
.grid-cell-checkbox { display: flex; align-items: center; justify-content: center; padding: 6px; }
.grid-cell-checkbox input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

td.grid-cell.is-dirty::after,
td.grid-cell.is-saving::after,
td.grid-cell.is-saved::after,
td.grid-cell.is-error::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  pointer-events: none;
}
td.grid-cell.is-dirty::after { background: var(--warning); }
td.grid-cell.is-saving::after { background: var(--info); animation: pulse 1s infinite; }
td.grid-cell.is-saved::after { background: var(--success); }
td.grid-cell.is-error::after { background: var(--danger); }
td.grid-cell.is-disabled { background: var(--border-light); }
td.grid-cell.is-disabled .grid-cell-input,
td.grid-cell.is-disabled .grid-cell-select,
td.grid-cell.is-disabled .grid-cell-textarea { cursor: not-allowed; color: var(--text-muted); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ---- Badge ---- */
.badge {
  background: var(--danger);
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: 6px;
}

/* ---- Tags ---- */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--primary-bg);
  color: var(--text-secondary);
}
.tag-active { background: var(--success-bg); color: var(--success); }
.tag-ancien { background: var(--info-bg); color: var(--info); }
.tag-deceased { background: var(--border-light); color: var(--text-muted); }

/* ---- Lang switch ---- */
.lang-switch { display: flex; gap: 4px; }
.lang-switch button {
  background: var(--primary-bg);
  border: none;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.lang-switch button.active { background: var(--primary); color: var(--white); }

/* ---- Toast ---- */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius); color: var(--white); font-size: 0.9rem; font-weight: 500; animation: slideIn 0.3s ease; box-shadow: var(--shadow-md); max-width: 360px; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- Spinner ---- */
.spinner { width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.pagination button { padding: 6px 12px; border: 1px solid var(--border); background: var(--white); border-radius: var(--radius-sm); cursor: pointer; font-size: 0.85rem; }
.pagination button.active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--white); border-radius: var(--radius-lg); padding: 28px; max-width: 500px; width: 100%; box-shadow: var(--shadow-lg); }
.modal h2 { font-size: 1.1rem; margin-bottom: 16px; color: var(--primary); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ============================================================
   Page-specific styles
   ============================================================ */

/* ---- Directory ---- */
.directory-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.directory-filters .form-control { flex: 1; min-width: 140px; }

.member-list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s;
  border-radius: var(--radius);
}
.member-list-item:hover { background: var(--primary-bg); }
.member-list-item.deceased { opacity: 0.6; }

.avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.member-list-item .info { flex: 1; min-width: 0; }
.member-list-item .name { font-weight: 600; font-size: 0.95rem; }
.member-list-item .name em { font-weight: 400; color: var(--text-secondary); }
.member-list-item .meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.number-badge {
  background: var(--primary-bg);
  color: var(--primary);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}

/* ---- Stats grid (dashboard) ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); text-align: center; border-top: 3px solid var(--primary); }
.stat-card .number { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* ---- Doyen cards ---- */
.doyen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.doyen-card { background: var(--primary-bg); border-radius: var(--radius); padding: 16px; cursor: pointer; transition: all 0.15s; border-left: 3px solid var(--primary); }
.doyen-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.doyen-card .section-name { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; }
.doyen-card .name { font-weight: 600; margin-top: 4px; }
.doyen-card .details { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }

/* ---- Profile ---- */
.profile-header { display: flex; gap: 24px; align-items: flex-start; margin-bottom: 24px; }
.profile-photo {
  width: 100px; height: 100px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.profile-photo img { width: 100%; height: 100%; object-fit: cover; }
.profile-name h1 { font-size: 1.5rem; }
.vulgo { color: var(--text-secondary); font-style: italic; margin-top: 2px; }
.memberships { display: flex; gap: 8px; flex-wrap: wrap; }
.membership-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
}
.membership-section { font-weight: 600; color: var(--primary); font-size: 0.85rem; }
.membership-number { font-weight: 700; font-size: 1rem; color: var(--text); }
.membership-type { font-size: 0.8rem; color: var(--text-muted); }

.profile-section { margin-bottom: 20px; }
.profile-section h3 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--primary); margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border-light); }
.profile-field { display: flex; gap: 12px; margin-bottom: 6px; }
.profile-field .label { font-size: 0.85rem; color: var(--text-muted); min-width: 180px; width: 180px; flex-shrink: 0; }
.profile-field .value { font-size: 0.9rem; }
.profile-cursus { white-space: pre-wrap; font-size: 0.9rem; line-height: 1.6; color: var(--text-secondary); background: var(--primary-bg); padding: 14px; border-radius: var(--radius); }

.relationship-link { display: inline-block; padding: 2px 8px; background: var(--primary-bg); border-radius: var(--radius-sm); font-size: 0.85rem; margin: 2px; }
.relationship-links { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---- Reference search fields (Leibbursch/Leibfux) ---- */
.ref-field { position: relative; }
.ref-results { position: absolute; top: 100%; left: 0; right: 0; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); z-index: 50; max-height: 200px; overflow-y: auto; }
.ref-results:empty { display: none; }
.ref-result-item { padding: 8px 12px; cursor: pointer; font-size: 0.85rem; border-bottom: 1px solid var(--border-light); }
.ref-result-item:hover { background: var(--primary-bg); }
.ref-result-item:last-child { border-bottom: none; }
.ref-no-results { padding: 8px 12px; font-size: 0.85rem; color: var(--text-muted); }
.ref-selected { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.ref-tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; }
.ref-tag button { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1rem; padding: 0 2px; line-height: 1; }
.ref-tag button:hover { color: var(--danger); }
.filiation-readonly { display: flex; flex-wrap: wrap; gap: 4px; min-height: 36px; align-items: center; padding: 4px 0; }

/* Audit detail rows */
.audit-row.has-details { cursor: pointer; }
.audit-row.has-details:hover { background: var(--primary-bg); }
.audit-detail-row { display: none; }
.audit-row.open + .audit-detail-row { display: table-row; }
.audit-detail-row td { padding: 12px 16px !important; background: var(--primary-bg); }
.audit-details { font-size: 0.85rem; }
.audit-details .diff-table { margin-top: 6px; font-size: 0.8rem; }
.audit-details .diff-table th { font-size: 0.7rem; }

/* ---- Livre d'Or (Book view) ---- */
.book-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.book-nav-info { font-size: 0.85rem; color: var(--text-muted); }

.book-container {
  display: flex;
  align-items: stretch;
  gap: 12px;
  justify-content: center;
}

.book {
  display: flex;
  max-width: 1000px;
  width: 100%;
  min-height: 640px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 40px rgba(110,22,17,0.06);
  overflow: hidden;
  user-select: none;
  font-family: Georgia, 'Times New Roman', serif;
}

.book-page {
  flex: 1;
  padding: 28px 24px;
  overflow-y: auto;
  min-height: 640px;
}

.book-page-left {
  background: linear-gradient(to right, var(--white) 96%, var(--primary-bg-hover));
}
.book-page-right {
  background: linear-gradient(to left, var(--white) 96%, var(--primary-bg-hover));
}

.book-spine {
  width: 3px;
  background: linear-gradient(to bottom, var(--border), var(--primary), var(--border));
  flex-shrink: 0;
  position: relative;
}
.book-spine::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: -6px; right: -6px;
  background: linear-gradient(to right, transparent, rgba(0,0,0,0.03), transparent);
}

.book-arrow {
  background: var(--white);
  border: 1px solid var(--border);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  box-shadow: var(--shadow);
  align-self: center;
}
.book-arrow:hover:not(:disabled) { background: var(--primary); color: var(--white); }
.book-arrow:disabled { opacity: 0.3; cursor: default; }

/* Book entries (multiple per page) */
.book-entry {
  padding: 12px 8px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.15s;
}
.book-entry:last-child { border-bottom: none; }
.book-entry:hover { background: var(--primary-bg); border-radius: var(--radius-sm); }
.book-deceased { opacity: 0.55; }

.book-entry-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 3px;
}

.book-entry-number {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 36px;
}

.book-entry-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.book-entry-name em {
  font-weight: 400;
  color: var(--text-secondary);
}

.book-entry-fields {
  padding-left: 46px;
}

.book-entry-line {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.6;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.book-entry-label {
  color: var(--primary);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-right: 4px;
}

.book-entry-cursus {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 4px;
  white-space: pre-wrap;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  border-top: 1px dotted var(--border-light);
  padding-top: 4px;
}

.book-page-number {
  text-align: center;
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: Georgia, 'Times New Roman', serif;
  letter-spacing: 0.05em;
}

.book-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--border);
}

/* Mobile book */
@media (max-width: 768px) {
  .book {
    flex-direction: column;
    min-height: auto;
  }
  .book-page { min-height: auto; padding: 20px 16px; }
  .book-page-left, .book-page-right { background: var(--white); }
  .book-spine { width: auto; height: 2px; background: linear-gradient(to right, var(--border), var(--primary), var(--border)); }
  .book-spine::before { display: none; }
  .book-arrow { width: 36px; height: 36px; font-size: 1.2rem; }
}

/* ---- Family tree ---- */
/* ---- Family tree (top-down) ---- */
.tree-container { min-height: 200px; overflow-x: auto; padding: 16px 0; }

/* Each family is a top-down tree */
.tree-family {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin: 0 24px 32px 0;
  vertical-align: top;
}

/* A tree node with its children below */
.tree-node-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* The person card */
.tree-person {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius);
  background: var(--white);
  border: 2px solid var(--primary);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.8rem;
  white-space: nowrap;
  box-shadow: var(--shadow);
  position: relative;
}
.tree-person:hover { background: var(--primary); color: var(--white); }
.tree-person:hover .node-number,
.tree-person:hover .node-vulgo { color: rgba(255,255,255,0.7); }
.tree-person.deceased { opacity: 0.5; border-color: var(--border); }
.tree-person.ehren { border-style: dashed; border-color: var(--info); }
.tree-person.ehren:hover { background: var(--info); border-color: var(--info); }

/* Godfather/godchild tags on person card */
.tree-person-wrap { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tree-godfathers, .tree-godchildren { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
.tree-godfather-tag {
  font-size: 0.6rem;
  background: var(--info-bg);
  color: var(--info);
  padding: 1px 6px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  border: 1px dashed var(--info);
}
.tree-godfather-tag:hover { background: var(--info); color: var(--white); }
.tree-godchild-tag {
  font-size: 0.6rem;
  background: var(--warning-bg);
  color: var(--warning);
  padding: 1px 6px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  border: 1px dashed var(--warning);
}
.tree-godchild-tag:hover { background: var(--warning); color: var(--white); }
.node-number { color: var(--primary); font-weight: 700; font-size: 0.75rem; }
.node-name { font-weight: 600; }
.node-vulgo { color: var(--text-muted); font-style: italic; font-size: 0.78rem; }
.node-rel-tag {
  font-size: 0.55rem;
  background: var(--info-bg);
  color: var(--info);
  padding: 1px 5px;
  border-radius: 6px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Vertical connector from parent down */
.tree-vline {
  width: 2px;
  height: 16px;
  background: var(--primary);
  margin: 0 auto;
}
.tree-vline.ehren { background: none; border-left: 2px dashed var(--info); }

/* Horizontal row of children */
.tree-children-row {
  display: flex;
  justify-content: center;
  gap: 0;
  position: relative;
}

/* Each child column */
.tree-child-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

/* Horizontal connector line across children */
.tree-hline {
  position: absolute;
  top: 0;
  height: 2px;
  background: var(--primary);
}
.tree-hline.ehren { background: none; border-top: 2px dashed var(--info); }

/* Vertical line from hline down to child */
.tree-child-col::before {
  content: '';
  width: 2px;
  height: 16px;
  background: var(--primary);
  flex-shrink: 0;
}
.tree-child-col.ehren-col::before {
  background: none;
  border-left: 2px dashed var(--info);
}

/* Spacing between children */
.tree-child-col { padding: 0 8px; }

/* Search highlight */
.tree-item { display: contents; }

/* ---- Pending changes ---- */
.change-card { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.change-card-header { padding: 12px 16px; background: var(--primary-bg); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.change-card-body { padding: 16px; }
.diff-table { width: 100%; }
.diff-table th { font-size: 0.75rem; }
.diff-old { color: var(--danger); }
.diff-new { color: var(--success); font-weight: 500; }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state h2 { color: var(--text-secondary); margin-bottom: 8px; }

/* ---- Utilities ---- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }

@media (max-width: 640px) {
  .profile-header { flex-direction: column; align-items: center; text-align: center; }
  .profile-field { flex-direction: column; gap: 2px; }
  .profile-field .label { min-width: 0; }
}

/* ============================================================
   Events
   ============================================================ */

.events-section { margin-bottom: 24px; }
.events-section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--primary);
}

.event-card {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 4px solid var(--primary);
}
.event-card:hover { box-shadow: var(--shadow-md); }

.event-date-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  padding: 8px;
  background: var(--primary-bg);
  border-radius: var(--radius);
  flex-shrink: 0;
}
.event-day { font-size: 1.5rem; font-weight: 700; color: var(--primary); line-height: 1; }
.event-month { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--primary); }
.event-year { font-size: 0.7rem; color: var(--text-muted); }

.event-content { flex: 1; min-width: 0; }
.event-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.event-title { font-size: 1rem; font-weight: 700; color: var(--text); margin: 0; }
.event-meta {
  display: flex;
  gap: 16px;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.event-meta span { display: flex; align-items: center; gap: 4px; }
.event-meta svg { width: 14px; height: 14px; }

.event-details {}
.event-details p {
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  border-top: 1px solid var(--border-light);
  padding-top: 10px;
}

.event-actions { margin-top: 8px; display: flex; gap: 6px; }

.event-past-item .event-card { opacity: 0.5; border-left-color: var(--border); }
.event-past-item .event-card:hover { opacity: 0.8; }

@media (max-width: 640px) {
  .event-card { flex-direction: column; gap: 10px; }
  .event-date-badge { flex-direction: row; gap: 6px; min-width: 0; }
}

/* Upload progress bar */
.upload-progress {
  display: flex;
  align-items: center;
  gap: 12px;
}
.upload-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.2s;
}
.upload-progress-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 120px;
}

/* ============================================================
   Feuille Centrale — Catalogue & PDF Viewer
   ============================================================ */

.feuille-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.feuille-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  border: 1px solid var(--border-light);
}
.feuille-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--primary);
}

.feuille-card-icon {
  color: var(--primary);
  margin-bottom: 14px;
}
.feuille-card-icon svg {
  width: 48px;
  height: 48px;
}

.feuille-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.3;
  word-break: break-word;
}

.feuille-card-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.feuille-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  padding: 0 !important;
  font-size: 1.1rem;
  line-height: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.feuille-card:hover .feuille-delete-btn {
  opacity: 1;
}

/* Drag and drop */
.feuille-draggable { cursor: grab; }
.feuille-draggable:active { cursor: grabbing; }
.feuille-dragging { opacity: 0.4; }
.feuille-dragover { border-color: var(--primary) !important; box-shadow: 0 0 0 2px var(--primary) !important; }
.feuille-drag-handle {
  position: absolute;
  top: 6px;
  left: 6px;
  color: var(--border);
  font-size: 0.8rem;
  letter-spacing: -2px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s;
}
.feuille-card:hover .feuille-drag-handle { opacity: 1; }

/* PDF Viewer Modal */
.feuille-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.feuille-modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 100%;
  height: 95vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.feuille-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.feuille-modal-header h2 {
  font-size: 1.05rem;
  color: var(--primary);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feuille-modal-iframe {
  flex: 1;
  width: 100%;
  border: none;
}
.feuille-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* PDF Book Viewer */
.pdf-book-viewer {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background: #2a2a2a;
  padding: 16px;
  position: relative;
}
.pdf-book-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-height: 100%;
}
.pdf-book-spread {
  display: flex;
  gap: 3px;
  align-items: flex-start;
  justify-content: center;
  max-height: 100%;
}
.pdf-page-canvas {
  max-height: calc(90vh - 80px);
  width: auto;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  background: white;
}
.pdf-page-placeholder {
  width: 1px;
}
.pdf-nav-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.pdf-nav-btn:hover:not(:disabled) { background: rgba(255,255,255,0.3); }
.pdf-nav-btn:disabled { opacity: 0.2; cursor: default; }

@media (max-width: 768px) {
  .pdf-book-spread { gap: 0; }
  .pdf-page-canvas { max-height: calc(95vh - 80px); width: 100%; }
  .pdf-nav-btn { width: 36px; height: 36px; font-size: 1.2rem; }
  .pdf-book-inner { gap: 4px; }
}

@media (max-width: 640px) {
  .feuille-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .feuille-card { padding: 18px 14px; }
  .feuille-modal { height: 95vh; }
  .feuille-modal-overlay { padding: 8px; }
}

/* ============================================================
   Newsletter
   ============================================================ */

.nl-toolbar {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 8px 10px;
  background: var(--primary-bg);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}

.nl-toolbar button {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
}
.nl-toolbar button:hover { background: var(--primary); color: var(--white); border-color: var(--primary); }

.nl-editor {
  min-height: 300px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--white);
  font-size: 0.95rem;
  line-height: 1.7;
  outline: none;
  overflow-y: auto;
  color: var(--text);
}
.nl-editor:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(110,22,17,0.1); }
.nl-editor h1, .nl-editor h2, .nl-editor h3 { color: var(--primary); margin: 12px 0 6px; }
.nl-editor img { max-width: 100%; border-radius: var(--radius-sm); cursor: pointer; transition: outline 0.15s; }
.nl-editor img.nl-img-selected { outline: 3px solid var(--primary); outline-offset: 2px; }
.nl-img-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--white);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.nl-img-toolbar button {
  background: var(--primary-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}
.nl-img-toolbar button:hover { background: var(--primary); color: var(--white); border-color: var(--primary); }
.nl-img-size { font-size: 0.72rem; color: var(--text-muted); margin-left: 4px; }
.nl-editor a { color: var(--primary); }
.nl-editor hr { border: none; border-top: 2px solid var(--border); margin: 16px 0; }
.nl-editor ul, .nl-editor ol { padding-left: 24px; margin: 8px 0; }
.nl-editor blockquote { border-left: 3px solid var(--primary); padding-left: 12px; margin: 8px 0; color: var(--text-secondary); }

.nl-sections-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.nl-sections-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--primary-bg);
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}
.nl-sections-grid label:hover { background: var(--primary-bg-hover); }

.nl-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.nl-preview-modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 900px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.nl-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.nl-preview-header h2 { font-size: 1.05rem; color: var(--primary); margin: 0; }
.nl-preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.nl-preview-body iframe {
  width: 100%;
  height: 100%;
  min-height: 600px;
  border: none;
}

.nl-status-draft { color: var(--warning); font-weight: 600; }
.nl-status-sent { color: var(--success); font-weight: 600; }

@media (max-width: 640px) {
  .nl-toolbar { gap: 2px; padding: 6px; }
  .nl-toolbar button { padding: 4px 8px; min-width: 28px; height: 28px; font-size: 0.8rem; }
  .nl-editor { min-height: 200px; padding: 12px; }
}

/* ============================================================
   FC Admin — Feuille Centrale Administration
   ============================================================ */
.fc-editions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.fc-edition-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.fc-edition-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}
.fc-edition-card h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
  color: var(--text);
}
.fc-edition-card .fc-year {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.fc-edition-card .fc-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 12px;
}
.fc-status-draft { background: #fef3cd; color: #856404; }
.fc-status-in_progress { background: #cce5ff; color: #004085; }
.fc-status-completed { background: #d4edda; color: #155724; }

.fc-progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}
.fc-progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.fc-progress-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: right;
}

/* Detail view */
.fc-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.fc-detail-header h2 { margin: 0; }
.fc-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.fc-sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.fc-section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.fc-section-card h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.fc-section-card .fc-section-status {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
}
.fc-sec-pending { background: #fef3cd; color: #856404; }
.fc-sec-assigned { background: #cce5ff; color: #004085; }
.fc-sec-received { background: #d1ecf1; color: #0c5460; }
.fc-sec-done { background: #d4edda; color: #155724; }

.fc-section-card .fc-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  font-size: 0.88rem;
}
.fc-section-card .fc-field label {
  font-weight: 600;
  color: var(--text-muted);
  min-width: 80px;
  flex-shrink: 0;
}
.fc-section-card .fc-field input,
.fc-section-card .fc-field textarea,
.fc-section-card .fc-field select {
  flex: 1;
  min-width: 0;
}
.fc-section-card textarea { resize: vertical; min-height: 48px; }
.fc-section-card .fc-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

.fc-member-list {
  margin: 8px 0;
  max-height: 200px;
  overflow-y: auto;
}
.fc-member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.fc-member-item:last-child { border-bottom: none; }
.fc-member-item:hover { background: rgba(110, 22, 17, 0.04); }
.fc-member-item .fc-member-name { font-weight: 600; }
.fc-member-item .fc-member-meta { color: var(--text-muted); font-size: 0.8rem; }
.fc-member-item .fc-received-check { cursor: pointer; }

@media (max-width: 640px) {
  .fc-sections-grid { grid-template-columns: 1fr; }
  .fc-editions-grid { grid-template-columns: 1fr; }
  .fc-detail-header { flex-direction: column; align-items: flex-start; }
}
