
  :root {
    --parchment: #c8ddb0;
    --parchment-dark: #5a9e3a;
    --parchment-light: #deecc8;
    --ink-dark: #081508;
    --ink-brown: #0f2808;
    --gold: #2e7d32;
    --gold-bright: #43a047;
    --gold-light: #76c442;
    --olive: #1a3a1a;
    --red-seal: #8b1a1a;
    --shadow: rgba(8,21,8,0.5);
    --header-bg: #0a2a0a;
    --row-alt: rgba(100,170,100,0.18);
    --border: #2a5e1e;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    background: #081508;
    background-image:
      radial-gradient(ellipse at 20% 20%, #0a1f08 0%, transparent 60%),
      radial-gradient(ellipse at 80% 80%, #050d05 0%, transparent 60%),
      url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%232e7d32' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 40px 20px 60px;
    font-family: 'IM Fell English', serif;
  }

  body.page-register {
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
    justify-content: center;
    padding: clamp(14px, 2vh, 28px) clamp(16px, 1.4vw, 24px);
  }

  .frame-outer {
    position: relative;
    background: var(--parchment);
    background-image:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E"),
      linear-gradient(135deg, #b0e090 0%, #d4a830 30%, #e8c870 50%, #c99a20 70%, #e0c060 100%);
    border: 6px solid var(--gold);
    border-radius: 4px;
    box-shadow:
      0 0 0 2px var(--ink-dark),
      0 0 0 10px var(--gold),
      0 0 0 12px var(--ink-dark),
      0 30px 80px rgba(0,0,0,0.8),
      inset 0 0 60px rgba(180,120,20,0.3);
    max-width: 1400px;
    width: 100%;
    padding: 30px;
    overflow: visible;
  }

  body.page-register .frame-outer {
    max-height: calc(100dvh - clamp(28px, 4vh, 56px));
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
  }

  .frame-outer::before, .frame-outer::after {
    content: '✦';
    position: absolute;
    font-size: 24px;
    color: var(--gold);
    text-shadow: 0 0 8px var(--gold-light);
  }
  .frame-outer::before { top: 10px; left: 14px; }
  .frame-outer::after  { bottom: 10px; right: 14px; }

  .corner-tr, .corner-bl {
    position: absolute;
    font-size: 24px;
    color: var(--gold);
    text-shadow: 0 0 8px var(--gold-light);
  }
  .corner-tr { top: 10px; right: 14px; }
  .corner-bl { bottom: 10px; left: 14px; }

  .header {
    text-align: center;
    margin-bottom: 24px;
    position: relative;
  }

  .logo-symbol {
    font-size: 36px;
    color: var(--ink-dark);
    margin-bottom: 4px;
    display: block;
  }

  .logo-svg {
    width: 54px;
    height: 54px;
    margin: 0 auto 6px;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
  }

  h1 {
    font-family: 'Cinzel', serif;
    font-weight: 900;
    font-size: clamp(18px, 3vw, 30px);
    color: var(--ink-dark);
    letter-spacing: 0.12em;
    text-shadow: 1px 1px 0 rgba(255,220,100,0.5), 0 2px 6px rgba(0,0,0,0.2);
    line-height: 1.2;
    margin-bottom: 10px;
  }

  .header-divider {
    width: 60%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), var(--ink-dark), var(--gold), transparent);
    margin: 8px auto;
  }

  .table-wrapper {
    overflow: visible;
    border-radius: 2px;
    border: 3px solid var(--border);
    box-shadow: inset 0 0 20px rgba(100,70,10,0.2), 0 4px 16px rgba(0,0,0,0.3);
  }

  body.page-register .table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
  }

  table {
    border-collapse: collapse;
    width: 100%;
    table-layout: auto;
    background: transparent;
  }

  thead th:nth-child(1) { width: 9%; }
  thead th:nth-child(2) { width: 11%; }
  thead th:nth-child(3) { width: 7%; }
  thead th:nth-child(4) { width: 11%; }
  thead th:nth-child(5) { width: 10%; }
  thead th:nth-child(6) { width: 7%; }
  thead th:nth-child(7) { width: 12%; }
  thead th:nth-child(8) { width: 10%; }
  thead th:nth-child(9) { width: 10%; }
  thead th:nth-child(10) { width: 32%; }

  thead tr {
    background: var(--header-bg);
  }

  thead th {
    font-family: 'Cinzel', serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--gold-light);
    letter-spacing: 0.06em;
    padding: 12px 10px;
    border: 1px solid #1a3a1a;
    text-align: center;
    white-space: nowrap;
    text-shadow: 0 0 8px rgba(67,160,71,0.6);
  }

  tbody tr {
    transition: background 0.2s;
  }

  tbody tr:nth-child(odd)  { background: rgba(232, 213, 163, 0.85); }
  tbody tr:nth-child(even) { background: rgba(200, 168, 80, 0.35); }
  tbody tr:hover { background: rgba(240,200,100,0.6) !important; }
  tbody tr.empty-row { opacity: 0.6; }

  tbody td {
    border: 1px solid var(--border);
    padding: 0;
    text-align: center;
    position: relative;
  }

  .cell-content {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 10px 8px;
    font-family: 'IM Fell English', serif;
    font-size: 14px;
    color: var(--ink-dark);
    outline: none;
    border: none;
    background: transparent;
    cursor: text;
    transition: background 0.15s, box-shadow 0.15s;
    text-align: center;
    line-height: 1.5;
    overflow: visible;
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    box-sizing: border-box;
  }

  td:last-child .cell-content {
    text-align: left;
  }

  .cell-content:focus {
    background: rgba(255,240,180,0.7);
    box-shadow: inset 0 0 0 2px var(--gold), 0 0 12px rgba(67,160,71,0.3);
    z-index: 2;
    position: relative;
  }

  .cell-content:empty::before {
    content: attr(data-placeholder);
    color: rgba(60,40,10,0.3);
    font-style: italic;
  }

  .controls {
    margin-top: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
  }

  .btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
  }

  .btn {
    font-family: 'Cinzel', serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 10px 22px;
    border: 2px solid var(--gold);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
  }

  .btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,220,80,0.15), transparent);
    opacity: 0;
    transition: opacity 0.2s;
  }
  .btn:hover::before { opacity: 1; }

  .btn-primary {
    background: linear-gradient(135deg, #0a2a0a, #0a2a00);
    color: var(--gold-light);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,220,80,0.2);
    text-shadow: 0 0 6px rgba(67,160,71,0.5);
  }
  .btn-primary:hover {
    background: linear-gradient(135deg, #0a2a10, #0a2a00);
    box-shadow: 0 6px 20px rgba(0,0,0,0.5), 0 0 15px rgba(67,160,71,0.3);
    transform: translateY(-1px);
    color: var(--gold-light);
  }
  .btn-primary:active { transform: translateY(0); }

  .btn-secondary {
    background: linear-gradient(135deg, rgba(232,213,163,0.9), rgba(200,168,80,0.7));
    color: var(--ink-dark);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  }
  .btn-secondary:hover {
    background: linear-gradient(135deg, rgba(245,230,180,0.95), rgba(220,188,100,0.8));
    transform: translateY(-1px);
  }

  .btn-danger {
    background: linear-gradient(135deg, #3a0a0a, #5a1010);
    color: #ffb0a0;
    border-color: #8b3333;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  }
  .btn-danger:hover {
    background: linear-gradient(135deg, #4a1010, #6a1818);
    transform: translateY(-1px);
  }

  .stamp {
    font-family: 'Cinzel', serif;
    font-weight: 900;
    font-size: 16px;
    color: var(--red-seal);
    border: 3px solid var(--red-seal);
    padding: 6px 14px;
    border-radius: 4px;
    transform: rotate(-6deg);
    opacity: 0.75;
    letter-spacing: 0.15em;
    text-shadow: 0 0 4px rgba(139,26,26,0.4);
    box-shadow: inset 0 0 12px rgba(139,26,26,0.2), 0 0 8px rgba(139,26,26,0.2);
    pointer-events: none;
    user-select: none;
    flex-shrink: 0;
  }

  .shuriken {
    position: absolute;
    opacity: 0.8;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));
  }
  .shuriken-tr { top: -18px; right: -18px; transform: rotate(15deg); }

  .status-bar {
    font-family: 'IM Fell English', serif;
    font-size: 13px;
    color: var(--ink-brown);
    font-style: italic;
    opacity: 0.8;
  }

  .toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--header-bg);
    color: var(--gold-light);
    font-family: 'Cinzel', serif;
    font-size: 14px;
    padding: 12px 28px;
    border: 2px solid var(--gold);
    border-radius: 2px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.6);
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    z-index: 1000;
    white-space: nowrap;
  }
  .toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }

  #loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10,8,2,0.85);
    z-index: 999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    color: var(--gold-light);
    font-family: 'Cinzel', serif;
    font-size: 16px;
  }
  #loading-overlay.active { display: flex; }
  .spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(67,160,71,0.3);
    border-top-color: var(--gold-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  @media (max-width: 600px) {
    .controls { flex-direction: column; align-items: stretch; }
    .btn-group { flex-direction: column; }
    .stamp { font-size: 12px; bottom: 16px; right: 16px; }
  }

  /* FILTER BAR */
  .filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 14px;
    background: rgba(255,240,180,0.26);
    border: 1px solid rgba(30,100,40,0.22);
    border-radius: 2px;
  }

  .filter-bar label {
    font-family: 'Cinzel', serif;
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-brown);
    letter-spacing: 0.06em;
    white-space: nowrap;
  }

  .filter-input {
    flex: 1;
    min-width: 180px;
    padding: 8px 12px;
    font-family: 'IM Fell English', serif;
    font-size: 14px;
    font-style: italic;
    color: var(--ink-dark);
    background: rgba(255,240,180,0.5);
    border: 1px solid var(--border);
    border-bottom: 2px solid var(--gold);
    outline: none;
    transition: all 0.2s;
  }

  .filter-input:focus {
    background: rgba(255,240,180,0.8);
    border-bottom-color: var(--ink-dark);
    box-shadow: 0 2px 8px rgba(67,160,71,0.3);
  }

  .filter-input::placeholder {
    color: rgba(60,40,10,0.35);
  }

  .filter-select {
    padding: 8px 10px;
    font-family: 'IM Fell English', serif;
    font-size: 13px;
    color: var(--ink-dark);
    background: rgba(255,240,180,0.5);
    border: 1px solid var(--border);
    border-bottom: 2px solid var(--gold);
    outline: none;
    cursor: pointer;
    min-width: 160px;
  }

  /* Premium polish */
  .toolbar,
  .filters-card,
  .table-wrapper,
  .admin-panel,
  .admin-panel-inner,
  .user-row {
    border-radius: 12px;
  }

  .toolbar,
  .filters-card {
    background:
      radial-gradient(circle at right top, rgba(255, 249, 228, 0.22), transparent 32%),
      linear-gradient(180deg, rgba(255,255,255,0.34), rgba(234, 214, 163, 0.54));
    box-shadow:
      0 14px 28px rgba(34, 20, 4, 0.1),
      inset 0 1px 0 rgba(255,255,255,0.52);
    border-color: rgba(184, 146, 42, 0.36);
  }

  .toolbar-value {
    text-shadow: 0 1px 10px rgba(46,125,50,0.14);
  }

  .table-wrapper {
    border-width: 2px;
    background:
      linear-gradient(180deg, rgba(255,255,255,0.18), rgba(244, 231, 194, 0.42)),
      rgba(255, 246, 215, 0.22);
    box-shadow:
      0 20px 36px rgba(34, 20, 4, 0.12),
      inset 0 1px 0 rgba(255,255,255,0.5),
      inset 0 0 20px rgba(100,70,10,0.1);
    padding: 6px;
  }

  tbody tr {
    transition: background 0.22s ease, transform 0.22s ease, box-shadow 0.22s ease;
  }

  tbody tr:hover {
    background: rgba(248, 226, 146, 0.62) !important;
    box-shadow: inset 0 0 0 1px rgba(46,125,50,0.16);
  }

  .cell-content {
    transition: background 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
  }

  .cell-content:hover {
    background: rgba(255, 248, 221, 0.28);
  }

  .cell-content:focus {
    background: rgba(255, 245, 198, 0.78);
    box-shadow:
      inset 0 0 0 2px rgba(67,160,71,0.86),
      0 0 0 3px rgba(67,160,71,0.12);
  }

  .btn,
  .btn-primary,
  .btn-secondary,
  .btn-danger,
  .btn-admin-panel,
  .admin-close-btn,
  .btn-toggle-perm {
    border-radius: 999px;
    box-shadow: 0 10px 20px rgba(43, 24, 3, 0.12);
  }

  .btn-primary:hover,
  .btn-secondary:hover,
  .btn-danger:hover,
  .admin-close-btn:hover,
  .btn-toggle-perm:hover {
    transform: translateY(-2px);
  }

  .admin-panel {
    border-radius: 16px;
    box-shadow: 0 30px 70px rgba(0,0,0,0.72);
  }

  .admin-panel-inner {
    background:
      radial-gradient(circle at top right, rgba(255, 245, 214, 0.28), transparent 28%),
      linear-gradient(160deg,#f8f0d0,#e8d08a);
  }

  .user-row {
    padding: 12px 10px;
    background: rgba(255, 249, 231, 0.28);
    border: 1px solid rgba(184, 146, 42, 0.12);
    margin-bottom: 8px;
  }

  .user-row:last-child {
    margin-bottom: 0;
  }

  .select-membre,
  .linked-membre-input,
  .filter-input,
  .filter-select,
  .rang-select {
    border-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.28);
  }

  .filter-select:focus {
    background: rgba(255,240,180,0.8);
    border-bottom-color: var(--ink-dark);
  }

  .division-select.division-none {
    color: var(--ink-brown);
  }

  .division-select.division-dri {
    color: #1f4da8;
    font-weight: 700;
  }

  .division-select.division-dpe {
    color: #8b1a1a;
    font-weight: 700;
  }

  .division-select.division-da {
    color: #081508;
    font-weight: 700;
  }

  /* SORTABLE HEADERS */
  thead th {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background 0.15s;
  }

  thead th:hover {
    background: rgba(255,220,80,0.15);
  }

  thead th .sort-arrow {
    font-size: 10px;
    margin-left: 4px;
    opacity: 0.4;
  }

  thead th.sort-active .sort-arrow {
    opacity: 1;
    color: var(--gold-light);
  }

  /* SAVE INDICATOR */
  .save-indicator {
    font-family: 'IM Fell English', serif;
    font-size: 12px;
    font-style: italic;
    color: var(--ink-brown);
    opacity: 0.7;
    transition: opacity 0.3s;
  }

  .save-indicator.saving {
    color: var(--gold-bright);
    opacity: 1;
  }

  /* USER BAR */
  .user-bar {
    position: fixed; top: 14px; right: 14px; z-index: 999;
    display: flex; align-items: center; gap: 8px;
  }
  .user-bar-inner { display: flex; align-items: center; gap: 8px; }
  .btn-burger { display: none; }
  .user-badge {
    font-family: 'Cinzel', serif; font-size: 10px; letter-spacing: 1px;
    color: var(--gold-light); background: rgba(20,14,3,0.88);
    border: 1px solid var(--gold); padding: 6px 12px; text-transform: uppercase;
  }
  .btn-user-action {
    font-family: 'Cinzel', serif; font-size: 10px; letter-spacing: 1px;
    padding: 6px 11px; cursor: pointer; border-radius: 2px; transition: all 0.2s;
  }
  .btn-logout {
    color: var(--gold-light); background: transparent; border: 1px solid var(--gold);
  }
  .btn-logout:hover { background: rgba(46,125,50,0.15); }

  /* BOUTON SUPPRESSION PAR LIGNE */
  .btn-del-row {
    background: none; border: none; cursor: pointer;
    color: var(--red-seal); font-size: 15px; font-weight: 700;
    padding: 2px 6px; opacity: 0.5; transition: opacity 0.2s; line-height: 1;
  }
  .btn-del-row:hover { opacity: 1; }
  td.del-col { width: 28px; padding: 2px 0; text-align: center; }
  th.del-col { width: 28px; padding: 0; }

  .cell-content[contenteditable="false"] {
    cursor: default;
  }

  /* SELECT RANG */
  .rang-select {
    width: 100%; min-height: 44px; padding: 10px 6px;
    font-family: 'IM Fell English', serif; font-size: 13px;
    font-style: italic; color: var(--ink-dark);
    background: transparent; border: none; outline: none;
    cursor: pointer; text-align: center; text-align-last: center;
    -webkit-appearance: none; appearance: none;
  }
  .rang-select:focus {
    background: rgba(255,240,180,0.7);
    box-shadow: inset 0 0 0 2px var(--gold);
  }
  td:has(.rang-select) { padding: 0; }

  /* ═══════════════════════════
     SIDEBAR PRÉSENCE EN LIGNE
     ═══════════════════════════ */
  .presence-sidebar {
    position: fixed; right: 8px; top: 70px;
    width: 162px; z-index: 800;
    background: rgba(8,5,1,0.93);
    border: 1px solid rgba(46,125,50,0.45);
    border-radius: 4px;
    box-shadow: -4px 0 20px rgba(0,0,0,0.45);
    overflow: hidden;
    transition: width 0.25s ease;
  }
  .presence-sidebar.collapsed { width: 28px; }
  .presence-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 100%; padding: 8px 0;
    background: none; border: none; border-bottom: 1px solid rgba(46,125,50,0.22);
    cursor: pointer; color: #2e7d32;
    font-family: 'Cinzel', serif; font-size: 9px; letter-spacing: 2px;
    white-space: nowrap; overflow: hidden; transition: background 0.2s;
  }
  .presence-toggle:hover { background: rgba(46,125,50,0.1); }
  .presence-toggle-icon { flex-shrink: 0; font-size: 11px; margin-right: 7px; }
  .presence-sidebar.collapsed .presence-toggle-text { display: none; }
  .presence-sidebar.collapsed .presence-toggle-icon { margin-right: 0; }
  .presence-body {
    padding: 6px 0 8px; max-height: 320px;
    overflow-y: auto; overflow-x: hidden;
  }
  .presence-sidebar.collapsed .presence-body { display: none; }
  .presence-user {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 12px; transition: background 0.15s;
  }
  .presence-user:hover { background: rgba(46,125,50,0.08); }
  .presence-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  }
  .presence-dot.active {
    background: #4caf50;
    box-shadow: 0 0 5px #4caf50, 0 0 10px rgba(76,175,80,0.45);
  }
  .presence-dot.away {
    background: #9c27b0;
    box-shadow: 0 0 5px #9c27b0, 0 0 10px rgba(156,39,176,0.45);
  }
  /* Police rôle — pastille présence */
  .presence-dot.police-active {
    background: #4caf50;
    box-shadow: 0 0 5px #4caf50, 0 0 10px rgba(76,175,80,0.5);
  }
  .presence-dot.police-away {
    background: #9c27b0;
    box-shadow: 0 0 5px #9c27b0, 0 0 10px rgba(156,39,176,0.45);
  }

