:root {
    --green: #007835;
    --green-dark: #178040;
    --orange: #FD5F00;
    --blue: #2aa3d6;
    --ink: #1d2a24;
    --muted: #6b7d73;
    --bg: #f4f7f5;
    --card: #ffffff;
    --border: #e1e8e3;
    --danger: #c8362f;
    --radius: 12px;
    --shadow: 0 2px 10px rgba(20, 50, 35, 0.06);
}

@font-face {
    font-family: "Google Sans Flex";
    src: url("/assets/font/GoogleSansFlex-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Google Sans Flex";
    src: url("/assets/font/GoogleSansFlex-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Google Sans Flex", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
}

a { color: var(--green-dark); }

/* --- Topbar --- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 60px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.topbar .brand span { color: var(--green); }
.topbar nav { display: flex; align-items: center; gap: 20px; }
.topbar nav a { text-decoration: none; color: var(--muted); font-weight: 500; }
.topbar nav a:hover { color: var(--ink); }

.inline { display: inline; margin: 0; }
button.link {
    background: none; border: 0; padding: 0; cursor: pointer;
    color: var(--muted); font: inherit; font-weight: 500;
}
button.link:hover { color: var(--danger); }

/* --- Layout --- */
.container { max-width: 960px; margin: 0 auto; padding: 32px 24px; }

h1 { font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 28px 0 12px; }
.muted { color: var(--muted); }

/* --- Auth --- */
body.auth {
    display: flex; min-height: 100vh; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
}
.auth-card {
    width: 100%; max-width: 380px; background: var(--card);
    padding: 36px 32px; border-radius: var(--radius); box-shadow: var(--shadow);
}
.logo-block { text-align: center; margin-bottom: 24px; }
.logo-block h1 { font-size: 1.3rem; }
.logo-block p { color: var(--muted); margin: 4px 0 0; }

/* --- Form --- */
.form label { display: block; margin-bottom: 16px; }
.form label span { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.form input {
    width: 100%; padding: 11px 12px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 1rem; background: #fff;
}
.form input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,157,77,.15); }

.btn {
    display: inline-block; padding: 11px 18px; border: 0; border-radius: 8px;
    font-size: 1rem; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn--primary { background: var(--green); color: #fff; }
.btn--primary:hover { background: var(--green-dark); }
.btn--block { display: block; width: 100%; text-align: center; }

/* --- Flash --- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .95rem; }
.flash--error { background: #fdecea; color: var(--danger); }
.flash--success { background: #e7f6ec; color: var(--green-dark); }

/* --- Stat cards --- */
.cards { display: flex; gap: 16px; margin: 24px 0; flex-wrap: wrap; }
.stat-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px 24px; min-width: 160px; box-shadow: var(--shadow);
}
.stat-card__value { display: block; font-size: 2rem; font-weight: 700; color: var(--green); }
.stat-card__label { color: var(--muted); font-size: .9rem; }

.next-steps ul { color: var(--muted); padding-left: 20px; }
.next-steps li { margin-bottom: 6px; }

.stat-card--link { text-decoration: none; transition: box-shadow .15s, transform .15s; }
.stat-card--link:hover { box-shadow: 0 6px 18px rgba(20,50,35,.10); transform: translateY(-1px); }

/* --- Page head --- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
.page-head h1 { margin: 0; }

.btn--sm { padding: 8px 14px; font-size: .9rem; }
.btn--ghost { background: #fff; border: 1px solid var(--border); color: var(--ink); }
.btn--ghost:hover { background: var(--bg); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
.empty { color: var(--muted); padding: 32px; text-align: center; background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius); }

/* --- Table --- */
.table { width: 100%; border-collapse: separate; border-spacing: 0; margin-top: 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.table thead th:first-child { border-top-left-radius: var(--radius); }
.table thead th:last-child { border-top-right-radius: var(--radius); }
.table tbody tr:last-child td:first-child { border-bottom-left-radius: var(--radius); }
.table tbody tr:last-child td:last-child { border-bottom-right-radius: var(--radius); }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafcfb; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { text-align: right; white-space: nowrap; }

.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(0,0,0,.08); vertical-align: middle; margin-right: 2px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge--ok { background: #e7f6ec; color: var(--green-dark); }
.badge--off { background: #f0f0f0; color: var(--muted); }

.link-action { color: var(--green-dark); text-decoration: none; font-weight: 500; font-size: .9rem; margin-left: 12px; background: none; border: 0; cursor: pointer; font-family: inherit; }
.link-action:first-child { margin-left: 0; }
.link-action:hover { text-decoration: underline; }
.link-action--danger { color: var(--danger); }

.emp-name { color: inherit; text-decoration: none; }
.emp-name:hover strong { color: var(--green-dark); text-decoration: underline; }

/* --- Actions dropdown --- */
.menu { position: relative; display: inline-block; }
.menu__toggle { list-style: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--ink); font-size: .88rem; font-weight: 500; cursor: pointer; user-select: none; }
.menu__toggle::-webkit-details-marker { display: none; }
.menu__toggle::after { content: ""; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor; opacity: .55; }
.menu__toggle:hover { background: var(--bg); }
.menu[open] .menu__toggle { background: var(--bg); }
.menu__list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 170px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(20,50,35,.14); padding: 6px; text-align: left; }
.menu__item { display: block; width: 100%; padding: 8px 12px; border: 0; border-radius: 7px; background: none; color: var(--ink); font: inherit; font-size: .9rem; font-weight: 500; text-align: left; text-decoration: none; cursor: pointer; }
.menu__item:hover { background: var(--bg); color: var(--green-dark); }
.menu__item--danger { color: var(--danger); }
.menu__item--danger:hover { background: #fdeeee; color: var(--danger); }
.menu__list form { margin: 0; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }

/* --- Forms wide --- */
.form--wide { max-width: 720px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; margin-top: 16px; box-shadow: var(--shadow); }
.form--wide textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; resize: vertical; }
.form--wide textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,157,77,.15); }
.form label span small { color: var(--muted); font-weight: 400; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }

.color-field input[type=color] { width: 100%; height: 44px; padding: 4px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; }

.field-label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.field-error { display: block; color: var(--danger); font-size: .82rem; margin-top: 4px; }
.upload-field { margin-bottom: 16px; }
.upload-field input[type=file] { font-size: .9rem; }
.thumb { width: 120px; height: 70px; border: 1px solid var(--border); border-radius: 8px; background: #fafcfb; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; overflow: hidden; }
.thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }

.checkbox { display: flex; align-items: center; gap: 8px; font-size: .92rem; margin: 8px 0 16px; }
.checkbox input { width: auto; }

/* Éditeur de métiers (label / couleur / picto) */
.services-editor { margin-bottom: 16px; }
.service-row { display: grid; grid-template-columns: 1fr 110px 220px 40px; gap: 10px; align-items: start; margin-bottom: 10px; }
@media (max-width: 700px) { .service-row { grid-template-columns: 1fr 90px; } }
.service-color { display: flex; flex-direction: column; gap: 4px; }
.service-color input[type=color] { width: 100%; height: 40px; padding: 3px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; }
.service-color input[type=color]:disabled { opacity: .35; cursor: default; }
.service-color .checkbox { margin: 0; font-size: .8rem; }
.service-picto { display: flex; flex-direction: column; gap: 4px; }
.service-picto img { width: 36px; height: 36px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; background: #fafcfb; padding: 3px; }
.service-picto .checkbox { margin: 0; font-size: .8rem; }
.service-picto input[type=file] { font-size: .8rem; }
.service-remove { align-self: center; }
.hint { color: var(--muted); font-size: .85rem; background: #fafcfb; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }

.form-actions { display: flex; gap: 12px; margin-top: 8px; }
.form-actions .btn--primary { width: auto; }

/* --- Actions carte --- */
.card-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 4px; padding: 14px 16px; background: #fafcfb; border: 1px solid var(--border); border-radius: var(--radius); }

/* --- Filtre --- */
.filter-bar { margin: 16px 0; }
.filter-bar label span { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.filter-bar select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; min-width: 220px; }

/* --- Form selects --- */
.form--wide select { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; }
.form--wide select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,157,77,.15); }

/* --- Employé : avatar + cellule --- */
.emp-cell { display: flex; align-items: center; gap: 12px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar--ph { display: inline-flex; align-items: center; justify-content: center; background: var(--green); color: #fff; font-size: .8rem; font-weight: 700; }
.thumb--square { width: 90px; height: 90px; }

/* --- Réseaux sociaux --- */
.socials { border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px 4px; margin: 8px 0 16px; }
.socials legend { font-weight: 600; font-size: .9rem; padding: 0 8px; }

/* --- Statistiques de scan --- */
.table .num, .table th.num { text-align: right; white-space: nowrap; }
.scan-count { text-decoration: none; color: var(--green-dark); }
.scan-count:hover { text-decoration: underline; }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; margin-top: 20px; box-shadow: var(--shadow); }
.panel h2 { margin-top: 0; }
.panel .table { margin-top: 8px; border: 0; box-shadow: none; }
.table--compact td { padding: 8px 12px; }

.stat-card__value--sm { font-size: 1.05rem; }
.note { font-size: .82rem; margin-top: 12px; }

/* Barre de filtres de la page stats */
.stats-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 20px 0 4px; padding: 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.stats-filters label { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.stats-filters label span { font-size: .78rem; font-weight: 600; color: var(--muted); }
.stats-filters select, .stats-filters input[type=date] { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; }
.stats-filters select:focus, .stats-filters input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,157,77,.15); }

/* En-tête de panneau avec contrôle de vue */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head h2 { margin: 0; }

/* Sélecteur segmenté (granularité) */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg__btn { padding: 6px 12px; font-size: .85rem; text-decoration: none; color: var(--muted); background: #fff; border-left: 1px solid var(--border); }
.seg__btn:first-child { border-left: 0; }
.seg__btn:hover { background: var(--bg); }
.seg__btn.is-active { background: var(--green); color: #fff; }

/* En-têtes triables */
.th-sort { color: inherit; text-decoration: none; }
.th-sort:hover { color: var(--ink); text-decoration: underline; }

/* Mini histogramme des scans par jour (sans dépendance JS) */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; margin-top: 8px; padding: 8px 0; }
.bars__col { flex: 1; display: flex; align-items: flex-end; height: 100%; }
.bars__bar { width: 100%; min-height: 2px; background: var(--green); border-radius: 3px 3px 0 0; transition: background .15s; }
.bars__col:hover .bars__bar { background: var(--orange); }
.bars__axis { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin-top: 4px; }
