/*
 * Citya Life Billing Desk — même structure que Citya Life Construction Desk,
 * identité du cahier des charges § 4 : gris anthracite #3B4044, jaune Citya, fond blanc, police Nunito.
 */
:root {
    --cy-ink: #3b4044;          /* gris anthracite — couleur principale */
    --cy-ink-dark: #25282b;
    --cy-ink-soft: #62686c;
    --cy-yellow: #f4d32c;       /* jaune Citya — couleur secondaire */
    --cy-yellow-dark: #d9b70f;
    --cy-yellow-tint: #fdf7d6;
    --cy-green: #1f8a5b;
    --cy-orange: #d97706;
    --cy-red: #c8322b;
    --cy-blue: #2f6fae;
    --cy-bg: #f4f5f6;
    --cy-surface: #ffffff;
    --cy-text: #2f3437;
    --cy-text-muted: #6b7276;
    --cy-border: #e3e6e8;
    --cy-shadow-sm: 0 1px 3px rgba(37, 40, 43, .07), 0 1px 2px rgba(37, 40, 43, .05);
    --cy-shadow-md: 0 6px 18px rgba(37, 40, 43, .10);
    --cy-shadow-lg: 0 16px 40px rgba(37, 40, 43, .16);
    --cy-radius: 14px;
    --cy-radius-sm: 9px;
    --sb-width: 264px;
    --bs-body-color: var(--cy-text);
    --bs-border-radius: var(--cy-radius-sm);
    --bs-link-color-rgb: 47, 111, 174;
}
body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--cy-bg); color: var(--cy-text); line-height: 1.55; min-height: 100vh;
    display: flex; flex-direction: column; -webkit-font-smoothing: antialiased;
}
body > footer { margin-top: auto !important; }
h1, h2, h3 { color: var(--cy-ink-dark); font-weight: 800; letter-spacing: -.015em; }
h4, h5, h6 { color: var(--cy-ink-dark); font-weight: 700; }
.text-mono, .num { font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }

/* ---------- Barre latérale permanente (anthracite) ---------- */
body.with-sidebar { padding-left: var(--sb-width); padding-top: 3.25rem; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sb-width); z-index: 1040;
    background: var(--cy-ink); color: #e9ecee; display: flex; flex-direction: column; transition: transform .22s ease;
}
.sb-brand { display: flex; align-items: center; gap: .7rem; padding: 1.05rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.08); text-decoration: none; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 10px; background: var(--cy-yellow); color: var(--cy-ink-dark);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 900; font-size: .95rem; flex-shrink: 0; letter-spacing: -.03em;
}
.sb-brand-text { color: #fff; font-weight: 800; line-height: 1.1; font-size: 1rem; }
.sb-brand-text small { display: block; color: var(--cy-yellow); font-weight: 700; font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; }
.sb-scroll { flex: 1; overflow-y: auto; padding: .8rem .65rem; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.sb-section { margin: .9rem .6rem .3rem; font-size: .66rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.42); }
.sb-item {
    display: flex; align-items: center; gap: .7rem; padding: .48rem .65rem; margin-bottom: .1rem; border-radius: var(--cy-radius-sm);
    color: #dfe3e5; font-weight: 600; font-size: .92rem; text-decoration: none; transition: background-color .15s, color .15s;
}
.sb-item i { width: 20px; text-align: center; opacity: .85; }
.sb-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.sb-item.active { background: rgba(244,211,44,.14); color: var(--cy-yellow); }
.sb-item.active i { opacity: 1; }
.sb-item .badge { margin-left: auto; }
.sb-cta { background: var(--cy-yellow); color: var(--cy-ink-dark) !important; font-weight: 800; margin-bottom: .7rem; }
.sb-cta:hover { background: #ffe14d; }
.sb-bottom { border-top: 1px solid rgba(255,255,255,.08); padding: .6rem .65rem; }
.sb-user small { color: rgba(255,255,255,.55); }
.avatar-sm { width: 30px; height: 30px; border-radius: 50%; background: var(--cy-yellow); color: var(--cy-ink-dark); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem; flex-shrink: 0; }
.sb-open-btn { position: fixed; top: .8rem; left: 1rem; z-index: 1050; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--cy-border); background: #fff; box-shadow: var(--cy-shadow-md); display: none; align-items: center; justify-content: center; color: var(--cy-ink); }

/* ---------- Barre supérieure : périmètre + cloche ---------- */
.topbar { position: fixed; top: .7rem; right: 1.2rem; z-index: 1030; display: flex; gap: .6rem; align-items: center; }
.topbar .who { background: #fff; border: 1px solid var(--cy-border); border-radius: 999px; padding: .3rem .85rem; font-size: .8rem; font-weight: 700; color: var(--cy-ink-soft); box-shadow: var(--cy-shadow-sm); }
.notif-bell { width: 42px; height: 42px; border-radius: 50%; background: #fff; border: 1px solid var(--cy-border); box-shadow: var(--cy-shadow-md); color: var(--cy-ink); position: relative; display: inline-flex; align-items: center; justify-content: center; }
.notif-count { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; background: var(--cy-red); color: #fff; border-radius: 9px; font-size: .68rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.notif-menu { min-width: 340px; max-height: 420px; overflow-y: auto; }
.notif-menu .dropdown-item { white-space: normal; }

/* ---------- Composants ---------- */
.card { border: 1px solid var(--cy-border); border-radius: var(--cy-radius); box-shadow: var(--cy-shadow-sm); }
.card-header { background: transparent; border-bottom: 1px solid var(--cy-border); font-weight: 800; color: var(--cy-ink-dark); padding: .8rem 1.1rem; }
.page-eyebrow { font-size: .7rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; color: var(--cy-yellow-dark); }
.kpi-card { display: block; text-decoration: none; color: inherit; height: 100%; transition: transform .15s, box-shadow .15s; }
a.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--cy-shadow-md); }
.kpi-value { font-size: 1.45rem; font-weight: 900; color: var(--cy-ink-dark); line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--cy-text-muted); font-weight: 700; font-size: .78rem; }
.kpi-sub { color: var(--cy-text-muted); font-size: .75rem; }
.kpi-accent { border-left: 4px solid var(--cy-yellow); }
.kpi-icon { width: 38px; height: 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--cy-yellow-tint); color: var(--cy-ink); flex-shrink: 0; }

.btn { border-radius: 999px; font-weight: 800; padding: .48rem 1.2rem; }
.btn-sm { padding: .25rem .8rem; }
.btn-primary { background: var(--cy-ink); border-color: var(--cy-ink); color: #fff; }
.btn-primary:hover, .btn-primary:focus { background: var(--cy-ink-dark); border-color: var(--cy-ink-dark); }
.btn-accent { background: var(--cy-yellow); border-color: var(--cy-yellow); color: var(--cy-ink-dark); }
.btn-accent:hover { background: #ffe14d; border-color: #ffe14d; color: var(--cy-ink-dark); }
.btn-outline-primary { color: var(--cy-ink); border-color: var(--cy-ink); }
.btn-outline-primary:hover { background: var(--cy-ink); color: #fff; }
.btn-outline-secondary { color: var(--cy-ink); border-color: var(--cy-border); }
.btn-outline-secondary:hover { background: var(--cy-bg); color: var(--cy-ink); border-color: var(--cy-ink-soft); }
.btn-success { background: var(--cy-green); border-color: var(--cy-green); }
.text-primary { color: var(--cy-ink) !important; }
.text-success { color: var(--cy-green) !important; }
.text-danger { color: var(--cy-red) !important; }
.text-warning { color: var(--cy-orange) !important; }
.text-secondary { color: var(--cy-text-muted) !important; }

.badge { padding: .42em .85em; border-radius: 999px; font-weight: 800; font-size: .74rem; }
.badge-ok { background: rgba(31,138,91,.13); color: #17704a; }
.badge-ok-strong { background: var(--cy-green); color: #fff; }
.badge-ko { background: rgba(200,50,43,.11); color: #a8261f; }
.badge-attente { background: rgba(217,119,6,.14); color: #965200; }
.badge-info { background: rgba(47,111,174,.12); color: #255a8e; }
.badge-neutre { background: rgba(59,64,68,.09); color: var(--cy-ink); }
.badge-yellow { background: var(--cy-yellow); color: var(--cy-ink-dark); }

.table { --bs-table-bg: transparent; border-color: var(--cy-border); margin-bottom: 0; }
.table thead th { font-weight: 800; text-transform: uppercase; font-size: .7rem; letter-spacing: .06em; color: var(--cy-text-muted); background: #fafbfb; white-space: nowrap; }
.table-hover tbody tr[data-href]:hover { background: var(--cy-yellow-tint); cursor: pointer; }
.table tfoot td { font-weight: 800; background: #fafbfb; }

.form-control, .form-select { border-color: #d5d9dc; border-radius: var(--cy-radius-sm); }
.form-control:focus, .form-select:focus { border-color: var(--cy-ink-soft); box-shadow: 0 0 0 3px rgba(244,211,44,.35); }
.form-label { font-weight: 700; color: var(--cy-ink); margin-bottom: .3rem; font-size: .9rem; }
.form-text { font-size: .78rem; }
.alert { border: 0; border-radius: var(--cy-radius-sm); font-weight: 600; }
.alert-success { background: rgba(31,138,91,.12); color: #17704a; }
.alert-danger { background: rgba(200,50,43,.10); color: #a8261f; }
.alert-warning { background: rgba(217,119,6,.13); color: #8a4b00; }
.alert-info { background: rgba(47,111,174,.10); color: #255a8e; }
.nav-tabs .nav-link { border: 0; border-bottom: 3px solid transparent; color: var(--cy-text-muted); font-weight: 700; }
.nav-tabs .nav-link.active { color: var(--cy-ink-dark); border-bottom-color: var(--cy-yellow); background: transparent; }
.dropdown-menu { border: 1px solid var(--cy-border); border-radius: var(--cy-radius-sm); box-shadow: var(--cy-shadow-md); }

/* Contrôles automatiques */
.ctrl-list { list-style: none; padding: 0; margin: 0; }
.ctrl-list li { display: flex; gap: .55rem; align-items: flex-start; padding: .35rem 0; font-size: .88rem; border-bottom: 1px dashed var(--cy-border); }
.ctrl-list li:last-child { border-bottom: 0; }
.ctrl-list i { margin-top: .2rem; }
.ctrl-bloquant i { color: var(--cy-red); }
.ctrl-alerte i { color: var(--cy-orange); }
.ctrl-ok i { color: var(--cy-green); }

/* Saisie : récapitulatif du calcul */
.calc-box { background: var(--cy-ink); color: #fff; border-radius: var(--cy-radius); padding: 1.1rem 1.2rem; position: sticky; top: 4.2rem; }
.calc-box .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.6); font-weight: 800; }
.calc-box .v { font-weight: 800; font-variant-numeric: tabular-nums; }
.calc-box .ttc { font-size: 1.7rem; color: var(--cy-yellow); font-weight: 900; }
.calc-box .detail { font-size: .82rem; color: rgba(255,255,255,.78); }
.calc-box .ctrl-list li { border-color: rgba(255,255,255,.12); color: #eef0f1; }

/* Frise de statut */
.wf { display: flex; gap: 0; overflow-x: auto; padding: .3rem 0 .6rem; }
.wf-step { flex: 1; min-width: 92px; text-align: center; position: relative; }
.wf-step:not(:last-child)::after { content: ''; position: absolute; top: 15px; left: calc(50% + 17px); right: calc(-50% + 17px); height: 2px; background: var(--cy-border); }
.wf-step.done:not(:last-child)::after { background: var(--cy-green); }
.wf-dot { width: 32px; height: 32px; border-radius: 50%; margin: 0 auto; background: #fff; border: 2px solid var(--cy-border); display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 800; color: var(--cy-text-muted); position: relative; z-index: 1; }
.wf-step.done .wf-dot { background: var(--cy-green); border-color: var(--cy-green); color: #fff; }
.wf-step.current .wf-dot { background: var(--cy-yellow); border-color: var(--cy-yellow); color: var(--cy-ink-dark); box-shadow: 0 0 0 5px rgba(244,211,44,.3); }
.wf-step.ko .wf-dot { background: var(--cy-red); border-color: var(--cy-red); color: #fff; }
.wf-label { font-size: .72rem; font-weight: 800; margin-top: .35rem; color: var(--cy-text-muted); }
.wf-step.current .wf-label { color: var(--cy-ink-dark); }

.id-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: .8rem 1.4rem; }
.id-grid .k { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--cy-text-muted); }
.id-grid .v { font-weight: 700; color: var(--cy-ink-dark); }
.timeline-item { border-left: 2px solid var(--cy-border); padding: 0 0 1rem 1rem; position: relative; font-size: .88rem; }
.timeline-item::before { content: ''; position: absolute; left: -6px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--cy-yellow); border: 2px solid var(--cy-ink); }
.bar-chart { display: flex; align-items: flex-end; gap: .45rem; height: 170px; padding-top: .5rem; }
.bar-chart .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-chart .bar span.b { width: 100%; max-width: 44px; background: var(--cy-ink); border-radius: 6px 6px 0 0; min-height: 2px; }
.bar-chart .bar span.b.encaisse { background: var(--cy-yellow); }
.bar-chart .bar small { font-size: .68rem; color: var(--cy-text-muted); font-weight: 700; margin-top: .3rem; white-space: nowrap; }
.bar-pair { display: flex; gap: 3px; width: 100%; justify-content: center; align-items: flex-end; height: 100%; }
.bar-pair span.b { max-width: 20px !important; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .3rem; vertical-align: middle; }
.progress { height: 8px; border-radius: 999px; background: var(--cy-border); }
.progress-bar { background: var(--cy-ink); }
.filters .form-select, .filters .form-control { font-size: .85rem; }
.empty { color: var(--cy-text-muted); text-align: center; padding: 2rem 1rem; }
.empty i { font-size: 1.6rem; display: block; margin-bottom: .5rem; color: #c3c8cb; }

/* Connexion */
.login-page { min-height: 100vh; display: flex; }
.login-brand-panel { background: var(--cy-ink); color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 4rem 4.5rem; position: relative; overflow: hidden; }
.login-brand-panel::after { content: ''; position: absolute; width: 480px; height: 480px; border-radius: 50%; background: radial-gradient(circle, rgba(244,211,44,.30) 0%, transparent 70%); bottom: -170px; right: -170px; }
.login-brand-panel h1 { color: #fff; font-size: 2.5rem; line-height: 1.15; }
.login-brand-panel h1 span { color: var(--cy-yellow); }
.login-brand-panel p { color: rgba(255,255,255,.72); max-width: 30rem; font-size: 1.05rem; }
.login-steps { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 2rem; position: relative; z-index: 1; }
.login-steps span { border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: .35rem .9rem; font-weight: 800; font-size: .82rem; }
.login-steps span b { color: var(--cy-yellow); margin-right: .3rem; }
.login-form-panel { background: var(--cy-bg); display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; }
.login-card { width: 100%; max-width: 460px; background: #fff; border-radius: 20px; border: 1px solid var(--cy-border); box-shadow: var(--cy-shadow-lg); padding: 2.4rem; }
.demo-accounts { font-size: .8rem; max-height: 210px; overflow-y: auto; }
.demo-accounts button { font-size: .78rem; padding: .2rem .6rem; }

/* Facture (aperçu HTML) */
.invoice-sheet { background: #fff; border: 1px solid var(--cy-border); border-radius: var(--cy-radius); overflow: hidden; }
.invoice-head { background: var(--cy-ink); color: #fff; padding: 1.4rem 1.6rem; display: flex; justify-content: space-between; align-items: center; }
.invoice-head h2 { color: #fff; margin: 0; }

@media (max-width: 991px) {
    body.with-sidebar { padding-left: 0; padding-top: 4.3rem; }
    body.with-sidebar:not(.sb-shown) .sidebar { transform: translateX(-100%); }
    .sb-open-btn { display: inline-flex; }
    body.sb-shown .sidebar { box-shadow: var(--cy-shadow-lg); }
    .login-brand-panel { display: none !important; }
    .topbar .who { display: none; }
    .calc-box { position: static; }
}
@media print {
    .sidebar, .no-print, .topbar, .sb-open-btn, .alert { display: none !important; }
    body, body.with-sidebar { background: #fff; padding: 0; }
    .card { box-shadow: none; }
}
