/* ── Variables ──────────────────────────────────────────────────────── */
:root {
  --bg:          #0d1117;
  --surface:     #161b22;
  --surface-2:   #21262d;
  --surface-3:   #30363d;
  --border:      #30363d;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --accent:      #4a9eff;
  --accent-hover:#58a6ff;
  --success:     #3fb950;
  --success-bg:  #0d2318;
  --danger:      #f85149;
  --danger-bg:   #2d1215;
  --warning:     #d29922;
  --warning-bg:  #2b1d0e;
  --info:        #4a9eff;
  --info-bg:     #0c1e3a;
  --radius:      6px;
  --shadow:      0 1px 3px rgba(0,0,0,0.4);
}

/* ── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Base ───────────────────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--text);
}

h3 {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin: 1.75rem 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

h3::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 13px;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

p {
  margin-bottom: 0.8rem;
  color: var(--text-muted);
}

/* ── Header ─────────────────────────────────────────────────────────── */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  padding: 0 1.5rem;
  height: 52px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}

header h1 span {
  color: var(--accent);
}

/* ── Nav ────────────────────────────────────────────────────────────── */
nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

nav a {
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
  text-decoration: none;
}

nav a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

/* ── Character switcher ─────────────────────────────────────────────── */
.char-switcher {
  position: relative;
}

.char-switcher-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.875rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}

.char-switcher-btn:hover {
  border-color: var(--accent);
}

.char-count {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 0 0.4em;
}

