/* Thème Graphite — Olympia Diffusion · Administratif
   Sombre, graphite chaud, un seul accent (laiton) pour l'action et l'exercice en cours, rouge brique pour ce qui presse.
   Chiffres et titres en Barlow Semi Condensed, texte en Instrument Sans. Mode clair automatique à l'impression. */
:root {
  --bg: #1A1B1E; --s1: #212226; --s2: #2A2B30; --s3: #323338; --line: #35373D; --line2: #44464D;
  --ink: #EDEAE3; --ink2: #A09D95; --ink3: #6F6D67;
  --brass: #D6A345; --brass-ink: #1A1B1E; --brass-dim: rgba(214,163,69,.16);
  --alert: #E0613F; --alert-dim: rgba(224,97,63,.16); --ok: #8DB47A; --ok-dim: rgba(141,180,122,.14);
  --r: 5px; --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif; --cond: "Barlow Semi Condensed", "Instrument Sans", system-ui, sans-serif;
  --side: 224px;
}
* { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14.5px/1.5 var(--sans); min-height: 100vh; }
a { color: var(--brass); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font: 700 30px/1.1 var(--cond); margin: 0 0 .2rem; letter-spacing: .005em; }
h2 { font: 700 17px/1.2 var(--cond); margin: 0 0 .8rem; letter-spacing: .01em; display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
h2 a, h2 .small { font: 500 13px var(--sans); }
h3 { font: 600 15px var(--cond); margin: 0 0 .5rem; color: var(--ink2); }
.muted { color: var(--ink2); } .small { font-size: .86rem; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; } .row.between { justify-content: space-between; } .grow { flex: 1; }
strong, b { font-weight: 600; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* ---- Structure : barre latérale + contenu ---- */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: var(--s1); border-right: 1px solid var(--line); padding: 1.1rem 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 0 1.2rem 1rem; border-bottom: 1px solid var(--line); margin-bottom: .6rem; color: var(--ink); }
.brand b { display: block; font: 700 19px/1.15 var(--cond); } .brand span { font-size: 12.5px; color: var(--ink2); }
.nav h6 { margin: .8rem 1.2rem .2rem; font: 600 11.5px var(--sans); color: var(--ink3); }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .45rem 1.2rem; color: var(--ink2); font-weight: 500; font-size: 14px; border-left: 2px solid transparent; }
.nav a:hover { color: var(--ink); text-decoration: none; background: var(--s2); }
.nav a.on { color: var(--ink); background: var(--s2); border-left-color: var(--brass); }
.nav a em { font: 600 12px var(--cond); color: var(--ink3); font-style: normal; } .nav a.on em { color: var(--brass); }
.side .user { margin-top: auto; padding: .9rem 1.2rem 0; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink2); display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.side .user b { color: var(--ink); display: block; }
.side .switch { padding: .7rem 1.2rem 0; margin: 0; } .side .switch select { width: 100%; font-size: 13.5px; padding: .42rem 2rem .42rem .6rem; background-color: var(--s2); border-color: var(--line2); color: var(--ink); font-weight: 600; }
.notice { background: var(--brass-dim); color: var(--brass); border: 1px solid rgba(214,163,69,.35); border-radius: var(--r); padding: .5rem .9rem; margin-bottom: 1rem; font-size: 13.5px; }
.tbl.matrix select { min-width: 110px; } .tbl.matrix th { white-space: nowrap; }
.side .search { padding: .6rem 1.2rem .2rem; } .side .search input { width: 100%; background: var(--bg); }
.topbar { display: none; }
main { padding: 1.4rem 2rem 3.5rem; max-width: 1400px; width: 100%; min-width: 0; }
main.center { max-width: 440px; margin: 0 auto; padding-top: 10vh; grid-column: 1 / -1; }
.app.noside { grid-template-columns: 1fr; }

/* En-tête de page */
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.pagehead p { margin: .15rem 0 0; color: var(--ink2); font-size: 13.5px; }
.flash { background: var(--ok-dim); color: var(--ok); border: 1px solid rgba(141,180,122,.35); border-radius: var(--r); padding: .55rem .9rem; margin-bottom: 1rem; }
.error { background: var(--alert-dim); color: var(--alert); border: 1px solid rgba(224,97,63,.4); border-radius: var(--r); padding: .55rem .9rem; margin-bottom: 1rem; }

/* ---- Panneaux ---- */
.card { background: var(--s1); border: 1px solid var(--line); border-radius: 6px; padding: 1.1rem 1.3rem; margin-bottom: 1.25rem; }
.card .card { background: var(--s2); }
.grid { display: grid; gap: 1.25rem; } .grid.c2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
/* Totaux par période : une règle, pas quatre boîtes */
.grid.c4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; background: var(--s1); border: 1px solid var(--line); border-radius: 6px; }
.stat { padding: .85rem 1.15rem; border-right: 1px solid var(--line); min-width: 0; } .stat:last-child { border-right: 0; }
.stat .k { font-size: 12.5px; color: var(--ink2); } .stat .v { font: 600 28px/1.1 var(--cond); margin: .2rem 0 .1rem; font-variant-numeric: tabular-nums; } .stat .s { font-size: 12px; color: var(--ink3); }
.stat:last-child .v { color: var(--brass); }
.empty { color: var(--ink3); padding: .6rem 0; }

