:root {
  --night: #0F1733;
  --navy: #24335D;
  --turq: #3BD9DB;
  --turq-soft: #8FE9EA;
  --ivory: #F6F2EA;
  --sand: #D7D3CB;
  --mute: #A9B0C6;
  --ochre: #C88A1C;
  --ochre-light: #E2A73C;
  --line: rgba(246,242,234,.10);
  --card: rgba(246,242,234,.04);
  --radius: 14px;
  --serif: Fraunces, Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--night); color: var(--ivory);
  font-family: "DM Sans", system-ui, sans-serif; -webkit-font-smoothing: antialiased; font-size: 14px; }
a { color: var(--turq); text-decoration: none; cursor: pointer; }
a:hover { color: var(--turq-soft); }
input, textarea, button, select { font-family: inherit; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 8px; } ::-webkit-scrollbar-thumb { background: rgba(246,242,234,.14); border-radius: 8px; }
@keyframes mnPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(59,217,219,.55); } 70% { box-shadow: 0 0 0 7px rgba(59,217,219,0); } }
@keyframes mnFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes dots { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }

.shell { display: flex; height: 100vh; background: linear-gradient(135deg, var(--navy) 0%, var(--night) 100%); position: relative; overflow: hidden; }
.stripes { position: absolute; inset: 0; pointer-events: none; background-image: repeating-linear-gradient(135deg, transparent 0 22px, rgba(59,217,219,.055) 22px 23px); }
.glow { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 22% 18%, rgba(59,217,219,.20) 0%, transparent 52%); }

/* ── Typo & éléments communs ── */
.eyebrow { font-size: 11px; letter-spacing: .25em; text-transform: uppercase; font-weight: 700; color: rgba(59,217,219,.85); }
.eyebrow.ochre { color: var(--ochre-light); }
.display { margin: 8px 0 0; font-family: var(--serif); font-weight: 500; font-size: 34px; line-height: 1.05; letter-spacing: -.02em; }
.display.xl { font-size: 40px; }
.display em { font-style: italic; color: var(--turq); }
.muted { color: var(--mute); }
.lead { margin: 10px 0 0; color: var(--mute); font-size: 15px; max-width: 540px; line-height: 1.55; }
.h2 { margin: 0; font-size: 12px; letter-spacing: .2em; text-transform: uppercase; font-weight: 700; }
.label { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; font-weight: 700; color: var(--mute); margin-bottom: 10px; }
.card { padding: 18px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 14px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 11px 20px; border-radius: 9999px; white-space: nowrap;
  border: 0; font-weight: 700; font-size: 13px; cursor: pointer; transition: transform .2s ease, opacity .2s ease, background .2s ease, border-color .2s ease, color .2s ease; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--turq); color: var(--navy); }
.btn-primary:hover:not(:disabled) { opacity: .9; transform: translateY(-1px); }
.btn-lg { padding: 13px 22px; font-size: 14px; }
.btn-ghost { background: transparent; color: var(--ivory); border: 1.5px solid rgba(246,242,234,.35); font-weight: 600; }
.btn-ghost:hover { border-color: var(--ivory); }
.btn-outline { background: transparent; color: var(--turq); border: 1.5px solid var(--turq); }
.btn-outline:hover { background: rgba(59,217,219,.12); }
.btn-text { background: transparent; color: var(--mute); font-weight: 600; padding: 11px 14px; }
.btn-text:hover { color: var(--ivory); }
.btn-block { width: 100%; }

.avatar { border-radius: 50%; display: grid; place-items: center; font-family: var(--serif); font-style: italic; color: var(--navy); flex: none; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 9999px; white-space: nowrap; font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tone-ready { background: rgba(59,217,219,.14); color: var(--turq); }
.tone-working { background: rgba(59,217,219,.14); color: var(--turq); }
.tone-working::before { animation: mnPulse 2s infinite; }
.tone-attention { background: rgba(200,138,28,.18); color: var(--ochre-light); }
.tone-paused { background: rgba(246,242,234,.10); color: var(--sand); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.switch { flex: none; width: 44px; height: 26px; border-radius: 9999px; border: 0; cursor: pointer; position: relative; background: rgba(246,242,234,.2); transition: background .2s ease; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--ivory); transition: left .2s ease; }
.switch.on { background: var(--turq); }
.switch.on::after { left: 21px; }
.switch:disabled { opacity: .5; cursor: wait; }

.empty { padding: 16px; border-radius: var(--radius); border: 1px dashed rgba(246,242,234,.2); color: var(--mute); font-size: 13px; }
.empty.big { padding: 48px; text-align: center; }
.empty.big .display { font-style: italic; color: var(--turq); font-size: 26px; }

/* ── Connexion ── */
.login { position: relative; z-index: 2; flex: 1; display: grid; place-items: center; padding: 24px 16px; overflow: auto; }
.login-card { width: 100%; max-width: 400px; padding: 32px; border-radius: 20px; background: rgba(15,23,51,.6); border: 1px solid rgba(59,217,219,.18); backdrop-filter: blur(8px); display: flex; flex-direction: column; gap: 14px; animation: mnFade .35s ease; }
.login-card .brand { padding: 0 0 8px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--sand); }
input.field, .login-card input, .modal input, .modal textarea, .modal select {
  padding: 12px 16px; border-radius: 12px; border: 1px solid rgba(246,242,234,.18); background: rgba(246,242,234,.06); color: var(--ivory); font-size: 15px; outline: none; }
