/* IRONMEUF Dashboard — Buffer/Later-inspired */

:root {
  --bg: #FAFAFB;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --border-soft: #F1F2F4;
  --ink: #0F172A;
  --slate-700: #334155;
  --slate-500: #64748B;
  --slate-400: #94A3B8;
  --slate-300: #CBD5E1;
  --slate-100: #F1F5F9;
  --slate-50: #F8FAFC;

  --terracotta: #C45A3F;
  --terracotta-tint: #FEF1EC;
  --terracotta-soft: #FAD8C9;
  --khaki: #708238;
  --khaki-tint: #F0F3E5;
  --emerald: #059669;
  --emerald-tint: #D1FAE5;
  --rose: #E11D48;
  --rose-tint: #FFE4E6;
  --amber: #D97706;
  --amber-tint: #FEF3C7;
  --indigo: #4F46E5;
  --indigo-tint: #EEF2FF;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.07);
}

/* Dark theme — auto via system preference */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1220;
    --surface: #141B2D;
    --border: #2A3447;
    --border-soft: #1C2436;
    --ink: #F1F5F9;
    --slate-700: #CBD5E1;
    --slate-500: #94A3B8;
    --slate-400: #64748B;
    --slate-300: #475569;
    --slate-100: #1C2436;
    --slate-50: #141B2D;

    --terracotta-tint: #3F1F15;
    --terracotta-soft: #5C2B1E;
    --khaki-tint: #1F2914;
    --emerald-tint: #053022;
    --rose-tint: #3D0F1A;
    --amber-tint: #3F2A0E;
    --indigo-tint: #1E1B4B;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
  }

  /* Fix specific elements that have white backgrounds in cards */
  .conn-card, .kpi, .card, .quick-card, .composer-form, .composer-preview { background: var(--surface); }
  .input-text, .input-textarea, .search input { background: var(--slate-100); color: var(--ink); border-color: var(--border); }
  .topbar { background: var(--surface); }
  .sidebar { background: var(--surface); }
  .icon-btn { background: var(--slate-100); color: var(--ink); }
  .icon-btn:hover { background: var(--slate-300); }
  .post-thumb { background: linear-gradient(135deg, #2A3447, #141B2D); }
  .kanban-col { background: var(--slate-100); }
  .kanban-card { background: var(--surface); }
  .platform-toggle { background: var(--slate-100); border-color: var(--border); color: var(--slate-700); }
  .insight { background: var(--indigo-tint); }
  .insight-icon { background: var(--surface); }
  .ribbon-top::before, .conn-meta { background: var(--slate-100); }
  .nav-item:hover { background: var(--slate-100); }
  .btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--border); }
  .btn-ghost:hover { background: var(--slate-100); }
}

@media (prefers-color-scheme: dark) {
  meta[name="theme-color"] { content: "#0B1220"; }
}

* { box-sizing: border-box; min-width: 0; }
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Empêche tout overflow horizontal global */
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

/* Fluid typography (retina + responsive) */
img, svg, video { max-width: 100%; height: auto; display: block; }
img { image-rendering: -webkit-optimize-contrast; }

/* Truncation utilities pour titres longs */
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.break-words { overflow-wrap: anywhere; word-break: break-word; }

/* Layout */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
}

.sidebar .brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--terracotta), var(--khaki));
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
}

.sidebar .brand-name {
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 18px;
}

.sidebar .brand-sub {
  color: var(--slate-500);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--slate-400);
  padding: 12px 12px 4px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--slate-700);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 120ms;
}

.nav-item:hover {
  background: var(--slate-50);
}

.nav-item.active {
  background: var(--terracotta-tint);
  color: var(--terracotta);
}

.nav-item.active svg { color: var(--terracotta); }

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--slate-500);
}

.nav-badge {
  margin-left: auto;
  background: var(--terracotta);
  color: white;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
}

/* Main */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}

.search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.search input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  background: var(--slate-50);
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
}

.search input:focus {
  background: var(--surface);
  border-color: var(--terracotta-soft);
  box-shadow: 0 0 0 3px var(--terracotta-tint);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--slate-400);
  width: 18px;
  height: 18px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: var(--slate-50);
  color: var(--slate-700);
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  transition: background 120ms;
}

.icon-btn:hover { background: var(--slate-100); }

.icon-btn .dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--rose);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--terracotta), var(--khaki));
  color: white;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms;
  text-decoration: none;
}

