@font-face {
  font-family: 'Nunito';
  src: url('/fonts/nunito/nunito-latin-wght-normal.woff2') format('woff2');
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  --navy: #0b2a5e;
  --navy-soft: #4d5f82;
  --teal: #0b9ea3;
  --teal-ink: #077176;
  --yellow: #ffb000;
  --pink: #ec3d66;
  --pink-ink: #c21f49;
  --green: #a0c800;
  --green-ink: #4f6a00;
  --cream: #fff8ea;
  --line: #efe6d2;
  --surface: #ffffff;
  --radius: 18px;
  --field: #ffffff;
  --primary-bg: #0b2a5e;
  --primary-ink: #ffffff;
  --primary-hover: #17407f;
  --badge-bg: #c21f49;
  --grid-base: #cfc5ad;
  --yellow-soft: #fff0c7;
  --yellow-text: #7a5300;
  --teal-soft: #d6f3f3;
  --teal-text: #055e62;
  --green-soft: #eaf4c4;
  --green-text: #435a00;
  --pink-soft: #fde0e8;
  --pink-text: #a81a3f;
  --grey-soft: #edeef2;
  --grey-text: #47546f;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --navy: #eef2fa;
  --navy-soft: #aeb9d1;
  --teal-ink: #62d8dc;
  --pink-ink: #ff8fa8;
  --green-ink: #c6e650;
  --cream: #0c1730;
  --line: #2b3c5e;
  --surface: #15243f;
  --field: #0f1c36;
  --primary-bg: #ffb000;
  --primary-ink: #0b2a5e;
  --primary-hover: #ffc233;
  --grid-base: #4a5c80;
  --yellow-soft: #4a3a10;
  --yellow-text: #ffd978;
  --teal-soft: #0f4347;
  --teal-text: #93e8eb;
  --green-soft: #37450e;
  --green-text: #d3ec74;
  --pink-soft: #55192c;
  --pink-text: #ffb3c5;
  --grey-soft: #2b3c5e;
  --grey-text: #d0d8e8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--navy);
  font: 500 16px/1.5 'Nunito', system-ui, sans-serif;
}

h1, h2, h3 { font-family: 'Arial Black', Arial, sans-serif; font-weight: 900; line-height: 1.2; margin: 0; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.05rem; margin-bottom: 12px; }
h3 { font-size: .95rem; margin-bottom: 8px; }
p { margin: 4px 0 0; }
a { color: var(--teal-ink); font-weight: 700; text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--cream); padding: 1px 5px; border-radius: 6px; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

.muted { color: var(--navy-soft); font-size: .92rem; font-weight: 500; }
.late { color: var(--pink-ink); font-weight: 800; }
.positive { color: var(--green-ink); font-weight: 800; }
.negative { color: var(--pink-ink); font-weight: 800; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }

/* Structure */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { text-align: center; margin-bottom: 14px; }
.brand img { width: 136px; height: auto; display: inline-block; }
[data-theme="dark"] .brand img, [data-theme="dark"] .login-card > img { background: #fff; border-radius: 24px; padding: 6px; }
.menu-toggle { display: none; }
.topbar-actions { display: none; }
.install-any { display: none; }
.sidebar-body { display: flex; flex-direction: column; justify-content: space-between; min-height: calc(100% - 160px); gap: 18px; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 12px;
  color: var(--navy);
  font-weight: 700;
}
.sidebar nav a:hover { background: var(--cream); text-decoration: none; }
.sidebar nav a.active { background: var(--primary-bg); color: var(--primary-ink); }
.sidebar nav svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.session { border-top: 1px solid var(--line); padding: 12px 12px 0; display: grid; gap: 2px; }
.content { padding: 30px 34px 60px; width: 100%; display: flex; flex-direction: column; gap: 20px; }

.avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; object-fit: cover; background: var(--cream); }
.avatar.large { width: 76px; height: 76px; }
.identity { display: flex; align-items: center; gap: 12px; }
.badge { margin-left: auto; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--badge-bg); color: #fff; font-size: .8rem; font-weight: 800; text-align: center; }
.me { display: flex; align-items: center; gap: 10px; color: var(--navy); font-weight: 800; line-height: 1.25; padding: 6px; margin: 0 -6px 4px; border-radius: 12px; }
.me:hover { background: var(--cream); text-decoration: none; }
.me.active { background: var(--cream); }
.me small { margin-top: 1px; font-weight: 700; color: var(--teal-ink); }
.notice { border: 2px solid var(--yellow); }
.form-intro { margin-bottom: 14px; }
.changes { margin-top: 10px; }
.photo-change { display: flex; align-items: center; gap: 10px; }
.requests { display: grid; gap: 14px; }
.request { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(240px, 2fr) auto; gap: 18px; align-items: center; padding-top: 14px; border-top: 1px solid var(--line); }
.request:first-child { padding-top: 0; border-top: 0; }
.request .changes { margin-top: 0; }
.request-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.refuse { display: flex; gap: 8px; }
.refuse input { width: 240px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-weight: 700; }
.session-actions { display: flex; gap: 8px; margin-top: 6px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--navy); cursor: pointer; }
.icon-btn:hover { background: var(--cream); border-color: var(--navy); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
/* GED */
.ged { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; align-items: start; }
.ged-tree { padding: 12px; display: grid; gap: 2px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.tree-item { display: flex; justify-content: space-between; gap: 10px; padding: 7px 10px; border-radius: 10px; color: var(--navy); font-weight: 700; font-size: .94rem; }
.tree-item:hover { background: var(--cream); text-decoration: none; }
.tree-item.active { background: var(--primary-bg); color: var(--primary-ink); }
.tree-item span { flex: none; font-size: .82rem; opacity: .75; }
.tree-item .tree-alert { min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--badge-bg); color: #fff; text-align: center; opacity: 1; }
.tree-group { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.tree-group summary { cursor: pointer; padding: 6px 10px; font-weight: 800; }
.tree-group summary span { float: right; font-size: .82rem; color: var(--navy-soft); }
.tree-empty { padding: 2px 10px 8px; }
.ged-main { display: grid; gap: 14px; min-width: 0; }
.ged-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 10px; }
.ged-head h2 { margin: 0; font-size: 1.2rem; }
.dropzone { border: 2px dashed var(--grid-base); border-radius: var(--radius); background: var(--surface); transition: border-color .15s ease, background-color .15s ease; }
.dropzone label { display: grid; justify-items: center; gap: 2px; padding: 20px; text-align: center; cursor: pointer; font-weight: 500; }
.dropzone:hover, .dropzone.over { border-color: var(--teal); background: var(--teal-soft); }
.dropzone.sending { opacity: .7; pointer-events: none; }
.dropzone:focus-within { outline: 3px solid var(--teal); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); border: 0; }
.tag-filter, .doc-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.doc-card { display: flex; flex-direction: column; gap: 4px; padding: 10px 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--navy); font-weight: 500; min-width: 0; }
.doc-card:hover { border-color: var(--teal); text-decoration: none; }
.doc-card strong { font-weight: 800; overflow-wrap: anywhere; }
.doc-thumb { display: grid; place-items: center; height: 120px; margin-bottom: 6px; border-radius: 12px; overflow: hidden; font: 900 1.05rem 'Arial Black', Arial, sans-serif; background: var(--grey-soft); color: var(--grey-text); }
.doc-thumb.pdf { background: var(--pink-soft); color: var(--pink-text); }
.doc-thumb.texte { background: var(--teal-soft); color: var(--teal-text); }
.doc-thumb.tableur { background: var(--green-soft); color: var(--green-text); }
.doc-thumb.diapo { background: var(--yellow-soft); color: var(--yellow-text); }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-thumb.big { width: 120px; margin: 0 auto 14px; }
.small-link { font-size: .85rem; }
.view-toggle { margin-left: auto; }
.doc-view { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.doc-preview { display: grid; }
.doc-preview iframe { width: 100%; height: 76vh; min-height: 420px; border: 0; background: #fff; }
.doc-preview img { display: block; width: 100%; max-height: 76vh; object-fit: contain; background: var(--cream); }
.preview-open { padding: 10px 16px; font-size: .9rem; border-top: 1px solid var(--line); }
.doc-side { display: grid; gap: 20px; min-width: 0; }
.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; margin: 0 0 12px; }
.facts dt { color: var(--navy-soft); font-size: .88rem; font-weight: 800; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.doc-notes { margin-top: 12px; white-space: pre-wrap; }
.version-form { display: grid; gap: 8px; justify-items: start; margin-bottom: 14px; }
.version-form input { max-width: 100%; }
.version-list { gap: 8px; }
.version-list li { display: grid; overflow-wrap: anywhere; }
.fields { display: contents; }
/* Consultation seule : le serveur refuse déjà ces actions, on évite juste de les proposer */
.read-only a[href$="/nouveau"], .read-only a[href*="/nouveau?"], .read-only a.btn[href$="/modifier"], .read-only a[href^="/ged/dossiers"],
.read-only .dropzone, .read-only .tick, .read-only .version-form { display: none; }
/* Inventaire */
.item-view { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; align-items: start; }
.item-photo { display: grid; place-items: center; min-height: 200px; border-radius: 12px; overflow: hidden; background: var(--cream); color: var(--navy-soft); }
.item-photo img { display: block; width: 100%; max-height: 340px; object-fit: contain; }
.item-thumb { width: 44px; height: 44px; flex: none; border-radius: 10px; object-fit: cover; background: var(--cream); }
.item-thumb.empty-thumb { display: grid; place-items: center; }
.item-thumb svg { width: 22px; height: 22px; fill: none; stroke: var(--navy-soft); stroke-width: 2; stroke-linejoin: round; }
.stock-low { color: var(--pink-ink); font-weight: 800; }
.read-only .loan-form, .read-only .loan-return { display: none; }

/* Compte rendu */
.editor { border: 2px solid var(--line); border-radius: 14px; background: var(--field); overflow: hidden; }
.editor:focus-within { border-color: var(--teal); }
.editor-bar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--surface); }
.editor-bar button { min-width: 36px; height: 34px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--navy); font: 800 .9rem 'Nunito', sans-serif; cursor: pointer; }
.editor-bar button:hover { background: var(--cream); }
.editor-sep { width: 1px; margin: 4px; background: var(--line); }
.editor-area { min-height: 130px; padding: 12px 14px; outline: none; }
.editor-area.tall { min-height: 340px; }
.rich p { white-space: normal; margin: 0 0 10px; max-width: 90ch; }
.rich h2 { font-size: 1.05rem; margin: 16px 0 8px; }
.rich h3 { font-size: .95rem; margin: 14px 0 6px; }
.rich ul, .rich ol { margin: 0 0 10px; padding-left: 24px; }
.rich blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 3px solid var(--line); }
.save-state { color: var(--navy-soft); font-size: .9rem; font-weight: 700; }
.save-state.error { color: var(--pink-ink); }
.print-only { display: none; }