/* ---- Tableaux ---- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { padding: .5rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font: 600 12px var(--sans); color: var(--ink3); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl td.num { font: 600 15px var(--cond); }
.tbl tr:last-child td { border-bottom: 0; } .tbl tbody tr:hover td { background: rgba(255,255,255,.015); }
.tbl-wrap { overflow-x: auto; }
.tbl a { color: var(--ink); } .tbl a:hover { color: var(--brass); }

/* ---- Étiquettes ---- */
.badge { display: inline-block; font: 600 12px var(--cond); padding: .12rem .45rem; border-radius: 3px; background: var(--s3); color: var(--ink2); white-space: nowrap; letter-spacing: .01em; }
a.badge { color: var(--ink); } a.badge:hover { background: var(--brass-dim); color: var(--brass); text-decoration: none; }
.badge:not(.gray):not(.warn):not(.danger) { background: var(--ok-dim); color: var(--ok); }
.badge.gray { background: var(--s3); color: var(--ink2); } .badge.warn { background: var(--brass-dim); color: var(--brass); } .badge.danger { background: var(--alert-dim); color: var(--alert); }

/* ---- Formulaires ---- */
label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: .25rem; color: var(--ink2); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=url], input[type=tel], input[type=search], input[type=file], select, textarea {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--line2); border-radius: 4px; background: var(--bg); color: var(--ink); font: inherit; font-size: 16px; }
input:focus, select:focus, textarea:focus { border-color: var(--brass); outline: none; }
input[type=date] { color-scheme: dark; }
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink2) 50%), linear-gradient(135deg, var(--ink2) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2rem; }
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: .85rem; } .fields { display: grid; gap: .25rem 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; color: var(--ink); font-size: 14px; } .check input { width: auto; accent-color: var(--brass); }
.btn { display: inline-block; padding: .48rem .95rem; border-radius: 4px; border: 1px solid var(--brass); background: var(--brass); color: var(--brass-ink); font: 600 13.5px var(--sans); cursor: pointer; line-height: 1.3; }
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line2); } .btn.ghost:hover { border-color: var(--ink2); }
.btn.danger { background: transparent; color: var(--alert); border-color: rgba(224,97,63,.5); }
.btn.sm { padding: .32rem .65rem; font-size: 12.5px; }
.inline-form { display: inline; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.filters .field { margin: 0; min-width: 150px; } .filters input, .filters select { font-size: 14px; padding: .4rem .55rem; }
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { padding: .35rem .75rem; border-radius: 4px; border: 1px solid var(--line); color: var(--ink2); font-size: 13px; font-weight: 500; background: var(--s1); }
.tabs a:hover { color: var(--ink); text-decoration: none; } .tabs a.on { background: var(--brass-dim); color: var(--brass); border-color: rgba(214,163,69,.4); }
details.edit summary { cursor: pointer; color: var(--ink2); font-size: 12.5px; } details.edit summary:hover { color: var(--brass); }
details > summary.btn { list-style: none; } details > summary::-webkit-details-marker { display: none; }

/* ---- Graphique mensuel ---- */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; align-items: end; height: 110px; margin-top: .4rem; }
.bars .b { background: var(--line2); min-height: 2px; position: relative; } .bars .b.hi { background: var(--ink2); } .bars .b:last-child { background: var(--brass); }
.bars .b span { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font: 600 11px var(--cond); color: var(--ink); background: var(--s3); padding: .1rem .35rem; border-radius: 3px; white-space: nowrap; display: none; margin-bottom: 3px; }
.bars .b:hover span { display: block; }
.bars-x { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; font-size: 10.5px; color: var(--ink3); text-align: center; margin-top: .25rem; }

