:root {
  --bg: #f3f7f4;
  --ink: #0e2218;
  --muted: #4f6a5c;
  --card: rgba(255, 255, 255, 0.82);
  --line: rgba(14, 34, 24, 0.14);
  --accent: #0c8c5f;
  --accent-2: #d6f26b;
  --danger: #b23a48;
  --radius: 16px;
  --shadow: 0 12px 35px rgba(10, 45, 25, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at 8% 15%, #d8ffd5 0%, transparent 28%),
    radial-gradient(circle at 85% 0%, #fff3bd 0%, transparent 22%),
    var(--bg);
  font-family: "IBM Plex Sans", sans-serif;
  min-height: 100vh;
  padding: 28px;
  position: relative;
  overflow-x: hidden;
}

body.modal-open {
  overflow: hidden;
}

h1,
h2,
h3,
.eyebrow,
.btn {
  font-family: "Space Grotesk", sans-serif;
}

.agent-fab {
  position: fixed;
  right: 22px;
  bottom: 28px;
  width: 62px;
  height: 62px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #2c2f47;
  color: #fff;
  box-shadow: 0 12px 24px rgba(22, 23, 35, 0.28);
  cursor: pointer;
  z-index: 70;
  transition: transform 160ms ease, box-shadow 160ms ease;
  display: grid;
  place-items: center;
}

.agent-fab:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 16px 28px rgba(22, 23, 35, 0.32);
}

.chat-icon {
  position: relative;
  width: 28px;
  height: 20px;
  display: block;
}

.chat-icon::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  border: 3px solid #fff;
  background: transparent;
}

.chat-icon::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  left: 6px;
  bottom: -4px;
  border-left: 3px solid #fff;
  border-bottom: 3px solid #fff;
  background: transparent;
  transform: rotate(-45deg);
}

.chat-dot {
  position: absolute;
  right: 7px;
  top: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.16);
}

.agent-assistant {
  position: fixed;
  right: 22px;
  bottom: 110px;
  width: min(360px, calc(100vw - 24px));
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(14, 34, 24, 0.12);
  border-radius: 20px 20px 18px 18px;
  box-shadow: 0 20px 40px rgba(9, 30, 20, 0.18);
  overflow: hidden;
  z-index: 80;
}

.agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #0f1f2f, #102d64);
  color: #fff;
}

.agent-label {
  margin: 0 0 3px;
  font-size: 0.7rem;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.agent-header h3 {
  margin: 0;
  font-size: 1.08rem;
}

.agent-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
}

.agent-messages {
  max-height: 280px;
  overflow-y: auto;
  padding: 14px 12px;
  display: grid;
  gap: 10px;
  background: #f7faf8;
}

.message {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.55;
  white-space: normal;
}

.message.assistant {
  background: #eaf6ef;
  color: #183728;
  border-top-left-radius: 4px;
}

.message.assistant strong,
.message.user strong {
  color: inherit;
}

.message.user {
  margin-left: auto;
  background: #dfe9ff;
  color: #102d64;
  border-top-right-radius: 4px;
}

.agent-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: #fff;
  border-top: 1px solid rgba(14, 34, 24, 0.08);
}

