@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #1e3a5f;
  --teal: #00c49f;
  --teal-bg: rgba(0,196,159,.1);
  --bg: #060e1c;
  --white: #ffffff;
  --border: rgba(255,255,255,.08);
  --text: #c8d6e8;
  --muted: #6b82a0;
  --light: #2d4055;
  --r: 10px;
  --r-sm: 7px;
  --sh: 0 2px 8px rgba(0,0,0,.4), 0 8px 32px rgba(0,0,0,.3);
  --teal-glow: 0 0 24px rgba(0,196,159,.3);
  --sb-w: 64px;
  --sb-open: 220px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: 'IBM Plex Sans', -apple-system, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; line-height: 1.5; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
img { display: block; max-width: 100%; }

/* ── Boot ──────────────────────────────────────────── */
.boot-spin { display: flex; align-items: center; justify-content: center; height: 100vh; }
.spinner { width: 20px; height: 20px; border: 2px solid rgba(255,255,255,.1); border-top-color: var(--teal); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Auth ──────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); position: relative; overflow: hidden;
}
.auth-wrap::before {
  content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 700px; height: 700px; border-radius: 50%;
  background: radial-gradient(circle at center, rgba(0,196,159,.055) 0%, transparent 65%);
  pointer-events: none;
}
.auth-box {
  background: var(--sidebar); border: 1px solid rgba(0,196,159,.1);
  border-radius: 14px; padding: 40px 36px; width: 100%; max-width: 380px;
  box-shadow: 0 0 0 1px rgba(0,196,159,.05), 0 40px 80px rgba(0,0,0,.6);
  position: relative; z-index: 1;
}
.auth-logo { text-align: center; margin-bottom: 30px; }
.auth-logo img { height: 28px; margin: auto; filter: brightness(0) invert(1); opacity: .6; }
.auth-title { font-size: 22px; font-weight: 700; color: #fff; margin-bottom: 4px; letter-spacing: -.3px; }
.auth-sub { font-size: 13px; color: var(--muted); margin-bottom: 28px; }
.auth-label { display: block; font-size: 10.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .8px; }
.auth-input {
  width: 100%; padding: 11px 14px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px; color: #fff; font-family: inherit; font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.auth-input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,196,159,.12); }
.auth-input::placeholder { color: rgba(255,255,255,.2); }
.auth-group { margin-bottom: 16px; }
.auth-btn {
  width: 100%; padding: 12px; background: var(--teal); color: #0a1628;
  border-radius: 8px; font-size: 14px; font-weight: 700; margin-top: 8px;
  transition: box-shadow .2s, opacity .15s; letter-spacing: .1px;
}
.auth-btn:hover { box-shadow: var(--teal-glow); }
.auth-btn:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }
.auth-err { font-size: 12.5px; color: #f87171; margin-top: 12px; text-align: center; min-height: 18px; }

/* ── Shell ─────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────── */
.sidebar {
  width: var(--sb-w); flex-shrink: 0;
  background: var(--sidebar); display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
  border-right: 1px solid rgba(255,255,255,.04); overflow: hidden;
  transition: width .22s cubic-bezier(.4,0,.2,1);
}
.sidebar:hover { width: var(--sb-open); }

.sb-brand {
  height: 64px; flex-shrink: 0; display: flex; align-items: center;
  border-bottom: 1px solid rgba(255,255,255,.05); overflow: hidden;
}
.sb-brand-icon { width: var(--sb-w); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.sb-brand-icon img { height: 22px; filter: brightness(0) invert(1); opacity: .6; }
.sb-brand-text {
  font-size: 10px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
  color: rgba(255,255,255,.3); white-space: nowrap;
  opacity: 0; transform: translateX(-6px);
  transition: opacity .18s .05s, transform .18s .05s;
}
.sidebar:hover .sb-brand-text { opacity: 1; transform: translateX(0); }

.sb-nav { flex: 1; padding: 8px 0; display: flex; flex-direction: column; gap: 1px; overflow: hidden; }

.sb-btn {
  display: flex; align-items: center; padding: 0; border-radius: 0;
  width: 100%; min-height: 44px; white-space: nowrap;
  color: rgba(255,255,255,.32); transition: color .15s, background .15s; position: relative;
}
.sb-btn::after {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 0; background: var(--teal); border-radius: 0 3px 3px 0;
  transition: height .18s cubic-bezier(.4,0,.2,1);
}
.sb-btn:hover { background: rgba(255,255,255,.04); color: rgba(255,255,255,.75); }
.sb-btn.active { background: rgba(0,196,159,.08); color: #fff; }
.sb-btn.active::after { height: 22px; }

.sb-btn-icon { width: var(--sb-w); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.sb-btn-icon svg { opacity: .55; transition: opacity .15s; }
.sb-btn:hover .sb-btn-icon svg, .sb-btn.active .sb-btn-icon svg { opacity: 1; }

.sb-btn-label {
  font-size: 13px; font-weight: 500; overflow: hidden;
  opacity: 0; transform: translateX(-6px); pointer-events: none;
  transition: opacity .18s .04s, transform .18s .04s;
}
.sidebar:hover .sb-btn-label { opacity: 1; transform: translateX(0); pointer-events: auto; }

.sb-sep { height: 1px; background: rgba(255,255,255,.05); margin: 4px 12px; flex-shrink: 0; }

.sb-footer { flex-shrink: 0; border-top: 1px solid rgba(255,255,255,.05); overflow: hidden; }
.sb-user { display: flex; align-items: center; min-height: 52px; }
.sb-avatar { width: var(--sb-w); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.sb-avatar-inner {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--teal); color: #0a1628; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.sb-email {
  font-size: 11.5px; color: rgba(255,255,255,.28); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  opacity: 0; transform: translateX(-6px); transition: opacity .18s .04s, transform .18s .04s;
}
.sidebar:hover .sb-email { opacity: 1; transform: translateX(0); }

.sb-logout { display: flex; align-items: center; min-height: 42px; width: 100%; white-space: nowrap; color: rgba(255,255,255,.22); transition: color .15s, background .15s; }
.sb-logout:hover { color: #f87171; background: rgba(248,113,113,.06); }
.sb-logout-icon { width: var(--sb-w); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.sb-logout-label { font-size: 13px; font-weight: 500; opacity: 0; transform: translateX(-6px); transition: opacity .18s .04s, transform .18s .04s; }
.sidebar:hover .sb-logout-label { opacity: 1; transform: translateX(0); }

/* ── Main content ──────────────────────────────────── */
.main { margin-left: var(--sb-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: rgba(6,14,28,.88); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border); padding: 0 28px; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-size: 15px; font-weight: 600; color: #fff; letter-spacing: -.1px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.content { padding: 24px 28px; flex: 1; }

/* ── Stats grid ────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat-card {
  background: var(--sidebar); border: 1px solid var(--border); border-radius: var(--r);
  padding: 20px; position: relative; overflow: hidden;
  transition: border-color .2s;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent);
}
.stat-card:hover { border-color: rgba(0,196,159,.18); }
.stat-value { font-size: 28px; font-weight: 600; color: var(--text); line-height: 1; font-family: 'IBM Plex Mono', monospace; letter-spacing: -.5px; }
.stat-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin-top: 8px; }
.stat-card.accent .stat-value { color: var(--teal); }
.stat-card.accent { border-color: rgba(0,196,159,.14); }

/* ── Card ──────────────────────────────────────────── */
.card { background: var(--sidebar); border: 1px solid var(--border); border-radius: var(--r); }
.card-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-header h2 { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

/* ── Table ─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 9px 16px; text-align: left; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); background: rgba(255,255,255,.02); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 16px; font-size: 13px; color: var(--text); border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

/* ── Badges ────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 100px; font-size: 10.5px; font-weight: 700; white-space: nowrap; letter-spacing: .2px; }
.badge-1 { background: rgba(59,130,246,.15); color: #93c5fd; border: 1px solid rgba(59,130,246,.25); }
.badge-2 { background: rgba(139,92,246,.15); color: #c4b5fd; border: 1px solid rgba(139,92,246,.25); }
.badge-3 { background: rgba(245,158,11,.12); color: #fcd34d; border: 1px solid rgba(245,158,11,.25); }
.badge-ok { background: rgba(16,185,129,.12); color: #6ee7b7; border: 1px solid rgba(16,185,129,.25); }
.badge-warn { background: rgba(245,158,11,.12); color: #fcd34d; border: 1px solid rgba(245,158,11,.25); }
.badge-gray { background: rgba(255,255,255,.06); color: var(--muted); border: 1px solid var(--border); }
.badge-red { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid rgba(239,68,68,.25); }
.badge-blue { background: rgba(59,130,246,.12); color: #93c5fd; border: 1px solid rgba(59,130,246,.2); }

/* ── Buttons ───────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 7px; font-size: 12.5px; font-weight: 600; transition: opacity .15s, background .15s, box-shadow .15s; white-space: nowrap; }
.btn:hover { opacity: .85; }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-primary { background: var(--teal); color: #0a1628; }
.btn-primary:hover { opacity: 1; box-shadow: var(--teal-glow); }
.btn-ghost { background: rgba(255,255,255,.06); color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { opacity: 1; background: rgba(255,255,255,.1); color: var(--text); }
.btn-danger { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid rgba(239,68,68,.2); }
.btn-danger:hover { opacity: 1; background: rgba(239,68,68,.22); }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }

/* ── Search ────────────────────────────────────────── */
.search-input { padding: 7px 13px; border: 1px solid var(--border); border-radius: 7px; font-family: inherit; font-size: 13px; color: var(--text); outline: none; background: rgba(255,255,255,.05); transition: border-color .15s, box-shadow .15s; width: 220px; }
.search-input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,196,159,.1); }
.search-input::placeholder { color: var(--muted); }

/* ── Modal ─────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; animation: m-in .15s ease-out; }
@keyframes m-in { from { opacity: 0; } }
.modal { background: #0b1525; border: 1px solid rgba(0,196,159,.12); border-radius: 14px; width: 100%; max-width: 480px; box-shadow: 0 0 0 1px rgba(0,196,159,.05), 0 40px 80px rgba(0,0,0,.7); max-height: 90vh; overflow-y: auto; animation: m-up .22s cubic-bezier(.34,1.4,.64,1); }
@keyframes m-up { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 14px; font-weight: 700; color: #fff; }
.modal-close { font-size: 18px; color: var(--muted); line-height: 1; padding: 4px 7px; border-radius: 6px; transition: color .15s, background .15s; }
.modal-close:hover { color: #fff; background: rgba(255,255,255,.08); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 10.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .7px; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 9px 12px; border: 1px solid rgba(255,255,255,.1); border-radius: 7px; font-family: inherit; font-size: 13.5px; color: var(--text); outline: none; background: rgba(255,255,255,.04); transition: border-color .15s, box-shadow .15s; }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,196,159,.1); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b82a0' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-color: rgba(255,255,255,.04); padding-right: 32px; color-scheme: dark; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* ── Alert ─────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: 7px; font-size: 13px; margin-bottom: 16px; }
.alert-err { background: rgba(239,68,68,.1); color: #fca5a5; border: 1px solid rgba(239,68,68,.2); }
.alert-ok  { background: rgba(16,185,129,.1); color: #6ee7b7; border: 1px solid rgba(16,185,129,.2); }

/* ── Loading / Empty ───────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 56px 20px; color: var(--muted); font-size: 13px; }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); font-size: 13px; }

/* ── Toast ─────────────────────────────────────────── */
#toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1a2740; color: var(--text); padding: 10px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; box-shadow: 0 4px 24px rgba(0,0,0,.5); animation: tin .2s ease-out, tout .25s ease-in 2.75s forwards; white-space: nowrap; border: 1px solid var(--border); }
.toast-ok  { background: rgba(16,185,129,.15); border-color: rgba(16,185,129,.25); color: #6ee7b7; }
.toast-err { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.25); color: #fca5a5; }
@keyframes tin  { from { opacity: 0; transform: translateX(12px); } }
@keyframes tout { to   { opacity: 0; transform: translateX(12px); } }

/* ── Image upload ──────────────────────────────────── */
.img-drop-zone {
  border: 2px dashed var(--border); border-radius: 8px; padding: 28px 20px;
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
  user-select: none;
}
.img-drop-zone:hover, .img-drop-zone.dragover { border-color: var(--teal); background: rgba(0,196,159,.04); }
.img-drop-hint { font-size: 13px; color: var(--muted); line-height: 1.6; }
.img-drop-hint span { color: var(--teal); font-weight: 600; }
.img-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.img-preview-item {
  position: relative; width: 76px; height: 76px; border-radius: 8px;
  overflow: hidden; border: 1px solid var(--border); flex-shrink: 0;
}
.img-preview-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-preview-item button {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,.75); color: #fff;
  font-size: 13px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.img-preview-item button:hover { background: #b91c1c; }
.img-uploading {
  width: 76px; height: 76px; border-radius: 8px;
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.03);
}

/* ── Carte selector ────────────────────────────────── */
.carte-btns { display: flex; gap: 4px; }
.carte-btn { padding: 3px 9px; border-radius: 100px; font-size: 11px; font-weight: 700; border: 1px solid transparent; transition: all .15s; }
.carte-btn[data-v="1"] { background: rgba(59,130,246,.1); color: #93c5fd; border-color: rgba(59,130,246,.18); }
.carte-btn[data-v="2"] { background: rgba(139,92,246,.1); color: #c4b5fd; border-color: rgba(139,92,246,.18); }
.carte-btn[data-v="3"] { background: rgba(245,158,11,.09); color: #fcd34d; border-color: rgba(245,158,11,.18); }
.carte-btn.selected[data-v="1"] { background: rgba(59,130,246,.25); border-color: #93c5fd; }
.carte-btn.selected[data-v="2"] { background: rgba(139,92,246,.25); border-color: #c4b5fd; }
.carte-btn.selected[data-v="3"] { background: rgba(245,158,11,.2); border-color: #fcd34d; }
