@font-face { font-family: 'Dancing Script'; font-weight: 600; font-display: swap; src: url("../fonts/dancing-script-latin-600-normal-waV8wcH.woff2") format('woff2'); }
@font-face { font-family: 'Great Vibes'; font-weight: 400; font-display: swap; src: url("../fonts/great-vibes-latin-400-normal-58ItW7e.woff2") format('woff2'); }
@font-face { font-family: 'Caveat'; font-weight: 600; font-display: swap; src: url("../fonts/caveat-latin-600-normal-kJk2uD6.woff2") format('woff2'); }

:root {
    --bg: #f4f6fc;
    --bg-soft: #eef1fa;
    --surface: #ffffff;
    --surface-2: #f7f9ff;
    --text: #151a30;
    --muted: #667090;
    --line: #e2e6f2;
    --line-strong: #ccd3e6;
    --accent: #3a4bc4;
    --accent-2: #6c5ce7;
    --accent-soft: #eceefe;
    --accent-glow: rgba(58, 75, 196, .14);
    --on-accent: #ffffff;
    --ok: #128157;
    --ok-soft: #ddf5ea;
    --warn: #a4690b;
    --warn-soft: #fdf1d8;
    --danger: #b3261e;
    --danger-soft: #fdecea;
    --glow-1: rgba(58, 75, 196, .12);
    --glow-2: rgba(108, 92, 231, .10);
    --radius: 14px;
    --radius-sm: 10px;
    --topbar-h: 56px;
    --shadow-sm: 0 1px 2px rgba(20, 30, 90, .05);
    --shadow: 0 2px 4px rgba(20, 30, 90, .04), 0 12px 30px rgba(20, 30, 90, .07);
    --shadow-lg: 0 18px 50px rgba(20, 30, 90, .14);
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0e1222;
    --bg-soft: #141a30;
    --surface: #191f38;
    --surface-2: #1f2646;
    --text: #e9ecfa;
    --muted: #9aa3c7;
    --line: #2a3156;
    --line-strong: #3a4270;
    --accent: #8b9bff;
    --accent-2: #b39dff;
    --accent-soft: #232a52;
    --accent-glow: rgba(139, 155, 255, .18);
    --on-accent: #10132a;
    --ok: #5fd6a0;
    --ok-soft: #123a2b;
    --warn: #f0c06a;
    --warn-soft: #3a2f16;
    --danger: #ff8a80;
    --danger-soft: #3f1e1e;
    --glow-1: rgba(139, 155, 255, .12);
    --glow-2: rgba(179, 157, 255, .10);
    --shadow-sm: none;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 34px rgba(0, 0, 0, .28);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .45);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg: #0e1222;
        --bg-soft: #141a30;
        --surface: #191f38;
        --surface-2: #1f2646;
        --text: #e9ecfa;
        --muted: #9aa3c7;
        --line: #2a3156;
        --line-strong: #3a4270;
        --accent: #8b9bff;
        --accent-2: #b39dff;
        --accent-soft: #232a52;
        --accent-glow: rgba(139, 155, 255, .18);
        --on-accent: #10132a;
        --ok: #5fd6a0;
        --ok-soft: #123a2b;
        --warn: #f0c06a;
        --warn-soft: #3a2f16;
        --danger: #ff8a80;
        --danger-soft: #3f1e1e;
        --glow-1: rgba(139, 155, 255, .12);
        --glow-2: rgba(179, 157, 255, .10);
        --shadow-sm: none;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 34px rgba(0, 0, 0, .28);
        --shadow-lg: 0 24px 60px rgba(0, 0, 0, .45);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(1100px 620px at 88% -12%, var(--glow-1), transparent 62%),
        radial-gradient(900px 520px at -8% 4%, var(--glow-2), transparent 58%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font: 16px/1.55 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: var(--on-accent); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-2); }
