:root {
  --bg: #f5f6fa;
  --panel: #fff;
  --text: #1e2230;
  --muted: #6b7280;
  --border: #e4e6ee;
  --primary: #4f46e5;
  --primary-soft: #eef0ff;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #d97706;
  --radius: 10px;
  --st-idea: #a78bfa;
  --st-draft: #60a5fa;
  --st-review: #f59e0b;
  --st-scheduled: #4f46e5;
  --st-publishing: #0ea5e9;
  --st-published: #10b981;
  --st-failed: #ef4444;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; }
code, pre { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
pre { background: #f1f2f6; padding: 10px; border-radius: 8px; overflow-x: auto; }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]), select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 12px; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; }
.label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }

/* Structure */
body.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: #161a2b; color: #cdd0e0; padding: 18px 14px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; }
.brand { color: #fff; font-weight: 700; font-size: 17px; }
.brand span, .brand-mark { color: #fbbf24; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: #cdd0e0; padding: 8px 10px; border-radius: 8px; display: flex; gap: 8px; align-items: center; }
.sidebar nav a:hover { background: #22273d; }
.sidebar nav a.active { background: #2c3250; color: #fff; }
.nav-icon { width: 20px; text-align: center; }
.logout { margin-top: auto; }
.link { background: none; border: 0; color: inherit; cursor: pointer; padding: 0; opacity: .7; }
.main { padding: 22px 26px; min-width: 0; }
body.bare { display: grid; place-items: center; min-height: 100vh; }
.auth { width: min(380px, 92vw); }
.auth h1 { margin-bottom: 14px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 6px; align-items: center; }
.actions select { width: auto; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
.span-3 { grid-column: 1 / -1; }

/* Boutons, messages */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-weight: 600; color: var(--text); }
.btn:hover { border-color: #c9ccd8; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-danger { color: var(--danger); }
.btn-small { padding: 5px 9px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid; }
.flash-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1e2230; color: #fff; padding: 10px 16px; border-radius: 8px; white-space: pre-line; max-width: 90vw; z-index: 10; }
.badge { padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; color: #fff; background: var(--muted); }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: #f1f2f6; color: var(--muted); }
.tag-pillar { background: color-mix(in srgb, var(--pillar) 15%, #fff); color: color-mix(in srgb, var(--pillar) 80%, #000); }

/* Statuts */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.status-dot-idea, .badge.status-idea { background: var(--st-idea); }
.status-dot-draft, .badge.status-draft { background: var(--st-draft); }
.status-dot-review, .badge.status-review { background: var(--st-review); }
.status-dot-scheduled, .badge.status-scheduled { background: var(--st-scheduled); }
.status-dot-publishing, .badge.status-publishing { background: var(--st-publishing); }
.status-dot-published, .badge.status-published { background: var(--st-published); }
.status-dot-failed, .badge.status-failed { background: var(--st-failed); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend > span { display: inline-flex; gap: 5px; align-items: center; }
.net-instagram { color: #e1306c; }
.net-facebook { color: #1877f2; }
.net-tiktok { color: #111; }
.net { vertical-align: -2px; flex: none; }
.btn-primary .net { color: #fff; }

/* Cartes */
.card { display: flex; gap: 8px; background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--pillar); border-radius: 8px; padding: 8px; margin-bottom: 8px; color: var(--text); cursor: pointer; }
.card[draggable=true] { cursor: grab; }
.card:hover { box-shadow: 0 2px 8px rgba(20, 24, 40, .08); }
.card.dragging { opacity: .4; }
.card .thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; flex: none; background: #eee; }
.card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.card-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.card-date { font-size: 11px; color: var(--muted); }
.card-compact { padding: 3px 6px; margin-bottom: 4px; font-size: 12px; border-left-width: 3px; }
.card-compact .card-body { gap: 1px; width: 100%; }
.card-compact .card-line { display: flex; gap: 4px; align-items: center; }
.card-compact .card-title { font-weight: 400; }
.card.status-published { opacity: .75; }
.card.status-failed { background: #fef2f2; }

/* Calendrier */
.calendar-layout { display: grid; grid-template-columns: 1fr 260px; gap: 16px; align-items: start; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--border); gap: 1px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.cal-head { background: #fafbfd; padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: capitalize; }
.cal-day { background: #fff; min-height: 118px; padding: 6px; }
.cal-day.other { background: #fafbfd; }
.cal-day.other .cal-day-head span { color: #b6bac8; }
.cal-day.past { background: #fcfcfd; }
.cal-day.today .cal-day-head span { background: var(--primary); color: #fff; border-radius: 99px; padding: 0 7px; }
.cal-day-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; font-size: 12px; font-weight: 600; }
.cal-day .add { opacity: 0; font-size: 14px; line-height: 1; padding: 0 4px; }
.cal-day:hover .add { opacity: 1; }
.drop-over { outline: 2px dashed var(--primary); outline-offset: -3px; background: var(--primary-soft) !important; }
.ideas { position: sticky; top: 16px; max-height: calc(100vh - 40px); overflow-y: auto; }

/* Planning */
.quick-idea { display: grid; grid-template-columns: 1fr 160px 180px auto; gap: 8px; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 6px; }
.column { background: #eceef4; border-radius: var(--radius); padding: 10px; min-height: 240px; }
.column h2 { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.count { color: var(--muted); font-weight: 400; }
.pillar-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.pillar-row input[type=color] { width: 36px; height: 34px; border: 1px solid var(--border); border-radius: 6px; padding: 2px; background: #fff; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 150px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.bar { background: #f1f2f6; border-radius: 99px; height: 10px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; }

/* Compositeur */
.composer { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.composer-form, .composer-actions { grid-column: 1; }
.preview-pane { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: 16px; }
.composer-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.segmented label { margin: 0; font-weight: 500; }
.segmented input { display: none; }
.segmented span { display: block; padding: 7px 14px; cursor: pointer; border-right: 1px solid var(--border); }
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--primary); color: #fff; }
.field { margin-bottom: 12px; }
.account-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.account-chip { margin: 0; font-weight: 500; }
.account-chip input { display: none; }
.account-chip span { display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border: 1px solid var(--border); border-radius: 99px; cursor: pointer; opacity: .6; }
.account-chip input:checked + span { opacity: 1; border-color: var(--primary); background: var(--primary-soft); }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 18px; text-align: center; cursor: pointer; font-weight: 400; margin: 0; }
.dropzone.drop-over { border-color: var(--primary); }
.dropzone input { display: none; }
.media-list { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.media-item { position: relative; width: 92px; }
.media-item img, .media-item video { width: 92px; height: 92px; object-fit: cover; border-radius: 8px; display: block; background: #eee; }
.media-item .tools { display: flex; justify-content: space-between; margin-top: 2px; }
.media-item .tools button { border: 0; background: #f1f2f6; border-radius: 4px; cursor: pointer; padding: 0 6px; }
.media-item .new { position: absolute; top: 4px; left: 4px; background: var(--primary); color: #fff; font-size: 10px; padding: 0 5px; border-radius: 4px; }
.counters { display: flex; gap: 14px; margin: -6px 0 10px; }
.counters .over { color: var(--danger); font-weight: 600; }
.results .result { padding: 6px 0; border-bottom: 1px solid var(--border); }
.results .result:last-child { border-bottom: 0; }
.result-failed { color: var(--danger); }
.warnings { list-style: none; padding: 0; margin: 10px 0 0; font-size: 12px; color: var(--warn); }
.warnings li::before { content: "⚠ "; }

/* Prévisualisation */
.preview-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.preview-tabs button { flex: 1; padding: 7px; border: 1px solid var(--border); background: #fff; border-radius: 8px; cursor: pointer; font-weight: 600; display: inline-flex; gap: 6px; justify-content: center; align-items: center; }
.preview-tabs button.active { border-color: var(--primary); background: var(--primary-soft); }
.preview { display: flex; justify-content: center; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #b4b9cc; object-fit: cover; flex: none; display: inline-grid; place-items: center; font-weight: 700; color: #fff; font-size: 13px; }
.avatar-lg { width: 64px; height: 64px; }
.pv { width: 340px; background: #fff; border: 1px solid #dbdbdb; border-radius: 12px; overflow: hidden; color: #000; font-size: 13px; }
.pv-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.pv-head b { font-size: 13px; }
.pv-head .sub { font-size: 11px; color: #65676b; }
.pv-media { position: relative; background: #000; overflow: hidden; }
.pv-media img, .pv-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pv-empty { display: grid; place-items: center; height: 100%; color: #8e8e8e; background: #f3f3f3; font-size: 12px; }
.pv-arrow { position: absolute; top: 50%; transform: translateY(-50%); border: 0; width: 26px; height: 26px; border-radius: 50%; background: rgba(255, 255, 255, .85); cursor: pointer; }
.pv-arrow.prev { left: 8px; } .pv-arrow.next { right: 8px; }
.pv-count { position: absolute; top: 10px; right: 10px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; padding: 1px 8px; border-radius: 99px; }
.pv-dots { display: flex; justify-content: center; gap: 4px; padding: 8px 0 0; }
.pv-dots span { width: 6px; height: 6px; border-radius: 50%; background: #c7c7c7; }
.pv-dots span.on { background: #0095f6; }
.pv-actions { display: flex; gap: 14px; padding: 8px 12px 4px; font-size: 20px; }
.pv-actions .save { margin-left: auto; }
.pv-caption { padding: 2px 12px 12px; white-space: pre-wrap; word-wrap: break-word; }
.pv-caption .more { color: #737373; cursor: pointer; }
.pv-caption .ht { color: #00376b; }
.pv-time { padding: 0 12px 12px; color: #737373; font-size: 11px; text-transform: uppercase; }
.pv-reel-badge { position: absolute; bottom: 10px; left: 10px; color: #fff; font-weight: 600; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.pv-fb .pv-caption .ht { color: #385898; }
.pv-fb .pv-caption { padding: 0 12px 10px; }
.pv-fb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: #fff; }
.pv-fb-grid > div { aspect-ratio: 1; position: relative; overflow: hidden; background: #000; }
.pv-fb-grid .more-count { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); color: #fff; font-size: 26px; display: grid; place-items: center; }
.pv-fb-bar { display: flex; justify-content: space-around; border-top: 1px solid #ced0d4; margin: 0 12px; padding: 6px 0; color: #65676b; font-weight: 600; }
.pv-story { width: 300px; aspect-ratio: 9 / 16; border-radius: 16px; position: relative; background: #111; overflow: hidden; }
.pv-story .pv-media { position: absolute; inset: 0; }
.pv-story-top { position: absolute; top: 0; left: 0; right: 0; padding: 10px; background: linear-gradient(rgba(0, 0, 0, .45), transparent); color: #fff; z-index: 1; }
.pv-story-bar { height: 2px; background: rgba(255, 255, 255, .5); border-radius: 2px; margin-bottom: 8px; }
.pv-story-bar span { display: block; width: 35%; height: 100%; background: #fff; }
.pv-story-top .pv-head { padding: 0; }
.pv-story-bottom { position: absolute; bottom: 12px; left: 12px; right: 12px; border: 1px solid rgba(255, 255, 255, .7); border-radius: 99px; color: #fff; padding: 8px 14px; font-size: 12px; z-index: 1; }

.pv-tiktok .pv-caption { padding: 4px 0 0; color: #fff; }
.pv-tiktok .pv-caption .ht { color: #fff; font-weight: 600; }
.pv-tiktok .pv-caption .more { color: #ddd; }
.pv-tt-bottom { position: absolute; left: 12px; right: 60px; bottom: 16px; color: #fff; font-size: 12px; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); z-index: 1; }
.pv-tt-side { position: absolute; right: 10px; bottom: 70px; display: flex; flex-direction: column; align-items: center; gap: 16px; color: #fff; font-size: 22px; z-index: 1; }
.pv-tt-side .avatar { width: 40px; height: 40px; border: 2px solid #fff; }
.pv-tt-dots { position: absolute; bottom: 6px; left: 0; right: 0; display: flex; justify-content: center; gap: 4px; z-index: 1; }
.pv-tt-dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .5); }
.pv-tt-dots span.on { background: #fff; }

/* Aperçu du feed */
.phone-profile { width: min(460px, 100%); background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 14px; }
.profile-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.ig-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.ig-tile { position: relative; aspect-ratio: 3 / 4; background: #efefef; overflow: hidden; display: block; color: var(--text); }
.ig-tile .tile-media { width: 100%; height: 100%; object-fit: cover; display: block; }
.ig-tile.planned { outline: 2px solid var(--primary); outline-offset: -2px; cursor: grab; }
.tile-empty { display: grid; place-items: center; height: 100%; padding: 8px; text-align: center; font-size: 12px; }
.tile-badge { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(79, 70, 229, .9); color: #fff; font-size: 10px; padding: 2px 4px; }
.tile-icon { position: absolute; top: 4px; right: 6px; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }

/* Statistiques et comptes */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.stat-card .big { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.delta { font-size: 13px; margin-left: 6px; }
.delta.up { color: var(--ok); } .delta.down { color: var(--danger); }
.spark { width: 100%; height: 70px; color: var(--primary); }
.kpis { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.kpis b { color: var(--text); font-size: 15px; display: block; }
.table { width: 100%; border-collapse: collapse; }
.table td { padding: 7px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table .num { text-align: right; white-space: nowrap; }
.account-row { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.account-row:last-of-type { margin-bottom: 14px; }
.grow { flex: 1; }

@media (max-width: 1100px) {
  .composer { grid-template-columns: 1fr; }
  .preview-pane { grid-column: 1; grid-row: auto; position: static; }
  .calendar-layout { grid-template-columns: 1fr; }
  .ideas { position: static; max-height: none; }
}
@media (max-width: 760px) {
  body.app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 16px; }
  .grid-2, .grid-3, .quick-idea { grid-template-columns: 1fr; }
  .calendar { grid-template-columns: repeat(7, minmax(44px, 1fr)); overflow-x: auto; }
  .cal-day { min-height: 80px; }
  .bar-row { grid-template-columns: 100px 1fr; }
  .bar-row > :last-child { grid-column: 1 / -1; }
}

/* Pages publiques : accueil, pages légales */
body.public { display: flex; flex-direction: column; min-height: 100vh; }
body.public .main { width: min(1040px, 100%); margin: 0 auto; flex: 1; }
.public-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 26px; background: #161a2b; }
.public-head .brand, .sidebar .brand { color: #fff; }
.brand span { color: #a5b4fc; }
.brand-dark { color: var(--text); }
.hero { text-align: center; padding: 48px 0 28px; }
.hero h1 { font-size: clamp(26px, 4vw, 40px); line-height: 1.15; max-width: 760px; margin: 0 auto 14px; }
.lead { font-size: 17px; color: var(--muted); max-width: 640px; margin: 0 auto 22px; }
.center-actions { justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.features { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.features p, .how li { color: var(--muted); }
.how ol { padding-left: 20px; }
.how li { margin-bottom: 6px; }
.legal { max-width: 820px; margin: 0 auto; }
.legal h1 { margin-bottom: 8px; }
.legal h2 { margin-top: 22px; }
.legal p, .legal li { color: #374151; }
.legal mark { background: #fef3c7; }
.legal-links { text-align: center; font-size: 12px; color: var(--muted); padding: 20px; }
.legal-links a { color: var(--muted); }
.hp { position: absolute; left: -9999px; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
label.check input { margin-top: 3px; }
.tag-danger { background: #fee2e2; color: var(--danger); }
.danger-zone { border-color: #fecaca; }
.inline-actions { display: inline-flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.sidebar .logout .small { color: #8b90a8; margin-bottom: 2px; }
.install h2 { margin-top: 18px; }
@media (max-width: 760px) {
  .public-head { padding: 12px 16px; }
  .public-head .btn { padding: 6px 10px; }
}
