/* ── Variables ─────────────────────────────────────────────── */
:root {
  --navy: #1A2E4A;
  --navy-light: #243D60;
  --gold: #C9A237;
  --gold-light: #E8C96A;
  --bg: #F4F1EC;
  --surface: #FFFFFF;
  --border: #E2DDD4;
  --border-light: #EDE9E2;
  --text: #1A1814;
  --muted: #6B6560;
  --hint: #9E9890;
  --vert: #1A6B35; --vert-bg: #E4F5EC;
  --noire: #3A3530; --noire-bg: #EDEAE6;
  --rouge: #B32B2B; --rouge-bg: #FAE6E6;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  --transition: .15s ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0 }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: #ECEAE6; color: var(--text); font-size: 14px; line-height: 1.5; min-height: 100vh }

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  background: linear-gradient(180deg, #13233a 0%, #1a2e4a 45%, #243d60 100%);
  border-right: 2px solid var(--gold);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 286px;
  z-index: 80;
  box-shadow: 6px 0 24px rgba(7, 14, 25, .22);
  transition: width .24s cubic-bezier(.2,.7,.2,1);
  overflow: hidden;
}
.topbar-main {
  padding: 14px 12px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  transition: gap .24s ease, padding .24s ease;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  flex: 1;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,.32);
  background: linear-gradient(145deg, #e2c46d, #b38624);
  color: #1a1813;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .7px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.42), 0 5px 12px rgba(0,0,0,.2);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  transition: opacity .16s ease, transform .16s ease;
}

.brand-title {
  color: #f6e0a5;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .34px;
  line-height: 1.1;
  font-family: "Cambria", "Times New Roman", serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-client {
  color: rgba(255,255,255,.7);
  font-weight: 600;
  font-size: 11.5px;
  line-height: 1.1;
  letter-spacing: .4px;
  text-transform: uppercase;
}

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px;
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.88);
  cursor: pointer;
}

.sidebar-toggle:hover {
  border-color: rgba(201,162,55,.65);
  color: #ffe4a4;
}

.nav-toggle {
  display: none;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 8px;
  background: rgba(255,255,255,.05);
  color: rgba(255,255,255,.9);
  font-size: 17px;
  cursor: pointer;
}

.nav-toggle:hover {
  border-color: rgba(201,162,55,.65);
  color: #ffe4a4;
}

.top-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  transition: margin-top .24s ease;
}
.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid transparent;
  color: rgba(255,255,255,.73);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition), padding .2s ease, gap .2s ease;
  text-decoration: none;
  letter-spacing: .15px;
  width: 100%;
  position: relative;
}

.nav-icon {
  width: 16px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.nav-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity .14s ease, transform .14s ease;
}

.nav-short {
  display: none;
  margin-left: auto;
  min-width: 22px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid rgba(201,162,55,.55);
  background: rgba(201,162,55,.17);
  color: #f5e7be;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .4px;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}
.nav-item:hover {
  color: rgba(255,255,255,.95);
  border-color: rgba(255,255,255,.2);
  background: rgba(255,255,255,.08);
}
.nav-item.active {
  color: #fffefc;
  font-weight: 600;
  background: linear-gradient(145deg, rgba(224, 189, 108, .32), rgba(201, 162, 55, .2));
  border: 1px solid rgba(224, 189, 108, .58);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2);
}

.top-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.14);
}
.global-radio-picker { display: flex; flex-direction: column; align-items: stretch; gap: 6px }
.global-radio-picker label { color: rgba(255,255,255,.7); font-size: 12px; font-weight: 600 }
.global-radio-picker select {
  min-width: 0;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.12);
  color: #fff;
  padding: 0 10px;
}
.global-radio-picker select:focus {
  outline: none;
  border-color: rgba(228, 194, 109, .8);
}
.global-radio-picker select option { color: var(--text) }
.radio-scope-label { color: rgba(255,255,255,.62); font-size: 11px; white-space: nowrap }
.api-status { display: inline-flex; align-items: center; gap: 5px }
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0 }
.dot-ok { background: #2ECC71 }
.dot-err { background: #E74C3C }
.auth-user { color: rgba(255,255,255,.75); font-size: 12px; font-weight: 500 }
.btn-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.05);
  color: rgba(255,255,255,.65);
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-logout:hover {
  border-color: rgba(201,162,55,.6);
  color: var(--gold);
  background: rgba(201,162,55,.08);
}

.has-tooltip {
  position: relative;
}

body.sidebar-collapsed .has-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #0f1b2b;
  color: #f8f5ea;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .2px;
  white-space: nowrap;
  border: 1px solid rgba(201,162,55,.55);
  border-radius: 7px;
  padding: 5px 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
  z-index: 90;
}

