/* ================= BASE ================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--fb);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: var(--focus); outline-offset: 2px; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: var(--r);
  font-family: var(--fm); font-size: 13px;
}
.skip-link:focus { top: 12px; }
#page-title:focus, #content:focus { outline: none; }
.num { font-family: var(--fm); font-variant-numeric: tabular-nums; }

/* ================= LAYOUT ================= */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--d-bg); color: var(--d-text);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 22px 16px;
  border-right: 1px solid var(--d-line);
}
.brand {
  font-family: var(--fd); font-weight: 700; font-size: 22px; letter-spacing: -.035em;
  display: flex; align-items: center; gap: 10px; padding: 0 8px 22px;
  border-bottom: 1px solid var(--d-line);
}
.brand b {
  width: 34px; height: 34px; border-radius: var(--r-sm); background: var(--accent);
  display: grid; place-items: center; color: var(--surface); font-size: 16px; letter-spacing: -.1em;
}
.brand small { display: block; font-family: var(--fm); font-weight: 400; font-size: 10.5px; letter-spacing: .08em; color: var(--d-dim); text-transform: uppercase; }

.nav { margin-top: 22px; display: flex; flex-direction: column; gap: 2px; }
.nav__label { font-family: var(--fm); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--d-dim); padding: 8px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500; color: var(--d-dim);
  border-left: 2px solid transparent; transition: background .15s, color .15s;
}
.nav a:hover { color: var(--d-text); background: rgba(255,255,255,.04); }
.nav a[aria-current="page"] { color: var(--d-text); background: rgba(255,255,255,.06); border-left-color: var(--accent); }
.nav svg { width: 17px; height: 17px; flex: none; }
.nav .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin: 0 4px; }
.sidebar__foot { margin-top: auto; font-family: var(--fm); font-size: 11px; color: var(--d-dim); padding: 16px 10px 0; border-top: 1px solid var(--d-line); letter-spacing: .03em; }
.sidebar__foot b { color: var(--accent); font-weight: 500; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(251, 250, 246, .96); backdrop-filter: blur(8px);
  border-bottom: var(--border);
  min-height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px clamp(16px, 3vw, 36px);
}
.topbar__title { display: flex; flex-direction: column; min-width: 0; }
.eyebrow {
  font-family: var(--fm); font-weight: 500; font-size: 11.5px; letter-spacing: .065em;
  text-transform: uppercase; color: var(--accent);
  display: inline-flex; align-items: center; gap: 10px;
}
.eyebrow::before { content: ""; width: 22px; height: 2px; background: var(--accent); }
h1.page-title { font-family: var(--fd); font-weight: 700; font-size: clamp(22px, 2.6vw, 30px); letter-spacing: -.035em; line-height: 1.05; }
.menu-toggle {
  display: none; background: none; border: 1px solid var(--ink); border-radius: var(--r);
  width: 44px; height: 44px; cursor: pointer; place-items: center; flex: none;
}
.menu-toggle svg { width: 20px; height: 20px; }

.content { padding: clamp(18px, 3vw, 36px); width: 100%; max-width: var(--max); display: flex; flex-direction: column; gap: 24px; }

/* ================= SEGMENTED (reprend .tabs__nav) ================= */
.seg {
  display: inline-flex; gap: 4px; padding: 5px;
  background: var(--surface); border: var(--border); border-radius: var(--r);
}
.seg button {
  font-family: var(--fb); font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent; border-radius: var(--r-sm);
  padding: 8px 14px; min-height: 36px; background: transparent; cursor: pointer; color: var(--gray);
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }

/* ================= BUTTONS ================= */
.btn {
  font-family: var(--fb); font-weight: 500; font-size: 13.5px;
  min-height: 44px; padding: 11px 18px; border-radius: var(--r);
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid transparent; transition: background .18s, color .18s;
}
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-d); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-ghost:hover { background: var(--paper); }

