/* CRM Connectivité — version Web. Palette reprise de la version bureau (bleu Québec). */
:root {
  --accent: #095797; --accent-dark: #223654; --accent-light: #e6eef6;
  --ink: #1d2733; --muted: #4f5b67; --line: #d5dce3; --surface: #fff; --canvas: #f2f4f7;
  --danger: #b42318; --danger-light: #fef3f2; --warning: #9a5b00; --warning-light: #fff6e5;
  --success: #1e7b34; --success-light: #eaf6ec; --info-light: #eef4fb;
  --radius: 6px; --shadow: 0 1px 3px rgba(16, 24, 40, .1);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--canvas); }
a { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 0 0 .6rem; font-weight: 600; }
h2 { font-size: 1.08rem; margin: 0 0 .5rem; font-weight: 600; }
h3 { font-size: .98rem; margin: .4rem 0; font-weight: 600; }
code { font-family: Consolas, "Cascadia Mono", monospace; font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.prewrap { white-space: pre-wrap; }
.right { margin-left: auto; }
.nowrap { white-space: nowrap; }
.loading { padding: 2rem; color: var(--muted); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ boutons et champs */
.btn { display: inline-flex; align-items: center; gap: .35rem; font: inherit; padding: .38rem .8rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #b0bac5; background: #f8fafc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #074a80; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: .2rem .55rem; font-size: .86rem; }
.btn.wide { width: 100%; justify-content: center; padding: .55rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #b8c2cc; border-radius: 4px; padding: .36rem .5rem; width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; }
input:read-only:not([type=checkbox]) { background: var(--canvas); border-color: var(--line); }
textarea { resize: vertical; min-height: 4.5rem; }
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger); background: var(--danger-light); }
label { display: block; font-weight: 600; font-size: .86rem; color: var(--muted); margin-bottom: .55rem; }
label > input, label > select, label > textarea { margin-top: .2rem; font-weight: 400; }
label.check { display: flex; align-items: center; gap: .45rem; font-weight: 400; color: var(--ink); font-size: .92rem; }
label small, .help { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; margin-top: .15rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .9rem .3rem; margin: 0 0 .9rem; }
legend { font-weight: 600; padding: 0 .3rem; }
.form { margin-top: .6rem; }
.alert { padding: .6rem .8rem; border-radius: var(--radius); margin: .6rem 0; border: 1px solid; }
.alert.danger { background: var(--danger-light); border-color: #f2b8b5; color: #7a1a12; }
.alert.info { background: var(--info-light); border-color: #b9cfe8; color: #12395f; }
.alert.warning { background: var(--warning-light); border-color: #f0d199; color: #5c3a00; }
.alert.success { background: var(--success-light); border-color: #a8d5b2; color: #154f24; }

/* ------------------------------------------------------------------ pages d'accès */
.auth-shell { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem;
  background: linear-gradient(160deg, #223654 0, #095797 100%); }
.auth-card { background: #fff; width: 100%; max-width: 520px; border-radius: 10px; padding: 1.6rem 1.8rem; box-shadow: 0 12px 40px rgba(0, 0, 0, .25); }
.auth-brand { display: flex; gap: .7rem; align-items: center; margin-bottom: 1.2rem; padding-bottom: .9rem; border-bottom: 1px solid var(--line); }
.auth-title { font-weight: 700; font-size: 1.1rem; }
.auth-sub { color: var(--muted); font-size: .85rem; }
.auth-foot { color: #dbe6f1; font-size: .82rem; margin-top: 1rem; text-align: center; }
.otp { font-size: 1.5rem; letter-spacing: .35em; text-align: center; font-family: Consolas, monospace; }
.qr { margin: .6rem 0; }
.qr svg { width: 220px; height: 220px; display: block; }
.secret { font-family: Consolas, monospace; font-size: 1.05rem; letter-spacing: .08em; background: var(--canvas); padding: .4rem .6rem; border-radius: 4px; }
.steps { padding-left: 1.2rem; }
.steps li { margin-bottom: .6rem; }

/* ------------------------------------------------------------------ coquille */
.shell { display: flex; height: 100vh; }
.sidebar { width: 236px; flex: 0 0 236px; background: var(--accent-dark); color: #fff; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: .55rem; padding: .9rem 1rem .6rem; color: #fff; font-weight: 600; font-size: 1.02rem; text-decoration: none; }
.nav-scroll { overflow-y: auto; padding-bottom: 1rem; }
.nav-h { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: #9fb3cc; padding: .9rem 1rem .25rem; font-weight: 600; }
.sidebar a:not(.brand) { display: block; color: #e3ebf4; text-decoration: none; padding: .38rem 1rem .38rem 1.1rem; border-left: 3px solid transparent; }
.sidebar a:not(.brand):hover { background: rgba(255, 255, 255, .07); }
.sidebar a.active { background: rgba(255, 255, 255, .12); border-left-color: #6fb1ef; color: #fff; font-weight: 600; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem; background: #fff; border-bottom: 1px solid var(--line); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.content { flex: 1; overflow: auto; }
.statusbar { display: flex; gap: 1.2rem; align-items: center; padding: .25rem 1rem; background: #e8edf2; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; }
.statusbar strong { color: var(--ink); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.ok { background: #2f9e44; }
.usermenu { position: relative; }
.usermenu summary { cursor: pointer; list-style: none; padding: .35rem .6rem; border: 1px solid var(--line); border-radius: var(--radius); }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu .menu { position: absolute; right: 0; top: 2.4rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 18px rgba(0, 0, 0, .15);
  padding: .6rem .8rem; min-width: 220px; z-index: 50; display: flex; flex-direction: column; gap: .5rem; }

/* recherche globale */
.search { position: relative; flex: 1; max-width: 560px; }
.search input { padding: .42rem .7rem; background: var(--canvas); }
.search-results { position: absolute; top: 2.4rem; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .15); list-style: none; margin: 0; padding: .25rem 0; max-height: 70vh; overflow: auto; z-index: 60; }
.search-results li { padding: .4rem .7rem; cursor: pointer; }
.search-results li.sel, .search-results li:hover { background: var(--accent-light); }
.search-results .t { font-weight: 600; }
.search-results .d { color: var(--muted); font-size: .84rem; }

/* ------------------------------------------------------------------ pages */
.page { padding: 1rem 1.2rem 2rem; }
.page.narrow { max-width: 900px; }
.page-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.page-head h1 { margin: 0; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.subtitle { color: var(--muted); font-size: .86rem; margin-top: .15rem; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .9rem 1rem; margin-bottom: .9rem; box-shadow: var(--shadow); }
.card > h2 { display: flex; align-items: center; gap: .5rem; }
.card .card-sub { color: var(--muted); font-size: .84rem; margin: -.3rem 0 .6rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
.cols { display: grid; grid-template-columns: minmax(420px, 1.15fr) minmax(360px, 1fr); gap: 1rem; align-items: start; }
.span2 { grid-column: 1 / -1; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: .7rem; }
.toolbar label { margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem .8rem; align-items: flex-end; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; margin-bottom: .7rem; }
.filters label { margin: 0; min-width: 140px; }
.filters label.check { min-width: 0; }
.count { color: var(--muted); font-size: .86rem; }

/* tableaux */
.table-wrap { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
table.data { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.data th { position: sticky; top: 0; background: #f7f9fb; text-align: left; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); padding: .45rem .55rem; white-space: nowrap; cursor: default; }
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--ink); }
table.data td { padding: .38rem .55rem; border-bottom: 1px solid #edf0f3; vertical-align: top; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: var(--accent-light); }
table.data tr.group td { background: #eef3f8; font-weight: 600; color: var(--accent-dark); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data.compact td, table.data.compact th { padding: .25rem .45rem; }
table.data tr.warn td { background: var(--warning-light); }
.empty { padding: 1rem; color: var(--muted); }

/* pastilles */
.pill { display: inline-block; padding: .08rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.st-new { background: #6f42c1; color: #fff; } .st-analyse { background: #8e44ad; color: #fff; } .st-assigned { background: #1f6feb; color: #fff; }
.st-progress { background: #0b7285; color: #fff; } .st-wait { background: #e67700; color: #fff; } .st-answered { background: #2b8a3e; color: #fff; }
.st-done { background: #5c940d; color: #fff; } .st-closed { background: #868e96; color: #fff; } .st-other { background: #495057; color: #fff; }
.dl-late { background: var(--danger-light); color: var(--danger); border: 1px solid #f2b8b5; }
.dl-near { background: var(--warning-light); color: var(--warning); border: 1px solid #f0d199; }
.dl-paused { background: #eef1f4; color: #495057; border: 1px solid #ced4da; }
.dl-ok { background: var(--success-light); color: var(--success); border: 1px solid #a8d5b2; }
.dl-future { background: var(--info-light); color: #12395f; border: 1px solid #b9cfe8; }
.dl-none { background: transparent; color: var(--muted); }
.prio-P1 { background: #c92a2a; color: #fff; } .prio-P2 { background: #f76707; color: #fff; } .prio-P3 { background: #fab005; color: #222; } .prio-P4 { background: #74c0fc; color: #123; }

/* tuiles et graphiques */
.tiles { display: flex; flex-wrap: wrap; gap: .7rem; margin-bottom: .9rem; }
.tile { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: .65rem .9rem; min-width: 175px; cursor: pointer; text-align: left; font: inherit; box-shadow: var(--shadow); }
.tile:hover { background: #f8fbff; }
.tile .v { font-size: 1.7rem; font-weight: 700; line-height: 1.2; color: var(--accent-dark); }
.tile .l { color: var(--muted); font-size: .86rem; font-weight: 600; }
.tile .s { color: var(--muted); font-size: .78rem; }
.tile.danger { border-left-color: var(--danger); } .tile.danger .v { color: var(--danger); }
.tile.warning { border-left-color: #e67700; } .tile.success { border-left-color: var(--success); } .tile.success .v { color: var(--success); }
.bars { display: flex; flex-direction: column; gap: .3rem; }
.bar { display: grid; grid-template-columns: minmax(120px, 34%) 1fr 3.5rem; gap: .5rem; align-items: center; background: none; border: 0; padding: .1rem 0; font: inherit; text-align: left; cursor: pointer; color: var(--ink); }
.bar:hover .bar-label { text-decoration: underline; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; }
.bar-track { display: block; background: #eef1f4; height: 14px; border-radius: 3px; overflow: hidden; }
.bar-fill { display: block; background: var(--accent); height: 100%; }
.bar-fill.dark { background: var(--accent-dark); }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; font-size: .88rem; }
.monthly { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: .4rem; }
.month { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; cursor: pointer; background: none; border: 0; padding: 0; font: inherit; }
.month .pair { display: flex; align-items: flex-end; gap: 2px; height: 140px; width: 100%; justify-content: center; }
.month .a { display: block; background: var(--accent); width: 42%; min-height: 1px; border-radius: 2px 2px 0 0; }
.month .b { display: block; background: #8fbde6; width: 42%; min-height: 1px; border-radius: 2px 2px 0 0; }
.month .m { font-size: .7rem; color: var(--muted); margin-top: .2rem; }
.legend { display: flex; gap: 1rem; font-size: .82rem; color: var(--muted); margin-top: .4rem; }
.legend i { display: inline-block; width: 12px; height: 10px; margin-right: .3rem; border-radius: 2px; }

/* onglets */
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: .8rem; flex-wrap: wrap; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: .45rem .8rem; font: inherit; color: var(--muted); cursor: pointer; }
.tabs button.on { border-bottom-color: var(--accent); color: var(--ink); font-weight: 600; }
.tabs button:hover { color: var(--ink); }

/* fil chronologique */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 3px solid var(--line); padding: .3rem 0 .6rem .8rem; margin-left: .3rem; }
.timeline li.courriel { border-left-color: #1f6feb; } .timeline li.appel { border-left-color: #2b8a3e; } .timeline li.statut { border-left-color: #e67700; }
.timeline .head { font-size: .82rem; color: var(--muted); }
.timeline .obj { font-weight: 600; }
.timeline .body { white-space: pre-wrap; font-size: .9rem; max-height: 14rem; overflow: auto; }

/* suggestions d'adresses */
.suggest { position: relative; }
.suggest ul { position: absolute; z-index: 40; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 8px 20px rgba(0, 0, 0, .15);
  list-style: none; margin: 2px 0 0; padding: .2rem 0; max-height: 320px; overflow: auto; }
.suggest li { padding: .32rem .6rem; cursor: pointer; }
.suggest li .d { color: var(--muted); font-size: .8rem; }
.suggest li.sel, .suggest li:hover { background: var(--accent-light); }
.snapshot td:first-child { color: var(--muted); white-space: nowrap; width: 40%; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .9rem; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* fenêtres */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 1rem; }
.modal { background: #fff; border-radius: 10px; padding: 1.1rem 1.3rem; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.modal.wide { max-width: 860px; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.toasts { position: fixed; right: 1rem; bottom: 2.4rem; display: flex; flex-direction: column; gap: .5rem; z-index: 300; max-width: 460px; }
.toast { background: var(--accent-dark); color: #fff; padding: .6rem .9rem; border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); cursor: pointer; white-space: pre-wrap; }
.toast.erreur { background: var(--danger); }
.toast.succes { background: #1e5c34; }

/* carte */
.map-page { display: flex; flex-direction: column; height: 100%; }
.map-host { position: relative; flex: 1; min-height: 420px; }
.map-host.inline { height: 380px; flex: none; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.map-canvas { position: absolute; inset: 0; }
.map-panel { position: absolute; background: rgba(255, 255, 255, .96); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); padding: .45rem .65rem; z-index: 2; font-size: .86rem; }
.map-toolbar { top: 10px; left: 10px; display: flex; gap: .9rem; flex-wrap: wrap; max-width: calc(100% - 70px); }
.map-toolbar .grp { display: flex; align-items: center; gap: .45rem; }
.map-toolbar .lbl { font-weight: 600; color: var(--muted); text-transform: uppercase; font-size: .7rem; letter-spacing: .04em; }
.map-toolbar label { display: inline-flex; align-items: center; gap: .25rem; margin: 0; font-weight: 400; color: var(--ink); font-size: .86rem; white-space: nowrap; }
.map-toolbar select { width: auto; padding: .1rem .3rem; }
.map-legend { bottom: 28px; left: 10px; min-width: 170px; }
.map-legend .row { display: flex; align-items: center; gap: .4rem; margin: .1rem 0; }
.map-legend .sw { width: 16px; height: 12px; border: 1px solid rgba(0, 0, 0, .2); border-radius: 2px; }
.map-status { bottom: 28px; right: 10px; color: #8a1c1c; background: #fff4f4; }
.map-pickhint { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; padding: .4rem .9rem; border-radius: 16px; z-index: 3; font-weight: 600; }
.maplibregl-popup-content { font: 13px var(--font); padding: .6rem .75rem; max-width: 360px; }
.pop h3 { margin: 0 0 .35rem; font-size: .95rem; }
.pop table { border-collapse: collapse; width: 100%; }
.pop td { padding: .1rem .25rem; vertical-align: top; border-bottom: 1px solid #eef1f4; }
.pop td:first-child { color: var(--muted); white-space: nowrap; }
.pop .list { max-height: 140px; overflow: auto; margin-top: .25rem; }
.pop .actions { margin-top: .5rem; display: flex; gap: .4rem; }
.pop button { font: inherit; border: 1px solid var(--accent); background: #fff; color: var(--accent); border-radius: 4px; padding: .15rem .5rem; cursor: pointer; }
.pop button.primary { background: var(--accent); color: #fff; }
.pop a { cursor: pointer; }

@media (max-width: 1100px) { .cols { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { flex-direction: column; height: auto; min-height: 100vh; }
  .sidebar { width: 100%; flex: none; }
  .nav-scroll { display: flex; flex-wrap: wrap; }
  .nav-h { width: 100%; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .statusbar { display: none; }
}
h1:focus { outline: none; }
.month .m { display: block; }
.links { list-style: none; padding: 0; margin: .2rem 0 .8rem; } .links li { padding: .15rem 0; }
.checks { display: flex; flex-wrap: wrap; gap: .2rem 1rem; } .datetime { display: grid; grid-template-columns: 1fr 7rem; gap: .4rem; } .field { min-width: 0; } .btn.disabled { opacity: .5; pointer-events: none; }
.map-host > .map-canvas { position: absolute !important; top: 0; left: 0; right: 0; bottom: 0; }