.agent-form input {
  flex: 1;
  border: 1px solid rgba(14, 34, 24, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.agent-form button {
  border: none;
  background: linear-gradient(135deg, #0c8c5f, #1bb17a);
  color: white;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
}

.bg-shape {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  opacity: 0.4;
  filter: blur(3px);
}

.bg-shape-1 {
  width: 220px;
  height: 220px;
  background: #9be9aa;
  top: 65%;
  left: -80px;
}

.bg-shape-2 {
  width: 280px;
  height: 280px;
  background: #ffe58c;
  top: -100px;
  right: -90px;
}

.topbar {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  animation: rise 460ms ease-out;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 6px;
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3.5vw, 2.5rem);
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#fileInput {
  display: none;
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

main {
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(5px);
}

.controls {
  padding: 16px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  align-items: start;
}

.search-wrap input,
.filters select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 5px;
}

.filters {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card {
  padding: 16px;
  animation: rise 520ms ease-out;
}

.kpi-card p {
  margin: 0;
  color: var(--muted);
}

.kpi-card h2 {
  margin: 8px 0 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.panel-head h3 {
  margin: 0;
}

.bars {
  display: grid;
  gap: 10px;
}

.grid-two .panel {
  padding: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(100px, 150px) 1fr auto;
  gap: 8px;
  align-items: center;
}

.bar-label,
.bar-value {
  font-size: 0.85rem;
}

.bar-track {
  background: #ecf1ed;
  border-radius: 999px;
  height: 9px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 420ms ease;
}

.table-panel {
  padding: 16px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.result-card {
  border: 1px solid rgba(14, 34, 24, 0.08);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(11, 31, 21, 0.07);
  padding: 18px 16px;
  display: grid;
  gap: 12px;
  min-height: 260px;
  animation: rise 420ms ease;
}

.result-title {
  margin: 0;
  text-align: center;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.15rem;
  color: #09275d;
}

.result-meta {
  margin: 0;
  text-align: center;
  color: #3f5d84;
  font-size: 0.83rem;
}

.result-desc {
  margin: 0;
  color: #355446;
  line-height: 1.48;
}

.result-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.result-action {
  justify-self: center;
  border: 1px solid #183b85;
  background: #fff;
  color: #0d2f74;
  border-radius: 10px;
  padding: 9px 16px;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  cursor: pointer;
  transition: all 150ms ease;
}

.result-action:hover {
  background: #f1f5ff;
}

.line-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #355446;
  line-height: 1.38;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  grid-column: 1 / -1;
  margin-top: 12px;
  padding-top: 8px;
}

.pagination-btn {
  border: 1px solid rgba(14, 34, 24, 0.14);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
}

.pagination-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pagination-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.loading-status {
  color: var(--muted);
  font-style: italic;
}

.chip-cell {
  min-width: 130px;
}

.badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 10px;
  line-height: 1.25;
}

.badge-public {
  background: #f1f6ff;
  border-color: #cdddf7;
  color: #284b75;
}

.badge-niveau {
  background: #eefcf2;
  border-color: #bfe8cb;
  color: #1f6542;
}

.badge-type {
  background: #fff7e7;
  border-color: #f0d7a0;
  color: #785613;
}

.badge-duree {
  background: #f2efff;
  border-color: #d8cef8;
  color: #4b2e90;
}

.badge-empty,
.badge-neutral {
  background: #f2f4f3;
  border-color: #d6ddda;
  color: #4f6a5c;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 10px;
  background: linear-gradient(120deg, #0c8c5f, #29a06f);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.link-btn:hover {
  filter: brightness(1.06);
}

a {
  color: var(--accent);
  font-weight: 600;
}

.status {
  padding: 10px 0;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
  font-weight: 600;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 19, 0.68);
}

.modal-card {
  position: relative;
  width: min(900px, calc(100% - 40px));
  max-height: 86vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.32);
  z-index: 1;
}

.modal-close {
  position: absolute;
  right: 12px;
  top: 10px;
  border: none;
  background: transparent;
  color: #213b66;
  font-size: 1.2rem;
  cursor: pointer;
  font-weight: 700;
}

.modal-kicker {
  margin: 0;
  color: #4a6187;
  font-size: 0.86rem;
}

.modal-header h3 {
  margin: 4px 0 0;
  font-size: 1.6rem;
  color: #102d64;
}

.modal-description {
  color: #365063;
  line-height: 1.6;
}

.modal-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  margin: 18px 0;
}

.modal-meta p {
  margin: 0;
  color: #355446;
  font-size: 0.92rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-start;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1024px) {
  body {
    padding: 16px;
  }

  .topbar {
    flex-direction: column;
  }

  .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .kpis,
  .grid-two {
    grid-template-columns: 1fr 1fr;
  }

  .results-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .filters,
  .kpis,
  .grid-two,
  .results-grid {
    grid-template-columns: 1fr;
  }

  .modal-card {
    width: calc(100% - 20px);
    padding: 18px;
  }

  .modal-meta {
    grid-template-columns: 1fr;
  }
}