.login-card input:focus, .modal input:focus, .modal textarea:focus, .modal select:focus { border-color: var(--turq); }
.form-error { color: #FFB4A2; font-size: 13px; }

/* ── Barre latérale ── */
.sidebar { position: relative; z-index: 2; width: 248px; flex: none; display: flex; flex-direction: column; padding: 28px 18px 22px; background: rgba(15,23,51,.55); border-right: 1px solid rgba(59,217,219,.14); backdrop-filter: blur(8px); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; }
.brand-mark { width: 36px; height: 36px; border-radius: 50%; background: var(--turq); display: grid; place-items: center; color: var(--navy); font-family: var(--serif); font-weight: 600; font-size: 18px; font-style: italic; flex: none; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { font-size: 10px; letter-spacing: .25em; text-transform: uppercase; font-weight: 700; color: rgba(59,217,219,.8); }
.menu-toggle { display: none; margin-left: auto; background: transparent; border: 1px solid rgba(246,242,234,.25); color: var(--ivory); border-radius: 10px; font-size: 18px; width: 40px; height: 38px; cursor: pointer; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; border-radius: 9999px; white-space: nowrap; border: 0; cursor: pointer; text-align: left; font-size: 14px; font-weight: 500; color: var(--ivory); background: transparent; transition: background .2s ease, color .2s ease; }
.nav button:hover { background: rgba(246,242,234,.08); }
.nav button.active { background: var(--turq); color: var(--navy); }
.nav svg { width: 18px; height: 18px; opacity: .9; flex: none; }
.nav .label-text { flex: 1; }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 9999px; background: var(--ochre); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.health { margin-top: auto; padding: 16px; border-radius: var(--radius); background: rgba(59,217,219,.08); border: 1px solid rgba(59,217,219,.18); }
.health.bad { background: rgba(200,138,28,.10); border-color: rgba(200,138,28,.35); }
.health-title { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; }
.health-title .dot { background: var(--turq); animation: mnPulse 2s infinite; }
.health.bad .dot { background: var(--ochre-light); animation: none; }
.health-sub { font-size: 12px; color: var(--mute); margin-top: 4px; line-height: 1.5; }
.me { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 8px 0; font-size: 13px; color: var(--sand); }
.me a { font-size: 12px; color: var(--mute); }

/* ── Contenu ── */
.main { position: relative; z-index: 1; flex: 1; min-width: 0; padding: 36px 44px 48px; overflow: auto; }
.screen { animation: mnFade .35s ease; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-top: 32px; }
.stat { padding: 20px 22px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); }
.stat-value { font-family: var(--serif); font-size: 36px; font-weight: 500; line-height: 1; }
.stat-label { margin-top: 10px; font-size: 10px; letter-spacing: .2em; text-transform: uppercase; font-weight: 600; color: var(--mute); }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 24px; margin-top: 32px; }
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.agent-card { cursor: pointer; transition: border-color .2s ease, background .2s ease; text-align: left; color: inherit; font: inherit; }
.agent-card:hover { border-color: rgba(59,217,219,.5); background: rgba(246,242,234,.06); }
.agent-id { display: flex; align-items: center; gap: 12px; }
.agent-name { font-weight: 700; font-size: 15px; }
.agent-role { font-size: 12px; color: var(--mute); }
.agent-task { margin-top: 12px; font-size: 13px; line-height: 1.5; color: var(--sand); }
.approval-mini { padding: 14px 16px; border-radius: var(--radius); background: rgba(200,138,28,.10); border: 1px solid rgba(200,138,28,.35); cursor: pointer; }
.approval-mini .who { font-size: 11px; letter-spacing: .15em; text-transform: uppercase; font-weight: 700; color: var(--ochre-light); }
.approval-mini .what { margin-top: 4px; font-size: 14px; font-weight: 600; line-height: 1.4; }
.timeline-row { display: flex; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.timeline-row .time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--turq); min-width: 62px; font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* Agents */
.agents-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 28px; }
.agent-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid transparent; background: transparent; color: var(--ivory); text-align: left; cursor: pointer; transition: background .2s ease; width: 100%; }
.agent-row:hover { background: rgba(246,242,234,.08); }
.agent-row.selected { background: rgba(59,217,219,.10); border-color: rgba(59,217,219,.4); }
.detail { padding: 32px; }
.detail-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 28px; margin-top: 28px; }
.bullets { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.bullets li { display: flex; gap: 10px; font-size: 14px; line-height: 1.5; color: var(--sand); }
.bullets li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--turq); margin-top: 8px; flex: none; }
.big-num { font-family: var(--serif); font-size: 26px; }
.history-row { display: flex; gap: 14px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 13px; }
.history-row .when { color: var(--mute); min-width: 86px; font-variant-numeric: tabular-nums; }
.history-row .what { color: var(--sand); }

