/* =========================================================================
   Suivi des Incidents — Charte graphique reprise de PEBCO Benin
   (palette teal/dark, tokens issus de demo-connect-hub-main)
   ========================================================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg: #ffffff;
  --content-bg: #f5f7f8;
  --surface: #ffffff;
  --surface-hover: #f8f9fb;

  --fg: #091018;
  --muted: #4d5660;
  --text-muted: #9ca3af;

  --border: #d9dfe5;
  --border-light: #eef1f4;

  --primary: #007ca5;
  --primary-hover: #006a8e;
  --primary-fg: #f8f8f8;
  --accent: #00befa;

  --sidebar: #0c151e;
  --sidebar-fg: #d8dfe4;
  --sidebar-accent: #192532;
  --sidebar-accent-fg: #ecf3f8;
  --sidebar-primary: #00befa;
  --sidebar-border: rgba(255, 255, 255, 0.08);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --danger: #e62b34;
  --danger-bg: rgba(230, 43, 52, 0.1);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.1);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 14px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: var(--font-sans); color: var(--fg); background: var(--content-bg); }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font-sans); border: none; background: none; }
input, select, textarea { font-family: var(--font-sans); outline: none; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #cbd3da; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ---------- Layout applicatif ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 256px;
  background: var(--sidebar);
  color: var(--sidebar-fg);
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}
.sidebar__brand {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar__logo {
  height: 34px; width: 34px; flex-shrink: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 16px;
}
.sidebar__title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.sidebar__nav { padding: 12px 0; overflow-y: auto; flex: 1; }
.sidebar__section { padding: 14px 20px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: rgba(216,223,228,.4); }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  margin: 2px 12px; padding: 0 12px;
  height: 40px; border-radius: var(--radius-sm);
  color: rgba(216, 223, 228, 0.8);
  font-size: 14px; transition: background .15s, color .15s;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgba(25, 37, 50, 0.6); color: var(--sidebar-accent-fg); }
.nav-item.active { background: var(--sidebar-accent); color: var(--sidebar-accent-fg); font-weight: 500; }
.nav-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--radius-full); background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 600; display: flex; align-items: center; justify-content: center;
}

/* Cloche topbar */
.bell { position: relative; width: 36px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--muted); transition: background .15s, color .15s; }
.bell:hover { background: var(--surface-hover); color: var(--fg); }
.bell svg { width: 20px; height: 20px; }
.bell__count {
  position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--radius-full); background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--surface);
}

