/* ======================= SURFACES ======================= */
.panel {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line-soft);
}
.panel-head h3 { font-size: var(--fs-14); letter-spacing: .01em; }
.panel-body { padding: var(--s-5); }
.panel-body.flush { padding: 0; }
.panel-foot { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--line-soft); }

.card {
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--s-4);
  transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
a.card:hover, button.card:hover, .card.clickable:hover {
  border-color: var(--brand-line); transform: translateY(-1px); box-shadow: var(--shadow-2);
}
.card.clickable { cursor: pointer; text-align: left; width: 100%; }

.grid { display: grid; gap: var(--s-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 700px)  { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ======================== BOUTONS ======================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 36px; padding: 0 var(--s-4);
  border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--bg-2); color: var(--tx-1);
  font-size: var(--fs-13); font-weight: 500; white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
}
.btn:hover { background: var(--bg-3); border-color: var(--tx-3); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-loading { opacity: .55; pointer-events: none; }
.btn.is-loading::before {
  content: ""; width: 13px; height: 13px; border-radius: var(--r-full);
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-primary { background: var(--brand); color: var(--brand-tx); border-color: transparent; }
.btn-primary:hover { background: var(--brand); filter: brightness(1.08); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--tx-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--tx-1); border-color: transparent; }
.btn-outline { background: transparent; }
.btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn-gate { background: var(--dep, var(--brand)); color: #0B0D10; border-color: transparent; font-weight: 600; }
.btn-gate:hover { filter: brightness(1.08); }
.btn-sm { height: 30px; padding: 0 var(--s-3); font-size: var(--fs-12); }
.btn-lg { height: 44px; padding: 0 var(--s-6); font-size: var(--fs-14); }
.btn-block { width: 100%; }

/* ======================== BADGES ======================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px;
  border-radius: var(--r-full);
  background: var(--bg-3); color: var(--tx-2);
  font-family: var(--f-mono); font-size: var(--fs-11);
  letter-spacing: .04em; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: var(--r-full); background: currentColor; }
.badge.plain::before { display: none; }
.badge-ok     { color: var(--ok);     background: color-mix(in srgb, var(--ok) 14%, transparent); }
.badge-warn   { color: var(--warn);   background: color-mix(in srgb, var(--warn) 14%, transparent); }
.badge-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.badge-info   { color: var(--info);   background: color-mix(in srgb, var(--info) 14%, transparent); }
.badge-dep    { color: var(--dep);    background: color-mix(in srgb, var(--dep) 15%, transparent); }

/* Voyant REC (tournage en cours) */
.rec-dot { width: 8px; height: 8px; border-radius: var(--r-full); background: var(--rec); animation: rec 1.6s ease-in-out infinite; }
@keyframes rec { 50% { opacity: .25; } }

/* ======================== TABLEAUX ====================== */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
.tbl th {
  text-align: left; padding: var(--s-3) var(--s-4);
  font-family: var(--f-mono); font-size: var(--fs-11);
  letter-spacing: .12em; text-transform: uppercase; color: var(--tx-3); font-weight: 400;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line-soft); color: var(--tx-2); vertical-align: middle; }
.tbl tbody tr { transition: background var(--t-fast); }
.tbl tbody tr:hover { background: var(--bg-2); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl td.strong, .tbl td b { color: var(--tx-1); font-weight: 500; }
.tbl tr:last-child td { border-bottom: 0; }

/* ====================== FORMULAIRES ===================== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s-4); }
.field > label { font-size: var(--fs-12); color: var(--tx-3); }
.input, .select, .textarea {
  width: 100%; min-height: 36px; padding: 8px var(--s-3);
  background: var(--bg-3); color: var(--tx-1);
  border: 1px solid var(--line); border-radius: var(--r-md);
  outline: none; font-size: var(--fs-13);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--tx-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); background: var(--bg-2); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--tx-3) 50%), linear-gradient(135deg, var(--tx-3) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: var(--s-8); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--s-4); }
@media (max-width: 700px) { .field-row { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-13); cursor: pointer; }
.check input { accent-color: var(--brand); width: 16px; height: 16px; }
.hint { font-size: var(--fs-11); color: var(--tx-3); }

/* ========================= TABS ========================= */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  position: relative; padding: var(--s-3) var(--s-4);
  color: var(--tx-3); font-size: var(--fs-13); white-space: nowrap;
  transition: color var(--t-fast);
}
.tab:hover { color: var(--tx-2); }
.tab.is-active { color: var(--tx-1); }
.tab.is-active::after {
  content: ""; position: absolute; left: var(--s-3); right: var(--s-3); bottom: -1px;
  height: 2px; background: var(--dep, var(--brand)); border-radius: 2px;
}

/* ======================== MODALES ======================= */
.modal-scrim {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: var(--scrim); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: var(--s-4);
  animation: fade-in var(--t-fast) var(--e-out);
}
.modal {
  width: min(680px, 100%); max-height: 88dvh;
  display: flex; flex-direction: column;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  animation: modal-in var(--t-mid) var(--e-out);
}
.modal.wide { width: min(980px, 100%); }
.modal.slim { width: min(460px, 100%); }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line-soft); }
.modal-body { padding: var(--s-5); overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line-soft); }
@media (max-width: 700px) {
  .modal-scrim { padding: 0; align-items: flex-end; }
  .modal { width: 100%; max-height: 92dvh; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  @keyframes modal-in { from { transform: translateY(40px); } }
  .modal-foot .btn { flex: 1; }
}

/* ========================= TOASTS ======================= */
.toasts { position: fixed; bottom: var(--s-5); right: var(--s-5); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--s-2); max-width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--bg-2); border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--r-md); box-shadow: var(--shadow-3);
  font-size: var(--fs-13); color: var(--tx-1);
  animation: toast-in var(--t-mid) var(--e-out);
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.out { animation: toast-out var(--t-fast) var(--e-out) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }
@media (max-width: 700px) { .toasts { left: var(--s-3); right: var(--s-3); bottom: var(--s-3); max-width: none; } }