body.sidebar-collapsed .has-tooltip:hover::after {
  opacity: 1;
}

body.sidebar-collapsed .topbar {
  width: 86px;
}

body.sidebar-collapsed .topbar-main {
  gap: 8px;
}

body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .radio-scope-label,
body.sidebar-collapsed .global-radio-picker label,
body.sidebar-collapsed .auth-user,
body.sidebar-collapsed .api-status {
  display: none;
}

body.sidebar-collapsed .brand {
  justify-content: center;
}

body.sidebar-collapsed .top-actions {
  align-items: center;
}

body.sidebar-collapsed .global-radio-picker {
  width: 100%;
}

body.sidebar-collapsed .global-radio-picker select {
  font-size: 11px;
  padding: 0 6px;
}

body.sidebar-collapsed .nav-item {
  justify-content: flex-start;
  gap: 6px;
  font-size: 0;
  padding: 8px 6px;
}

body.sidebar-collapsed .nav-text {
  opacity: 0;
  transform: translateX(-4px);
  width: 0;
  display: none;
}

body.sidebar-collapsed .nav-icon {
  font-size: 15px;
}

body.sidebar-collapsed .nav-short {
  display: inline-flex;
}

body.sidebar-collapsed .nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #0f1b2b;
  color: #f8f5ea;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .2px;
  white-space: nowrap;
  border: 1px solid rgba(201,162,55,.55);
  border-radius: 7px;
  padding: 5px 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
}

body.sidebar-collapsed .nav-item:hover::after {
  opacity: 1;
}

body.sidebar-collapsed .nav-item.active .nav-short {
  border-color: rgba(224,189,108,.75);
  background: rgba(224,189,108,.27);
  color: #fff7de;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 36, .58);
  z-index: 350;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 42px rgba(0,0,0,.22);
  padding: 20px;
  display: grid;
  gap: 12px;
}
.auth-card h2 {
  color: var(--navy);
  font-size: 20px;
}
.auth-sub {
  color: var(--muted);
  font-size: 12.5px;
  margin-bottom: 4px;
}

/* ── Main ──────────────────────────────────────────────────── */
#main {
  margin-left: 286px;
  padding: 18px 20px 40px;
  max-width: none;
  width: calc(100% - 286px);
  transition: margin-left .24s cubic-bezier(.2,.7,.2,1), width .24s cubic-bezier(.2,.7,.2,1);
}

body.sidebar-collapsed #main {
  margin-left: 86px;
  width: calc(100% - 86px);
}

/* ── Pages ─────────────────────────────────────────────────── */
.page { display: none }
.page.active { display: block }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.page-header h1 { font-size: 20px; font-weight: 600; color: var(--navy) }
.page-date { font-size: 13px; color: var(--muted) }

/* ── KPI Grid ──────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px }
.kpi {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: none;
  transition: var(--transition);
}
.kpi:hover { box-shadow: 0 2px 12px rgba(0,0,0,.09) }
.kpi .kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 8px }
.kpi .kpi-value { font-size: 24px; font-weight: 700; color: var(--navy); letter-spacing: -.5px }
.kpi .kpi-value .unit { font-size: 16px; color: var(--gold); font-weight: 600 }
.kpi .kpi-sub { font-size: 12px; color: var(--muted); margin-top: 5px }
.kpi .kpi-trend { font-size: 12px; margin-top: 4px }
.kpi .trend-up { color: var(--vert) }
.kpi .trend-dn { color: var(--rouge) }

.skeleton { height: 90px; background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite }
@keyframes shimmer { 0% { background-position: 200% 0 } 100% { background-position: -200% 0 } }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
}
.card-head {
  padding: 14px 18px;
  border-bottom: 0.5px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-head h3 { font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted) }
.card-sub { font-size: 12px; color: var(--hint) }
.link-sm { font-size: 12px; color: var(--gold); cursor: pointer; text-decoration: none }
.link-sm:hover { text-decoration: underline }

/* ── Charts ────────────────────────────────────────────────── */
.charts-row { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 20px }
.chart-card { overflow: hidden }
.chart-wrap { padding: 16px; position: relative }
#chart-monthly { height: 190px !important }
#chart-modes { height: 150px !important }
.chart-legend { padding: 0 16px 14px; display: flex; flex-wrap: wrap; gap: 10px }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted) }
.legend-sq { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0 }