.btn-primary {
  background: var(--terracotta);
  color: white;
}

.btn-primary:hover {
  background: #A84A33;
}

.btn-ghost {
  background: var(--surface);
  color: var(--slate-700);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--slate-50);
}

.btn-soft {
  background: var(--terracotta-tint);
  color: var(--terracotta);
}

.btn-soft:hover {
  background: var(--terracotta-soft);
}

.btn svg { width: 16px; height: 16px; }

/* Content area */
.content {
  padding: 32px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.page-sub {
  color: var(--slate-500);
  font-size: 14px;
  margin: 0;
}

.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card.elev { box-shadow: var(--shadow-md); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.card-sub {
  font-size: 12px;
  color: var(--slate-500);
}

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.kpi-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  margin-bottom: 16px;
}

.kpi-icon-wrap.indigo { background: var(--indigo-tint); color: var(--indigo); }
.kpi-icon-wrap.terracotta { background: var(--terracotta-tint); color: var(--terracotta); }
.kpi-icon-wrap.emerald { background: var(--emerald-tint); color: var(--emerald); }
.kpi-icon-wrap.amber { background: var(--amber-tint); color: var(--amber); }

.kpi-icon-wrap svg { width: 20px; height: 20px; }

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
}

.kpi-value-sub { font-size: 14px; color: var(--slate-500); margin-left: 4px; }

.kpi-label {
  font-size: 13px;
  color: var(--slate-500);
  margin-top: 6px;
}

.kpi-trend {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.kpi-trend.up { background: var(--emerald-tint); color: var(--emerald); }
.kpi-trend.down { background: var(--rose-tint); color: var(--rose); }
.kpi-trend.flat { background: var(--slate-100); color: var(--slate-500); }

.kpi-trend svg { width: 12px; height: 12px; }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 28px; }
.grid-2-eq { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 28px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

@media (max-width: 1100px) {
  .grid-2, .grid-2-eq, .grid-3 { grid-template-columns: 1fr; }
}

/* Post / Reel preview */
.post-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}
.post-row:last-child { border-bottom: 0; }

.post-thumb {
  width: 56px;
  height: 72px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--slate-200, #E2E8F0), var(--slate-100));
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.post-thumb::after {
  content: "▶";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: white;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
  font-size: 14px;
  opacity: 0.85;
}

.post-meta {
  flex: 1;
  min-width: 0;
}

.post-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-stats {
  font-size: 12px;
  color: var(--slate-500);
  display: flex;
  gap: 12px;
}

.platform-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.platform-tag.ig { background: #FCE7F3; color: #BE185D; }
.platform-tag.tiktok { background: #FDE2E2; color: #DC2626; }
.platform-tag.youtube { background: #FEE2E2; color: #B91C1C; }
.platform-tag.facebook { background: #DBEAFE; color: #2563EB; }
.platform-tag.discord { background: #E0E7FF; color: #4338CA; }

/* Status pill */
.status-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-pill.draft { background: var(--slate-100); color: var(--slate-500); }
.status-pill.scheduled { background: var(--indigo-tint); color: var(--indigo); }
.status-pill.published { background: var(--emerald-tint); color: var(--emerald); }
.status-pill.review { background: var(--amber-tint); color: var(--amber); }

/* Tables — wrap in scroll container if needed */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-soft);
}

.table td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
  color: var(--slate-700);
}

.table tr:last-child td { border-bottom: 0; }
.table tr:hover { background: var(--slate-50); }

/* Quick action card */
.quick-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  cursor: pointer;
  transition: all 150ms;
  text-decoration: none;
  color: var(--ink);
  flex: 1;
  min-width: 180px;
}

.quick-card:hover {
  border-color: var(--terracotta-soft);
  box-shadow: 0 0 0 3px var(--terracotta-tint);
}

.quick-card .qc-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--terracotta-tint);
  color: var(--terracotta);
  display: grid;
  place-items: center;
}

.quick-card .qc-icon svg { width: 18px; height: 18px; }

.quick-card .qc-title { font-weight: 600; font-size: 14px; }
.quick-card .qc-sub { font-size: 12px; color: var(--slate-500); }

/* Calendar minimal */
.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.cal-day {
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--slate-50);
  border: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 8px;
  font-size: 11px;
  color: var(--slate-500);
}

