[hidden] { display: none !important; }
:root {
  color-scheme: light;
  /* Couleurs Yooka : vert #387f4b, crème #fdf9e7 */
  --brand: #387f4b;
  --brand-ink: #fdf9e7;
  --brand-dark: #2c6a3d;
  --page: #f6f1df;
  --surface: #fffcf0;
  --card: #fffdf6;
  --ink: #17261c;
  --ink-2: #4c5a50;
  --muted: #858d7f;
  --grid: #e6dfc8;
  --axis: #c9c1a6;
  --border: rgba(23, 38, 28, 0.11);
  --accent: #387f4b;
  --accent-ink: #fdf9e7;
  --accent-soft: #e4eedf;
  --good: #006300;
  --critical: #d03b3b;
  --warning-bg: #fff6e0;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --seq-0: #f0efec; --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95; --seq-7: #0d366b;
  --radius: 12px;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme='light'])) {
    color-scheme: dark;
    --brand: #387f4b; --brand-ink: #fdf9e7; --brand-dark: #2c6a3d;
    --page: #0f1812; --surface: #16231a; --card: #16231a;
    --ink: #f6f1df; --ink-2: #c4ccbd; --muted: #8b9585; --grid: #24352a; --axis: #33473a;
    --border: rgba(253, 249, 231, 0.1); --accent: #6dbb82; --accent-ink: #0f1812; --accent-soft: #1f3a28;
    --good: #0ca30c; --critical: #e66767; --warning-bg: #3a2f12;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --seq-0: #2c2c2a; --seq-1: #104281; --seq-2: #184f95; --seq-3: #1c5cab; --seq-4: #256abf; --seq-5: #3987e5; --seq-6: #6da7ec; --seq-7: #9ec5f4;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.5; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* En-tête */
.topbar { display: flex; align-items: center; gap: 20px; padding: 10px 24px; background: var(--brand); color: var(--brand-ink); position: sticky; top: 0; z-index: 10; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08); }
.brand { color: var(--brand-ink); text-decoration: none; display: flex; flex-direction: column; align-items: center; gap: 2px; }
/* Le fond vert du logo se confond avec celui de la barre. */
.brand-logo { height: 32px; width: auto; display: block; }
.brand-sub { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; color: var(--brand-ink); opacity: 0.85; line-height: 1; text-align: center; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--s1); box-shadow: 0 0 0 4px var(--accent-soft); }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { color: var(--brand-ink); opacity: 0.85; text-decoration: none; padding: 6px 12px; border-radius: 8px; font-weight: 500; }
.topbar nav a:hover { opacity: 1; background: rgba(253, 249, 231, 0.12); }
.topbar nav a.active { opacity: 1; background: var(--brand-ink); color: var(--brand); }
.topbar > button { background: transparent; color: var(--brand-ink); border-color: rgba(253, 249, 231, 0.45); }
.topbar > button:hover { background: rgba(253, 249, 231, 0.12); }
.user-btn { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 0; line-height: 1.15; padding: 4px 10px; }
.user-btn .user-role { font-size: 11px; opacity: 0.75; }
.api-badge { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid rgba(253, 249, 231, 0.4); color: var(--brand-ink); white-space: nowrap; }
.api-badge.demo { background: #f3c64d; color: #2b2410; border-color: transparent; }

main { max-width: 1240px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } main { padding: 16px; } .topbar { padding: 10px 16px; flex-wrap: wrap; } }
.stack > * + * { margin-top: 16px; }

/* Boutons et formulaires */
button, .btn { font: inherit; border: 1px solid var(--border); background: var(--card); color: var(--ink); padding: 7px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { background: var(--accent-soft); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--critical); }
button:disabled { opacity: 0.55; cursor: default; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--axis); border-radius: 8px; padding: 7px 10px; width: 100%; }
input[type='checkbox'], input[type='radio'] { width: auto; }
label { display: block; font-weight: 600; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { font-weight: 400; color: var(--ink-2); font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 160px; }
.row > select, .row > input:not(.grow) { width: auto; }
.error { color: var(--critical); }
.notice { background: var(--warning-bg); border-radius: 8px; padding: 10px 14px; }

/* Segmented control (période, onglets) */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; padding: 2px; background: var(--card); }
.seg button { border: 0; padding: 5px 12px; border-radius: 7px; background: transparent; color: var(--ink-2); }
.seg button.on { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 10px 14px; color: var(--ink-2); white-space: nowrap; }
.tabs button.on { border-bottom-color: var(--accent); color: var(--ink); font-weight: 600; }