.char-arrow {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.badge-grade {
  background: color-mix(in srgb, var(--gc, #8b949e) 18%, #0d1117);
  color: var(--gc, #8b949e);
  border: 1px solid color-mix(in srgb, var(--gc, #8b949e) 55%, transparent);
}

.badge-header {
  font-size: 0.65rem;
  padding: 0.1em 0.5em;
  border-radius: 8px;
}

.char-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  min-width: 200px;
  z-index: 200;
  overflow: hidden;
}

.char-switcher.open .char-dropdown {
  display: block;
}

.char-dropdown-section {
  padding: 0.4rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.char-dropdown-item {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-size: 0.875rem;
  text-decoration: none;
  transition: background 0.1s;
}

.char-dropdown-item:hover {
  background: var(--surface-2);
  text-decoration: none;
  color: var(--text);
}

.char-corp {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.char-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

.char-link-alt {
  color: var(--accent);
}

.char-alt-inactive {
  opacity: 0.65;
}

.char-alt-inactive .char-corp {
  color: var(--warning);
  font-style: italic;
}

.char-logout {
  color: var(--danger);
}

/* ── Main content ───────────────────────────────────────────────────── */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

/* ── Bannière reconnexion scope ─────────────────────────────────────── */
.reauth-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: color-mix(in srgb, var(--warning) 12%, #0d1117);
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  color: var(--text);
}

.reauth-banner .reauth-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.reauth-banner span a {
  color: var(--accent);
  text-decoration: underline;
}

.reauth-btn {
  margin-left: auto;
  flex-shrink: 0;
  background: var(--warning) !important;
  color: #0d1117 !important;
  border-color: var(--warning) !important;
}

.reauth-btn:hover {
  opacity: 0.85;
}

/* ── Flash messages ─────────────────────────────────────────────────── */
.flashes {
  list-style: none;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flashes li {
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  border-left: 3px solid;
  font-size: 0.875rem;
}

.flashes li.success {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}

.flashes li.error {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

.flashes li.warning {
  background: var(--warning-bg);
  border-color: var(--warning);
  color: var(--warning);
}

.flashes li.info {
  background: var(--info-bg);
  border-color: var(--info);
  color: var(--info);
}

/* ── Tables ─────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-top: 1rem;
}

table {
  border-collapse: collapse;
  width: 100%;
  background: var(--surface);
  font-size: 0.875rem;
}

thead th {
  background: var(--surface-2);
  padding: 0.65rem 0.85rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--surface-3);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: linear-gradient(90deg, rgba(74, 158, 255, 0.05), transparent);
}

/* ── Badges statut ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.2em 0.65em;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-attente {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning);
}

.badge-accepte {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success);
}

.badge-refuse {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.badge-livre {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid var(--info);
}

/* Grades */
.badge-invite {
  background: #1c1c1c;
  color: var(--text-muted);
  border: 1px solid var(--surface-3);
}
.badge-membre {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid var(--info);
}
.badge-officier {
  background: #1f1a00;
  color: var(--warning);
  border: 1px solid var(--warning);
}
.badge-admin {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.stats-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  cursor: default;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: rgba(74, 158, 255, 0.35);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

.grade-legend {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: .85rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

/* ── Boutons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:active {
  transform: translateY(1px) !important;
}

.btn-primary {
  background: linear-gradient(135deg, #4a9eff 0%, #2563eb 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(74, 158, 255, 0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #58a6ff 0%, #3b82f6 100%);
  box-shadow: 0 4px 20px rgba(74, 158, 255, 0.45);
  transform: translateY(-1px);
  color: #fff;
  text-decoration: none;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(248, 81, 73, 0.5);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  box-shadow: 0 4px 14px rgba(248, 81, 73, 0.35);
  transform: translateY(-1px);
  text-decoration: none;
}

.btn-accepter {
  background: transparent;
  color: var(--success);
  border-color: rgba(63, 185, 80, 0.5);
}
.btn-accepter:hover {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
  text-decoration: none;
}

.btn-refuser {
  background: transparent;
  color: var(--danger);
  border-color: rgba(248, 81, 73, 0.5);
}
.btn-refuser:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  text-decoration: none;
}

.btn-livrer {
  background: transparent;
  color: var(--info);
  border-color: rgba(74, 158, 255, 0.5);
}
.btn-livrer:hover {
  background: var(--info);
  color: #fff;
  border-color: var(--info);
  text-decoration: none;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--surface-3);
  border-color: var(--text-muted);
  transform: translateY(-1px);
  text-decoration: none;
}

.btn-sm {
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
}

/* ── Formulaires ────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 1rem;
}

label, .form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="number"],
input[type="email"],
select,
textarea {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.15);
}

input[type="checkbox"] {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.form-check label {
  margin-bottom: 0;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ── Filtres (bpos_list) ────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.filter-bar input,
.filter-bar select {
  width: auto;
  flex: 1 1 160px;
  min-width: 120px;
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.filter-counter {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ── BPO catégories (sections dépliables) ───────────────────────────── */
.bpo-cat-section {
  margin-bottom: .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.bpo-cat-section > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem 1rem;
  cursor: pointer;
  background: var(--surface);
  user-select: none;
}
.bpo-cat-section > summary::-webkit-details-marker { display: none; }
.bpo-cat-section > summary:hover { background: var(--surface-2); }

.bpo-cat-arrow {
  display: inline-block;
  width: 10px;
  font-size: .55rem;
  opacity: .5;
  flex-shrink: 0;
}
.bpo-cat-arrow::before { content: '▶'; }
.bpo-cat-section[open] > summary .bpo-cat-arrow::before { content: '▼'; }

.bpo-cat-name {
  font-weight: 600;
  font-size: .875rem;
  flex: 1;
}

.bpo-cat-count {
  font-size: .75rem;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 2px 8px;
}

.bpo-cat-section .table-wrapper {
  border-top: 1px solid var(--border);
  border-radius: 0;
}

.bpo-cat-section table { border-radius: 0; }

.bpo-runs {
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.bpo-runs-unknown {
  color: var(--warning);
  cursor: help;
}

.price-hub-toggle {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
  font-size: 0.85rem;
}

.bpo-inline-price {
  font-size: 0.75rem;
  white-space: nowrap;
  min-width: 70px;
  display: inline-block;
}

.bpo-inline-price-ok  { color: var(--accent); }
.bpo-inline-price-na  { color: var(--text-muted); }

/* ── Inline form dans table (Commander) ─────────────────────────────── */
.inline-order-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.inline-order-form input[type="number"] {
  width: 60px;
  flex: none;
}

.inline-order-form input[type="text"] {
  width: 140px;
  flex: 1 1 100px;
}

.inline-order-form .select-livraison {
  flex: none;
  width: 130px;
}

/* ── Actions toolbar (update commandes) ─────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.toolbar label {
  margin-bottom: 0;
  white-space: nowrap;
}

.toolbar select,
.toolbar input[type="text"] {
  width: auto;
  flex: 1 1 180px;
}

/* ── Colonnes table commandes ───────────────────────────────────────── */
.td-msg {
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.td-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  white-space: nowrap;
}

/* ── Panneau commentaires ───────────────────────────────────────────── */
.detail-row td {
  background: var(--surface-2);
  padding: 0;
  border-top: none;
}

.comment-panel {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.comment-item {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  max-width: 70%;
}

.comment-mine {
  align-self: flex-end;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-1));
}

.comment-author {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--accent);
  margin-right: 0.5rem;
}

.comment-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.comment-content {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}

.comment-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.comment-form input[type="text"] {
  flex: 1;
}

.btn-comment-toggle.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Nav panier ─────────────────────────────────────────────────────── */
.nav-cart {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius);
  font-size: 1rem;
  text-decoration: none;
  color: var(--text-muted);
  transition: color 0.15s;
}

.nav-cart:hover { color: var(--text); }

.nav-cart-active { color: var(--accent) !important; }

.nav-cart-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 4px;
}

/* ── Badge Admin nouveaux membres ───────────────────────────────────── */
.nav-admin-link { position: relative; }

.nav-admin-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  margin-left: 3px;
  vertical-align: middle;
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 4px;
  margin-left: 6px;
}

.tab-new { color: var(--warning) !important; }
.tab-new.active { color: var(--text) !important; }

.new-members-actions { margin-bottom: 1rem; }

.sync-ok   { color: var(--success); font-size: 0.85rem; }
.sync-none { color: var(--text-muted); font-size: 0.85rem; font-style: italic; }

/* ── Page panier ─────────────────────────────────────────────────────── */
.cart-empty {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}

.cart-empty p { font-size: 1.1rem; margin-bottom: 1.25rem; }

.cart-group {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.cart-group-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.cart-owner-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
}

.cart-owner-name { font-weight: 700; font-size: 1rem; }

.cart-owner-count {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
}

.cart-item:last-child { border-bottom: none; }

.cart-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  flex-shrink: 0;
}

.cart-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.cart-item-name { font-weight: 600; }

.cart-item-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.cart-item-location { color: var(--text-muted); }

.cart-item-msg {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

.cart-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.cart-checkout-info {
  font-size: 0.8rem;
  opacity: 0.8;
  margin-left: 0.5rem;
}

/* ── Estimation prix panier ─────────────────────────────────────────── */
.cart-estimation {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-top: 1.5rem;
}

.cart-estimation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.cart-estimation-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.cart-estimation-hubs {
  display: flex;
  gap: 0.4rem;
}

.hub-btn {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.15s, color 0.15s;
}

.hub-btn:hover { background: var(--surface-3); color: var(--text); }

.hub-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.estimation-loading {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.5rem 0;
  animation: pulse 1.5s ease-in-out infinite;
}

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

.estimation-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.estimation-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.estimation-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--surface-3);
  color: var(--text);
}

.est-qty  { text-align: center; width: 60px; }
.est-price { text-align: right; white-space: nowrap; }

.no-price { color: var(--text-muted); }

.estimation-total {
  text-align: right;
  font-size: 0.95rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.estimation-total strong {
  color: var(--accent);
  font-size: 1.05rem;
  margin-left: 0.25rem;
}

.estimation-disclaimer {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.2rem;
}

.estimation-error {
  color: var(--danger);
  font-size: 0.85rem;
  padding: 0.4rem 0;
}

/* ── Page vide ──────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── No-result inline ───────────────────────────────────────────────── */
#noResult {
  color: var(--danger);
  font-size: 0.875rem;
  margin-top: 0.75rem;
}

/* ── Admin form inline ──────────────────────────────────────────────── */
.inline-form {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.inline-form .form-group {
  margin-bottom: 0;
  flex: 1 1 200px;
}

/* ── Onglets (tabs) ─────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  background: var(--surface);
  padding: 0.3rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  width: fit-content;
  max-width: 100%;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.2rem;
  font-size: .875rem;
  color: var(--text-muted);
  border-radius: 9px;
  text-decoration: none;
  transition: all .2s ease;
  white-space: nowrap;
  font-weight: 500;
  border: 1px solid transparent;
}

.tab:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

.tab.active {
  color: #fff;
  background: var(--accent);
  border-color: rgba(74, 158, 255, 0.3);
  box-shadow: 0 0 18px rgba(74, 158, 255, 0.3), 0 2px 8px rgba(0,0,0,0.3);
  font-weight: 600;
}

.tab-count {
  background: rgba(255,255,255,0.2);
  color: inherit;
  font-size: .7rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 0 .45em;
  line-height: 1.6;
}

/* ── Page header ─────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.page-header-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, rgba(74,158,255,0.15), rgba(74,158,255,0.03));
  border: 1px solid rgba(74,158,255,0.25);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.page-header-text h2 {
  margin: 0 0 0.1rem;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.page-header-text p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Calculateur ─────────────────────────────────────────────────────── */
.calc-form {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.calc-form .form-group {
  margin-bottom: 0;
}

.calc-result {
  margin-top: 1.25rem;
}

.calc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.calc-meta {
  display: flex;
  gap: 1.25rem;
  font-size: .85rem;
  color: var(--text-muted);
}

.calc-meta strong {
  color: var(--text);
}

table tfoot td {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: .9rem;
}

/* ── Permissions table ───────────────────────────────────────────────── */
.perm-table tbody td {
  padding: .55rem .85rem;
}

.perm-table input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
}

/* ── Grade form inline (joueurs) ─────────────────────────────────────── */
.inline-grade-form {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.inline-grade-form select {
  width: auto;
}

/* ── Wiki ────────────────────────────────────────────────────────────── */
/* ── Alt rows (admin joueurs) ────────────────────────────────────────── */
.alt-row td {
  background: rgba(0,0,0,0.15);
}

.alt-badge {
  display: inline-block;
  font-size: .65rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 .35em;
  margin-left: .35rem;
  vertical-align: middle;
}

/* ── Wiki ────────────────────────────────────────────────────────────── */
.wiki-toolbar {
  display: flex;
  gap: .6rem;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.wiki-new-cat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin-bottom: 1.25rem;
}

.wiki-new-cat form {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}

.wiki-new-cat input {
  flex: 1 1 180px;
  width: auto;
}

.hidden { display: none !important; }

.wiki-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.wiki-cat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .2s, box-shadow .2s;
}

.wiki-cat-card:hover {
  border-color: rgba(74,158,255,.35);
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
}

.wiki-cat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
  padding: 1rem 1rem .6rem;
  border-bottom: 1px solid var(--border);
}

.wiki-cat-title {
  font-size: .85rem !important;
  font-weight: 700 !important;
  color: var(--accent) !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  margin: 0 !important;
}

.wiki-cat-title::before { display: none !important; }

.wiki-cat-desc {
  font-size: .78rem;
  color: var(--text-muted);
  margin: .2rem 0 0;
}

.wiki-article-list {
  list-style: none;
  padding: .5rem 0;
  flex: 1;
}

.wiki-article-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .4rem 1rem;
  border-bottom: 1px solid var(--surface-3);
  gap: .5rem;
}

.wiki-article-list li:last-child { border-bottom: none; }

.wiki-article-list a {
  color: var(--text);
  font-size: .875rem;
  flex: 1;
  text-decoration: none;
  transition: color .15s;
}

.wiki-article-list a:hover { color: var(--accent); }

.wiki-art-date {
  font-size: .72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.wiki-empty {
  font-size: .8rem;
  color: var(--text-muted);
  padding: .75rem 1rem;
  text-align: center;
}

.wiki-cat-footer {
  padding: .6rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* Article view */
.wiki-breadcrumb {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.wiki-breadcrumb a { color: var(--accent); }

.wiki-article-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.wiki-article-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .75rem;
}

.wiki-article-title-row h2 {
  font-size: 1.75rem;
  margin: 0;
}

.wiki-actions {
  display: flex;
  gap: .5rem;
  flex-shrink: 0;
}

.wiki-meta {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* Rendered markdown content */
.wiki-content {
  max-width: 820px;
  line-height: 1.75;
  color: var(--text);
}

.wiki-content h1,
.wiki-content h2,
.wiki-content h3,
.wiki-content h4 {
  color: var(--text);
  margin: 1.75rem 0 .6rem;
  font-weight: 600;
  border-bottom: none;
}

.wiki-content h1 { font-size: 1.5rem; }
.wiki-content h2 { font-size: 1.2rem; border-bottom: 1px solid var(--border); padding-bottom: .4rem; }
.wiki-content h3 { font-size: 1rem; }

.wiki-content h2::before,
.wiki-content h3::before { display: none; }

.wiki-content p { margin-bottom: .9rem; }

.wiki-content ul,
.wiki-content ol {
  padding-left: 1.5rem;
  margin-bottom: .9rem;
}

.wiki-content li { margin-bottom: .25rem; }

.wiki-content code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .15em .4em;
  font-size: .85em;
  font-family: "Cascadia Code", "Fira Code", monospace;
  color: var(--accent);
}

.wiki-content pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.wiki-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
}

.wiki-content table {
  margin-bottom: 1rem;
  font-size: .875rem;
}

.wiki-content blockquote {
  border-left: 3px solid var(--accent);
  padding: .5rem 1rem;
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

.wiki-back { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* Editor */
.wiki-form { max-width: 900px; }

.wiki-form-row {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}

.wiki-md-hints {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  margin-bottom: .4rem;
}

.wiki-md-hints code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .15em .45em;
  font-size: .75rem;
  color: var(--text-muted);
  cursor: default;
}

.wiki-textarea {
  font-family: "Cascadia Code", "Fira Code", monospace;
  font-size: .85rem;
  line-height: 1.65;
  resize: vertical;
  min-height: 400px;
}

.wiki-form-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1.25rem;
}

/* ── Wiki layout (arbre + contenu) ──────────────────────────────────── */
.wiki-layout {
  display: flex;
  min-height: calc(100vh - 180px);
  margin: -1.75rem -1.5rem -3rem;
}

.wiki-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.wiki-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  gap: .5rem;
}

.wiki-sidebar-logo {
  font-weight: 600;
  font-size: .875rem;
  color: var(--text);
  text-decoration: none;
}

.wiki-tree {
  flex: 1;
  padding: .5rem 0;
  overflow-y: auto;
}

/* catégorie dépliable */
.wiki-tree-node { border: none; }

.wiki-tree-node > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .75rem;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  user-select: none;
}
.wiki-tree-node > summary::-webkit-details-marker { display: none; }

.wiki-tree-node > summary:hover {
  color: var(--text);
  background: rgba(255,255,255,.03);
}

.wiki-tree-arrow {
  display: inline-block;
  width: 10px;
  font-size: .55rem;
  opacity: .6;
  flex-shrink: 0;
}
.wiki-tree-arrow::before { content: '▶'; }
.wiki-tree-node[open] > summary .wiki-tree-arrow::before { content: '▼'; }

.wiki-tree-cat-name { flex: 1; }

.wiki-tree-cat-count {
  font-size: .68rem;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 1px 6px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.wiki-tree-cat-del {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .7rem;
  padding: 0 .2rem;
  opacity: 0;
  transition: opacity .15s;
}
.wiki-tree-node > summary:hover .wiki-tree-cat-del { opacity: .6; }
.wiki-tree-cat-del:hover { color: var(--danger) !important; opacity: 1 !important; }

/* articles dans l'arbre */
.wiki-tree-articles {
  list-style: none;
  padding: .1rem 0 .4rem 1.5rem;
  margin: 0;
}

.wiki-tree-articles a {
  display: block;
  padding: .3rem .6rem;
  font-size: .82rem;
  color: var(--text-muted);
  border-radius: 4px;
  border-left: 2px solid transparent;
  transition: color .1s, border-color .1s, background .1s;
}
.wiki-tree-articles a:hover {
  color: var(--text);
  background: rgba(255,255,255,.04);
  border-left-color: rgba(74,158,255,.4);
}
.wiki-tree-articles a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(74,158,255,.08);
  font-weight: 600;
}

.wiki-tree-empty {
  font-size: .78rem;
  color: var(--text-muted);
  padding: .2rem .6rem;
  opacity: .5;
}

.wiki-tree-add-article a {
  color: var(--text-muted) !important;
  font-size: .75rem;
  opacity: .5;
  border-left-color: transparent !important;
  background: none !important;
}
.wiki-tree-add-article a:hover { opacity: 1 !important; }

/* footer sidebar : nouvelle catégorie */
.wiki-sidebar-footer {
  padding: .6rem .75rem;
  border-top: 1px solid var(--border);
}

.wiki-new-cat-btn {
  width: 100%;
  text-align: left;
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  padding: .35rem .6rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .78rem;
}
.wiki-new-cat-btn:hover { color: var(--text); border-color: var(--accent); }

.wiki-new-cat-form {
  margin-top: .5rem;
}
.wiki-new-cat-form form {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

/* zone principale */
.wiki-main {
  flex: 1;
  padding: 2rem 2.5rem;
  overflow-y: auto;
  min-width: 0;
}

/* écran d'accueil wiki */
.wiki-home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  color: var(--text-muted);
  text-align: center;
}
.wiki-home-icon { font-size: 3rem; margin-bottom: 1rem; }
.wiki-home h2 { color: var(--text); margin-bottom: .5rem; font-size: 1.3rem; }
.wiki-home p { max-width: 380px; font-size: .9rem; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  header {
    padding: 0 1rem;
  }

  header h1 {
    font-size: 0.85rem;
  }

  nav a {
    padding: 0.3rem 0.45rem;
    font-size: 0.8rem;
  }

  main {
    padding: 1.25rem 1rem 2rem;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-order-form {
    flex-direction: column;
    align-items: stretch;
  }
}

