/* ==========================================================================
   Constance Digital : espace d'administration
   Même univers que le site : papier quadrillé, encre bleue, surligneur ambre.
   ========================================================================== */
:root {
  --paper: #fbfcff; --rule: rgba(58, 88, 196, .12);
  --ink: #101a3a; --ink-soft: #48527a; --line: #d9deef; --wash: #f1f4fc;
  --night: #0d1430; --night-2: #18214a;
  --amber: #f59e0b; --amber-deep: #a8530a; --amber-wash: #fff4dc;
  --pen: #1d3a9e; --pen-wash: #e8eeff;
  --red: #d93a30; --red-wash: #fdeceb; --ok: #17794a; --ok-wash: #e3f5ec;
  --font: 'Archivo', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --hand: 'Caveat', 'Segoe Print', 'Bradley Hand', cursive;
  --side: 264px; --r: 10px; --gut: clamp(1rem, 3.2vw, 2.25rem);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html:has(.side.open) { overflow: hidden; }
body { margin: 0; font-family: var(--font); font-size: 1rem; line-height: 1.5; color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
body.app { background-image: linear-gradient(var(--rule) 1px, transparent 1px), linear-gradient(90deg, var(--rule) 1px, transparent 1px); background-size: 28px 28px; background-attachment: fixed; }
h1, h2, h3, p, ul, dl, dd, figure { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: var(--pen); }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--amber); color: var(--ink); }
:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; border-radius: 4px; }
.i { width: 1.15rem; height: 1.15rem; flex: none; display: inline-block; vertical-align: middle; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; z-index: 200; background: var(--ink); color: #fff; padding: .7rem 1rem; }
.skip:focus { left: 0; }
.mute { color: var(--ink-soft); } .small { font-size: .875rem; }
.late { color: var(--red); font-weight: 700; } .soon { color: var(--amber-deep); font-weight: 700; }
code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: .92em; background: var(--wash); padding: .1em .4em; border-radius: 4px; word-break: break-all; }

