/* ============================================================================
   ORCA — feuille de style. Reprend la base de Budgeo (charte GRETA-CFA de la
   Loire : orange + gris anthracite) pour que les outils maison se
   ressemblent, puis ajoute les styles propres à la grille annuelle.
   ========================================================================== */
:root {
  --bg: #f4f1ee;
  --surface: #ffffff;
  --border: #e3ddd6;
  --text: #262320;
  --text-muted: #6f6a63;
  --primary: #e2600c;
  --primary-hover: #b94d08;
  --primary-light: #fdecdf;
  --ink: #2b2a28;
  --ink-2: #3d3b38;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --success: #1e7d3c;
  --success-bg: #eaf7ee;
  --warning: #9a4a00;
  --warning-bg: #fdf0dc;
  --info: #1d5fa8;
  --info-bg: #e8f0fa;
  --radius: 8px;

  /* Grille de planification */
  --cell-centre: #f6d66b;
  --cell-centre-light: #fff7d6;
  --cell-a-affecter: #b88a00;
  --cell-entreprise: repeating-linear-gradient(135deg, #cfe0f2 0 4px, #e7f0f9 4px 8px);
  --cell-entreprise-text: #1d4f8c;
  --cell-vacances: radial-gradient(#bdb9b0 0.9px, transparent 1px) 0 0 / 4px 4px, #fbfaf8;
  --cell-weekend: #e7e5df;
  --cell-fermeture: #4a5260;
  --cell-conflit-bg: #fad4cf;
  --cell-conflit: #b42318;
  --cell-alerte: #b54708;
  --cell-selection: rgba(29, 95, 168, 0.30);

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

header.app-header {
  background: var(--ink);
  border-bottom: 3px solid var(--primary);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
header.app-header h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: .06em; }
header.app-header h1 a { color: #fff; text-decoration: none; display: flex; align-items: center; gap: 8px; }
header.app-header h1 .accent { color: var(--primary); }
header.app-header .logo-icon { height: 38px; width: 38px; display: block; object-fit: contain; }

nav.app-nav { display: flex; gap: 6px; flex-wrap: wrap; }
nav.app-nav a { color: #d8d5d1; text-decoration: none; padding: 6px 12px; border-radius: var(--radius); font-size: 13px; }
nav.app-nav a:hover { background: var(--ink-2); color: #fff; }
nav.app-nav a.active { background: var(--primary); color: #fff; font-weight: 600; }
#user-info { color: #c9c5c0; font-size: 13px; }
#user-info a { color: #fff; }
#user-info .muted { color: #a9a49e; }

main { max-width: 1500px; margin: 0 auto; padding: 24px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card h2 { margin-top: 0; font-size: 16px; }
.card h2 .subtitle { color: var(--text-muted); font-weight: 400; font-size: 13px; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.toolbar .label-groupe { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); min-width: 84px; }

button, .btn {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s, transform .12s;
}
button:hover, .btn:hover { border-color: var(--primary); color: var(--primary); }
button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(43, 42, 40, .15); }
button.primary:hover, .btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; box-shadow: 0 3px 8px rgba(43, 42, 40, .22); transform: translateY(-1px); }
button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); background: var(--danger-bg); }
button:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; transform: none; }
button.chip { border-radius: 999px; padding: 5px 12px; font-size: 13px; }
button.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
button.chip .swatch { width: 14px; height: 14px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); display: inline-block; }

kbd { font: 600 11px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }

input[type=text], input[type=number], input[type=date], input[type=password], input[type=color], select, textarea {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  background: #fff;
  color: var(--text);
}
input[type=color] { padding: 2px; height: 34px; width: 52px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
label { font-size: 13px; color: var(--text-muted); display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }

table.simple { width: 100%; border-collapse: collapse; font-size: 13px; }
table.simple th, table.simple td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.simple th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
table.simple tr:hover td { background: #fafaf9; }
table.simple td.num, table.simple th.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.badge.brouillon { background: var(--primary-light); color: var(--primary-hover); }
.badge.valide, .badge.actif { background: var(--success-bg); color: var(--success); }
.badge.archive { background: #eee; color: #666; }
.badge.conflit { background: var(--cell-conflit); color: #fff; }
.badge.alerte { background: var(--warning-bg); color: var(--warning); }

.code-pill { display: inline-block; min-width: 30px; text-align: center; padding: 1px 6px; border-radius: 4px; font: 700 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--bg); border: 1px solid var(--border); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: none; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 8px 14px; color: var(--text-muted); }
.tabs button.active { border-bottom-color: var(--primary); color: var(--text); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.msg { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 13px; box-shadow: 0 4px 14px rgba(43, 42, 40, 0.18); }
.msg.error { background: var(--danger-bg); color: var(--danger); }
.msg.success { background: var(--success-bg); color: var(--success); }
.msg.info { background: var(--primary-light); color: var(--primary-hover); }
#messages { position: sticky; top: 0; z-index: 100; }

.muted { color: var(--text-muted); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

.stat-row { display: flex; gap: 14px; flex-wrap: wrap; }
.stat { background: var(--bg); border-radius: var(--radius); padding: 12px 16px; min-width: 130px; }
.stat .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .label { font-size: 12px; color: var(--text-muted); }
.stat .value.ok { color: var(--success); }
.stat .value.warn { color: var(--warning); }
.stat .value.ko { color: var(--danger); }

.barre { height: 8px; border-radius: 999px; background: #ebe7e2; overflow: hidden; margin-top: 6px; }
.barre > span { display: block; height: 100%; background: var(--info); border-radius: 999px; }
.barre.depasse > span { background: var(--cell-alerte); }

dialog { border: none; border-radius: 10px; padding: 0; max-width: 520px; width: 92%; }
dialog::backdrop { background: rgba(30, 28, 26, .45); }
dialog form { padding: 20px; }

/* ============================================================================
   Page action : grille annuelle
   ========================================================================== */

.action-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; }
.action-head h2 { margin: 2px 0; font-size: 24px; }
.action-head .surtitre { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }

.outils { display: flex; flex-direction: column; gap: 10px; }
.outils .ligne { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.outils .ligne + .ligne.sep { border-top: 1px solid var(--border); padding-top: 10px; }

.etat-ligne { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; font-size: 13px; margin-bottom: 8px; }
.etat-ligne strong { font-variant-numeric: tabular-nums; }
.sauvegarde { font-size: 12px; color: var(--text-muted); }
.sauvegarde.en-cours { color: var(--info); }
.sauvegarde.erreur { color: var(--danger); font-weight: 600; }

.grille { overflow-x: auto; border-radius: 6px; padding: 2px; outline: none; user-select: none; -webkit-user-select: none; }
.grille:focus-visible { box-shadow: 0 0 0 2px var(--info); }
.grille { --c-h: 19px; --c-f: 8.5px; --mois-w: 100px; }
.grille[data-zoom="1.5"] { --c-h: 28px; --c-f: 11px; --mois-w: 150px; }
.grille[data-zoom="2"] { --c-h: 38px; --c-f: 13px; --mois-w: 200px; }
.grille-annee { display: grid; grid-template-columns: repeat(12, minmax(var(--mois-w), 1fr)); gap: 6px; min-width: calc(12 * var(--mois-w) + 66px); }
.zoom { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-muted); }
.zoom button.chip { padding: 2px 8px; font-size: 12px; }
.mois { display: flex; flex-direction: column; gap: 1px; }
.mois-tete { background: var(--ink); color: #fff; border-radius: 4px; padding: 4px 6px; display: flex; justify-content: space-between; align-items: baseline; }
.mois-tete .nom { font-weight: 700; font-size: 12px; }
.mois-tete .h { font: 500 10px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--cell-centre); }
.mois-cols, .jour { display: grid; grid-template-columns: 30px repeat(4, minmax(0, 1fr)); gap: 1px; }
.mois-cols { font: 600 9px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #9aa0aa; text-align: center; padding: 2px 0; }
.jour.lundi { margin-top: 3px; }
.jour .lib { display: flex; gap: 3px; align-items: center; font: 600 9px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #3a4150; }
.jour .lib .j { width: 9px; }
.jour.weekend .lib { color: #b0b4bc; }
.jour.ferie .lib { color: var(--cell-conflit); }

.c {
  height: var(--c-h, 19px);
  border-radius: 2px;
  background: #fff;
  box-shadow: inset 0 0 0 1px #e8e6e0;
  font: 700 var(--c-f, 8.5px) ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: cell;
  color: var(--text);
  position: relative;
}
.c.vac { background: var(--cell-vacances); }
.c.we { background: var(--cell-weekend); box-shadow: none; cursor: not-allowed; }
.c.fer { background: repeating-linear-gradient(45deg, #e7e5df 0 3px, #d2cfc6 3px 6px); box-shadow: none; cursor: not-allowed; }
.c.ferm { background: var(--cell-fermeture); box-shadow: none; cursor: not-allowed; }
.c.ce { background: var(--cell-centre); box-shadow: none; }
.c.ce.h1 { background: linear-gradient(135deg, var(--cell-centre) 0 50%, var(--cell-centre-light) 50% 100%); }
.c.aff { background: var(--cell-centre-light); color: #7a5c00; box-shadow: inset 0 0 0 1.5px var(--cell-a-affecter); }
.c.en { background: var(--cell-entreprise); color: var(--cell-entreprise-text); box-shadow: none; }
.c.conflit { background: var(--cell-conflit-bg); color: var(--cell-conflit); box-shadow: inset 0 0 0 2px var(--cell-conflit); }
.c.alerte { box-shadow: inset 0 0 0 2px var(--cell-alerte); }
.c.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; padding: 0; background: #d9d6cf; box-shadow: none; }
.c .h { height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #fff; color: var(--text); border-radius: 1px; position: relative; font-size: .92em; }
.c .h.aff { background: var(--cell-centre-light); color: #7a5c00; box-shadow: inset 0 0 0 1.5px var(--cell-a-affecter); }
.c .h.conflit { background: var(--cell-conflit-bg) !important; color: var(--cell-conflit); box-shadow: inset 0 0 0 2px var(--cell-conflit); }
.c .h.alerte { box-shadow: inset 0 0 0 2px var(--cell-alerte); }
.c .h.vac { background: var(--cell-vacances); }
.c .h.hsel { outline: 2px solid var(--ink); outline-offset: -2px; z-index: 1; }
.swatch-demi { background: linear-gradient(90deg, #f6d66b 0 48%, #d9d6cf 48% 52%, #cdbff0 52% 100%) !important; }
.c.sel::after { content: ''; position: absolute; inset: 0; background: var(--cell-selection); pointer-events: none; }
.c.curseur { outline: 2px solid var(--ink); outline-offset: -1px; z-index: 1; }

.legende { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; color: #3a4150; }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.legende i { width: 18px; height: 12px; border-radius: 3px; display: inline-block; }

.panneaux { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.alerte-item { width: 100%; text-align: left; flex-direction: column; align-items: flex-start; gap: 3px; padding: 8px 12px; margin-bottom: 6px; }
.alerte-item .quand { font: 500 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--text-muted); }
.sugg { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); background: var(--bg); margin-bottom: 6px; }
.sugg .pt { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.sugg .pt.ok { background: var(--success); }
.sugg .pt.moyen { background: var(--cell-alerte); }
.sugg .pt.ko { background: var(--cell-conflit); }
.sugg .qui { flex: 1; min-width: 0; }
.sugg .qui small { display: block; color: var(--text-muted); }

.saisie-code { position: fixed; z-index: 200; background: var(--ink); color: #fff; padding: 6px 10px; border-radius: 6px; font: 700 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; box-shadow: 0 6px 18px rgba(0,0,0,.25); pointer-events: none; }

/* Matrice des compétences (Référentiels) */
table.matrice td.niv { text-align: center; padding: 4px; }
table.matrice td.niv button { width: 44px; height: 30px; justify-content: center; padding: 0; gap: 2px; }
table.matrice td.niv button i { width: 6px; height: 14px; border-radius: 2px; background: #dad7cf; display: inline-block; }
table.matrice td.niv button i.on { background: var(--info); }

@media print {
  header.app-header, .outils, .panneaux, .etat-ligne, #messages, .no-print { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { border: none; padding: 0; }
  .grille { overflow: visible; }
  .grille-annee { min-width: 0; }
  .c.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; padding: 0; background: #d9d6cf; box-shadow: none; }
.c .h { height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #fff; color: var(--text); border-radius: 1px; position: relative; font-size: .92em; }
.c .h.aff { background: var(--cell-centre-light); color: #7a5c00; box-shadow: inset 0 0 0 1.5px var(--cell-a-affecter); }
.c .h.conflit { background: var(--cell-conflit-bg) !important; color: var(--cell-conflit); box-shadow: inset 0 0 0 2px var(--cell-conflit); }
.c .h.alerte { box-shadow: inset 0 0 0 2px var(--cell-alerte); }
.c .h.vac { background: var(--cell-vacances); }
.c .h.hsel { outline: 2px solid var(--ink); outline-offset: -2px; z-index: 1; }
.swatch-demi { background: linear-gradient(90deg, #f6d66b 0 48%, #d9d6cf 48% 52%, #cdbff0 52% 100%) !important; }
.c.sel::after { display: none; }
  .c.curseur { outline: none; }
  body { background: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: A4 landscape; margin: 8mm; }
}

/* ============================================================================
   V1.1 — calendrier annuel des formateurs
   ========================================================================== */
.grille button.c { border: 0; padding: 0; border-radius: 2px; display: flex; gap: 0; transition: none; width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.grille button.c.split { display: grid; }
.grille button.c:hover { color: inherit; border: 0; }
.mois-barre { height: 4px; margin: 0 0 1px; border-radius: 0 0 2px 2px; background: #d9d6ce; }
.barre-empilee { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: #ebe7e2; }
.barre-empilee span { display: block; height: 100%; }
.heat { display: grid; column-gap: 2px; row-gap: 4px; align-items: center; min-width: 1300px; }
.heat-mois { font: 600 10px ui-monospace, Menlo, Consolas, monospace; color: var(--text-muted); white-space: nowrap; overflow: visible; }
.heat-nom { flex-direction: column; align-items: flex-start; gap: 0; border: 0; border-top: 1px solid var(--border); border-radius: 0; background: none; padding: 6px 8px 6px 0; text-align: left; }
.heat-nom small { color: var(--text-muted); font-size: 12px; }
.heat-case { height: 34px; border-radius: 3px; display: flex; align-items: center; justify-content: center; font: 600 9px ui-monospace, Menlo, Consolas, monospace; cursor: pointer; }
.heat-tot { text-align: right; font: 600 13px ui-monospace, Menlo, Consolas, monospace; }
.heat-tot small { display: block; font: 500 11px -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text-muted); }
@media print {
  .print-only { display: block !important; }
  #kpis, .barre-empilee, #liste-actions { display: none !important; }
}

/* Import / export Excel (Référentiels) */
.excel { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.apercu-resume { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.apercu-table { max-height: 340px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.apercu-table table { margin: 0; }
.apercu-table tr.erreur td { background: var(--danger-bg); }
