/* =====================================================================
   HADOTECH AI - feuille de styles principale
   Couleurs du logo : bleu #0153A7, rouge #D01C22
   ===================================================================== */

:root {
  --blue: #0153A7;
  --blue-600: #01468D;
  --blue-50: #EAF2FB;
  --red: #D01C22;
  --red-50: #FDECEC;
  --brand: var(--blue);
  --brand-contrast: #ffffff;
  --brand-soft: color-mix(in srgb, var(--brand) 11%, transparent);

  --bg: #F4F6FA;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-3: #EEF2F7;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #0F1B2D;
  --text-2: #475569;
  --text-3: #64748B;
  --success: #15803D;
  --success-bg: #E8F6EC;
  --warning: #B45309;
  --warning-bg: #FEF3E2;
  --danger: #C2161C;
  --danger-bg: #FDECEC;
  --info: #0153A7;
  --info-bg: #EAF2FB;
  --muted-bg: #EEF2F7;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .06), 0 1px 3px rgba(15, 27, 45, .05);
  --shadow-lg: 0 10px 30px rgba(15, 27, 45, .12);
  --sidebar-w: 264px;
  --topbar-h: 64px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --link: #7FB3F5;
  --brand-contrast: #ffffff;
  --bg: #0B1220;
  --surface: #111A2B;
  --surface-2: #142036;
  --surface-3: #1B2940;
  --border: #22324D;
  --border-strong: #2E4366;
  --text: #E6EDF7;
  --text-2: #A9B6CB;
  --text-3: #8293AD;
  --success: #4ADE80;
  --success-bg: rgba(74, 222, 128, .12);
  --warning: #FBBF24;
  --warning-bg: rgba(251, 191, 36, .12);
  --danger: #F87171;
  --danger-bg: rgba(248, 113, 113, .13);
  --info: #60A5FA;
  --info-bg: rgba(96, 165, 250, .13);
  --muted-bg: #1B2940;
  --blue-50: rgba(96, 165, 250, .12);
  --red-50: rgba(248, 113, 113, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link, var(--brand)); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
code, pre, .mono { font-family: var(--font-mono); font-size: .88em; }
pre { background: var(--surface-3); padding: 12px 14px; border-radius: var(--radius-sm); overflow-x: auto; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
img { max-width: 100%; }
.icon { width: 18px; height: 18px; stroke-width: 2; vertical-align: -3px; flex-shrink: 0; }
svg.lucide { width: 18px; height: 18px; stroke-width: 2; vertical-align: -3px; flex-shrink: 0; }

/* ---------------------------------------------------------------------
   Structure : barre latérale + contenu
   --------------------------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column;
  z-index: 40;
  transition: transform .2s ease;
}
.sidebar-head { padding: 18px 18px 14px; border-bottom: 1px solid var(--border); }
.sidebar-logo { display: block; height: 38px; width: auto; }
.sidebar-logo-wrap { display: flex; align-items: center; gap: 10px; }
.tenant-chip {
  margin-top: 12px; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border);
}
.tenant-chip img { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; background: #fff; }
.tenant-chip .avatar { width: 28px; height: 28px; font-size: 12px; }
.tenant-chip-name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.tenant-chip-sub { font-size: 11.5px; color: var(--text-3); }
.nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; }
.nav-group { margin-top: 14px; }
.nav-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 0 10px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; text-decoration: none;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav a.active .icon, .nav a.active svg { color: var(--brand); }
.nav .count { margin-left: auto; background: var(--red); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; font-weight: 600; }
.sidebar-foot { padding: 12px 18px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); }
.sidebar-foot img { height: 16px; vertical-align: -3px; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; border-radius: 99px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.menu-toggle { display: none; }
.content { padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; flex: 1; }
.banner { padding: 10px 24px; font-size: 13.5px; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--border); }
.banner-warning { background: var(--warning-bg); color: var(--warning); }
.banner-danger { background: var(--danger-bg); color: var(--danger); }
.banner-info { background: var(--info-bg); color: var(--info); }
.banner a { color: inherit; font-weight: 600; text-decoration: underline; }

.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text); font: inherit; }
.avatar { width: 30px; height: 30px; border-radius: 99px; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12.5px; flex-shrink: 0; }
.avatar.red { background: var(--red); }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 50;
}
.dropdown.open { display: block; }
.dropdown a, .dropdown button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; text-decoration: none; }
.dropdown a:hover, .dropdown button:hover { background: var(--surface-3); }
.dropdown-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-head small { color: var(--text-3); display: block; }
.notif-list { max-height: 380px; overflow-y: auto; min-width: 320px; }
.notif-item { padding: 10px; border-radius: var(--radius-sm); display: block; color: var(--text); }
.notif-item.unread { background: var(--blue-50); }
.notif-item small { color: var(--text-3); }

/* ---------------------------------------------------------------------
   En-têtes de page, cartes, grilles
   --------------------------------------------------------------------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { margin: 0; }
.page-header p { margin: 4px 0 0; color: var(--text-2); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { font-size: 13px; color: var(--text-3); margin-bottom: 6px; }
.breadcrumb a { color: var(--text-3); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { margin: 0; font-size: 1rem; }
.card-header p { margin: 2px 0 0; color: var(--text-3); font-size: 13px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.mt { margin-top: 16px; } .mt-0 { margin-top: 0; } .mb { margin-bottom: 16px; } .mb-0 { margin-bottom: 0; }
.muted { color: var(--text-3); } .small { font-size: 12.5px; } .strong { font-weight: 600; }
.text-right { text-align: right; } .text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden;
}
.stat-label { color: var(--text-2); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.stat-label .icon, .stat-label svg { color: var(--brand); }
.stat-value { font-family: var(--font-display); font-size: 1.65rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat-sub { font-size: 12.5px; color: var(--text-3); }
.stat.accent { border-top: 3px solid var(--brand); }
.stat.accent-red { border-top: 3px solid var(--red); }
.stat.accent-orange { border-top: 3px solid var(--warning); }
.trend-up { color: var(--success); } .trend-down { color: var(--danger); }

.progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.progress.warn > span { background: var(--warning); }
.progress.danger > span { background: var(--red); }

/* ---------------------------------------------------------------------
   Boutons, badges, alertes
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 84%, #000); border-color: color-mix(in srgb, var(--brand) 84%, #000); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #B3161B; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; gap: 5px; }
.btn-block { width: 100%; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; }
.btn-link { background: none; border: 0; color: var(--brand); padding: 0; height: auto; font-weight: 500; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--muted-bg); color: var(--text-2); }
.badge-brand { background: var(--brand); color: #fff; }
.badge-red { background: var(--red); color: #fff; }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid transparent; }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-error, .alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert-info { background: var(--info-bg); color: var(--info); }
.alert .close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: .7; }
.toast-zone { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: 360px; }

/* ---------------------------------------------------------------------
   Formulaires
   --------------------------------------------------------------------- */
.form-group { margin-bottom: 16px; }
.form-group label, .label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.form-group label.choice { display: flex; font-weight: 400; font-size: inherit; margin-bottom: 0; }
.form-group label.check { display: flex; font-weight: 500; font-size: inherit; margin-bottom: 0; }
.form-group .hint, .hint { font-size: 12.5px; color: var(--text-3); margin-top: 5px; }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.textarea.code { font-family: var(--font-mono); font-size: 13px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--red); }
.field-error { color: var(--danger); font-size: 12.5px; margin-top: 5px; }
.input-group { display: flex; }
.input-group .input { border-radius: 10px 0 0 10px; }
.input-group .btn { border-radius: 0 10px 10px 0; border-left: 0; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-weight: 500; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--brand); }
.check small { display: block; color: var(--text-3); font-weight: 400; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.choice { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 12px; cursor: pointer; display: flex; gap: 10px; align-items: flex-start; background: var(--surface); }
.choice:hover { border-color: var(--brand); }
.choice input { accent-color: var(--brand); margin-top: 3px; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice strong { display: block; }
.choice small { color: var(--text-3); }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 99px; transition: .2s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(18px); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px 6px; margin: 0 0 16px; }
legend { font-weight: 600; padding: 0 6px; font-family: var(--font-display); }
.color-input { width: 52px; height: 40px; padding: 4px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); }

