@import url('/vendor/inter/index.css');

/* Charte CLIM-MAG : bleu #009ACD, bleu foncé #175EA6, marine #0d1b2e — effet verre dépoli sur le fond géométrique. */
:root {
  --brand: #009acd; --brand-dark: #175ea6; --brand-deeper: #0d1b2e; --brand-light: #e6f6fc;
  --bg: #eef3f8; --surface: #fff; --surface-2: rgba(248, 250, 252, .75); --line: rgba(15, 40, 70, .1); --line-2: rgba(15, 40, 70, .07);
  --text: #0d1b2e; --text-2: #2b3a4e; --muted: #5b6b80; --faint: #8796a8;
  --primary: #175ea6; --primary-2: #0f4c8a; --primary-soft: rgba(0, 154, 205, .1); --accent: #009acd;
  --grad: linear-gradient(135deg, #009acd 0%, #175ea6 100%);
  --glass: rgba(255, 255, 255, .62); --glass-strong: rgba(255, 255, 255, .82); --glass-border: rgba(255, 255, 255, .75);
  --blur: saturate(160%) blur(18px);
  --ok: #15803d; --ok-soft: rgba(22, 163, 74, .12); --warn: #b45309; --warn-soft: rgba(245, 158, 11, .14); --err: #b91c1c; --err-soft: rgba(220, 38, 38, .1);
  --radius: 16px; --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(0, 26, 60, .06);
  --shadow: 0 10px 30px -12px rgba(0, 26, 60, .22), 0 2px 6px rgba(0, 26, 60, .05);
  --shadow-lg: 0 30px 70px -15px rgba(0, 26, 60, .4);
  --r-sender: #64748b; --r-signer1: #009acd; --r-signer2: #059669; --r-signer3: #d97706; --r-signer4: #7c3aed; --r-signer5: #0891b2; --r-internal: #dc2626; --r-any: #64748b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font: 14px/1.5 "Inter Variable", "Segoe UI", system-ui, sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
body.glass-bg::before { content: ''; position: fixed; inset: 0; z-index: -2; background: url('/brand/fond.webp') center / cover no-repeat; }
body.glass-bg::after { content: ''; position: fixed; inset: 0; z-index: -1; background: linear-gradient(115deg, rgba(240, 245, 250, .55) 0%, rgba(240, 245, 250, .35) 50%, rgba(240, 245, 250, .15) 100%); }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -.025em; color: var(--brand-deeper); }
h2 { font-size: 15px; font-weight: 650; margin: 0 0 14px; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Coque : barre latérale en verre */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar { margin: 14px 0 14px 14px; border-radius: 22px; background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--glass-border); box-shadow: var(--shadow); display: flex; flex-direction: column; padding: 22px 14px 16px; position: sticky; top: 14px; height: calc(100vh - 28px); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--brand-deeper); font-weight: 700; font-size: 15px; letter-spacing: -.01em; padding: 0 8px 24px; text-decoration: none !important; }
.brand img.mark { width: 40px; height: 40px; }
.brand small { display: block; font-weight: 600; font-size: 10.5px; color: var(--brand); letter-spacing: .14em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 12px; color: var(--text-2); font-weight: 550; text-decoration: none; transition: background .15s, color .15s; }
.nav a:hover { background: rgba(255, 255, 255, .7); color: var(--brand-dark); text-decoration: none; }
.nav a.on { background: var(--grad); color: #fff; box-shadow: 0 8px 18px -8px rgba(0, 154, 205, .7); }
.nav .sep { height: 1px; background: var(--line); margin: 10px 6px; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 14px 6px 0; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 650; font-size: 12.5px; flex: none; }
.side-foot .who { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); }
.side-foot .who b { display: block; color: var(--text); font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 7px; border-radius: 9px; display: grid; }
.icon-btn:hover { background: rgba(255, 255, 255, .8); color: var(--brand-dark); }

