/* AFJ — espace bureau */
:root {
  --bg: #f4f1ea;
  --paper: #fffdf8;
  --ink: #1d1a17;
  --ink-2: #5b544b;
  --muted: #8a8278;
  --line: #e3ddd1;
  --shu: #c23b22;
  --shu-dark: #9c2c17;
  --ai: #24344d;
  /* statuts */
  --st-repere: #8a8278;     --st-repere-bg: #ece8e0;
  --st-a_deposer: #a86b00;  --st-a_deposer-bg: #fbefd4;
  --st-depose: #2f5fa7;     --st-depose-bg: #e1ebf8;
  --st-accepte: #2d7a3e;    --st-accepte-bg: #dff0e1;
  --st-refuse: #b03a2e;     --st-refuse-bg: #f8e1dd;
  --st-abandonne: #6d6a66;  --st-abandonne-bg: #e6e4e1;
  --radius: 12px;
  --font: "Zen Kaku Gothic New", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font: 15px/1.55 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--ai); }
h1 { font-size: 1.7rem; margin: 0 0 4px; line-height: 1.2; }
h2 { font-size: 1.08rem; margin: 0 0 14px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 12px; }
.inline { display: inline; }
.narrow { max-width: 560px; }

/* ---------- Structure ---------- */
.bureau { display: flex; min-height: 100vh; }
.side {
  width: 250px; flex-shrink: 0; background: var(--ink); color: #d8d1c4; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 18px 14px;
}
.side-brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; font-weight: 700; padding: 4px 8px 22px; }
.side-brand small { display: block; font-weight: 400; color: #a69e90; font-size: .8rem; }
.hanko {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 6px; background: var(--shu); color: #fff;
  font-weight: 800; font-size: .8rem; writing-mode: vertical-rl; transform: rotate(-3deg); flex-shrink: 0;
}
.side-nav { display: grid; gap: 2px; }
.side-nav a, .side-foot a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #d8d1c4; text-decoration: none;
}
.side-nav a:hover, .side-foot a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-nav a.on { background: rgba(255,255,255,.12); color: #fff; font-weight: 700; }
.side-nav .ico { width: 20px; text-align: center; opacity: .8; }
.pill { margin-left: auto; background: var(--shu); color: #fff; border-radius: 999px; font-size: .75rem; padding: 0 8px; font-weight: 700; }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding-top: 12px; display: grid; gap: 2px; font-size: .9rem; }
.side-foot .linkbtn { color: #a69e90; padding: 9px 10px; }
.main { flex: 1; min-width: 0; }
.content { padding: 28px clamp(16px, 3vw, 40px) 60px; max-width: 1280px; }
.mobilebar { display: none; }

/* ---------- Éléments ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--ink); background: var(--ink); color: #fff; font: 600 .92rem var(--font); text-decoration: none; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--shu); border-color: var(--shu); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--paper); color: var(--ink); border-color: var(--ink-2); }
.btn-dark { background: var(--ink-2); border-color: var(--ink-2); }
.btn-sm { padding: 5px 11px; font-size: .84rem; }
.btn[disabled] { opacity: .7; cursor: default; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--ai); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.linkbtn.danger { color: var(--st-refuse); }
.x { background: none; border: 0; color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.x:hover { color: var(--st-refuse); background: var(--st-refuse-bg); }
.flash { padding: 11px 15px; border-radius: 9px; margin-bottom: 14px; font-weight: 500; }
.flash-ok { background: var(--st-accepte-bg); color: #1f5a2c; }
.flash-err { background: var(--st-refuse-bg); color: #8c2a20; }
.tag { display: inline-block; font-size: .74rem; padding: 1px 8px; border-radius: 999px; background: #ece8e0; color: var(--ink-2); font-weight: 600; }
.badge { display: inline-block; font-size: .78rem; padding: 2px 10px; border-radius: 999px; font-weight: 700; white-space: nowrap; }
.st-repere    { --c: var(--st-repere);    --cb: var(--st-repere-bg); }
.st-a_deposer { --c: var(--st-a_deposer); --cb: var(--st-a_deposer-bg); }
.st-depose    { --c: var(--st-depose);    --cb: var(--st-depose-bg); }
.st-accepte   { --c: var(--st-accepte);   --cb: var(--st-accepte-bg); }
.st-refuse    { --c: var(--st-refuse);    --cb: var(--st-refuse-bg); }
.st-abandonne { --c: var(--st-abandonne); --cb: var(--st-abandonne-bg); }
.badge[class*="st-"] { color: var(--c); background: var(--cb); }
.due { font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.due.soon { color: var(--st-a_deposer); }
.due.late { color: var(--st-refuse); }
.sub { color: var(--muted); font-size: .86rem; }
.empty { color: var(--muted); font-style: italic; margin: 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; }
.panel-soft { background: transparent; border-style: dashed; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.box { background: var(--bg); border-radius: 9px; padding: 12px 14px; margin: 12px 0; }
.box p { margin: 4px 0 0; }

/* Tableau de bord */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--paper); border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: var(--radius);
  padding: 14px 18px; text-decoration: none; color: var(--ink);
}
.stat:hover { border-color: var(--c); }
.stat strong { display: block; font-size: 1.9rem; line-height: 1.1; color: var(--c); }
.stat span { font-weight: 600; font-size: .9rem; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }
.rows li > a { text-decoration: none; color: var(--ink); margin-right: 6px; }
.rows li > a:hover { color: var(--shu); }
.progress { height: 6px; background: #ece8e0; border-radius: 99px; overflow: hidden; margin: 7px 0 3px; }
.progress span { display: block; height: 100%; background: var(--st-accepte); border-radius: 99px; }
.progress.big { height: 9px; margin-bottom: 14px; }

/* ---------- Formulaires ---------- */
.form { display: grid; gap: 14px; }
.form > .btn { justify-self: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.span-2 { grid-column: span 2; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 16px; margin: 0; display: grid; gap: 12px; grid-template-columns: inherit; }
fieldset.span-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
fieldset:not(.span-2) { grid-template-columns: 1fr; }
legend { font-weight: 700; padding: 0 6px; }
label { display: grid; gap: 5px; font-weight: 600; font-size: .88rem; color: var(--ink-2); }
input, select, textarea {
  font: 400 .95rem var(--font); color: var(--ink); padding: 8px 11px; border: 1px solid #d6cfc2; border-radius: 8px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ai); box-shadow: 0 0 0 3px rgba(36,52,77,.14); }
input[type="checkbox"] { width: auto; }
input[type="file"] { padding: 6px; }
textarea { resize: vertical; }
.check-label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.form-actions { display: flex; gap: 10px; }
.sticky-actions { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input[type="search"] { flex: 1; min-width: 220px; }
.filters select { width: auto; }
.inline-add { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }
.inline-add input:not([type="date"]):not([type="file"]) { flex: 1; min-width: 180px; }
.inline-add select, .inline-add input[type="date"] { width: auto; }
.inline-add input[type="file"] { flex: 1; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; padding: 6px 8px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr[onclick] { cursor: pointer; }
.table tbody tr[onclick]:hover { background: #faf6ee; }
.table td a { color: var(--ink); text-decoration: none; }
.table.compact td { padding: 7px 10px; }
.thumb { max-width: 220px; border-radius: 8px; margin-bottom: 6px; }
.thumb-sm { width: 52px; height: 36px; object-fit: cover; border-radius: 5px; }
.kanji-sm { display: inline-grid; place-items: center; width: 52px; height: 36px; background: var(--ink); color: #fff; border-radius: 5px; font-size: 1.2rem; }

/* ---------- Agenda ---------- */
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-nav h1 { min-width: 210px; text-align: center; margin: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .84rem; color: var(--ink-2); margin-bottom: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 11px; height: 11px; border-radius: 3px; background: var(--c); display: inline-block; }
.dot-limit { background: transparent; border: 2px dashed var(--st-a_deposer); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--line); gap: 1px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; }
.cal-h { background: var(--paper); text-align: center; font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 0; }
.cal-d { background: var(--paper); min-height: 112px; padding: 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-d.we { background: #fcf9f2; }
.cal-d.out { background: #f6f3ec; }
.cal-d.out .cal-num span { color: #c2bbb0; }
.cal-num { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: .88rem; }
.cal-d.today .cal-num span { background: var(--shu); color: #fff; border-radius: 999px; min-width: 24px; height: 24px; display: inline-grid; place-items: center; padding: 0 6px; }
.cal-add { opacity: 0; text-decoration: none; color: var(--muted); font-size: 1.1rem; width: 22px; text-align: center; border-radius: 5px; }
.cal-d:hover .cal-add { opacity: 1; }
.cal-add:hover { background: var(--bg); color: var(--ink); }
.chip {
  display: block; font-size: .78rem; font-weight: 600; line-height: 1.3; padding: 3px 7px; border-radius: 5px; text-decoration: none;
  background: var(--cb); color: var(--c); border-left: 3px solid var(--c); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip.cont { border-left-color: transparent; opacity: .85; }
.chip-limit { background: transparent; color: var(--st-a_deposer); border: 1px dashed var(--st-a_deposer); border-left-width: 1px; }
.chip:hover { filter: brightness(.95); }
.cal-list { display: none; }

/* ---------- Fiche événement ---------- */
.crumbs { margin: 0 0 4px; font-size: .85rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.ev-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin: 8px 0 0; color: var(--ink-2); }
.pipeline-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.pipeline { list-style: none; margin: 0; padding: 0; display: flex; flex: 1; min-width: 300px; }
.pipeline li { flex: 1; position: relative; }
.pipeline li + li::before { content: ""; position: absolute; left: -50%; right: 50%; top: 17px; height: 3px; background: var(--line); z-index: 0; }
.pipeline li.done::before, .pipeline li.now::before { background: var(--st-accepte); }
.pipeline form { position: relative; z-index: 1; }
.pipeline button {
  width: 100%; background: none; border: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px;
  font: 600 .82rem var(--font); color: var(--muted); padding: 0 4px; text-align: center;
}
.pipeline .step {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--paper); border: 3px solid var(--line);
  font-weight: 800; color: var(--muted); transition: .15s;
}
.pipeline button:hover:not([disabled]) .step { border-color: var(--ai); color: var(--ai); }
.pipeline li.done .step { background: var(--st-accepte); border-color: var(--st-accepte); color: #fff; }
.pipeline li.done button { color: var(--ink-2); }
.pipeline li.now .step { background: var(--ink); border-color: var(--ink); color: #fff; box-shadow: 0 0 0 4px rgba(29,26,23,.12); }
.pipeline li.now button { color: var(--ink); cursor: default; }
.pipeline-side { display: flex; gap: 8px; }
.pipeline-help { width: 100%; margin: 0; font-size: .86rem; }
.ev-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 18px; margin: 0; }
.facts dt { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.facts dd { margin: 2px 0 0; font-weight: 500; }
.cat { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 18px 0 6px; }
.tasks { list-style: none; margin: 0; padding: 0; }
.tasks li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.tasks li:target { background: #fff6dc; }
.check {
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid #c9c1b3; background: #fff; cursor: pointer; color: #fff; font-weight: 800;
  display: grid; place-items: center; padding: 0; font-size: .85rem;
}
.check:hover { border-color: var(--st-accepte); }
.tasks li.done .check { background: var(--st-accepte); border-color: var(--st-accepte); }
.tasks li.done .task-lib { text-decoration: line-through; color: var(--muted); }
.task-body { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; min-width: 0; }
.task-lib { flex: 1 1 180px; min-width: 0; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.task-meta select { max-width: 160px; }
.task-meta select, .task-meta input { width: auto; padding: 4px 8px; font-size: .82rem; border-color: var(--line); background: transparent; }
.task-meta input.late { color: var(--st-refuse); border-color: var(--st-refuse); font-weight: 700; }
.files { list-style: none; margin: 0; padding: 0; }
.files li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.files li a { font-weight: 600; flex: 1; min-width: 160px; word-break: break-all; }
.files li .muted { font-size: .82rem; }
.notes { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 12px; }
.notes li { border-left: 3px solid var(--line); padding-left: 10px; }
.notes p { margin: 2px 0 0; font-size: .92rem; }
.note-head { display: flex; align-items: center; gap: 8px; font-size: .84rem; }
.note-head form { margin-left: auto; }
details.edit { margin-top: 16px; }
details.edit summary { list-style: none; display: inline-flex; }
details.edit summary::-webkit-details-marker { display: none; }
details.edit[open] summary { margin-bottom: 14px; }
.danger-zone { text-align: center; padding: 8px; font-size: .88rem; }

/* Messages */
.msg header { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.msg:not(.read) { border-left: 4px solid var(--shu); }
.msg.read { opacity: .75; }
.msg p { margin: 0; }

/* ---------- Connexion / installation ---------- */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: var(--ink); }
.auth-card { background: var(--paper); border-radius: 16px; padding: 34px 32px; width: 100%; max-width: 400px; box-shadow: 0 30px 60px -30px rgba(0,0,0,.6); }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .form { margin-top: 18px; }
.auth-card fieldset { grid-template-columns: 1fr; }
.auth-mark { width: 54px; height: 54px; border-radius: 8px; background: var(--shu); color: #fff; display: grid; place-items: center; font-weight: 800; writing-mode: vertical-rl; transform: rotate(-3deg); margin-bottom: 16px; }

/* ---------- Mobile ---------- */
@media (max-width: 1100px) {
  .ev-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .bureau { display: block; }
  .side { position: fixed; z-index: 100; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s; }
  .side-open .side { transform: none; }
  .side-open .side-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; }
  .mobilebar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 50; }
  .burger { width: 40px; height: 40px; background: none; border: 0; position: relative; cursor: pointer; }
  .burger span, .burger span::before, .burger span::after { position: absolute; left: 9px; right: 9px; height: 2px; background: #fff; content: ""; }
  .burger span { top: 19px; }
  .burger span::before { left: 0; right: 0; top: -7px; }
  .burger span::after { left: 0; right: 0; top: 7px; }
  .content { padding-top: 20px; }
  .grid-2, .form-grid, fieldset.span-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .cal-d { min-height: 64px; padding: 3px; }
  .chip { font-size: 0; padding: 0; height: 6px; border-left-width: 0; border-radius: 3px; background: var(--c); }
  .chip-limit { height: 6px; background: transparent; }
  .cal-add { display: none; }
  .cal-list { display: block; }
  .cal-nav h1 { min-width: 0; font-size: 1.3rem; }
  .pipeline .step { width: 30px; height: 30px; }
  .pipeline li + li::before { top: 14px; }
  .pipeline button { font-size: .72rem; }
}