.cal-day.has-post { background: var(--terracotta-tint); border-color: var(--terracotta-soft); color: var(--terracotta); }
.cal-day.today { background: var(--ink); color: white; }
.cal-day .day-num { font-weight: 700; font-size: 13px; }
.cal-day .day-count {
  margin-top: auto;
  font-weight: 600;
}

/* Insight card */
.insight {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  background: var(--indigo-tint);
  margin-bottom: 8px;
}

.insight-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: white;
  display: grid;
  place-items: center;
  color: var(--indigo);
  flex-shrink: 0;
}

.insight-icon svg { width: 18px; height: 18px; }

.insight-body { flex: 1; }
.insight-title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.insight-sub { font-size: 12px; color: var(--slate-700); line-height: 1.4; }

/* Kanban */
.kanban {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  overflow-x: auto;
}

.kanban-col {
  background: var(--slate-50);
  border-radius: 12px;
  padding: 14px;
  min-height: 400px;
}

.kanban-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate-500);
}

.kanban-col-header .count {
  background: white;
  color: var(--ink);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
}

.kanban-card {
  background: var(--surface);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  border: 1px solid transparent;
  transition: all 120ms;
}

.kanban-card:hover {
  border-color: var(--terracotta-soft);
}

.kanban-card-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.kanban-card-meta { font-size: 11px; color: var(--slate-500); display: flex; justify-content: space-between; align-items: center; }
.kanban-card-amount { font-weight: 700; color: var(--terracotta); }

/* Multi-platform composer preview */
.composer-grid { display: grid; grid-template-columns: 1fr 360px; gap: 24px; }
.composer-form { background: var(--surface); border-radius: 12px; padding: 20px; border: 1px solid var(--border-soft); }
.composer-preview { background: var(--surface); border-radius: 12px; padding: 16px; border: 1px solid var(--border-soft); position: sticky; top: 80px; height: fit-content; }

.platform-toggle-row { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.platform-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-700);
}
.platform-toggle.active { background: var(--terracotta-tint); border-color: var(--terracotta-soft); color: var(--terracotta); }

.input-text, .input-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: all 120ms;
}

.input-textarea { min-height: 120px; resize: vertical; }

.input-text:focus, .input-textarea:focus {
  border-color: var(--terracotta-soft);
  box-shadow: 0 0 0 3px var(--terracotta-tint);
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 6px;
}

.phone-frame {
  width: 280px;
  height: 560px;
  background: #000;
  border-radius: 36px;
  padding: 12px;
  margin: 0 auto;
}

.phone-screen {
  width: 100%;
  height: 100%;
  background: white;
  border-radius: 26px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Sidebar overlay (mobile) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 50;
  opacity: 0;
  transition: opacity 200ms;
}

.sidebar-backdrop.open {
  display: block;
  opacity: 1;
}

/* Responsive — tablet */
@media (max-width: 1100px) {
  .grid-2, .grid-2-eq, .grid-3 { grid-template-columns: 1fr !important; }
}