.main { min-width: 0; }
.page { max-width: 1240px; margin: 0 auto; padding: 36px 36px 64px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.head p { margin: 5px 0 0; color: var(--muted); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 30; margin: 0; border-radius: 0; height: auto; flex-direction: row; align-items: center; padding: 10px 14px; gap: 10px; overflow-x: auto; }
  .brand { padding: 0; } .brand small, .brand span { display: none; }
  .nav { flex-direction: row; } .nav .sep, .nav a span { display: none; }
  .side-foot { margin: 0 0 0 auto; border: none; padding: 0; } .side-foot .who { display: none; }
  .page { padding: 20px 16px 48px; }
}

/* ---------- Surfaces en verre */
.card { background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--glass-border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 22px 24px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr !important; } }

/* ---------- Boutons et champs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid rgba(15, 40, 70, .12); background: rgba(255, 255, 255, .75); color: var(--text-2); padding: 8px 15px; border-radius: var(--radius-sm); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap; box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, box-shadow .15s, transform .1s; }
.btn:hover { background: #fff; border-color: rgba(0, 154, 205, .35); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 8px 18px -8px rgba(0, 154, 205, .75); }
.btn.primary:hover { filter: brightness(1.06); box-shadow: 0 10px 22px -8px rgba(0, 154, 205, .9); }
.btn.ghost { border-color: transparent; box-shadow: none; background: transparent; }
.btn.ghost:hover { background: rgba(255, 255, 255, .7); }
.btn.danger { color: var(--err); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.link { border: none; background: none; color: var(--brand-dark); padding: 4px 6px; box-shadow: none; }
label.f { display: block; margin-bottom: 14px; }
label.f > span, .lbl { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=search], input[type=date], input:not([type]), select, textarea {
  width: 100%; font: inherit; padding: 9px 12px; border: 1px solid rgba(15, 40, 70, .14); border-radius: var(--radius-sm); background: rgba(255, 255, 255, .85); color: var(--text); transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, select:focus, textarea:focus { outline: none; background: #fff; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(0, 154, 205, .16); }
textarea { min-height: 84px; resize: vertical; }
.check, label.f.check { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; }
label.f.check > span { display: inline; font-size: inherit; font-weight: 400; margin: 0; color: var(--text); }
.check input { margin-top: 3px; accent-color: var(--brand); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 160px; }

/* ---------- Tableaux */
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); font-weight: 650; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr:last-child td { border-bottom: none; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: rgba(255, 255, 255, .7); }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: rgba(15, 40, 70, .07); color: var(--muted); white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.in_progress, .badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.completed, .badge.signed { background: var(--ok-soft); color: var(--ok); }
.badge.declined, .badge.cancelled { background: var(--err-soft); color: var(--err); }
.badge.archived { background: var(--primary-soft); color: var(--brand-dark); }
.badge.plain::before { display: none; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 8px; font-size: 12px; background: rgba(255, 255, 255, .75); border: 1px solid var(--line); margin: 2px 4px 2px 0; color: var(--text-2); }
.chip.ok { color: var(--ok); border-color: rgba(22, 163, 74, .25); background: var(--ok-soft); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.group-title { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--brand-dark); font-weight: 700; margin: 28px 0 12px; display: flex; align-items: center; gap: 10px; }
.group-title::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(0, 154, 205, .35), transparent); }

/* ---------- Filtres */
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .fi { display: flex; flex-direction: column; min-width: 160px; }
.filters .fi.grow { flex: 1; min-width: 220px; }
.seg { display: inline-flex; background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--glass-border); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; box-shadow: var(--shadow-sm); }
.seg button { border: none; background: none; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); padding: 6px 12px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--brand-dark); }
.seg button.on { background: var(--grad); color: #fff; box-shadow: 0 6px 14px -6px rgba(0, 154, 205, .7); }
.resume { font-size: 13px; color: var(--muted); margin: 0 0 10px 2px; }

/* ---------- Cartes de modèles */
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.tcard { background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--glass-border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: box-shadow .2s, transform .2s; }
.tcard:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); }
.tcard .thumb { height: 190px; background: linear-gradient(160deg, rgba(0, 154, 205, .16), rgba(23, 94, 166, .08)); display: flex; justify-content: center; align-items: flex-start; padding-top: 18px; overflow: hidden; cursor: pointer; }
.tcard .thumb canvas { box-shadow: 0 6px 18px rgba(0, 26, 60, .2); border-radius: 3px; }
.tcard .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.tcard .name { font-weight: 650; letter-spacing: -.01em; line-height: 1.35; }
.tcard .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tcard .btns { display: flex; flex-direction: column; gap: 4px; margin-top: auto; }
.tcard .btns .btn { width: 100%; }
.tcard .btns .btn.ghost { color: var(--muted); }

