:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-hover: #f0f2f5;
  --border: #d1d5db;
  --accent: #6c63ff;
  --accent-hover: #5a52d9;
  --accent2: #a78bfa;
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.1);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.1);
  --yellow: #eab308;
  --text: #1a1e27;
  --muted: #64748b;
  --sidebar-w: 240px;
}

html.dark-mode {
  --bg: #0d0f14;
  --surface: #13161d;
  --surface-hover: #1a1e27;
  --border: #1e2330;
  --text: #e2e8f0;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 100;
}
.sidebar-logo {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.nav-links {
  list-style: none;
  padding: 16px 12px;
  flex: 1;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 8px;
  transition: .2s;
  font-weight: 500;
  margin-bottom: 4px;
}
.nav-link:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.nav-link.active {
  background: rgba(108, 99, 255, 0.1);
  color: var(--accent);
}
.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border);
}
.user-badge {
  background: var(--border);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  text-align: center;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.logout-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: .2s;
}
.logout-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

/* --- Main Content --- */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 40px;
  max-width: 1200px;
}

.page { display: none; animation: fadeIn .3s; }
.page:not(.hidden) { display: block; }
@keyframes fadeIn { from{opacity:0; transform:translateY(10px)} to{opacity:1; transform:translateY(0)} }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}
.page-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 30px;
}
.page-header .page-title { margin-bottom: 0; }

.mt { margin-top: 30px; }

/* --- Cards & Grids --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top:0; left:0; width:4px; height:100%;
  background: var(--border);
}
.stat-card.accent::before { background: var(--accent); }
.stat-card.green::before { background: var(--green); }
.stat-card.purple::before { background: var(--accent2); }

.stat-value { font-size: 32px; font-weight: 700; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--muted); }

/* --- Tables --- */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: none; }

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge.active { background: var(--green-bg); color: var(--green); }
.badge.inactive { background: var(--red-bg); color: var(--red); }
.badge.protocol { background: var(--border); color: var(--text); }

/* --- Forms & Buttons --- */
.field { margin-bottom: 16px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-family: inherit;
  outline: none;
}
select option {
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus { border-color: var(--accent); }

.btn-row { display: flex; gap: 12px; }
.btn-primary, .btn-outline, .btn-danger, .btn-sm {
  border-radius: 8px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: .2s;
  outline: none;
}
.btn-primary {
  background: var(--accent); border: none; color: #fff; padding: 10px 20px;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline {
  background: transparent; border: 1px solid var(--border); color: var(--text); padding: 10px 20px;
}
.btn-outline:hover { border-color: var(--muted); }
.btn-danger {
  background: transparent; border: 1px solid var(--red); color: var(--red); padding: 10px 20px;
}
.btn-danger:hover { background: var(--red-bg); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* --- Modals --- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn .2s;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%; max-width: 400px;
  box-shadow: 0 20px 40px rgba(0,0,0,.5);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal h2 { margin-bottom: 20px; font-size: 18px; flex-shrink: 0; }
#modalBody {
  overflow-y: auto;
  flex: 1;
  padding-right: 8px;
}
.modal .btn-row {
  margin-top: 20px !important;
  flex-shrink: 0;
}

/* --- Toasts --- */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--surface);
  border-left: 4px solid var(--accent);
  padding: 16px 24px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  z-index: 2000;
  transition: transform .3s, opacity .3s;
}
.toast.hidden { transform: translateX(120%); opacity: 0; }
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }
.toast.warning { border-color: #f59e0b; background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

/* --- Protocols Grid --- */
.protocols-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px;
}
.proto-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.proto-head { display: flex; justify-content: space-between; align-items: center; }
.proto-name { font-weight: 600; font-size: 15px; }
.proto-status { width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.proto-status.active { background: var(--green); box-shadow: 0 0 10px var(--green); }
.proto-info { font-size: 12px; color: var(--muted); }

/* --- Bots Grid --- */
.bots-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.bot-status {
  display: inline-block; padding: 4px 10px; border-radius: 20px;
  background: var(--border); font-size: 12px; margin-bottom: 20px;
}

/* --- Online Indicator --- */
.status-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--muted);
  margin-right: 8px;
  vertical-align: middle;
  opacity: 0.5;
  transition: all .3s;
}
.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  opacity: 1;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 4px var(--green); }
  50% { box-shadow: 0 0 12px var(--green); }
}