/* Responsive — mobile */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .content { padding: 16px; max-width: 100vw; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar .search { max-width: none; }
  .topbar .btn { padding: 8px 12px; font-size: 12px; }
  .topbar .btn span, .topbar .btn:not(.icon-btn) { /* keep label visible */ }

  .hamburger { display: grid !important; }

  /* Sidebar : caché par défaut sur mobile, slide-in via .open */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 80vw);
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.18);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Quand sidebar open, le bouton hamburger devient un X */
  .hamburger.open svg {
    transform: rotate(90deg);
    transition: transform 200ms;
  }

  /* Page header : titre + actions empilent */
  .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; justify-content: center; }
  .page-title { font-size: 22px !important; }
  .page-sub { font-size: 13px; }

  /* KPI grid : 2 colonnes sur mobile, full width sinon */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 22px; }
  .kpi-label { font-size: 11px; }
  .kpi-icon-wrap { width: 32px; height: 32px; margin-bottom: 10px; }
  .kpi-icon-wrap svg { width: 16px; height: 16px; }
  .kpi-trend { top: 14px; right: 14px; font-size: 10px; padding: 2px 6px; }

  /* Cards : padding réduit + force wrapping */
  .card { padding: 14px; border-radius: 12px; }
  .card-header { flex-wrap: wrap; gap: 8px; }
  .card-title { font-size: 13px; }

  /* Tables auto-scrollables */
  .table { font-size: 12px; min-width: 0; }
  .table th, .table td { padding: 8px 6px; }

  /* Quick action cards : empilent */
  .quick-card { flex-basis: calc(50% - 6px); min-width: 0; }

  /* Post rows : éviter overflow titre */
  .post-row { gap: 10px; }
  .post-thumb { width: 44px; height: 56px; }
  .post-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .post-stats { font-size: 11px; flex-wrap: wrap; }

  /* Kanban scrollable horizontal sur mobile */
  .kanban {
    grid-template-columns: repeat(5, 280px);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
  }
  .kanban-col { scroll-snap-align: start; }

  /* Mini-cal : reste lisible mais plus compact */
  .cal-week { gap: 4px; }
  .cal-day { font-size: 10px; padding: 4px; }
  .cal-day .day-num { font-size: 11px; }

  /* Composer phone preview : scale down */
  .phone-frame {
    width: min(280px, 100%) !important;
    height: auto !important;
    aspect-ratio: 9 / 18;
    margin: 0 auto;
  }

  /* Connections cards : single col */
  .conn-grid { grid-template-columns: 1fr !important; }
  .conn-card { padding: 14px; }
  .conn-meta { grid-template-columns: 1fr; }

  /* Composer grid */
  .composer-grid { grid-template-columns: 1fr !important; gap: 16px; }
  .composer-preview { position: static !important; top: auto !important; }
  .platform-toggle-row { gap: 6px; }
  .platform-toggle { padding: 6px 10px; font-size: 12px; }

  /* Hero / very large titles guard */
  h1, h2 { overflow-wrap: anywhere; }

  /* Avatar topbar plus petit */
  .avatar { width: 36px; height: 36px; font-size: 13px; }
  .icon-btn { width: 36px; height: 36px; }

  /* Inputs lisibles */
  .input-text, .input-textarea { font-size: 16px; /* évite zoom iOS */ }
}

/* Mini phones (< 380px) */
@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .quick-card { flex-basis: 100%; }
  .topbar .btn:not(.btn-primary) span,
  .topbar .btn:not(.btn-primary) { padding: 8px; }
  .page-title { font-size: 20px !important; }
}

/* Retina / high-DPI : crispness */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  body { -webkit-font-smoothing: antialiased; }
  .card, .kpi { border-width: 0.5px; }
  .post-thumb, .conn-logo, .avatar { background-size: cover; }
}

/* Touch targets : 44px min (Apple HIG) */
@media (pointer: coarse) {
  .nav-item, .btn, .icon-btn, .conn-actions .btn, .platform-toggle {
    min-height: 40px;
  }
  .kanban-card, .quick-card, .conn-card { min-height: 44px; }
}

/* Safe area pour iPhone notch */
@supports (padding: env(safe-area-inset-top)) {
  .topbar { padding-top: max(12px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .sidebar { padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  .content { padding-bottom: max(32px, env(safe-area-inset-bottom)); }
}

/* ==========================================================
   POLISH ADDITIONS — UI/UX Pro Max pass
   ========================================================== */

/* A11y : focus rings cohérents partout (a11y WCAG) */
:where(a, button, [role="button"], input, select, textarea, .nav-item, .chip, .ptab, .tab, .tab-btn, .platform-toggle, .quick-card, .reel-card, .preview-tab, .stream-tab):focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 2px;
  border-radius: 8px;
}
.btn:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 2px;
}

/* Disabled / loading buttons */
.btn:disabled,
.btn[aria-busy="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.btn[aria-busy="true"]::before {
  content: "";
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Hover micro-interaction sur boutons primaires */
.btn-primary { box-shadow: 0 1px 2px rgba(196, 90, 63, 0.15); }
.btn-primary:hover { box-shadow: 0 4px 12px rgba(196, 90, 63, 0.25); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost:active, .btn-soft:active { transform: translateY(0); }
.btn-ghost:hover, .btn-soft:hover { transform: translateY(-1px); }

/* Empty state — composant unifié */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 40px 24px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, transparent, var(--slate-50));
  color: var(--slate-500);
}
.empty-state .empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--terracotta-tint);
  color: var(--terracotta);
  margin-bottom: 4px;
}
.empty-state .empty-icon svg { width: 26px; height: 26px; }
.empty-state .empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.empty-state .empty-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--slate-500);
  max-width: 380px;
  margin: 0;
}
.empty-state .empty-actions {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  margin-top: 6px;
}
.empty-state.compact { padding: 24px 16px; gap: 8px; }
.empty-state.compact .empty-icon { width: 40px; height: 40px; border-radius: 12px; }
.empty-state.compact .empty-icon svg { width: 18px; height: 18px; }