/* ── Two-col layout ────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px }

/* ── Mini list ─────────────────────────────────────────────── */
.mini-list { padding: 6px 14px }
.mini-row {
  display: flex;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 0.5px solid var(--border-light);
  gap: 8px;
}
.mini-row:last-child { border-bottom: none }
.mini-rank { width: 20px; font-size: 11.5px; color: var(--hint); text-align: right; flex-shrink: 0 }
.mini-name { flex: 1; font-size: 13px; font-weight: 500; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.mini-sub { font-size: 11.5px; color: var(--muted) }
.mini-amt { font-size: 13px; font-weight: 600; color: var(--navy); white-space: nowrap }

/* ── Badges ────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 500 }
.badge-vert { background: var(--vert-bg); color: var(--vert) }
.badge-noire { background: var(--noire-bg); color: var(--noire) }
.badge-rouge { background: var(--rouge-bg); color: var(--rouge) }
.badge-mode { background: #EEF4FF; color: #1D4B8F; font-size: 11px; padding: 2px 6px }
.badge-gold { background: #FFF8E0; color: #7A5C10 }

/* ── Settings ─────────────────────────────────────────────── */
.settings-warning {
  padding: 14px 16px;
  margin-bottom: 14px;
  border-left: 4px solid #b32b2b;
}

.settings-warning-text {
  color: #7f1d1d;
  font-weight: 600;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.settings-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-tab {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
}

.settings-tab.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: block;
}

.settings-card .settings-body {
  padding: 14px 16px;
  display: grid;
  gap: 12px;
}

.settings-row {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-row .form-group {
  min-width: 220px;
  margin-bottom: 0;
}

.settings-row-spaced {
  align-items: center;
}

.settings-help {
  font-size: 12px;
  color: var(--muted);
}

.settings-help-box {
  border: 1px solid var(--border-light);
  background: #fcfaf6;
  border-radius: 10px;
  padding: 10px 12px;
}

.settings-help-box h4 {
  margin: 0 0 6px;
  font-size: 13px;
}

.settings-help-box p {
  margin: 4px 0;
  font-size: 12px;
  color: var(--muted);
}

.settings-table-wrap {
  overflow: auto;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: #fff;
}

.settings-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

.settings-table th,
.settings-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
}

.settings-table th {
  text-transform: none;
  letter-spacing: 0;
  background: #f7f4ee;
}

.settings-form {
  border-top: 1px solid var(--border-light);
  padding-top: 10px;
}

.settings-form textarea,
.settings-form input,
.settings-form select {
  width: 100%;
}

.cerfa-logo-preview-wrap {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

#settings-cerfa-logo-preview {
  max-width: 220px;
  max-height: 120px;
  width: auto;
  height: auto;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: #fff;
  padding: 4px;
}

.import-context-box {
  margin-top: 10px;
}

.import-context-actions {
  justify-content: flex-start;
  margin-top: 8px;
  margin-bottom: 10px;
  padding-top: 0;
  border-top: none;
}

.import-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 12px;
}

.import-col-chip {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11.5px;
  color: var(--muted);
}

.import-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}

.import-status-ok {
  background: #E7F8EE;
  color: #1E6A3D;
  border: 1px solid #B8E0C8;
}

.import-status-missing {
  background: #FDEEEE;
  color: #9A2F2F;
  border: 1px solid #E7C0C0;
}

.import-status-empty {
  background: #F1F1EF;
  color: #6A6761;
  border: 1px solid #D7D3CC;
}