/* ---------- Fenêtre modale */
.modal-bg { position: fixed; inset: 0; background: rgba(13, 27, 46, .35); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
.modal { background: var(--glass-strong); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--glass-border); border-radius: 20px; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 780px; }
.modal header { padding: 22px 24px 0; font-weight: 700; font-size: 16px; letter-spacing: -.01em; color: var(--brand-deeper); }
.modal .body { padding: 16px 24px; }
.modal footer { padding: 14px 24px 18px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line-2); }
@keyframes fade { from { opacity: 0; } }

/* ---------- Panneau latéral (visionneuse) */
.drawer-bg { position: fixed; inset: 0; background: rgba(13, 27, 46, .3); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 90; animation: fade .15s; }
.drawer { position: fixed; top: 10px; right: 10px; bottom: 10px; width: min(1180px, calc(100vw - 20px)); border-radius: 22px; overflow: hidden; background: var(--glass-strong); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--glass-border); z-index: 91; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slide .22s ease; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer .dh { border-bottom: 1px solid var(--line); padding: 14px 20px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.drawer .dh .t { flex: 1; min-width: 200px; }
.drawer .dh .t b { display: block; font-size: 16px; font-weight: 700; color: var(--brand-deeper); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer .db { flex: 1; display: grid; grid-template-columns: 1fr 340px; min-height: 0; }
.drawer .viewer { overflow: auto; padding: 24px; background: rgba(13, 27, 46, .06); }
.drawer .info { overflow: auto; border-left: 1px solid var(--line); padding: 20px 22px; }
@media (max-width: 900px) { .drawer .db { grid-template-columns: 1fr; grid-template-rows: 1fr auto; } .drawer .info { border-left: none; border-top: 1px solid var(--line); max-height: 40vh; } }
.pdfpage { margin: 0 auto 18px; background: #fff; box-shadow: 0 8px 24px -6px rgba(0, 26, 60, .25); position: relative; border-radius: 2px; }
.pdfpage canvas { display: block; }
.kv { display: grid; grid-template-columns: 100px 1fr; gap: 7px 10px; font-size: 13px; margin: 0 0 20px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; color: var(--text); word-break: break-word; }
.sec { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--brand-dark); font-weight: 700; margin: 0 0 10px; }

/* ---------- Notifications */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: rgba(13, 27, 46, .92); backdrop-filter: blur(10px); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); max-width: 400px; font-weight: 500; animation: up .2s ease; border-left: 3px solid var(--brand); }
.toast.err { background: rgba(185, 28, 28, .95); border-left-color: #fecaca; }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Chronologie */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 0 0 14px 20px; border-left: 1.5px solid rgba(0, 154, 205, .25); position: relative; font-size: 13px; margin-left: 4px; }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ''; position: absolute; left: -5.5px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2.5px solid var(--brand); }
.timeline time { display: block; font-size: 11.5px; color: var(--faint); }
.signer-line { padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.signer-line:last-child { border-bottom: none; }

/* ---------- Pages de connexion / signature */
.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth { width: 100%; max-width: 420px; }
.auth .logo-full { display: block; width: 132px; margin: 0 auto 22px; filter: drop-shadow(0 6px 14px rgba(0, 26, 60, .15)); }
.auth .card { background: var(--glass-strong); border-radius: 22px; padding: 28px 30px; }
.auth .tagline { text-align: center; color: var(--muted); font-size: 13px; margin: -10px 0 20px; }
.code-input { font-size: 26px !important; letter-spacing: 10px; text-align: center; font-weight: 700; }
.err-msg { color: var(--err); font-size: 13px; margin: -4px 0 12px; }

/* Modèles : recherche + filtres par type */
.tpl-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: -4px 0 18px; }
.tpl-tools input[type=search] { width: 300px; max-width: 100%; }
.tpl-tools .seg .n { font-weight: 500; opacity: .65; margin-left: 2px; }
.tpl-tools .seg button.on .n { opacity: .85; }