.presence-dot.mobile {
  background: #2196F3;
  box-shadow: 0 0 6px rgba(33, 150, 243, 0.6);
}

.presence-dot.police-mobile {
  background: #2196F3;
  box-shadow: 0 0 8px rgba(33, 150, 243, 0.75);
}
  .status-dot.mobile {
  background: #2196F3;
  box-shadow: 0 0 6px rgba(33,150,243,0.6);
}
  .presence-police-icon { font-size: 8px; color: #43a047; flex-shrink: 0; line-height: 1; }
  /* Invités */
  .presence-guest-row {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 12px; opacity: 0.5;
    border-top: 1px dashed rgba(46,125,50,0.18); margin-top: 3px;
  }
  .presence-guest-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #555; flex-shrink: 0;
  }
  /* Admin panel — bouton rôle Police */
  .btn-police-on {
    font-family: 'Cinzel', serif; font-size: 9px; letter-spacing: 0.5px;
    background: rgba(180,134,11,0.28); border: 1px solid #2e7d32; color: #76c442;
    padding: 3px 7px; border-radius: 2px; cursor: pointer; transition: all 0.2s; white-space: nowrap;
  }
  .btn-police-on:hover { background: rgba(180,134,11,0.5); }
  .btn-police-off {
    font-family: 'Cinzel', serif; font-size: 9px; letter-spacing: 0.5px;
    background: transparent; border: 1px dashed rgba(46,125,50,0.35); color: rgba(67,160,71,0.5);
    padding: 3px 7px; border-radius: 2px; cursor: pointer; transition: all 0.2s; white-space: nowrap;
  }
  .btn-police-off:hover { border-style: solid; color: #43a047; }
  /* Badge invité */
  .user-badge.guest { opacity: 0.6; font-style: italic; letter-spacing: 0.5px; }
  .presence-name {
    font-family: 'Cinzel', serif; font-size: 9px; letter-spacing: 0.5px;
    color: #43a047; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; max-width: 108px;
  }
  .presence-empty {
    font-family: 'Cinzel', serif; font-size: 8px; letter-spacing: 1px;
    color: rgba(46,125,50,0.4); text-align: center; padding: 10px 8px;
  }

  /* BACK BUTTON */
  .btn-back {
    position: fixed;
    top: 18px;
    left: 18px;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 7px;
    background: linear-gradient(135deg, #0a2a0a, #0a2a00);
    border: 2px solid var(--gold);
    color: var(--gold-light);
    font-family: 'Cinzel', serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 8px 14px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
    transition: all 0.2s;
  }
  .btn-back:hover {
    background: linear-gradient(135deg, #0a2a10, #0a2a00);
    border-color: var(--gold-light);
    color: #fff;
    transform: translateX(-2px);
  }

  /* BOUTON ADMIN */
  .btn-admin-panel {
    color: var(--gold-light); background: rgba(74,42,10,0.7); border: 1px solid var(--gold);
  }
  .btn-admin-panel:hover { background: rgba(100,70,20,0.85); }

  /* PANNEAU ADMIN */
  .admin-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(0,0,0,0.78);
    display: none; align-items: center; justify-content: center;
  }
  .admin-overlay.active { display: flex; }
  .admin-panel {
    background: linear-gradient(145deg,#deecc8,#e8d080,#b0e090);
    border: 3px solid #1b5e20; padding: 5px;
    width: 92%; max-width: 500px; max-height: 82vh;
    display: flex; flex-direction: column;
    box-shadow: 0 0 60px rgba(0,0,0,0.7);
  }
  .admin-panel-inner {
    background: linear-gradient(160deg,#f8f0d0,#e8d08a);
    border: 1px solid rgba(180,140,40,0.3);
    padding: 24px 22px 18px; overflow-y: auto; flex: 1;
  }
  .admin-title {
    font-family: 'Cinzel', serif; font-size: 12px; font-weight: 700;
    letter-spacing: 3px; text-transform: uppercase;
    color: #0a1f0a; text-align: center; margin-bottom: 14px;
  }
  .admin-divider { height:1px; background: linear-gradient(90deg,transparent,#2e7d32,transparent); margin-bottom: 14px; }
  .user-row {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 0; border-bottom: 1px solid rgba(180,140,40,0.2);
  }
  .user-row:last-child { border-bottom: none; }
  .user-row-pseudo { font-family: 'Cinzel', serif; font-size: 11px; color: #0a1f0a; flex: 1; }
  .perm-badge {
    font-family: 'Cinzel', serif; font-size: 9px; letter-spacing: 1px;
    padding: 3px 8px; border-radius: 2px; white-space: nowrap;
  }
  .perm-badge.READ   { background:#1a2a4a; color:#a0c0e0; border:1px solid #2a4a8a; }
  .perm-badge.UPDATE { background:#1a3a10; color:#80c060; border:1px solid #2a6a20; }
  .perm-badge.ADMIN  { background:#4a2a0a; color:#f0c060; border:1px solid #1b5e20; }
  .btn-toggle-perm {
    font-family: 'Cinzel', serif; font-size: 9px; letter-spacing: 1px;
    padding: 4px 9px; cursor: pointer; transition: all 0.2s; border-radius: 2px;
  }
  .to-update { background: rgba(20,50,15,0.3); color:#60c040; border:1px solid #2a6a20; }
  .to-update:hover { background: rgba(20,50,15,0.55); }
  .to-read   { background: rgba(15,25,55,0.3); color:#60a0e0; border:1px solid #2a4a8a; }
  .to-read:hover { background: rgba(15,25,55,0.55); }
  .btn-del-user {
    font-size: 15px; background: none; border: none; cursor: pointer;
    color: #8b1a1a; padding: 2px 5px; opacity: 0.55; transition: opacity 0.2s;
  }
  .btn-del-user:hover { opacity: 1; }
  .admin-close-btn {
    width:100%; padding: 9px; margin-top: 0;
    font-family: 'Cinzel', serif; font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
    background: linear-gradient(135deg,#3a2a10,#5a4020); border: 1px solid #1b5e20;
    color: #43a047; cursor: pointer; transition: all 0.2s; flex-shrink: 0;
  }
  .admin-close-btn:hover { background: linear-gradient(135deg,#5a4020,#7a5a30); }
  .admin-empty { text-align:center; font-style:italic; color:#7a5a20; font-size:13px; padding:20px 0; }

  .watermark-confidential {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-family: 'Cinzel', serif;
    font-weight: 900;
    font-size: 72px;
    color: rgba(139, 26, 26, 0.10);
    letter-spacing: 0.18em;
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
    z-index: 1;
  }

  /* ── Responsive Mobile ── */
  @media (max-width: 700px) {
    body { padding: 56px 6px 56px; }

    /* ── Burger menu ── */
    .btn-burger {
      display: flex; align-items: center; justify-content: center;
      width: 36px; height: 36px; border-radius: 3px;
      background: rgba(20,14,3,0.9); border: 1px solid var(--gold);
      color: var(--gold-light); font-size: 20px; cursor: pointer;
      flex-shrink: 0;
    }
    .user-bar { top: 8px; right: 6px; gap: 0; }
    .user-bar-inner {
      display: none;
      position: fixed; top: 50px; right: 6px;
      flex-direction: column; gap: 6px;
      background: rgba(8,5,1,0.97); border: 1px solid rgba(46,125,50,0.55);
      border-radius: 4px; padding: 10px 8px; min-width: 165px;
      box-shadow: 0 6px 24px rgba(0,0,0,0.75);
      z-index: 1000;
    }
    .user-bar-inner.open { display: flex; }
    .user-bar-inner .user-badge {
      text-align: center; padding: 8px 10px; font-size: 10px; letter-spacing: 0.5px;
      border-bottom: 1px solid rgba(46,125,50,0.28); margin-bottom: 2px;
    }
    .user-bar-inner .btn-user-action {
      width: 100%; text-align: left; padding: 8px 10px; font-size: 10px;
    }

    /* ── Bouton retour ── */
    .btn-back { top: 10px; left: 6px; font-size: 9px; padding: 6px 10px; letter-spacing: 1px; width: auto; }
    .btn-back-text { display: none; }

    /* ── Cadre extérieur ── */
    .frame-outer {
      padding: 14px 8px 16px; border-width: 3px;
      box-shadow:
        0 0 0 1px var(--ink-dark),
        0 0 0 4px var(--gold),
        0 0 0 6px var(--ink-dark),
        0 8px 30px rgba(0,0,0,0.7);
    }
    .frame-outer::before, .frame-outer::after,
    .corner-tr, .corner-bl { font-size: 14px; }

    h1 { font-size: 14px !important; letter-spacing: 3px; }

    /* ── Filtres en colonne ── */
    .filter-bar { flex-direction: column; gap: 6px; }
    .filter-bar label { font-size: 9px; }
    .filter-bar select, .filter-bar input { font-size: 11px; padding: 5px 8px; }

    /* ── Contrôles en colonne ── */
    .controls { flex-direction: column; align-items: stretch; gap: 8px; }
    .btn-group { flex-wrap: wrap; gap: 6px; }
    .btn { font-size: 10px; padding: 8px 12px; }

    /* ── Tableau scrollable ── */
    .table-wrapper {
      overflow-x: auto; -webkit-overflow-scrolling: touch; border-width: 2px;
    }
    table { min-width: 680px; }
    thead th, td { font-size: 10px; padding: 6px 4px; }
    .cell-content { min-height: 28px; padding: 4px 5px; font-size: 11px; }
    .rang-select { font-size: 11px; min-height: 28px; padding: 4px 2px; }

    /* ── Sidebar présence : banderole repliée en bas ── */
    .presence-sidebar {
      position: fixed !important;
      top: auto !important; right: auto !important;
      bottom: 0 !important; left: 0 !important;
      width: 100% !important; max-height: 36px;
      border-radius: 6px 6px 0 0;
      overflow: hidden;
      transition: max-height 0.28s ease;
    }
    .presence-sidebar.mobile-open { max-height: 180px; }
    .presence-sidebar.collapsed { width: 100% !important; }
    .presence-sidebar.collapsed .presence-toggle-text { display: inline !important; }
    .presence-sidebar.collapsed .presence-toggle-icon { margin-right: 7px !important; }
    .presence-sidebar.collapsed .presence-body { display: block !important; }
    .presence-toggle { padding: 8px 14px; justify-content: center; border-bottom: none; }
    .presence-body { max-height: 140px; overflow-y: auto; padding: 4px 0 8px; }
  }

  /* ── Liaison compte → personnage RP ── */
  .user-row { flex-wrap: wrap; }
  .user-row-link {
    display: flex; align-items: center; gap: 8px;
    width: 100%; margin-top: 6px; padding-top: 6px;
    border-top: 1px dashed rgba(46,125,50,0.15);
  }
  .user-row-link-label {
    font-family: 'Cinzel', serif; font-size: 9px; letter-spacing: 1px;
    color: #8a6a30; white-space: nowrap; text-transform: uppercase;
  }
  .select-membre {
    font-family: 'Cinzel', serif; font-size: 9px; letter-spacing: 0.5px;
    background: rgba(25,16,3,0.9); border: 1px solid rgba(46,125,50,0.4);
    color: #43a047; padding: 4px 6px; cursor: pointer;
    border-radius: 2px; flex: 1; max-width: 200px;
    appearance: none; -webkit-appearance: none;
  }
  .select-membre:focus { outline: none; border-color: #43a047; }
  .select-membre option { background: #081508; color: #43a047; }


  /* ═══════════════════════════════════════
     POPUP PROFIL (badge cliquable)
     ═══════════════════════════════════════ */
  .profile-popup {
    pointer-events: all;
    position: fixed;
    top: 52px;
    right: 14px;
    width: 230px;
    background: linear-gradient(155deg, #d0eebc 0%, #e8cc60 40%, #f0d870 100%);
    border: 2px solid #1b5e20;
    box-shadow:
      0 0 0 1px #3d8f2a,
      0 10px 36px rgba(0,0,0,0.65);
    padding: 16px 16px 14px;
    border-radius: 3px;
    transform: translateY(-8px) scaleY(0.92);
    opacity: 0;
    transform-origin: top right;
    transition: transform 0.22s cubic-bezier(0.34,1.28,0.64,1), opacity 0.18s ease;
    display: none;
    z-index: 1500;
  }
  .profile-popup.open {
    display: block;
    transform: translateY(0) scaleY(1);
    opacity: 1;
  }
  .profile-popup::before {
    content: '';
    position: absolute;
    top: -8px; right: 20px;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 8px solid #1b5e20;
  }
  .profile-popup::after {
    content: '';
    position: absolute;
    top: -5px; right: 22px;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 6px solid #d0eebc;
  }
  .profile-popup-title {
    font-family: 'Cinzel', serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: #1a4818;
    text-align: center;
    margin-bottom: 14px;
    border-bottom: 1px solid rgba(180,140,40,0.35);
    padding-bottom: 8px;
  }
  .profile-avatar-preview {
    width: 90px; height: 90px;
    border: 2px solid #3a7e2a;
    border-radius: 2px;
    margin: 0 auto 12px;
    background: rgba(180,140,40,0.12);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    position: relative;
  }
  .profile-avatar-preview img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
  }
  .profile-avatar-placeholder {
    font-size: 30px;
    opacity: 0.3;
    color: #1a4818;
    user-select: none;
    pointer-events: none;
  }
  .profile-upload-label {
    display: block;
    text-align: center;
    font-family: 'Cinzel', serif;
    font-size: 9px;
    letter-spacing: 1.5px;
    color: #3a2208;
    background: rgba(255,255,255,0.45);
    border: 1px dashed #3a7e2a;
    padding: 7px 10px;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 8px;
    border-radius: 2px;
  }
  .profile-upload-label:hover {
    background: rgba(255,255,255,0.7);
    border-style: solid;
  }
  .profile-upload-input { display: none; }
  .profile-save-btn {
    width: 100%;
    font-family: 'Cinzel', serif;
    font-size: 9px;
    letter-spacing: 2px;
    text-transform: uppercase;
    background: #1a3a1a;
    color: #b8e398;
    border: 1px solid #4a6a28;
    padding: 8px;
    cursor: pointer;
    transition: all 0.18s;
    border-radius: 2px;
  }
  .profile-save-btn:hover { background: #3a5020; color: #fff; }
  .profile-save-btn:disabled { opacity: 0.5; cursor: default; }
  .profile-save-status {
    font-family: 'Cinzel', serif;
    font-size: 8px;
    letter-spacing: 1px;
    text-align: center;
    margin-top: 7px;
    height: 14px;
    color: #1a3a1a;
  }

  /* Back-office admin rework */
  .admin-panel {
    background:
      linear-gradient(145deg, rgba(30, 20, 6, 0.92), rgba(16, 10, 3, 0.98)),
      linear-gradient(135deg, #deecc8, #e8d080);
    border: 1px solid rgba(67,160,71,0.4);
    padding: 14px;
    width: min(1120px, 94vw);
    max-height: min(88vh, 920px);
    border-radius: 10px;
    box-shadow:
      0 28px 80px rgba(0,0,0,0.72),
      0 0 0 1px rgba(67,160,71,0.18),
      inset 0 1px 0 rgba(255, 230, 170, 0.08);
    backdrop-filter: blur(6px);
  }

  .admin-panel-inner {
    background:
      radial-gradient(circle at top left, rgba(255, 232, 180, 0.16), transparent 35%),
      linear-gradient(160deg, #fbf1cf 0%, #f0dc9f 46%, #e6ca74 100%);
    border: 1px solid rgba(40,110,40,0.3);
    border-radius: 8px;
    padding: 26px 24px 20px;
  }

  .admin-hero {
    text-align: center;
    margin-bottom: 18px;
  }

  .admin-kicker {
    font-family: 'Cinzel', serif;
    font-size: 10px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(74, 42, 10, 0.72);
    margin-bottom: 8px;
  }

  .admin-title {
    font-size: 18px;
    letter-spacing: 4px;
    margin-bottom: 8px;
  }

  .admin-subtitle {
    max-width: 640px;
    margin: 0 auto;
    font-size: 14px;
    line-height: 1.55;
    color: rgba(61, 43, 10, 0.78);
    font-style: italic;
  }

  .admin-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
  }

  .admin-summary-card {
    background: linear-gradient(160deg, rgba(255,244,210,0.8), rgba(215,181,90,0.32));
    border: 1px solid rgba(40,110,40,0.28);
    border-radius: 8px;
    padding: 14px 16px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
  }

  .admin-summary-label {
    font-family: 'Cinzel', serif;
    font-size: 9px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(74, 42, 10, 0.68);
    margin-bottom: 8px;
  }

  .admin-summary-value {
    font-family: 'Cinzel', serif;
    font-size: 26px;
    font-weight: 700;
    color: #0a1f0a;
  }

  .admin-toolbar {
    margin-bottom: 18px;
  }

  .admin-search-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid rgba(40,110,40,0.32);
    background: rgba(255, 248, 228, 0.7);
    color: #0a1f0a;
    font-family: 'IM Fell English', serif;
    font-size: 15px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
  }

  .admin-search-input:focus {
    outline: none;
    border-color: #2e7d32;
    box-shadow: 0 0 0 3px rgba(46,125,50,0.15);
  }

  .admin-card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .user-row {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    border: 1px solid rgba(40,110,40,0.24);
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(255,250,232,0.82), rgba(231,205,120,0.42));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 6px 18px rgba(88, 60, 12, 0.08);
  }

  .user-row:last-child { border-bottom: 1px solid rgba(40,110,40,0.24); }

  .user-row-header,
  .user-row-meta,
  .user-row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }

  .user-row-header {
    justify-content: space-between;
  }

  .user-row-pseudo {
    display: block;
    font-size: 15px;
    letter-spacing: 1px;
  }

  .user-row-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .user-row-link {
    width: 100%;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .user-row-link-label,
  .user-row-selector-label {
    font-family: 'Cinzel', serif;
    font-size: 9px;
    letter-spacing: 2px;
    color: rgba(90, 58, 20, 0.72);
    text-transform: uppercase;
  }

  .linked-membre-pill {
    width: 100%;
    min-height: 40px;
    padding: 10px 12px;
    border-radius: 7px;
    background: rgba(42, 26, 8, 0.92);
    color: #76c442;
    border: 1px solid rgba(46,125,50,0.35);
    font-family: 'Cinzel', serif;
    font-size: 11px;
    letter-spacing: 0.8px;
    display: flex;
    align-items: center;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  }

  .linked-membre-pill.empty {
    color: rgba(240, 220, 170, 0.7);
    font-style: italic;
  }

  .user-row-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .perm-badge,
  .role-badge,
  .btn-toggle-perm,
  .btn-police-on,
  .btn-police-off {
    min-height: 34px;
    padding: 7px 12px;
    border-radius: 7px;
    font-size: 10px;
    letter-spacing: 1px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
  }

  .role-badge {
    font-family: 'Cinzel', serif;
    border: 1px solid rgba(40,110,40,0.24);
    background: rgba(255, 247, 224, 0.54);
    color: #5b4316;
  }

  .role-badge.police {
    background: rgba(46,125,50,0.14);
    color: #76500a;
  }

  .role-badge.civil {
    background: rgba(120, 120, 120, 0.12);
    color: #584c36;
  }

  .btn-toggle-perm,
  .btn-police-on,
  .btn-police-off,
  .btn-del-user,
  .select-membre {
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  }

  .btn-toggle-perm:hover,
  .btn-police-on:hover,
  .btn-police-off:hover,
  .btn-del-user:hover,
  .select-membre:hover {
    transform: translateY(-1px);
  }

  .btn-del-user {
    min-width: 34px;
    min-height: 34px;
    border-radius: 7px;
    border: 1px solid rgba(139, 26, 26, 0.2);
    background: rgba(139, 26, 26, 0.08);
    color: #8b1a1a;
    opacity: 0.95;
  }

  .btn-del-user:hover {
    background: rgba(139, 26, 26, 0.14);
  }

  .select-membre {
    max-width: none;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 7px;
    font-size: 10px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
  }

  .admin-owner-note {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(74, 42, 10, 0.09);
    border: 1px dashed rgba(40,110,40,0.3);
    color: #6c5320;
    font-size: 13px;
    font-style: italic;
  }

  .admin-close-btn {
    margin-top: 12px;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 11px;
    letter-spacing: 3px;
  }

  @media (max-width: 980px) {
    .admin-summary,
    .admin-card-grid {
      grid-template-columns: 1fr 1fr;
    }
  }

  @media (max-width: 700px) {
    .admin-panel {
      width: 96vw;
      padding: 10px;
      max-height: 90vh;
      border-radius: 8px;
    }

    .admin-panel-inner {
      padding: 18px 14px 16px;
    }

    .admin-title {
      font-size: 13px;
      letter-spacing: 2px;
    }

    .admin-subtitle {
      font-size: 13px;
    }

    .admin-summary,
    .admin-card-grid {
      grid-template-columns: 1fr;
    }

    .user-row-header {
      flex-direction: column;
      align-items: flex-start;
    }

    .user-row-actions {
      width: 100%;
    }

    .btn-toggle-perm,
    .btn-police-on,
    .btn-police-off,
    .btn-del-user {
      flex: 1 1 calc(50% - 4px);
    }

    .btn-del-user {
      flex-basis: 100%;
    }
  }

  @media (max-width: 1100px), (max-height: 820px) {
    body.page-register {
      min-height: 100vh;
      height: auto;
      overflow-x: hidden;
      overflow-y: auto;
      justify-content: flex-start;
      padding: 40px 20px 60px;
    }

    body.page-register .frame-outer {
      max-height: none;
      overflow: visible;
    }
  }
