:root {
  --ink: #142B3B;
  --ink-2: #4A6070;
  --ink-3: #7C8F9B;
  --paper: #F3F6F5;
  --surface: #FFFFFF;
  --line: #DFE6E3;
  --teal: #0E6B66;
  --teal-d: #0A524E;
  --teal-soft: #E3F0EE;
  --saffron: #E2A52B;
  --saffron-soft: #FBF1DC;
  --ok: #2F8F5B;      --ok-soft: #E2F2E8;
  --danger: #B4443A;  --danger-soft: #F8E5E2;
  --violet: #5B5BA8;  --violet-soft: #E9E9F6;
  --radius: 10px;
  --font-display: "Sora", "Segoe UI", system-ui, sans-serif;
  --font-body: "Public Sans", "Segoe UI", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 .95rem/1.55 var(--font-body); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--teal); }
svg { max-width: 100%; }
:focus-visible { outline: 3px solid var(--saffron); outline-offset: 2px; }
.muted { color: var(--ink-2); }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.01em; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--ink); color: #C7D3DA; padding: 1.4rem 1rem;
}
.brand { display: flex; gap: .6rem; align-items: center; color: #fff; text-decoration: none; font: 600 1.02rem var(--font-display); padding: 0 .6rem 1.6rem; }
.brand-mark { width: 20px; height: 20px; background: var(--saffron); clip-path: polygon(50% 0, 63% 37%, 100% 50%, 63% 63%, 50% 100%, 37% 63%, 0 50%, 37% 37%); }
.nav { display: grid; gap: .15rem; }
.nav a { display: flex; gap: .7rem; align-items: center; padding: .62rem .7rem; border-radius: 8px; color: inherit; text-decoration: none; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(255,255,255,.1); color: #fff; box-shadow: inset 3px 0 0 var(--saffron); }
.nav svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; flex: none; }
.nav-count { margin-left: auto; background: var(--saffron); color: var(--ink); font-size: .74rem; font-weight: 700; border-radius: 999px; padding: 0 .45rem; min-width: 1.4rem; text-align: center; }
.me { margin-top: auto; display: flex; align-items: center; gap: .65rem; padding: .8rem .5rem 0; border-top: 1px solid rgba(255,255,255,.1); }
.me-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; font: 600 .82rem var(--font-display); flex: none; }
.me-info { display: grid; line-height: 1.25; min-width: 0; }
.me-info strong { color: #fff; font-weight: 600; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-info span { font-size: .78rem; }
.me-actions { margin-left: auto; display: flex; }
.me .icon-btn { color: #C7D3DA; }
.me .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

.main { min-width: 0; padding: 1.6rem clamp(1rem, 3vw, 2.5rem) 3rem; }
.main-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; min-height: 44px; }
.main-head h1 { font-size: 1.55rem; margin: 0; }
.head-actions { margin-left: auto; display: flex; gap: .5rem; }
.icon-btn.menu-btn { display: none; }

.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border: 0; background: none; border-radius: 8px; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--paper); color: var(--ink); }
.icon-btn svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; height: 40px; padding: 0 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: .9rem; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: #B9C8C3; }
.btn svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 2; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-d); border-color: var(--teal-d); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-sm { height: 32px; padding: 0 .7rem; font-size: .83rem; }
.btn-block { width: 100%; height: 46px; }
.btn[disabled] { opacity: .6; cursor: progress; }