h1 { font-size: 1.65rem; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 .9rem; }
h2 { font-size: 1rem; line-height: 1.3; letter-spacing: -.01em; margin: 0 0 .7rem; }
p { margin: .55rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.center { text-align: center; }
.mt { margin-top: 1rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Structure ---------- */
.topbar {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    min-height: var(--topbar-h); padding: .45rem 1.1rem;
    background: var(--surface);
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    border-bottom: 1px solid var(--line);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 750; font-size: 1.12rem; letter-spacing: -.02em; color: var(--accent); text-decoration: none; }
.brand:hover { color: var(--accent-2); }
.brand svg { border-radius: 8px; box-shadow: 0 4px 12px var(--accent-glow); }
.topbar > nav:not(.mobile-nav) { margin-left: auto; }
.topbar nav { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.topbar nav a { padding: .4rem .6rem; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: .92rem; transition: color .15s, background .15s; }
.topbar nav a:hover { color: var(--text); background: var(--accent-soft); }
.topbar nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 650; }
.topbar nav .who { padding: .25rem .7rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.topbar nav .who:hover { color: var(--accent); }
.topbar nav form { margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: .4rem; }

/* Notifications */
.notif { position: relative; }
.notif-toggle {
    position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0;
    border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--muted);
    cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.notif-toggle:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.notif-toggle svg { width: 18px; height: 18px; }
.notif-count {
    position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 4px;
    display: grid; place-items: center; border-radius: 99px; border: 2px solid var(--surface);
    background: var(--danger); color: #fff; font-size: .66rem; font-weight: 750; line-height: 1;
}
.notif-panel {
    position: absolute; top: calc(100% + .55rem); right: 0; z-index: 50;
    width: min(370px, calc(100vw - 1.6rem));
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); overflow: hidden;
}
.notif-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .75rem .9rem; border-bottom: 1px solid var(--line); }
.notif-head .badge { font-size: .68rem; }
.notif-list { list-style: none; margin: 0; padding: 0; max-height: min(55vh, 380px); overflow-y: auto; }
.notif-item a { display: block; padding: .6rem .9rem; color: var(--text); text-decoration: none; border-left: 3px solid transparent; }
.notif-item a:hover { background: var(--surface-2); }
.notif-item.unread a { background: var(--accent-soft); border-left-color: var(--accent); }
.notif-item span { display: block; font-size: .86rem; line-height: 1.35; }
.notif-item time { display: block; margin-top: .2rem; color: var(--muted); font-size: .72rem; }
.notif-empty { padding: .9rem; margin: 0; }
.notif-foot { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; padding: .6rem .9rem; border-top: 1px solid var(--line); font-size: .8rem; }
.notif-foot form { margin: 0; }
.notif-page-list { border-top: 1px solid var(--line); }
.notif-page-list .notif-item:first-child a { border-top: 0; }

/* Menu mobile */
.mobile-menu-btn { display: none; border: 0; background: none; color: var(--muted); cursor: pointer; padding: .4rem; }
.mobile-menu-btn:hover { color: var(--text); }
.mobile-menu-btn svg { width: 24px; height: 24px; }
.mobile-nav {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding: 1rem; flex-direction: column; gap: .5rem;
    box-shadow: var(--shadow-lg);
    max-height: calc(100dvh - var(--topbar-h));
    overflow-y: auto; overscroll-behavior: contain;
}
.mobile-nav.open { display: flex; }
.mobile-nav a { padding: .6rem .8rem; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: .95rem; }
.mobile-nav a:hover { color: var(--text); background: var(--accent-soft); }
.mobile-nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 650; }
.mobile-nav .who { padding: .5rem .8rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.mobile-nav form { margin-top: .5rem; }
.mobile-nav button { width: 100%; justify-content: flex-start; }
.container { max-width: 1280px; margin: 0 auto; padding: 1.1rem clamp(1rem, 2vw, 1.75rem) 2.5rem; }
main { animation: fade-in .28s ease-out both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.3rem;
    box-shadow: var(--shadow);
}
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; align-items: start; }
.title-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.title-row h1 { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: .9rem 0 1.2rem; }
.actions form { margin: 0; }

/* ---------- Thème ---------- */
.theme-toggle {
    display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--surface-2); color: var(--muted); cursor: pointer;
    transition: color .15s, border-color .15s, transform .12s, background .15s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .theme-toggle .icon-sun { display: block; }
    :root:not([data-theme]) .theme-toggle .icon-moon { display: none; }
}

