/* ============================================================
   LSFD Dashboard V4 — design system
   Sombre par défaut · thème clair via [data-theme="light"]
   ============================================================ */

:root {
  color-scheme: dark;

  /* Blason LSFD : rouge pompier, or gravé, bleu marine */
  --accent:        #D62F37;
  --accent-2:      #F0642B;
  --accent-ink:    #ffffff;
  --accent-soft:   rgba(214, 47, 55, .14);
  --accent-line:   rgba(214, 47, 55, .38);
  --accent-glow:   rgba(214, 47, 55, .32);
  --gold:          #D9AE5B;
  --gold-2:        #A87E34;
  --gold-soft:     rgba(217, 174, 91, .14);
  --navy:          #1C2C5E;

  --bg:        #080a11;
  --bg-2:      #0c0f19;
  --bg-3:      #141a2a;
  --surface:   #10141f;
  --surface-2: #151b29;
  --surface-3: #1b2234;
  --border:    rgba(217, 174, 91, .09);
  --border-2:  rgba(217, 174, 91, .18);
  --overlay:   rgba(5, 6, 11, .74);

  --text:      #f5f1e8;
  --text-2:    #b9b3a6;
  --text-3:    #7c7a74;

  --ok:     #37c978;  --ok-soft:     rgba(55, 201, 120, .13);
  --warn:   #f2a93b;  --warn-soft:   rgba(242, 169, 59, .13);
  --danger: #ff5560;  --danger-soft: rgba(255, 85, 96, .13);
  --info:   #5b8cff;  --info-soft:   rgba(91, 140, 255, .13);
  --purple: #a07cf0;  --purple-soft: rgba(160, 124, 240, .13);

  --r-xs: 6px;  --r-sm: 9px;  --r: 12px;  --r-lg: 16px;  --r-xl: 22px;
  --sh-1: 0 1px 2px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.25);
  --sh-2: 0 6px 20px rgba(0,0,0,.36), 0 2px 6px rgba(0,0,0,.26);
  --sh-3: 0 24px 60px rgba(0,0,0,.55), 0 8px 24px rgba(0,0,0,.38);
  --sh-glow: 0 8px 28px var(--accent-soft);

  --ease: cubic-bezier(.22, 1, .36, 1);
  --sidebar-w: 272px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --display: 'Oswald', 'Arial Narrow', 'Inter', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
}

[data-theme="light"] {
  color-scheme: light;
  --accent: #B3202A; --accent-2: #D9481F; --accent-ink: #ffffff;
  --accent-soft: rgba(179, 32, 42, .10); --accent-line: rgba(179, 32, 42, .34); --accent-glow: rgba(179, 32, 42, .24);
  --gold: #9C7426; --gold-2: #7A5A1B; --gold-soft: rgba(156, 116, 38, .12);
  --bg: #f6f3ec; --bg-2: #efeadf; --bg-3: #e7e0d2;
  --surface: #ffffff; --surface-2: #faf8f3; --surface-3: #f1ece2;
  --border: rgba(40, 28, 10, .10); --border-2: rgba(40, 28, 10, .18);
  --overlay: rgba(28, 22, 12, .38);
  --text: #1b1712; --text-2: #4d4538; --text-3: #847a69;
  --sh-1: 0 1px 2px rgba(40,28,10,.06), 0 2px 6px rgba(40,28,10,.05);
  --sh-2: 0 8px 24px rgba(40,28,10,.10), 0 2px 6px rgba(40,28,10,.06);
  --sh-3: 0 30px 70px rgba(40,28,10,.18), 0 10px 24px rgba(40,28,10,.10);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
*::selection { background: var(--accent); color: var(--accent-ink); }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ambient background */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(700px circle at 10% -8%, var(--accent-soft), transparent 55%),
    radial-gradient(760px circle at 100% 0%, rgba(28, 44, 94, .35), transparent 55%),
    radial-gradient(900px circle at 50% 120%, var(--gold-soft), transparent 60%);
  opacity: .8;
}

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes shimmer { 100% { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================ LAYOUT */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg-2);
  background: linear-gradient(180deg, var(--bg-2), color-mix(in srgb, var(--bg) 88%, #000));
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  z-index: 60;
}
.sidebar__brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 18px; }
.sidebar__brand .logo {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; object-fit: cover;
  box-shadow: 0 0 0 2px var(--gold-2), 0 6px 22px var(--accent-glow);
}
.sidebar__brand h1 { font-family: var(--display); font-size: 21px; font-weight: 700; letter-spacing: 2.5px; line-height: 1; color: var(--gold); }
.sidebar__brand span { font-size: 10px; color: var(--text-3); font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; }
.sidebar__brand { border-bottom: 1px solid var(--border); margin-bottom: 14px; position: relative; }
.sidebar__brand::after { content: ''; position: absolute; left: 20px; right: 20px; bottom: -1px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold-2), transparent); }