.import-muted {
  color: var(--hint);
}

.import-inline-edit {
  display: flex;
  align-items: center;
  gap: 6px;
}

.import-inline-edit select {
  min-width: 230px;
  max-width: 360px;
}

/* ── Toolbar ───────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap }
.search-wrap {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}
.search-wrap:focus-within { border-color: var(--gold) }
.search-icon { color: var(--muted); font-size: 14px; margin-right: 6px }
.search-wrap input { border: none; outline: none; font-size: 13.5px; background: transparent; flex: 1; padding: 8px 0; color: var(--text) }
.clear-btn { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 2px 4px }

.filter-chips { display: flex; gap: 6px }
.chip {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12.5px;
  cursor: pointer;
  color: var(--muted);
  transition: var(--transition);
  font-family: inherit;
}
.chip:hover { border-color: var(--navy); color: var(--navy) }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy) }
.chip-vert.active { background: var(--vert); border-color: var(--vert) }
.chip-noire.active { background: var(--noire); border-color: var(--noire) }
.chip-rouge.active { background: var(--rouge); border-color: var(--rouge) }
.count-badge { font-size: 12px; color: var(--muted); white-space: nowrap }

.intensity-help {
  margin: -4px 0 12px;
  background: #F7F4EE;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.intensity-help summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy);
  list-style: none;
}
.intensity-help summary::-webkit-details-marker { display: none }
.intensity-help-content {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}
.intensity-help-content p {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ── Table ─────────────────────────────────────────────────── */
.table-card { overflow: hidden }
table { width: 100%; border-collapse: collapse; font-size: 13.5px }
th {
  padding: 9px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  background: var(--bg);
  border-bottom: 0.5px solid var(--border);
  white-space: nowrap;
}
th.sortable { cursor: pointer; user-select: none }
th.sortable:hover { color: var(--navy) }
.sort-arrow { color: var(--hint) }
td { padding: 10px 14px; border-bottom: 0.5px solid var(--border-light); color: var(--text); vertical-align: middle }
tr:hover td { background: #FAFAF7; cursor: pointer }
tr:last-child td { border-bottom: none }
.table-footer {
  padding: 12px 16px;
  border-top: 0.5px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
}
#page-info { font-size: 13px; color: var(--muted) }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  padding: 8px 16px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: var(--transition);
}
.btn:hover { border-color: var(--navy); color: var(--navy) }
.btn:active { transform: scale(.98) }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy) }
.btn-primary:hover { background: var(--navy-light); color: #fff }
.btn-primary:disabled { opacity: .5; cursor: not-allowed }
.btn-sm { padding: 5px 12px; font-size: 12.5px }

/* ── Agents ────────────────────────────────────────────────── */
.agents-toolbar { display: inline-flex; align-items: center; gap: 10px; margin-left: auto; font-size: 12px; color: var(--muted) }
.agents-toolbar select { min-width: 220px }
.agents-layout { display: flex; flex-direction: column; gap: 14px }
.agents-sidebar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; overflow-y: visible }
.empty-state { padding: 18px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); background: var(--surface) }
.agent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: var(--transition);
}
.agent-card:hover { border-color: var(--gold); box-shadow: 0 2px 10px rgba(201,162,55,.15) }
.agent-card.selected { border-color: var(--gold); border-width: 2px; box-shadow: 0 2px 10px rgba(201,162,55,.2) }
.agent-card-icon { font-size: 20px; margin-bottom: 8px }
.agent-card-name { font-size: 13.5px; font-weight: 600; margin-bottom: 4px }
.agent-card-desc { font-size: 12px; color: var(--muted); line-height: 1.5 }
.agent-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px }
.agent-chip { background: var(--bg); border: 0.5px solid var(--border); border-radius: 10px; padding: 1px 7px; font-size: 11px; color: var(--muted) }

.chat-panel { display: flex; flex-direction: column; background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); overflow: hidden; min-height: 300px }
.agent-banner {
  background: var(--navy);
  color: rgba(255,255,255,.9);
  padding: 10px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.agent-banner.hidden { display: none }
.agent-live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); margin-left: auto; animation: pulse 1.8s infinite }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

