:root {
    --bg: #070b14;
    --bg-2: #0c1220;
    --bg-3: #121a2c;
    --line: rgba(245, 196, 0, .12);
    --stroke: rgba(255, 255, 255, .08);
    --gold: #f5c400;
    --gold-2: #ffe36a;
    --ink: #f4f6fb;
    --muted: #8d98b0;
    --ok: #3dd68c;
    --warn: #ffb020;
    --bad: #ff5d6c;
    --info: #5aa7ff;
    --radius: 18px;
    --font: "Outfit", system-ui, sans-serif;
    --display: "Syne", "Outfit", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { overflow-x: hidden; }
body {
    font-family: var(--font);
    background:
        radial-gradient(900px 400px at 10% -10%, rgba(245, 196, 0, .08), transparent 50%),
        linear-gradient(180deg, var(--bg), #05070d);
    color: var(--ink);
    overflow-x: hidden;
}
img, svg, video { max-width: 100%; height: auto; }
a { color: var(--gold); text-decoration: none; }
h1, h2, h3 { font-family: var(--display); margin: 0 0 .4rem; letter-spacing: -.03em; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 .8rem; }
.muted { color: var(--muted); }
.kicker { color: var(--gold); text-transform: uppercase; letter-spacing: .18em; font-size: .72rem; font-weight: 700; margin-bottom: .35rem; }

.app {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    max-width: 100vw;
}

/* —— Mobile top bar + drawer (default) —— */
.topbar {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .75rem;
    padding-top: max(.55rem, env(safe-area-inset-top));
    background: #080d18;
    border-bottom: 1px solid var(--stroke);
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar .brand { flex: 1; min-width: 0; }
.topbar-user {
    width: 32px; height: 32px; border-radius: 50%;
    background: #1b2744; color: var(--gold);
    display: grid; place-items: center; font-weight: 700; font-size: .72rem; flex-shrink: 0;
}
.nav-toggle {
    width: 40px; height: 40px; border: 1px solid var(--stroke); border-radius: 10px;
    background: #121a2c; display: grid; place-items: center; gap: 4px; padding: 0; cursor: pointer;
    flex-shrink: 0;
}
.nav-toggle span {
    display: block; width: 16px; height: 2px; background: var(--ink); border-radius: 2px;
    transition: transform .2s, opacity .2s;
}
.app.nav-open .nav-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.app.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
.app.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.rail-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 35;
}
.rail-backdrop[hidden] { display: none !important; }

.rail {
    background: #080d18;
    border-right: 1px solid var(--stroke);
    padding: 1.2rem 1rem;
    padding-bottom: max(1.2rem, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform .22s ease;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}
.app.nav-open .rail { transform: translateX(0); }
.rail-brand { display: flex; }
.stage {
    padding: .85rem .75rem 1.4rem;
    padding-bottom: max(1.4rem, env(safe-area-inset-bottom));
    min-width: 0;
    width: 100%;
    overflow-x: hidden;
}

.brand { display: flex; align-items: center; gap: .7rem; color: inherit; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 11px;
    background: var(--gold); color: #111;
    display: grid; place-items: center;
    font-family: var(--display); font-weight: 800; font-size: 1.35rem;
}
.brand-name { display: block; font-family: var(--display); font-weight: 800; font-size: 1.15rem; line-height: 1; }
.brand-sub { display: block; color: var(--gold); font-size: .65rem; letter-spacing: .28em; text-transform: uppercase; font-weight: 700; }
.brand.big { margin-bottom: 1rem; }
.brand.big .brand-mark { width: 48px; height: 48px; font-size: 1.7rem; }
.brand.compact .brand-mark { width: 32px; height: 32px; }

.nav { display: flex; flex-direction: column; gap: .35rem; }
.nav a {
    color: var(--muted); display: flex; align-items: center; gap: .7rem;
    padding: .7rem .8rem; border-radius: 12px; font-weight: 500;
}
.nav a span { white-space: nowrap; }
.nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav a.is-on, .nav a:hover { background: rgba(245, 196, 0, .1); color: var(--ink); }
.nav a.is-on { color: var(--gold); }

.rail-foot { margin-top: auto; display: grid; gap: .8rem; }
.who { display: flex; gap: .7rem; align-items: center; }
.who strong, .who small { display: block; }
.who small { color: var(--muted); font-size: .78rem; }
.avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: #1b2744; color: var(--gold);
    display: grid; place-items: center; font-weight: 700; font-size: .8rem;
}

.btn {
    border: 0; cursor: pointer; font: inherit; font-weight: 600;
    border-radius: 999px; padding: .7rem 1.1rem; display: inline-flex;
    align-items: center; justify-content: center; gap: .4rem; color: inherit;
}
.btn.gold { background: var(--gold); color: #111; }
.btn.gold:hover { background: var(--gold-2); }
.btn.ghost { background: transparent; border: 1px solid var(--stroke); color: var(--ink); }
.btn.full { width: 100%; }
.btn.sm { padding: .35rem .7rem; font-size: .85rem; }

.page-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 1.4rem; flex-wrap: wrap; }
.head-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1.4rem; }

.stat {
    background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
    border: 1px solid var(--stroke); border-radius: var(--radius); padding: 1.1rem 1.2rem;
}
.stat span { color: var(--muted); font-size: .85rem; }
.stat strong { display: block; font-size: 1.5rem; margin-top: .35rem; font-family: var(--display); }
.stat a { font-size: .8rem; color: var(--gold); }

.card {
    background: var(--bg-2); border: 1px solid var(--stroke);
    border-radius: var(--radius); padding: 1.2rem;
}
.split { display: grid; grid-template-columns: 1fr; gap: 1rem; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .75rem 0; border-bottom: 1px solid var(--stroke); }
.rows a { color: inherit; display: grid; gap: .15rem; }
.rows a span, .rows time { color: var(--muted); font-size: .82rem; }

.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: .15rem .55rem; font-size: .75rem; font-weight: 700; }
.pill.lg { padding: .4rem .9rem; font-size: .85rem; }
.pill.brouillon { background: #243049; color: #c9d4ea; }
.pill.envoyee { background: rgba(90, 167, 255, .15); color: var(--info); }
.pill.payee { background: rgba(61, 214, 140, .15); color: var(--ok); }
.pill.en_retard { background: rgba(255, 93, 108, .15); color: var(--bad); }
.pill.receipt { background: rgba(61, 214, 140, .15); color: var(--ok); }
.pill.no-receipt { background: rgba(245, 196, 0, .14); color: var(--gold); }

.stack { display: grid; gap: .9rem; }
label { display: grid; gap: .35rem; font-size: .88rem; color: var(--muted); }
input, select, textarea {
    font: inherit; color: var(--ink); background: #0a1020;
    border: 1px solid var(--stroke); border-radius: 12px; padding: .7rem .8rem; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(245, 196, 0, .35); border-color: var(--gold); }
.grid-3, .grid-2 { display: grid; gap: .8rem; }
.grid-3, .grid-2 { grid-template-columns: 1fr; }

.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .7rem .5rem; border-bottom: 1px solid var(--stroke); font-size: .92rem; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
table.plain td { border-bottom: 1px dashed var(--stroke); }

.totals { margin-top: 1rem; display: grid; gap: .35rem; justify-items: end; }
.totals p { display: flex; gap: 1.5rem; min-width: 240px; justify-content: space-between; color: var(--muted); margin: 0; }
.totals .grand { color: var(--ink); font-size: 1.05rem; }
.totals.paper { background: #f6f3ea; padding: 1rem; border-radius: 12px; }
.status-row { display: flex; gap: .5rem; }
.status-row select { flex: 1; }
.notes { color: var(--muted); }

.toast { border-radius: 12px; padding: .8rem 1rem; margin-bottom: 1rem; }
.toast.success { background: rgba(61, 214, 140, .12); color: var(--ok); }
.toast.error { background: rgba(255, 93, 108, .12); color: var(--bad); }

.inbox {
    display: grid;
    grid-template-columns: 1fr;
    flex: 1;
    min-height: 0;
    height: 100%;
    background: var(--bg-2);
    border: 0;
    border-top: 1px solid var(--stroke);
    border-radius: 0;
    overflow: hidden;
}
.stage:has(.inbox) {
    display: flex;
    flex-direction: column;
    padding: 0;
    height: calc(100dvh - 56px);
    max-height: calc(100dvh - 56px);
    overflow: hidden;
}
.stage:has(.inbox) > .toast { flex-shrink: 0; margin: .55rem .7rem 0; }
.inbox.has-current .threads { display: none; }
.inbox.list-only .chat { display: none; }
.chat-back { display: inline-flex; flex-shrink: 0; }
.threads {
    border-right: 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}
.threads-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .6rem;
    padding: .85rem .9rem;
    border-bottom: 1px solid var(--stroke);
    flex-shrink: 0;
}
.threads-head h1 { font-size: 1.25rem; margin: 0; }
.threads-actions { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.thread-list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; }
.thread { display: grid; gap: .2rem; padding: .85rem .9rem; color: inherit; border-bottom: 1px solid var(--stroke); }
.thread.is-on { background: rgba(245, 196, 0, .08); }
.thread-top { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.thread-top strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-top em { background: var(--gold); color: #111; border-radius: 999px; min-width: 1.2rem; text-align: center; font-style: normal; font-size: .75rem; padding: 0 .35rem; flex-shrink: 0; }
.subject { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview, .meta { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 1rem; color: var(--muted); }

.chat { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.chat-head {
    padding: .75rem .9rem;
    border-bottom: 1px solid var(--stroke);
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    align-items: flex-start;
    flex-shrink: 0;
}
.chat-head-main { display: flex; gap: .65rem; align-items: flex-start; min-width: 0; flex: 1; }
.chat-head-main > div { min-width: 0; }
.chat-head h2 { font-size: 1rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head p { margin: .15rem 0 0; color: var(--muted); font-size: .85rem; }
.chat-head-actions { display: flex; flex-direction: column; align-items: flex-end; gap: .45rem; }
.people { display: flex; gap: .35rem; flex-wrap: wrap; max-width: 100%; justify-content: flex-end; }
.chip { background: #1a243c; border-radius: 999px; padding: .2rem .55rem; font-size: .72rem; color: var(--muted); }
.danger-btn {
    border-color: rgba(255, 93, 108, .4) !important;
    color: #ff8a98 !important;
}
.danger-btn:hover {
    background: rgba(255, 93, 108, .15) !important;
    color: #fff !important;
}

.log {
    overflow: auto;
    padding: .85rem;
    display: flex;
    flex-direction: column;
    gap: .65rem;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}
.bubble {
    max-width: 92%;
    background: #182238;
    border-radius: 16px 16px 16px 4px;
    padding: .65rem .8rem;
    position: relative;
}
.bubble.mine { align-self: flex-end; background: #2a2208; border-radius: 16px 16px 4px 16px; }
.msg-who { display: block; color: var(--muted); font-size: .72rem; margin: 0; min-width: 0; word-break: break-word; }
.bubble p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.bubble-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .45rem; margin-bottom: .3rem; }
.msg-del-form { margin: 0; flex-shrink: 0; }
.msg-del {
    width: 1.45rem; height: 1.45rem; padding: 0; border: 0; border-radius: 6px;
    background: transparent; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1;
}
.msg-del:hover { color: #f87171; background: rgba(248, 113, 113, .12); }
.attach { display: inline-block; margin-top: .4rem; font-size: .85rem; word-break: break-all; }
.inv-card {
    display: grid; gap: .15rem; margin-top: .55rem; padding: .7rem;
    border: 1px solid rgba(245, 196, 0, .35); border-radius: 12px; color: inherit; background: rgba(245, 196, 0, .06);
}
.inv-card span { color: var(--gold); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; }
.empty-chat {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 1rem;
    color: var(--muted);
    height: 100%;
    padding: 1.5rem;
    text-align: center;
}

.composer {
    display: grid;
    grid-template-columns: 1fr;
    gap: .55rem;
    padding: .7rem .8rem;
    border-top: 1px solid var(--stroke);
    align-items: end;
    flex-shrink: 0;
    background: var(--bg-2);
}
.composer .btn { width: 100%; }
.composer-tools { grid-column: 1 / -1; display: flex; gap: .45rem; flex-wrap: wrap; min-width: 0; }
.composer-tools select { flex: 1; min-width: 0; max-width: 100%; }
.file-btn { position: relative; overflow: hidden; background: #1a243c; border-radius: 999px; padding: .4rem .8rem; font-size: .82rem; color: var(--ink); cursor: pointer; flex-shrink: 0; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.composer textarea { resize: none; min-width: 0; max-height: 120px; }


.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
    z-index: 20;
    -webkit-overflow-scrolling: touch;
}
.modal[hidden] { display: none; }
.modal-card {
    background: var(--bg-3);
    border: 1px solid var(--stroke);
    border-radius: 20px;
    padding: 1.3rem;
    width: min(560px, 100%);
    display: grid;
    gap: .8rem;
    align-content: start;
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    overflow-x: hidden;
    margin: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    position: sticky;
    bottom: 0;
    z-index: 1;
    margin-top: .25rem;
    padding-top: .85rem;
    background: var(--bg-3);
    border-top: 1px solid var(--stroke);
}

.auth-body {
    min-height: 100vh;
    display: grid; place-items: center;
    background: #070b14 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cpath d='M0 80L80 0' stroke='%23f5c400' stroke-opacity='.05'/%3E%3C/svg%3E");
}
.auth-panel { width: min(420px, 92vw); background: #0d1424; border: 1px solid var(--stroke); border-radius: 24px; padding: 2rem; }
.lede { color: var(--muted); }
.demo { margin-top: 1.2rem; font-size: .82rem; color: var(--muted); }
.demo ul { padding-left: 1.1rem; }

.print-body:has(.ticket-label) { padding: 1rem; }

.sheet-actions { display: flex; justify-content: space-between; align-items: center; max-width: 920px; margin: 0 auto 1rem; }
.sheet {
    max-width: 860px; margin: 0 auto; background: #fff; color: #161616;
    padding: 2.2rem; border-radius: 8px; box-shadow: 0 20px 50px rgba(0,0,0,.18);
}
.sheet a { color: #111; }
.sheet-head, .sheet-foot { display: flex; justify-content: space-between; gap: 2rem; }
.sheet-head { margin-bottom: 2rem; }
.sheet .brand-name { color: #111; }
.sheet p { color: #444; }
.sheet h1 { font-size: 2rem; }
.sheet table { margin: 1.4rem 0; }
.sheet th, .sheet td { border-bottom: 1px solid #e6e1d6; color: #222; }
.bill-to { background: #f6f3ea; padding: 1rem 1.1rem; border-radius: 12px; }
.legal { font-size: .75rem; color: #888; margin-top: 2rem; }
.sheet.missing { text-align: center; padding: 4rem 2rem; }

.calc-panels {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.4rem;
}
.calc-panels.cols-4 { margin-top: 0; }
a.calc-panel { text-decoration: none; color: inherit; display: block; }
a.calc-panel:hover { border-color: rgba(245,196,0,.45); }
.invoice-filters {
    display: grid;
    grid-template-columns: 1fr;
    gap: .8rem;
    align-items: end;
}
.envoi-search { margin-bottom: 1rem; padding: 1rem; }
.invoice-filters.envoi-search-row { grid-template-columns: minmax(0, 1fr) auto auto; }
.envoi-search-q { min-width: 0; }
.envoi-search-q input[type="search"] { width: 100%; }
.search-box {
    display: flex;
    align-items: stretch;
    gap: 0;
    min-width: min(100%, 280px);
    flex: 1 1 260px;
    max-width: 420px;
    background: var(--bg-3);
    border: 1px solid var(--stroke);
    border-radius: 999px;
    overflow: hidden;
}
.search-box input[type="search"] {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    padding: .55rem 1rem;
    color: inherit;
    font: inherit;
    outline: none;
}
.search-box button {
    border: 0;
    background: var(--gold);
    color: #1a1408;
    font-weight: 700;
    padding: .45rem .95rem;
    cursor: pointer;
}
.invoice-filters .envoi-search-q { grid-column: 1 / -1; }
.calc-panel {
    background: var(--panel);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 14px;
    padding: 1rem 1.1rem;
}
.calc-panel.is-active {
    border-color: rgba(245,196,0,.45);
    box-shadow: 0 0 0 1px rgba(245,196,0,.2);
}
.calc-panel header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem;
    margin-bottom: .25rem;
}
.calc-panel h2 { font-size: 1rem; margin: 0; font-family: var(--display); }
.calc-panel header a { font-size: .8rem; color: var(--gold); }
.calc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .65rem .8rem;
    margin: .85rem 0;
}
.calc-grid span { display: block; color: var(--muted); font-size: .78rem; }
.calc-grid strong { font-size: 1.05rem; font-family: var(--display); }
.pending-line { font-size: .85rem; color: var(--muted); margin: 0 0 .6rem; }
.pending-line strong { color: var(--text); }
.section-title { margin: 0 0 .85rem; font-size: 1.15rem; }
.filter-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-tabs a {
    padding: .45rem .9rem; border-radius: 999px; border: 1px solid var(--stroke);
    color: var(--muted); font-size: .88rem; font-weight: 600;
}
.filter-tabs a.ghost-tab { border-style: dashed; }
.filter-tabs a.is-on { background: rgba(245,196,0,.14); color: var(--gold); border-color: rgba(245,196,0,.35); }

.def-block-head {
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem;
    align-items: flex-start; margin-bottom: .4rem;
}
.def-summary { margin: 0; min-width: min(100%, 420px); }
.def-block h3 { color: var(--muted); font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.check-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: var(--ink); }
.check-row input { width: auto; }
.stats.mini { grid-template-columns: repeat(2, 1fr); margin-bottom: 1rem; }
.row-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline; }
.inline-form select { width: auto; padding: .35rem .5rem; font-size: .82rem; }
.otp-input {
    letter-spacing: .45em;
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
    font-family: var(--display);
}
.archive-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
    align-items: center;
    margin-bottom: 1rem;
    position: sticky;
    top: .6rem;
    z-index: 4;
}
.archive-toolbar [data-archive-count] { margin-right: auto; }
.col-check { width: 2.4rem; text-align: center; vertical-align: middle; }
.col-check input { width: auto; margin: 0; cursor: pointer; }

.sheet.transport {
    font-size: .9rem;
    color: #111;
    max-width: 920px;
}
.sheet.transport th,
.sheet.transport td {
    border-bottom: none;
    color: inherit;
}
.sheet.transport table { margin: .85rem 0 1rem; }
.sheet.transport .print-brand .brand-name { color: #0a1a3a; }
.sheet.transport .print-brand .brand-sub { color: #e8b923; }
.sheet.transport .brand-mark {
    background: #0a1a3a;
    color: #e8b923;
}
.ny-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    border-bottom: 2px solid #1a1a1a;
    padding-bottom: .9rem;
    margin-bottom: .9rem;
}
.ny-addr, .ny-contact {
    font-size: .72rem;
    color: #222;
    margin: .4rem 0 0;
    max-width: 360px;
    line-height: 1.35;
}
.ny-stamp {
    text-align: center;
    border: 2px solid #c9a227;
    padding: .7rem .9rem;
    min-width: 170px;
    background: #fff;
}
.ny-stamp strong {
    display: block;
    letter-spacing: .06em;
    font-size: .88rem;
    color: #111;
}
.stamp-seal {
    display: inline-block;
    margin-top: .45rem;
    border: 2px solid #c9a227;
    color: #c9a227;
    border-radius: 50%;
    width: 70px;
    height: 70px;
    line-height: 66px;
    font-weight: 800;
    font-size: .7rem;
    font-family: var(--display);
}
.ny-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: .85rem;
}
.ny-meta-left p { margin: .15rem 0; font-size: .9rem; color: #111; }
.ny-client { text-align: right; }
.ny-client h2 {
    font-size: 1.45rem;
    margin: 0;
    font-weight: 800;
    letter-spacing: .02em;
    color: #0a1a3a;
}
.ny-client p { margin: .25rem 0 0; font-size: .85rem; }

/* PDF-like ENVOIS / RETOUR grid */
.ny-grid {
    width: 100%;
    border-collapse: collapse;
    margin: .85rem 0 1rem;
    table-layout: fixed;
    font-size: .78rem;
}
.ny-grid th, .ny-grid td {
    border: 1px solid #4a5a6a;
    padding: .28rem .3rem;
    vertical-align: middle;
}
.ny-grid-top th {
    background: #c5d4e0;
    color: #111;
    font-weight: 700;
    text-align: center;
}
.ny-grid-top th.sec {
    width: 5.5%;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    letter-spacing: .12em;
    font-size: .85rem;
    background: #b7c9d8;
}
.ny-grid-top th.date-h {
    width: 16%;
    min-width: 6.2rem;
    white-space: nowrap;
}
.ny-grid-sub th {
    background: #dce6ee;
    font-size: .7rem;
    font-weight: 700;
    text-align: center;
}
.ny-grid td.sec-cell {
    background: #eef3f7;
    border-right: 1px solid #4a5a6a;
}
.ny-grid td.date {
    text-align: center;
    font-weight: 600;
    white-space: nowrap;
    font-size: .72rem;
    letter-spacing: 0;
    padding: .28rem .2rem;
    overflow: hidden;
}
.ny-grid td.num { text-align: center; }
.ny-grid td.empty { text-align: center; color: #888; }
.ny-total-row td {
    font-weight: 800;
    background: #f3f6f9;
    border-top: 2px solid #333;
}

.ny-summary {
    margin-top: .6rem;
    margin-left: auto;
    width: min(280px, 100%);
}
.ny-summary table {
    width: 100%;
    border-collapse: collapse;
}
.ny-summary td {
    border: 1px solid #555;
    padding: .35rem .55rem;
    font-size: .88rem;
    color: #111;
}
.ny-summary td:last-child {
    text-align: right;
    font-weight: 700;
    width: 40%;
}
.ny-summary tr.net td {
    background: #f5a623;
    color: #111;
    font-weight: 800;
    font-size: 1rem;
}

.ny-totals-block {
    margin-top: 1rem;
    max-width: 280px;
    margin-left: auto;
}
.ny-totals-block p {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin: .25rem 0;
    color: #222;
}
.ny-totals-block .grand {
    font-size: 1.1rem;
    font-weight: 800;
    background: #f5a623;
    padding: .35rem .5rem;
}
.ny-totals-block .words {
    font-size: .85rem;
    font-weight: 700;
    margin-top: .6rem;
    display: block;
}
.ny-tva-table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.ny-tva-table th, .ny-tva-table td { border: 1px solid #333; padding: .45rem; font-size: .85rem; }

.ny-totals-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin-top: 1rem;
}
.ny-tva-stamp {
    flex: 0 0 auto;
    text-align: center;
}
.ny-tva-stamp img {
    display: block;
    width: 170px;
    max-width: 40vw;
    height: auto;
    mix-blend-mode: multiply;
}
.ny-totals-row .ny-summary,
.ny-totals-row .ny-totals-block { margin-top: 0; }

.ny-foot {
    margin-top: 1.4rem;
    border-top: 1px solid #bbb;
    padding-top: .7rem;
    font-size: .68rem;
    color: #333;
}
.ny-foot-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: .6rem;
}
.ny-foot p { margin: .12rem 0; line-height: 1.3; }

.sheet.ticket { text-align: center; max-width: 560px; }
.sheet.ticket .ticket-code { font-size: 1.6rem; font-weight: 800; letter-spacing: .12em; margin: .4rem 0 1rem; }
.barcode-wrap { margin: 1.2rem 0; display: grid; gap: .55rem; justify-items: center; }
.barcode-wrap .ticket-qr,
.barcode-wrap #qrcode {
    width: 260px;
    height: 260px;
    background: #fff;
    border-radius: 12px;
    padding: 8px;
    box-sizing: content-box;
}
.scan-hint { font-size: .9rem; color: #666; margin: 0; }
.scan-url { font-size: .8rem; word-break: break-all; color: #222; font-weight: 600; margin: 0; max-width: 100%; }
.scan-url a { color: inherit; text-decoration: underline; }

/* Ticket étiquette 16,2 × 16,2 cm — plein format, sans marge papier */
.ticket-print-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
}
.ticket-toolbar { max-width: 16.2cm; gap: .8rem; flex-wrap: wrap; margin-left: auto; margin-right: auto; }
.ticket-size-pick { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; color: var(--muted); font-size: .9rem; }
.ticket-size-pick strong { color: var(--text, #eee); }

.sheet.ticket-label {
    width: 16.2cm;
    height: auto;
    min-height: 0;
    max-width: 16.2cm;
    margin: 0 auto;
    padding: 2.5mm;
    box-sizing: border-box;
    background: #fff;
    color: #000;
    font-family: "Outfit", "Segoe UI", system-ui, sans-serif;
    display: flex;
    flex-direction: column;
    gap: 1.2mm;
    overflow: hidden;
    box-shadow: 0 6px 24px rgba(0,0,0,.2);
    border-radius: 2px;
    flex-shrink: 0;
}
.sheet.ticket-label .tl-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2mm;
    border-bottom: 1.5px solid #000;
    padding-bottom: 1mm;
}
.sheet.ticket-label .tl-price {
    margin: 0;
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1;
    font-family: "Syne", "Outfit", sans-serif;
}
.sheet.ticket-label .tl-price-col {
    display: flex;
    flex-direction: column;
    gap: 0.8mm;
    align-items: flex-start;
}
.sheet.ticket-label .tl-pay-cash {
    margin: 0;
    display: inline-block;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #000;
    border: 1.5px solid #000;
    padding: 0.6mm 1.8mm;
    line-height: 1.1;
    background: #fff;
}
.sheet.ticket-label .tl-pay-cash-line {
    margin: 1mm 0 0 !important;
    font-size: 1.05rem !important;
    font-weight: 800 !important;
    color: #000 !important;
}
.sheet.ticket-label .tl-brand-row {
    display: flex;
    align-items: center;
    gap: 1.5mm;
    text-align: right;
}
.sheet.ticket-label .tl-brand-mark {
    width: 7mm;
    height: 7mm;
    display: inline-grid;
    place-items: center;
    background: #111;
    color: #f5c400;
    border-radius: 4px;
    font-weight: 800;
    font-size: .72rem;
}
.sheet.ticket-label .tl-brand-text {
    font-size: .82rem;
    font-weight: 700;
    line-height: 1.1;
}
.sheet.ticket-label .tl-brand-text em {
    font-style: normal;
    font-weight: 500;
    color: #444;
    font-size: .72rem;
}
.sheet.ticket-label .tl-piece {
    font-size: .7rem;
    font-weight: 700;
    border: 1px solid #000;
    padding: .5mm 1.5mm;
    border-radius: 3px;
}
.sheet.ticket-label .tl-block {
    min-height: 0;
    overflow: visible;
    padding-bottom: 0.5mm;
    flex-shrink: 0;
}
.sheet.ticket-label .tl-block h3 {
    margin: 0 0 1.2mm;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #000;
}
.sheet.ticket-label .tl-block p {
    margin: 0 0 1mm;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.22;
    color: #000;
}
.sheet.ticket-label .tl-block p.tl-strong {
    font-size: 1.42rem;
    font-weight: 800;
    line-height: 1.18;
    letter-spacing: -.01em;
}
.sheet.ticket-label .tl-colis {
    display: block;
    margin: 1mm 0 !important;
    padding: 1mm 1.5mm;
    font-size: 1.15rem !important;
    font-weight: 800 !important;
    border: 1.5px solid #000;
    background: #fff;
    color: #000;
    line-height: 1.2;
}
.sheet.ticket-label .tl-wrap {
    word-break: break-word;
}
.sheet.ticket-label .tl-code-row {
    border-top: 1px dashed #000;
    border-bottom: 1px dashed #000;
    padding: 1mm 0;
    text-align: center;
}
.sheet.ticket-label .tl-code {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: .08em;
    font-family: "Syne", "Outfit", sans-serif;
}
.sheet.ticket-label .ticket-barcode {
    display: block;
    width: 100%;
    height: auto;
    max-height: 11mm;
}
.sheet.ticket-label .barcode-wrap {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    flex-shrink: 0;
    overflow: hidden;
    text-align: center;
}
.sheet.ticket-label .tl-qr-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    margin: 0;
    padding: 0;
    width: 100%;
}
.sheet.ticket-label .barcode-wrap .ticket-qr {
    width: 5.5cm;
    height: 5.5cm;
    max-width: 100%;
    padding: 0;
    border-radius: 0;
    background: #fff;
    image-rendering: pixelated;
    flex-shrink: 0;
    display: block;
    margin: 0;
}
.sheet.ticket-label .tl-url {
    margin: 0.8mm 0 0;
    padding: 0;
    font-size: .82rem;
    font-weight: 800;
    line-height: 1.15;
    color: #000;
    word-break: break-all;
    max-width: 15.5cm;
}
.sheet.ticket-label .tl-date {
    margin: 1mm 0 0;
    font-size: .82rem;
    font-weight: 700;
    color: #000;
}
.sheet.ticket-label .tl-foot {
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 1px solid #000;
    padding-top: 0.8mm;
    margin-top: 0.5mm;
    font-size: .78rem;
    font-weight: 800;
    line-height: 1.1;
    color: #000;
    flex-shrink: 0;
    text-align: center;
}
.sheet.ticket-label .tl-foot span {
    word-break: break-word;
}

/* legacy ticket classes (autres vues) */
.sheet.ticket-a4,
.sheet.ticket-square {
    width: 16.2cm;
    height: 16.2cm;
    max-width: 16.2cm;
    max-height: 16.2cm;
}

.trajet-livreurs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem; margin-top: .6rem; }
.trajet-block { background: #0a1020; border: 1px solid var(--stroke); border-radius: 12px; padding: .7rem .8rem; }
.trajet-block ul { margin: .4rem 0 0; padding-left: 1rem; color: var(--muted); font-size: .85rem; }
.modal-card.wide { width: min(640px, 100%); }
.route-line { font-size: .85rem; color: var(--gold-2); word-break: break-word; }
.route-builder { display: grid; gap: .6rem; }
.route-stops { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.route-stops li { display: grid; grid-template-columns: 28px 1fr auto; gap: .5rem; align-items: center; }
.route-stops .pos {
    width: 28px; height: 28px; border-radius: 50%; background: rgba(245,196,0,.15); color: var(--gold);
    display: grid; place-items: center; font-size: .8rem; font-weight: 700;
}

.days-check-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem .55rem;
    margin: .25rem 0 .35rem;
}
.day-check {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    margin: 0;
    font-size: .85rem;
    cursor: pointer;
    padding: .25rem .45rem;
    border: 1px solid var(--stroke);
    border-radius: 8px;
    background: #0a1020;
}
.day-check input { width: auto; margin: 0; }

.bulk-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
}

@media (max-width: 720px) {
    .modal {
        padding: .5rem;
        padding-bottom: max(.5rem, env(safe-area-inset-bottom));
        align-items: flex-start;
    }
    .modal-card,
    .modal-card.wide {
        width: 100%;
        max-width: 100%;
        margin: 0 auto .5rem;
        max-height: calc(100dvh - 1rem);
        border-radius: 16px;
        padding: 1rem .9rem;
    }
    .modal-actions { flex-wrap: wrap; }
    .modal-actions .btn {
        flex: 1 1 auto;
        min-width: 7rem;
        justify-content: center;
    }

    input, select, textarea {
        font-size: 16px;
        max-width: 100%;
    }

    .page-head {
        flex-direction: column;
        align-items: stretch;
        gap: .75rem;
        margin-bottom: 1rem;
    }
    .page-head > div { min-width: 0; }
    .page-head .head-actions,
    .page-head > .btn { width: 100%; }
    .page-head .head-actions {
        display: flex;
        flex-wrap: wrap;
        gap: .45rem;
    }
    .page-head .head-actions .btn,
    .page-head > .btn {
        flex: 1 1 auto;
        justify-content: center;
        text-align: center;
    }
    .page-head .search-box {
        flex: 1 1 100%;
        max-width: none;
        width: 100%;
    }

    .card { padding: .9rem .85rem; }
    .stage { padding-left: .65rem; padding-right: .65rem; }

    .table-wrap {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }
    .table-wrap.card { padding: .35rem 0; }
    .table-wrap table {
        min-width: 560px;
        font-size: .86rem;
    }
    .table-wrap th,
    .table-wrap td {
        padding: .55rem .45rem;
        white-space: nowrap;
    }
    .table-wrap td .muted,
    .table-wrap .route-line {
        white-space: normal;
        word-break: break-word;
        max-width: 11rem;
        display: inline-block;
        vertical-align: top;
    }

    .filter-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: .35rem;
        padding-bottom: .35rem;
        scrollbar-width: none;
    }
    .filter-tabs::-webkit-scrollbar { display: none; }
    .filter-tabs a {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: .4rem .75rem;
        font-size: .82rem;
    }

    .invoice-filters { grid-template-columns: 1fr 1fr; }
    .invoice-filters .btn {
        grid-column: 1 / -1;
        width: 100%;
    }
    .invoice-filters.envoi-search-row { grid-template-columns: 1fr; }
    .invoice-filters.envoi-search-row .btn { grid-column: auto; }

    .calc-grid { grid-template-columns: 1fr; }
    .row-actions { width: 100%; }
    .row-actions .btn { flex: 1 1 auto; justify-content: center; }

    .prices-form {
        flex-direction: column;
        align-items: stretch !important;
    }
    .price-inline input {
        width: 100% !important;
        max-width: none;
        box-sizing: border-box;
    }

    .days-check-grid { gap: .3rem; }
    .day-check {
        flex: 1 1 calc(33.33% - .3rem);
        justify-content: center;
        min-width: 3.6rem;
    }

    .totals { justify-items: stretch; }
    .totals p { min-width: 0; width: 100%; }

    .status-row { flex-wrap: wrap; }
    .status-row select,
    .status-row .btn { width: 100%; }

    .archive-toolbar { align-items: stretch; }
    .archive-toolbar .btn,
    .archive-toolbar select,
    .archive-toolbar input { width: 100%; }

    .check-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .def-summary { min-width: 0; width: 100%; }
    .ship-livreur-box { padding: .65rem .75rem; }
    .route-line { word-break: break-word; }
    .trajet-livreurs { grid-template-columns: 1fr; }

    .bulk-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .bulk-status-label {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }
    .bulk-status-label select {
        min-width: 0;
        width: 100%;
    }
    .bulk-bar .btn { width: 100%; }

    .sheet-actions {
        flex-direction: column;
        align-items: stretch;
        gap: .5rem;
        max-width: 100%;
    }
    .sheet-actions .btn { width: 100%; }
    .sheet {
        padding: 1.1rem .9rem;
        margin: 0 .35rem;
        max-width: calc(100% - .7rem);
    }
    .sheet h1 { font-size: 1.35rem; }
    .sheet-head, .sheet-foot {
        flex-direction: column;
        gap: .75rem;
    }
    .sheet.ticket { max-width: 100%; }
    .scan-actions,
    .scan-type-row {
        display: flex;
        flex-direction: column;
        gap: .5rem;
    }
    .scan-actions .btn,
    .scan-type-row .btn,
    .scan-type-row label {
        width: 100%;
    }
}

@media print {
    .no-print { display: none !important; }
    .print-body { background: #fff; padding: 0; margin: 0; }
    .print-body:has(.ticket-label) { padding: 0 !important; }

    .sheet { box-shadow: none; max-width: none; }
    .sheet.transport { max-width: none; }
    .ny-foot-grid { grid-template-columns: 1fr 1.4fr 1.2fr; }
    .ny-grid { font-size: .74rem; }
    .ny-grid-top th.date-h { width: 17%; }
    .ny-grid td.date {
        font-size: .7rem;
        padding: .22rem .15rem;
    }

    .sheet.ticket-label {
        box-shadow: none;
        border-radius: 0;
        width: 200mm !important;
        height: auto !important;
        min-height: 200mm !important;
        max-width: 200mm !important;
        max-height: none !important;
        padding: 5mm !important;
        overflow: visible !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .sheet.ticket-label .tl-block {
        overflow: visible !important;
        flex-shrink: 0 !important;
    }
    .sheet.ticket-label .tl-colis {
        display: block !important;
        visibility: visible !important;
        font-size: 16pt !important;
        font-weight: 800 !important;
        border: 1.5px solid #000 !important;
        padding: 1.5mm 2mm !important;
        margin: 1.5mm 0 !important;
        background: #fff !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .sheet.ticket-label .tl-brand-mark {
        background: #000 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .sheet.ticket-label .tl-qr-stack { gap: 1mm !important; }
    .sheet.ticket-label .tl-url {
        font-size: 10pt !important;
        font-weight: 800 !important;
        margin-top: 1mm !important;
    }
    .sheet.ticket-label .barcode-wrap .ticket-qr {
        width: 5.5cm !important;
        height: 5.5cm !important;
    }
}

.mobile-nav { display: none; }

/* —— Tablette / desktop —— */
@media (min-width: 720px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .stats.mini { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .split { grid-template-columns: 1fr 1fr; }
    .calc-panels { grid-template-columns: 1fr 1fr; }
    .invoice-filters { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1024px) {
    .topbar { display: none; }
    .rail-backdrop { display: none !important; }

    .app {
        grid-template-columns: 260px minmax(0, 1fr);
        grid-template-rows: 1fr;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }
    .rail {
        position: sticky;
        top: 0;
        left: auto;
        bottom: auto;
        width: auto;
        height: 100vh;
        height: 100dvh;
        transform: none;
        z-index: 1;
        overflow: auto;
    }
    .app.nav-open .rail { transform: none; }
    .stage {
        padding: 1.5rem 1.8rem 2.5rem;
        overflow: auto;
    }

    .stats { grid-template-columns: repeat(5, 1fr); }
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .calc-panels { grid-template-columns: repeat(3, 1fr); }
    .calc-panels.cols-4 { grid-template-columns: repeat(4, 1fr); }
    .invoice-filters { grid-template-columns: repeat(5, 1fr); }
    .invoice-filters.envoi-search-row { grid-template-columns: minmax(0, 1fr) auto auto; }

    .inbox {
        grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
        border-radius: 20px;
        border: 1px solid var(--stroke);
        border-top: 1px solid var(--stroke);
    }
    .inbox.has-current .threads { display: flex; }
    .inbox.list-only .chat { display: grid; }
    .inbox.has-current .chat { display: grid; }
    .inbox.list-only .threads { display: flex; }
    .threads { border-right: 1px solid var(--stroke); display: flex; }
    .chat-back { display: none !important; }
    .stage:has(.inbox) {
        padding: .85rem 1rem 1rem;
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
    }
    .stage:has(.inbox) > .toast { margin: 0 0 .65rem; }
    .bubble { max-width: min(78%, 520px); }
    .composer {
        grid-template-columns: minmax(0, 1fr) auto;
    }
    .composer .btn { width: auto; }
    .ny-foot-grid { grid-template-columns: 1fr 1.4fr 1.2fr; }
    .head-actions { width: auto; }
}

@media (max-width: 480px) {
    h1 { font-size: 1.28rem; }
    h2 { font-size: 1rem; }
    .brand-sub { letter-spacing: .18em; font-size: .58rem; }
    .threads-head { flex-direction: column; align-items: stretch; }
    .threads-actions { justify-content: stretch; }
    .threads-actions .btn { flex: 1; text-align: center; justify-content: center; }
    .people { display: none; }

    .stats.mini { grid-template-columns: 1fr 1fr; gap: .65rem; }
    .stat { padding: .85rem .9rem; }
    .stat strong { font-size: 1.25rem; }

    .invoice-filters { grid-template-columns: 1fr; }

    .table-wrap table { min-width: 520px; }
    .table-wrap th,
    .table-wrap td { font-size: .8rem; padding: .45rem .35rem; }

    .filter-tabs a { font-size: .78rem; padding: .35rem .65rem; }

    .day-check { flex: 1 1 calc(50% - .3rem); }

    .pill.lg { font-size: .78rem; padding: .3rem .65rem; }

    .page-head .muted,
    .card > .muted {
        font-size: .82rem;
        line-height: 1.45;
    }

    .inline-form select { max-width: 100%; }
}
