/* === ImmoCheck EDL — app.css === */
:root {
  --navy: #13294b;
  --navy-2: #1d3a66;
  --green: #22a865;
  --green-soft: #e3f6ec;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --line: #e2e7ee;
  --line-2: #cfd7e2;
  --text: #17202c;
  --muted: #637083;
  --info: #2f6fd6;   --info-soft: #e7effc;
  --warn: #b7700b;   --warn-soft: #fdf1dc;
  --danger: #c53b3b; --danger-soft: #fbe7e7;
  --accent: #6b4fd1; --accent-soft: #eeeafc;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(19, 41, 75, .06), 0 4px 16px rgba(19, 41, 75, .05);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Manrope', var(--font);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.01em; margin: 0; }
a { color: var(--info); }
code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
.ic { flex: none; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* ---------- Mise en page ---------- */
.layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--navy); color: #c9d4e5; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 22px; }
.brand-name { color: #fff; font: 800 16px var(--display); }
.brand-sub { font-size: 11.5px; color: #8fa2c0; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: inherit; text-decoration: none; font-weight: 500; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: rgba(255,255,255,.11); color: #fff; box-shadow: inset 3px 0 0 var(--green); }
.nav-count { margin-left: auto; font-size: 11px; font-weight: 700; min-width: 20px; text-align: center; padding: 1px 6px; border-radius: 10px; display: none; }
.nav-count.on { display: inline-block; }
.nav-count.warn { background: #f3b04a; color: #3a2600; }
.nav-count.info { background: #6ea0f0; color: #0b2350; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.09); display: grid; gap: 8px; }
.sidebar-foot .btn { color: #c9d4e5; border-color: rgba(255,255,255,.15); justify-content: flex-start; }
.sidebar-foot .btn:hover { background: rgba(255,255,255,.07); color: #fff; }
.who { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #8fa2c0; }
.sidebar-scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px 6px; }
.topbar h1 { font-size: 22px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.topbar .menu-btn { display: none; }
.demo-banner { margin: 8px 28px 0; padding: 8px 12px; border-radius: 8px; background: var(--warn-soft); color: #7a4a05; font-size: 13px; }
.page { padding: 16px 28px 48px; min-width: 0; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font: 600 13.5px var(--font); cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: #f0f3f7; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #1c9257; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #a92f2f; }
.btn-ghost { background: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: #eef1f5; color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.link { background: none; border: 0; color: var(--info); cursor: pointer; font: inherit; padding: 0; }
.link:hover { text-decoration: underline; }

/* ---------- Cartes & KPI ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px 0; flex-wrap: wrap; }
.card-head h2 { font-size: 15px; }
.grid { display: grid; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { padding: 16px 18px; }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi-value { font: 800 26px/1.15 var(--display); margin-top: 6px; letter-spacing: -.02em; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-sub .up { color: var(--green); font-weight: 600; }
.kpi-sub .down { color: var(--danger); font-weight: 600; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid { align-content: start; }
.dash-grid > * { min-width: 0; }

/* ---------- Barre d'outils / filtres ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 34px; }
.seg { display: inline-flex; background: #e9edf3; border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; font: 500 13px var(--font); color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- Formulaires ---------- */
input, select, textarea { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; font: 14px var(--font); color: var(--text); }
textarea { height: auto; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47, 111, 214, .25); border-color: var(--info); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--navy); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 12.5px; font-weight: 600; color: #3b4757; }
.hint { color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; height: 36px; }
.form-section { grid-column: 1 / -1; font: 700 12px var(--font); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.price-hint { font-size: 12px; color: var(--green); font-weight: 600; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfc; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: #f7f9fc; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 12.5px; color: var(--muted); }
.month-row td { background: #f1f4f8; font-weight: 700; font-size: 12.5px; color: #3b4757; padding: 7px 14px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eef1f5; color: #4a5566; }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-success { background: var(--green-soft); color: #167447; }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-muted { background: #eef1f5; color: #7a8595; }
select.status-select { width: auto; height: 28px; font-size: 12.5px; font-weight: 600; padding: 0 6px; border-radius: 14px; }

/* ---------- Listes simples ---------- */
.list { list-style: none; margin: 0; padding: 6px 0; }
.list li { display: flex; gap: 12px; align-items: center; padding: 10px 20px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .when { width: 92px; flex: none; font-size: 12.5px; color: var(--muted); }
.list .when b { display: block; color: var(--text); font-size: 13px; }
.list .grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Graphiques ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { font: 11px var(--font); fill: var(--muted); }
.chart .val { fill: var(--text); font-weight: 600; }
.bars-h { display: grid; gap: 10px; padding: 16px 20px 20px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 46px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 10px; background: #edf0f5; border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--navy); border-radius: 5px; }
.bar-row .n { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Pipeline prospection ---------- */
.board { display: grid; grid-template-columns: repeat(6, minmax(185px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: start; }
.col { background: #eaeef4; border-radius: var(--radius); padding: 10px; min-height: 120px; }
.col.drag-over { outline: 2px dashed var(--info); outline-offset: -2px; }
.col-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 13px; padding: 2px 4px 10px; }
.col-head .badge { background: #fff; }
.pcard { background: var(--surface); border-radius: 8px; border: 1px solid var(--line); padding: 10px 12px; margin-bottom: 8px; cursor: pointer; box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.pcard:hover { border-color: var(--line-2); }
.pcard.dragging { opacity: .5; }
.pcard-title { font-weight: 600; }
.pcard-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pcard-foot { display: flex; align-items: center; margin-top: 8px; gap: 6px; }
.pcard-foot:empty { display: none; }
.pcard-foot .btn-sm { height: 26px; padding: 0 8px; font-size: 12px; }
.due { font-size: 12px; font-weight: 600; }
.due.late { color: var(--danger); }
.due.today { color: var(--warn); }
.due.later { color: var(--muted); }

/* ---------- Agenda ---------- */
.week-nav { display: flex; align-items: center; gap: 8px; }
.week-label { font: 700 15px var(--display); min-width: 220px; text-align: center; }
.week { display: grid; grid-template-columns: 56px repeat(6, minmax(120px, 1fr)); overflow-x: auto; }
.week-head { position: sticky; top: 0; background: #fafbfc; border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: center; font-size: 12.5px; color: var(--muted); }
.week-head b { display: block; font: 800 18px var(--display); color: var(--text); }
.week-head.today b { color: #fff; background: var(--navy); border-radius: 50%; width: 32px; height: 32px; line-height: 32px; margin: 2px auto 0; }
.hours { position: relative; border-right: 1px solid var(--line); }
.hour-label { position: absolute; right: 8px; font-size: 11px; color: var(--muted); transform: translateY(-50%); }
.day-col { position: relative; border-right: 1px solid var(--line); background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% 48px; cursor: copy; }
.day-col:last-child { border-right: 0; }
.ev { position: absolute; left: 4px; right: 4px; border-radius: 6px; padding: 4px 7px; font-size: 12px; line-height: 1.3; overflow: hidden; cursor: pointer; border-left: 3px solid; }
.ev b { display: block; font-weight: 700; }
.ev-planifiee { background: var(--info-soft); border-color: var(--info); color: #1b4593; }
.ev-confirmee { background: var(--accent-soft); border-color: var(--accent); color: #432fa0; }
.ev-realisee { background: var(--green-soft); border-color: var(--green); color: #135e3a; }
.ev-annulee { background: #f1f2f4; border-color: #aab2bd; color: #7a8595; text-decoration: line-through; }

/* ---------- Modales ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 25, 40, .45); display: grid; place-items: start center; padding: 6vh 16px; overflow-y: auto; z-index: 50; animation: fade .12s ease; }
.modal { width: min(560px, 100%); background: var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); display: flex; flex-direction: column; }
.modal-wide { width: min(820px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: #fafbfc; border-radius: 0 0 14px 14px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }

/* ---------- Divers ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-title { font: 700 16px var(--display); color: var(--text); margin-bottom: 4px; }
.alert { background: var(--danger-soft); color: var(--danger); padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.note { background: var(--info-soft); color: #1b4593; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
#toasts { position: fixed; bottom: 18px; right: 18px; display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); font-weight: 500; transition: opacity .3s, transform .3s; border-left: 4px solid var(--green); }
.toast-danger { border-left-color: #ff7b7b; }
.toast-warn { border-left-color: #f3b04a; }
.toast.out { opacity: 0; transform: translateY(6px); }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 180px; overflow-y: auto; }
.history li { font-size: 13px; padding: 6px 10px; background: #f6f8fb; border-radius: 6px; }
.history time { color: var(--muted); font-size: 12px; margin-right: 6px; }
.lines-table input { height: 32px; }
.lines-table td { padding: 6px 6px; }
.totals { display: grid; grid-template-columns: auto auto; gap: 4px 24px; justify-content: end; margin-top: 12px; font-variant-numeric: tabular-nums; }
.totals .grand { font: 800 16px var(--display); }
.pick-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.pick-list label { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pick-list label:last-child { border-bottom: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { border: 0; background: none; padding: 9px 14px; font: 600 13.5px var(--font); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--navy); border-bottom-color: var(--navy); }

/* ---------- Connexion ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--navy) 0%, #0d1c34 100%); }
.login-card { width: min(380px, 100%); background: #fff; border-radius: 16px; padding: 30px 28px; display: grid; gap: 14px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.login-card h1 { font-size: 22px; }
.login-card p { margin: -8px 0 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 39; }
  .topbar .menu-btn { display: inline-grid; }
  .topbar { padding: 12px 16px 4px; }
  .topbar h1 { font-size: 19px; }
  .page { padding: 12px 16px 40px; }
  .demo-banner { margin: 6px 16px 0; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .search { max-width: none; }
  .week-label { min-width: 0; font-size: 14px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 20px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Impression (factures) ---------- */
@media print {
  body { background: #fff; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
}
#print-root { display: none; }
.invoice-preview { border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; background: #fff; }
.invoice-preview .invoice-doc { min-width: 640px; padding: 24px 28px !important; }