/* ---------------------------------------------------------------------
   Tableaux
   --------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .actions { text-align: right; white-space: nowrap; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-toolbar { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.table-toolbar .input, .table-toolbar .select { height: 36px; width: auto; min-width: 180px; }
.pagination { display: flex; gap: 6px; justify-content: flex-end; padding: 12px 16px; align-items: center; }

.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty .icon, .empty svg { width: 40px; height: 40px; color: var(--border-strong); margin-bottom: 10px; }
.empty .btn .icon, .empty .btn svg { width: 16px; height: 16px; margin: 0; color: inherit; }
.empty h3 { color: var(--text); }

/* ---------------------------------------------------------------------
   Onglets, listes de définitions, divers
   --------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a, .tabs button { padding: 10px 14px; color: var(--text-2); border: 0; background: none; font: inherit; font-weight: 600; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; text-decoration: none; }
.tabs a.active, .tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.dl { display: grid; grid-template-columns: minmax(100px, 38%) 1fr; gap: 10px 16px; margin: 0; }
.dl dt { color: var(--text-3); font-size: 13.5px; }
.dl dd { margin: 0; font-weight: 500; word-break: break-word; }
.kbd, kbd { font-family: var(--font-mono); font-size: 12px; background: var(--surface-3); border: 1px solid var(--border); border-bottom-width: 2px; padding: 1px 6px; border-radius: 6px; }
.copy-box { display: flex; align-items: center; gap: 8px; background: var(--surface-3); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 10px 12px; font-family: var(--font-mono); font-size: 13px; word-break: break-all; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: center; }
.list li:last-child { border-bottom: 0; }
.dot-status { width: 9px; height: 9px; border-radius: 99px; display: inline-block; background: var(--text-3); }
.dot-status.on { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.dot-status.off { background: var(--danger); }
.dot-status.warn { background: var(--warning); }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 200px; }

/* Cartes d'agents */
.agent-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; }
.agent-card-head { display: flex; align-items: center; gap: 12px; }
.agent-avatar { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.agent-avatar svg, .agent-avatar .icon { width: 22px; height: 22px; }
.agent-card h3 { margin: 0; }
.agent-card .meta { display: flex; gap: 8px; flex-wrap: wrap; }
.template-card { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; gap: 8px; cursor: pointer; transition: border-color .15s, box-shadow .15s; color: var(--text); text-decoration: none; }
.template-card:hover { border-color: var(--brand); box-shadow: var(--shadow-lg); text-decoration: none; }
.template-card p { color: var(--text-2); font-size: 13.5px; margin: 0; }

/* Assistant (étapes) */
.steps { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); font-weight: 600; font-size: 13px; }
.step b { width: 24px; height: 24px; border-radius: 99px; background: var(--border-strong); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.step.active { background: var(--brand-soft); color: var(--brand); }
.step.active b { background: var(--brand); }
.step.done b { background: var(--success); }

/* Modale */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 15, 28, .55); display: none; align-items: center; justify-content: center; z-index: 90; padding: 16px; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; border: 1px solid var(--border); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal-head h3 { margin: 0; flex: 1; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------------------------------------------------------------------
   Pages d'authentification
   --------------------------------------------------------------------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side {
  background: linear-gradient(150deg, #01386F 0%, var(--blue) 55%, #0A63BF 100%);
  color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-side::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 360px; height: 360px; border-radius: 50%; border: 40px solid rgba(208, 28, 34, .55); }
.auth-side h2 { font-size: 2rem; color: #fff; max-width: 440px; }
.auth-side p { color: rgba(255, 255, 255, .85); max-width: 440px; font-size: 15px; }
.auth-side ul { list-style: none; padding: 0; margin: 24px 0 0; position: relative; z-index: 1; }
.auth-side li { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; color: rgba(255, 255, 255, .92); }
.auth-side .logo-plate { background: #fff; border-radius: 14px; padding: 10px 14px; display: inline-block; }
.auth-side .logo-plate img { height: 40px; display: block; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 20px; background: var(--surface); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.6rem; }
.auth-card .sub { color: var(--text-2); margin-bottom: 24px; }
.auth-logo-mobile { display: none; height: 40px; margin-bottom: 24px; }

/* ---------------------------------------------------------------------
   Site public (présentation, tarifs, démo)
   --------------------------------------------------------------------- */
.public-nav { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.public-nav .inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 20px; padding: 12px 20px; }
.public-nav img { height: 36px; }
.public-nav nav { display: flex; gap: 18px; flex: 1; justify-content: center; }
.public-nav nav a { color: var(--text-2); font-weight: 600; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.hero { padding: 72px 0 56px; }
.hero .grid { align-items: center; }
.hero h1 { font-size: clamp(2rem, 4.5vw, 3.1rem); letter-spacing: -.03em; }
.hero h1 .red { color: var(--red); }
.hero h1 .blue { color: var(--blue); }
.hero p.lead { font-size: 1.12rem; color: var(--text-2); max-width: 560px; }
.eyebrow { display: inline-flex; gap: 8px; align-items: center; font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--red); margin-bottom: 14px; }
.section { padding: 56px 0; }
.section-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section h2 { font-size: 1.8rem; }
.feature { padding: 20px; }
.feature .agent-avatar { margin-bottom: 12px; }
.price-card { padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.price-card.featured { border: 2px solid var(--brand); position: relative; }
.price-card .price { font-family: var(--font-display); font-size: 2rem; font-weight: 700; }
.price-card .price small { font-size: .9rem; color: var(--text-3); font-weight: 500; }
.price-card ul { list-style: none; padding: 0; margin: 0; }
.price-card li { padding: 6px 0; display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.price-card li .icon, .price-card li svg { color: var(--success); margin-top: 2px; }
.footer { padding: 32px 0; color: var(--text-3); font-size: 13.5px; border-top: 1px solid var(--border); }

/* Mock d'agent (page d'accueil) */
.chat-preview { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.bubble { padding: 10px 14px; border-radius: 14px; max-width: 85%; font-size: 14px; line-height: 1.45; }
.bubble.user { background: var(--brand); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.bot { background: var(--surface-3); align-self: flex-start; border-bottom-left-radius: 4px; }

/* ---------------------------------------------------------------------
   Impression (factures)
   --------------------------------------------------------------------- */
@media print {
  .no-print, .sidebar, .topbar, .banner { display: none !important; }
  .main { margin: 0 !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
}

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(8, 15, 28, .45); z-index: 35; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .auth-page { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-logo-mobile { display: block; }
  .public-nav nav { display: none; }
  .content { padding: 16px; }
  .topbar { padding: 0 12px; }
  .user-btn .user-name { display: none; }
  .dl { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .page-header { flex-direction: column; }
  .stat-value { font-size: 1.4rem; }
}

/* Logo lisible en thème sombre : plaque claire derrière le logo (bleu et rouge HadoTech) */
:root[data-theme="dark"] .sidebar-logo,
:root[data-theme="dark"] .auth-logo-mobile,
:root[data-theme="dark"] .public-nav img,
:root[data-theme="dark"] .pub-logo img,
:root[data-theme="dark"] .pub-foot-logo { background: #fff; border-radius: 8px; padding: 4px 8px; box-sizing: content-box; }
.text-danger { color: var(--danger); }

/* =====================================================================
   Thème « Salle de pilotage » (v1.1)
   Barre latérale nuit, bandeau de pilotage sur les tableaux de bord,
   cartes nettes, rouge réservé à ce qui attend une décision humaine.
   ===================================================================== */
:root {
  --night: #071A33;
  --night-2: #0B2447;
  --night-line: rgba(255, 255, 255, .08);
  --night-text: rgba(226, 236, 250, .74);
  --sky: #3E8EF0;
  --bg: #F2F5F9;
  --surface-2: #F7F9FC;
  --border: #E3E9F1;
  --text: #0E1A2B;
  --success: #0F8A5F;
  --success-bg: #E5F5EE;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 0 rgba(14, 26, 43, .04), 0 1px 2px rgba(14, 26, 43, .06);
  --shadow-hover: 0 1px 0 rgba(14, 26, 43, .04), 0 10px 24px -10px rgba(1, 83, 167, .28);
  --shadow-lg: 0 18px 40px -12px rgba(7, 26, 51, .28);
}
:root[data-theme="dark"] {
  --night: #050E1C;
  --night-2: #0A1A33;
  --bg: #0A1120;
  --surface: #101A2C;
  --surface-2: #13203A;
  --border: #1F2E49;
  --success: #34D399;
  --success-bg: rgba(52, 211, 153, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-hover: 0 10px 26px -10px rgba(0, 0, 0, .6);
}

body { font-size: 14.5px; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.025em; }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }

/* --- Barre latérale nuit --- */
.sidebar {
  background: linear-gradient(180deg, var(--night) 0%, var(--night-2) 100%);
  border-right: 0; color: var(--night-text);
}
.sidebar-head { border-bottom: 1px solid var(--night-line); padding: 18px 16px 16px; }
.sidebar-logo-wrap { background: #fff; border-radius: 12px; padding: 8px 12px; display: inline-flex; box-shadow: 0 6px 18px -8px rgba(0, 0, 0, .5); }
.sidebar-logo { height: 32px; }
:root[data-theme="dark"] .sidebar-logo { background: none; padding: 0; }
.tenant-chip { background: rgba(255, 255, 255, .06); border: 1px solid var(--night-line); color: #fff; }
.tenant-chip-sub { color: var(--night-text); }
.nav { padding: 6px 12px 20px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.nav-group { margin-top: 18px; }
.nav-group-title { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; color: rgba(226, 236, 250, .45); padding: 0 12px 6px; }
.nav a { color: var(--night-text); padding: 9px 12px; border-radius: 10px; position: relative; transition: background .15s, color .15s; }
.nav a .icon, .nav a svg { color: rgba(226, 236, 250, .55); transition: color .15s; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a:hover .icon, .nav a:hover svg { color: #fff; }
.nav a.active { background: linear-gradient(90deg, rgba(62, 142, 240, .24), rgba(62, 142, 240, .08)); color: #fff; font-weight: 600; }
.nav a.active .icon, .nav a.active svg { color: #8CC0FF; }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--red); }
.nav .count { box-shadow: 0 0 0 3px rgba(208, 28, 34, .25); }
.sidebar-foot { border-top: 1px solid var(--night-line); color: rgba(226, 236, 250, .45); }

/* --- Barre du haut --- */
.topbar {
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(12px); backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border); padding: 0 28px;
}
.topbar-title { font-weight: 600; color: var(--text-2); font-size: 1rem; }
.user-btn { border-color: var(--border); box-shadow: var(--shadow); }
.content { padding: 28px; }

/* --- En-tête de page --- */
.page-header { margin-bottom: 24px; align-items: flex-end; }
.page-header p { color: var(--text-3); }

/* --- Bandeau de pilotage (tableaux de bord) --- */
.page-hero {
  position: relative; overflow: hidden; isolation: isolate;
  background: radial-gradient(120% 140% at 100% 0%, #0E4C93 0%, var(--night-2) 46%, var(--night) 100%);
  color: #fff; border-radius: 18px; padding: 26px 28px; margin-bottom: 22px;
  box-shadow: var(--shadow-lg); align-items: center;
}
.page-hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: .5;
  background-image: radial-gradient(rgba(140, 192, 255, .22) 1px, transparent 1px);
  background-size: 18px 18px;
  -webkit-mask-image: linear-gradient(100deg, transparent 35%, #000 85%); mask-image: linear-gradient(100deg, transparent 35%, #000 85%);
}
.page-hero::after {
  content: ""; position: absolute; z-index: -1; right: -60px; bottom: -90px; width: 260px; height: 260px; border-radius: 50%;
  border: 38px solid rgba(208, 28, 34, .16);
}
.page-hero h1 { color: #fff; font-size: 1.9rem; }
.page-hero p { color: rgba(226, 236, 250, .78); }
.page-hero .btn { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .22); color: #fff; }
.page-hero .btn:hover { background: rgba(255, 255, 255, .18); }
.page-hero .btn-primary { background: #fff; border-color: #fff; color: var(--blue); }
.page-hero .btn-primary:hover { background: #E8F1FB; border-color: #E8F1FB; }
.hero-status { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.hero-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 10px; border-radius: 99px;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); color: #fff;
  font-size: 13px; font-weight: 500; text-decoration: none;
}
a.hero-pill:hover { background: rgba(255, 255, 255, .16); text-decoration: none; }
.hero-pill strong { font-family: var(--font-display); font-size: 15px; font-weight: 700; }
.hero-pill .pulse { width: 8px; height: 8px; border-radius: 50%; background: #34D399; box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); animation: hai-pulse 2s infinite; }
.hero-pill.alert-pill { background: rgba(208, 28, 34, .9); border-color: rgba(255, 255, 255, .25); }
.hero-pill.alert-pill .icon, .hero-pill.alert-pill svg { color: #fff; }
.hero-pill .icon, .hero-pill svg { width: 16px; height: 16px; color: #8CC0FF; }
@keyframes hai-pulse { 0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .55); } 70% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); } 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); } }

/* --- Cartes --- */
.card { border-color: var(--border); box-shadow: var(--shadow); }
.card-header { padding: 18px 22px; }
.card-header h2, .card-header h3 { font-size: 1.02rem; font-weight: 600; }
.card-body { padding: 22px; }

/* --- Indicateurs : pastille d'icône, chiffre affirmé --- */
.stat { padding: 18px 20px; gap: 4px; border-top: 1px solid var(--border); transition: box-shadow .2s, border-color .2s, transform .2s; }
.stat.accent, .stat.accent-red, .stat.accent-orange { border-top: 1px solid var(--border); }
.stat-label { color: var(--text-2); font-weight: 500; gap: 10px; margin-bottom: 6px; }
.stat-label .icon, .stat-label svg {
  width: 34px; height: 34px; padding: 8px; border-radius: 10px; flex-shrink: 0;
  background: var(--blue-50); color: var(--blue); box-sizing: border-box;
}
:root[data-theme="dark"] .stat-label .icon, :root[data-theme="dark"] .stat-label svg { color: #8CC0FF; }
.stat.accent .stat-label .icon, .stat.accent .stat-label svg { background: var(--blue); color: #fff; }
.stat.accent-red { box-shadow: inset 3px 0 0 var(--red), var(--shadow); }
.stat.accent-red .stat-label .icon, .stat.accent-red .stat-label svg { background: var(--red-50); color: var(--red); }
.stat.accent-orange .stat-label .icon, .stat.accent-orange .stat-label svg { background: var(--warning-bg); color: var(--warning); }
.stat-value { font-size: 1.9rem; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-sub { line-height: 1.45; }
.hx-kpi-link:hover .stat { border-color: color-mix(in srgb, var(--blue) 35%, var(--border)); box-shadow: var(--shadow-hover); transform: translateY(-2px); }

/* --- Boutons --- */
.btn { border-radius: 10px; border-color: var(--border); box-shadow: 0 1px 0 rgba(14, 26, 43, .04); }
.btn-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 88%, #fff) 0%, var(--brand) 100%);
  border-color: color-mix(in srgb, var(--brand) 80%, #000);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 6px 14px -6px color-mix(in srgb, var(--brand) 70%, transparent);
}
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 86%, #000); }
.btn-danger { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 6px 14px -6px rgba(208, 28, 34, .6); }
.btn-ghost, .btn-link { box-shadow: none; }

/* --- Tableaux --- */
.table th { text-transform: none; letter-spacing: 0; font-size: 12.5px; color: var(--text-3); background: var(--surface-2); padding: 11px 16px; }
.table td { padding: 13px 16px; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--blue) 4%, var(--surface)); }

/* --- Badges, onglets, formulaires --- */
.badge { padding: 3px 10px; font-weight: 600; letter-spacing: .01em; }
.tabs { gap: 2px; }
.tabs a, .tabs button { border-radius: 8px 8px 0 0; }
.tabs a:hover, .tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs a.active, .tabs button.active { border-bottom-width: 2px; }
.input, .select, .textarea { border-color: var(--border-strong); background: var(--surface); }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--blue) 30%, var(--border-strong)); }
.alert { border-radius: 12px; }
.eyebrow { text-transform: none; letter-spacing: 0; font-size: 13px; }
.hx-perm-group h4 { text-transform: none; letter-spacing: 0; }
.empty .icon, .empty svg { width: 56px; height: 56px; padding: 14px; border-radius: 16px; background: var(--blue-50); color: var(--blue); box-sizing: border-box; }
.dropdown { border-radius: 14px; }
.progress { background: color-mix(in srgb, var(--blue) 10%, var(--surface-3)); }
.progress > span { background: linear-gradient(90deg, var(--blue), var(--sky)); }

/* --- Petits écrans --- */
@media (max-width: 1024px) {
  .content { padding: 18px 16px; }
  .topbar { padding: 0 16px; }
  .page-hero { padding: 20px; border-radius: 16px; }
  .page-hero h1 { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-pill .pulse { animation: none; }
  .stat, .hx-kpi-link:hover .stat { transition: none; transform: none; }
}
.page-hero > div:first-child { flex: 1 1 560px; min-width: 0; }
.page-hero .page-actions { align-self: flex-start; }