/* ==================== ÉTATS & SQUELETTES ================ */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); padding: var(--s-10) var(--s-5); text-align: center; }
.empty .ico { color: var(--tx-3); opacity: .5; }
.empty h4 { color: var(--tx-1); }
.empty p { color: var(--tx-3); font-size: var(--fs-13); max-width: 42ch; }

.skel { background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 50%, var(--bg-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: var(--r-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-line { height: 12px; margin-bottom: var(--s-2); }
.skel-card { height: 92px; }

/* ==================== DIVERS PARTAGÉS =================== */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: var(--s-2) var(--s-4); font-size: var(--fs-13); }
.kv dt { color: var(--tx-3); }
.kv dd { margin: 0; color: var(--tx-1); }
@media (max-width: 700px) { .kv { grid-template-columns: 1fr; gap: 2px var(--s-2); } .kv dd { margin-bottom: var(--s-2); } }

.progress { height: 5px; background: var(--bg-3); border-radius: var(--r-full); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--dep, var(--brand)); border-radius: var(--r-full); transition: width var(--t-slow) var(--e-out); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 var(--s-3);
  background: var(--bg-3); border: 1px solid transparent; border-radius: var(--r-full);
  font-size: var(--fs-12); color: var(--tx-2); transition: all var(--t-fast);
}
.chip:hover { border-color: var(--line); color: var(--tx-1); }
.chip.is-on { background: var(--brand-soft); border-color: var(--brand-line); color: var(--tx-1); }

.stack-list > * { border-bottom: 1px solid var(--line-soft); }
.stack-list > *:last-child { border-bottom: 0; }
.list-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-5); transition: background var(--t-fast); }
.list-row:hover { background: var(--bg-2); }
.list-row .eyebrow, .list-row .badge { white-space: nowrap; flex: none; }
.presence-row .eyebrow { white-space: nowrap; flex: none; }

/* ================= CARTES — TRAITEMENT MAQUETTE ================= */
.panel { background: var(--bg-1); border-radius: var(--r-lg); }
.panel-head { padding: var(--s-4) var(--s-5) var(--s-3); border-bottom: 0; }
.panel-head h3 {
  font-size: var(--fs-13); letter-spacing: .14em; text-transform: uppercase;
  color: var(--tx-1); font-weight: 700;
}
.panel-head .btn-ghost, .panel-head a.btn-sm { color: var(--brand); }
.card { background: var(--bg-1); }

/* Tuile chiffrée : une icône, un nombre, un mot. */
.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: var(--s-3); }
.tuile {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: var(--s-4) var(--s-2); border-radius: var(--r-md);
  background: var(--bg-2); border: 1px solid var(--line-soft);
  transition: border-color var(--t-fast), transform var(--t-fast);
}
a.tuile:hover, button.tuile:hover { border-color: var(--brand-line); transform: translateY(-1px); }
.tuile .ico { color: var(--brand); }
.tuile .n { font-size: var(--fs-22); font-weight: 700; color: var(--tx-1); line-height: 1.1; }
.tuile .l { font-size: var(--fs-12); color: var(--tx-2); text-align: center; }
.tuile.vide .n { color: var(--tx-3); }
.tuile.vide .ico { color: var(--tx-3); opacity: .6; }

/* Bouton principal : une seule action évidente par écran. */
.btn-hero {
  height: 46px; padding: 0 var(--s-6); font-size: var(--fs-14); font-weight: 600;
  background: var(--brand); color: var(--brand-tx); border-color: transparent;
  box-shadow: 0 8px 24px -12px var(--brand);
}
.btn-hero:hover { filter: brightness(1.06); border-color: transparent; }

/* Signaux : le vocabulaire des couleurs, une seule fois. */
.sig-termine { --sig: var(--ok); }
.sig-encours { --sig: var(--info); }
.sig-attente { --sig: var(--warn); }
.sig-bloque  { --sig: var(--danger); }
.sig-neutre  { --sig: var(--neutre); }
.point-sig { width: 8px; height: 8px; border-radius: var(--r-full); background: var(--sig); flex: none; }
.badge-sig { color: var(--sig); background: color-mix(in srgb, var(--sig) 14%, transparent); }

/* ==================== SECTIONS REPLIABLES ====================
   Sur ordinateur, tout est ouvert : le repli ne sert qu'au doigt. */
.repliable-tete {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3); text-align: left; cursor: default;
}
.repliable-chevron { display: none; color: var(--tx-3); transition: transform var(--t-fast) var(--e-out); }
.repliable-corps { display: block; }

@media (max-width: 1100px) {
  .repliable-tete { cursor: pointer; }
  .repliable-tete:hover h3 { color: var(--brand); }
  .repliable-chevron { display: flex; }
  .repliable[data-open="false"] .repliable-chevron { transform: rotate(-90deg); }
  .repliable-corps {
    display: grid; grid-template-rows: 1fr;
    transition: grid-template-rows var(--t-mid) var(--e-out);
  }
  .repliable[data-open="false"] .repliable-corps { grid-template-rows: 0fr; }
  .repliable-corps > * { overflow: hidden; min-height: 0; }
}