.sidebar__user {
  margin: 0 14px 8px; padding: 11px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  display: flex; align-items: center; gap: 10px; transition: border-color .2s;
}
.sidebar__user:hover { border-color: var(--border-2); }
.avatar {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(145deg, var(--accent-soft), transparent);
  color: var(--accent); border: 1px solid var(--accent-line);
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
  overflow: hidden;
}
img.avatar {
  object-fit: cover; background: var(--surface-3);
  border-color: var(--border-2); color: transparent;
}
.sidebar__user .nm { font-weight: 700; font-size: 13px; line-height: 1.3; }
.sidebar__user .rl { font-size: 11px; color: var(--text-3); display: flex; align-items: center; gap: 5px; }

.nav { padding: 8px 12px 20px; flex: 1; }
.nav__group { margin-top: 18px; }
.nav__group:first-child { margin-top: 6px; }
.nav__title {
  font-family: var(--display); font-size: 11px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase;
  color: var(--gold); opacity: .75; padding: 0 12px 8px;
}
.nav__link {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 11px;
  color: var(--text-2); font-size: 13px; font-weight: 600; position: relative;
  transition: background .16s var(--ease), color .16s, transform .12s;
}
.nav__link i { width: 18px; text-align: center; font-size: 14px; opacity: .9; }
.nav__link:hover { background: var(--surface); color: var(--text); }
.nav__link:active { transform: scale(.985); }
.nav__link.is-active { background: linear-gradient(90deg, var(--accent-soft), transparent 80%); color: var(--accent); }
.nav__link.is-active i { opacity: 1; }
.nav__link.is-active::before {
  content: ''; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent); box-shadow: 0 0 12px var(--accent-glow);
}
.nav__badge {
  margin-left: auto; min-width: 19px; height: 19px; padding: 0 6px; border-radius: 10px;
  font-size: 10.5px; font-weight: 800; display: grid; place-items: center;
  background: var(--danger); color: #fff; box-shadow: 0 0 0 3px var(--bg-2);
}
.nav__badge.is-ok { background: var(--ok); }

.sidebar__foot { padding: 12px 16px 18px; border-top: 1px solid var(--border); }
.sidebar__foot a { display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 13px; font-weight: 600; padding: 8px 8px; border-radius: 9px; transition: .16s; }
.sidebar__foot a:hover { color: var(--danger); background: var(--danger-soft); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 62px; flex-shrink: 0; display: flex; align-items: center; gap: 14px; padding: 0 26px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  position: sticky; top: 0; z-index: 50;
}
.topbar__toggle { display: none; }
.topbar__title { font-family: var(--display); font-weight: 600; font-size: 19px; letter-spacing: .8px; text-transform: uppercase; }
.topbar__sub { color: var(--text-3); font-size: 12px; margin-left: 8px; font-weight: 600; }
.topbar__spacer { flex: 1; }

.iconbtn {
  width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 14px;
  display: grid; place-items: center; transition: .16s var(--ease);
}
.iconbtn:hover { color: var(--text); border-color: var(--border-2); transform: translateY(-1px); }
.iconbtn:active { transform: none; }

.page { padding: 26px; max-width: 1480px; width: 100%; margin: 0 auto; flex: 1; animation: fadeUp .3s var(--ease); }
.page__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page__head h2 { font-family: var(--display); font-size: 26px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; }
.page__head p { color: var(--text-3); font-size: 13px; margin-top: 2px; }

.app-footer { padding: 20px 26px; color: var(--text-3); font-size: 11.5px; text-align: center; border-top: 1px solid var(--border); }