/* Skeleton loader (utilities) */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--slate-100) 0%, var(--slate-50) 50%, var(--slate-100) 100%);
  background-size: 800px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
  display: block;
}
.skeleton-text { height: 12px; border-radius: 4px; margin: 6px 0; }
.skeleton-text.lg { height: 20px; }
.skeleton-text.sm { height: 10px; }
.skeleton-block { height: 80px; }
.skeleton-circle { border-radius: 50%; }
.skeleton-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border-soft);
}
.skeleton-row:last-child { border-bottom: 0; }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--slate-200, var(--slate-300));
  border-top-color: var(--terracotta);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

/* Toast (cohérent global) */
.toast {
  position: fixed;
  top: 80px;
  right: 24px;
  padding: 12px 16px;
  background: var(--surface);
  color: var(--ink);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  animation: slideInRight 240ms cubic-bezier(0.22, 1, 0.36, 1);
  max-width: calc(100vw - 48px);
}
.toast.success { border-color: rgba(5, 150, 105, 0.3); }
.toast.success .toast-dot { background: var(--emerald); }
.toast.error { border-color: rgba(225, 29, 72, 0.3); }
.toast.error .toast-dot { background: var(--rose); }
.toast .toast-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--terracotta); }
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Card hover discret */
.card { transition: border-color 150ms, box-shadow 150ms; }
.card.interactive { cursor: pointer; }
.card.interactive:hover { border-color: var(--terracotta-soft); box-shadow: var(--shadow-md); }

/* Quick-card refined */
.quick-card { transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1), border-color 150ms, box-shadow 150ms; }
.quick-card:hover { transform: translateY(-2px); }

/* KPI card hover lift (discret) */
.kpi { transition: border-color 150ms, box-shadow 150ms, transform 180ms; }
.kpi:hover { border-color: var(--border); box-shadow: var(--shadow-md); }

/* Chips uniforme global */
.chip-group {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 4px;
}
.chip {
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--slate-500);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 120ms;
}
.chip:hover { color: var(--ink); }
.chip.active {
  background: var(--terracotta-tint);
  color: var(--terracotta);
  font-weight: 600;
}

/* Section heading util */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 8px 0 12px; gap: 12px; flex-wrap: wrap;
}
.section-head h2 {
  font-size: 16px; font-weight: 700; letter-spacing: -0.01em;
  margin: 0; color: var(--ink);
}
.section-head .section-sub { font-size: 12px; color: var(--slate-500); }

/* Status pill — ajout success/warn/danger neutres */
.status-pill.success { background: var(--emerald-tint); color: var(--emerald); }
.status-pill.warn { background: var(--amber-tint); color: var(--amber); }
.status-pill.danger { background: var(--rose-tint); color: var(--rose); }
.status-pill.info { background: var(--indigo-tint); color: var(--indigo); }

/* Tabular numerals pour les KPIs et tables (lisibilité) */
.kpi-value, .table td:has(strong), .table td strong, .entry-amount, .pt-amount, .audience-kpi-value {
  font-variant-numeric: tabular-nums;
}

/* Reduced motion (a11y) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .skeleton { animation: none; background: var(--slate-100); }
  .live-pulse.online { animation: none; }
}

/* Touch targets : 44px sur mobile/tablet (WCAG/HIG) */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .chip, .platform-toggle, .ptab, .tab, .preview-tab, .stream-tab {
    min-height: 40px;
  }
  .nav-item { min-height: 44px; }
  .page-btn { min-height: 40px; min-width: 40px; }
}

/* Lien terracotta cohérent */
a.link, .link {
  color: var(--terracotta);
  text-decoration: none;
  font-weight: 500;
}
a.link:hover, .link:hover { text-decoration: underline; }

/* Form select inherit input style (cross-browser) */
select.input-text {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Input focus ring conformity */
.input-text:focus,
.input-textarea:focus,
.search input:focus,
.search-box input:focus {
  outline: none;
}

/* Dialog modal motion */
dialog[open] {
  animation: modalIn 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Page section spacing rhythm */
.section-stack > * + * { margin-top: 28px; }

/* Mobile : empty-state padding réduit */
@media (max-width: 640px) {
  .empty-state { padding: 28px 18px; }
  .empty-state .empty-icon { width: 44px; height: 44px; border-radius: 12px; }
}
