/* ===================================================================
   DeviW — thème Bootstrap 5.3 : bleu marine, bleu ciel, rouge, gris
   =================================================================== */
:root {
  --navy: #0F2A4E;
  --navy-2: #1D3E68;
  --sky: #2F7DC1;
  --sky-tint: #E1EFFA;
  --red: #C0392B;
  --bg: #EBEEF2;
  --bg-soft: #F7F8FA;
  --line: #D7DCE3;
  --slate: #5B6472;
  --topbar-h: 56px;

  --bs-primary: #0F2A4E;
  --bs-primary-rgb: 15, 42, 78;
  --bs-info: #2F7DC1;
  --bs-info-rgb: 47, 125, 193;
  --bs-danger: #C0392B;
  --bs-danger-rgb: 192, 57, 43;
  --bs-body-color: #1B2430;
  --bs-secondary-color: #5B6472;
  --bs-border-color: #D7DCE3;
  --bs-link-color: #2F7DC1;
  --bs-link-hover-color: #0F2A4E;
  --bs-link-color-rgb: 47, 125, 193;
  --bs-link-hover-color-rgb: 15, 42, 78;
  --bs-border-radius: .5rem;
  --bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}
body { background: var(--bg); }
h1, h2, h3, h4, h5 { color: var(--navy); letter-spacing: -.01em; }
.text-navy { color: var(--navy) !important; }
.text-sky { color: var(--sky) !important; }
.bg-navy { background: var(--navy) !important; }
.bg-sky-tint { background: var(--sky-tint) !important; }

/* Boutons */
.btn-primary { --bs-btn-bg: var(--navy); --bs-btn-border-color: var(--navy); --bs-btn-hover-bg: var(--navy-2); --bs-btn-hover-border-color: var(--navy-2); --bs-btn-active-bg: var(--navy-2); --bs-btn-active-border-color: var(--navy-2); --bs-btn-disabled-bg: var(--navy); --bs-btn-disabled-border-color: var(--navy); }
.btn-accent { --bs-btn-color: #fff; --bs-btn-bg: var(--sky); --bs-btn-border-color: var(--sky); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #256aa6; --bs-btn-hover-border-color: #256aa6; --bs-btn-active-bg: #256aa6; --bs-btn-active-border-color: #256aa6; --bs-btn-active-color: #fff; }
.btn-outline-primary { --bs-btn-color: var(--navy); --bs-btn-border-color: var(--navy); --bs-btn-hover-bg: var(--navy); --bs-btn-hover-border-color: var(--navy); --bs-btn-active-bg: var(--navy); --bs-btn-active-border-color: var(--navy); }
.btn-danger { --bs-btn-bg: var(--red); --bs-btn-border-color: var(--red); --bs-btn-hover-bg: #a52f23; --bs-btn-hover-border-color: #a52f23; }
.btn-outline-danger { --bs-btn-color: var(--red); --bs-btn-border-color: var(--red); --bs-btn-hover-bg: var(--red); --bs-btn-hover-border-color: var(--red); }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: var(--sky); box-shadow: 0 0 0 .2rem rgba(47, 125, 193, .2); }
.form-check-input:checked { background-color: var(--sky); border-color: var(--sky); }
.form-label { font-weight: 600; font-size: .85rem; color: var(--navy); }
.form-label.req::after { content: " *"; color: var(--red); }
.card { border-color: var(--line); box-shadow: 0 1px 2px rgba(15, 42, 78, .05); }
.card-header { background: var(--bg-soft); font-weight: 600; color: var(--navy); }
.table { --bs-table-bg: transparent; }
.table > thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--slate); background: var(--bg-soft); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--sky-tint); }
.badge { font-weight: 600; }
.text-bg-info { color: #fff !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }
.page-eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--sky); }
.page-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; font-size: 1.6rem; font-weight: 700; }
.page-head p { margin: .15rem 0 0; color: var(--slate); }