/* ---------- Boutons, champs ---------- */
.btn, button.link {
    font: inherit; font-weight: 550; cursor: pointer; text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    border: 1px solid var(--line); background: var(--surface); color: var(--text);
    padding: .55rem 1rem; border-radius: var(--radius-sm); line-height: 1.2;
    box-shadow: var(--shadow-sm);
    transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease, color .15s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.99); }
.btn.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent; color: var(--on-accent);
    box-shadow: 0 6px 18px var(--accent-glow);
}
.btn.primary:hover { color: var(--on-accent); filter: brightness(1.06); box-shadow: 0 10px 26px var(--accent-glow); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.btn.small { padding: .34rem .7rem; font-size: .85rem; border-radius: 8px; }
.btn.block { display: flex; width: 100%; }
.btn:disabled { opacity: .55; cursor: progress; transform: none; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); box-shadow: none; font-weight: 500; }
button.link:hover { color: var(--accent-2); transform: none; }

input[type=text], input[type=password], input[type=number], input[type=email], input[type=tel], input[type=url], input[type=search], select, textarea {
    font: inherit; padding: .58rem .72rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--text); max-width: 100%;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=url] { width: 100%; }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent); background: var(--surface);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
select {
    appearance: none; -webkit-appearance: none; padding-right: 2.2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667090' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .65rem center;
}
input[type=file] { font: inherit; color: var(--muted); }
input[type=file]::file-selector-button {
    font: inherit; font-size: .85rem; margin-right: .7rem; padding: .4rem .8rem;
    border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
    color: var(--text); cursor: pointer;
}
input[type=file]::file-selector-button:hover { border-color: var(--accent); color: var(--accent); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 1rem; height: 1rem; }
label { display: block; font-weight: 600; font-size: .9rem; margin: .85rem 0 .35rem; }
label.check, label.inline { display: flex; align-items: center; gap: .5rem; font-weight: 500; margin: .45rem 0; }
label.check input, label.inline input { flex: none; }
.row { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.input-icon { position: relative; }
.input-icon > svg {
    position: absolute; left: .78rem; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; color: var(--muted); pointer-events: none;
}
.input-icon > input { padding-left: 2.5rem; }

.flash { padding: .7rem .95rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .93rem; border: 1px solid transparent; border-left-width: 3px; }
.flash-success { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.flash-secret { background: var(--accent-soft); color: var(--text); border: 1px dashed var(--accent); font: 1rem ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
.flash-secret small { display: block; margin-top: .3rem; font: .8rem system-ui, sans-serif; color: var(--muted); }
.alert { padding: .7rem .95rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .9rem; border: 1px solid transparent; border-left-width: 3px; }
.alert p { margin: .25rem 0; }
.alert.info { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }
.alert.error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.alert.success { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.field { margin-bottom: .9rem; }
.field > label:first-child { margin-top: 0; }

.badge { display: inline-flex; align-items: center; gap: .38rem; padding: .16rem .62rem; border-radius: 99px; font-size: .78rem; font-weight: 650; background: var(--accent-soft); color: var(--accent); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }

/* ---------- Accueil ---------- */
.dropzone {
    display: flex; flex-direction: column; align-items: center; gap: .35rem; text-align: center;
    padding: 2.2rem 1rem; margin-bottom: 1.6rem; border: 2px dashed var(--line-strong); border-radius: var(--radius);
    background: linear-gradient(180deg, var(--surface), var(--surface-2)); color: var(--muted);
    transition: border-color .18s, background .18s, transform .18s;
}
.dropzone svg { color: var(--accent); margin-bottom: .3rem; }
.dropzone p { margin: .2rem 0; }
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.empty { text-align: center; padding: 1.5rem 1rem; }
.table-card { padding: 0; overflow: hidden; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .8rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); font-weight: 700; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }

/* ---------- Détail ---------- */
dl { margin: 0; }
dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: .85rem; font-weight: 700; }
dd { margin: .15rem 0 0; overflow-wrap: anywhere; }
dd.hash { font: .8rem ui-monospace, Menlo, Consolas, monospace; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; flex-direction: column; gap: .1rem; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border: 0; padding-bottom: 0; }
.login { max-width: 380px; margin: 4rem auto; }

/* ---------- Éditeur ---------- */
.editor-main { padding: 0; }
.editor { display: grid; grid-template-columns: 300px 1fr; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
    background: var(--surface); border-right: 1px solid var(--line); padding: .9rem 1rem;
    position: sticky; top: var(--topbar-h); align-self: start;
    max-height: calc(100vh - var(--topbar-h)); overflow-y: auto;
}
.sidebar section { margin-bottom: 1.4rem; }
.sidebar .back { display: block; margin-bottom: 1rem; font-size: .9rem; text-decoration: none; overflow-wrap: anywhere; }
.workflow-banner {
    display: flex; align-items: center; flex-wrap: wrap; gap: .55rem 1rem;
    padding: .7rem clamp(1rem, 2vw, 1.75rem);
    background: var(--surface); border-bottom: 1px solid var(--line);
    font-size: .9rem;
}
.workflow-info { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.current-step { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-left: auto; color: var(--muted); }
.text-tools { margin-top: .5rem; }
.text-tools label { display: flex; justify-content: space-between; align-items: center; gap: .6rem; font-weight: 500; margin: .45rem 0; }
.sign-box { border-top: 1px solid var(--line); padding-top: 1rem; }
.sign-box .flash { margin: .6rem 0; }
.sign-box p { margin: .65rem 0 0; }

.assets { display: flex; flex-direction: column; gap: .45rem; margin-bottom: .7rem; }
.assets:empty::before { content: 'Aucun élément pour l’instant.'; color: var(--muted); font-size: .85rem; }
.asset { position: relative; }
.asset-add {
    display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left; cursor: pointer; font: inherit; font-size: .85rem;
    padding: .4rem 2rem .4rem .4rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text);
    transition: border-color .15s, background .15s;
}
.asset-add:hover { border-color: var(--accent); background: var(--accent-soft); }
.asset-add img { width: 84px; height: 40px; object-fit: contain; background: #fff; border-radius: 5px; border: 1px solid var(--line); }
.asset-add span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-del { position: absolute; top: 50%; right: .4rem; transform: translateY(-50%); border: 0; background: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; line-height: 1; }
.asset-del:hover { color: var(--danger); }

.workspace { padding: .8rem; overflow-x: auto; background: var(--bg-soft); }
.pages { width: 100%; max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }
.loading { text-align: center; padding: 3rem 0; }
.loading.error { color: var(--danger); }
.page { position: relative; width: 100%; background: #fff; border-radius: 3px; box-shadow: 0 2px 10px rgba(20, 30, 90, .14), 0 14px 40px rgba(20, 30, 90, .12); }
.page canvas { display: block; width: 100%; height: 100%; }
.page-number { position: absolute; top: 100%; left: 0; font-size: .75rem; color: var(--muted); margin-top: .15rem; }
.layer { position: absolute; inset: 0; overflow: hidden; }

.item { position: absolute; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.item:active { cursor: grabbing; }
.item.selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.item-image img { display: block; width: 100%; height: auto; pointer-events: none; }
.item-text { width: max-content; max-width: none; padding: 0; }
.item-text .label {
    display: block; white-space: pre; font-family: Helvetica, Arial, 'Liberation Sans', sans-serif;
    font-size: calc(var(--size) * var(--k, 1) * 1px); line-height: 1.2; outline: none;
}
.item-text.editing { cursor: text; user-select: text; -webkit-user-select: text; }
.item-del, .item-handle { display: none; position: absolute; }
.item.selected .item-del, .item.selected .item-handle { display: block; }
.item-del {
    top: -12px; right: -12px; width: 22px; height: 22px; border-radius: 50%; border: 0; padding: 0;
    background: var(--danger); color: #fff; font-size: 15px; line-height: 22px; cursor: pointer;
}
.item-handle { right: -7px; bottom: -7px; width: 14px; height: 14px; border-radius: 3px; background: var(--accent); border: 2px solid #fff; cursor: nwse-resize; }
.editing .item-handle, .editing .item-del { display: none !important; }

/* Bloc de signature numérique (déplaçable et redimensionnable comme une image). */
.item-digital { container-type: inline-size; }
.item-digital .digital-card {
    display: flex; align-items: stretch; gap: 2.2cqw;
    width: 100%; aspect-ratio: 3 / 1; padding: 2.2cqw 2.4cqw 2.2cqw 2.8cqw;
    background: #fff; border: 1px solid #ccd3e6; border-left: .55cqw solid #3a4bc4;
    border-radius: .9cqw; box-shadow: 0 1px 2px rgba(20, 30, 90, .08);
    color: #151a30; overflow: hidden;
}
.item-digital .digital-qr { flex: 0 0 auto; height: 100%; aspect-ratio: 1; background: #fff; }
.item-digital .digital-qr img { display: block; width: 100%; height: 100%; object-fit: contain; }
.item-digital .digital-body {
    flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column;
    justify-content: center; gap: .55cqw; line-height: 1.15;
}
.item-digital .digital-title { font-size: 2.75cqw; font-weight: 750; color: #3a4bc4; }
.item-digital .digital-name { font-size: 3cqw; font-weight: 650; overflow-wrap: anywhere; }
.item-digital .digital-meta { font-size: 2.45cqw; color: #667090; }
.item-digital .digital-hint { font-size: 2.05cqw; color: #667090; }

/* ---------- Vérification publique d'une signature ---------- */
.verify-wrap { max-width: 640px; margin: 2.5rem auto; }
.verify-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: clamp(1.4rem, 4vw, 2.4rem); box-shadow: var(--shadow); text-align: center;
}
.verify-seal {
    width: 76px; height: 76px; margin: 0 auto 1rem; display: grid; place-items: center;
    border-radius: 50%; background: var(--ok-soft); color: var(--ok);
    border: 1px solid color-mix(in srgb, var(--ok) 25%, transparent);
}
.verify-seal svg { width: 40px; height: 40px; }
.verify-card h1 { margin: .8rem 0 .4rem; font-size: 1.5rem; }
.verify-list { text-align: left; margin: 1.5rem 0; border-top: 1px solid var(--line); }
.verify-list > div { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 1rem; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.verify-list dt { margin: 0; }
.verify-list dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.verify-note { margin: 1.2rem 0 0; color: var(--muted); font-size: .85rem; }
@media (max-width: 640px) { .verify-list > div { grid-template-columns: 1fr; gap: .2rem; } }

/* ---------- Fenêtre signature / cachet ---------- */
.dialog {
    border: 1px solid var(--line); border-radius: 16px; padding: 1.3rem; width: min(660px, 94vw);
    max-height: calc(100dvh - 2rem); overflow-y: auto;
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(10, 13, 30, .55); backdrop-filter: blur(3px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.dialog-head h2 { font-size: 1.2rem; margin: 0; }
.icon { border: 0; background: none; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); border-radius: 8px; padding: 0 .2rem; }
.icon:hover { color: var(--text); }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: .9rem; }
.tab { border: 0; background: none; font: inherit; padding: .55rem .95rem; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 650; }
.pad, .preview {
    display: block; width: 100%; height: auto; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: #fff;
}
.pad { touch-action: none; cursor: crosshair; aspect-ratio: 3 / 1; }
.preview { margin-top: .6rem; max-height: 220px; object-fit: contain; }
.checker { background: repeating-conic-gradient(#e6e6ee 0 25%, #fff 0 50%) 0 / 16px 16px; }
.fonts { display: flex; gap: .6rem; margin: .7rem 0; flex-wrap: wrap; }
.fonts label { display: block; margin: 0; cursor: pointer; }
.fonts input { position: absolute; opacity: 0; }
.fonts span { display: block; padding: .3rem .9rem; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 1.5rem; background: var(--surface-2); transition: border-color .15s, background .15s; }
.fonts input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }
.dialog-foot { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
.dialog-foot input { flex: 1 1 200px; width: auto; }
.dialog-foot .flash { flex-basis: 100%; margin: 0; order: -1; }

/* ---------- Comptes, administration, extension Office ---------- */
.narrow { max-width: 600px; margin: .75rem auto; }
.topbar nav .who { font-weight: 650; }
.subnav { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.3rem; overflow-x: auto; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav a { flex: none; white-space: nowrap; }
.subnav a { padding: .55rem .95rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: .92rem; }
.subnav a:hover { color: var(--text); }
.subnav a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 650; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); gap: .85rem; margin-bottom: 1.3rem; }
.stat {
    position: relative; overflow: hidden;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: .85rem 1rem; color: var(--muted); font-size: .84rem; box-shadow: var(--shadow-sm);
}
.stat::before { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--accent); opacity: .55; }
.stat span { display: block; font-size: 1.85rem; font-weight: 750; letter-spacing: -.03em; color: var(--text); line-height: 1.15; margin-bottom: .1rem; }
.stat.ok::before { background: var(--ok); }
.stat.warn::before { background: var(--warn); }
.stat.bad::before { background: var(--danger); }
.stat.ok span { color: var(--ok); }
.stat.warn span { color: var(--warn); }
.stat.bad span { color: var(--danger); }
.toolbar { display: flex; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar form { margin: 0; }
.toolbar input[type=search] { min-width: 240px; background: var(--surface); }
.row-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.row-actions form { margin: 0; }
.signer-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.signer-row select { flex: 1; min-width: 0; }
label.radio { align-items: flex-start; padding: .65rem .75rem; margin: .5rem 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); transition: border-color .15s, background .15s; }
label.radio:hover { border-color: var(--accent); background: var(--accent-soft); }
label.radio input { margin-top: .3rem; }
label.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
ul.plain { list-style: none; padding: 0; margin: 0 0 .8rem; }
ul.plain li { margin-bottom: .8rem; }
.steps { padding-left: 1.25rem; } .steps li { margin-bottom: .65rem; }
code { background: var(--accent-soft); color: var(--accent); padding: .1rem .38rem; border-radius: 5px; font-size: .85em; overflow-wrap: anywhere; }
.embedded .topbar { display: none; }
.embedded .editor { min-height: 100vh; }
.embedded .sidebar { top: 0; max-height: 100vh; }
.done-overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(10, 13, 30, .6); z-index: 50; backdrop-filter: blur(4px); }
.done-overlay .card { text-align: center; max-width: 380px; box-shadow: var(--shadow-lg); }

/* ---------- Responsive Design ---------- */

/* Mobile (≤ 768px) */
@media (max-width: 768px) {
    .mobile-menu-btn { display: block; }
    .topbar nav { display: none; }
    .mobile-nav { display: none; }
    .mobile-nav.open { display: flex; }

    .container { padding: 1rem 1rem; }
    .topbar { padding: .4rem .8rem; }
    .topbar-actions { gap: .3rem; }
    .notif-panel { position: fixed; top: calc(var(--topbar-h) + .35rem); left: .8rem; right: .8rem; width: auto; }
    .brand { font-size: 1rem; }
    .brand svg { width: 22px; height: 22px; }

    h1 { font-size: 1.4rem; }
    h2 { font-size: .95rem; }

    .card { padding: 1rem; }
    .grid-2 { grid-template-columns: 1fr; }

    .btn { padding: .5rem .85rem; font-size: .9rem; }
    .btn.small { padding: .3rem .6rem; font-size: .8rem; }

    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar input[type=search] { min-width: 100%; }

    .stats { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
    .stat { padding: .7rem .8rem; font-size: .8rem; }
    .stat span { font-size: 1.5rem; }

    table { font-size: .85rem; }
    th, td { padding: .6rem .5rem; }
    .table-card { border-radius: var(--radius-sm); }

    .workflow-banner { padding: .7rem 1rem; }
    .current-step { margin-left: 0; width: 100%; }

    .subnav { margin-bottom: 1rem; }

    .signer-row { flex-wrap: wrap; }
    .signer-row select { flex: 1 1 100%; }

    .editor { grid-template-columns: 1fr; }
    .sidebar {
        position: static; max-height: 46dvh; overflow-y: auto; overscroll-behavior: contain;
        border-right: 0; border-bottom: 1px solid var(--line); padding: .8rem;
    }
    .sidebar section { margin-bottom: 1rem; }
    .workspace { padding: .5rem; }
    .pages { gap: .5rem; }

    .dialog { width: 100%; max-width: none; border-radius: var(--radius-sm); padding: 1rem; }
    .dialog-head h2 { font-size: 1rem; }
    .fonts { gap: .4rem; }
    .fonts span { padding: .25rem .6rem; font-size: 1.2rem; }

    .login { margin: 1.5rem auto; }
    .dropzone { padding: 1.5rem .8rem; }
    .dropzone svg { width: 32px; height: 32px; }

    .badge { font-size: .7rem; padding: .12rem .5rem; }
}

/* Petits mobiles (≤ 640px) : tables en cartes */
@media (max-width: 640px) {
    table.responsive,
    table.responsive tbody,
    table.responsive tr,
    table.responsive td { display: block; width: 100%; }

    table.responsive thead { display: none; }
    table.responsive tr { padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
    table.responsive tr:last-child { border-bottom: 0; }
    table.responsive tr:hover { background: transparent; }

    table.responsive td {
        display: grid; grid-template-columns: minmax(88px, 36%) minmax(0, 1fr);
        gap: .5rem; align-items: start;
        padding: .18rem 0; border: 0;
    }
    table.responsive td::before {
        content: attr(data-label);
        font-size: .68rem; font-weight: 700; letter-spacing: .05em;
        text-transform: uppercase; color: var(--muted);
    }
    table.responsive td[data-label=""]::before { display: none; }
    table.responsive td.right { text-align: left; }

    table.responsive td.cell-actions {
        display: block; padding-top: .55rem;
    }
    table.responsive td.cell-actions::before {
        display: block; margin-bottom: .4rem;
    }

    table.responsive td.empty-row {
        display: block; padding: .7rem 0; text-align: center;
    }
    table.responsive td.empty-row::before { display: none; }

    .dialog { max-height: calc(100dvh - 1rem); }
}

/* Tablet (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .container { padding: 1rem 1.5rem; }
    .grid-2 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
    .stats { grid-template-columns: repeat(3, 1fr); }
}

/* Large Desktop (> 1024px) */
@media (min-width: 1025px) {
    .mobile-menu-btn { display: none; }
    .mobile-nav { display: none; }
}

/* Extra Large Screens (> 1440px) */
@media (min-width: 1440px) {
    .container { max-width: 1400px; }
}

/* Mobile Landscape (≤ 768px, landscape) */
@media (max-width: 768px) and (orientation: landscape) {
    .topbar { min-height: 48px; }
    .brand { font-size: .95rem; }
    .container { padding: .5rem 1rem; }
}

/* Print Styles */
@media print {
    .topbar, .sidebar, .toolbar, .actions, .theme-toggle, .mobile-menu-btn, .mobile-nav, .notif { display: none !important; }
    .container { max-width: none; padding: 0; }
    .card { border: none; box-shadow: none; padding: 0; }
    body { background: white; color: black; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ---------- Permissions ---------- */
.perm-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.perm-item { display: inline-block; font-size: .75rem; padding: .15rem .5rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.perm-checkboxes { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; margin-top: .5rem; }
.perm-checkbox { font-size: .9rem; cursor: pointer; }
.perm-checkbox input { margin-right: .35rem; }
.perm-checkbox input:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Sélecteur d’espace (logo + dropdown) ---------- */
.org-picker { display: inline-flex; align-items: center; gap: .25rem; position: relative; }
.org-trigger {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .35rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--text); font-size: .9rem; font-weight: 600;
    cursor: pointer; transition: border-color .15s, background .15s, color .15s;
}
.org-trigger:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.org-trigger svg { width: 14px; height: 14px; flex: none; }
.org-logo {
    width: 28px; height: 28px; border-radius: 6px; object-fit: cover; border: 1px solid var(--line);
    background: var(--surface); flex: none;
}
.org-menu {
    position: absolute; top: 100%; right: 0; z-index: 50;
    min-width: 190px; margin-top: .4rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column;
}
.org-menu-item {
    display: block; padding: .6rem .9rem; color: var(--text); text-decoration: none;
    font-size: .9rem; border-bottom: 1px solid var(--line); transition: background .15s, color .15s;
}
.org-menu-item:last-child { border-bottom: 0; }
.org-menu-item:hover { background: var(--surface-2); color: var(--accent); }
.org-menu-item.org-menu-switch { cursor: pointer; border: none; background: none; text-align: left; font: inherit; padding: 0; }
.org-menu-item.org-menu-switch .org-menu-item-link { display: block; padding: .6rem .9rem; border-bottom: 1px solid var(--line); }
.org-menu-item.org-menu-switch .org-menu-item-link:last-child { border-bottom: 0; }
.org-menu-item.org-menu-switch .org-menu-item-link:hover { background: var(--surface-2); color: var(--accent); }