.main { flex: 1; margin-left: 256px; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 10;
}
.topbar__title { font-size: 15px; font-weight: 600; }
.topbar__user { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 32px; height: 32px; border-radius: var(--radius-full);
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.content { padding: 24px; flex: 1; }

/* ---------- Composants ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card__body { padding: 20px; }
.card__header {
  padding: 16px 20px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.card__title { font-size: 15px; font-weight: 600; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.page-header p { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* Grille KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm);
}
.kpi__label { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.kpi__icon { width: 32px; height: 32px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; }
.kpi__icon svg { width: 18px; height: 18px; }
.kpi__value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.kpi__value small { font-size: 14px; font-weight: 500; color: var(--muted); }
.kpi__hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; transition: background .15s, border-color .15s, opacity .15s;
  border: 1px solid transparent;
}
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--primary); color: var(--primary-fg); }
.btn--primary:hover { background: var(--primary-hover); }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--fg); }
.btn--ghost:hover { background: var(--surface-hover); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* Forms */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; font-size: 14px; color: var(--fg);
  transition: border-color .2s, box-shadow .2s;
}
.textarea { min-height: 110px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 124, 165, 0.18);
}
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 500; line-height: 1.4;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--nouveau { color: #2563eb; background: var(--info-bg); }
.badge--en_cours { color: #b45309; background: var(--warning-bg); }
.badge--resolu { color: #047857; background: var(--success-bg); }
.badge--clos { color: #4b5563; background: rgba(75, 85, 99, 0.1); }
.badge--basse { color: #4b5563; background: rgba(75, 85, 99, 0.1); }
.badge--moyenne { color: #2563eb; background: var(--info-bg); }
.badge--haute { color: #b45309; background: var(--warning-bg); }
.badge--critique { color: var(--danger); background: var(--danger-bg); }
.badge--late { color: var(--danger); background: var(--danger-bg); }
.badge--expiree { color: #fff; background: var(--danger); }
.badge--expiree::before { background: #fff; }
.badge--critique { color: var(--danger); background: var(--danger-bg); }
.badge--proche { color: #b45309; background: var(--warning-bg); }
.badge--a_venir { color: #2563eb; background: var(--info-bg); }
.badge--ok { color: #047857; background: var(--success-bg); }

/* Bandeau latéral coloré selon urgence (cartes échéances) */
.ech-card { border-left: 4px solid var(--border); }
.ech-card.u-expiree { border-left-color: var(--danger); }
.ech-card.u-critique { border-left-color: var(--danger); }
.ech-card.u-proche { border-left-color: var(--warning); }
.ech-card.u-a_venir { border-left-color: var(--info); }
.ech-card.u-ok { border-left-color: var(--success); }
.countdown { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.countdown small { font-size: 12px; font-weight: 500; color: var(--muted); }

/* Calendrier mensuel */
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { padding: 10px 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; text-align: left; border-bottom: 1px solid var(--border); }
.cal td { border: 1px solid var(--border-light); vertical-align: top; height: 116px; padding: 6px; width: 14.28%; }
.cal-day { position: relative; height: 100%; }
.cal-num { font-size: 13px; font-weight: 600; color: var(--fg); display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; }
.cal-out .cal-num { color: var(--text-muted); }
.cal-out { background: var(--surface-hover); }
.cal-today .cal-num { background: var(--primary); color: #fff; }
.cal-events { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.cal-ev { display: block; font-size: 11px; line-height: 1.3; padding: 2px 6px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid; }
.cal-ev.u-expiree { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.cal-ev.u-critique { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.cal-ev.u-proche { background: var(--warning-bg); color: #b45309; border-color: var(--warning); }
.cal-ev.u-a_venir { background: var(--info-bg); color: #2563eb; border-color: var(--info); }
.cal-ev.u-ok { background: var(--success-bg); color: #047857; border-color: var(--success); }
.cal-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; font-size: 12px; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* Frise chronologique (Gantt) */
.gantt { --label-w: 220px; min-width: 720px; }
.gantt-row { display: grid; grid-template-columns: var(--label-w) 1fr; align-items: center; border-bottom: 1px solid var(--border-light); }
.gantt-row:last-child { border-bottom: none; }
.gantt-head { position: sticky; top: 0; background: var(--surface); z-index: 2; }
.gantt-label { padding: 10px 14px 10px 0; font-size: 13px; overflow: hidden; }
.gantt-label a { font-weight: 600; color: var(--fg); }
.gantt-label a:hover { color: var(--primary); }
.gantt-label .sub { color: var(--muted); font-size: 12px; }
.gantt-track { position: relative; height: 44px; border-left: 1px solid var(--border); }
.gantt-head .gantt-track { height: 34px; }
/* colonnes de mois */
.gantt-col { position: absolute; top: 0; bottom: 0; border-right: 1px dashed var(--border-light); }
.gantt-col span { position: absolute; top: 8px; left: 8px; font-size: 11px; color: var(--muted); white-space: nowrap; text-transform: capitalize; }
.gantt-head .gantt-col { border-right: 1px solid var(--border); }
/* la bande d'alerte qui court sur la période */
.gantt-bar { position: absolute; top: 50%; transform: translateY(-50%); height: 18px; border-radius: 999px; display: flex; align-items: center; box-shadow: var(--shadow-sm); }
.gantt-bar.u-expiree { background: linear-gradient(90deg, rgba(230,43,52,.25), var(--danger)); }
.gantt-bar.u-critique { background: linear-gradient(90deg, rgba(230,43,52,.2), var(--danger)); }
.gantt-bar.u-proche { background: linear-gradient(90deg, rgba(245,158,11,.2), var(--warning)); }
.gantt-bar.u-a_venir { background: linear-gradient(90deg, rgba(59,130,246,.2), var(--info)); }
.gantt-bar.u-ok { background: linear-gradient(90deg, rgba(16,185,129,.2), var(--success)); }
/* marqueurs de palier sur la frise */
.gantt-palier { position: absolute; top: 50%; transform: translate(-50%, -50%); width: 9px; height: 9px; border-radius: 50%; background: #fff; border: 2px solid var(--fg); z-index: 2; }
.gantt-fin { position: absolute; top: 50%; transform: translate(-50%, -50%); width: 12px; height: 12px; border-radius: 3px; background: var(--fg); z-index: 3; }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--primary); z-index: 4; }
.gantt-today::after { content: "auj."; position: absolute; top: -2px; left: 3px; font-size: 10px; color: var(--primary); font-weight: 600; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 12px 16px; font-weight: 600; font-size: 12px;
  color: var(--muted); text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 1px solid var(--border);
}
table.data td { padding: 14px 16px; border-bottom: 1px solid var(--border-light); }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--surface-hover); }
.ref-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert--success { background: var(--success-bg); color: #047857; border: 1px solid rgba(16, 185, 129, 0.25); }
.alert--error { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(230, 43, 52, 0.25); }

/* Filters bar */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.filters .input, .filters .select { width: auto; min-width: 160px; height: 40px; min-height: 40px; }
.filters .input--search { flex: 1; min-width: 220px; }

/* Timeline / comments */
.timeline { list-style: none; }
.timeline li { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: 15px; top: 32px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline__dot { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: #fff; background: var(--primary); }
.timeline__body { flex: 1; }
.timeline__meta { font-size: 12px; color: var(--muted); }
.timeline__event { color: var(--muted); font-style: italic; }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 16px; align-items: start; overflow-x: auto; padding-bottom: 8px; }
.kanban-col { background: #eef1f4; border-radius: var(--radius-lg); min-height: 120px; display: flex; flex-direction: column; }
.kanban-col__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; }
.kanban-col__count { font-size: 12px; font-weight: 600; color: var(--muted); background: #fff; border-radius: var(--radius-full); padding: 1px 9px; }
.kanban-col__body { padding: 0 10px 12px; display: flex; flex-direction: column; gap: 10px; min-height: 60px; transition: background .15s; border-radius: var(--radius-md); }
.kanban-col__body.over { background: rgba(0, 124, 165, 0.08); outline: 2px dashed var(--primary); outline-offset: -4px; }
.kanban-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; box-shadow: var(--shadow-sm); cursor: grab; transition: box-shadow .15s, transform .1s; }
.kanban-card:hover { box-shadow: var(--shadow-md); }
.kanban-card.dragging { opacity: .5; cursor: grabbing; }
.kanban-card__title { display: block; font-weight: 600; font-size: 13px; margin: 4px 0 8px; color: var(--fg); line-height: 1.35; }
.kanban-card__title:hover { color: var(--primary); }
.kanban-card__meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.kanban-card__foot { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.avatar--xs { width: 22px; height: 22px; font-size: 10px; }

.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }

/* Bar chart (dashboard) */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 40px; align-items: center; gap: 12px; font-size: 13px; }
.bar-track { height: 10px; background: var(--border-light); border-radius: var(--radius-full); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--radius-full); background: var(--primary); }