/* ---------- Stats ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem 1.2rem; position: relative; overflow: hidden; }
.stat:hover { border-color: #B9C8C3; }
.stat strong { display: block; font: 700 2rem/1.1 var(--font-display); }
.stat span { color: var(--ink-2); font-size: .88rem; }
.stat::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--c, var(--teal)); }

/* ---------- Panels & tables ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 1.02rem; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; padding: .9rem 1.2rem; border-bottom: 1px solid var(--line); }
.filters input, .filters select { height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 0 .8rem; background: var(--paper); min-width: 0; }
.filters input { flex: 1 1 240px; }
.filters select { flex: 0 1 220px; }
.filters input:focus, .filters select:focus { outline: none; border-color: var(--teal); background: #fff; }
.filters .count { align-self: center; color: var(--ink-3); font-size: .85rem; margin-left: auto; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; font-size: .8rem; color: var(--ink-3); padding: .7rem 1.2rem; background: #FAFBFB; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .85rem 1.2rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #F7FAF9; }
td .sub { display: block; color: var(--ink-3); font-size: .83rem; }
.cell-name { font-weight: 600; }
.cell-actions { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.cell-actions .btn + .btn { margin-left: .3rem; }
.num-link { font-weight: 600; text-decoration: none; }
.num-link em { font-style: normal; color: #8A5B10; background: var(--saffron-soft); border-radius: 999px; padding: 0 .4rem; font-size: .78rem; margin-left: .3rem; }

.badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 600; padding: .18rem .55rem; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-nouvelle { background: var(--saffron-soft); color: #8A5B10; }
.b-acceptee, .b-publiee { background: var(--ok-soft); color: var(--ok); }
.b-refusee { background: var(--danger-soft); color: var(--danger); }
.b-cvtheque { background: var(--violet-soft); color: var(--violet); }
.b-brouillon { background: #ECEFF1; color: var(--ink-2); }
.b-fermee { background: #ECEFF1; color: var(--ink-3); }

.empty { padding: 3rem 1.5rem; text-align: center; color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); font: 600 1.05rem var(--font-display); margin-bottom: .3rem; }
.empty .btn { margin-top: 1rem; }
.loading { padding: 3rem; text-align: center; color: var(--ink-3); }

/* ---------- Forms ---------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: .3rem; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: .6rem .8rem; }
.field input, .field select { height: 42px; padding-block: 0; }
.field textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14,107,102,.14); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); }
.field .hint { display: block; color: var(--ink-3); font-size: .8rem; margin-top: .25rem; }
.field .err { display: block; color: var(--danger); font-size: .8rem; margin-top: .25rem; }
.field .err:empty { display: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
.form-foot { display: flex; justify-content: flex-end; gap: .5rem; padding-top: .5rem; }
.form-msg { color: var(--danger); font-size: .88rem; margin: .6rem 0 0; }
.form-msg:empty { display: none; }
.check { display: flex; gap: .5rem; align-items: center; font-size: .87rem; color: var(--ink-2); cursor: pointer; }
.check input { accent-color: var(--teal); width: 16px; height: 16px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 1rem; background: rgba(15,30,40,.55); }
.modal[hidden] { display: none; }
.modal-panel { width: min(760px, 100%); max-height: calc(100vh - 2rem); display: flex; flex-direction: column; background: var(--surface); border-radius: 16px; animation: rise .22s ease-out; }
.modal-panel.sm { width: min(460px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-body { padding: 1.3rem 1.4rem; overflow: auto; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }

/* ---------- Drawer (fiche candidat) ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(15,30,40,.4); }
.drawer { position: fixed; z-index: 50; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); overflow-y: auto; box-shadow: -20px 0 60px -20px rgba(15,30,40,.4); animation: slide .22s ease-out; }
.drawer[hidden] { display: none; }
.drawer-close { position: absolute; top: .9rem; right: .9rem; }
.cand-head { padding: 1.6rem 1.6rem 1.2rem; border-bottom: 1px solid var(--line); }
.cand-head h2 { margin: .5rem 0 .2rem; font-size: 1.5rem; padding-right: 2.5rem; }
.cand-head .poste { color: var(--ink-2); }
.cand-contact { display: grid; gap: .35rem; margin: 1rem 0 0; }
.cand-contact a { display: inline-flex; gap: .5rem; align-items: center; text-decoration: none; color: var(--ink); }
.cand-contact svg { width: 16px; fill: none; stroke: var(--ink-3); stroke-width: 1.8; }
.cv-box { display: flex; gap: .8rem; align-items: center; margin-top: 1.2rem; padding: .8rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.cv-ext { width: 42px; height: 50px; border-radius: 6px; background: var(--teal); color: #fff; display: grid; place-items: center; font: 700 .72rem var(--font-display); text-transform: uppercase; flex: none; }
.cv-name { min-width: 0; flex: 1; font-size: .88rem; word-break: break-all; }
.cv-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.section { padding: 1.3rem 1.6rem; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: 0; }
.section h3 { font-size: .98rem; margin: 0 0 .8rem; }
.decision { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: .8rem; }
.decision button { height: 44px; border-radius: 8px; border: 1.5px solid var(--line); background: #fff; font-weight: 600; cursor: pointer; font-size: .87rem; }
.decision [data-s=acceptee]:hover, .decision [data-s=acceptee].on { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.decision [data-s=refusee]:hover, .decision [data-s=refusee].on { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.decision [data-s=cvtheque]:hover, .decision [data-s=cvtheque].on { border-color: var(--violet); color: var(--violet); background: var(--violet-soft); }
.decision button.on { cursor: default; }
.readonly-note { background: var(--violet-soft); color: var(--violet); border-radius: 8px; padding: .7rem .9rem; font-size: .87rem; }
.thread { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.thread li { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; }
.thread .t-head { display: flex; justify-content: space-between; gap: .5rem; font-size: .8rem; color: var(--ink-3); margin-bottom: .3rem; }
.thread strong { display: block; font-size: .9rem; margin-bottom: .25rem; }
.thread p { margin: 0; white-space: pre-line; font-size: .88rem; color: var(--ink-2); }
.warn { color: #8A5B10; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 1.5rem; z-index: 90; translate: -50% 1rem; opacity: 0; pointer-events: none; background: var(--ink); color: #fff; padding: .75rem 1.1rem; border-radius: 10px; font-size: .9rem; transition: opacity .2s, translate .2s; max-width: calc(100% - 2rem); }
.toast.show { opacity: 1; translate: -50% 0; }
.toast.error { background: var(--danger); }

/* ---------- Login ---------- */
.login-page { display: grid; grid-template-columns: 1fr minmax(360px, 480px); min-height: 100vh; }
.login-art { position: relative; background: var(--ink); color: #2D7A73; overflow: hidden; }
.login-art svg { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .5; }
.login-art p { position: absolute; left: 2.5rem; bottom: 2rem; margin: 0; color: #fff; font: 600 1.1rem var(--font-display); }
.login-box { display: flex; flex-direction: column; justify-content: center; padding: 2.5rem clamp(1.5rem, 5vw, 3.5rem); background: var(--surface); }
.login-box h1 { margin: 0 0 .3rem; font-size: 1.7rem; }
.login-box form { margin-top: 1.8rem; }
.login-box .back { margin-top: 1.6rem; font-size: .88rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 45; left: 0; width: 260px; translate: -100% 0; transition: translate .2s; }
  .sidebar.open { translate: 0 0; }
  .icon-btn.menu-btn { display: inline-grid; }
  .main-head h1 { font-size: 1.3rem; }
  .hide-sm { display: none; }
  .login-page { grid-template-columns: 1fr; }
  .login-art { display: none; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .decision { grid-template-columns: 1fr; }
  .head-actions .btn span { display: none; }
  td, th { padding-inline: .8rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