/* ============================================================ GRID / CARDS */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 18px; position: relative; transition: border-color .2s, transform .2s var(--ease), box-shadow .2s;
}
.card--pad-lg { padding: 24px; }
.card--hover:hover, a .card:hover { border-color: var(--border-2); transform: translateY(-2px); box-shadow: var(--sh-2); }
.card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; gap: 10px; }
.card__head h3 { font-family: var(--display); font-size: 15px; font-weight: 600; letter-spacing: .9px; text-transform: uppercase; display: flex; align-items: center; gap: 9px; }
.card__head h3 > i { color: var(--gold); }
.card__head .sub, .card__head a.sub { color: var(--text-3); font-size: 12px; font-weight: 600; }
.card__head a.sub:hover { color: var(--accent); }

/* stat cards */
.stat { display: flex; flex-direction: column; gap: 9px; overflow: hidden; }
.stat::after {
  content: ''; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%); opacity: .6; pointer-events: none;
}
.stat__label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .9px; color: var(--text-3); display: flex; align-items: center; gap: 9px; }
.stat__label i {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 13px;
}
.stat__value { font-size: 27px; font-weight: 800; letter-spacing: -.6px; line-height: 1; font-variant-numeric: tabular-nums; }
.stat__delta { font-size: 12px; font-weight: 700; color: var(--text-3); }
.stat__delta.up { color: var(--ok); } .stat__delta.down { color: var(--danger); }
.stat--ok     .stat__label i { background: var(--ok-soft); color: var(--ok); }
.stat--warn   .stat__label i { background: var(--warn-soft); color: var(--warn); }
.stat--info   .stat__label i { background: var(--info-soft); color: var(--info); }
.stat--danger .stat__label i { background: var(--danger-soft); color: var(--danger); }
.stat--ok::after     { background: radial-gradient(circle, var(--ok-soft), transparent 70%); }
.stat--warn::after   { background: radial-gradient(circle, var(--warn-soft), transparent 70%); }
.stat--danger::after { background: radial-gradient(circle, var(--danger-soft), transparent 70%); }
.stat--info::after   { background: radial-gradient(circle, var(--info-soft), transparent 70%); }

