/* ==========================================================================
   Optimus Sante - systeme de design
   ========================================================================== */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #94a3b8;

  --brand: #0f766e;
  --brand-strong: #115e59;
  --brand-soft: #ccfbf1;
  --brand-text: #0f766e;

  --accent: #0284c7;
  --accent-soft: #e0f2fe;

  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --info: #4338ca;
  --info-soft: #e0e7ff;

  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
  --sidebar-w: 244px;
  --topbar-h: 60px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #121a2a;
  --surface-2: #172033;
  --surface-3: #1e293b;
  --border: #24304a;
  --border-strong: #33415c;
  --text: #e8edf5;
  --text-2: #a3b1c6;
  --muted: #6b7c96;

  --brand: #2dd4bf;
  --brand-strong: #5eead4;
  --brand-soft: #10403c;
  --brand-text: #5eead4;

  --accent: #38bdf8;
  --accent-soft: #0c3a52;

  --ok: #4ade80;      --ok-soft: #0f3d24;
  --warn: #fbbf24;    --warn-soft: #422c06;
  --danger: #f87171;  --danger-soft: #451a1a;
  --info: #a5b4fc;    --info-soft: #232a5c;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 12px 34px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0 0 .6rem; }
small { font-size: 12px; }

/* ------------------------------- Utilitaires ----------------------------- */
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12px; }
.hidden { display: none !important; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.fs-12 { font-size: 12px; } .fs-13 { font-size: 13px; } .fs-18 { font-size: 18px; }
.fw-6 { font-weight: 600; }

/* ================================= SHELL ================================== */

.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  height: var(--topbar-h); flex-shrink: 0;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px;
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.02em; }
.brand-sub { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.nav { padding: 12px 10px; flex: 1; }
.nav-group { margin-bottom: 16px; }
.nav-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); padding: 0 10px 6px; font-weight: 700;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 550; font-size: 13.5px;
  cursor: pointer; margin-bottom: 1px; text-decoration: none;
}
.nav-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--brand-soft); color: var(--brand-text); font-weight: 650; }
/* Taille par defaut des icones, valable partout hors menu. */
.ico { width: 17px; height: 17px; flex-shrink: 0; }
.nav-link .ico { opacity: .85; }
.ico-xl .ico { width: 42px; height: 42px; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 20px;
}

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }

/* -------------------------------- Topbar --------------------------------- */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
  position: sticky; top: 0; z-index: 30;
}
.topbar-search { position: relative; flex: 1; max-width: 460px; }
.topbar-search input {
  width: 100%; padding: 7px 12px 7px 34px; font-size: 13.5px;
  border: 1px solid var(--border); border-radius: 20px;
  background: var(--surface-2); color: var(--text);
}
.topbar-search svg { position: absolute; left: 11px; top: 8px; width: 16px; height: 16px; color: var(--muted); }

.icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-2);
  display: grid; place-items: center; cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .dot {
  position: absolute; top: 5px; right: 5px; min-width: 15px; height: 15px;
  background: var(--danger); color: #fff; border-radius: 20px;
  font-size: 9.5px; font-weight: 700; display: grid; place-items: center; padding: 0 3px;
}

.content { padding: 22px 26px 60px; max-width: 1440px; width: 100%; }

/* ------------------------------ En-tete de page --------------------------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ================================ COMPOSANTS ============================== */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title { font-size: 14px; font-weight: 650; }
.card-body { padding: 16px; }
.card-body.tight { padding: 10px 16px; }
.card-foot { padding: 11px 16px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.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)); }
/* `minmax(0, ...)` : sans lui, une piste `fr` ne descend jamais sous la
   largeur minimale de son contenu, et un tableau large fait defiler toute la
   page au lieu de defiler dans son propre cadre. */
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }

/* --------------------------------- KPI ----------------------------------- */
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }
.kpi-value { font-size: 26px; font-weight: 720; letter-spacing: -.03em; margin-top: 4px; line-height: 1.1; }
.kpi-sub { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.kpi-accent { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); }

/* -------------------------------- Boutons -------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap; font-family: inherit; line-height: 1.3;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
[data-theme="dark"] .btn-primary { color: #062a27; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(.92); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn svg { width: 15px; height: 15px; }

/* -------------------------------- Badges --------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 650;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-brand { background: var(--brand-soft); color: var(--brand-text); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* -------------------------------- Avatars -------------------------------- */
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12.5px;
  letter-spacing: -.02em; text-transform: uppercase;
}
.avatar-sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar-lg { width: 52px; height: 52px; font-size: 18px; }