/* --- Config Modal --- */
.config-list {
  display: flex; flex-direction: column; gap: 12px;
  max-height: 60vh; overflow-y: auto;
}
.config-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}
.config-item .config-proto {
  font-weight: 600; font-size: 13px;
  color: var(--accent); margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: .5px;
}
.config-item .config-link {
  word-break: break-all;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  background: rgba(0,0,0,.3);
  padding: 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: .2s;
}
.config-item .config-link:hover {
  color: var(--text); background: rgba(0,0,0,.5);
}
.config-item .config-details {
  font-size: 12px; color: var(--muted);
  line-height: 1.8;
}
.config-item .config-details strong { color: var(--text); }
.btn-copy {
  background: var(--accent);
  border: none; color: #fff;
  padding: 4px 10px; border-radius: 4px;
  font-size: 11px; cursor: pointer;
  margin-top: 8px;
  transition: .2s;
}
.btn-copy:hover { background: var(--accent-hover); }

/* --- Bandwidth Bar --- */
.bw-bar {
  height: 4px; background: var(--border);
  border-radius: 2px; margin-top: 4px;
  overflow: hidden;
}
.bw-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px;
  transition: width .5s ease;
}
.bw-text {
  font-size: 11px; color: var(--muted); margin-top: 2px;
}

/* --- Checkbox Custom --- */
.checkbox-field {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; cursor: pointer;
}
.checkbox-field input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}
.checkbox-field label {
  margin-bottom: 0; cursor: pointer; font-size: 13px;
}

/* --- Modal wider for configs --- */
.modal.modal-wide { max-width: 560px; }

/* --- Mobile & Responsive --- */
.mobile-header {
  display: none; /* Caché par défaut sur PC */
  position: fixed; top: 0; left: 0; right: 0;
  height: 60px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 150;
  padding: 0 20px;
  align-items: center; justify-content: space-between;
}
.header-left { display: flex; align-items: center; gap: 15px; }
.menu-toggle {
  background: transparent; border: none;
  color: var(--text); font-size: 24px; cursor: pointer;
}
.mobile-logo { font-weight: 700; font-size: 18px; color: var(--accent); }
.user-badge-top {
  font-size: 11px; background: var(--border);
  padding: 4px 8px; border-radius: 4px;
  text-transform: uppercase; color: var(--muted);
}
.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 190; display: none; backdrop-filter: blur(2px);
}

/* Regles Globales Admin-Only */
body.reseller-mode .admin-only { display: none !important; }

