/* CASTOR – feuille de style (même charte que les maquettes) */
:root {
  --ground: #F4F2EE; --panel: #fff; --ink: #1B2433; --muted: #5A6474; --line: #DDD8CF; --line-soft: #ECE8E1;
  --accent: #B8410E; --accent-dark: #8A300A; --nav: #1B2433; --nav-active: #2C3850; --nav-text: #D5DAE3;
  --ok: #1E6537; --ok-bg: #E2F1E6; --warn: #863A0A; --warn-bg: #FCEBD9; --bad: #9E2419; --bad-bg: #FBE3E1;
  --info: #1D4E89; --info-bg: #E3ECF8; --violet: #563687; --violet-bg: #EDE6F7; --grey: #454A52; --grey-bg: #ECEAE5;
  --font: "Inter", "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
h1 { font-size: 28px; margin: 0; line-height: 1.25; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 15px; margin: 0; }
p { margin: 0; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pre { white-space: pre-line; }

/* Mise en page */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.nav { flex: 1 1 240px; max-width: 100%; background: var(--nav); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 20px; color: #fff; text-decoration: none; }
.brand img { width: 54px; height: 54px; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35)); }
.brand b { display: block; font-size: 22px; letter-spacing: .03em; }
.brand span { font-size: 12px; color: #A9B2C2; letter-spacing: .04em; }
.nav a.item { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 12px; border-radius: 6px; color: var(--nav-text); text-decoration: none; }
.nav a.item:hover { background: #26324A; color: #fff; }
.nav a.item.active { background: var(--nav-active); color: #fff; font-weight: 600; }
.nav .who { margin-top: auto; padding: 18px 12px 0; border-top: 1px solid #2E3A52; display: flex; flex-direction: column; gap: 2px; }
.nav .who b { font-size: 15px; }
.nav .who span { font-size: 13px; color: #A9B2C2; }
.nav .who .links { display: flex; gap: 14px; margin-top: 8px; }
.nav .who a, .nav .who button.linklike { color: #D5DAE3; font-size: 13px; }
.main { flex: 999 1 560px; min-width: 0; padding: 28px 36px 48px; display: flex; flex-direction: column; gap: 22px; max-width: 1320px; }
@media (max-width: 860px) { .main { padding: 20px 16px 40px; } .nav { padding: 12px; } .nav .who { margin-top: 8px; } }
/* Grand écran : le menu garde sa largeur, l'espace libre reste à droite au lieu d'élargir le menu */
@media (min-width: 861px) { .nav { flex: 0 0 260px; } }
/* Menu repliable : barre d'icônes sur grand écran, menu « hamburger » sur mobile */
.nav-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.nav-items { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.who-txt { display: flex; flex-direction: column; gap: 2px; }
.nav-toggle { flex: none; width: 36px; height: 36px; margin-top: 8px; border-radius: 8px; border: 1px solid #2E3A52; background: transparent; color: #A9B2C2; cursor: pointer; display: grid; place-items: center; }
.nav-toggle:hover { background: #26324A; color: #fff; }
.nav-toggle .ico { transition: transform .2s; }
.nav .ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a.item { justify-content: flex-start; gap: 12px; position: relative; }
.nav a.item .b { margin-left: auto; }
.nav .who .links a, .nav .who .links button { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.nav .who .links .lbl { font-size: 13px; color: inherit; }
.nav .who .links .ico { width: 16px; height: 16px; }
.shell .nav { transition: flex-basis .2s ease; }
@media (min-width: 861px) {
  .nav { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
  html[data-nav=replie] .nav { flex-basis: 76px; padding: 20px 10px; }
  html[data-nav=replie] .nav-top { flex-direction: column; align-items: center; }
  html[data-nav=replie] .brand { padding: 0 0 6px; }
  html[data-nav=replie] .brand img { width: 44px; height: 44px; }
  html[data-nav=replie] .brand div, html[data-nav=replie] .nav .lbl, html[data-nav=replie] .who-txt { display: none; }
  html[data-nav=replie] .nav-toggle { margin: 0 0 12px; }
  html[data-nav=replie] .nav-toggle .ico { transform: rotate(180deg); }
  html[data-nav=replie] .nav a.item { justify-content: center; padding: 0; }
  html[data-nav=replie] .nav a.item .b { position: absolute; top: 4px; right: 4px; min-width: 18px; padding: 0 5px; font-size: 10px; line-height: 16px; }
  html[data-nav=replie] .nav .who { padding: 14px 0 0; align-items: center; }
  html[data-nav=replie] .nav .who .links { flex-direction: column; gap: 14px; align-items: center; }
}
@media (max-width: 860px) {
  .nav-toggle { margin-top: 4px; }
  .nav-toggle .ico { transform: rotate(-90deg); }
  html[data-nav=replie] .nav-toggle .ico { transform: rotate(90deg); }
  html[data-nav=replie] .nav-items { display: none; }
  html[data-nav=replie] .brand { padding-bottom: 0; }
}
/* Sections du menu */
.nav-sec { margin: 14px 12px 4px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #7D879A; }
.nav-sec.nav-sep { margin: 10px 12px; height: 1px; background: #2E3A52; }
.nav-items > .nav-sec:first-child { margin-top: 4px; }
@media (min-width: 861px) {
  html[data-nav=replie] .nav-sec { margin: 8px 10px; height: 1px; font-size: 0; background: #2E3A52; }
  html[data-nav=replie] .nav-items > .nav-sec:first-child { display: none; }
}
/* Pages qui profitent de toute la largeur (cartographie) */
.main.wide { max-width: none; }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px; }
.page-head .titles { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 420px; }
.crumbs { font-size: 14px; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.cols { display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-start; }
.cols > .wide { flex: 999 1 600px; min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.cols > .side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; }
.grid-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
@media (max-width: 500px) { .grid-2 { grid-template-columns: 1fr; } }

/* Cartes */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.card.pad { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.card.soft { background: #FAF8F5; }
.card.alert { border-color: #E8B4AE; }
.card-head { padding: 18px 22px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; }
.card-head .sub { font-size: 14px; color: var(--muted); }
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.kpi .v { font-size: 32px; font-weight: 700; }
.kpi .l { font-size: 14px; color: var(--muted); }
.kpi.bad .v, .kpi.bad .l { color: var(--bad); }
.kpi.violet .v { color: var(--violet); }
.kpi progress { width: 100%; height: 8px; }
progress { appearance: none; border: 0; border-radius: 4px; background: var(--line-soft); }
progress::-webkit-progress-bar { background: var(--line-soft); border-radius: 4px; }
progress::-webkit-progress-value { background: var(--ok); border-radius: 4px; }
progress::-moz-progress-bar { background: var(--ok); border-radius: 4px; }

.list-item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.list-item:last-child { border-bottom: 0; }
.list-item .t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list-item .t a { font-weight: 600; text-decoration: none; }
.list-item .r { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; white-space: nowrap; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }

/* Badges */
.b { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.b.gray { background: var(--grey-bg); color: var(--grey); }
.b.blue { background: var(--info-bg); color: var(--info); }
.b.orange { background: var(--warn-bg); color: var(--warn); }
.b.violet { background: var(--violet-bg); color: var(--violet); }
.b.green { background: var(--ok-bg); color: var(--ok); }
.b.red { background: var(--bad-bg); color: var(--bad); }
.nav .b { font-size: 12px; }

/* Formulaires */
label.f, .f { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: #2A3240; }
.f .hint { font-weight: 400; font-size: 13px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=number], select, textarea {
  font: inherit; font-size: 15px; font-weight: 400; min-height: 44px; padding: 8px 12px; border: 1px solid #B9B2A6; border-radius: 6px;
  background: #fff; color: var(--ink); width: 100%;
}
textarea { resize: vertical; line-height: 1.5; min-height: 96px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #E9A27A; outline-offset: 1px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 6px; font: inherit; font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer; border: 1px solid transparent; white-space: nowrap; background: none; }
.btn.p { background: var(--accent); color: #fff; }
.btn.p:hover { background: var(--accent-dark); color: #fff; }
.btn.s { background: #fff; color: var(--ink); border-color: #B9B2A6; }
.btn.s:hover { border-color: var(--ink); }
.btn.g { color: var(--accent); padding: 0 8px; }
.btn.danger { color: var(--bad); border-color: #E8B4AE; background: #fff; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn:disabled { background: var(--grey-bg); color: var(--muted); border-color: var(--line); cursor: not-allowed; }
button.linklike { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 12px; border-radius: 999px; background: var(--info-bg); color: var(--info); font-size: 14px; font-weight: 600; }
.chip button { border: 0; background: transparent; color: var(--info); font-size: 17px; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; }
.chip button:hover { background: #CFDDF2; }
.picker { display: flex; flex-direction: column; gap: 8px; }
.radio-cards { display: flex; flex-wrap: wrap; gap: 12px; }
.radio-cards label { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid #B9B2A6; border-radius: 8px; cursor: pointer; flex: 1 1 220px; font-weight: 400; }
.radio-cards input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); }
.err { color: var(--bad); font-size: 14px; font-weight: 600; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #FAF8F5; white-space: nowrap; }
table.t td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.t tr.late td { background: #FFF8F7; }
table.t td.actions-cell { white-space: nowrap; text-align: right; }
table.t a.strong { font-weight: 600; text-decoration: none; }

/* Fiche PAC */
.stepper { display: flex; flex-wrap: wrap; gap: 8px; padding: 18px 22px; }
.stepper .st { flex: 1 1 130px; min-width: 0; border-top: 4px solid var(--line); padding-top: 10px; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.stepper .st.done { border-color: var(--ok); }
.stepper .st.cur { border-color: var(--accent); }
.stepper .st.cur span { color: var(--warn); font-weight: 600; }
.stepper .st.todo b { color: var(--muted); }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.kv > div { display: flex; flex-direction: column; gap: 4px; }
.k { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sig { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ok); background: #F1F8F3; border: 1px solid #CFE6D6; border-radius: 6px; padding: 8px 12px; }
.sig.warn { color: var(--warn); background: #FFF6EE; border-color: #F2D2B6; }
.timeline { display: flex; flex-direction: column; }
.timeline .ev { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 12px; padding-bottom: 14px; font-size: 14px; }
.timeline .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--info); }
.timeline .dot.ok { background: var(--ok); }
.timeline .dot.bad { background: var(--bad); }
.timeline .dot.warn { background: var(--accent); }

/* Onglets */
.tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tabs a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-bottom: 3px solid transparent; font-weight: 600; text-decoration: none; color: var(--muted); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Boîtes de dialogue */
dialog { border: 0; border-radius: 12px; padding: 0; width: min(640px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); color: var(--ink); }
dialog::backdrop { background: rgba(27, 36, 51, .45); }
dialog form { display: flex; flex-direction: column; gap: 16px; padding: 24px; }
dialog h2 { font-size: 20px; }

/* Notifications */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 8px; font-size: 14px; max-width: 380px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.toast.bad { background: var(--bad); }

/* Connexion */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login .card { width: min(440px, 100%); padding: 32px; display: flex; flex-direction: column; gap: 18px; }
.login .logo { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.login .logo img { width: 200px; height: 200px; border-radius: 22px; }
.login .logo b { font-size: 30px; letter-spacing: .03em; display: block; }
.login .sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.login .sep::before, .login .sep::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.loading { color: var(--muted); padding: 30px 0; }
.dlg-body { display: flex; flex-direction: column; gap: 14px; }
.card.link { text-decoration: none; color: inherit; }
.card.link:hover { border-color: var(--violet); }
.nowrap { white-space: nowrap; }
label.f.row { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; }
label.f.row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.card { padding: 14px 16px; }
legend { padding: 0; margin-bottom: 8px; }
ol.small { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 8px; }
.row-actions .btn.g { padding: 0 6px; }
table.t td.mono, table.t .mono { white-space: nowrap; }