/* -------------------------------- Tableaux ------------------------------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 700; padding: 9px 14px;
  border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-2); }

/* --------------------------------- Listes -------------------------------- */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: var(--surface-2); }

/* -------------------------------- Formulaires ---------------------------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 620; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--muted); }
input, select, textarea {
  font-family: inherit; font-size: 13.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
select { cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: auto; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
fieldset { border: none; padding: 0; margin: 0; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters input, .filters select { width: auto; min-width: 150px; }

/* -------------------------------- Onglets -------------------------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 9px 14px; font-size: 13.5px; font-weight: 600; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; background: none; border-top: none; border-left: none; border-right: none; font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand-text); border-bottom-color: var(--brand); }

/* ------------------------------ Etats vides ------------------------------ */
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty-icon { font-size: 30px; opacity: .35; margin-bottom: 8px; }
.empty-title { font-weight: 650; color: var(--text-2); margin-bottom: 4px; font-size: 14px; }

/* ------------------------------- Progression ----------------------------- */
.progress { height: 7px; background: var(--surface-3); border-radius: 20px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 20px; transition: width .3s; }
.progress.warn > span { background: var(--warn); }
.progress.danger > span { background: var(--danger); }

/* -------------------------------- Graphiques ----------------------------- */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 46px; align-items: center; gap: 10px; font-size: 13px; }
.bar-track { background: var(--surface-3); border-radius: 5px; height: 20px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 5px; min-width: 2px; transition: width .35s; }
.bar-val { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }

.spark { display: flex; align-items: flex-end; gap: 3px; height: 72px; }
.spark-col { flex: 1; background: var(--brand-soft); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.spark-col > span { display: block; width: 100%; background: var(--brand); border-radius: 3px 3px 0 0; height: 100%; }

/* -------------------------------- Timeline ------------------------------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ''; position: absolute; left: -19px; top: 5px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--brand);
  box-shadow: 0 0 0 3px var(--surface);
}
.tl-time { font-size: 11.5px; color: var(--muted); font-weight: 600; }

/* --------------------------------- Agenda -------------------------------- */
.agenda-item {
  display: grid; grid-template-columns: 62px 1fr auto; gap: 14px; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.agenda-item:last-child { border-bottom: none; }
.agenda-time {
  font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums;
  color: var(--brand-text); text-align: center;
}
.agenda-time small { display: block; font-size: 10.5px; color: var(--muted); font-weight: 600; }

/* ------------------------------- Messagerie ------------------------------ */
.chat { display: grid; grid-template-columns: 290px 1fr; height: calc(100vh - var(--topbar-h) - 96px); min-height: 460px; }
.chat-list { border-right: 1px solid var(--border); overflow-y: auto; }
.chat-thread { display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-form { border-top: 1px solid var(--border); padding: 12px 16px; display: flex; gap: 10px; align-items: flex-end; flex-shrink: 0; }
.chat-form textarea { min-height: 42px; max-height: 130px; }
.msg { max-width: 74%; display: flex; flex-direction: column; gap: 3px; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg-bubble { padding: 9px 13px; border-radius: 13px; background: var(--surface-3); line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg.mine .msg-bubble { background: var(--brand); color: #fff; }
[data-theme="dark"] .msg.mine .msg-bubble { color: #062a27; }
.msg-meta { font-size: 11px; color: var(--muted); }

/* --------------------------------- Modale -------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: grid; place-items: center; z-index: 100; padding: 20px; overflow-y: auto;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column;
  border: 1px solid var(--border);
}
.modal-lg { max-width: 820px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* --------------------------------- Toasts -------------------------------- */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: 11px 16px; min-width: 250px; max-width: 380px; font-size: 13.5px;
  animation: slide-in .22s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slide-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ------------------------------- Notifications --------------------------- */
.popover {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 340px; max-height: 440px; overflow-y: auto;
}
.notif-item { padding: 11px 14px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; cursor: pointer; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--brand-soft); }
[data-theme="dark"] .notif-item.unread { background: var(--surface-3); }
.notif-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); margin-top: 6px; flex-shrink: 0; }

/* ----------------------------- Authentification -------------------------- */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
  background: var(--surface);
}
.auth-hero {
  background: linear-gradient(150deg, #0f766e 0%, #0e7490 45%, #075985 100%);
  color: #fff; padding: 48px 52px; display: flex; flex-direction: column; justify-content: center;
}
.auth-hero h1 { font-size: 32px; line-height: 1.15; margin-bottom: 14px; letter-spacing: -.03em; }
.auth-hero p { color: rgba(255, 255, 255, .82); font-size: 15px; max-width: 430px; line-height: 1.6; }
.auth-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.auth-pill { background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .2); padding: 5px 12px; border-radius: 20px; font-size: 12.5px; font-weight: 600; }
.auth-flow { margin-top: 30px; font-size: 13px; color: rgba(255,255,255,.9); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.auth-flow span { background: rgba(255,255,255,.1); padding: 4px 10px; border-radius: 6px; }
.auth-panel { display: grid; place-items: center; padding: 40px 32px; overflow-y: auto; }
.auth-box { width: 100%; max-width: 400px; }
.auth-demo { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.demo-account {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 7px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); cursor: pointer; margin-bottom: 6px; font-family: inherit; font-size: 12.5px; color: var(--text);
}
.demo-account:hover { border-color: var(--brand); background: var(--brand-soft); }

/* -------------------------------- Divers --------------------------------- */
.stars { color: #f59e0b; letter-spacing: 1px; }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 7px 14px; font-size: 13.5px; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; }
.prose { line-height: 1.65; white-space: pre-wrap; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.pill-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 4px 10px; border-radius: 20px; border: 1px solid var(--border-strong);
  font-size: 12.5px; cursor: pointer; background: var(--surface); font-weight: 600; color: var(--text-2);
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
[data-theme="dark"] .chip.active { color: #062a27; }

/* --------------------------- Curseur (interrupteur) ---------------------- */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 44px; height: 25px; border-radius: 20px; flex-shrink: 0;
  background: var(--border-strong); position: relative; transition: background .2s;
}
.switch-track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 19px; height: 19px; border-radius: 50%; background: #fff;
  transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .28);
}
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track::after { transform: translateX(19px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--brand-soft); }
.switch input:disabled + .switch-track { opacity: .5; cursor: not-allowed; }
.switch-on .switch-track { background: var(--ok); }
.switch-label { font-size: 13.5px; font-weight: 600; }
.switch-hint { font-size: 12px; color: var(--muted); }

/* Bloc d'action mis en avant sur une fiche produit. */
.action-panel {
  border: 1px solid var(--border); border-left: 3px solid var(--brand);
  border-radius: var(--radius); padding: 14px 16px; background: var(--surface-2);
}

/* Regroupement de produits par agence. */
.group-head {
  display: flex; align-items: center; gap: 10px;
  margin: 22px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.group-head:first-child { margin-top: 0; }
.group-dot { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.group-name { font-size: 15px; font-weight: 680; letter-spacing: -.01em; }

.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 10px; }
.map-cell {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 13px;
  background: var(--surface-2); position: relative; overflow: hidden;
}
.map-cell-bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--brand); }

.loading { padding: 60px; text-align: center; color: var(--muted); }
.spinner {
  width: 26px; height: 26px; border: 2.5px solid var(--border);
  border-top-color: var(--brand); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------- Responsive ------------------------------ */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2-1, .grid-1-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 90;
    transform: translateX(-100%); transition: transform .22s; height: 100vh;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 16px 14px 50px; }
  .chat { grid-template-columns: 1fr; }
  .chat-list.has-thread { display: none; }
  .field-row, .field-row-3 { grid-template-columns: 1fr; }
}

/* Sous 640px seulement, tout passe sur une colonne unique. */
@media (max-width: 640px) {
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  /* La recherche globale laisse la place au menu : chaque liste a son filtre. */
  .topbar-search { display: none; }
  /* Compte d'agence : le laboratoire de travail reste lisible, le nom de
     l'agence s'efface. */
  .lab-switch-agency { display: none; }
  .lab-switch select { min-width: 150px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .filters > input, .filters > select { flex: 1; min-width: 0; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dt { margin-top: 8px; }
  .agenda-item { grid-template-columns: 52px 1fr; row-gap: 8px; }
  .agenda-item > :last-child { grid-column: 1 / -1; }
  .bar-row { grid-template-columns: 96px 1fr 42px; font-size: 12px; }
}
@media (min-width: 901px) { .menu-toggle { display: none; } }
