/* ═══════════════ IAG — thème lumineux & coloré (repris de la v1 Streamlit) ═══════════════ */
:root {
  --bg: #f0f4ff;
  --bg2: #e8eeff;
  --surface: #ffffff;
  --surface2: #f7f9ff;
  --border: #dce3f5;
  --border2: #c5d0ef;
  --accent: #3b6ef8;
  --accent2: #6189fa;
  --accent-light: #e8eeff;
  --indigo: #4f46e5;
  --teal: #0d9488;
  --amber: #d97706;
  --violet: #7c3aed;
  --text: #1e293b;
  --text2: #334155;
  --muted: #64748b;
  --muted2: #94a3b8;
  --side1: #1e2d6b;
  --side2: #2d3f8f;
  --shadow: 0 2px 16px rgba(59,110,248,0.10);
  --shadow-lg: 0 8px 40px rgba(59,110,248,0.15);
  --glow: 0 0 24px rgba(59,110,248,0.3);
  --mono: 'Space Mono', ui-monospace, monospace;
  --display: 'Syne', 'DM Sans', sans-serif;
  --sans: 'DM Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 50%, #faf0ff 100%) fixed;
  background-color: var(--bg);
  font-family: var(--sans);
  color: var(--text);
  font-size: 15px;
}
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 3px solid #93b4ff; outline-offset: 2px; }