/* Tuiles chiffres */
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .label { color: var(--ink-2); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 650; margin-top: 2px; }
.stat .sub { color: var(--ink-2); font-size: 12px; margin-top: 2px; }
.delta-up { color: var(--good); }
.delta-down { color: var(--critical); }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--axis); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
tr.client td { background: var(--accent-soft); font-weight: 600; }
th.sortable { cursor: pointer; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: baseline; }
.bar-cell { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.bar-cell .bar { height: 8px; border-radius: 0 4px 4px 0; background: var(--s1); min-width: 2px; }
.thumb { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; background: var(--grid); display: block; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--ink-2); margin: 2px 4px 0 0; white-space: nowrap; }
.tag.pay { border-color: var(--critical); color: var(--critical); }
.title-cell a { color: var(--ink); text-decoration: none; font-weight: 550; }
.title-cell a:hover { text-decoration: underline; }

/* Graphiques */
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 360px; }
.chart-box.short { height: 220px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; }
.legend-item { border: 0; background: none; padding: 2px 6px; margin: -2px -6px; border-radius: 6px; color: var(--ink-2); font-size: 13px; display: inline-flex; align-items: center; }
.legend-item:hover { background: var(--accent-soft); color: var(--ink); }
.legend-item.off { opacity: 0.45; text-decoration: line-through; }
.legend-item.off .swatch { background: var(--axis) !important; }

/* Carte de chaleur heures × jours */
.heat { display: grid; grid-template-columns: 36px repeat(24, minmax(0, 1fr)); gap: 2px; font-size: 11px; color: var(--muted); }
.heat .cell { aspect-ratio: 1.3; border-radius: 3px; background: var(--seq-0); position: relative; }
.heat .cell:hover { outline: 2px solid var(--ink); }
.heat .hl { text-align: center; }
.heat-scale { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); margin-top: 8px; }
.heat-scale i { width: 18px; height: 10px; border-radius: 2px; display: inline-block; }

/* Info-bulle */
.tip { position: fixed; pointer-events: none; background: var(--card); color: var(--ink); border: 1px solid var(--border); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); padding: 6px 10px; border-radius: 8px; font-size: 12px; z-index: 100; display: none; max-width: 280px; }

/* Publications sociales */
.social-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.social-card { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; color: inherit; text-decoration: none; background: var(--surface); }
.social-card:hover { border-color: var(--accent); }
.social-card.followed { box-shadow: 0 0 0 2px var(--accent); }
.social-card img, .social-card .ph { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: var(--grid); display: block; }
.social-card .body { padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.social-card .title { font-size: 13px; font-weight: 550; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Cartes projets */
.project-card { display: block; text-decoration: none; color: inherit; transition: border-color 0.15s; }
.project-card:hover { border-color: var(--accent); }
.project-card .kpis { display: flex; gap: 24px; margin-top: 14px; }
.project-card .kpis b { display: block; font-size: 22px; }
.mini-bars { margin-top: 14px; }
.mini-bars .r { display: grid; grid-template-columns: 120px 1fr 36px; gap: 8px; align-items: center; font-size: 12px; margin-top: 4px; }
.mini-bars .r .b { height: 8px; border-radius: 0 4px 4px 0; }
.mini-bars .r span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Fenêtre modale */
dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; width: min(640px, calc(100vw - 32px)); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog form { padding: 22px; }
dialog .actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.site-row { display: grid; grid-template-columns: 1fr 32px; gap: 8px; margin-bottom: 8px; }
.site-row button { padding: 0; justify-content: center; }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--axis); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
pre { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow: auto; max-height: 480px; font-size: 12px; }

/* Connexion */
.login { max-width: 360px; margin: 12vh auto; }
.login-page { background: var(--brand); }
.login-page .login { box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18); }

/* Administration */
.card-off { opacity: 0.7; }
.user-actions { text-align: right; }
.user-actions button { margin: 2px 0 2px 4px; padding: 5px 10px; font-size: 13px; }
.project-picker { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.project-picker .pick { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; padding: 5px 8px; border-radius: 8px; cursor: pointer; }
.project-picker .pick:hover { background: var(--accent-soft); }
.project-picker .pick.on { background: var(--accent-soft); font-weight: 600; }