/* ============================================================ TABLES */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 10px; font-weight: 800; letter-spacing: .9px; text-transform: uppercase;
  color: var(--text-3); padding: 13px 15px; border-bottom: 1px solid var(--border); white-space: nowrap;
  background: var(--surface-2); position: sticky; top: 0; z-index: 1;
}
.tbl td { padding: 12px 15px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .strong { font-weight: 700; color: var(--text); }
.tbl td .btn-sm, .tbl td .select.btn-sm, .tbl td .input.btn-sm { opacity: .55; transition: opacity .15s; }
.tbl tr:hover td .btn-sm, .tbl tr:hover td .select.btn-sm, .tbl tr:hover td .input.btn-sm { opacity: 1; }
.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-user .avatar { width: 30px; height: 30px; font-size: 11px; border-radius: 9px; }
a.cell-user, a.cell-user--link { color: inherit; text-decoration: none; }
a.cell-user--link .strong { transition: color .14s; }
a.cell-user--link:hover .strong { color: var(--accent); }
a.cell-user--link:hover .avatar { border-color: var(--accent-line); }
.av-link { display: inline-flex; flex-shrink: 0; border-radius: inherit; transition: transform .12s var(--ease); }
.av-link:hover { transform: scale(1.06); }
.av-link:hover .avatar { border-color: var(--accent-line); }

.empty { padding: 46px 20px; text-align: center; color: var(--text-3); }
.empty i { font-size: 30px; display: block; margin-bottom: 12px; opacity: .45; }

/* ============================================================ BADGES */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .3px; line-height: 1.6; white-space: nowrap;
  border: 1px solid transparent;
}
.badge-ok     { background: var(--ok-soft); color: var(--ok); }
.badge-warn   { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info   { background: var(--info-soft); color: var(--info); }
.badge-muted  { background: var(--bg-3); color: var(--text-3); border-color: var(--border); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot-danger { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.dot-muted { background: var(--text-3); }
.dot-ok, .dot-danger { animation: pulse 2s var(--ease) infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px transparent; } 50% { box-shadow: 0 0 0 4px var(--ok-soft); } }

/* ============================================================ BUTTONS */
.btn {
  --_bg: var(--surface); --_bd: var(--border-2); --_fg: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 11px; font-size: 13px; font-weight: 700; white-space: nowrap;
  border: 1px solid var(--_bd); background: var(--_bg); color: var(--_fg);
  cursor: pointer; transition: transform .12s var(--ease), filter .15s, border-color .15s, background .15s;
  user-select: none;
}
.btn:hover { border-color: var(--text-3); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-primary { --_bg: linear-gradient(145deg, var(--accent), var(--accent-2)); --_bd: transparent; --_fg: var(--accent-ink); box-shadow: var(--sh-glow); }
.btn-primary:hover { filter: brightness(1.06); border-color: transparent; }
.btn-ok { --_bg: var(--ok); --_bd: transparent; --_fg: #05230f; }
.btn-danger { --_bg: var(--danger); --_bd: transparent; --_fg: #fff; }
.btn-ghost { --_bg: transparent; --_bd: transparent; }
.btn-ghost:hover { --_bg: var(--surface-2); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 9px; }
.btn-icon { padding: 8px; width: 34px; }
.btn .fa-spin { animation: spin .7s linear infinite; }

/* ============================================================ FORMS */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 700; color: var(--text-2); }
.input, .select, textarea.input {
  width: 100%; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--border-2);
  background: var(--bg-2); color: var(--text); font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder, textarea.input::placeholder { color: var(--text-3); }
.input:hover, .select:hover, textarea.input:hover { border-color: var(--text-3); }
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--accent-line); background: var(--surface);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
textarea.input { resize: vertical; min-height: 84px; }
.select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23737d92' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
input[type="color"].input { padding: 4px; height: 40px; cursor: pointer; }
input[type="date"].input { cursor: pointer; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 160px; }
.search { position: relative; }
.search > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 13px; pointer-events: none; }
.search .input { padding-left: 34px; }

.segmented { display: inline-flex; background: var(--bg-3); border-radius: 12px; padding: 4px; gap: 3px; border: 1px solid var(--border); }
.segmented a { padding: 6px 13px; border-radius: 9px; font-size: 12.5px; font-weight: 700; color: var(--text-2); transition: .16s var(--ease); display: inline-flex; align-items: center; gap: 6px; }
.segmented a:hover { color: var(--text); }
.segmented a.is-active { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }

/* ============================================================ MISC */
.progress { height: 7px; border-radius: 5px; background: var(--bg-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .5s var(--ease); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.timeline { display: flex; flex-direction: column; }
.timeline__item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 13px; align-items: flex-start; }
.timeline__item:last-child { border-bottom: 0; }
.timeline__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex-shrink: 0; box-shadow: 0 0 10px var(--accent-glow); }
.timeline__time { color: var(--text-3); font-size: 11px; white-space: nowrap; margin-left: auto; }

.photo-thumb { width: 100%; border-radius: var(--r); border: 1px solid var(--border); background: var(--bg-3); aspect-ratio: 16/9; object-fit: cover; transition: transform .25s var(--ease); }
a:hover > .photo-thumb { transform: scale(1.015); }

details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }

.skeleton { background: linear-gradient(90deg, var(--bg-3) 25%, var(--surface-2) 37%, var(--bg-3) 63%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }

/* ============================================================ TOASTS */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 9000; max-width: 380px; }
.toast {
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r);
  padding: 12px 14px 12px 12px; font-size: 13px; font-weight: 600; box-shadow: var(--sh-3);
  display: flex; align-items: flex-start; gap: 10px; overflow: hidden; position: relative;
  animation: toastIn .32s var(--ease);
}
.toast.leaving { animation: toastOut .25s var(--ease) forwards; }
.toast__ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; flex-shrink: 0; background: var(--accent-soft); color: var(--accent); }
.toast.ok  .toast__ic { background: var(--ok-soft); color: var(--ok); }
.toast.err .toast__ic { background: var(--danger-soft); color: var(--danger); }
.toast.warn .toast__ic { background: var(--warn-soft); color: var(--warn); }
.toast__msg { flex: 1; padding-top: 3px; color: var(--text); }
.toast__bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--accent); width: 100%; transform-origin: left; }
.toast.ok .toast__bar { background: var(--ok); } .toast.err .toast__bar { background: var(--danger); } .toast.warn .toast__bar { background: var(--warn); }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px) scale(.96); } }