.agent-actions {
  border-bottom: 0.5px solid var(--border-light);
  background: #FBFAF7;
  padding: 10px 14px;
}

.agent-actions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}

.agent-auto-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
}

.agent-actions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.agent-action-btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--navy);
  font-size: 12px;
  padding: 5px 11px;
  cursor: pointer;
  transition: var(--transition);
}

.agent-action-btn:hover {
  border-color: var(--gold);
  background: #FFF9EA;
}

.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-height: 220px }
.chat-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; color: var(--hint); text-align: center; gap: 10px }
.message-preview { color: var(--muted); font-size: 12px; line-height: 1.45 }
.chat-empty-icon { font-size: 36px }

.msg { max-width: 80%; padding: 10px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word }
.msg-user { background: var(--navy); color: #fff; align-self: flex-end; border-bottom-right-radius: 3px }
.msg-assistant { background: var(--bg); border: 0.5px solid var(--border); color: var(--text); align-self: flex-start; border-bottom-left-radius: 3px }
.msg-system { background: #FFF8E0; border: 0.5px solid #E8D89A; color: #7A5C10; align-self: center; font-size: 12px; padding: 6px 12px; border-radius: 8px; max-width: 100%; text-align: center }
.msg-loading { background: var(--bg); border: 0.5px solid var(--border); color: var(--muted); align-self: flex-start; font-style: italic }
.msg-loading::after { content: ''; animation: dots 1.2s infinite }
@keyframes dots { 0%{content:'.'} 33%{content:'..'} 66%{content:'...'} }

.chat-input-row { padding: 12px 14px; border-top: 0.5px solid var(--border); display: flex; gap: 10px; align-items: flex-end }
.chat-input-row textarea {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  background: var(--bg);
  resize: none;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
}
.chat-input-row textarea:focus { border-color: var(--gold) }
.chat-input-row textarea:disabled { opacity: .5; cursor: not-allowed }

/* ── Modals ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 45, .5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex }
.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
}
.modal-large { max-width: 700px }
.modal-header {
  padding: 18px 20px;
  border-bottom: 0.5px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-header h2 { font-size: 16px; font-weight: 600; color: var(--navy) }
.modal-sub { font-size: 12px; color: var(--muted); display: block; margin-top: 2px }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); padding: 2px 6px; border-radius: 4px }
.modal-close:hover { background: var(--bg) }
.modal-body { padding: 18px 20px }

.stats-trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px }
.stat-box { background: var(--navy); border-radius: 8px; padding: 12px; text-align: center }
.stat-box .stat-n { color: var(--gold); font-size: 18px; font-weight: 700 }
.stat-box .stat-l { color: rgba(255,255,255,.55); font-size: 11px; margin-top: 2px }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px }
.info-item { background: var(--bg); border-radius: 7px; padding: 9px 11px }
.info-lbl { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-bottom: 3px }
.info-val { font-size: 13px; color: var(--text); font-weight: 500 }

.section-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 14px 0 8px }
.inner-table { width: 100%; border-collapse: collapse; font-size: 13px }
.inner-table th { background: var(--bg); padding: 7px 10px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); border-bottom: 0.5px solid var(--border) }
.inner-table td { padding: 8px 10px; border-bottom: 0.5px solid var(--border-light) }
.inner-table tr:last-child td { border-bottom: none }
.notes-box { margin-top: 12px; background: #FFFBF0; border: 0.5px solid #E8D89A; border-radius: 8px; padding: 10px 12px; font-size: 12.5px; color: #7A5C10 }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px }
.form-group { display: flex; flex-direction: column; gap: 5px }
.form-group.full { grid-column: 1 / -1 }
.form-group label { font-size: 12px; font-weight: 500; color: var(--muted) }
.form-group input, .form-group select, .form-group textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--gold); background: var(--surface) }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 0.5px solid var(--border) }

.dup-check-result {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #F8F8F6;
}
.dup-check-result.dup-ok {
  border-color: #BBDCC7;
  background: #EDF8F1;
}
.dup-check-result.dup-risk {
  border-color: #E5C1C1;
  background: #FBF1F1;
}
.dup-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
}
.dup-ai {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.dup-list {
  margin-left: 16px;
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--text);
}
.dup-none {
  font-size: 12px;
  color: var(--muted);
}

.quick-don-box {
  margin-top: 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #F8F6F2;
  padding: 10px 12px;
}

.quick-don-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--navy);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
}

.quick-don-fields {
  margin-top: 10px;
}

.don-selected {
  margin: 8px 0;
  padding: 8px 10px;
  border: 1px solid #BBDCC7;
  background: #EDF8F1;
  border-radius: 7px;
  font-size: 12.5px;
  color: #244A31;
}

.donor-pick-list {
  margin: 6px 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  max-height: 190px;
  overflow-y: auto;
}

.donor-pick-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border: none;
  border-bottom: 1px solid var(--border-light);
  background: #fff;
  padding: 9px 10px;
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
}

.donor-pick-item:last-child {
  border-bottom: none;
}

.donor-pick-item:hover {
  background: #F7F4EE;
}

.donor-pick-item small {
  color: var(--muted);
}

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--navy);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  transform: translateY(20px);
  opacity: 0;
  transition: all .25s ease;
  z-index: 500;
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1 }
.toast.toast-ok { border-left: 3px solid #2ECC71 }
.toast.toast-err { border-left: 3px solid #E74C3C }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px }
::-webkit-scrollbar-track { background: transparent }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px }
::-webkit-scrollbar-thumb:hover { background: var(--muted) }

/* ── Filter select ─────────────────────────────────────────── */
.filter-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.filter-select:focus { border-color: var(--gold) }

/* ── Toggle vue dons ───────────────────────────────────────── */
.view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden }
.view-btn { background: var(--surface); border: none; padding: 7px 11px; cursor: pointer; color: var(--muted); transition: var(--transition); font-size: 14px }
.view-btn:hover { background: var(--bg); color: var(--text) }
.view-btn.active { background: var(--navy); color: #fff }

/* ── Page info générique ───────────────────────────────────── */
#dons-page-info { font-size: 13px; color: var(--muted) }

/* ── CERFA table actions ───────────────────────────────────── */
#recus-table td:last-child { white-space: nowrap }
#recus-table .btn-sm { padding: 4px 8px }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 980px) {
  .topbar {
    position: sticky;
    width: 100%;
    bottom: auto;
    border-right: none;
    border-bottom: 2px solid var(--gold);
    box-shadow: 0 10px 24px rgba(7, 14, 25, .22);
  }
  .topbar-main {
    min-height: 0;
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 10px 12px;
    gap: 10px;
  }
  .sidebar-toggle { display: none; }
  .topbar-left {
    width: 100%;
    justify-content: space-between;
    min-width: 0;
  }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center }
  .top-nav,
  .top-actions {
    width: 100%;
    display: none;
    margin: 0;
  }
  .topbar-main.nav-open .top-nav,
  .topbar-main.nav-open .top-actions {
    display: flex;
  }
  .top-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 10px;
  }
  .nav-item {
    width: 100%;
    justify-content: flex-start;
    padding: 9px 10px;
    font-size: 12.5px;
    gap: 8px;
  }
  .nav-text {
    display: inline;
    opacity: 1;
    width: auto;
  }
  .nav-short { display: none; }
  .nav-item::after {
    display: none;
  }
  .has-tooltip::after {
    display: none;
  }
  .top-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    padding: 8px;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 10px;
    margin-top: 0;
    border-top: 1px solid rgba(255,255,255,.16);
  }
  .global-radio-picker {
    width: 100%;
    justify-content: space-between;
    display: flex;
    flex-direction: row;
    align-items: center;
  }
  .global-radio-picker select {
    min-width: 0;
    flex: 1;
  }
  .api-status { width: 100%; }
  .radio-scope-label { display: none }
  #main {
    margin-left: 0;
    width: 100%;
    padding: 14px 12px 26px;
  }
  body.sidebar-collapsed #main {
    margin-left: 0;
    width: 100%;
  }
  #main { padding: 14px 12px 26px }
  .kpi-grid { grid-template-columns: 1fr 1fr }
  .charts-row, .two-col { grid-template-columns: 1fr }
  .agents-sidebar { grid-template-columns: 1fr }
}
