:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1d2430;
    --muted: #6b7380;
    --border: #e1e4ea;
    --primary: #3b6fd4;
    --primary-text: #ffffff;
    --sidebar: #1d2430;
    --sidebar-text: #c9cfda;
    --error-bg: #fdeaea;
    --error-text: #a12626;
    --ok-bg: #e5f5ec;
    --ok-text: #1f6e42;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14181f;
        --surface: #1c222c;
        --text: #e8ebf0;
        --muted: #98a1af;
        --border: #2d3542;
        --sidebar: #0f1218;
        --error-bg: #3a1c1c;
        --error-text: #f2a3a3;
        --ok-bg: #173126;
        --ok-text: #8fd9b0;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--primary); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .75rem; }
.muted { color: var(--muted); }
.right { text-align: right; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1.5rem; }
.sidebar a { color: inherit; text-decoration: none; }
.brand { font-weight: 700; font-size: 1.1rem; color: #fff !important; }
.sidebar nav { display: flex; flex-direction: column; gap: .25rem; }
.sidebar nav a { padding: .5rem .75rem; border-radius: 8px; }
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255, 255, 255, .1); color: #fff; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }

.content { padding: 2rem; min-width: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.head h1 { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; }
.card.narrow { max-width: 520px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.stat-n { font-size: 2rem; font-weight: 700; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .35rem; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .5rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }
tr:last-child td { border-bottom: 0; }

label { display: block; font-weight: 600; margin: .9rem 0 .3rem; font-size: .9rem; }
input[type=text], input[type=email], input[type=password], textarea, select {
    width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font: inherit;
}
input[type=color] { width: 4rem; height: 2.4rem; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
select { width: auto; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }

.btn {
    display: inline-block; margin: 1.2rem .75rem 0 0; padding: .6rem 1.1rem; border: 0; border-radius: 8px;
    background: var(--primary); color: var(--primary-text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.head .btn { margin: 0; }

.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-success { background: var(--ok-bg); color: var(--ok-text); }
.flash-error { background: var(--error-bg); color: var(--error-text); }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { margin-bottom: .25rem; }

.form-error, .invalid-feedback { color: var(--error-text); font-size: .85rem; }
.invalid-feedback, ul.form-errors { list-style: none; padding: 0; margin: .25rem 0 0; }

h3 { font-size: 1rem; margin: 1.5rem 0 0; }
.head-actions { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .85rem; margin-top: .75rem; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; color: #fff; font-size: .8rem; font-weight: 600; }
.caption { white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: .75rem 1rem; margin: 1rem 0; }

.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; text-decoration: underline; }
.link-btn.danger { color: var(--error-text); }
.danger-zone { margin-top: 1.5rem; }

/* Médiathèque */
.small { font-size: .85rem; }
.upload { margin-bottom: 1rem; }
.upload-form { display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; }
.upload-form .btn { margin: 0; }
.upload-form input[type=file] { max-width: 100%; }
.chips { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
.chips a { padding: .25rem .8rem; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; color: var(--text); font-size: .9rem; }
.chips a.active { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; margin-top: 1rem; }
.media-grid.compact { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
.tile { position: relative; display: block; aspect-ratio: 1; padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: var(--bg); cursor: pointer; }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-badge { position: absolute; left: 6px; bottom: 6px; background: rgba(0, 0, 0, .65); color: #fff; font-size: .7rem; padding: .05rem .4rem; border-radius: 4px; }
.tile.selected { border-color: var(--primary); }
.tile .order { position: absolute; right: 6px; top: 6px; min-width: 1.5rem; height: 1.5rem; padding: 0 .3rem; display: grid; place-items: center; border-radius: 999px; background: var(--primary); color: #fff; font-size: .8rem; font-weight: 700; }
.tile .order[hidden] { display: none; }
.picker { margin: 1rem 0; }
.picker-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.picker-head h3 { margin: 0; }
.preview img, .preview video { max-width: 100%; max-height: 420px; border-radius: 8px; display: block; margin: 0 auto; }

/* Page publique de validation client */
body.public { background: var(--bg); }
.public-head { background: var(--surface); border-bottom: 1px solid var(--border); padding: .9rem 1rem; }
.public-inner { max-width: 680px; margin: 0 auto; padding: 0 1rem; }
.public-head .public-inner { padding: 0; display: flex; gap: .75rem; align-items: baseline; flex-wrap: wrap; }
main.public-inner { padding-top: 1.5rem; padding-bottom: 3rem; }
.vpost { margin-bottom: 1.25rem; }
.vpost.done { opacity: .85; }
.vmeta { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.vform textarea { resize: vertical; }
.vactions { display: flex; gap: .75rem; flex-wrap: wrap; }
.btn.ok { background: #2e9e5b; }
.btn.warn { background: #d97706; }
.vcomment { margin: .75rem 0 0; padding: .6rem .8rem; border-radius: 8px; background: var(--bg); border-left: 4px solid var(--border); }
.vcomment.change { border-left-color: #d64545; }
.btn-secondary { display: inline-block; margin: 0; padding: .55rem 1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.publish-list { max-width: 680px; }
.publish-actions { align-items: center; margin-top: 1rem; }
.publish-actions .btn { margin: 0; }
.vpost .btn-secondary { margin-top: .25rem; }
.due-callout { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
/* Espace client : onglets, cartes, listes */
.space-head { margin-bottom: 1.25rem; }
.space-title { display: flex; align-items: center; gap: .5rem; font-size: 1.15rem; margin-bottom: .6rem; }
.space-tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--border); -webkit-overflow-scrolling: touch; }
.space-tabs a { white-space: nowrap; padding: .55rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.space-tabs a.active { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }
.client-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.client-card { display: flex; flex-direction: column; gap: .4rem; text-decoration: none; color: var(--text); }
.client-card:hover { border-color: var(--primary); }
.client-card-name { font-size: 1.05rem; }
.client-card-badges { display: flex; flex-wrap: wrap; gap: .35rem; min-height: 1.4rem; }
.list-card { padding: 0; overflow: hidden; }
.row-link { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .8rem 1rem; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--border); }
.row-link:last-child { border-bottom: 0; }
.row-link:hover { background: var(--bg); }
.caption-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; text-align: right; }
.chip-static { display: inline-block; padding: .2rem .7rem; margin: 0 .35rem .35rem 0; border: 1px solid var(--border); border-radius: 999px; font-size: .9rem; }
.table-wrap { overflow-x: auto; }
td.actions { white-space: normal; }
td.actions form { display: inline-block; margin-left: .75rem; }
.flash-secret { background: #fff7d6; color: #5c4600; border: 1px solid #e8c547; font-family: ui-monospace, Consolas, monospace; word-break: break-all; user-select: all; }
@media (prefers-color-scheme: dark) { .flash-secret { background: #3b3210; color: #f5dd8a; border-color: #8a7220; } }

.revisions { margin: 1rem 0; max-width: 680px; }
.revisions summary { cursor: pointer; font-weight: 600; }
.revision { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.rev-cols { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 640px) { .rev-cols { grid-template-columns: 1fr; } }
.review-form { margin-top: 1rem; }
.comments { margin-bottom: 1rem; max-width: 520px; }
.comments h3 { margin-top: 0; }

/* Grille (profil Instagram : 3 colonnes, tuiles portrait 3:4) */
.grid-wrap { max-width: 520px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.grid3.saving { opacity: .6; pointer-events: none; }
.gtile { position: relative; aspect-ratio: 3 / 4; overflow: hidden; background: var(--bg); cursor: grab; user-select: none; }
.grid3.fixed .gtile { cursor: default; }
.gtile img, .gtile video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.gtext { height: 100%; padding: .6rem; font-size: .75rem; line-height: 1.3; color: var(--muted); overflow: hidden; display: flex; align-items: center; text-align: center; }
.gstatus { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; }
.gdate { position: absolute; left: 4px; bottom: 8px; background: rgba(0, 0, 0, .65); color: #fff; font-size: .68rem; padding: 0 .3rem; border-radius: 4px; }
.gcount { position: absolute; right: 4px; bottom: 8px; background: rgba(0, 0, 0, .65); color: #fff; font-size: .68rem; padding: 0 .3rem; border-radius: 4px; }
.gopen { position: absolute; right: 4px; top: 4px; width: 1.6rem; height: 1.6rem; display: grid; place-items: center; border-radius: 999px; background: rgba(0, 0, 0, .65); color: #fff; text-decoration: none; font-size: .85rem; opacity: 0; transition: opacity .15s; }
.gtile:hover .gopen, .gtile:focus-within .gopen { opacity: 1; }
@media (hover: none) { .gopen { opacity: 1; } }
.gtile-ghost { opacity: .4; }

/* FullCalendar : s'aligne sur le thème clair/sombre */
.fc { --fc-border-color: var(--border); --fc-page-bg-color: var(--surface); --fc-neutral-bg-color: var(--bg);
      --fc-today-bg-color: rgba(59, 111, 212, .1); --fc-button-bg-color: var(--primary); --fc-button-border-color: var(--primary);
      --fc-button-hover-bg-color: var(--primary); --fc-button-hover-border-color: var(--primary);
      --fc-button-active-bg-color: var(--primary); --fc-button-active-border-color: var(--primary); }
.fc .fc-event { cursor: pointer; }

@media (max-width: 760px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { flex-direction: row; align-items: center; flex-wrap: wrap; gap: .75rem; padding: .75rem 1rem; }
    .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; gap: .75rem; }
    .content { padding: 1rem; }
}

/* ===== Calendrier visuel ===== */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* Icônes de réseaux (sprite) */
.pi { vertical-align: middle; flex: none; }
.pi-instagram { color: #d6249f; }
.pi-facebook { color: #1877f2; }
.pi-linkedin { color: #0a66c2; }
.pi-tiktok, .pi-x, .pi-threads { color: var(--text); }
.pi-youtube { color: #ff0000; }
.pi-pinterest { color: #e60023; }

/* Filtres */
.filters { margin-bottom: 1rem; }
.filters-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .6rem 1rem; }
.filters-panel summary { cursor: pointer; font-weight: 600; }
.filter-group { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .75rem; }
.filter-label { min-width: 4.5rem; font-size: .85rem; color: var(--muted); font-weight: 600; }
.fchip { margin: 0; font-weight: 400; cursor: pointer; }
.fchip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.fchip > span { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .75rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: .88rem; min-height: 2rem; }
.fchip-icon > span { padding: .3rem .5rem; }
.fchip input:checked + span { border-color: var(--primary); background: rgba(59, 111, 212, .12); font-weight: 600; }
.fchip input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.filters-panel > a { display: inline-block; margin-top: .75rem; }

/* Événements du calendrier */
.cal-card { padding: .75rem; }
.fc .fc-toolbar { flex-wrap: wrap; gap: .5rem; }
.fc .fc-toolbar-title { font-size: 1.15rem; }
.fc .fc-event.ev, .fc .fc-daygrid-event.ev { background: transparent; border: 0; cursor: pointer; }
.ev-card { display: flex; align-items: center; gap: .35rem; width: 100%; min-width: 0; padding: 2px 4px 2px 3px; border-left: 4px solid var(--evc, var(--primary)); border-radius: 4px; background: var(--surface); color: var(--text); font-size: .75rem; line-height: 1.25; box-shadow: 0 0 0 1px var(--border); overflow: hidden; }
.ev-card:hover { box-shadow: 0 0 0 1px var(--evc, var(--primary)); }
.ev-thumb { width: 28px; height: 28px; flex: none; border-radius: 4px; object-fit: cover; background: var(--bg); display: grid; place-items: center; font-size: .7rem; color: var(--muted); }
.ev-thumb-video { background: #222; color: #fff; }
.ev-body { min-width: 0; flex: 1; }
.ev-top { display: flex; align-items: center; gap: .3rem; }
.ev-time { color: var(--muted); }
.ev-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-format { padding: 0 .3rem; border-radius: 3px; background: var(--bg); color: var(--muted); font-size: .65rem; font-weight: 600; text-transform: uppercase; }
.ev-format-story { background: #fde7f3; color: #b4236e; }
.ev-format-reel { background: #e8e4fb; color: #5a3fc0; }
.ev-card-compact { padding: 1px 3px; }
.ev-card-compact .ev-title { display: none; }
.ev-card-list { padding: .4rem .6rem .4rem .4rem; font-size: .9rem; gap: .65rem; box-shadow: none; border-left-width: 5px; white-space: normal; }
.ev-card-list .ev-thumb { width: 48px; height: 48px; }
.ev-card-list .ev-title { white-space: normal; }
.ev-meta { display: flex; align-items: center; gap: .5rem; margin-top: .15rem; }
.ev-hl { display: flex; align-items: center; gap: .3rem; padding: 0 4px; font-size: .72rem; font-weight: 600; color: #8a5a00; background: #fff3cf; border-radius: 4px; overflow: hidden; }
.ev-star { color: #e8a317; }
@media (prefers-color-scheme: dark) { .ev-hl { color: #f5dd8a; background: #3b3210; } .ev-format-story { background: #4a1f37; color: #f3a6cf; } .ev-format-reel { background: #2f2855; color: #c6b8ff; } }
.fc .fc-event.ev-highlight { background: transparent; border: 0; }

/* Vue annuelle */
.year-nav { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.ymonth { padding: .9rem; }
.ymonth-title { display: flex; justify-content: space-between; align-items: center; margin: 0 0 .5rem; font-size: 1rem; }
.ymonth-title a { text-decoration: none; color: var(--text); }
.ycal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.yh { text-align: center; font-size: .7rem; color: var(--muted); font-weight: 600; }
.yd { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; min-height: 2.5rem; padding: 2px 0; border-radius: 6px; text-decoration: none; color: var(--text); font-size: .8rem; }
a.yd:hover { background: var(--bg); }
.yd-empty { pointer-events: none; }
.yd.has { background: var(--bg); font-weight: 600; }
.yd.hl { box-shadow: inset 0 0 0 1px #e8a317; }
.yd-star { position: absolute; top: 0; right: 2px; font-size: .6rem; color: #e8a317; }
.yd-dots { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; margin-top: 2px; }
.ydot { width: 6px; height: 6px; border-radius: 50%; }
.year-marks { list-style: none; margin: .6rem 0 0; padding: .5rem 0 0; border-top: 1px solid var(--border); font-size: .8rem; display: grid; gap: .2rem; }
.year-marks strong { display: inline-block; min-width: 1.5rem; color: #e8a317; }
@media (max-width: 760px) {
    .yd { min-height: 2.9rem; font-size: .85rem; }
    .cal-card { padding: .4rem; }
    .fc .fc-toolbar-title { font-size: 1rem; }
    .filter-label { min-width: 100%; }
}

/* Mobile : barre du haut compacte, navigation sur une ligne défilable */
@media (max-width: 760px) {
    .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .3rem .75rem; padding: .6rem 1rem; }
    .brand { font-size: 1rem; }
    .sidebar nav { order: 3; flex-direction: row; width: 100%; gap: .25rem; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: .1rem; }
    .sidebar nav a { white-space: nowrap; padding: .4rem .7rem; }
    .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; gap: .75rem; font-size: .82rem; }
    .sidebar-foot span { display: none; }
    .head { align-items: flex-start; }
}

/* ===== Statistiques & graphiques =====
   Palette catégorielle du guide de visualisation, validée (clair : surface #fcfcfb, sombre : #1a1a19) ;
   la couleur suit le compte (emplacement fixe), jamais le rang ni le filtre. */
:root {
    --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
    --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
    --viz-grid: #e1e0d9; --viz-axis: #c3c2b7; --viz-muted: #898781; --viz-ink2: #52514e;
    --viz-up: #006300; --viz-down: #d03b3b;
}
@media (prefers-color-scheme: dark) {
    :root {
        --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
        --series-5: #d55181; --series-6: #0ca30c; --series-7: #9085e9; --series-8: #e66767;
        --viz-grid: #2c2c2a; --viz-axis: #383835; --viz-ink2: #c3c2b7;
        --viz-up: #0ca30c; --viz-down: #e66767;
    }
}

.stats-filters { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: end; margin-bottom: 1.25rem; }
.stats-filters label { margin: 0; font-size: .85rem; color: var(--muted); font-weight: 600; display: grid; gap: .25rem; }
.stats-filters select { min-width: 10rem; max-width: 100%; }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi { display: flex; flex-direction: column; gap: .2rem; padding: 1rem; }
.kpi-label { font-size: .85rem; color: var(--muted); }
.kpi-value { font-size: 1.75rem; font-weight: 700; line-height: 1.15; }   /* chiffres proportionnels (pas de tabular-nums) */
.kpi-delta { font-size: .82rem; font-weight: 600; }
.kpi-delta.up { color: var(--viz-up); }
.kpi-delta.down { color: var(--viz-down); }
.kpi-delta .muted { font-weight: 400; }
.kpi-note { font-size: .78rem; }
.kpi-spark { min-height: 28px; margin-top: .25rem; }
.spark { display: block; }

.viz { padding: 1rem 1.25rem 1.25rem; margin-bottom: 1.5rem; position: relative; }
.viz-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; }
.viz-title { margin: 0; font-size: 1rem; }
.viz-tabs { display: flex; flex-wrap: wrap; gap: .35rem; }
.viz-tab { border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .85rem; padding: .3rem .75rem; border-radius: 999px; cursor: pointer; min-height: 2rem; }
.viz-tab[aria-pressed="true"] { border-color: var(--primary); background: rgba(59, 111, 212, .12); font-weight: 600; }
.viz-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.viz-legend { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; margin: .75rem 0 .25rem; font-size: .85rem; color: var(--viz-ink2); }
.viz-legend:empty { display: none; }
.viz-legend-item { display: inline-flex; align-items: center; gap: .4rem; }
.viz-key { display: inline-block; flex: none; }
.viz-key-line { width: 14px; height: 2px; border-radius: 1px; }
.viz-key-box { width: 10px; height: 10px; border-radius: 2px; }
.viz-canvas { position: relative; margin-top: .5rem; }
.viz-canvas svg { display: block; overflow: visible; }
.viz-empty { padding: 3rem 0; text-align: center; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-axis { stroke: var(--viz-axis); stroke-width: 1; }
.viz-tick { fill: var(--viz-muted); font-size: 11px; font-family: inherit; }
.viz-direct { font-size: 11px; font-family: inherit; }
.viz-direct-name { fill: var(--viz-ink2); }
.viz-direct-value { fill: var(--text); font-weight: 700; }
.viz-cross { stroke: var(--viz-axis); stroke-width: 1; pointer-events: none; }
.viz-hit { outline: none; cursor: crosshair; }
.viz-hit:focus-visible { stroke: var(--primary); stroke-width: 2; }
.viz-col.is-hot .viz-bar { filter: brightness(1.12); }
.viz-tooltip { position: absolute; z-index: 5; top: 0; left: 0; pointer-events: none; min-width: 170px; max-width: 280px; padding: .55rem .7rem; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 14px rgba(0, 0, 0, .12); font-size: .82rem; }
.viz-canvas + .viz-tooltip, .viz-legend ~ .viz-tooltip { margin-top: 0; }
.viz-tip-title { font-weight: 600; margin-bottom: .3rem; }
.viz-tip-row { display: flex; align-items: center; gap: .5rem; padding: .1rem 0; }
.viz-tip-value { min-width: 3.5rem; text-align: right; }   /* la valeur domine, le nom suit */
.viz-tip-name { color: var(--viz-ink2); }
.viz-tip-total { margin-top: .25rem; padding-top: .3rem; border-top: 1px solid var(--border); }

.data-table th.num, .data-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table tbody th, .data-table tfoot th { font-weight: 600; text-align: left; white-space: nowrap; }
.data-table tfoot td, .data-table tfoot th { border-top: 2px solid var(--border); font-weight: 700; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .5rem; }
.entry-table input { width: 100%; min-width: 5.5rem; text-align: right; padding: .4rem .5rem; }
@media (max-width: 760px) {
    .viz { padding: .85rem; }
    .kpi-value { font-size: 1.5rem; }
    .viz-tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: .15rem; }
    .viz-tab { white-space: nowrap; }
}

/* Statistiques : six tuiles sur une ligne en bureau ; pas de filet sous la dernière ligne (cellules d'en-tête comprises) */
.kpi-row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.data-table tbody tr:last-child th, .data-table tbody tr:last-child td { border-bottom: 0; }

/* Campagnes Ads : jauge de budget consommé (piste = teinte claire de la même couleur ; dépassement signalé par le libellé en plus de la couleur) */
.meter { display: block; width: 100%; min-width: 80px; max-width: 160px; height: 6px; margin-top: .3rem; border-radius: 999px; background: rgba(59, 111, 212, .18); overflow: hidden; margin-left: auto; }
.meter > span { display: block; height: 100%; background: var(--series-1); border-radius: 999px; }
.meter > span.over { background: var(--viz-down); }
td.num .meter { margin-left: auto; }
p .meter { display: inline-block; vertical-align: middle; width: 120px; margin: 0 0 0 .5rem; }

/* Ajustements : pastilles sur une ligne, pas de filet sous le total, sept tuiles sur une ligne en bureau */
.badge { white-space: nowrap; }
.data-table tfoot th, .data-table tfoot td { border-bottom: 0; }
.kpi-row { grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); }

/* ===== Plan de communication ===== */
.plan-head h1 { margin-bottom: .25rem; }
.plan-summary { border-left: 4px solid var(--primary); }
.plan-summary h2, .plan-section h2 { margin-top: 0; font-size: 1.15rem; }
.plan-toc { margin-bottom: 1rem; }
.plan-toc ol { margin: .5rem 0 0; padding-left: 1.25rem; columns: 2; column-gap: 2rem; }
.plan-toc li { break-inside: avoid; margin: .15rem 0; }
.plan-section { margin-bottom: 1rem; scroll-margin-top: 1rem; }
.plan-body { max-width: 72ch; }
.plan-body p { margin: 0 0 .75rem; }
.plan-body ul { margin: 0 0 .75rem; padding-left: 1.25rem; }
.plan-body li { margin: .2rem 0; }
.plan-body h4 { margin: 1rem 0 .4rem; font-size: 1rem; }
.plan-body > :last-child { margin-bottom: 0; }
.plan-highlights { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.plan-highlights strong { display: inline-block; min-width: 3rem; }
.plan-admin { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin: 1.5rem 0 1rem; }
.plan-admin form { margin: 0; }
.plan-newyear { max-width: 360px; }
.inline-form { display: flex; gap: .5rem; align-items: center; }
.inline-form input { max-width: 8rem; }
.plan-help { margin-bottom: 1rem; }
.plan-help summary { cursor: pointer; font-weight: 600; }
.plan-help code { background: var(--bg); padding: 0 .3rem; border-radius: 4px; }
.plan-form textarea { resize: vertical; }
.section-edit { margin-bottom: 1rem; scroll-margin-top: 1rem; }
.section-edit-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.section-edit-head label { margin: 0; }
.section-tools { display: flex; align-items: center; gap: .5rem; }
.icon-btn { min-width: 2.25rem; padding: .3rem .5rem; }
.icon-btn:disabled { opacity: .4; cursor: default; }
.plan-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 2rem; }
.plan-actions .btn, .plan-actions .btn-secondary { margin: 0; }
@media (max-width: 760px) { .plan-toc ol { columns: 1; } }

/* Impression / PDF : on ne garde que le contenu du plan */
@media print {
    .sidebar, .no-print, .space-tabs, .flash, .head-actions { display: none !important; }
    .shell { display: block; }
    .content { padding: 0; }
    body { background: #fff; color: #000; }
    .card { border: 0; padding: 0; background: transparent; break-inside: avoid; }
    .plan-section, .plan-summary { margin-bottom: 1rem; border: 0; }
}

/* Mobile : les onglets d'espace passent à la ligne plutôt que de défiler hors de l'écran (onglets cachés = onglets introuvables) */
@media (max-width: 760px) {
    .space-tabs { flex-wrap: wrap; overflow-x: visible; }
    .space-tabs a { padding: .45rem .7rem; }
}

/* ===== Passe mobile ===== */

/* Tous les champs : même style que les champs texte (dates, nombres, fichiers compris). */
input[type=date], input[type=datetime-local], input[type=number], input[type=url], input[type=search], input[type=tel] {
    width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font: inherit;
}
input[type=file] { font: inherit; }
/* Cases à cocher : cible tactile confortable, couleur de l'application. */
input[type=checkbox], input[type=radio] { width: 1.25rem; height: 1.25rem; margin: 0; flex: none; accent-color: var(--primary); }
/* Choix multiples Symfony (case + libellé) : chaque case sur sa ligne, alignée avec son libellé. */
form div:has(> input[type=checkbox] + label) { display: grid; grid-template-columns: auto 1fr; gap: .55rem .6rem; align-items: center; margin-top: .3rem; }
form div:has(> input[type=checkbox] + label) > label { margin: 0; font-weight: 400; }
.check { gap: .6rem; }

@media (max-width: 760px) {
    /* Les éléments de grille/flex ne rétrécissent pas sous leur contenu par défaut : sans min-width 0, la barre de
       navigation de l'équipe (6 liens) imposait ~600 px et toute la page s'affichait dézoomée sur téléphone. */
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar, .sidebar nav, .content { min-width: 0; max-width: 100%; }
    .sidebar nav { flex-wrap: wrap; overflow-x: visible; gap: .2rem; }
    .sidebar nav a { padding: .35rem .6rem; }

    /* 16 px minimum dans les champs : en dessous, iOS zoome automatiquement à chaque saisie. */
    input, select, textarea, .stats-filters select { font-size: 16px; }

    /* Tableaux de type liste : une ligne = un bloc empilé. */
    .stack-table thead { display: none; }
    .stack-table, .stack-table tbody, .stack-table tr, .stack-table td, .stack-table th { display: block; width: 100%; }
    .stack-table tr { padding: .65rem 0; border-bottom: 1px solid var(--border); }
    .stack-table tr:last-child { border-bottom: 0; }
    .stack-table td, .stack-table th { border: 0; padding: .1rem 0; text-align: left; }
    .stack-table td.right { text-align: left; margin-top: .25rem; }
    .stack-table td.actions form { margin: .25rem 1rem 0 0; }

    .head { gap: .75rem; }
    .head h1 { font-size: 1.4rem; }
    .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
    .stat { padding: .75rem; }
    .stat-n { font-size: 1.5rem; }
    .client-cards { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .head-actions { min-width: 0; max-width: 100%; }
    .head-actions select, .head-actions form, .stats-filters select { max-width: 100%; }
    .head-actions form { width: 100%; }
    .head-actions select { width: 100%; }
}
/* Écrans tactiles : cases à cocher de 24 px (taille de cible minimale recommandée). */
@media (pointer: coarse) { input[type=checkbox], input[type=radio] { width: 24px; height: 24px; } }

/* ---------- Modèles de légendes ---------- */
.tpl-list { display:grid; grid-template-columns:repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap:1rem; }
.tpl-card { display:flex; flex-direction:column; gap:.6rem; min-width:0; margin:0; }
.tpl-head { display:flex; flex-wrap:wrap; justify-content:space-between; align-items:baseline; gap:.3rem .8rem; }
.tpl-body { white-space:pre-wrap; overflow-wrap:anywhere; font-size:.92rem; max-height:12rem; overflow:auto; background:var(--bg); border-radius:8px; padding:.6rem .7rem; flex:1; }
.tpl-actions { display:flex; gap:1rem; align-items:center; }
.tpl-actions form { margin:0; }
details.card > summary { cursor:pointer; padding:.2rem 0; }
details.card[open] > summary { margin-bottom:.6rem; }
.caption-tools { margin-bottom:.4rem; }
.caption-count { margin:.3rem 0 .8rem; }
.caption-count.is-over { color:var(--error-text); font-weight:600; }