/* ============================================================ MODAL */
.modal-scrim {
  position: fixed; inset: 0; z-index: 8000; background: var(--overlay);
  backdrop-filter: blur(4px); display: grid; place-items: center; padding: 24px;
  animation: fadeUp .18s var(--ease);
}
.modal {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); box-shadow: var(--sh-3); overflow: hidden; animation: pop .22s var(--ease);
}
.modal--wide { max-width: 560px; }
.modal__head { display: flex; align-items: center; gap: 12px; padding: 20px 22px 0; }
.modal__ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 16px; flex-shrink: 0; background: var(--accent-soft); color: var(--accent); }
.modal__ic.danger { background: var(--danger-soft); color: var(--danger); }
.modal__ic.warn { background: var(--warn-soft); color: var(--warn); }
.modal__ic.ok { background: var(--ok-soft); color: var(--ok); }
.modal__title { font-size: 15px; font-weight: 800; }
.modal__body { padding: 14px 22px 20px; color: var(--text-2); font-size: 13.5px; line-height: 1.6; white-space: pre-line; }
.modal__body .chips, .modal__body select, .modal__body input { white-space: normal; }
.modal__body strong { color: var(--text); }
.modal__foot { display: flex; gap: 10px; justify-content: flex-end; padding: 0 22px 22px; }
.modal__foot .btn { min-width: 96px; }

/* ============================================================ TOP PROGRESS */
#nprogress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 9999; pointer-events: none; }
#nprogress > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); box-shadow: 0 0 12px var(--accent-glow); transition: width .3s var(--ease), opacity .4s; }

/* ============================================================ LOGIN */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.login-wrap::before {
  content: ''; position: absolute; inset: -20%; z-index: 0;
  background:
    radial-gradient(500px circle at 25% 20%, var(--accent-soft), transparent 60%),
    radial-gradient(600px circle at 80% 80%, rgba(28, 44, 94, .5), transparent 55%);
  filter: blur(20px);
}
.login-card {
  position: relative; z-index: 1; width: 100%; max-width: 392px;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(20px); border: 1px solid var(--border-2);
  border-radius: var(--r-xl); padding: 34px; margin-top: 60px; box-shadow: var(--sh-3);
  animation: pop .3s var(--ease);
}
.login-card .logo {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 18px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2)); display: grid; place-items: center;
  font-size: 26px; color: var(--accent-ink); box-shadow: var(--sh-glow);
}
.login-card h1 { text-align: center; font-family: var(--display); font-size: 22px; font-weight: 600; letter-spacing: 1.4px; text-transform: uppercase; color: var(--gold); line-height: 1.2; }
.login-crest { display: block; width: 120px; height: 120px; margin: -70px auto 14px; border-radius: 50%; box-shadow: 0 0 0 3px var(--gold-2), 0 14px 40px var(--accent-glow); }
.login-card p.sub { text-align: center; color: var(--text-3); font-size: 12.5px; margin-bottom: 24px; }
.login-err { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); border-radius: 11px; padding: 10px 12px; font-size: 12.5px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; animation: pop .2s var(--ease); }

/* ============================================================ RECHERCHE RAPIDE (Ctrl+K) */
.topbar__titles { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__search {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 9px 0 12px; width: 290px; flex-shrink: 1; min-width: 36px;
  border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text-3);
  font-size: 12.5px; font-weight: 600; cursor: pointer; transition: .16s var(--ease); overflow: hidden;
}
.topbar__search:hover { border-color: var(--border-2); color: var(--text-2); }
.topbar__search span { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
kbd {
  font-family: var(--mono); font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 6px; white-space: nowrap;
  border: 1px solid var(--border-2); background: var(--bg-3); color: var(--text-3);
}
.pal-scrim {
  position: fixed; inset: 0; z-index: 8500; background: var(--overlay); backdrop-filter: blur(4px);
  display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; animation: fadeUp .16s var(--ease);
}
.pal { width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-lg); box-shadow: var(--sh-3); overflow: hidden; }
.pal__in { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.pal__in input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: 15px; color: var(--text); }
.pal__in input::placeholder { color: var(--text-3); }
.pal__list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.pal__item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.pal__item i { width: 18px; text-align: center; color: var(--text-3); }
.pal__item small { margin-left: auto; color: var(--text-3); font-size: 11px; font-weight: 700; white-space: nowrap; }
.pal__item.is-sel { background: var(--accent-soft); color: var(--text); }
.pal__item.is-sel i { color: var(--accent); }
.pal__empty { padding: 24px; text-align: center; color: var(--text-3); font-size: 13px; }
.pal__foot { display: flex; gap: 16px; padding: 9px 16px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 11px; font-weight: 600; }

