/* ==========================================================================
   SmartLabo — design system
   ========================================================================== */
:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-d: #1d4ed8;
    --accent: #0d9488;
    --danger: #dc2626;
    --warn: #d97706;
    --ok: #16a34a;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .05);
    --header-h: 60px;
}

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

html, body { height: 100%; }
body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid rgba(37, 99, 235, .35); outline-offset: 1px; }

/* ---------- Header ---------- */
.app-header {
    height: var(--header-h);
    display: flex; align-items: center; gap: 24px;
    padding: 0 24px;
    background: linear-gradient(110deg, #0f172a 0%, #1e3a8a 100%);
    color: #fff;
    position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; letter-spacing: .2px; }
.brand-logo { font-size: 1.5rem; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
    color: #cbd5e1; text-decoration: none; padding: 8px 14px; border-radius: 8px;
    font-weight: 500; font-size: .92rem; transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.nav a.active { background: rgba(255, 255, 255, .16); color: #fff; }
.header-right { display: flex; align-items: center; gap: 14px; }
.user-chip { font-size: .85rem; color: #cbd5e1; }
.live {
    display: flex; align-items: center; gap: 7px; font-size: .78rem; font-weight: 600;
    padding: 5px 10px; border-radius: 999px; background: rgba(255, 255, 255, .1); color: #e2e8f0;
}
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.live[data-state="online"] .dot { background: #22c55e; box-shadow: 0 0 0 0 rgba(34, 197, 94, .7); animation: ping 2s infinite; }
.live[data-state="connecting"] .dot { background: #f59e0b; animation: blink 1s infinite; }
.live[data-state="offline"] .dot { background: #ef4444; }
@keyframes ping { 70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }
@keyframes blink { 50% { opacity: .3; } }

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; border-radius: 9px; border: 1px solid var(--border);
    background: var(--surface); font-weight: 600; font-size: .92rem;
    transition: transform .08s, background .15s, box-shadow .15s, opacity .15s;
}
.btn:hover { background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost-light { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .2); color: #fff; padding: 7px 12px; }
.btn-ghost-light:hover { background: rgba(255, 255, 255, .2); }
.btn-lg { padding: 14px 20px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn.is-loading::after {
    content: ""; width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formulaires ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: .82rem; font-weight: 600; color: #334155; }
.field label .req { color: var(--danger); }
.input, .field input[type="text"], .field input[type="password"], .field input[type="date"], .field select, .field textarea {
    width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 9px;
    background: #fff; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.field textarea { resize: vertical; min-height: 70px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: .92rem; }
.check input { width: 18px; height: 18px; accent-color: var(--danger); }
.check-urgent { padding: 12px 14px; border: 1px dashed #fca5a5; background: #fef2f2; border-radius: 9px; color: #991b1b; margin-bottom: 18px; }

/* ---------- Pastilles / badges ---------- */
.status-badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700;
    color: var(--c, var(--primary)); background: color-mix(in srgb, var(--c, var(--primary)) 14%, white);
    white-space: nowrap;
}
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .7rem; font-weight: 700; }
.pill-urgent { background: #fee2e2; color: #b91c1c; animation: pulse 1.8s infinite; }
.pill-late { background: #ffedd5; color: #c2410c; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(220, 38, 38, .15); } }
.tag { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 6px; background: #f1f5f9; color: #475569; font-weight: 600; }
.tag-teinte { background: #fef9c3; color: #854d0e; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 36px)); }
.toast {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 10px;
    background: #0f172a; color: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
    border-left: 4px solid #64748b; animation: toast-in .25s ease-out; font-size: .9rem;
}
.toast-success { border-left-color: #22c55e; }
.toast-error { border-left-color: #ef4444; }
.toast-warning { border-left-color: #f59e0b; }
.toast.leaving { animation: toast-out .25s ease-in forwards; }
.toast-msg { flex: 1; }
.toast-x { background: none; border: none; color: #94a3b8; font-size: 1.2rem; line-height: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateX(30px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }

/* ---------- Bandeau d'erreur / états vides ---------- */
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; margin: 12px 24px 0; border-radius: 10px; font-weight: 500; }
.banner-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; font-size: .9rem; }

/* ==========================================================================
   Tableau de bord Admin (Kanban)
   ========================================================================== */
.toolbar {
    display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; justify-content: space-between;
    padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; padding: 6px 14px; border-radius: 10px; background: #f8fafc; border: 1px solid var(--border); min-width: 96px; }
.stat b { font-size: 1.3rem; line-height: 1.1; }
.stat span { font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.stat.warn b { color: var(--danger); }
.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.filters .search { width: 260px; }
.filters .check { font-weight: 500; font-size: .85rem; color: #334155; }
.filters .check input { accent-color: var(--primary); }

.kanban {
    display: flex; gap: 14px; padding: 18px 24px 24px; overflow-x: auto; align-items: flex-start;
    height: calc(100vh - var(--header-h) - 92px); min-height: 420px;
}
.column {
    flex: 0 0 272px; max-height: 100%; display: flex; flex-direction: column;
    background: #e8eef5; border-radius: var(--radius); border-top: 4px solid var(--c);
    transition: background .15s, box-shadow .15s;
}
.column.drop-target { background: color-mix(in srgb, var(--c) 18%, #e8eef5); box-shadow: 0 0 0 2px var(--c) inset; }
.column-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; }
.column-title { font-weight: 700; font-size: .92rem; display: flex; align-items: center; gap: 8px; }
.column-count { background: var(--c); color: #fff; border-radius: 999px; min-width: 24px; text-align: center; padding: 1px 8px; font-size: .78rem; font-weight: 700; }
.cards { padding: 4px 10px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; flex: 1; min-height: 80px; }
.cards-empty { color: #94a3b8; font-size: .82rem; text-align: center; padding: 18px 6px; border: 2px dashed #cbd5e1; border-radius: 10px; }
.cards-more { color: var(--muted); font-size: .78rem; text-align: center; padding: 4px; }

.card {
    background: var(--surface); border-radius: 10px; padding: 11px 12px; cursor: pointer;
    border: 1px solid var(--border); border-left: 4px solid var(--c);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06); transition: transform .15s, box-shadow .15s, opacity .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(15, 23, 42, .12); }
.card[draggable="true"] { cursor: grab; }
.card.dragging { opacity: .4; transform: rotate(2deg); cursor: grabbing; }
.card.is-urgent { background: linear-gradient(180deg, #fff 60%, #fff5f5); border-color: #fecaca; border-left-color: var(--danger); }
.card.is-late .card-due { color: var(--danger); font-weight: 700; }
.card.flash { animation: flash 2.2s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--primary), 0 6px 18px rgba(37, 99, 235, .4); transform: scale(1.03); } 100% { box-shadow: 0 1px 2px rgba(15, 23, 42, .06); transform: none; } }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.card-code { font-size: .95rem; letter-spacing: .3px; }
.card-patient { font-weight: 600; }
.card-meta { font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; }
.card-due { font-size: .78rem; color: #475569; }
.skeleton { height: 92px; border-radius: 10px; background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ==========================================================================
   Modal de détails
   ========================================================================== */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center;
    padding: 16px; background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal-content {
    position: relative; width: 90%; max-width: 600px; max-height: 92vh; overflow-y: auto;
    margin: 0 auto; padding: 25px; border-radius: 12px; background: var(--surface);
    box-shadow: 0 4px 20px rgba(0, 0, 0, .15); animation: pop .2s ease-out;
}
@keyframes pop { from { transform: translateY(14px) scale(.97); opacity: 0; } }
.pm-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.pm-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.pm-code { font-size: 1.45rem; font-weight: 800; letter-spacing: .5px; }
.pm-close { background: #f1f5f9; border: none; width: 32px; height: 32px; border-radius: 50%; font-size: 1.2rem; color: var(--muted); flex-shrink: 0; }
.pm-close:hover { background: #e2e8f0; color: var(--text); }
.pm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.pm-info { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; font-size: .88rem; align-content: start; }
.pm-info dt { color: var(--muted); font-weight: 600; }
.pm-info dd { font-weight: 600; word-break: break-word; }
.pm-info .late { color: var(--danger); }
.pm-qr { margin-top: 16px; text-align: center; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #f8fafc; }
.pm-qr img { width: 130px; height: 130px; display: block; margin: 0 auto 10px; image-rendering: pixelated; background: #fff; border-radius: 6px; }
.pm-section-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 12px; }
.pm-notes { margin-top: 14px; padding: 10px 12px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 9px; font-size: .85rem; color: #78350f; }
.pm-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.pm-actions .btn-primary { flex: 1; }

/* Timeline verticale compacte */
.tl { list-style: none; }
.tl li { position: relative; padding: 0 0 11px 30px; font-size: .84rem; font-weight: 600; color: #94a3b8; }
.tl li::before { content: ""; position: absolute; left: 8px; top: 18px; bottom: -3px; width: 2px; background: var(--border); }
.tl li:last-child { padding-bottom: 0; }
.tl li:last-child::before { display: none; }
.tl .tl-dot {
    position: absolute; left: 0; top: 1px; width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid var(--border); background: #fff; display: grid; place-items: center; font-size: 10px; color: #fff;
}
.tl li.past { color: var(--text); }
.tl li.past::before { background: var(--c); }
.tl li.past .tl-dot { background: var(--c); border-color: var(--c); }
.tl li.current { color: var(--text); font-weight: 800; }
.tl li.current .tl-dot { border-color: var(--c); background: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 25%, transparent); }
.tl li.current .tl-dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.tl .tl-time { display: block; font-size: .72rem; font-weight: 500; color: var(--muted); }

/* ==========================================================================
   Réception
   ========================================================================== */
.page { max-width: 1180px; margin: 0 auto; padding: 24px; }
.tabs { display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 2px solid var(--border); }
.tab-btn { background: none; border: none; padding: 12px 20px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn .count { background: #e2e8f0; border-radius: 999px; padding: 1px 8px; font-size: .75rem; margin-left: 6px; color: #334155; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .2s; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.panel h2 { font-size: 1.1rem; margin-bottom: 18px; }
.reception-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 22px; align-items: start; }

.ticket-placeholder { text-align: center; color: var(--muted); padding: 50px 10px; }
.ticket-placeholder .big { font-size: 3rem; display: block; margin-bottom: 8px; filter: grayscale(.4); }
.ticket-ok { text-align: center; color: var(--ok); font-weight: 700; margin-bottom: 8px; }
.ticket-code { text-align: center; font-size: 2.3rem; font-weight: 800; letter-spacing: 1px; color: var(--primary); }
.ticket-qr { display: block; width: 190px; height: 190px; margin: 12px auto; image-rendering: pixelated; border: 1px solid var(--border); border-radius: 10px; padding: 6px; background: #fff; }
.ticket-info { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .9rem; margin: 14px 0 18px; padding: 14px; background: #f8fafc; border-radius: 10px; }
.ticket-info dt { color: var(--muted); font-weight: 600; }
.ticket-info dd { font-weight: 600; }
.ticket-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.ticket-actions .btn-primary { flex: 1; }
.new-flash { animation: flash 1.6s ease-out; }

.table-tools { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.table-tools .search { flex: 1; min-width: 220px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; padding: 11px 14px; background: #f8fafc; color: #475569; font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr { cursor: pointer; transition: background .12s; }
table.data tbody tr:hover { background: #f8fafc; }
table.data tbody tr.is-urgent td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
table.data tbody tr.flash { animation: rowflash 2s ease-out; }
@keyframes rowflash { 0% { background: #dbeafe; } 100% { background: transparent; } }
.cell-late { color: var(--danger); font-weight: 700; }

/* ==========================================================================
   Scanner
   ========================================================================== */
.scanner-page { max-width: 640px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.scan-box { background: #0f172a; border-radius: var(--radius); overflow: hidden; min-height: 280px; position: relative; display: grid; place-items: center; }
#reader { width: 100%; }
#reader video { border-radius: 0; }
.scan-idle { color: #94a3b8; text-align: center; padding: 50px 20px; }
.scan-idle .big { font-size: 3rem; display: block; margin-bottom: 8px; }
.scan-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.scan-controls .check { margin-left: auto; font-weight: 500; font-size: .85rem; }
.scan-controls .check input { accent-color: var(--primary); }
.manual { display: flex; gap: 10px; }
.manual input { flex: 1; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.scan-result { border-left: 5px solid var(--c, var(--primary)); animation: pop .2s ease-out; }
.scan-result.success { border-left-color: var(--ok); background: #f0fdf4; }
.scan-result .code { font-size: 1.8rem; font-weight: 800; }
.scan-result .flow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 16px; }
.scan-result .arrow { color: var(--muted); font-size: 1.2rem; }
.scan-log { list-style: none; font-size: .85rem; }
.scan-log li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.scan-log li:last-child { border-bottom: none; }
.scan-log time { color: var(--muted); }

/* ==========================================================================
   Login
   ========================================================================== */
.login-page {
    min-height: 100vh; display: grid; place-items: center; padding: 20px;
    background: radial-gradient(circle at 20% 15%, #1d4ed8 0, transparent 45%),
                radial-gradient(circle at 85% 85%, #0d9488 0, transparent 40%), #0f172a;
}
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 36px 32px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); animation: pop .35s ease-out; }
.login-card.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.login-logo { text-align: center; margin-bottom: 26px; }
.login-logo .emoji { font-size: 2.8rem; display: block; }
.login-logo h1 { font-size: 1.6rem; margin-top: 4px; }
.login-logo p { color: var(--muted); font-size: .9rem; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px !important; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: none; padding: 6px 8px; font-size: 1.05rem; }
.form-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; padding: 10px 12px; border-radius: 9px; font-size: .88rem; margin-bottom: 14px; }

/* ==========================================================================
   Facturation (Admin)
   ========================================================================== */
.btn-billing {
    background: linear-gradient(135deg, #f59e0b, #d97706); border-color: #b45309; color: #fff;
    padding: 8px 14px; box-shadow: 0 2px 12px rgba(245, 158, 11, .5);
}
.btn-billing:hover { background: linear-gradient(135deg, #fbbf24, #d97706); }
.badge-count {
    display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 2px;
    border-radius: 999px; background: #fff; color: #b45309; font-size: .75rem; font-weight: 800;
}
.stat-bill b { color: #b45309; }
.tag-prix { background: #ecfdf5; color: #047857; }
.tag-billed { background: #dcfce7; color: #166534; }

/* Champ prix dans le modal de détails */
.pm-price { margin-top: 14px; padding: 12px; border: 1px solid #bbf7d0; background: #f0fdf4; border-radius: 10px; }
.pm-price label { display: block; font-size: .8rem; font-weight: 700; color: #166534; margin-bottom: 6px; }
.price-row { display: flex; gap: 8px; }
.price-row input {
    flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid #86efac; border-radius: 9px;
    background: #fff; font-weight: 700;
}
.price-row input:focus { outline: none; border-color: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); }
.price-row input:disabled { background: #f1f5f9; color: var(--muted); }
.price-row input.saved { animation: saved 1.4s ease-out; }
@keyframes saved { 0% { background: #bbf7d0; box-shadow: 0 0 0 4px rgba(22, 163, 74, .35); } 100% { background: #fff; box-shadow: none; } }
.price-note { display: block; margin-top: 6px; font-size: .76rem; color: var(--muted); }
.price-note.ok { color: #166534; font-weight: 600; }

/* Grand modal de facturation */
.modal-content.modal-xl { max-width: 1000px; width: 94%; }
.bill-sub { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.bill-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.bill-summary > div { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; display: flex; flex-direction: column; }
.bill-summary b { font-size: 1.35rem; line-height: 1.2; }
.bill-summary span { font-size: .74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.bill-row {
    display: grid; grid-template-columns: auto 1fr auto auto; gap: 16px; align-items: center;
    padding: 14px 16px; margin-bottom: 10px; background: #fff; border: 1px solid var(--border);
    border-radius: 10px; transition: box-shadow .15s, border-color .15s;
}
.bill-row:hover { border-color: #93c5fd; box-shadow: 0 4px 14px rgba(37, 99, 235, .1); }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, #2563eb, #0d9488); color: #fff; display: grid; place-items: center; font-weight: 800; }
.bill-name { font-weight: 700; font-size: 1.02rem; }
.bill-meta { font-size: .82rem; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.bill-amount { text-align: right; display: flex; flex-direction: column; }
.bill-amount b { font-size: 1.15rem; color: #047857; }
.bill-amount span { font-size: .72rem; color: var(--muted); }
.bill-empty { padding: 40px 10px; }
.bill-bar {
    position: sticky; top: -25px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    margin: -25px -25px 14px; padding: 14px 25px; background: #fff; border-bottom: 1px solid var(--border); border-radius: 12px 12px 0 0;
}
.bill-bar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inv-done { color: var(--ok); font-weight: 700; padding: 0 6px; }

/* ---------- Facture (aperçu écran ET impression) ---------- */
.invoice-sheet { background: #cbd5e1; padding: 20px; border-radius: 10px; overflow-x: auto; }
.invoice {
    background: #fff; color: #0f172a; width: 100%; max-width: 794px; min-height: 560px; margin: 0 auto;
    padding: 40px 46px; box-shadow: 0 4px 18px rgba(15, 23, 42, .25);
    font-size: 13px; line-height: 1.5; font-family: "Inter", -apple-system, "Segoe UI", Arial, sans-serif;
}
.invoice .c { text-align: center; }
.invoice .r { text-align: right; }
.invoice .mono { font-weight: 700; letter-spacing: .3px; white-space: nowrap; }
.inv-muted { color: #64748b; }
.inv-warn { color: #dc2626; font-weight: 700; font-size: 11px; }
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding-bottom: 18px; border-bottom: 3px solid #1e3a8a; }
.inv-brand { display: flex; align-items: center; gap: 12px; }
.inv-logo { width: 54px; height: 54px; border-radius: 12px; background: #1e3a8a; color: #fff; display: grid; place-items: center; font-size: 28px; }
.inv-lab-name { font-size: 24px; font-weight: 800; color: #1e3a8a; line-height: 1.1; }
.inv-title { text-align: right; }
.inv-title h1 { font-size: 30px; letter-spacing: 4px; color: #1e3a8a; line-height: 1.1; margin-bottom: 4px; }
.inv-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 22px 0; }
.inv-box { border: 1px solid #cbd5e1; border-radius: 8px; padding: 12px 14px; }
.inv-box h4 { font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: #64748b; margin-bottom: 5px; }
.inv-box-client { background: #eff6ff; border-color: #bfdbfe; }
.inv-client { font-size: 17px; font-weight: 800; color: #1e3a8a; }
.inv-table { width: 100%; border-collapse: collapse; }
.inv-table th { background: #1e3a8a; color: #fff; padding: 9px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; text-align: left; }
.inv-table th.c { text-align: center; }
.inv-table th.r { text-align: right; }
.inv-table td { padding: 8px 10px; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
.inv-table tbody tr:nth-child(even) td { background: #f8fafc; }
.inv-total { width: 320px; margin: 18px 0 0 auto; border: 2px solid #1e3a8a; border-radius: 8px; overflow: hidden; }
.inv-total-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; }
.inv-grand { background: #1e3a8a; color: #fff; font-size: 15px; }
.inv-grand b { font-size: 17px; }
.inv-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-top: 34px; }
.inv-thanks { font-weight: 700; color: #1e3a8a; margin-top: 4px; }
.inv-sign { width: 200px; height: 80px; border: 1px dashed #94a3b8; border-radius: 8px; padding: 6px 10px; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #64748b; text-align: center; }
.inv-legal { margin-top: 24px; padding-top: 10px; border-top: 1px solid #e2e8f0; text-align: center; font-size: 10px; color: #64748b; }

@media (max-width: 760px) {
    .bill-row { grid-template-columns: auto 1fr; }
    .bill-amount { text-align: left; }
    .bill-row .btn { grid-column: 1 / -1; }
    .bill-summary { grid-template-columns: 1fr; }
    .invoice { padding: 24px 20px; min-width: 620px; }
}

/* ==========================================================================
   Zones imprimables (invisibles à l'écran) : étiquette et facture
   ========================================================================== */
#print-ticket, #print-invoice { display: none; }

@media print {
    @page { margin: 6mm; }
    html, body { background: #fff !important; height: auto; }
    /* Tout est masqué SAUF la zone imprimable (étiquette OU facture) */
    body > *:not(#print-ticket):not(#print-invoice) { display: none !important; }
    #print-ticket {
        display: block !important; position: absolute; left: 0; top: 0;
        width: 70mm; padding: 4mm; text-align: center; color: #000; background: #fff;
        font-family: Arial, Helvetica, sans-serif;
        -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important;
    }
    #print-ticket .pt-brand { font-size: 9pt; letter-spacing: 2px; text-transform: uppercase; border-bottom: 1px solid #000; padding-bottom: 2mm; margin-bottom: 3mm; }
    #print-ticket .pt-code { font-size: 24pt; font-weight: 800; letter-spacing: 1px; }
    #print-ticket .pt-urgent { display: inline-block; border: 2px solid #000; padding: 1mm 3mm; font-weight: 800; font-size: 10pt; margin: 1mm 0; }
    #print-ticket img { width: 42mm; height: 42mm; display: block; margin: 2mm auto; image-rendering: pixelated; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    #print-ticket .pt-line { font-size: 10pt; margin: 1mm 0; }
    #print-ticket .pt-line b { font-weight: 700; }

    /* ===== Mode « facture » : activé par billing.js (body.print-invoice) ===== */
    @page invoice { size: A4 portrait; margin: 12mm; }
    body.print-invoice #print-ticket { display: none !important; }
    body.print-invoice #print-invoice {
        display: block !important; page: invoice;
        padding: 0; margin: 0; background: #fff; color: #0f172a;
    }
    /* Couleurs (bandeaux, en-tête du tableau, logo) réellement imprimées */
    #print-invoice, #print-invoice * {
        -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important;
    }
    #print-invoice .invoice { box-shadow: none !important; max-width: none; width: 100%; min-height: 0; margin: 0; padding: 0; border-radius: 0; }
    #print-invoice .inv-table thead { display: table-header-group; }   /* en-tête répété sur chaque page */
    #print-invoice .inv-table tr,
    #print-invoice .inv-total,
    #print-invoice .inv-foot,
    #print-invoice .inv-meta,
    #print-invoice .inv-legal { break-inside: avoid; page-break-inside: avoid; }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
    .reception-grid { grid-template-columns: 1fr; }
    .app-header { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 8px 14px; }
    .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
    .header-right { margin-left: auto; }
    .user-chip { display: none; }
    .toolbar { padding: 12px 14px; }
    .kanban { padding: 14px; height: auto; min-height: 60vh; }
    .filters .search { width: 100%; }
}
@media (max-width: 560px) {
    .pm-grid { grid-template-columns: 1fr; }
    .field-row { grid-template-columns: 1fr; }
    .page { padding: 14px; }
    .panel { padding: 18px; }
}
