:root {
    --bg: #f5f6f8;
    --card: #fff;
    --ink: #1d2433;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #0b67d0;
    --primary-d: #0950a3;
    --ok-bg: #e7f6ec; --ok-ink: #1b7a3d;
    --err-bg: #fdeaea; --err-ink: #b42318;
    --info-bg: #eaf2fd; --info-ink: #0950a3;
}
* { box-sizing: border-box; }
body {
    margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg); color: var(--ink); font-size: 14px;
}
.topbar {
    display: flex; align-items: center; gap: 24px;
    background: #fff; border-bottom: 1px solid var(--line); padding: 0 24px; height: 56px;
}
.brand { font-weight: 700; font-size: 16px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
    padding: 8px 14px; border-radius: 8px; color: var(--ink); text-decoration: none;
}
.topbar nav a:hover { background: var(--bg); }
.topbar nav a.active { background: var(--primary); color: #fff; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; }
.userbox .who { color: var(--muted); }
.userbox .logout {
    color: var(--primary); text-decoration: none; font-weight: 600;
    border: 1px solid var(--line); padding: 6px 12px; border-radius: 8px;
}
.userbox .logout:hover { background: var(--bg); }

/* Page de connexion */
.auth-body { background: var(--bg); }
.auth-main { max-width: 420px; margin: 8vh auto; padding: 24px; }
.auth-card { padding: 28px; }
.auth-card h1 { font-size: 20px; margin: 0 0 12px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; }
.auth-form button { margin-top: 4px; }

/* Boutons compacts (gestion utilisateurs) */
.user-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.user-actions form { display: inline; }
.btn-mini { padding: 5px 10px; font-size: 12px; font-weight: 600; }
.btn-danger { background: var(--err-ink); }
.btn-danger:hover { background: #962d22; }
main { max-width: 1180px; margin: 0 auto; padding: 24px; }
h1 { font-size: 22px; margin: 0 0 18px; }
h2 { font-size: 16px; margin: 0 0 14px; }
h3 { font-size: 14px; margin: 18px 0 8px; }

.card {
    background: var(--card); border: 1px solid var(--line); border-radius: 12px;
    padding: 20px; margin-bottom: 20px;
}
.muted { color: var(--muted); }
code {
    background: #f0f1f4; padding: 1px 6px; border-radius: 5px; font-size: 12.5px;
}

/* Boutons / liens */
button {
    background: var(--primary); color: #fff; border: 0; border-radius: 8px;
    padding: 9px 16px; font-size: 14px; cursor: pointer;
}
button:hover { background: var(--primary-d); }
.btn-link {
    display: inline-block; margin-left: 10px; color: var(--primary);
    text-decoration: none; font-weight: 600;
}
.btn-link:hover { text-decoration: underline; }

/* Formulaires */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.grid label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; }
.grid .full { grid-column: 1 / -1; }
input, select {
    border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px;
    font-size: 14px; font-family: inherit; background: #fff;
}
.presets { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.presets button {
    background: #eef1f5; color: var(--ink); padding: 6px 12px; font-size: 13px; font-weight: 600;
}
.presets button:hover { background: #e1e6ec; }
.filters { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.filters label { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.filters .check { font-weight: normal; }
.filters .check input[type=checkbox] { width: auto; }
.filters .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.filters { flex-wrap: wrap; }

/* En-tête de groupe par type */
.group-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.group-head h2 { margin: 0; }
.group-total { text-align: right; }
.group-total strong { font-size: 17px; display: block; }
.group-total small { color: var(--muted); }

/* Flash */
.flash { padding: 11px 16px; border-radius: 9px; margin-bottom: 16px; font-weight: 500; }
.flash-success { background: var(--ok-bg); color: var(--ok-ink); }
.flash-error { background: var(--err-bg); color: var(--err-ink); }
.flash-info { background: var(--info-bg); color: var(--info-ink); }

/* Étapes */
.step {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%; background: var(--muted);
    color: #fff; font-size: 12px; margin-right: 8px;
}
.step.done { background: var(--ok-ink); }

/* Cartes métriques */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric {
    background: var(--card); border: 1px solid var(--line); border-radius: 12px;
    padding: 16px; display: flex; flex-direction: column; gap: 8px;
    text-decoration: none; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.metric:hover { border-color: var(--primary); box-shadow: 0 2px 10px rgba(11,103,208,.1); }
.metric.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(11,103,208,.18); }
.metric strong { font-size: 19px; }
.metric small { color: var(--muted); }
.metric-total { background: #1d2433; color: #fff; }
.metric-total small { color: #c3c9d4; }

/* Badges de type */
.badge {
    display: inline-block; padding: 3px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 600; width: fit-content;
}
.badge-nom-de-domaine       { background: #e6f0ff; color: #1d4ed8; }
.badge-email                { background: #e7f6ec; color: #1b7a3d; }
.badge-hosted-private-cloud { background: #f3e8ff; color: #7c3aed; }
.badge-serveurs-dedies      { background: #fff1e6; color: #c2410c; }
.badge-xdsl                 { background: #e0f2fe; color: #0369a1; }
.badge-telephonie           { background: #fef3c7; color: #92660b; }
.badge-ip                   { background: #d1fae5; color: #047857; }
.badge-autre                { background: #eceef1; color: #4b5563; }
.badge-total                { background: #374151; color: #fff; }

/* Tableau */
table.lines { width: 100%; border-collapse: collapse; }
table.lines th, table.lines td {
    text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle;
}
table.lines th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.lines th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
table.lines th.sortable:hover { color: var(--ink); }
table.lines th .sort-ind { color: var(--primary); font-size: 11px; }
table.lines .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.lines .desc { max-width: 320px; }
table.lines .billno { white-space: nowrap; font-variant-numeric: tabular-nums; }
.inline-type { display: flex; align-items: center; gap: 6px; margin: 0; }
.inline-type select { padding: 4px 8px; font-size: 12px; font-weight: 600; border-radius: 999px; }
.manual { color: var(--primary); font-weight: 700; }
table.lines td.hf { color: #b42318; font-weight: 600; }
table.lines tr.row-selected { background: #eaf2fd; }
.grp-code { font-size: 11px; }
.kind { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.kind-sip { background: #e0f2fe; color: #0369a1; }
.kind-num { background: #f3e8ff; color: #7c3aed; }
.kind-grp { background: #eceef1; color: #4b5563; }
.kind-trunk { background: #fef3c7; color: #92660b; }
.src { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.src-service { color: var(--ok-ink); }
.src-mots-cles { color: #92660b; }

ol { margin: 0; padding-left: 20px; line-height: 1.7; }

/* Barre de progression de synchronisation */
.progress { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.prog-row { display: flex; align-items: center; gap: 12px; }
.prog-label { width: 80px; font-weight: 600; }
.prog-txt { min-width: 150px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { flex: 1; height: 14px; background: #eceef1; border-radius: 999px; overflow: hidden; }
.bar-fill {
    width: 0; height: 100%; background: linear-gradient(90deg, var(--primary), #3b9bf0);
    border-radius: 999px; transition: width .25s ease;
}
.done-msg { color: var(--ok-ink); font-weight: 600; }
.err-msg { color: var(--err-ink); font-weight: 600; }