/* ============================================================ TABLES TRIABLES / COPIE */
.tbl th[data-sortable] { cursor: pointer; user-select: none; }
.tbl th[data-sortable]:hover { color: var(--text); }
.tbl th[data-sortable]::after { content: '↕'; margin-left: 6px; opacity: .3; font-size: 11px; }
.tbl th[aria-sort="ascending"]::after { content: '▲'; opacity: 1; color: var(--accent); font-size: 9px; }
.tbl th[aria-sort="descending"]::after { content: '▼'; opacity: 1; color: var(--accent); font-size: 9px; }
code { cursor: copy; }
a code, button code, label code, summary code { cursor: inherit; }
button[data-busy] { cursor: progress; }

/* ============================================================ HELPERS */
.hidden { display: none !important; }
.mt-0{margin-top:0}.mt-1{margin-top:8px}.mt-2{margin-top:16px}.mt-3{margin-top:24px}
.text-2{color:var(--text-2)}.text-3{color:var(--text-3)}.text-ok{color:var(--ok)}.text-danger{color:var(--danger)}.text-warn{color:var(--warn)}
.fw-800{font-weight:800}.tabnum{font-variant-numeric:tabular-nums}
code { font-family: var(--mono); font-size: .88em; background: var(--bg-3); padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border); }

/* ============================================================ RESPONSIVE */
@media (max-width: 1120px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) {
  .grid.cols-3, .grid.cols-4, .grid.cols-2 { grid-template-columns: 1fr !important; }
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .28s var(--ease); box-shadow: var(--sh-3); }
  .sidebar.is-open { transform: none; }
  .topbar__toggle { display: grid; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar__sub { display: none; }
  .topbar__search { width: 36px; padding: 0; justify-content: center; }
  .topbar__search span, .topbar__search kbd { display: none; }
  .card:has(> table.tbl) { overflow-x: auto; }      /* tableaux hors .table-wrap : défilement horizontal */
  .pal__foot { display: none; }
  .page { padding: 16px; }
  .sb-scrim { position: fixed; inset: 0; background: var(--overlay); z-index: 55; backdrop-filter: blur(2px); animation: fadeUp .2s; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ============================================================ LSFD — Configuration du bot */
.cfg-alert { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; border-left: 3px solid var(--warn); }
.cfg-alert > i { font-size: 22px; color: var(--warn); }
.cfg-tabs {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 16px;
  position: sticky; top: 62px; z-index: 20; padding: 10px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
}
.cfg-tabs > a {
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 12.5px; font-weight: 600; display: inline-flex; gap: 7px; align-items: center;
}
.cfg-tabs > a:hover { border-color: var(--accent-line); color: var(--text); }
.cfg-tabs > a i { color: var(--gold); }
.cfg-sec { margin-bottom: 16px; scroll-margin-top: 130px; }
.cfg-help { font-size: 12.5px; margin: -6px 0 14px; }
.cfg-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 18px; }
.cfg-wide { grid-column: 1 / -1; }
.cfg-fields select[multiple] { min-height: 96px; }
.cfg-fields small { font-size: 11px; }
.cfg-color { display: flex; gap: 8px; }
.cfg-color input[type=color] { width: 44px; height: 40px; padding: 3px; border-radius: var(--r-sm); border: 1px solid var(--border-2); background: var(--surface-2); cursor: pointer; flex-shrink: 0; }
.cfg-grades { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); gap: 8px 18px; }
.cfg-group {
  grid-column: 1 / -1; margin: 10px 0 2px; font-family: var(--display); letter-spacing: 2px; text-transform: uppercase;
  font-size: 12px; color: var(--gold); display: flex; align-items: center; gap: 10px;
}
.cfg-group::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--gold-2), transparent); opacity: .5; }
.cfg-grade { display: grid; grid-template-columns: 30px 1fr 1.3fr; gap: 8px; align-items: center; }
.cfg-grade__n {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 800;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line);
}
.cfg-save {
  position: sticky; bottom: 12px; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--r-lg); border: 1px solid var(--border-2);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); box-shadow: var(--sh-3);
}
.cfg-save .text-3 { font-size: 12px; }
@media (max-width: 640px) {
  .cfg-grade { grid-template-columns: 28px 1fr; }
  .cfg-grade > .select, .cfg-grade > input.input[inputmode] { grid-column: 2; }
  .cfg-tabs { top: 56px; }
}
.cfg-live { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; border-left: 3px solid var(--gold); }
.cfg-live__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--gold); flex-shrink: 0; animation: cfgPulse 1s infinite; }
.cfg-live.is-ok { border-left-color: var(--ok); } .cfg-live.is-ok .cfg-live__dot { background: var(--ok); animation: none; }
.cfg-live.is-err { border-left-color: var(--danger); } .cfg-live.is-err .cfg-live__dot { background: var(--danger); animation: none; }
@keyframes cfgPulse { 50% { opacity: .3; transform: scale(.8); } }