/* ── Boutons ── */
.btn-primary {
  background: linear-gradient(135deg, #3b6ef8 0%, #4f46e5 100%);
  color: #fff; border: none; border-radius: 10px;
  font-family: var(--display); font-weight: 700; letter-spacing: .5px;
  padding: 13px 24px; font-size: 15px;
  box-shadow: 0 4px 14px rgba(59,110,248,0.35);
  transition: box-shadow .2s, transform .2s;
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 20px rgba(59,110,248,0.5); transform: translateY(-1px); }
.btn-block { width: 100%; }
.btn-secondary {
  background: var(--surface); color: var(--accent); border: 1.5px solid #c7d6fe;
  border-radius: 10px; padding: 10px 14px; font-weight: 600; font-size: 13px;
}
.btn-secondary:hover { background: var(--accent-light); }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.10); color: #e2e8ff;
  border: 1px solid rgba(255,255,255,0.25); border-radius: 8px;
  padding: 7px 10px; font-size: 12.5px; cursor: pointer;
}
.btn-ghost:hover { background: rgba(255,255,255,0.18); }
.btn-ghost.rec { background: #e11d48; border-color: #fb7185; animation: rec 1.2s infinite; }
@keyframes rec { 50% { box-shadow: 0 0 0 6px rgba(225,29,72,.25); } }
.btn-ghost-dark {
  background: var(--surface); border: 1.5px solid var(--border); color: var(--text2);
  border-radius: 8px; padding: 6px 12px; font-size: 13px;
}
.btn-ghost-dark:hover { border-color: var(--accent); color: var(--accent); }
.link-mini { background: none; border: none; color: #a5b4fc; font-size: 10px; text-decoration: underline; padding: 0; }

/* ── Connexion ── */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(160deg, #1e2d6b 0%, #2d4eb0 55%, #1a2860 100%);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border-radius: 20px; padding: 34px 30px 24px; box-shadow: 0 20px 60px rgba(10,20,70,.45);
  text-align: center;
}
.login-logo { font-size: 46px; }
.login-title { font-family: var(--display); font-size: 30px; font-weight: 800; color: var(--side1); }
.login-sub { font-family: var(--mono); font-size: 10px; letter-spacing: 2px; color: var(--muted); text-transform: uppercase; margin-bottom: 22px; }
.login-card form { text-align: left; }
.login-card label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text2); margin: 12px 0 5px; }
.login-card input {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 15px; font-family: inherit; background: var(--surface2);
}
.login-card input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(59,110,248,.15); }
.login-err { color: #dc2626; font-size: 12.5px; min-height: 18px; margin: 10px 0 6px; }
.login-foot { margin-top: 20px; font-family: var(--mono); font-size: 9.5px; color: var(--muted2); }

/* ── Mise en page ── */
.app { display: grid; grid-template-columns: 290px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #1e2d6b 0%, #2d3f8f 60%, #1a2860 100%);
  color: #e2e8ff; padding: 0 18px 28px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.main { padding: 18px 28px 32px; min-width: 0; }

.side-brand { text-align: center; padding: 24px 0 18px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.side-logo { font-size: 36px; }
.side-name { font-family: var(--display); font-size: 21px; font-weight: 800; color: #fff; }
.side-tag { font-family: var(--mono); font-size: 8px; letter-spacing: 2px; color: #a5b4fc; }
.side-ver { font-size: 11px; color: #818cf8; margin-top: 4px; }
.side-section { padding: 16px 0; border-bottom: 1px solid rgba(255,255,255,0.08); }
.side-label { font-family: var(--mono); font-size: 9px; letter-spacing: 2px; color: #a5b4fc; text-transform: uppercase; margin-bottom: 9px; }
.side-label-row { display: flex; justify-content: space-between; align-items: center; }
.side-input, .side-select, .side-textarea {
  width: 100%; background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px; color: #fff; font-size: 13.5px; padding: 8px 10px; font-family: inherit;
}
.side-input { margin-bottom: 8px; }
.side-input::placeholder, .side-textarea::placeholder { color: rgba(255,255,255,0.45); }
.side-select option, .side-select optgroup { background: #2d3f8f; color: #fff; }
.side-textarea { resize: vertical; line-height: 1.45; }
.country-card {
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; padding: 10px 12px; margin-top: 10px;
}
.country-card .cc-flag { font-size: 22px; }
.country-card .cc-name { font-weight: 700; font-size: 14px; color: #fff; }
.country-card .cc-reg { font-size: 11px; color: #a5b4fc; }
.country-card .cc-base { font-size: 11px; color: #c7d2fe; margin-top: 6px; }
.audio-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.audio-status { font-size: 11.5px; color: #c7d2fe; margin-top: 6px; min-height: 14px; }
.audio-status.err { color: #fda4af; }

.w-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 12px; }
.w-id { color: #c7d2fe; }
.w-bar { width: 60px; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
.w-bar div { height: 100%; border-radius: 2px; }
.w-right { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; }

.h-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.h-name { font-size: 11.5px; color: #e2e8ff; }
.h-ts { font-family: var(--mono); font-size: 9px; color: #818cf8; }
.h-score { font-size: 13px; font-weight: 700; }

/* ── Barre supérieure ── */
.topbar { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-bottom: 14px; }
.topbar-user { font-size: 13px; color: var(--text2); }
.btn-menu { display: none; margin-right: auto; background: var(--side1); color: #fff; border: none; border-radius: 8px; padding: 6px 12px; font-size: 18px; }

/* ── Bandeau ── */
.page-header {
  background: linear-gradient(135deg, #1e2d6b 0%, #2d4eb0 50%, #1a3fa8 100%);
  border-radius: 20px; padding: 26px 32px; margin-bottom: 24px;
  position: relative; overflow: hidden; box-shadow: var(--shadow-lg);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
}
.page-header::after {
  content: 'IAG'; position: absolute; font-family: var(--display); font-size: 140px; font-weight: 800;
  color: rgba(255,255,255,0.05); right: 20px; bottom: -34px; line-height: 1; pointer-events: none;
}
.header-title { font-family: var(--display); font-size: 26px; font-weight: 800; color: #fff; margin-bottom: 4px; }
.header-sub { font-family: var(--mono); font-size: 10px; letter-spacing: 2px; color: #a5b4fc; text-transform: uppercase; }
.ph-country { margin-top: 14px; display: flex; align-items: center; gap: 10px; }
.ph-flag { font-size: 28px; }
.ph-cname { font-size: 17px; font-weight: 700; color: #fff; }
.ph-meta { font-size: 11.5px; color: #a5b4fc; }
.ph-right { text-align: right; position: relative; z-index: 1; }
.header-date { font-family: var(--mono); font-size: 11px; color: #c7d2fe; margin-bottom: 4px; }
.ph-badge { margin-top: 10px; background: rgba(255,255,255,0.1); border-radius: 8px; padding: 6px 12px; font-family: var(--mono); font-size: 10px; color: #c7d2fe; }

/* ── Ligne principale ── */
.top-row { display: grid; grid-template-columns: 5fr 3fr; gap: 22px; align-items: start; }
.iag-hero {
  background: linear-gradient(135deg, #ffffff 0%, #f8faff 100%);
  border: 2px solid var(--border); border-radius: 20px; padding: 24px 28px; text-align: center;
  box-shadow: var(--shadow); transition: box-shadow .3s;
}
.iag-hero:hover { box-shadow: var(--shadow-lg); }
.iag-label { font-family: var(--mono); font-size: 10px; letter-spacing: 3px; color: var(--muted); text-transform: uppercase; }
.gauge { width: 100%; max-width: 360px; display: block; margin: 4px auto 0; }
.gauge-score { font-family: var(--display); font-weight: 800; }
.level-pill {
  display: inline-block; font-family: var(--mono); font-size: 13px; font-weight: 700; letter-spacing: 3px;
  padding: 6px 20px; border-radius: 30px; border: 2px solid; margin: 6px 0 10px;
}
.iag-timestamp { font-size: 11px; color: var(--muted2); font-family: var(--mono); }
.calc-line { margin-top: 12px; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.chip { font-size: 11.5px; background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: 4px 11px; color: var(--text2); }
.chip b { color: var(--text); }
.ref-box { margin-top: 12px; background: #eff6ff; border: 1.5px solid #bfdbfe; border-radius: 10px; padding: 10px 16px; font-size: 12.5px; color: #1e40af; }
.idle-score { font-family: var(--display); font-size: 6rem; font-weight: 800; line-height: 1; color: #dce3f5; margin: 12px 0; }

.panel { display: flex; flex-direction: column; gap: 12px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric-card {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px;
  padding: 14px 16px; position: relative; overflow: hidden; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s;
}
.metric-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.metric-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.metric-card.blue::before   { background: linear-gradient(90deg, #3b6ef8, #818cf8); }
.metric-card.teal::before   { background: linear-gradient(90deg, #0d9488, #34d399); }
.metric-card.amber::before  { background: linear-gradient(90deg, #d97706, #fbbf24); }
.metric-card.violet::before { background: linear-gradient(90deg, #7c3aed, #a78bfa); }
.metric-label { font-family: var(--mono); font-size: 9px; letter-spacing: 2px; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }
.metric-value { font-family: var(--display); font-size: 2rem; font-weight: 800; line-height: 1; }
.metric-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.btn-run { padding: 15px 20px; font-size: 15.5px; }
.progress-wrap { background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.progress-track { height: 8px; background: var(--accent-light); border-radius: 4px; overflow: hidden; }
.progress-fill-main { height: 100%; width: 0; background: linear-gradient(90deg, #3b6ef8, #7c3aed); transition: width .5s ease; }
.progress-text { font-size: 12px; color: var(--muted); margin-top: 6px; }
.exports { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── Bannières ── */
.alert-banner { border-radius: 10px; padding: 11px 14px; margin-bottom: 10px; display: flex; align-items: flex-start; gap: 10px; font-size: 13px; line-height: 1.45; }
.alert-banner .ab-ico { font-size: 17px; line-height: 1.1; }
.alert-green  { background: #f0fdf4; border: 1.5px solid #86efac; color: #166534; }
.alert-yellow { background: #fffbeb; border: 1.5px solid #fcd34d; color: #92400e; }
.alert-orange { background: #fff7ed; border: 1.5px solid #fb923c; color: #9a3412; }
.alert-red    { background: #fef2f2; border: 1.5px solid #fca5a5; color: #991b1b; }

/* ── Sections ── */
.section-header { display: flex; align-items: center; gap: 10px; margin: 28px 0 14px; flex-wrap: wrap; }
.section-title { font-family: var(--display); font-size: 17px; font-weight: 700; }
.section-pill { background: var(--accent-light); color: var(--accent); font-family: var(--mono); font-size: 9px; letter-spacing: 1.5px; padding: 3px 10px; border-radius: 20px; border: 1px solid #c7d6fe; }

.synth-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; }
.synth-box {
  background: linear-gradient(135deg, #f8faff 0%, #f0f4ff 100%); border: 1.5px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: 12px; padding: 18px; font-size: 14px;
  color: var(--text2); line-height: 1.75; box-shadow: var(--shadow);
}
.reco-box { background: #eff6ff; border: 1.5px solid #bfdbfe; border-left: 4px solid #3b6ef8; border-radius: 10px; padding: 12px 14px; font-size: 13px; color: #1e40af; line-height: 1.6; margin-bottom: 10px; }
.calib-box { background: #f0fdf4; border: 1.5px solid #86efac; border-radius: 10px; padding: 11px 14px; font-size: 12px; color: #166534; line-height: 1.5; }
.box-kicker { font-family: var(--mono); font-size: 9px; letter-spacing: 1px; margin-bottom: 6px; opacity: .85; }
.scen-list { margin-top: 14px; display: grid; gap: 8px; }
.scen {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 12px;
  display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--text2);
}
.scen-proba { font-family: var(--mono); font-size: 9.5px; font-weight: 700; padding: 3px 8px; border-radius: 12px; white-space: nowrap; }
.p-faible { background: #f0fdf4; color: #166534; } .p-moyenne { background: #fffbeb; color: #92400e; } .p-forte { background: #fef2f2; color: #991b1b; }
.indic-list { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--text2); line-height: 1.6; }

.radar-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.radar-card, .news-box { background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.news-box { font-size: 13px; line-height: 1.65; color: var(--text2); max-height: 380px; overflow: auto; white-space: pre-wrap; }
.news-box h4 { margin: 0 0 8px; font-family: var(--display); font-size: 14px; color: var(--text); white-space: normal; }

/* ── Agents ── */
.agents-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.agent-card {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px;
  box-shadow: 0 1px 8px rgba(59,110,248,0.07); transition: border-color .2s, box-shadow .2s; overflow: hidden;
}
.agent-card:hover { border-color: var(--border2); box-shadow: var(--shadow); }
.agent-card.waiting { opacity: .55; }
.agent-card.active { border-color: var(--accent); animation: pulse-card 2s infinite; }
@keyframes pulse-card { 0%,100% { box-shadow: 0 0 0 0 rgba(59,110,248,0.2); } 50% { box-shadow: 0 0 0 6px rgba(59,110,248,0.08); } }
.agent-card summary { list-style: none; padding: 13px 16px; cursor: pointer; }
.agent-card summary::-webkit-details-marker { display: none; }
.agent-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.agent-name { font-family: var(--display); font-weight: 700; font-size: 13.5px; }
.agent-kpi { font-size: 11px; color: var(--muted2); margin-top: 2px; }
.agent-badge { font-family: var(--mono); font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 20px; white-space: nowrap; }
.agent-state { font-family: var(--mono); font-size: 10.5px; color: var(--muted2); white-space: nowrap; }
.agent-state.run { color: var(--amber); }
.bar { width: 100%; height: 6px; background: #eef2fb; border-radius: 3px; margin-top: 9px; overflow: hidden; }
.bar div { height: 100%; border-radius: 3px; transition: width .8s ease; }
.agent-body { padding: 0 16px 14px; }
.agent-analysis { font-size: 13px; color: #475569; line-height: 1.65; margin: 4px 0 10px; }
.signal { background: #f8faff; border: 1.5px solid var(--border); border-radius: 8px; padding: 9px 12px; margin-bottom: 10px; }
.signal-k { font-family: var(--mono); font-size: 8.5px; letter-spacing: 1.5px; color: var(--muted2); margin-bottom: 3px; }
.signal-v { font-size: 13px; font-weight: 500; }
.agent-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 11px; color: var(--muted2); }
.tag-est { font-family: var(--mono); font-size: 9px; background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; border-radius: 10px; padding: 1px 7px; margin-left: 6px; }

/* ── Console ── */
.log-console {
  background: #1e1b4b; border: 1.5px solid #3730a3; border-radius: 12px; padding: 14px 18px;
  font-family: var(--mono); font-size: 11px; color: #a5b4fc; max-height: 230px; overflow-y: auto; line-height: 1.9;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.2);
}
.log-time { color: #818cf8; } .log-agent { color: #38bdf8; }
.log-ok { color: #4ade80; } .log-warn { color: #fbbf24; } .log-err { color: #f87171; } .log-info { color: #c7d2fe; }

.iag-footer { margin-top: 44px; border-top: 1.5px solid var(--border); padding-top: 16px; text-align: center; font-family: var(--mono); font-size: 10px; color: var(--muted2); line-height: 1.8; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .top-row, .synth-grid, .radar-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 290px; transform: translateX(-100%); transition: transform .25s; box-shadow: 8px 0 30px rgba(0,0,0,.3); }
  .sidebar.open { transform: none; }
  .btn-menu { display: block; }
  .main { padding: 14px 16px 28px; }
  .agents-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; padding: 20px; }
  .ph-right { text-align: left; }
  .header-title { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