/* --- Dropdown Menu --- */
.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown-btn {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: .2s;
}
.dropdown-btn:hover {
  background: var(--border);
}
.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  min-width: 160px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  border-radius: 10px;
  z-index: 50;
  margin-top: 8px;
  overflow: hidden;
  animation: fadeIn .2s;
}
.dropdown-content.show {
  display: block;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
  transition: .2s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.dropdown-item:hover {
  background: var(--surface-hover);
}
.dropdown-item.danger {
  color: var(--red);
}
.dropdown-item.danger:hover {
  background: var(--red-bg);
}
.dropdown-item i {
  font-size: 14px;
  width: 16px;
  text-align: center;
}

@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .3s ease;
    z-index: 200;
  }
  .sidebar.active { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .main { margin-left: 0; padding: 80px 20px 20px 20px; }
  .mobile-header { display: flex; }
  
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 16px; }
  .table-container { overflow-x: auto; width: 100%; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 16px; }
  .modal { padding: 20px; margin: 10px; width: 95%; }
}@media (max-width: 768px) {
  /* Tables responsiveness (Card layout) */
  #usersTable thead, .subusers-table thead, #tweaksTable thead, #resellersTable > thead {
    display: block !important;
    border: none !important;
    background: transparent !important;
    padding: 0 16px !important;
    margin-bottom: 8px !important;
  }
  #usersTable thead tr, .subusers-table thead tr, #tweaksTable thead tr, #resellersTable > thead > tr {
    display: flex !important;
    justify-content: flex-start !important;
    align-items: center !important;
  }
  #usersTable thead th, .subusers-table thead th, #tweaksTable thead th, #resellersTable > thead > tr > th {
    display: none !important;
  }
  #usersTable thead th:nth-child(1), .subusers-table thead th:nth-child(1), #tweaksTable thead th:nth-child(1), #resellersTable > thead > tr > th:nth-child(1) {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    font-weight: 500 !important;
    font-size: 13px !important;
    color: var(--muted) !important;
    cursor: pointer !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    width: auto !important;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
  }
  #usersTable thead th:nth-child(1)::after, #tweaksTable thead th:nth-child(1)::after, #resellersTable > thead > tr > th:nth-child(1)::after {
    content: " Tout sélectionner";
    white-space: nowrap !important;
  }

  .mobile-only-title {
    display: inline !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--accent) !important;
    margin-left: 8px !important;
    white-space: nowrap !important;
  }
  
  .reseller-subrow-title {
    display: none !important;
  }
  
  #resellersTable > tbody > tr.reseller-subrow > td {
    display: block !important;
    width: 100% !important;
    padding: 16px !important;
  }
  
  #usersTable, #usersTable tbody, #usersTable tr, #usersTable td,
  .subusers-table, .subusers-table tbody, .subusers-table tr, .subusers-table td,
  #tweaksTable, #tweaksTable tbody, #tweaksTable tr, #tweaksTable td,
  #resellersTable, #resellersTable > tbody, #resellersTable > tbody > tr, #resellersTable > tbody > tr > td {
    display: block;
    width: 100% !important;
  }
  
  #usersTable tbody tr, .subusers-table tbody tr, #tweaksTable tbody tr, #resellersTable > tbody > tr:not(.reseller-subrow) {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 16px;
    padding: 16px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: transform 0.2s;
    position: relative;
    cursor: pointer;
  }
  
  #usersTable tbody tr:hover, .subusers-table tbody tr:hover, #tweaksTable tbody tr:hover, #resellersTable > tbody > tr:not(.reseller-subrow):hover {
    background: var(--surface-hover);
    transform: translateY(-2px);
  }
  
  /* Chevron folding indicator */
  #usersTable tbody tr::after, .subusers-table tbody tr::after, #tweaksTable tbody tr::after, #resellersTable > tbody > tr:not(.reseller-subrow)::after {
    content: "▼";
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 11px;
    color: var(--muted);
    pointer-events: none;
    transition: transform 0.2s;
  }
  #usersTable tbody tr.expanded::after, .subusers-table tbody tr.expanded::after, #tweaksTable tbody tr.expanded::after, #resellersTable > tbody > tr:not(.reseller-subrow).expanded::after {
    content: "▲";
    color: var(--accent);
  }
  
  #usersTable td, .subusers-table td, #tweaksTable td, #resellersTable > tbody > tr:not(.reseller-subrow) > td {
    border-bottom: none;
    padding: 8px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
  }
  
  /* Hide details by default on mobile cards */
  #usersTable td:nth-child(3), #usersTable td:nth-child(4), #usersTable td:nth-child(5), #usersTable td:nth-child(6), #usersTable td:nth-child(7),
  .subusers-table td:nth-child(3), .subusers-table td:nth-child(4), .subusers-table td:nth-child(5), .subusers-table td:nth-child(6), .subusers-table td:nth-child(7),
  #tweaksTable td:nth-child(4), #tweaksTable td:nth-child(5), #tweaksTable td:nth-child(6), #tweaksTable td:nth-child(7),
  #resellersTable > tbody > tr:not(.reseller-subrow) > td:nth-child(3), #resellersTable > tbody > tr:not(.reseller-subrow) > td:nth-child(4), #resellersTable > tbody > tr:not(.reseller-subrow) > td:nth-child(5) {
    display: none !important;
  }
  
  /* Show details only when expanded */
  #usersTable tr.expanded td:nth-child(3), #usersTable tr.expanded td:nth-child(4), #usersTable tr.expanded td:nth-child(5), #usersTable tr.expanded td:nth-child(6), #usersTable tr.expanded td:nth-child(7),
  .subusers-table tr.expanded td:nth-child(3), .subusers-table tr.expanded td:nth-child(4), .subusers-table tr.expanded td:nth-child(5), .subusers-table tr.expanded td:nth-child(6), .subusers-table tr.expanded td:nth-child(7),
  #tweaksTable tr.expanded td:nth-child(4), #tweaksTable tr.expanded td:nth-child(5), #tweaksTable tr.expanded td:nth-child(6), #tweaksTable tr.expanded td:nth-child(7),
  #resellersTable > tbody > tr:not(.reseller-subrow).expanded > td:nth-child(3), #resellersTable > tbody > tr:not(.reseller-subrow).expanded > td:nth-child(4), #resellersTable > tbody > tr:not(.reseller-subrow).expanded > td:nth-child(5) {
    display: flex !important;
  }
  
  /* Checkboxes */
  #usersTable td:nth-child(1), .subusers-table td:nth-child(1), #tweaksTable td:nth-child(1), #resellersTable > tbody > tr:not(.reseller-subrow) > td:nth-child(1) {
    display: inline-flex !important;
    align-items: center !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    vertical-align: middle !important;
  }
  
  /* Table headers (2nd columns & main items line) */
  #usersTable td:nth-child(2), .subusers-table td:nth-child(2), #tweaksTable td:nth-child(2), #resellersTable > tbody > tr:not(.reseller-subrow) > td:nth-child(2) {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    border-bottom: none !important;
    padding: 0 !important;
    margin: 0 0 0 10px !important;
    font-size: 15px !important;
    vertical-align: middle !important;
    width: auto !important;
  }
  #usersTable td:nth-child(2) strong, .subusers-table td:nth-child(2) strong, #tweaksTable td:nth-child(2) strong, #resellersTable > tbody > tr > td:nth-child(2) strong {
    font-size: 16px;
    color: var(--text);
  }
  
  /* Bandwidth display toggle inside td:nth-child(2) */
  #usersTable tbody tr:not(.expanded) td:nth-child(2) .bw-text,
  #usersTable tbody tr:not(.expanded) td:nth-child(2) .bw-bar,
  .subusers-table tbody tr:not(.expanded) td:nth-child(2) .bw-text,
  .subusers-table tbody tr:not(.expanded) td:nth-child(2) .bw-bar {
    display: none !important;
  }
  
  #usersTable tr.expanded td:nth-child(2),
  .subusers-table tr.expanded td:nth-child(2) {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding-bottom: 8px !important;
  }
  #usersTable tr.expanded td:nth-child(2) .bw-text,
  .subusers-table tr.expanded td:nth-child(2) .bw-text {
    display: block !important;
    margin-top: 6px !important;
  }
  #usersTable tr.expanded td:nth-child(2) .bw-bar,
  .subusers-table tr.expanded td:nth-child(2) .bw-bar {
    display: block !important;
  }
  
  #tweaksTable td:nth-child(2) {
    display: inline-flex !important;
    align-items: center !important;
    width: auto !important;
    margin: 0 0 0 10px !important;
    padding: 0 !important;
    vertical-align: middle !important;
    border-bottom: none !important;
  }
  #tweaksTable td:nth-child(3) {
    display: inline-flex !important;
    align-items: center !important;
    width: auto !important;
    margin: 0 0 0 10px !important;
    padding: 0 !important;
    vertical-align: middle !important;
  }
  #tweaksTable tr.expanded td:nth-child(3)::before {
    display: none !important;
  }
  
  /* Top border separators for expanded content */
  #usersTable tr.expanded td:nth-child(3),
  .subusers-table tr.expanded td:nth-child(3),
  #tweaksTable tr.expanded td:nth-child(4),
  #resellersTable > tbody > tr:not(.reseller-subrow).expanded > td:nth-child(3) {
    border-top: 1px solid var(--border) !important;
    padding-top: 12px !important;
    margin-top: 10px !important;
  }
  
  /* Users table pseudo-labels */
  #usersTable td:nth-child(3)::before, .subusers-table td:nth-child(3)::before { content: "Expiration"; color: var(--muted); font-size: 12px; }
  #usersTable td:nth-child(4)::before, .subusers-table td:nth-child(4)::before { content: "Jours"; color: var(--muted); font-size: 12px; }
  #usersTable td:nth-child(5)::before, .subusers-table td:nth-child(5)::before { content: "Logins"; color: var(--muted); font-size: 12px; }
  #usersTable td:nth-child(6)::before, .subusers-table td:nth-child(6)::before { content: "Statut"; color: var(--muted); font-size: 12px; }
  #usersTable td:nth-child(7)::before, .subusers-table td:nth-child(7)::before { content: "Session"; color: var(--muted); font-size: 12px; }
  
  /* Tweaks table pseudo-labels */
  #tweaksTable td:nth-child(4)::before { content: "Protocole"; color: var(--muted); font-size: 12px; }
  #tweaksTable td:nth-child(5)::before { content: "Statut"; color: var(--muted); font-size: 12px; }
  #tweaksTable td:nth-child(6)::before { content: "Auteur"; color: var(--muted); font-size: 12px; }
  
  /* Resellers table pseudo-labels */
  #resellersTable > tbody > tr:not(.reseller-subrow) > td:nth-child(3)::before { content: "Crédits"; color: var(--muted); font-size: 12px; }
  #resellersTable > tbody > tr:not(.reseller-subrow) > td:nth-child(4)::before { content: "Rôle"; color: var(--muted); font-size: 12px; }
  #resellersTable > tbody > tr:not(.reseller-subrow) > td:nth-child(5)::before { content: "Statut"; color: var(--muted); font-size: 12px; }
  
  /* Raise z-index for row when actions menu is open */
  #usersTable tbody tr.has-open-dropdown,
  .subusers-table tbody tr.has-open-dropdown,
  #tweaksTable tbody tr.has-open-dropdown,
  #resellersTable > tbody > tr:not(.reseller-subrow).has-open-dropdown {
    z-index: 100 !important;
  }
 
  /* Action columns (last ones) - Position absolutely at top-right next to chevron */
  #usersTable td:nth-child(8), .subusers-table td:nth-child(8), #resellersTable > tbody > tr:not(.reseller-subrow) > td:nth-child(6) {
    position: absolute;
    top: 12px;
    right: 48px;
    width: auto !important;
    border-top: none !important;
    padding: 0 !important;
  }
}

/* --- High Contrast Borders in Light Mode --- */
.card, .modal {
  border: 1px solid #000000 !important;
}
.btn-outline, .dropdown-btn {
  border: 1px solid #000000 !important;
}

@media (max-width: 768px) {
  #usersTable tbody tr, #tweaksTable tbody tr, #resellersTable tbody tr {
    border: 1px solid #000000 !important;
  }
}

/* --- Maintain soft borders in Dark Mode --- */
html.dark-mode .card, html.dark-mode .modal {
  border: 1px solid var(--border) !important;
}
html.dark-mode .btn-outline, html.dark-mode .dropdown-btn {
  border: 1px solid var(--border) !important;
}
@media (max-width: 768px) {
  html.dark-mode #usersTable tbody tr, html.dark-mode #tweaksTable tbody tr, html.dark-mode #resellersTable tbody tr {
    border: 1px solid var(--border) !important;
  }
}

/* --- Table responsive helper for smaller tables --- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 10px;
}

.mobile-only-title {
  display: none;
}
