:root {
    --bg: #eef1f6;
    --surface: #ffffff;
    --line: #e4e7ec;
    --line-strong: #cfd4dc;
    --text: #141a24;
    --muted: #667085;
    --accent: #1f4fd8;
    --accent-soft: #eaf0ff;
    --ink: #111827;
    --ok: #0f7a4d;
    --ok-soft: #e4f6ec;
    --warn: #9a5b00;
    --warn-soft: #fdf1d8;
    --err: #b42318;
    --err-soft: #fdecea;
    --navy: #14233f;
    --rdv: #1f4fd8;
    --rdv-soft: #e6edff;
    --try: #b35c00;
    --try-soft: #fff1dc;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-feature-settings: "tnum";
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 20px; padding-bottom: 60px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* Barre du haut */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-in { display: flex; align-items: center; gap: 20px; height: 58px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 16px; color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 14px; }
.tabs { display: flex; gap: 2px; align-self: stretch; }
.tabs a { display: flex; align-items: center; gap: 7px; padding: 0 12px; color: var(--muted); font-weight: 500; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-bottom-color: var(--ink); }
.count { background: var(--ink); color: #fff; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 999px; }
.count.warn { background: var(--warn-soft); color: var(--warn); }
.search { flex: 1; min-width: 120px; }
.me { display: flex; align-items: center; gap: 12px; font-size: 14px; white-space: nowrap; }
.me a { color: var(--text); font-weight: 500; }
.link { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; }
.link:hover { color: var(--text); }

/* Champs */
input[type=text], input[type=search], input[type=password], input[type=tel] {
    width: 100%; height: 36px; padding: 0 11px;
    border: 1px solid var(--line-strong); border-radius: 8px;
    background: var(--surface); color: var(--text); font: inherit; font-size: 14px;
    transition: border-color .12s, box-shadow .12s;
}
input:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: #98a2b3; }
label { display: grid; gap: 5px; font-size: 13px; font-weight: 500; color: #344054; }
label small { font-weight: 400; color: var(--muted); }

/* Boutons */
.btn {
    height: 34px; padding: 0 13px; border-radius: 8px; border: 1px solid var(--line-strong);
    background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
    transition: background .12s, border-color .12s;
}
.btn:hover { background: #f2f4f7; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #283447; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.wide { width: 100%; height: 40px; }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 12px; }
.card.done { background: #fafbfc; }
.card.done .dem-titre, .card.done .ref { color: var(--muted); }
.card.narrow { max-width: 460px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.name { font-size: 17px; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
.name.sm { font-size: 15px; }
.name.unknown { color: var(--muted); font-weight: 500; }
.tag { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; white-space: nowrap; vertical-align: 2px; }
.tag.warn { background: var(--warn-soft); color: var(--warn); margin-left: 0; }
.tag.ok { background: var(--ok-soft); color: var(--ok); margin-left: 0; }
.tel { display: flex; align-items: center; gap: 8px; }
.tel a { font-size: 17px; font-weight: 600; color: var(--accent); letter-spacing: .01em; }
.copy { height: 26px; padding: 0 9px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.copy:hover { color: var(--text); border-color: var(--line-strong); }
.copy.done { color: var(--ok); border-color: var(--ok); }

/* Demande */
.dem { padding: 11px 0; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.card-head + .dem { margin-top: 10px; }
.card > .dem:first-child { border-top: 0; padding-top: 0; }
.dem-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.dem-titre { font-weight: 500; flex: 1; min-width: 200px; }
.dem-titre .muted { font-weight: 400; }
.ref { font: 600 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: #f2f4f7; border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; }
.msg summary { cursor: pointer; color: var(--muted); font-size: 13px; width: fit-content; border-radius: 4px; }
.msg summary:hover { color: var(--text); }
.msg p, .quote { margin: 8px 0 0; padding: 10px 12px; background: #f8f9fb; border-radius: 8px; font-size: 14px; white-space: pre-line; }
.note { height: 32px !important; font-size: 13px !important; background: #fbfbfc !important; border-color: var(--line) !important; }
.note.saved { border-color: var(--ok) !important; }
.note.failed { border-color: var(--err) !important; }
.trace { list-style: none; margin: 0; padding: 10px 0 0; border-top: 1px solid var(--line); display: grid; gap: 3px; font-size: 13px; color: var(--muted); }
.trace li::before { content: "•"; margin-right: 7px; color: var(--line-strong); }
.trace .pnote { color: var(--text); }
.actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* Messages */
.flash { background: var(--ok-soft); color: var(--ok); border-radius: 8px; padding: 9px 13px; margin-bottom: 14px; font-size: 14px; font-weight: 500; }
.flash.err { background: var(--err-soft); color: var(--err); }
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 6px; }
.empty p { margin: 0; }
.lead { color: var(--muted); margin: 0 0 14px; }
.section { margin: 26px 0 12px; }
.section.first { margin-top: 4px; }

/* Tableaux */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.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; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.pages { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; font-size: 14px; }

/* Formulaires */
.stack { display: grid; gap: 14px; }
.fix { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 10px; align-items: end; margin-top: 12px; }
.userrow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto auto auto; gap: 10px; align-items: end; }
.check { display: flex; align-items: center; gap: 6px; height: 34px; white-space: nowrap; }

/* Activité */
.bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.bar .section { margin: 0; }
.seg { display: flex; background: #e9ecf1; border-radius: 8px; padding: 3px; }
.seg a { padding: 4px 12px; border-radius: 6px; color: var(--muted); font-size: 13px; font-weight: 500; }
.seg a:hover { text-decoration: none; color: var(--text); }
.seg a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi strong { font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.kpi strong.small { font-size: 17px; line-height: 39px; }
.kpi em { font-style: normal; font-size: 13px; color: var(--err); }
.kpi.bad { border-color: var(--err); }

/* Connexion */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-box { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 30px rgba(16, 24, 40, .08); padding: 30px 28px; display: grid; gap: 14px; }
.login-box .brand { font-size: 18px; }
.login-box p { margin: -8px 0 6px; font-size: 14px; }

@media (max-width: 860px) {
    .top-in { height: auto; flex-wrap: wrap; padding-top: 10px; gap: 10px 16px; }
    .tabs { order: 3; width: 100%; overflow-x: auto; height: 42px; }
    .search { order: 2; }
    .fix, .userrow { grid-template-columns: 1fr 1fr; }
    .actions { justify-content: stretch; }
    .actions .btn { flex: 1; }
}

/* Couleurs utiles */
.top { background: var(--navy); border-bottom: 0; }
.top .brand, .top .me a { color: #fff; }
.top .brand-mark { background: #fff; color: var(--navy); }
.top .tabs a { color: #b6c2d9; }
.top .tabs a:hover { color: #fff; }
.top .tabs a.on { color: #fff; border-bottom-color: #6ea0ff; }
.top .count { background: #6ea0ff; color: #0b1a33; }
.top .count.warn { background: #ffc266; color: #4a2a00; }
.top .link { color: #b6c2d9; }
.top .link:hover { color: #fff; }
.top .search input { background: rgba(255, 255, 255, .1); border-color: transparent; color: #fff; }
.top .search input::placeholder { color: #9fb0cc; }
.top .search input:focus-visible { background: #fff; color: var(--text); box-shadow: 0 0 0 3px rgba(110, 160, 255, .45); }
.top .search input:focus-visible::placeholder { color: #98a2b3; }

/* Ancienneté : liseré à gauche de la carte */
.card[class*=age-] { border-left: 4px solid var(--line-strong); }
.card.age-fresh { border-left-color: #2f9e6b; }
.card.age-due { border-left-color: #e89b1c; }
.card.age-late { border-left-color: #d6382c; }
.tag.due { background: var(--warn-soft); color: var(--warn); }
.tag.late { background: var(--err-soft); color: var(--err); }
.tag.try { background: var(--try-soft); color: var(--try); }
.tag.rdv { background: var(--rdv-soft); color: var(--rdv); margin-left: 0; }
.tag.missed { background: var(--err-soft); color: var(--err); margin-left: 0; }

/* Source du mail */
.src { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.src.hektor { background: #ece8fd; color: #4a34b8; }
.src.leboncoin { background: #ffe9dc; color: #b3470a; }

/* Boutons selon leur effet */
.btn.try:hover { background: var(--try-soft); border-color: #e8b877; color: var(--try); }
.btn.rdv { border-color: #b9c9f7; color: var(--rdv); background: var(--rdv-soft); }
.btn.rdv:hover { background: #d6e1ff; }
.btn.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.done:hover { background: #0b6540; }
.trace li.try::before { color: #e89b1c; }
.trace li.ok::before { color: #2f9e6b; }
.trace li.try { color: var(--try); }
.card.done { border-left: 4px solid #b9dcc9; }

/* Carte compacte : message et note repliés */
.dem { gap: 6px; padding: 9px 0; }
.dem-tools { display: flex; gap: 14px; }
.tool { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; border-radius: 4px; }
.tool::before { content: "▸ "; }
.tool[aria-expanded=true]::before { content: "▾ "; }
.tool:hover, .tool[aria-expanded=true] { color: var(--text); }
.quote { margin: 0; }
[hidden] { display: none !important; }
.actions { margin-top: 6px; }
.card { padding: 13px 16px; }

.src.site { background: #dcf3f1; color: #0d6b63; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot.due { background: #e89b1c; }
.dot.late { background: #d6382c; }

/* Filtres et tri */
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select { height: 32px; max-width: 360px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); font: inherit; font-size: 13px; color: var(--text); }
.filters .total { margin-left: auto; }
a.ref { color: var(--text); }
a.ref:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }

/* Panneau d'un bien */
.bien { background: #fff8ea; border: 1px solid #f0d9a8; border-radius: var(--radius); padding: 13px 16px; margin-bottom: 14px; display: grid; gap: 9px; }
.bien-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.bien-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bien p { margin: 0; }
.btn.warn { background: #fff; border-color: #e0a84a; color: #8a4b00; }
.btn.warn:hover { background: #ffedc9; }
a.btn { display: inline-flex; align-items: center; }
a.btn:hover { text-decoration: none; }

/* Appel en cours, mail, annulation d'une tentative */
.tag.calling { background: #dff3ff; color: #075985; }
.tag.calling::before { content: "● "; color: #0ea5e9; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 0 6px; }
.btn.ghost:hover { color: var(--text); background: #f2f4f7; }
.grow { flex: 1; }
a.copy { display: inline-flex; align-items: center; }
a.copy:hover { text-decoration: none; }
.mailmain { font-size: 15px; font-weight: 600; }
form.inline { display: inline; margin-left: 6px; }
.link.small { font-size: 12px; text-decoration: underline; }

/* Statistiques */
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.sw.recues, .bars .recues { background: #7c8db5; }
.sw.appels, .bars .appels { background: #e89b1c; }
.sw.traitees, .bars .traitees { background: #2f9e6b; }
.kpi em.evo { color: var(--muted); }
.chart-card { padding: 16px 16px 10px; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 190px; }
.chart .col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; border-radius: 6px; }
.chart .col.we { background: #f4f5f8; }
.chart .col:hover { background: #eef1f6; }
.chart .bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; border-bottom: 1px solid var(--line); }
.chart .bars i { flex: 1; max-width: 14px; min-height: 0; border-radius: 3px 3px 0 0; }
.chart .col span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.legend { margin: 10px 0 0; font-size: 13px; }
.legend .sw { margin-left: 12px; }
.legend .sw:first-child { margin-left: 0; }
.table tr.we td { background: #fafbfc; color: var(--muted); }
.search { min-width: 180px; }
.top .wrap { max-width: 1240px; }

.sep { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.userrow { grid-template-columns: repeat(3, minmax(0, 1fr)) auto auto auto; }
