/* CITA Leadflow — refonte v1.2.5 : palette CITA + inspiration LeadFlow */
:root {
    --c-navy: #0b1f3b;
    --c-navy-2: #0b3b73;
    --c-primary: #0b3b73;
    --c-primary-2: #1560a8;
    --c-primary-3: #2a7bc8;
    --c-accent: #c8321e;
    --c-bg: #f4f6fa;
    --c-surface: #ffffff;
    --c-border: #e2e7ee;
    --c-border-2: #eef1f6;
    --c-text: #1a1f2b;
    --c-text-muted: #6a7280;
    --c-text-dim: #94a3b8;
    --c-ok: #12a45a;
    --c-warn: #d97b1a;
    --c-err: #c8321e;
    --c-info: #1560a8;
    --c-purple: #8b5cf6;
    --c-teal: #14b8a6;
    --c-amber: #f59e0b;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(11,31,59,.05), 0 1px 3px rgba(11,31,59,.04);
    --shadow-md: 0 4px 12px rgba(11,31,59,.08);
    --sidebar-w: 240px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--c-text); background: var(--c-bg); font-size: 14px; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; }
a { color: var(--c-primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.icon { display: inline-flex; align-items: center; justify-content: center; }
.icon svg { width: 100%; height: 100%; }

/* ---------- Boot ---------- */
.boot { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: linear-gradient(180deg, var(--c-navy) 0%, var(--c-primary) 100%); color: #fff; z-index: 9999; }
.boot-logo { width: 180px; padding: 12px 16px; background: #fff; border-radius: 14px; margin-bottom: 20px; display: block; }
.boot-spin { width: 28px; height: 28px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
.boot-label { margin-top: 14px; font-size: 13px; opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar { background: linear-gradient(180deg, var(--c-navy) 0%, #08284d 100%); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar-brand { padding: 18px 18px 16px; display: flex; align-items: center; gap: 12px; }
.sidebar-brand .logo { width: 42px; height: 42px; background: #fff; padding: 3px; border-radius: 8px; object-fit: contain; }
.sidebar-brand .brand-text .name { font-size: 15px; font-weight: 700; margin-bottom: 1px; letter-spacing: .2px; }
.sidebar-brand .brand-text .agency { font-size: 11px; color: #94a8c6; }
.sidebar-nav { flex: 1; padding: 10px 12px; overflow-y: auto; }
.sidebar-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; color: rgba(255,255,255,.75); border-radius: 8px; margin-bottom: 2px; font-size: 13.5px; font-weight: 500; transition: background .12s, color .12s; }
.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar-nav a.active { background: rgba(255,255,255,.1); color: #fff; box-shadow: inset 3px 0 0 var(--c-accent); }
.sidebar-nav a .icon { width: 18px; height: 18px; color: currentColor; opacity: .9; flex-shrink: 0; }
.sidebar-nav .nav-section { font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: #667fa6; padding: 16px 14px 6px; font-weight: 600; }
.sidebar-foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-foot .profile-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; cursor: pointer; }
.sidebar-foot .profile-row:hover { background: rgba(255,255,255,.06); }
.sidebar-foot .avatar { width: 34px; height: 34px; background: var(--c-primary-2); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.sidebar-foot .profile-info { font-size: 12.5px; line-height: 1.3; overflow: hidden; }
.sidebar-foot .profile-info .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .profile-info .role { font-size: 10px; color: #94a8c6; text-transform: uppercase; letter-spacing: .5px; }
.sidebar-foot .version { text-align: center; font-size: 10px; color: #4a6087; margin-top: 8px; }

/* ---------- Main + top bar ---------- */
.main { padding: 0; overflow-x: hidden; }
.topbar { background: #fff; border-bottom: 1px solid var(--c-border); padding: 12px 28px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 100; }
.topbar-agency { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.topbar-agency .dot { width: 8px; height: 8px; background: var(--c-accent); border-radius: 50%; }
.topbar-agency b { font-weight: 700; margin-left: 3px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-right .bell { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #6a7280; cursor: pointer; transition: background .12s; position: relative; }
.topbar-right .bell:hover { background: #f0f3f8; }
.topbar-right .bell .icon { width: 18px; height: 18px; }
.topbar-right .user { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; border-radius: 30px; cursor: pointer; transition: background .12s; }
.topbar-right .user:hover { background: #f0f3f8; }
.topbar-right .user .avatar { width: 34px; height: 34px; background: var(--c-primary); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.topbar-right .user .info { line-height: 1.3; }
.topbar-right .user .info .name { font-size: 13px; font-weight: 600; }
.topbar-right .user .info .role { font-size: 11px; color: var(--c-text-muted); }

.view-container { padding: 24px 28px 60px; }

/* ---------- View head (greeting) ---------- */
.view-head { margin-bottom: 20px; display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.view-head-left { position: relative; padding-left: 16px; }
.view-head-left::before { content: ''; position: absolute; left: 0; top: 2px; bottom: 2px; width: 4px; background: var(--c-accent); border-radius: 2px; }
.view-head h2 { font-size: 22px; margin: 0 0 3px; color: var(--c-text); font-weight: 700; }
.view-head p { color: var(--c-text-muted); font-size: 13px; margin: 0; }
.view-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Filters bar ---------- */
.filters-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.filters-bar select { padding: 9px 30px 9px 14px; border: 1px solid var(--c-border); border-radius: 10px; background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236a7280'><path fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.06l3.71-3.83a.75.75 0 111.08 1.04l-4.25 4.4a.75.75 0 01-1.08 0L5.21 8.27a.75.75 0 01.02-1.06z' clip-rule='evenodd'/></svg>") no-repeat right 10px center / 14px; -webkit-appearance: none; appearance: none; font-size: 13px; color: var(--c-text); font-family: inherit; cursor: pointer; min-width: 170px; box-shadow: var(--shadow-sm); }
.filters-bar select:focus { outline: none; border-color: var(--c-primary-2); }

/* ---------- KPI ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--c-surface); border: 1px solid var(--c-border-2); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 14px; }
.kpi-icon { width: 44px; height: 44px; border-radius: 12px; background: #eef4fc; color: var(--c-primary-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kpi-icon .icon { width: 20px; height: 20px; }
.kpi.money .kpi-icon { background: var(--c-primary); color: #fff; }
.kpi.warn .kpi-icon { background: #fff4e5; color: var(--c-warn); }
.kpi.err .kpi-icon { background: #fde7e3; color: var(--c-err); }
.kpi.ok .kpi-icon { background: #e6f7ee; color: var(--c-ok); }
.kpi-body { min-width: 0; }
.kpi-label { font-size: 11px; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 4px; font-weight: 600; }
.kpi-value { font-size: 22px; font-weight: 700; color: var(--c-text); line-height: 1.1; }
.kpi-sub { font-size: 11px; color: var(--c-text-muted); margin-top: 2px; }

/* ---------- Cards ---------- */
.card { background: var(--c-surface); border: 1px solid var(--c-border-2); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; margin-bottom: 18px; }
.card h3 { font-size: 15px; margin: 0 0 14px; color: var(--c-text); font-weight: 700; }
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .card-grid { grid-template-columns: 1fr; } }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--c-border-2); vertical-align: top; }
th { background: #fafbfd; color: var(--c-text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
tr:hover td { background: #fafbfd; }
.table-scroll { overflow-x: auto; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.badge.new { background: #eef4fc; color: #1560a8; }
.badge.callback { background: #fff4e5; color: #a05a00; }
.badge.rdv { background: #f0ebfe; color: #6d28d9; }
.badge.quote_sent { background: #e0f7f5; color: #0e7570; }
.badge.signed { background: #d4f5df; color: #0d6b34; }
.badge.installed { background: #d4f5df; color: #0d6b34; }
.badge.lost { background: #eef1f6; color: #64748b; }
.badge.in_progress { background: #fff4e5; color: #a05a00; }
.badge.complete { background: #e6f7ee; color: #0f7a3f; }
.badge.transmitted { background: #e8f0fc; color: #1560a8; }
.badge.scheduled { background: #ede9fe; color: #5b3fc9; }
.badge.done { background: #d4f5df; color: #0d6b34; }
.badge.validated { background: #d9ebff; color: #0b4b90; }
.badge.err { background: #fde7e3; color: #a02010; }
.badge.warn { background: #fff4e5; color: #a05a00; }
.badge.ok { background: #e6f7ee; color: #0f7a3f; }
.badge.high { background: #fde7e3; color: #a02010; }
.badge.normal { background: #eef4fc; color: #1560a8; }
.badge.low { background: #eef1f6; color: #64748b; }

/* ---------- Pipeline Kanban ---------- */
.kanban { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 20px; }
.kanban-col { flex: 0 0 300px; background: transparent; }
.kanban-col-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px 12px; }
.kanban-col-head .col-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--c-text); }
.kanban-col-head .col-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-primary-2); }
.kanban-col-head .col-count { font-size: 12px; color: var(--c-text-muted); font-weight: 600; }
.kanban-body { display: flex; flex-direction: column; gap: 10px; min-height: 200px; }
.kanban-card { background: #fff; border: 1px solid var(--c-border-2); border-radius: 10px; padding: 14px; box-shadow: var(--shadow-sm); cursor: pointer; transition: transform .1s, box-shadow .12s; position: relative; }
.kanban-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kanban-card .card-priority-dot { position: absolute; top: 12px; right: 12px; width: 8px; height: 8px; border-radius: 50%; }
.kanban-card .card-name { font-size: 14px; font-weight: 600; margin-bottom: 8px; padding-right: 14px; color: var(--c-text); }
.kanban-card .card-line { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--c-text-muted); margin-bottom: 4px; }
.kanban-card .card-line .icon { width: 12px; height: 12px; flex-shrink: 0; opacity: .8; }
.kanban-card .card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--c-border-2); font-size: 11px; color: var(--c-text-muted); }
.kanban-card .card-foot .assignee { display: flex; align-items: center; gap: 5px; }
.kanban-card .card-foot .assignee .avatar-mini { width: 18px; height: 18px; background: var(--c-primary-2); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; }
.stage-select { position: absolute; top: 30px; right: 8px; z-index: 10; background: #fff; border: 1px solid var(--c-border); border-radius: 8px; box-shadow: var(--shadow-md); padding: 4px; display: none; min-width: 160px; }
.stage-select.open { display: block; }
.stage-select button { display: block; width: 100%; text-align: left; padding: 8px 10px; background: none; border: none; font-size: 12px; cursor: pointer; border-radius: 6px; }
.stage-select button:hover { background: #f4f6fa; }

/* ---------- Forms ---------- */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-row.full { grid-template-columns: 1fr; }
label.field-label { display: block; font-size: 11px; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; font-weight: 600; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=date], input[type=time], input[type=datetime-local], select, textarea {
    width: 100%; padding: 10px 12px; font-size: 13px; border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: #fff; color: var(--c-text); transition: border-color .12s; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--c-primary-2); box-shadow: 0 0 0 3px rgba(21,96,168,.1); }
textarea { min-height: 70px; resize: vertical; }
.field-pw { position: relative; }
.field-pw .toggle-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; padding: 4px; color: #888; font-size: 16px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 6px 0; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; font-size: 13px; font-weight: 500; border: 1px solid var(--c-border); border-radius: 8px; background: #fff; color: var(--c-text); cursor: pointer; transition: all .12s; }
.btn:hover { background: #f7f9fc; border-color: var(--c-primary-2); }
.btn .icon { width: 14px; height: 14px; }
.btn.primary { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.btn.primary:hover { background: var(--c-primary-2); border-color: var(--c-primary-2); }
.btn.ok { background: var(--c-ok); color: #fff; border-color: var(--c-ok); }
.btn.err { background: var(--c-err); color: #fff; border-color: var(--c-err); }
.btn.warn { background: var(--c-warn); color: #fff; border-color: var(--c-warn); }
.btn.small { padding: 5px 9px; font-size: 12px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--c-primary-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(11,31,55,.5); display: flex; align-items: center; justify-content: center; z-index: 5000; padding: 20px; }
.modal { background: #fff; border-radius: 12px; max-width: 640px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--c-border-2); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; color: var(--c-text); text-transform: none; letter-spacing: 0; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--c-border-2); display: flex; justify-content: flex-end; gap: 8px; }
.close { background: none; border: none; font-size: 22px; cursor: pointer; color: #888; padding: 0 4px; }

/* ---------- Toast ---------- */
.toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 6000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 16px; border-radius: 8px; box-shadow: var(--shadow-md); font-size: 13px; color: #fff; min-width: 220px; max-width: 340px; animation: slidein .2s ease; }
.toast.ok { background: var(--c-ok); }
.toast.err { background: var(--c-err); }
.toast.info { background: var(--c-info); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Pieces ---------- */
.pieces-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.piece-tile { border: 1px dashed var(--c-border); border-radius: 8px; padding: 12px; text-align: center; font-size: 12px; background: #fafbfd; }
.piece-tile.present { border-style: solid; border-color: var(--c-ok); background: #f0faf4; }
.piece-tile.missing { border-color: var(--c-warn); background: #fff8f0; }
.piece-tile .piece-name { font-weight: 600; margin-bottom: 6px; }

/* ---------- Kanban drag & drop ---------- */
.kanban-body.drop-target { background: #eef4fc; border: 2px dashed var(--c-primary-2); border-radius: 10px; padding: 6px; }
.kanban-card.dragging { opacity: .4; cursor: grabbing; }
.kanban-card { cursor: grab; }
.kanban-card:active { cursor: grabbing; }

/* ---------- Bell badge ---------- */
.bell-badge { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; background: var(--c-accent); color: #fff; border-radius: 8px; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; box-shadow: 0 0 0 2px #fff; }

/* ---------- Notifications ---------- */
.notif-list { display: flex; flex-direction: column; }
.notif-item { display: flex; align-items: flex-start; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--c-border-2); cursor: pointer; transition: background .12s; position: relative; }
.notif-item:hover { background: #fafbfd; }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: #f0f7ff; }
.notif-item.unread:hover { background: #e6f0fc; }
.notif-icon { width: 36px; height: 36px; background: #eef4fc; color: var(--c-primary-2); border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-weight: 600; font-size: 13.5px; margin-bottom: 3px; color: var(--c-text); }
.notif-desc { font-size: 12.5px; color: var(--c-text-muted); margin-bottom: 4px; }
.notif-ts { font-size: 11px; color: var(--c-text-dim); }
.notif-dot { position: absolute; top: 20px; right: 20px; width: 8px; height: 8px; background: var(--c-accent); border-radius: 50%; }

/* ---------- Charts (SVG) ---------- */
.chart-wrap { width: 100%; overflow: hidden; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; justify-content: center; }
.chart-legend .lg-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--c-text); }
.chart-legend .lg-dot { width: 12px; height: 12px; border-radius: 2px; }

/* ---------- Stock jauge ---------- */
.jauge { height: 6px; background: #eef; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.jauge > span { display: block; height: 100%; background: var(--c-ok); }
.jauge.low > span { background: var(--c-warn); }
.jauge.out > span { background: var(--c-err); }

/* ---------- Planning ---------- */
.planning-grid { border: 1px solid var(--c-border); border-radius: 8px; overflow: hidden; background: #fff; }
.planning-head { display: grid; background: var(--c-primary); color: #fff; font-size: 12px; font-weight: 600; }
.planning-head > div { padding: 10px 12px; border-right: 1px solid rgba(255,255,255,.15); }
.planning-row { display: grid; border-top: 1px solid var(--c-border); min-height: 60px; }
.planning-row > div { padding: 8px 10px; border-right: 1px solid var(--c-border); position: relative; }
.planning-row .tech-cell { background: #fafbfd; font-weight: 600; font-size: 12px; }
.slot { display: block; margin: 3px 0; padding: 4px 6px; border-radius: 4px; font-size: 11px; color: #fff; cursor: pointer; }
.slot.pose { background: var(--c-primary-2); }        /* bleu */
.slot.sav { background: var(--c-warn); }              /* orange */
.slot.maintenance { background: var(--c-ok); }        /* vert */
.absence-cell { background: repeating-linear-gradient(45deg, #eee, #eee 6px, #f6f6f6 6px, #f6f6f6 12px); color: #999; font-style: italic; font-size: 11px; text-align: center; padding-top: 20px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    :root { --sidebar-w: 100%; }
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; }
    .sidebar-nav { display: block; padding: 6px 8px; }
    .topbar { padding: 10px 16px; }
    .view-container { padding: 16px; }
    .form-row { grid-template-columns: 1fr; }
    .view-head { flex-direction: column; }
    .view-head-actions { width: 100%; }
    .kpi-row { grid-template-columns: 1fr 1fr; gap: 10px; }
    .kpi { padding: 14px; gap: 10px; }
    .kpi-icon { width: 38px; height: 38px; }
    .kpi-value { font-size: 18px; }
    .kanban-col { flex: 0 0 260px; }
}
@media (max-width: 600px) {
    .kpi-row { grid-template-columns: 1fr; }
}