/* ---- Échéances (liste) ---- */
.dl { list-style: none; margin: 0; padding: 0; }
.dl li { display: grid; grid-template-columns: 82px auto 1fr; gap: .8rem; padding: .5rem 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.dl li:last-child { border-bottom: 0; }
.dl .d { font: 600 14px var(--cond); font-variant-numeric: tabular-nums; } .dl .when { }
.dl .grow a { color: var(--ink); font-weight: 600; } .dl .grow .muted a { color: var(--ink2); font-weight: 400; }

/* ---- Règle des 90 jours ---- */
.ruler { position: relative; height: 128px; margin: .5rem .6rem 0; }
.ruler .axis { position: absolute; left: 0; right: 0; top: 62px; height: 1px; background: var(--line2); }
.ruler .tick { position: absolute; top: 58px; width: 1px; height: 9px; background: var(--line2); }
.ruler .tick span { position: absolute; top: 10px; left: 0; transform: translateX(-50%); font-size: 11px; color: var(--ink3); white-space: nowrap; }
.ruler .tick.first span { transform: none; } .ruler .tick.last span { transform: translateX(-100%); }
.ruler .ev { position: absolute; top: 18px; transform: translateX(-50%); text-align: center; width: 150px; }
.ruler .ev i { display: block; width: 10px; height: 10px; border-radius: 50%; background: var(--ok); margin: 8px auto 0; border: 2px solid var(--s1); box-shadow: 0 0 0 1px var(--line2); }
.ruler .ev.warn i { background: var(--brass); } .ruler .ev.hot i { background: var(--alert); } .ruler .ev i.multi { width: 14px; height: 14px; border-radius: 3px; margin-top: 6px; }
.ruler .ev.below { top: auto; bottom: 0; display: flex; flex-direction: column-reverse; } .ruler .ev.below i { margin: 0 auto 8px; }
.ruler .ev b { display: block; font: 600 12.5px var(--sans); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.ruler .ev a { color: inherit; } .ruler .ev small { display: block; font-size: 11px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ruler .ev.edge-r { transform: translateX(-100%); text-align: right; margin-left: 6px; } .ruler .ev.edge-r i { margin-right: 0; margin-left: auto; }
.ruler .ev.edge-l { transform: none; text-align: left; margin-left: -6px; } .ruler .ev.edge-l i { margin-left: 0; margin-right: auto; }
.ruler .ev.below.edge-r i { margin: 0 0 8px auto; } .ruler .ev.below.edge-l i { margin: 0 auto 8px 0; }
.ruler .ev.past b { color: var(--alert); }

.share { height: 3px; background: var(--line); margin-top: .35rem; } .share i { display: block; height: 100%; background: var(--brass); }
.gaps { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .7rem; } .gaps a { font-size: 12px; color: var(--alert); border: 1px solid rgba(224,97,63,.45); padding: .1rem .5rem; border-radius: 3px; } .gaps a:hover { background: var(--alert-dim); text-decoration: none; }

/* ---- Identité visuelle ---- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.asset .thumb { display: flex; align-items: center; justify-content: center; height: 140px; border: 1px solid var(--line); border-radius: 4px; background: repeating-conic-gradient(var(--s3) 0 25%, var(--s2) 0 50%) 0 0 / 16px 16px; overflow: hidden; }
.asset .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.asset .thumb .ext { font: 700 14px var(--cond); color: var(--ink2); background: var(--s1); padding: .3rem .6rem; border-radius: 3px; }
.asset .meta { padding: .4rem .1rem; line-height: 1.35; }

/* ---- Mobile ---- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: .75rem 16px .6rem; margin: 0; border-bottom: 0; display: flex; align-items: baseline; gap: .5rem; }
  .brand b { font-size: 17px; } .brand span { display: none; }
  .side .search { display: none; } .side .switch { padding: 0 12px .5rem; } .side .switch select { font-size: 13px; }
  .nav { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0 10px .5rem; gap: .15rem; }
  .nav h6 { display: none; }
  .nav a { padding: .35rem .6rem; border-left: 0; border-radius: 4px; white-space: nowrap; font-size: 13.5px; gap: .35rem; } .nav a.on { background: var(--brass-dim); color: var(--brass); }
  .side .user { position: absolute; top: .6rem; right: 12px; margin: 0; padding: 0; border: 0; } .side .user b, .side .user span { display: none; }
  .side { position: relative; }
  main { padding: 1rem 16px 3rem; }
  h1 { font-size: 24px; }
  .grid.c4 { grid-template-columns: 1fr 1fr; } .stat { border-bottom: 1px solid var(--line); } .stat:nth-child(even) { border-right: 0; } .stat:nth-last-child(-n+2) { border-bottom: 0; }
  .stat .v { font-size: 22px; }
  .tbl { font-size: 13px; } .tbl th, .tbl td { padding: .4rem .35rem; } .hide-m { display: none; }
  .tbl-wrap { margin: 0 -1.3rem; padding: 0 1.3rem; }
  .ruler { display: none; }
  .dl li { grid-template-columns: 78px 1fr; } .dl .grow { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- Impression : clair ---- */
@media print {
  :root { --bg: #fff; --s1: #fff; --s2: #f4f4f2; --s3: #e8e8e4; --line: #d4d4cf; --line2: #bdbdb7; --ink: #111; --ink2: #555; --ink3: #777; --brass: #8a6512; --brass-dim: #f3e8cf; }
  .side, .btn, .filters, .tabs, .search, details > summary { display: none !important; }
  .app { grid-template-columns: 1fr; } main { padding: 0; max-width: none; }
  .card { break-inside: avoid; }
}