/* Messagerie */
.mail { display: grid; grid-template-columns: 350px minmax(0, 1fr); height: calc(100vh - 150px); min-height: 480px; overflow: hidden; }
.mail-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.mail-tools { display: grid; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.mail-tabs { display: flex; gap: 6px; font-size: .9rem; }
.mail-tabs a { padding: 3px 12px; border-radius: 999px; color: var(--navy); }
.mail-tabs a.active { background: var(--primary-bg); color: var(--primary-ink); }
.conv-list { flex: 1; min-height: 0; overflow-y: auto; }
.conv { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 2px 10px; padding: 11px 12px; border-bottom: 1px solid var(--line); color: var(--navy); font-weight: 500; }
.conv:hover { background: var(--cream); text-decoration: none; }
.conv.active { background: var(--teal-soft); }
.conv .avatar { grid-row: span 2; width: 44px; height: 44px; }
.conv-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 700; }
.conv.unread .conv-title { font-weight: 900; }
.conv-time { color: var(--navy-soft); font-size: .78rem; white-space: nowrap; }
.conv-preview { grid-column: 2; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--navy-soft); font-size: .88rem; }
.conv.unread .conv-preview { color: var(--navy); font-weight: 700; }
.conv-count { grid-column: 3; justify-self: end; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--badge-bg); color: #fff; font-size: .75rem; font-weight: 800; text-align: center; }
.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.thread-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.thread-head h2 { margin: 0; font-size: 1.02rem; overflow-wrap: anywhere; }
.thread-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.thread-back { display: none; }
.thread-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.day-sep { align-self: center; padding: 2px 12px; border-radius: 999px; background: var(--cream); color: var(--navy-soft); font-size: .8rem; font-weight: 700; }
.msg { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 8px; max-width: min(720px, 88%); }
.msg .avatar { width: 36px; height: 36px; }
.msg-bubble { padding: 8px 12px; border-radius: 4px 14px 14px 14px; background: var(--cream); }
.msg.mine { align-self: flex-end; grid-template-columns: minmax(0, 1fr); }
.msg.mine .avatar { display: none; }
.msg.mine .msg-bubble { border-radius: 14px 4px 14px 14px; background: var(--teal-soft); }
.msg-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; font-size: .8rem; color: var(--navy-soft); }
.msg-meta strong { color: var(--navy); font-size: .88rem; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-deleted { font-style: italic; color: var(--navy-soft); }
.msg-delete { margin-left: auto; padding: 0; font-size: .78rem; min-height: 0; }
.msg-system { align-self: center; color: var(--navy-soft); font-size: .84rem; text-align: center; }
.msg-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.msg-files img { display: block; max-width: 240px; max-height: 180px; border-radius: 10px; }
.msg-file { padding: 4px 10px; border: 1px solid var(--grid-base); border-radius: 10px; font-size: .86rem; overflow-wrap: anywhere; }
.read-state { align-self: flex-end; color: var(--navy-soft); font-size: .8rem; }
.composer { display: grid; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.composer textarea { resize: vertical; min-height: 64px; }
.composer-actions { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.composer-actions input[type="file"] { flex: 1 1 200px; width: auto; min-width: 0; max-width: 100%; border: 0; padding: 0; background: none; }
.recipients { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; max-height: 300px; overflow-y: auto; }
.recipient { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border: 2px solid var(--line); border-radius: 12px; font-weight: 700; cursor: pointer; }
.recipient:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.recipient input { width: 18px; height: 18px; flex: none; }
.recipient small { margin: 0; font-weight: 600; }
.role-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.role-chips button { border: 0; cursor: pointer; font-family: inherit; }
.empty-thread { flex: 1; display: grid; place-items: center; }
.members { color: var(--navy-soft); font-size: .86rem; overflow-wrap: anywhere; }
.add-member { display: flex; gap: 6px; }
.add-member select { width: auto; max-width: 170px; padding: 4px 8px; font-size: .88rem; }
.flush-head { padding: 18px 22px 0; }
.inline-form { display: block; }
.plain-text { white-space: pre-wrap !important; }
/* Onglets */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 2px solid var(--line); }
.tabs a { display: flex; align-items: center; gap: 8px; padding: 9px 16px; margin-bottom: -2px; border-bottom: 3px solid transparent; color: var(--navy-soft); font-weight: 800; }
.tabs a:hover { color: var(--navy); text-decoration: none; }
.tabs a.active { border-bottom-color: var(--primary-bg); color: var(--navy); }
.tabs .badge { margin-left: 0; }
.form-hint { margin-bottom: 12px; }
section .filters + .form-hint { margin: 10px 0 0; }
.menu-badge { display: inline-block; margin-left: 4px; }

/* Notifications */
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-list li + li { border-top: 1px solid var(--line); }
.notif-list a { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 13px 22px; color: var(--navy); font-weight: 500; }
.notif-list a:hover { background: var(--cream); text-decoration: none; }
.notif-dot { width: 10px; height: 10px; border-radius: 50%; }
.notif-list .unread .notif-dot { background: var(--badge-bg); }
.notif-text { display: grid; gap: 1px; min-width: 0; overflow-wrap: anywhere; }
.notif-text strong { font-weight: 600; }
.notif-list .unread .notif-text strong { font-weight: 900; }
.notif-meta { display: grid; justify-items: end; gap: 3px; white-space: nowrap; }
.icon-btn[data-notif-open] { position: relative; }
.icon-btn[data-notif-open] .badge { position: absolute; top: -6px; right: -6px; margin: 0; min-width: 18px; padding: 0 4px; font-size: .7rem; line-height: 18px; }
.notif-dialog { width: min(620px, calc(100vw - 24px)); max-height: 85vh; margin: auto; padding: 0; border: 0; border-radius: var(--radius); background: var(--surface); color: var(--navy); }
.notif-dialog::backdrop { background: rgba(11, 42, 94, .45); }
.notif-panel { display: flex; flex-direction: column; gap: 16px; min-height: 120px; padding: 22px; }
.notif-panel .page-head { padding-right: 48px; }
.notif-close { position: absolute; top: 14px; right: 14px; }
.install-dialog { width: min(420px, calc(100vw - 24px)); margin: auto; padding: 22px; border: 0; border-radius: var(--radius); background: var(--surface); color: var(--navy); }
.install-dialog::backdrop { background: rgba(11, 42, 94, .45); }
.install-dialog ol { margin: 12px 0 18px; padding-left: 22px; display: grid; gap: 8px; }
.install-dialog .btn { width: 100%; }

/* Signatures */
.sign-box { display: grid; gap: 14px; }
.sign-source { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; min-width: 0; }
.sign-source legend { padding: 0; margin-bottom: 8px; font-weight: 800; font-size: .93rem; }
.sign-consent { align-items: flex-start; margin: 0; font-weight: 700; }
.sign-password { max-width: 420px; }
.sign-password input { margin-top: 4px; }
.signature-pad { max-width: 600px; }
.signature-pad canvas { display: block; width: 100%; height: auto; aspect-ratio: 3 / 1; border: 2px solid var(--grid-base); border-radius: 12px; background: #fff; cursor: crosshair; touch-action: none; }
.signature-pad.missing canvas { border-color: var(--pink-ink); }
.signature-tools { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 6px; }
.signature-preview { display: block; width: 100%; max-width: 280px; height: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.signature-saved { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 14px; }
.signature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; margin-bottom: 14px; }
.signature-block { display: grid; gap: 3px; justify-items: start; padding: 14px; border: 1px solid var(--line); border-radius: 14px; }
.signature-block h3 { margin-bottom: 6px; }
.signature-block .signature-preview { margin-bottom: 6px; }
.notice-flash { background: var(--yellow-soft); color: var(--yellow-text); }
.send-card { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px; }
.send-card h2 { margin-bottom: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.install-now { margin-bottom: 12px; }
.install-help { gap: 6px; }
.check input, .check-input { width: 20px; height: 20px; flex: none; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 14px; }
.page-head .tag { margin-top: 8px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.crumb { display: inline-block; margin-bottom: 6px; font-size: .92rem; }

/* Boutons */
.btn {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 999px;
  border: 2px solid var(--navy);
  background: var(--surface);
  color: var(--navy);
  font: 800 .95rem 'Nunito', sans-serif;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--cream); text-decoration: none; }
.btn.primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { border-color: var(--pink-ink); color: var(--pink-ink); }
.btn.danger:hover { background: var(--pink-soft); }
.link { background: none; border: 0; padding: 0; color: var(--teal-ink); font: 700 .9rem 'Nunito', sans-serif; cursor: pointer; text-align: left; }
.link:hover { text-decoration: underline; }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.columns { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.columns.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.action-card { color: var(--navy); display: block; }
.action-card:hover { border-color: var(--teal); text-decoration: none; }
.action-card h2 { margin: 10px 0 2px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; color: var(--navy); display: flex; flex-direction: column; gap: 2px; font-weight: 500; }
a.tile:hover { border-color: var(--teal); text-decoration: none; }
.tile-label { font-weight: 800; font-size: .92rem; }
.tile strong { font: 900 1.75rem/1.25 'Nunito', sans-serif; font-variant-numeric: tabular-nums; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .96rem; }
th { text-align: left; font-size: .84rem; font-weight: 800; color: var(--navy-soft); padding: 10px 12px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { border-top: 2px solid var(--line); border-bottom: 0; font-weight: 800; }
th:first-child, td:first-child { padding-left: 4px; }
th:last-child, td:last-child { padding-right: 4px; }
.flush th:first-child, .flush td:first-child { padding-left: 22px; }
.flush th:last-child, .flush td:last-child { padding-right: 22px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
input.num { text-align: left; }

.tag { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .8rem; font-weight: 800; white-space: nowrap; }
.tag.yellow { background: var(--yellow-soft); color: var(--yellow-text); }
.tag.teal { background: var(--teal-soft); color: var(--teal-text); }
.tag.green { background: var(--green-soft); color: var(--green-text); }
.tag.pink { background: var(--pink-soft); color: var(--pink-text); }
.tag.grey { background: var(--grey-soft); color: var(--grey-text); }

/* Formulaires */
label { font-weight: 800; font-size: .93rem; display: block; }
input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  color: var(--navy);
  font: 600 1rem 'Nunito', sans-serif;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); }
textarea { resize: vertical; }
small { display: block; color: var(--navy-soft); margin-top: 4px; font-size: .85rem; }
.req { color: var(--pink-ink); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px 18px; }
.field { display: grid; gap: 4px; align-content: start; }
.full { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 4px; }
.push { margin-left: auto; }
.stack { display: grid; gap: 14px; }
.stack label input { margin-top: 4px; }
.inline { display: flex; gap: 8px; }
.inline select { width: auto; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters input { flex: 1 1 200px; width: auto; }
.filters select { flex: 0 1 auto; width: auto; }

.flash { padding: 10px 16px; border-radius: 12px; font-weight: 700; }
.flash.success { background: var(--green-soft); color: var(--green-text); }
.flash.error { background: var(--pink-soft); color: var(--pink-text); }

.empty { text-align: center; padding: 42px 20px; color: var(--navy-soft); }
.empty p { margin: 0 auto 14px; max-width: 46ch; }
.empty.small { padding: 18px 10px; }
.empty.small p:last-child { margin-bottom: 0; }
.empty h1 { color: var(--navy); margin-bottom: 6px; }

.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.prose p { white-space: pre-wrap; margin: 0 0 20px; max-width: 90ch; }
.prose p:last-child { margin-bottom: 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 92px minmax(0, 1fr); column-gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .date { grid-row: span 2; font-weight: 800; font-size: .92rem; font-variant-numeric: tabular-nums; }
.timeline .muted { grid-column: 2; }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist form { display: flex; }
.checklist .grow .muted:empty { display: none; }
.tick { width: 24px; height: 24px; flex: none; border: 2px solid var(--navy); border-radius: 8px; background: var(--field); cursor: pointer; padding: 0; }
.tick:hover { background: var(--teal-soft); }
.done .tick { background: var(--teal); border-color: var(--teal); }
.done a { text-decoration: line-through; color: var(--navy-soft); }

/* Graphique */
.legend { list-style: none; display: flex; gap: 16px; margin: 0 0 8px; padding: 0; font-size: .9rem; font-weight: 700; }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 4px; }
.swatch.income, .chart .income { background: #0b9ea3; fill: #0b9ea3; }
.swatch.expense, .chart .expense { background: #ec3d66; fill: #ec3d66; }
.chart-scroll { overflow-x: auto; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .grid.base { stroke: var(--grid-base); }
.chart .axis { fill: var(--navy-soft); font: 700 11.5px 'Nunito', sans-serif; }
.chart .hit { fill: transparent; }
.chart .month:hover .hit, .chart .month:focus .hit { fill: var(--cream); }
.chart .month:focus { outline: none; }
.chart .month { cursor: pointer; }
.chart-table { margin-top: 8px; }
.chart-table summary { cursor: pointer; font-weight: 700; font-size: .92rem; color: var(--teal-ink); }
.chart-tip { position: fixed; z-index: 10; background: var(--primary-bg); color: var(--primary-ink); padding: 6px 12px; border-radius: 10px; font-size: .88rem; font-weight: 700; pointer-events: none; max-width: 320px; }

/* Connexion */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: 28px 32px 32px; width: 100%; max-width: 400px; }
.login-card > img { display: block; width: 200px; height: auto; margin: 0 auto 10px; }
.login-card h1 { font-size: 1.35rem; text-align: center; margin-bottom: 18px; }
.login-card .flash { margin-bottom: 14px; font-size: .95rem; }
.login-card .btn { width: 100%; }

@media (max-width: 1000px) {
  .columns, .columns.even, .ged, .doc-view, .item-view { grid-template-columns: minmax(0, 1fr); }
  .mail { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - 130px); }
  .mail-list { border-right: 0; }
  .mail.has-thread .mail-list { display: none; }
  .mail:not(.has-thread) .thread { display: none; }
  .thread-back { display: inline; }
  .ged-tree { position: static; max-height: 45vh; }
  .request { grid-template-columns: minmax(0, 1fr); }
  .refuse { flex: 1 1 100%; }
  .refuse input { flex: 1; width: auto; min-width: 0; }
}

@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { top: 0; z-index: 5; height: auto; overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); padding: calc(6px + env(safe-area-inset-top)) 16px 6px; }
  .brand { display: flex; justify-content: space-between; align-items: center; margin: 0; }
  .brand img { width: 46px; display: block; }
  .topbar-actions { display: flex; align-items: center; gap: 8px; }
  .install-any { display: block; }
  .topbar-actions .install-any { background: none; border: 2px solid var(--teal-ink); border-radius: 999px; padding: 6px 12px; color: var(--teal-ink); font: 800 .9rem 'Nunito', sans-serif; cursor: pointer; }
  .login-card .install-any { margin-top: 10px; }
  .session-actions [data-notif-open] { display: none; }
  .menu-toggle { display: block; background: none; border: 2px solid var(--navy); border-radius: 999px; padding: 6px 16px; color: var(--navy); font: 800 .95rem 'Nunito', sans-serif; cursor: pointer; }
  .sidebar-body { display: none; position: absolute; top: 100%; left: 0; right: 0; min-height: 0; max-height: calc(100dvh - 70px); overflow-y: auto; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 12px 24px rgba(11, 42, 94, .18); }
  .sidebar.open .sidebar-body { display: flex; }
  .content { padding: 20px 16px calc(40px + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.35rem; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .filters input { flex: 1 1 100%; width: 100%; }
  .filters select { flex: 1 1 calc(50% - 4px); width: calc(50% - 4px); min-width: 0; }
  .chart { min-width: 560px; }
  .notif-list a { grid-template-columns: 12px minmax(0, 1fr); padding: 12px 16px; }
  .notif-meta { grid-column: 2; justify-items: start; }
  .tabs a { flex: 1 1 auto; justify-content: center; padding: 9px 8px; }
  .composer-actions .muted { display: none; }
  .doc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .doc-preview iframe { height: 60vh; }
  .view-toggle { margin-left: 0; }
  .head-actions .btn { flex: 1 1 auto; text-align: center; }
  .form-actions .btn { flex: 1 1 100%; text-align: center; }
  .push { margin-left: 0; }
  .btn, .link, .sidebar nav a { min-height: 44px; }
  .link { padding: 8px 0; }
  .refuse { flex-wrap: wrap; }
  .refuse input { flex: 1 1 100%; width: 100%; }
  .refuse .btn, .request-actions form, .request-actions .btn { width: 100%; }
  input, select, textarea { font-size: 16px; }

  table.cards-on-mobile thead { display: none; }
  table.cards-on-mobile, table.cards-on-mobile tbody, table.cards-on-mobile tfoot { display: block; }
  table.cards-on-mobile tr { display: block; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  table.cards-on-mobile tbody tr:last-child { border-bottom: 0; }
  table.cards-on-mobile td,
  .flush table.cards-on-mobile td:first-child,
  .flush table.cards-on-mobile td:last-child { display: flex; justify-content: space-between; gap: 14px; padding: 3px 0; border: 0; text-align: right; white-space: normal; }
  table.cards-on-mobile td:empty { display: none; }
  table.cards-on-mobile td[data-label]::before { content: attr(data-label); flex: none; color: var(--navy-soft); font-size: .84rem; font-weight: 800; text-align: left; }
  table.cards-on-mobile tbody td:first-child,
  .flush table.cards-on-mobile tbody td:first-child { display: block; text-align: left; font-weight: 700; padding-bottom: 6px; }
  table.cards-on-mobile tbody td:first-child::before { display: none; }
  table.cards-on-mobile td .tag { align-self: center; }
  table.cards-on-mobile tfoot tr { border-top: 2px solid var(--line); border-bottom: 0; }
  .card:not(.flush) table.cards-on-mobile tr { padding-left: 0; padding-right: 0; }
  .flush th:first-child, .flush td:first-child { padding-left: 16px; }
  .flush th:last-child, .flush td:last-child { padding-right: 16px; }
}

/* Animations : uniquement si l'appareil n'a pas demandé à réduire les mouvements */
@media (prefers-reduced-motion: no-preference) {
  @keyframes rise { from { opacity: 0; transform: translateY(14px); } }
  @keyframes fade { from { opacity: 0; } }
  @keyframes pop { 0% { opacity: 0; transform: scale(.92); } 70% { transform: scale(1.02); } }
  @keyframes jump { 0%, 100% { transform: translateY(0) rotate(0); } 35% { transform: translateY(-7px) rotate(-3deg); } 65% { transform: translateY(-2px) rotate(2deg); } }
  @keyframes wiggle { 25% { transform: rotate(-9deg) scale(1.06); } 75% { transform: rotate(9deg) scale(1.06); } }
  @keyframes grow { from { transform: scaleY(0); } }
  @keyframes slide-down { from { opacity: 0; transform: translateY(-8px); } }
  @keyframes pulse { 50% { transform: scale(1.18); } }

  /* Arrivée de la page, élément par élément */
  .content > * { animation: rise .42s cubic-bezier(.2, .8, .3, 1) backwards; }
  .content > *:nth-child(2) { animation-delay: .05s; }
  .content > *:nth-child(3) { animation-delay: .1s; }
  .content > *:nth-child(4) { animation-delay: .15s; }
  .content > *:nth-child(n+5) { animation-delay: .2s; }
  .doc-card { animation: pop .38s cubic-bezier(.2, .8, .3, 1) backwards; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
  .doc-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(11, 42, 94, .13); }
  .tile, .action-card { animation: pop .42s cubic-bezier(.2, .8, .3, 1) backwards; }
  .tile:nth-child(2), .action-card:nth-child(2) { animation-delay: .07s; }
  .tile:nth-child(3), .action-card:nth-child(3) { animation-delay: .14s; }
  .tile:nth-child(n+4), .action-card:nth-child(n+4) { animation-delay: .21s; }
  tbody tr, .timeline li, .checklist li { animation: fade .4s ease backwards .12s; }
  .flash { animation: slide-down .3s ease backwards; }
  .login-card { animation: pop .5s cubic-bezier(.2, .8, .3, 1) backwards; }
  .login-card > img { animation: jump .8s ease .35s; }
  .sidebar.open .sidebar-body { animation: slide-down .22s ease; }
  .badge { animation: pulse 1.8s ease-in-out 3; }

  /* Graphique : les barres poussent mois après mois */
  .chart .income, .chart .expense {
    transform-box: fill-box;
    transform-origin: bottom;
    animation: grow .55s cubic-bezier(.2, .8, .3, 1) backwards;
    animation-delay: calc(var(--i, 0) * 35ms + .15s);
  }

  /* Réactions au survol et au clic */
  .btn, .icon-btn, .tick, .tile, .action-card, .sidebar nav a, .me { transition: transform .16s ease, background-color .16s ease, border-color .16s ease, box-shadow .16s ease; }
  .btn:hover { transform: translateY(-2px); box-shadow: 0 5px 12px rgba(11, 42, 94, .18); }
  .btn:active, .icon-btn:active { transform: scale(.94); box-shadow: none; }
  a.tile:hover, .action-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(11, 42, 94, .13); }
  .sidebar nav a:hover { transform: translateX(3px); }
  .sidebar nav a:hover svg, .icon-btn:hover svg { animation: wiggle .4s ease; }
  .icon-btn:hover { transform: translateY(-2px); }
  .tick:hover { transform: scale(1.12); }
  .tick:active { transform: scale(.85); }
  .brand a:hover img { animation: jump .6s ease; }
  .avatar { transition: transform .2s ease; }
  .me:hover .avatar, .identity:hover .avatar { animation: wiggle .45s ease; }
  .chart .hit { transition: fill .15s ease; }
  .theme-switching, .theme-switching * { transition: background-color .3s ease, border-color .3s ease, color .3s ease, fill .3s ease !important; }
}

@media print {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  :root, :root[data-theme="dark"] {
    --navy: #0b2a5e; --navy-soft: #4d5f82; --teal-ink: #077176; --pink-ink: #c21f49; --green-ink: #4f6a00;
    --cream: #fff; --line: #ccc; --surface: #fff; --field: #fff;
    color-scheme: light;
  }
  body { background: #fff; }
  .shell { display: block; }
  .sidebar, .no-print, .flash { display: none !important; }
  .print-only { display: block; }
  .print-only img { width: 90px; height: auto; }
  .prose h2 { margin-top: 14px; }
  .content { padding: 0; max-width: none; }
  .card, .tile { border-color: #ccc; break-inside: avoid; }
}