/* Connexion avec Discord */
.btn-discord { width: 100%; justify-content: center; --_bg: #5865F2; --_bd: transparent; --_fg: #fff; background: #5865F2; color: #fff; border-color: transparent; font-weight: 700; }
.btn-discord:hover { background: #4752c4; color: #fff; }
.btn-discord i { font-size: 16px; }
.login-or { display: flex; align-items: center; gap: 10px; margin: 18px 0 14px; color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: 1px; }
.login-or::before, .login-or::after { content: ''; flex: 1; height: 1px; background: var(--border-2); }
.cfg-tiers { margin-top: 6px; }
.cfg-tier { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.cfg-tier .input { width: 150px; }

/* Candidatures */
.cv-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(460px, 100%), 1fr)); gap: 16px; }
.cv { display: flex; flex-direction: column; gap: 12px; }
.cv__head { display: flex; align-items: center; gap: 12px; }
.cv__who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cv__who b { font-size: 15px; }
.cv__who .text-3 { font-size: 12px; }
.cv__body { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13px; margin: 0; }
.cv__body dt { color: var(--gold); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; padding-top: 2px; }
.cv__body dd { margin: 0; color: var(--text-2); white-space: normal; overflow-wrap: anywhere; }
.cv__actions { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.cv__actions .select { flex: 1; min-width: 150px; }
.cv__err { color: var(--danger); font-size: 12.5px; margin: 0; }
.cv__done { font-size: 12.5px; margin: 0; border-top: 1px solid var(--border); padding-top: 10px; }
@media (max-width: 560px) { .cv__body { grid-template-columns: 1fr; } }

/* Fiche employé — gestion RH */
.rh__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 4px 20px; }
.rh__grid .select { min-width: 190px; }
.rh__status { margin: 4px 0 0; font-size: 13px; }
.cv__wait { margin: 0; font-size: 13px; color: var(--warn); background: var(--warn-soft); padding: 10px 12px; border-radius: var(--r-sm); }
.cv__ticket { font-size: 12.5px; }
.cv__ticket:hover { color: var(--accent); }
.cv__conv { border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2); }
.cv__conv > summary { cursor: pointer; padding: 9px 12px; font-size: 12.5px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.cv__conv > summary a { margin-left: auto; font-weight: 600; color: var(--text-3); }
.cv__conv > summary a:hover { color: var(--accent); }
.cv__msgs { max-height: 340px; overflow-y: auto; padding: 4px 12px 10px; display: flex; flex-direction: column; gap: 8px; }
.cv__msg { padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; }
.cv__msg.is-cand { border-color: var(--accent-line); }
.cv__msg.is-bot { opacity: .85; }
.cv__msg-h { margin-bottom: 3px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cv__msg-h .text-3 { font-size: 11px; }
.cv__msg-t { color: var(--text-2); overflow-wrap: anywhere; }
.cv__att { display: inline-flex; gap: 6px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--info); }
.cv__att img { max-width: 220px; max-height: 160px; border-radius: 6px; border: 1px solid var(--border); }
.cv__reply { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); align-items: flex-end; }
.cv__reply textarea { flex: 1; }
.cv__mat { width: 74px; text-align: center; }