h1, h2, h3, .brand-t, .kpi strong, .ph h1 { font-stretch: 78%; letter-spacing: -.005em; }
h1 { font-size: clamp(1.9rem, 4.2vw, 2.6rem); font-weight: 800; line-height: 1.02; }
h2 { font-size: 1.45rem; font-weight: 800; line-height: 1.1; }
h3 { font-size: 1.2rem; font-weight: 750; line-height: 1.15; font-stretch: 84%; }
.h-s { font-size: 1.2rem; font-stretch: 84%; margin-bottom: .8rem; }
.hand { font-family: var(--hand); font-weight: 700; font-size: 1.6rem; line-height: 1; color: var(--pen); display: inline-block; transform: rotate(-1.5deg); margin-bottom: .2rem; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 2.8rem; padding: .55rem 1.2rem; border: 2px solid var(--ink); border-radius: 7px;
  background: transparent; color: var(--ink); font-weight: 700; font-size: .95rem; line-height: 1.2; text-decoration: none; cursor: pointer; transition: background-color .15s, color .15s, transform .1s, box-shadow .15s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn-amber { background: var(--amber); box-shadow: 3px 3px 0 var(--ink); }
.btn-amber:hover { background: #ffb42b; box-shadow: 4px 4px 0 var(--ink); }
.btn-amber:active { box-shadow: 1px 1px 0 var(--ink); }
.btn-ink { background: var(--ink); color: #fff; } .btn-ink:hover { background: var(--pen); border-color: var(--pen); }
.btn-line:hover { background: var(--ink); color: #fff; }
.btn-danger { border-color: var(--red); color: var(--red); } .btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-sm { min-height: 2.3rem; padding: .3rem .85rem; font-size: .875rem; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; border: 0; border-radius: 7px; background: transparent; color: var(--ink-soft); cursor: pointer; text-decoration: none; transition: background-color .15s, color .15s; }
.icon-btn:hover { background: var(--pen-wash); color: var(--pen); }
.icon-btn.danger:hover { background: var(--red-wash); color: var(--red); }
.inl { display: inline-flex; margin: 0; }

/* ---------- Pastilles de statut ---------- */
.bd { display: inline-flex; align-items: center; padding: .12rem .65rem; border-radius: 99px; font-size: .78rem; font-weight: 700; line-height: 1.5; white-space: nowrap; border: 1.5px solid currentColor; }
.bd-ok { color: var(--ok); background: var(--ok-wash); } .bd-pen { color: var(--pen); background: var(--pen-wash); }
.bd-amber { color: var(--amber-deep); background: var(--amber-wash); } .bd-red { color: var(--red); background: var(--red-wash); } .bd-mute { color: var(--ink-soft); background: var(--wash); }

/* ---------- Structure ---------- */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main { width: 100%; max-width: 1240px; margin: 0 auto; padding: var(--gut); padding-bottom: calc(var(--gut) + env(safe-area-inset-bottom)); flex: 1; }

.side { position: sticky; top: 0; align-self: flex-start; width: var(--side); height: 100vh; height: 100dvh; flex: none; display: flex; flex-direction: column; background: var(--night); color: #dfe5ff; padding: 1.1rem .9rem; overflow-y: auto; z-index: 60; }
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.4rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; text-decoration: none; color: inherit; }
.logo { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 10px; background: var(--amber); color: var(--ink); font-weight: 900; font-size: 1.45rem; font-stretch: 100%; }
.brand-t { display: flex; flex-direction: column; font-weight: 800; font-size: 1.35rem; line-height: 1; color: #fff; }
.brand-t small { font-family: var(--hand); font-size: 1.05rem; font-weight: 500; color: var(--amber); letter-spacing: 0; font-stretch: 100%; margin-top: .1rem; }
.side-close { display: none; color: #fff; }
.nav { display: flex; flex-direction: column; gap: .2rem; }
.nav a { display: flex; align-items: center; gap: .8rem; padding: .7rem .85rem; border-radius: 8px; color: #c5cdf0; text-decoration: none; font-weight: 600; position: relative; transition: background-color .15s, color .15s; }
.nav a:hover { background: var(--night-2); color: #fff; }
.nav a.on { background: var(--night-2); color: #fff; }
.nav a.on::before { content: ''; position: absolute; left: -.9rem; top: .35rem; bottom: .35rem; width: 5px; border-radius: 0 4px 4px 0; background: var(--amber); }
.side-foot { margin-top: auto; padding-top: 1.2rem; }
.note-hand { display: block; font-family: var(--hand); font-size: 1.35rem; color: var(--amber); transform: rotate(-2deg); margin: 0 0 .9rem .4rem; }
.me { display: flex; align-items: center; gap: .65rem; padding: .65rem; border-radius: 10px; background: var(--night-2); }
.me .icon-btn { color: #c5cdf0; } .me .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.av { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; flex: none; border-radius: 50%; background: var(--amber); color: var(--ink); font-weight: 800; }
.me-t { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.me-t strong { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-t small { font-size: .75rem; color: #98a3d6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scrim { display: none; }
.top { display: none; }

/* ---------- Titres de page ---------- */
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.ph-s { color: var(--ink-soft); margin-top: .35rem; }
.sec-h { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin: 1.6rem 0 .9rem; }
.sec-h h2 { font-size: 1.5rem; } .sec-h p { margin-top: .15rem; }
.sec-act { display: flex; gap: .5rem; flex-wrap: wrap; }
.more { font-weight: 700; font-size: .9rem; }
.back { display: inline-flex; align-items: center; gap: .3rem; margin-bottom: .9rem; color: var(--ink-soft); font-weight: 600; text-decoration: none; font-size: .95rem; }
.back:hover { color: var(--pen); }

/* ---------- Cartes ---------- */
.card { background: #fff; border: 2px solid var(--ink); border-radius: var(--r); }
.pad { padding: 1.2rem 1.3rem; }
.narrow { max-width: 640px; }
.stack { display: grid; gap: 1rem; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; margin-top: 1.1rem; align-items: start; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.1rem; }
.kpi { display: flex; flex-direction: column; gap: .15rem; padding: 1rem 1.15rem; background: #fff; border: 2px solid var(--ink); border-radius: var(--r); box-shadow: 5px 5px 0 var(--ink); text-decoration: none; color: inherit; min-width: 0; transition: transform .15s, box-shadow .15s; }
a.kpi:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--ink); }
.kpi-l { font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); }
.kpi strong { font-size: clamp(1.5rem, 2.4vw, 2rem); font-weight: 800; line-height: 1.1; overflow-wrap: anywhere; }
.kpi small { color: var(--ink-soft); font-size: .85rem; }
.kpi:nth-child(odd) { background: linear-gradient(#fff, #fff) padding-box; }
.kpi-red { background: var(--red-wash); } .kpi-red strong { color: var(--red); }

/* ---------- Filtres ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; margin-bottom: 1rem; }
.search { display: flex; align-items: center; gap: .55rem; flex: 1 1 260px; max-width: 460px; padding: 0 .85rem; background: #fff; border: 2px solid var(--ink); border-radius: 8px; color: var(--ink-soft); }
.search input:not([type=checkbox]):not([type=radio]):not([type=file]), .search input:focus { flex: 1; min-width: 0; width: auto; border: 0; padding: 0; outline: 0; box-shadow: none; background: transparent; min-height: 2.65rem; color: var(--ink); }
.search:focus-within { box-shadow: 0 0 0 3px var(--pen-wash); border-color: var(--pen); }
.month input { min-height: 2.8rem; padding: 0 .7rem; border: 2px solid var(--ink); border-radius: 8px; background: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .85rem; border: 2px solid var(--line); border-radius: 99px; background: #fff; color: var(--ink); text-decoration: none; font-weight: 600; font-size: .875rem; }
.chip b { font-size: .75rem; padding: 0 .4rem; border-radius: 99px; background: var(--wash); }
.chip:hover { border-color: var(--ink); } .chip.on { background: var(--ink); border-color: var(--ink); color: #fff; } .chip.on b { background: rgba(255,255,255,.2); }

/* ---------- Tableaux ---------- */
.tbl-wrap { overflow: hidden; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { padding: .75rem 1rem; text-align: left; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); background: var(--wash); border-bottom: 2px solid var(--ink); white-space: nowrap; }
.tbl td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #fafbff; }
.tbl small { display: block; color: var(--ink-soft); font-size: .8rem; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl td.act { white-space: nowrap; text-align: right; }
.tbl td.act > * { vertical-align: middle; }
.rowlink { color: var(--ink); text-decoration: none; } .rowlink:hover { color: var(--pen); text-decoration: underline; text-underline-offset: 3px; }
.filelink { display: inline-flex; align-items: center; gap: .4rem; max-width: 190px; color: var(--pen); font-weight: 600; text-decoration: none; font-size: .9rem; }
.filelink span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .filelink:hover span { text-decoration: underline; }
.sel-badge { appearance: none; -webkit-appearance: none; border: 1.5px solid currentColor; border-radius: 99px; padding: .15rem 1.5rem .15rem .7rem; font-size: .78rem; font-weight: 700; cursor: pointer;
  background: right .45rem center / .6rem no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23101a3a' stroke-width='1.6'/%3E%3C/svg%3E"); }
.sel-ok { color: var(--ok); background-color: var(--ok-wash); } .sel-pen { color: var(--pen); background-color: var(--pen-wash); } .sel-amber { color: var(--amber-deep); background-color: var(--amber-wash); }
.sel-red { color: var(--red); background-color: var(--red-wash); } .sel-mute { color: var(--ink-soft); background-color: var(--wash); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-top: 1rem; }
.pager-i { color: var(--ink-soft); font-weight: 600; font-size: .9rem; }
.empty { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: 2.8rem 1.2rem; text-align: center; background: #fff; border: 2px dashed var(--line); border-radius: var(--r); }
.empty .i { width: 2.4rem; height: 2.4rem; color: var(--amber); } .empty strong { font-size: 1.15rem; font-stretch: 84%; } .empty p { color: var(--ink-soft); max-width: 42ch; margin-bottom: .6rem; }

/* ---------- Fiche client ---------- */
.chead { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem 1.6rem; align-items: center; padding: 1.2rem 1.3rem; box-shadow: 5px 5px 0 var(--ink); }
.chead-main { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.avatar { display: grid; place-items: center; width: 3.6rem; height: 3.6rem; flex: none; border: 2px solid var(--ink); border-radius: 12px; background: var(--amber); font-size: 1.8rem; font-weight: 900; font-stretch: 80%; }
.chead-t { min-width: 0; } .chead-t h1 { overflow-wrap: anywhere; }
.chead-s { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-top: .4rem; font-size: .9rem; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; font-weight: 700; padding: .1rem .5rem; border-radius: 4px; background: var(--wash); }
.contacts { display: flex; flex-wrap: wrap; gap: .35rem 1.2rem; font-size: .92rem; min-width: 0; }
.contacts li { display: flex; align-items: center; gap: .45rem; color: var(--ink-soft); min-width: 0; overflow-wrap: anywhere; } .contacts a { color: var(--ink); font-weight: 600; }
.chead-act { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }

.tabs { display: flex; gap: .3rem; margin: 1.5rem 0 0; padding-bottom: 0; overflow-x: auto; scrollbar-width: none; border-bottom: 2px solid var(--ink); -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: inline-flex; align-items: center; gap: .45rem; padding: .7rem 1.1rem; color: var(--ink-soft); font-weight: 700; text-decoration: none; white-space: nowrap; border: 2px solid transparent; border-bottom: 0; border-radius: 9px 9px 0 0; margin-bottom: -2px; }
.tabs a:hover { color: var(--ink); background: rgba(255,255,255,.7); }
.tabs a.on { color: var(--ink); background: #fff; border-color: var(--ink); }
.tabs a.on::after { content: ''; position: absolute; }
.tabs b { font-size: .75rem; padding: 0 .45rem; border-radius: 99px; background: var(--amber-wash); color: var(--amber-deep); }

.proj { padding: 1.2rem 1.3rem; }
.proj-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.proj-b { display: flex; align-items: center; gap: .55rem; margin-top: .4rem; font-size: .9rem; }
.proj-a { display: flex; flex: none; }
.links { display: flex; flex-wrap: wrap; gap: .5rem; margin: .9rem 0 .2rem; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .7rem 1.4rem; margin-top: .9rem; }
.kv dt { font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-soft); } .kv dd { overflow-wrap: anywhere; }
.proj-n { margin-top: .9rem; padding: .7rem .9rem; border-left: 4px solid var(--amber); background: var(--amber-wash); border-radius: 0 6px 6px 0; font-size: .92rem; }
.creds { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .8rem; margin-top: 1.1rem; padding-top: 1.1rem; border-top: 2px dashed var(--line); }
.cred { padding: .8rem .9rem; border: 2px solid var(--line); border-radius: 9px; background: var(--paper); min-width: 0; }
.cred-h { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .4rem; }
.cred-h strong { display: flex; align-items: center; gap: .45rem; font-size: .95rem; min-width: 0; overflow-wrap: anywhere; } .cred-h strong .i { color: var(--amber-deep); }
.cred-a { display: flex; flex: none; margin-right: -.4rem; } .cred-a .icon-btn { width: 2.1rem; height: 2.1rem; }
.cred-r { display: flex; align-items: center; gap: .4rem; min-height: 2.2rem; }
.cred-r .k { flex: none; width: 6.4rem; font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); }
.cred-r code { flex: 1; min-width: 0; padding: .25rem .5rem; }
.cred-r .icon-btn { width: 2.1rem; height: 2.1rem; flex: none; }
.cred-n { margin-top: .35rem; font-size: .85rem; color: var(--ink-soft); }

.sub { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: .8rem 1.6rem; align-items: center; padding: 1rem 1.2rem; }
.sub-p { text-align: right; } .sub-p strong { display: block; font-size: 1.3rem; font-stretch: 84%; line-height: 1.1; } .sub-p small, .sub-d small { color: var(--ink-soft); }
.sub-d { display: flex; flex-direction: column; gap: .25rem; align-items: flex-start; }
.sub-a { display: flex; align-items: center; gap: .15rem; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Listes ---------- */
.list li { display: flex; align-items: center; gap: .7rem; padding: .7rem 0; border-bottom: 1px solid var(--line); } .list li:last-child { border-bottom: 0; padding-bottom: 0; }
.li-m { flex: 1; min-width: 0; } .li-m a { color: var(--ink); text-decoration: none; } .li-m a:hover { color: var(--pen); }
.li-m strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .li-m small, .li-r small { display: block; color: var(--ink-soft); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-r { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: .15rem; }
.feed li { display: flex; gap: .8rem; padding: .55rem 0; position: relative; }
.feed .dot { flex: none; width: .65rem; height: .65rem; margin-top: .45rem; border-radius: 50%; background: var(--amber); border: 2px solid var(--ink); }
.feed li:not(:last-child)::before { content: ''; position: absolute; left: .27rem; top: 1.35rem; bottom: -.4rem; width: 2px; background: var(--line); }
.feed small { display: block; color: var(--ink-soft); font-size: .8rem; }
.note-form { display: flex; flex-direction: column; align-items: flex-end; gap: .5rem; margin-bottom: 1rem; }
.note-form textarea { width: 100%; }
.notes li { padding: .8rem .9rem; margin-bottom: .6rem; background: var(--amber-wash); border-left: 4px solid var(--amber); border-radius: 0 8px 8px 0; }
.notes p { overflow-wrap: anywhere; }
.notes footer { display: flex; align-items: center; justify-content: space-between; margin-top: .3rem; font-size: .8rem; color: var(--ink-soft); }
.notes .icon-btn { width: 1.9rem; height: 1.9rem; }

/* ---------- Formulaires ---------- */
.grid-f { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.f { display: flex; flex-direction: column; gap: .3rem; min-width: 0; } .f-full { grid-column: 1 / -1; }
.f-l { font-size: .85rem; font-weight: 700; } .f-l b { color: var(--red); }
.f-h { color: var(--ink-soft); font-size: .8rem; line-height: 1.35; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea { width: 100%; min-height: 2.8rem; padding: .55rem .8rem; border: 2px solid var(--ink); border-radius: 8px; background: #fff; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; min-height: 4.5rem; line-height: 1.45; }
select { appearance: none; -webkit-appearance: none; padding-right: 2.2rem; background: #fff right .8rem center / .7rem no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23101a3a' stroke-width='1.6'/%3E%3C/svg%3E"); }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--pen); box-shadow: 0 0 0 3px var(--pen-wash); }
input[type=file] { width: 100%; padding: .6rem; border: 2px dashed var(--ink-soft); border-radius: 8px; background: var(--paper); cursor: pointer; font-size: .9rem; }
input[type=file]::file-selector-button { margin-right: .8rem; padding: .4rem .9rem; border: 2px solid var(--ink); border-radius: 6px; background: var(--amber); color: var(--ink); font-weight: 700; cursor: pointer; }
.pw { position: relative; display: block; } .pw input { padding-right: 3rem; } .pw .icon-btn { position: absolute; right: .25rem; top: 50%; transform: translateY(-50%); }
.dlg-sum { padding: .7rem .9rem; background: var(--wash); border-radius: 8px; margin: 0; }

/* ---------- Fenêtres de saisie ---------- */
.dlg { width: min(640px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); padding: 0; border: 2px solid var(--ink); border-radius: 14px; background: #fff; color: var(--ink); box-shadow: 8px 8px 0 var(--ink); overflow: hidden; }
.dlg[open] { display: flex; flex-direction: column; animation: pop .18s ease-out; }
.dlg::backdrop { background: rgba(13, 20, 48, .55); backdrop-filter: blur(2px); }
.dlg form { display: flex; flex-direction: column; min-height: 0; max-height: calc(100dvh - 2rem); }
.dlg-h { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1.1rem .9rem 1.4rem; border-bottom: 2px solid var(--ink); background: var(--amber-wash); }
.dlg-b { padding: 1.2rem 1.4rem; overflow-y: auto; overscroll-behavior: contain; }
.dlg-f { display: flex; justify-content: flex-end; gap: .6rem; padding: .9rem 1.4rem calc(.9rem + env(safe-area-inset-bottom)); border-top: 2px solid var(--line); background: var(--paper); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Messages ---------- */
.flash { display: flex; align-items: flex-start; gap: .7rem; padding: .75rem .9rem; margin-bottom: 1rem; border: 2px solid; border-radius: 9px; font-weight: 600; }
.flash > span { flex: 1; padding-top: .1rem; } .flash .icon-btn { width: 1.9rem; height: 1.9rem; margin: -.2rem -.3rem -.2rem 0; color: inherit; }
.flash-ok { color: var(--ok); background: var(--ok-wash); border-color: var(--ok); } .flash-err { color: var(--red); background: var(--red-wash); border-color: var(--red); }
.toast { position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); z-index: 300; transform: translate(-50%, 140%); padding: .65rem 1.1rem; border-radius: 99px; background: var(--ink); color: #fff; font-weight: 600; font-size: .92rem; box-shadow: 0 6px 24px rgba(0,0,0,.25); transition: transform .25s, opacity .25s, visibility .25s; opacity: 0; visibility: hidden; pointer-events: none; max-width: calc(100vw - 2rem); }
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

/* ---------- Connexion / installation ---------- */
body.auth { min-height: 100vh; min-height: 100dvh; background-color: var(--paper); background-image: linear-gradient(var(--rule) 1px, transparent 1px), linear-gradient(90deg, var(--rule) 1px, transparent 1px); background-size: 28px 28px; }
.auth-wrap { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.2rem; gap: 1.2rem; }
.auth-card { width: 100%; max-width: 440px; padding: 1.8rem; background: #fff; border: 2px solid var(--ink); border-radius: 14px; box-shadow: 8px 8px 0 var(--ink); }
.auth-card .brand { margin-bottom: 1.4rem; } .auth-card .brand-t { color: var(--ink); } .auth-card .brand-t small { color: var(--amber-deep); }
.auth-sub { color: var(--ink-soft); margin: .4rem 0 1.2rem; }
.auth-form { display: grid; gap: 1rem; }
.auth-foot { font-size: .85rem; color: var(--ink-soft); text-align: center; }

/* ---------- Tablette ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chead { grid-template-columns: 1fr; } .chead-act { justify-content: flex-start; }
  .sub { grid-template-columns: minmax(0, 1fr) auto; } .sub-d { align-items: flex-start; } .sub-a { grid-column: 1 / -1; justify-content: flex-start; padding-top: .6rem; border-top: 1px dashed var(--line); }
}
@media (max-width: 900px) {
  .shell { display: block; }
  .side { position: fixed; inset: 0 auto 0 0; transform: translateX(-102%); transition: transform .25s ease, box-shadow .25s; width: min(300px, 86vw); padding-top: calc(1.1rem + env(safe-area-inset-top)); }
  .side.open { transform: none; box-shadow: 8px 0 30px rgba(0,0,0,.3); } .side-close { display: grid; }
  .nav a.on::before { left: -.9rem; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(13,20,48,.55); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .side.open + .scrim { opacity: 1; pointer-events: auto; }
  .top { display: flex; align-items: center; gap: .7rem; position: sticky; top: 0; z-index: 40; padding: .55rem .8rem; padding-top: calc(.55rem + env(safe-area-inset-top)); background: var(--night); color: #fff; }
  .top .icon-btn { color: #fff; } .top .icon-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
  .brand-sm .logo { width: 2rem; height: 2rem; font-size: 1.2rem; } .brand-sm .brand-t { font-size: 1.15rem; }
  .top-title { margin-left: auto; font-weight: 700; font-size: .95rem; color: #c5cdf0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 45%; }
  .two { grid-template-columns: 1fr; }
}

/* ---------- Mobile : tableaux en cartes, fenêtre en feuille du bas ---------- */
@media (max-width: 760px) {
  .tbl-wrap { border: 0; background: transparent; overflow: visible; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tbl tbody { display: grid; gap: .8rem; }
  .tbl tr { background: #fff; border: 2px solid var(--ink); border-radius: var(--r); padding: .35rem .95rem; }
  .tbl tbody tr:hover { background: #fff; }
  .tbl td { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px dashed var(--line); text-align: right; }
  .tbl td::before { content: attr(data-l); flex: none; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-soft); text-align: left; }
  .tbl td > :not(small) { min-width: 0; } .tbl small { text-align: right; }
  .tbl td:first-child { padding-top: .75rem; } .tbl td:first-child strong { font-size: 1.05rem; }
  .tbl td.act { justify-content: flex-end; border-bottom: 0; padding-bottom: .7rem; } .tbl td.act::before { content: none; }
  .tbl .num { text-align: right; } .filelink { max-width: 60vw; }
  .kpis { gap: .75rem; } .kpi { padding: .8rem .9rem; box-shadow: 4px 4px 0 var(--ink); }
  .ph { align-items: flex-start; } .ph > .btn { width: 100%; }
  .search { max-width: none; flex-basis: 100%; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(var(--gut) * -1); padding: .1rem var(--gut) .35rem; scrollbar-width: none; flex: 1 1 100%; } .chips::-webkit-scrollbar { display: none; } .chip { flex: none; }
  .grid-f { grid-template-columns: 1fr; }
  .dlg { width: 100vw; max-width: none; max-height: 92dvh; margin: auto 0 0; border-radius: 18px 18px 0 0; border-bottom: 0; box-shadow: none; }
  .dlg[open] { animation: sheet .25s ease-out; } .dlg form { max-height: 92dvh; }
  .dlg-f .btn { flex: 1; }
  .sec-act { width: 100%; } .sec-act .btn { flex: 1; }
  .sec-h > .btn { width: 100%; }
  .proj, .pad { padding: 1rem; } .creds { grid-template-columns: 1fr; }
  .cred-r .k { width: 4.6rem; }
  .sub { grid-template-columns: 1fr; } .sub-p { text-align: left; } .sub-p strong { display: inline; } .sub-a .btn { flex: 1; }
  .chead { padding: 1rem; box-shadow: 4px 4px 0 var(--ink); } .chead-act .btn { flex: 1; } .chead-act form { flex: 1; } .chead-act form .btn { width: 100%; }
  .auth-card { padding: 1.3rem; box-shadow: 5px 5px 0 var(--ink); }
}
@keyframes sheet { from { transform: translateY(100%); } }
@media (max-width: 380px) { .kpis { grid-template-columns: 1fr; } }
@media (hover: none) { .btn-amber:hover { box-shadow: 3px 3px 0 var(--ink); background: var(--amber); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media print { .side, .top, .btn, .icon-btn, .tabs { display: none !important; } body.app { background: #fff; } .card, .kpi { box-shadow: none; } }