/* Conversation */
.chat-layout { display: grid; grid-template-columns: 240px minmax(0, 860px); gap: 24px; height: calc(100vh - 84px); }
.conv-list { display: flex; flex-direction: column; gap: 6px; overflow: auto; min-height: 0; }
.conv-item { padding: 10px 12px; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--ivory); text-align: left; cursor: pointer; width: 100%; }
.conv-item:hover { background: rgba(246,242,234,.06); }
.conv-item.selected { background: rgba(59,217,219,.10); border-color: rgba(59,217,219,.4); }
.conv-item .t { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .s { font-size: 11px; color: var(--mute); margin-top: 2px; }
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-head { display: flex; align-items: center; gap: 14px; padding-bottom: 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-head select { padding: 9px 14px; border-radius: 9999px; border: 1px solid rgba(246,242,234,.25); background: rgba(15,23,51,.6); color: var(--ivory); font-size: 13px; cursor: pointer; }
.chat-head select option { background: var(--night); }
.messages { flex: 1; overflow: auto; padding: 24px 4px; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.msg { display: flex; }
.msg.me { justify-content: flex-end; }
.bubble { max-width: 76%; padding: 13px 17px; border-radius: 18px; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.msg.me .bubble { background: var(--turq); color: var(--navy); white-space: pre-wrap; }
.msg.agent .bubble { background: rgba(246,242,234,.06); color: var(--ivory); border: 1px solid rgba(246,242,234,.12); }
.bubble p { margin: 0 0 8px; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 4px 0 8px; padding-left: 20px; }
.bubble code { background: rgba(15,23,51,.6); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.bubble pre { background: rgba(15,23,51,.6); padding: 10px 12px; border-radius: 8px; overflow-x: auto; white-space: pre; }
.bubble h3, .bubble h4 { margin: 6px 0; font-size: 15px; }
.msg-meta { font-size: 11px; color: var(--mute); margin-top: 4px; }
.msg.me .msg-meta { text-align: right; }
.validation-tag { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: rgba(200,138,28,.12); border: 1px solid rgba(200,138,28,.35); font-size: 13px; }
.validation-tag strong { color: var(--ochre-light); }
.validation-tag.approved { background: rgba(59,217,219,.10); border-color: rgba(59,217,219,.35); }
.validation-tag.approved strong { color: var(--turq); }
.validation-tag.rejected { background: rgba(246,242,234,.05); border-color: var(--line); }
.validation-tag.rejected strong { color: var(--sand); }
.typing span { display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: var(--turq); animation: dots 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: 12px; }
.chip { flex: none; padding: 8px 14px; border-radius: 9999px; border: 1px solid rgba(59,217,219,.4); background: transparent; color: var(--turq); font-size: 13px; font-weight: 600; cursor: pointer; }
.chip:hover { background: rgba(59,217,219,.12); }
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 8px 8px 8px 20px; border-radius: 26px; background: rgba(246,242,234,.06); border: 1px solid rgba(246,242,234,.16); }
.composer textarea { flex: 1; border: 0; background: transparent; color: var(--ivory); font-size: 15px; outline: none; resize: none; max-height: 180px; padding: 11px 0; line-height: 1.4; }
.composer textarea::placeholder { color: var(--mute); }
.welcome { margin: auto 0; text-align: center; padding: 24px; }
.welcome .display { font-size: 28px; }

/* Missions */
.table { margin-top: 28px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.mission-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1.3fr) auto; gap: 20px; align-items: center; padding: 18px 22px; background: rgba(246,242,234,.03); border-top: 1px solid rgba(246,242,234,.08); }
.mission-row:first-child { border-top: 0; }
.mission-row.off .m-name { opacity: .5; }
.m-name { font-weight: 600; font-size: 15px; }
.warn { color: var(--ochre-light); font-size: 12px; margin-top: 2px; }

/* À valider */
.approval { padding: 24px 26px; border-radius: var(--radius); background: var(--card); border: 1px solid rgba(200,138,28,.4); }
.approval-badge { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 9999px; background: var(--ochre); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .05em; }
.approval h3 { margin: 14px 0 6px; font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.approval .why { margin: 0; font-size: 14px; line-height: 1.6; color: var(--sand); }
.preview { margin-top: 16px; padding: 16px 18px; border-radius: 10px; background: rgba(15,23,51,.6); border: 1px solid var(--line); font-size: 13px; line-height: 1.6; color: var(--sand); white-space: pre-wrap; max-height: 320px; overflow: auto; overflow-wrap: anywhere; }
.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* Journal */
.day-label { position: relative; text-align: center; font-size: 11px; letter-spacing: .25em; text-transform: uppercase; font-weight: 700; color: var(--mute); margin-bottom: 14px; }
.day-label span { position: relative; z-index: 1; background: #182548; padding: 0 14px; }
.day-label::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(246,242,234,.12); }
.log-row { display: grid; grid-template-columns: 56px 28px minmax(0, 1fr); gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid rgba(246,242,234,.08); }
.log-row .time { font-size: 13px; color: var(--mute); font-variant-numeric: tabular-nums; }
.log-row .text { font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.log-row .text span { color: var(--sand); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: -12px 0 24px; }
.chip.active { background: var(--turq); color: var(--navy); border-color: var(--turq); }

/* Réglages */
.settings-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 20px 24px; background: rgba(246,242,234,.03); border-top: 1px solid rgba(246,242,234,.08); }
.settings-row:first-child { border-top: 0; }
.s-label { font-weight: 600; font-size: 15px; }
.s-help { font-size: 13px; color: var(--mute); margin-top: 3px; line-height: 1.5; }

/* Modale */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(8,12,28,.7); display: grid; place-items: center; padding: 16px; animation: mnFade .2s ease; }
.modal { width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 28px; border-radius: 20px; background: #182548; border: 1px solid rgba(59,217,219,.2); display: flex; flex-direction: column; gap: 14px; }
.modal label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--sand); }
.modal textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.modal select option { background: var(--night); }
.modal .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60; padding: 12px 20px; border-radius: 9999px; background: var(--ivory); color: var(--navy); font-weight: 600; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.35); max-width: calc(100vw - 32px); text-align: center; animation: mnFade .25s ease; }
.toast.error { background: #FFB4A2; }
.loading { color: var(--mute); padding: 40px 0; }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); }
  .chat-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 14px; }
  .conv-list { flex-direction: row; align-items: stretch; overflow-x: auto; overflow-y: hidden; gap: 8px; padding-bottom: 4px; }
  .conv-list > .btn { width: auto; margin: 0 !important; flex: none; }
  .conv-list > .label { display: none; }
  #conv-items { display: flex; gap: 8px; }
  .conv-item { width: 190px; flex: none; border-color: var(--line); }
  .mission-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; }
  .mission-row .m-freq, .mission-row .m-next { grid-column: 1; }
  .mission-row .switch { grid-row: 1 / span 3; grid-column: 2; }
}
@media (max-width: 860px) {
  .shell { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  .sidebar { width: 100%; padding: 14px 16px; border-right: 0; border-bottom: 1px solid rgba(59,217,219,.14); position: sticky; top: 0; z-index: 10; }
  .brand { padding: 0; }
  .menu-toggle { display: block; }
  .sidebar .nav, .sidebar .health, .sidebar .me { display: none; }
  .sidebar.open .nav { display: flex; margin-top: 14px; }
  .sidebar.open .health { display: block; margin-top: 14px; }
  .sidebar.open .me { display: flex; }
  .main { padding: 24px 16px 40px; overflow: visible; }
  .display { font-size: 28px; } .display.xl { font-size: 32px; }
  .agents-layout { grid-template-columns: minmax(0, 1fr); }
  .detail { padding: 22px; }
  .chat-layout { height: calc(100vh - 120px); }
  .bubble { max-width: 90%; }
  .modal .grid2 { grid-template-columns: 1fr; }
}