/* ---------- Barre du haut (pleine largeur, collante) ---------- */
.app-topbar { position: sticky; top: 0; z-index: 1030; height: var(--topbar-h); background: var(--navy); color: #fff; display: flex; align-items: center; gap: .5rem; padding: 0 .75rem; box-shadow: 0 1px 0 rgba(255,255,255,.06); }
.app-topbar .brand { display: flex; align-items: center; gap: .55rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; letter-spacing: .01em; }
.app-topbar .brand img { width: 30px; height: 30px; border-radius: 7px; background: #fff; padding: 2px; }
.app-topbar .tb-btn { color: #fff; background: transparent; border: 0; border-radius: .5rem; padding: .35rem .6rem; display: inline-flex; align-items: center; gap: .4rem; line-height: 1; }
.app-topbar .tb-btn:hover, .app-topbar .tb-btn:focus-visible, .app-topbar .tb-btn.show { background: rgba(255,255,255,.12); color: #fff; }
.app-topbar .fi, .dropdown-menu .fi { font-size: 1.1rem; line-height: 1; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.app-topbar .dropdown-menu { --bs-dropdown-border-color: var(--line); --bs-dropdown-link-active-bg: var(--sky-tint); --bs-dropdown-link-active-color: var(--navy); box-shadow: 0 8px 24px rgba(15,42,78,.18); }
.app-topbar .dropdown-item.active .bi-check2 { visibility: visible; }
.notif-badge { position: absolute; top: 2px; right: 2px; min-width: 1.1rem; height: 1.1rem; font-size: .65rem; line-height: 1.1rem; padding: 0 .25rem; border-radius: 1rem; background: var(--red); color: #fff; text-align: center; font-weight: 700; }
.user-chip { display: inline-flex; align-items: center; gap: .45rem; }
.user-chip .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--sky); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem; }

/* ---------- Structure : menu latéral + contenu ---------- */
.app-shell { display: flex; align-items: stretch; min-height: calc(100vh - var(--topbar-h)); }
.app-sidebar { --bs-offcanvas-width: 260px; --bs-offcanvas-bg: #fff; }
.app-sidebar .offcanvas-header { background: var(--navy); color: #fff; }
.app-sidebar .offcanvas-header .brand { color: #fff; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.app-sidebar .offcanvas-header img { width: 28px; height: 28px; border-radius: 6px; background: #fff; padding: 2px; }
.side-nav { list-style: none; margin: 0; padding: .75rem; display: flex; flex-direction: column; gap: .2rem; width: 100%; }
.side-nav a { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border-radius: .5rem; color: var(--navy); text-decoration: none; font-weight: 500; }
.side-nav a .bi { font-size: 1.1rem; color: var(--slate); }
.side-nav a:hover { background: var(--bg-soft); }
.side-nav a.active { background: var(--sky-tint); color: var(--navy); font-weight: 700; box-shadow: inset 3px 0 0 var(--sky); }
.side-nav a.active .bi { color: var(--sky); }
.app-main { flex: 1; min-width: 0; padding: 1.25rem; }
@media (min-width: 992px) {
  .app-aside { width: 240px; flex: 0 0 240px; background: #fff; border-right: 1px solid var(--line); position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; }
  .app-main { padding: 1.75rem 2rem; }
}
@media (max-width: 575.98px) {
  .stat-card .stat-icon { display: none; }
  .app-main { padding: 1rem .75rem; }
  .page-head h1 { font-size: 1.3rem; }
}

/* ---------- Tableau de bord ---------- */
.stat-card .stat-icon { width: 42px; height: 42px; border-radius: .6rem; display: grid; place-items: center; background: var(--sky-tint); color: var(--sky); font-size: 1.25rem; }
.stat-card .stat-value { font-size: clamp(1.05rem, 1.5vw + .4rem, 1.5rem); font-weight: 700; color: var(--navy); line-height: 1.15; white-space: nowrap; }
.stat-card .stat-label { font-size: .78rem; color: var(--slate); text-transform: uppercase; letter-spacing: .05em; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--slate); }
.empty-state .bi { font-size: 2.2rem; color: var(--line); display: block; margin-bottom: .5rem; }
.empty-state h3 { font-size: 1.1rem; }

/* ---------- Formulaire de document ---------- */
.lines-table th, .lines-table td { vertical-align: middle; }
.lines-table .col-qty { width: 100px; }
.lines-table .col-price { width: 150px; }
.lines-table .col-total { width: 140px; text-align: right; white-space: nowrap; }
.lines-table .col-act { width: 48px; }
.totals-box { max-width: 340px; margin-left: auto; }
.totals-box .row + .row { margin-top: .35rem; }
.totals-box .grand { font-size: 1.15rem; font-weight: 700; color: var(--navy); border-top: 2px solid var(--navy); padding-top: .5rem; margin-top: .5rem; }
@media (max-width: 767.98px) {
  .lines-table thead { display: none; }
  .lines-table, .lines-table tbody, .lines-table tr, .lines-table td { display: block; width: 100%; }
  .lines-table tr { border: 1px solid var(--line); border-radius: .5rem; padding: .5rem; margin-bottom: .6rem; background: #fff; }
  .lines-table td { border: 0; padding: .2rem 0; }
  .lines-table td[data-label]::before { content: attr(data-label); display: block; font-size: .7rem; text-transform: uppercase; color: var(--slate); }
  .lines-table .col-qty, .lines-table .col-price, .lines-table .col-total, .lines-table .col-act { width: 100%; text-align: left; }
}

/* ---------- Document imprimable (aperçu devis / facture) ---------- */
.doc-wrap { overflow-x: auto; }
.doc { background: #fff; color: #111; width: 100%; max-width: 794px; margin: 0 auto; padding: 44px 48px; border: 1px solid var(--line); box-shadow: 0 2px 10px rgba(15,42,78,.08); font-size: 14px; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.doc-company { display: flex; gap: 14px; align-items: flex-start; }
.doc-company img { max-width: 72px; max-height: 72px; object-fit: contain; }
.doc-company .name { font-weight: 700; font-size: 1.15rem; color: var(--navy); }
.doc-company .meta { color: #444; white-space: pre-line; }
.doc-qr { width: 110px; height: 110px; flex: 0 0 auto; }
.doc-qr img { width: 100%; height: 100%; display: block; }
.doc-meta { display: flex; justify-content: space-between; gap: 24px; margin: 28px 0 22px; }
.doc-meta .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #666; }
.doc-title { font-weight: 800; color: #000; text-transform: uppercase; font-size: 22px; letter-spacing: .04em; margin: 0 0 10px; }
.doc table.doc-lines { width: 100%; border-collapse: collapse; }
.doc table.doc-lines th { background: var(--navy); color: #fff; text-align: left; padding: 8px 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.doc table.doc-lines td { padding: 8px 10px; border-bottom: 1px solid #e3e6ea; vertical-align: top; }
.doc .num, .doc table.doc-lines th.num { text-align: right; white-space: nowrap; }
.doc-totals { width: 280px; margin: 16px 0 0 auto; }
.doc-totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.doc-totals .grand { border-top: 2px solid var(--navy); margin-top: 6px; padding-top: 8px; font-weight: 800; font-size: 16px; color: var(--navy); }
.doc-notes { margin-top: 26px; padding-top: 12px; border-top: 1px solid #e3e6ea; color: #333; white-space: pre-line; }
@media (max-width: 575.98px) { .doc { padding: 18px 12px; font-size: 12.5px; } .doc table.doc-lines th, .doc table.doc-lines td { padding: 6px 5px; } .doc table.doc-lines th { font-size: 10px; letter-spacing: 0; } .doc-totals { width: 100%; } .doc-head { flex-direction: column-reverse; } .doc-qr { align-self: flex-end; } }
@media print {
  body { background: #fff; }
  .app-topbar, .app-aside, .no-print, .alert { display: none !important; }
  .app-main { padding: 0 !important; }
  .doc { border: 0; box-shadow: none; max-width: none; padding: 0; }
  .doc-wrap { overflow: visible; }
}

/* ---------- Pages publiques ---------- */
.pub-nav { background: var(--navy); }
.hero { background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 62%, #24578d 100%); color: #fff; min-height: calc(100vh - var(--topbar-h)); display: flex; align-items: center; padding: 3rem 0; }
.hero h1 { color: #fff; font-weight: 800; font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.1; }
.hero p.lead { color: rgba(255,255,255,.85); max-width: 34rem; }
.hero .illus { max-width: 480px; width: 100%; }
.hero .btn-light { color: var(--navy); font-weight: 600; }
.feature { background: #fff; border: 1px solid var(--line); border-radius: .75rem; padding: 1.4rem; height: 100%; }
.feature .bi { width: 46px; height: 46px; border-radius: .7rem; background: var(--sky-tint); color: var(--sky); display: grid; place-items: center; font-size: 1.4rem; margin-bottom: .8rem; }
.pf-card { background: #fff; border: 1px solid var(--line); border-radius: .75rem; padding: 1.2rem; height: 100%; text-decoration: none; color: inherit; display: block; transition: transform .15s, box-shadow .15s; }
.pf-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15,42,78,.12); color: inherit; }
.pf-logo { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; background: var(--sky-tint); display: grid; place-items: center; color: var(--sky); font-weight: 700; font-size: 1.3rem; }
.pf-hero { background: linear-gradient(160deg, var(--navy), var(--navy-2)); color: #fff; padding: 3rem 0; }
.pf-hero h1 { color: #fff; font-weight: 800; }
.pf-hero .pf-logo { width: 84px; height: 84px; background: #fff; }
.pf-item img { width: 100%; height: 200px; object-fit: cover; border-radius: .6rem .6rem 0 0; }
.auth-card { max-width: 420px; width: 100%; }
.foot { color: var(--slate); font-size: .85rem; padding: 1.5rem 0; }
.logo-preview { max-width: 96px; max-height: 96px; object-fit: contain; border: 1px solid var(--line); border-radius: .5rem; padding: 4px; background: #fff; }
.item-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: .5rem; background: var(--bg-soft); }