/* ================= CARDS ================= */
.card {
  background: var(--surface); border: var(--border); border-radius: var(--r);
  box-shadow: var(--shadow); padding: clamp(16px, 2vw, 24px); min-width: 0;
}
.card--feat { border-top: 3px solid var(--accent); }
.card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line-2); }
.card__title { font-family: var(--fd); font-weight: 700; font-size: 19px; letter-spacing: -.025em; line-height: 1.15; }
.card__sub { font-family: var(--fm); font-size: 11.5px; color: var(--gray); letter-spacing: .03em; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 2fr 1fr; }
.grid-2-eq { grid-template-columns: 1fr 1fr; }

/* ================= KPI (reprend .mini-grid) ================= */
.kpis {
  display: grid; grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr));
  border-top: var(--border); border-left: var(--border); background: var(--surface); border-radius: var(--r); overflow: hidden;
}
.kpi { padding: 18px 20px 20px; border-right: var(--border); border-bottom: var(--border); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi__label { font-family: var(--fm); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--gray); }
.kpi__value { font-family: var(--fd); font-weight: 700; font-size: clamp(26px, 2.6vw, 34px); letter-spacing: -.035em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi__delta { font-family: var(--fm); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kpi__delta .prev { color: var(--gray); }
.delta { display: inline-flex; align-items: center; gap: 3px; padding: 2px 6px; border-radius: var(--r-sm); font-weight: 500; }
.delta--up { color: var(--pos); background: rgba(46, 125, 79, .09); }
.delta--down { color: var(--neg); background: rgba(192, 57, 27, .09); }
.delta--flat { color: var(--gray); background: var(--tag-bg); }

/* ================= CHARTS ================= */
.chart-box { position: relative; height: 300px; }
.chart-box--sm { height: 240px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-family: var(--fm); font-size: 12px; color: var(--gray); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.split-list { list-style: none; display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.split-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.split-list .bar { height: 6px; background: var(--line-2); border-radius: 2px; overflow: hidden; }
.split-list .bar i { display: block; height: 100%; }

/* ================= BADGES / TAGS ================= */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--fm); font-size: 11px; letter-spacing: .03em; font-weight: 500;
  border-radius: var(--r-sm); padding: 3px 8px; border: 1px solid currentColor; white-space: nowrap; line-height: 1.4;
}
.badge svg { width: 12px; height: 12px; }
.badge--tiktok { color: var(--c-tiktok); }
.badge--instagram { color: var(--c-instagram); }
.badge--linkedin { color: var(--c-linkedin); }
.tag { font-family: var(--fm); font-size: 11px; color: var(--gray); border: var(--border); background: var(--tag-bg); border-radius: var(--r-sm); padding: 3px 8px; white-space: nowrap; }
.sent { font-family: var(--fm); font-size: 11px; padding: 3px 8px; border-radius: var(--r-sm); white-space: nowrap; }
.sent--positive { color: var(--pos); background: rgba(46, 125, 79, .09); }
.sent--negative { color: var(--neg); background: rgba(192, 57, 27, .09); }
.sent--neutral { color: var(--gray); background: var(--tag-bg); }

/* ================= TABLES / POSTS ================= */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data caption { text-align: left; }
table.data th {
  font-family: var(--fm); font-weight: 500; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--gray); text-align: right; padding: 10px 12px; border-bottom: var(--border); white-space: nowrap;
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data td { padding: 12px; border-bottom: 1px solid var(--line-2); text-align: right; font-family: var(--fm); font-variant-numeric: tabular-nums; font-size: 13px; vertical-align: middle; }
table.data td.post-cell { font-family: var(--fb); font-size: 14px; min-width: 260px; }
table.data tbody tr:hover { background: rgba(229, 226, 214, .25); }
table.data th button { font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; background: none; border: 0; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
table.data th button[aria-sort-active="true"], table.data th[aria-sort="descending"] button { color: var(--ink); }
.post-title { font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; font-family: var(--fm); font-size: 11.5px; color: var(--gray); }
.er-strong { color: var(--accent); font-weight: 500; }

.top-list { list-style: none; counter-reset: top; display: flex; flex-direction: column; }
.top-list li { counter-increment: top; display: grid; grid-template-columns: 34px 1fr auto; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.top-list li:last-child { border-bottom: 0; }
.top-list li::before { content: counter(top, decimal-leading-zero); font-family: var(--fm); font-size: 12px; color: var(--accent); letter-spacing: .1em; }
.top-list .stats { text-align: right; font-family: var(--fm); font-size: 12px; color: var(--gray); white-space: nowrap; }
.top-list .stats strong { display: block; font-size: 15px; color: var(--ink); font-weight: 500; }

/* ================= COMMENTS ================= */
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 14px; align-items: end; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field input, .field select {
  width: 100%; min-height: 44px; background-color: var(--surface); color: var(--ink);
  border: var(--border); border-radius: var(--r); padding: 10px 12px; font-size: 15px;
}
.field select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23231F20' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.field input::placeholder { color: var(--gray); }
.field input:focus-visible, .field select:focus-visible { outline: var(--focus); outline-offset: 2px; }
.results-count { font-family: var(--fm); font-size: 12px; color: var(--gray); }

.comment-list { list-style: none; display: flex; flex-direction: column; }
.comment { display: grid; grid-template-columns: 40px 1fr; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--line-2); }
.comment:last-child { border-bottom: 0; }
.comment > article { min-width: 0; }
.avatar { width: 40px; height: 40px; border-radius: var(--r-sm); display: grid; place-items: center; font-family: var(--fd); font-weight: 700; font-size: 15px; color: var(--surface); background: var(--ink); }
.comment__head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.comment__author { font-weight: 600; }
.comment__handle, .comment__date { font-family: var(--fm); font-size: 12px; color: var(--gray); }
.comment__text { margin: 6px 0 8px; max-width: 75ch; overflow-wrap: anywhere; }
.comment__foot { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-family: var(--fm); font-size: 12px; color: var(--gray); }
.comment__foot svg { width: 13px; height: 13px; vertical-align: -2px; }
.comment__post { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: min(46ch, 100%); min-width: 0; }
mark { background: rgba(240, 69, 30, .16); color: inherit; border-radius: 2px; padding: 0 1px; }

.empty { text-align: center; padding: 40px 16px; color: var(--gray); font-family: var(--fm); font-size: 13px; }
.loading { color: var(--gray); font-family: var(--fm); font-size: 13px; padding: 40px 0; text-align: center; }

.account-strip { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; }
.account-strip .handle { font-family: var(--fd); font-weight: 700; font-size: 22px; letter-spacing: -.03em; }
.account-strip .meta { font-family: var(--fm); font-size: 12px; color: var(--gray); }

.footer { margin-top: auto; padding: 18px clamp(16px, 3vw, 36px); border-top: var(--border); font-family: var(--fm); font-size: 11.5px; color: var(--gray); background: var(--surface); }

.backdrop { display: none; }

/* ================= RESPONSIVE ================= */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(var(--cols-md, 3), minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(280px, 84vw); z-index: 80;
    transform: translateX(-100%); transition: transform .22s ease; visibility: hidden;
  }
  .sidebar.is-open { transform: none; visibility: visible; }
  .backdrop.is-open { display: block; position: fixed; inset: 0; background: rgba(35, 31, 32, .45); z-index: 70; }
  .menu-toggle { display: grid; }
  .grid-2-eq { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .field--search { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .topbar .seg { width: 100%; }
  .seg button { flex: 1; padding: 8px 6px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi { padding: 14px; }
  .chart-box { height: 240px; }
  .filters { grid-template-columns: 1fr; }
  .comment { grid-template-columns: 32px 1fr; gap: 10px; }
  .avatar { width: 32px; height: 32px; font-size: 13px; }
  .top-list li { grid-template-columns: 28px 1fr; }
  .top-list .stats { grid-column: 2; text-align: left; }
  .top-list .stats strong { display: inline; margin-right: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ================= CONNEXIONS / BANDEAUX (mode API) ================= */
.notices { display: flex; flex-direction: column; gap: 10px; padding: clamp(18px, 3vw, 36px) clamp(18px, 3vw, 36px) 0; max-width: var(--max); }
.notices[hidden] { display: none; }
.notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  background: var(--surface); border: var(--border); border-left: 3px solid var(--gray); border-radius: var(--r);
  padding: 12px 16px; font-size: 14px;
}
.notice--ok { border-left-color: var(--pos); }
.notice--err { border-left-color: var(--neg); }
.notice--info { border-left-color: var(--accent); }
.notice--inline { font-family: var(--fm); font-size: 12.5px; color: var(--gray); }
.notice--inline ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.notice__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.notice .btn { min-height: 36px; padding: 7px 14px; }
.connect-card { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; max-width: 640px; }
.connect-card p { color: var(--gray); }
.connect-card code { font-family: var(--fm); font-size: 13px; }
.conn-list { list-style: none; margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.conn-list li { display: flex; align-items: center; gap: 8px; }
.conn-list .linklike { margin-left: auto; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--d-dim); flex: none; }
.conn-dot--connected { background: var(--pos); }
.conn-dot--limited, .conn-dot--mock { background: #C9A227; }
.conn-dot--expired, .conn-dot--error { background: var(--accent); }
.linklike { background: none; border: 0; padding: 2px 0; cursor: pointer; color: var(--d-text); text-decoration: underline; text-underline-offset: 3px; font: inherit; }
.linklike:hover { color: var(--accent); }

/* ================= PAGE DE CONNEXION ================= */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login__card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 18px; }
.login__card .brand { color: var(--ink); border-bottom: var(--border); padding: 0 0 18px; }
.login__card .brand small { color: var(--gray); }
.login__card label { font-family: var(--fm); font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--gray); display: block; margin-bottom: 6px; }
.login__card input { width: 100%; min-height: 44px; padding: 10px 12px; border: var(--border); border-radius: var(--r); background: #fff; }
.login__card input:focus-visible { outline: var(--focus); outline-offset: 1px; }
.login__card .btn { justify-content: center; width: 100%; }
.login__error { color: var(--neg); font-size: 14px; min-height: 1.4em; }

/* ================= PAGE LÉGALE (/confidentialite) ================= */
.legal { max-width: 860px; margin: 0 auto; padding: clamp(20px, 4vw, 48px) 16px; display: flex; flex-direction: column; gap: 18px; }
.legal__head { display: flex; align-items: center; gap: 18px; margin-bottom: 6px; }
.legal__head img { border-radius: var(--r); flex: none; }
.legal__meta { font-family: var(--fm); font-size: 12px; color: var(--gray); margin-top: 6px; }
.legal .card { display: flex; flex-direction: column; gap: 10px; }
.legal ul { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.legal a { color: var(--accent-d); text-decoration: underline; text-underline-offset: 3px; }
.legal code { font-family: var(--fm); font-size: 13px; background: var(--paper); padding: 1px 5px; border-radius: var(--r-sm); }
.footer a { text-decoration: underline; text-underline-offset: 3px; }
.login__legal { font-family: var(--fm); font-size: 11.5px; color: var(--gray); text-align: center; }
.login__legal a { text-decoration: underline; }

/* ================= ÉTAT « EN ATTENTE D'APPROBATION » ================= */
.notice, .connect-card { overflow-wrap: anywhere; }
.steps { margin: 4px 0 0 20px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--ink); flex-basis: 100%; }
.steps__title { font-family: var(--fm); font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--gray); }
.conn-dot--pending_approval { background: #C9A227; }
.conn-note { margin-left: auto; color: var(--d-dim); font-style: italic; }
