:root {
  --green: #0A6B47; --green-d: #07503A; --green-l: #E7F2EC; --gold: #E8A800; --red: #C0322B;
  --red-l: #FBE9E7; --ink: #13261E; --muted: #4E6158; --border: #D5E0DA; --border-d: #A9BBB1;
  --bg: #F4F7F5; --white: #FFFFFF; --warn-l: #FFF4D6; --warn-d: #6B4A00;
  --head: 'Plus Jakarta Sans', Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, system-ui, sans-serif; }
a { color: var(--green); } a:hover { color: var(--green-d); }
h1, h2, h3 { font-family: var(--head); margin: 0; }
input, select, textarea, button { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); } .small { font-size: 13px; } .right { margin-left: auto; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .col { display: flex; flex-direction: column; gap: 6px; }
.grow { flex: 1; min-width: 0; }

/* Boutons et champs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--green); background: var(--green); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--green-d); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--border-d); } .btn.ghost:hover { background: var(--bg); color: var(--ink); }
.btn.danger { background: var(--red); border-color: var(--red); } .btn.danger:hover { background: #9E2620; }
.icon-btn { background: transparent; border: 1px solid transparent; color: var(--muted); min-width: 40px; min-height: 40px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; font-weight: 600; font-size: 14px; padding: 0 8px; }
.icon-btn:hover { background: var(--green-l); color: var(--green-d); }
.icon-btn.on { color: var(--green); background: var(--green-l); }
.icon-btn.danger:hover { background: var(--red-l); color: var(--red); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; }
.input, select.input { height: 44px; border: 1px solid var(--border-d); border-radius: 8px; padding: 0 12px; background: #fff; width: 100%; }
.input:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: 1px; }
.alert { padding: 10px 14px; border-radius: 8px; font-size: 14px; }
.alert.err { background: var(--red-l); color: #8A1F1A; } .alert.ok { background: var(--green-l); color: var(--green-d); } .alert.info { background: var(--warn-l); color: var(--warn-d); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; white-space: nowrap; background: var(--green-l); color: var(--green-d); }
.badge.run { background: var(--warn-l); color: var(--warn-d); } .badge.err { background: var(--red-l); color: var(--red); } .badge.off { background: #E9EEEB; color: var(--muted); }
.tricolor { display: flex; height: 3px; } .tricolor i { flex: 1; } .tricolor i:nth-child(1) { background: var(--green); } .tricolor i:nth-child(2) { background: var(--gold); } .tricolor i:nth-child(3) { background: var(--red); }

/* Logo */
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo .mark { width: 40px; height: 40px; border-radius: 10px; background: var(--green); display: flex; align-items: flex-end; justify-content: center; gap: 4px; padding-bottom: 9px; }
.logo .mark i { width: 5px; background: #fff; border-radius: 1px; } .logo .mark i:nth-child(1) { height: 10px; } .logo .mark i:nth-child(2) { height: 18px; background: var(--gold); } .logo .mark i:nth-child(3) { height: 14px; }
.logo b { font: 800 20px var(--head); letter-spacing: .5px; color: var(--ink); display: block; line-height: 1.15; } .logo small { font-size: 12px; color: var(--muted); }
.logo.inv .mark { background: #fff; } .logo.inv .mark i { background: var(--green); } .logo.inv .mark i:nth-child(2) { background: var(--gold); } .logo.inv b { color: #fff; } .logo.inv small { color: #D7EDE2; }
.logo.sm .mark { width: 34px; height: 34px; border-radius: 9px; gap: 3px; padding-bottom: 8px; } .logo.sm .mark i { width: 4px; } .logo.sm .mark i:nth-child(1) { height: 8px; } .logo.sm .mark i:nth-child(2) { height: 14px; } .logo.sm .mark i:nth-child(3) { height: 11px; }

/* Pages d'authentification */
.auth { min-height: 100vh; display: flex; flex-wrap: wrap; }
.auth .hero { flex: 1 1 420px; background: var(--green); color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.auth .hero h2 { font-size: 40px; line-height: 1.15; font-weight: 800; } .auth .hero p { font-size: 17px; line-height: 1.6; color: #E3F2EA; margin: 0; }
.auth .hero li { display: flex; align-items: center; gap: 12px; font-size: 16px; } .auth .hero ul { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 12px; } .auth .hero li svg { color: var(--gold); width: 20px; height: 20px; }
.auth .panel { flex: 1 1 480px; display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 28px; }
.auth .card { width: 100%; max-width: 440px; padding: 40px 36px; display: flex; flex-direction: column; gap: 20px; }
.auth .card h1 { font-size: 28px; font-weight: 800; }

/* En-tête */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 10px 28px; background: #fff; border-bottom: 1px solid var(--border); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 8px; font-weight: 600; color: var(--muted); text-decoration: none; }
.nav a.on { background: var(--green-l); color: var(--green-d); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.who { line-height: 1.25; } .who b { font-size: 14px; font-weight: 600; display: block; } .who span { font-size: 12px; color: var(--muted); }

/* Conversation */
.chat { flex: 1; display: flex; min-height: 0; height: calc(100vh - 68px); }
.side { width: 300px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.search { position: relative; } .search svg { position: absolute; left: 12px; top: 13px; color: var(--muted); } .search .input { padding-left: 40px; font-size: 14px; }
.group { display: flex; flex-direction: column; gap: 2px; }
.group > span { font-size: 12px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); padding: 0 12px 4px; }
.conv { display: flex; align-items: center; border-radius: 8px; padding: 0 4px 0 12px; }
.conv a { flex: 1; min-width: 0; min-height: 40px; display: flex; align-items: center; font-size: 14px; color: var(--ink); text-decoration: none; }
.conv a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .icon-btn { display: none; min-width: 32px; min-height: 32px; padding: 0; }
.conv:hover, .conv.on { background: var(--green-l); } .conv.on a { font-weight: 600; color: var(--green-d); } .conv:hover .icon-btn, .conv.on .icon-btn { display: inline-flex; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 28px; border-bottom: 1px solid var(--border); background: #fff; min-height: 62px; }
.main-head h1 { font: 700 18px Inter, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msgs { flex: 1; overflow-y: auto; padding: 28px; display: flex; flex-direction: column; gap: 22px; }
.q { align-self: flex-end; max-width: 70%; background: var(--green); color: #fff; padding: 12px 16px; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.a { display: flex; gap: 12px; align-items: flex-start; }
.bubble { flex: 1; min-width: 0; max-width: 760px; background: #fff; border: 1px solid var(--border); border-radius: 4px 16px 16px 16px; padding: 16px 18px 8px; display: flex; flex-direction: column; gap: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.bubble p, .bubble ul, .bubble ol { margin: 0; } .bubble ul, .bubble ol { padding-left: 22px; }
.bubble sup { color: var(--green); font-weight: 700; font-size: 11px; padding: 0 1px; }
.sources { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.sources > span, .label { font-size: 12px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 99px; background: #fff; font-size: 13px; font-weight: 500; cursor: pointer; max-width: 100%; }
.chip:hover { border-color: var(--green); background: var(--green-l); } .chip svg { width: 16px; height: 16px; color: var(--green); } .chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .chip em { font-style: normal; color: var(--muted); white-space: nowrap; }
.composer { padding: 16px 28px 18px; border-top: 1px solid var(--border); background: #fff; display: flex; flex-direction: column; gap: 8px; }
.composer textarea { flex: 1; min-width: 0; resize: none; border: 1px solid var(--border-d); border-radius: 12px; padding: 12px 14px; line-height: 1.5; }
.send { width: 50px; height: 50px; border-radius: 12px; border: none; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; } .send:disabled { opacity: .5; }
.empty { margin: auto; text-align: center; max-width: 520px; display: flex; flex-direction: column; gap: 14px; align-items: center; color: var(--muted); } .empty h2 { color: var(--ink); font-size: 26px; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.dots i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--border-d); margin-right: 4px; animation: blink 1.2s infinite; } .dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* Pages de contenu (compte, administration) */
.page { width: 100%; max-width: 1220px; margin: 0 auto; padding: 32px 24px 56px; display: flex; flex-direction: column; gap: 22px; }
.page.narrow { max-width: 760px; }
.page h1 { font-size: 30px; font-weight: 800; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tabs a { padding: 10px 16px; font-weight: 600; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 8px; align-items: center; }
.tabs a.on { color: var(--green-d); border-color: var(--green); }
.form { display: flex; flex-direction: column; gap: 16px; }
.drop { border: 2px dashed var(--border-d); border-radius: 14px; background: #fff; padding: 28px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.drop.over { border-color: var(--green); background: var(--green-l); }
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: 14px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; } tr:last-child td { border-bottom: none; }
td .name { font-weight: 600; overflow-wrap: anywhere; } td .sub { font-size: 13px; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; font-size: 14px; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; } .kpi b { font: 800 28px var(--head); display: block; } .kpi span { font-size: 13px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }
.card h3 { font: 700 16px Inter, sans-serif; margin-bottom: 12px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; } .bars div { flex: 1; background: var(--green); border-radius: 3px 3px 0 0; min-height: 2px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; } .list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; } .list li:last-child { border: none; } .list li span:first-child { overflow-wrap: anywhere; }

/* Fenêtres et messages */
.overlay { position: fixed; inset: 0; background: rgba(19, 38, 30, .5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: 16px; padding: 28px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; } .modal h2 { font-size: 22px; font-weight: 800; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; max-width: 90vw; } #toast.show { opacity: 1; } #toast.err { background: var(--red); }

@media (max-width: 820px) {
  .topbar { padding: 10px 14px; } .who, .logo small { display: none; } .nav a span { display: none; }
  .chat { flex-direction: column; height: auto; } .side { width: 100%; max-height: 240px; border-right: none; border-bottom: 1px solid var(--border); }
  .main { min-height: 70vh; } .msgs, .composer, .main-head { padding-left: 14px; padding-right: 14px; } .q { max-width: 90%; }
  .auth .hero { padding: 32px 24px; } .auth .hero h2 { font-size: 28px; }
}
