/* ============================================================
   HeraHub — sistema de diseño v2 (paleta validada, tema claro,
   sidebar oscura, animaciones e interacción)
   ============================================================ */
:root {
  --page: #f6f6f3;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;         /* serie 1 — azul (ASR) */
  --accent-strong: #1c5cab;
  --accent-soft: #cde2fb;
  --aqua: #1baf7a;           /* serie 2 — aqua (Rayser) */
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-tint: #e9f6ef;          /* fond « fait » (chip de tâche, état bon) */
  --good-tint-border: #bfe6cf;
  --attention-bg: #fdf5e6;       /* fond d'une ligne qui demande attention */
  --side-bg: #151a2b;
  --side-ink: #b6bccf;
  --side-muted: #6d7590;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 6px 18px rgba(11, 11, 11, 0.06);
  --shadow-lift: 0 4px 10px rgba(11, 11, 11, 0.08), 0 12px 32px rgba(11, 11, 11, 0.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 21px; font-weight: 650; margin: 0 0 2px; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 13.5px; margin: 0 0 8px; color: var(--ink-2); }

/* ---------- Animaciones base ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Estructura ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--side-bg);
  padding: 16px 12px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  scrollbar-width: thin; scrollbar-color: #333a52 transparent;
}
.side-nav { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px 10px; scrollbar-width: thin; scrollbar-color: #333a52 transparent; }
.side-footer {
  margin-top: 10px; padding: 12px 6px 2px; border-top: 1px solid rgba(255, 255, 255, .09);
  display: flex; align-items: center; gap: 9px;
}
.side-footer .avatar { width: 32px; height: 32px; font-size: 12px; flex-shrink: 0; }
.side-footer .who { flex: 1; min-width: 0; }
.side-footer b { color: #fff; font-size: 12.5px; display: block; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-footer small {
  color: var(--side-muted); font-size: 10.5px;
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.side-footer .btn-exit {
  margin-left: auto; color: var(--side-muted); background: none; border: 1px solid rgba(255,255,255,.14);
  border-radius: 7px; padding: 4px 9px; font-size: 11.5px; cursor: pointer; font-family: inherit;
  transition: all .15s;
}
.side-footer .btn-exit:hover { color: #fff; border-color: rgba(255,255,255,.4); }
.brand { display: flex; align-items: center; gap: 9px; padding: 2px 8px 16px; }
.brand-logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #3987e5, #1c5cab);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; box-shadow: 0 3px 8px rgba(42, 120, 214, .4);
}
.brand-mark { width: 34px; height: 34px; object-fit: contain; flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .35)); }
.brand b { font-size: 15.5px; color: #fff; }
.brand small { display: block; color: var(--side-muted); font-size: 10px; letter-spacing: .08em; }
.nav-section { margin-top: 14px; }
.nav-section > span {
  display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--side-muted); padding: 0 10px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: 8px;
  color: var(--side-ink); font-size: 13px; margin-bottom: 1px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(42, 120, 214, .28), rgba(42, 120, 214, .12));
  color: #fff; font-weight: 600; box-shadow: inset 2px 0 0 var(--accent);
}
.nav-item .ico { width: 16px; text-align: center; color: var(--side-muted); font-size: 12px; display: inline-flex; align-items: center; justify-content: center; }
.nav-item .ico svg { display: block; }
.bell > summary svg { vertical-align: -2px; color: var(--ink-2); }
.nav-item:hover .ico, .nav-item.active .ico { color: #7db4ee; }

/* ---------- Sidebar : groupes repliables ---------- */
.nav-group { margin-bottom: 1px; }
.nav-group-head {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 6px 10px; border-radius: 8px; cursor: pointer;
  background: none; border: 0; text-align: left; font: inherit;
  color: var(--side-ink); font-size: 13px;
  transition: background .15s, color .15s;
}
.nav-group-head:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-group-head .ico { width: 16px; color: var(--side-muted); display: inline-flex; align-items: center; justify-content: center; }
.nav-group-head .ico svg { display: block; }
.nav-group-head:hover .ico { color: #7db4ee; }
.nav-group-head .lbl { flex: 1; }
.nav-group-head .chevron { color: var(--side-muted); display: inline-flex; transition: transform .18s; }
.nav-group-head .chevron svg { display: block; }
.nav-group.open > .nav-group-head .chevron { transform: rotate(180deg); }
.nav-group.active > .nav-group-head { color: #fff; font-weight: 600; }
.nav-group.active > .nav-group-head .ico { color: #7db4ee; }
.nav-group-items { display: none; margin: 2px 0 4px; padding-left: 24px; }
.nav-group.open > .nav-group-items { display: block; }
.nav-sub {
  display: block; padding: 5px 10px; border-radius: 7px; margin-bottom: 1px;
  color: var(--side-muted); font-size: 12.5px; text-decoration: none;
  border-left: 2px solid transparent; transition: background .15s, color .15s;
}
.nav-sub:hover { color: #fff; background: rgba(255, 255, 255, .05); text-decoration: none; }
.nav-sub.active { color: #fff; border-left-color: var(--accent); background: rgba(42, 120, 214, .14); font-weight: 600; }
.sidebar .entity-chip {
  background: rgba(255, 255, 255, .07); border-color: transparent; color: var(--side-ink);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 28px 0;
  position: sticky; top: 0; z-index: 40; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.topbar .spacer { flex: 1; }
.topbar-search {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(8px); border: 1px solid var(--hairline); border-radius: 99px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .06); color: var(--muted);
  transition: border-color .15s, box-shadow .15s, width .2s; width: 240px;
}
.topbar-search:focus-within {
  border-color: #7db4ee; box-shadow: 0 0 0 3px rgba(42, 120, 214, .12); width: 320px;
}
.topbar-search input {
  border: 0; outline: 0; background: transparent; flex: 1; min-width: 0;
  font: inherit; font-size: 13px; color: var(--ink); padding: 0;
}
.topbar-search input::placeholder { color: var(--muted); }
.topbar-search kbd {
  font: 600 10.5px/1 var(--mono, ui-monospace, monospace); color: var(--muted);
  border: 1px solid var(--hairline); border-radius: 5px; padding: 2px 5px;
  background: var(--surface);
}
.topbar-search:focus-within kbd { display: none; }
.content { padding: 2px 28px 44px; max-width: 1760px; display: flex; flex-direction: column; }

/* ---------- Onglets de module (tira de tabs bajo la topbar) ---------- */
.tabstrip {
  display: flex; gap: 2px; flex-wrap: wrap;
  border-bottom: 1px solid var(--hairline);
  margin: 6px 0 22px;
}
.tabstrip .tab {
  padding: 9px 15px; color: var(--muted); font-weight: 500; font-size: 13.5px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  text-decoration: none; white-space: nowrap; transition: color .12s;
}
.tabstrip .tab:hover { color: var(--ink); }
.tabstrip .tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
/* La tira va justo bajo el título (JS la coloca); evitamos doble línea. */
/* Tabs SIEMPRE bajo el título, vía flex-order (CSS puro, robusto ante colisiones). */
.content > .page-head { order: -2; }
.content > .tabstrip { order: -1; margin: 2px 0 20px; }
.content:has(> .tabstrip) > .page-head { border-bottom: none; margin-bottom: 8px; padding-bottom: 2px; }

/* ---------- Tooltip d'échéancier (colonne « Éch. ») ---------- */
.ech-cell { position: relative; }
.ech-cell .ech { cursor: pointer; text-decoration: none; }
.ech-cell .ech:hover { text-decoration: underline; }
.ech-tip {
  position: fixed; z-index: 60;
  min-width: 250px; max-width: 340px; text-align: left;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 12px; box-shadow: var(--shadow-lift); padding: 10px 12px;
  display: none;
}
.ech-tip.show, .ech-tip.pinned { display: block; }
.ech-tip.pinned { outline: 2px solid var(--accent-soft); }
.ech-tip-head { font-weight: 600; font-size: 12px; margin-bottom: 6px; color: var(--ink); }
.ei-line { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 12px; border-top: 1px solid var(--page); }
.ei-idx { width: 16px; color: var(--muted); text-align: center; }
.ei-amt { font-weight: 600; }
.ei-due { color: var(--muted); }
.ei-due.late { color: var(--critical); font-weight: 600; }
.ei-ok { margin-left: auto; color: var(--good-text); font-weight: 600; }
.ei-form { margin-left: auto; }
.ech-tip-foot { display: block; margin-top: 8px; font-size: 11.5px; color: var(--accent); }
.btn.xs { padding: 1px 8px; font-size: 11px; line-height: 1.5; }

/* Closer éditable inline (select filtrable) */
.closer-edit { margin: 0; }
/* La colonne garde la même largeur avant et après transformation du champ :
   le <select> fait 108 px, l'enveloppe du combo aussi. Sans ça, la colonne
   sautait au premier clic. */
.col-closer { width: 124px; }
.closer-edit .sel-search { width: 108px; }
.closer-input {
  width: 108px; border: 1px solid transparent; background: transparent;
  padding: 3px 6px; border-radius: 6px; font: inherit; font-size: 13px; color: var(--ink);
  /* Un nom long (« Marie-Charlotte ») ne doit pas élargir la cellule. */
  text-overflow: ellipsis;
}
/* La liste, elle, peut être plus large que le champ : les noms doivent se lire. */
.closer-edit .sel-search .combo-list { min-width: 170px; }
.closer-input:hover { border-color: var(--hairline); background: var(--page); }
.closer-input:focus { outline: none; border-color: var(--accent); background: var(--surface); }

/* Chip « Paiement » verrouillé (fractionné : régler les échéances) */
.task-chip.locked { cursor: default; opacity: .75; }
.task-chip.locked:hover { border-color: var(--hairline); color: var(--muted); }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; }
.pagination .btn.disabled { opacity: .4; pointer-events: none; }

/* ---------- Registre des ventes : suivi de réalisation (modèle Jimmy) ---------- */
.sales-log td { vertical-align: top; }
.nowrap { white-space: nowrap; }
.comm { color: var(--accent-strong); }
.flag-warn { display: inline-block; margin-top: 2px; color: var(--serious); font-size: 11px; font-weight: 600; }
tr.row-attention > td { background: var(--attention-bg); }
tr.row-attention > td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
.task-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; }
.task-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; line-height: 1.4; cursor: pointer;
  border: 1px solid var(--hairline); background: var(--surface); color: var(--muted);
  transition: background .12s, color .12s, border-color .12s;
}
.task-chip .tick { font-size: 11px; }
.task-chip:hover { border-color: var(--accent); color: var(--ink); }
.task-chip.done { background: var(--good-tint); border-color: var(--good-tint-border); color: var(--good-text); font-weight: 600; }
.task-chip.done .tick { color: var(--good); }
.page-head {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; animation: rise .3s ease both;
  padding: 4px 0 12px; border-bottom: 1px solid var(--hairline); margin-bottom: 16px;
}
.page-head .sub { color: var(--muted); font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------- Entidades ---------- */
.entity-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--hairline); border-radius: 99px; padding: 3px 10px;
  color: var(--ink-2); background: var(--surface);
}
.entity-dot { width: 8px; height: 8px; border-radius: 50%; }
.entity-switch { display: flex; gap: 6px; align-items: center; }
.entity-switch a {
  font-size: 12px; padding: 3px 11px; border-radius: 99px; border: 1px solid var(--hairline);
  color: var(--ink-2); transition: all .15s;
}
.entity-switch a.on { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
.entity-switch a:hover { text-decoration: none; border-color: var(--ink-2); transform: translateY(-1px); }

/* ---------- Tarjetas y grids ---------- */
.card {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 13px;
  animation: rise .35s ease both;
}
.card:nth-child(2) { animation-delay: .04s; }
.card:nth-child(3) { animation-delay: .08s; }
.card > h2 {
  display: flex; align-items: center; gap: 8px; font-size: 13.5px;
  padding-bottom: 8px; border-bottom: 1px solid var(--hairline); margin-bottom: 10px;
}
.grid { display: grid; gap: 12px; align-items: start; }
.grid > .card { margin-bottom: 0; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-32 { grid-template-columns: 3fr 2fr; }
@media (max-width: 1100px) { .grid-32 { grid-template-columns: 1fr; } }

/* ---------- KPI (stat tiles) ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 9px; margin-bottom: 13px; }
.kpi {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 11px 14px; box-shadow: var(--shadow); animation: rise .35s ease both;
  transition: box-shadow .2s, transform .2s;
}
.kpi:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.kpis .kpi:nth-child(2) { animation-delay: .05s; }
.kpis .kpi:nth-child(3) { animation-delay: .1s; }
.kpis .kpi:nth-child(4) { animation-delay: .15s; }
.kpis .kpi:nth-child(5) { animation-delay: .2s; }
.kpis .kpi:nth-child(6) { animation-delay: .25s; }
.kpi .label { font-size: 12px; color: var(--ink-2); }
.kpi .value { font-size: 22px; font-weight: 650; margin-top: 2px; letter-spacing: -0.01em; }
.kpi .delta { font-size: 12px; margin-top: 2px; color: var(--muted); }
.kpi .delta.up { color: var(--good-text); }
.kpi .delta.down { color: var(--critical); }
.kpi.alert { border-color: #f2bcbc; background: linear-gradient(180deg, #fff, #fdf6f6); }
.kpi.alert .value { color: var(--critical); }

/* ---------- Badges de estado (icono + etiqueta) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
  border-radius: 99px; padding: 2px 9px; white-space: nowrap;
  background: var(--page); color: var(--ink-2); border: 1px solid var(--hairline);
}
.badge::before { content: "●"; font-size: 8px; }
.badge.b-good { background: #e7f6e7; color: var(--good-text); border-color: #bfe6bf; }
.badge.b-warning { background: #fdf3dc; color: #8a5f00; border-color: #f3dda6; }
.badge.b-serious { background: #fdeae2; color: #99401d; border-color: #f6cdba; }
.badge.b-critical { background: #fbe4e4; color: #8f2020; border-color: #f2bcbc; }
.badge.b-accent { background: #e9f1fc; color: #1c5cab; border-color: #c4dcf6; }
.badge.b-aqua { background: #e2f6ee; color: #0c6b4a; border-color: #b5e6d3; }
.badge.b-muted::before { content: "○"; }

/* ---------- Tablas ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 650; padding: 7px 10px; border-bottom: 1px solid var(--hairline);
  background: var(--page);
}
.table-scroll table.data th { position: sticky; top: 0; z-index: 2; }
table.data td { padding: 7px 10px; border-bottom: 1px solid #eceae4; vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr, table.data tr { transition: background .12s; }
table.data tr:hover td { background: #f3f6fb; }
td.num, th.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-scroll { max-height: 72vh; overflow: auto; }

/* ---------- Botones y formularios ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink);
  border-radius: 9px; padding: 6px 13px; font-size: 13px; font-weight: 600;
  font-family: inherit; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); text-decoration: none; transform: translateY(-1px); box-shadow: 0 3px 8px rgba(11,11,11,.08); }
.btn:active { transform: translateY(0); }
.btn.primary { background: linear-gradient(180deg, #3987e5, var(--accent)); border-color: var(--accent-strong); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.good { background: linear-gradient(180deg, #14b514, var(--good)); border-color: #0a8a0a; color: #fff; }
.btn.danger { background: #fff; border-color: var(--critical); color: var(--critical); }
.btn.danger:hover { background: var(--critical); color: #fff; }
.btn.sm { padding: 3px 10px; font-size: 12px; border-radius: 7px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); box-shadow: none; }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=password], select, textarea {
  font-family: inherit; font-size: 13.5px; color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 9px; padding: 7px 10px;
  background: var(--surface); width: 100%; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23898781' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"),
                    linear-gradient(180deg, #fdfdfc, #f7f7f4);
  background-repeat: no-repeat; background-position: right 11px center, 0 0;
  background-size: 10px 6px, 100% 100%;
  padding-right: 30px; cursor: pointer; text-overflow: ellipsis;
  font-weight: 500; color: var(--ink-2);
  box-shadow: 0 1px 2px rgba(11, 11, 11, .05);
  transition: border-color .15s, box-shadow .15s, color .15s, transform .12s;
}
select:hover {
  border-color: #b9b7ae; color: var(--ink); transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(11, 11, 11, .08);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%230b0b0b' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"),
                    linear-gradient(180deg, #ffffff, #f9f9f6);
}
select:focus {
  color: var(--ink); transform: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%231c5cab' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"),
                    linear-gradient(180deg, #ffffff, #f9f9f6);
}
select option { font-weight: 400; color: var(--ink); background: #fff; }
.form-row > label select { font-weight: 400; }
input[type=date] { cursor: pointer; }
input[type=date]:hover, input[type=text]:hover, input[type=number]:hover, input[type=search]:hover { border-color: #b9b7ae; }
form.inline { display: inline; }
.form-row { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.form-row > label { flex: 1; min-width: 130px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.form-row > label input, .form-row > label select, .form-row > label textarea { margin-top: 4px; font-weight: 400; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.check input { width: auto; }
.filter-input { max-width: 280px; }

/* ---------- Avisos embebidos ---------- */
.msg { border-radius: 9px; padding: 9px 14px; font-size: 13.5px; border: 1px solid; margin-bottom: 12px; animation: rise .3s ease both; }
.msg.success { background: #e7f6e7; border-color: #bfe6bf; color: #063; }
.msg.info { background: #e9f1fc; border-color: #c4dcf6; color: #1c5cab; }
.msg.error { background: #fbe4e4; border-color: #f2bcbc; color: #8f2020; }
.msg.warning { background: #fdf3dc; border-color: #f3dda6; color: #8a5f00; }

/* ---------- Toasts (mensajes flash flotantes) ---------- */
.toasts { position: fixed; top: 62px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  border-radius: 10px; padding: 11px 14px; font-size: 13px; border: 1px solid;
  background: var(--surface); box-shadow: var(--shadow-lift);
  animation: toast-in .3s ease both; transition: opacity .4s, transform .4s;
}
.toast.hide { opacity: 0; transform: translateX(24px); }
.toast .t-close { cursor: pointer; border: none; background: none; color: inherit; font-size: 14px; padding: 0 0 0 6px; opacity: .6; }
.toast .t-close:hover { opacity: 1; }
.toast.success { background: #ecf9ec; border-color: #bfe6bf; color: #063; }
.toast.info { background: #ecf3fd; border-color: #c4dcf6; color: #1c5cab; }
.toast.error { background: #fdecec; border-color: #f2bcbc; color: #8f2020; }
.toast.warning { background: #fdf5e0; border-color: #f3dda6; color: #8a5f00; }

/* ---------- Kanban (drag & drop) ---------- */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(205px, 1fr)); gap: 12px; align-items: start; }
.kanban-col {
  background: #f0f0ec; border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 10px; border-top: 3px solid var(--muted); transition: background .15s, box-shadow .15s;
  animation: rise .35s ease both;
}
.kanban-col[data-col="prospecto"], .kanban-col[data-col="recibida"] { border-top-color: #86b6ef; }
.kanban-col[data-col="presupuesto"], .kanban-col[data-col="en_preparacion"] { border-top-color: var(--warning); }
.kanban-col[data-col="seguimiento"] { border-top-color: var(--serious); }
.kanban-col[data-col="firmado"], .kanban-col[data-col="lista"] { border-top-color: var(--good); }
.kanban-col[data-col="perdido"] { border-top-color: var(--muted); }
.kanban-col[data-col="expedida"] { border-top-color: var(--accent); }
.kanban-col.drop-hover { background: #e6effb; box-shadow: inset 0 0 0 2px var(--accent); }
.kanban-col > header { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 8px; }
.kanban-col > header b { font-size: 12.5px; }
.kanban-col > header span { font-size: 11px; color: var(--muted); }
.kcard {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 9px;
  padding: 9px 10px; margin-bottom: 8px; box-shadow: var(--shadow); font-size: 12.5px;
  transition: box-shadow .15s, transform .15s;
}
.kcard[draggable="true"] { cursor: grab; }
.kcard[draggable="true"]:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.kcard.dragging { opacity: .45; transform: rotate(1.5deg) scale(.98); cursor: grabbing; }
.kcard b { display: block; font-size: 13px; }
.kcard .meta { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.kcard.urgent { border-left: 3px solid var(--critical); }
.kanban-scroll { overflow-x: auto; padding-bottom: 6px; }
.drag-hint { font-size: 11.5px; color: var(--muted); }
.drag-hint kbd {
  font-family: inherit; background: var(--page); border: 1px solid var(--hairline);
  border-radius: 5px; padding: 0 6px; font-size: 11px;
}

/* ---------- Gráficos CSS (animados) ---------- */
.chart-cols { display: flex; align-items: flex-end; gap: 18px; height: 150px; padding: 6px 4px 0; }
.chart-group { flex: 1; display: flex; flex-direction: column; height: 100%; }
.chart-bars { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.chart-bar {
  width: 22px; max-width: 22px; border-radius: 4px 4px 0 0; background: var(--accent);
  min-height: 2px; position: relative;
  transform-origin: bottom; animation: grow-y .7s cubic-bezier(.2, .7, .3, 1) both .1s;
}
.chart-bar.s2 { background: var(--aqua); animation-delay: .22s; }
.chart-bar .tip {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  font-size: 10.5px; color: var(--ink-2); font-weight: 600; white-space: nowrap;
}
.chart-x { text-align: center; font-size: 11px; color: var(--muted); padding-top: 6px; border-top: 1px solid var(--hairline); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.hbars { display: flex; flex-direction: column; gap: 7px; }
.hbar { display: grid; grid-template-columns: 170px 1fr 64px; align-items: center; gap: 10px; font-size: 12.5px; }
.hbar .track { background: var(--page); border-radius: 4px; height: 16px; overflow: hidden; }
.hbar .fill {
  height: 100%; border-radius: 4px; background: var(--accent); min-width: 2px;
  transform-origin: left; animation: grow-x .7s cubic-bezier(.2, .7, .3, 1) both .15s;
}
.hbar .n { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.meter { background: var(--accent-soft); border-radius: 5px; height: 9px; overflow: hidden; min-width: 80px; }
.meter .fill {
  height: 100%; background: var(--accent); border-radius: 5px;
  transform-origin: left; animation: grow-x .8s cubic-bezier(.2, .7, .3, 1) both .2s;
}
.meter.warn .fill { background: var(--serious); }
.meter.over { background: #f6cdba; }
.meter.over .fill { background: var(--critical); }

/* ---------- Notificaciones ---------- */
.bell { position: relative; }
.bell > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 9px; border: 1px solid var(--hairline); font-size: 13px;
  transition: all .15s;
}
.bell > summary:hover { border-color: var(--ink-2); }
.bell > summary::-webkit-details-marker { display: none; }
.bell .count {
  background: var(--critical); color: #fff; font-size: 10.5px; font-weight: 700;
  border-radius: 99px; padding: 0 6px; animation: pulse 2.4s ease-in-out infinite;
}
.bell-menu {
  position: absolute; right: 0; top: 40px; width: 360px; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--radius); box-shadow: var(--shadow-lift);
  z-index: 60; max-height: 420px; overflow-y: auto; animation: rise .2s ease both;
}
.bell-menu a.notif { display: block; padding: 10px 14px; border-bottom: 1px solid var(--hairline); font-size: 12.5px; color: var(--ink); }
.bell-menu a.notif:hover { background: var(--page); text-decoration: none; }
.bell-menu a.notif small { color: var(--muted); display: block; }
.bell-menu .all { display: block; text-align: center; padding: 9px; font-size: 12.5px; font-weight: 600; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid #eceae4; font-size: 13px; }
.timeline li:last-child { border-bottom: none; }
.timeline .t-ico {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 9px; background: var(--page);
  border: 1px solid var(--hairline); display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.timeline .t-date { color: var(--muted); font-size: 11.5px; }

/* ---------- Checklist ---------- */
.checklist-cat { margin-bottom: 14px; }
.check-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--hairline); font-size: 13px; }
.check-item:last-child { border-bottom: none; }
.check-state {
  width: 27px; height: 27px; border-radius: 8px; border: 1px solid var(--hairline);
  background: var(--surface); cursor: pointer; font-size: 13px; transition: all .15s;
}
button.check-state:hover { transform: scale(1.12); border-color: var(--accent); }
.check-state.ok { background: #e7f6e7; border-color: var(--good); }
.check-state.na { background: var(--page); color: var(--muted); }
.check-state.falta { background: #fdf3dc; border-color: var(--warning); }

/* ---------- Portal: pasos ---------- */
.steps { display: flex; margin: 14px 0; }
.step { flex: 1; text-align: center; position: relative; font-size: 12px; color: var(--muted); }
.step::before {
  content: ""; display: block; width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--hairline); margin: 0 auto 6px; position: relative; z-index: 2;
}
.step::after { content: ""; position: absolute; top: 7px; left: 50%; width: 100%; height: 2px; background: var(--hairline); }
.step:last-child::after { display: none; }
.step.done { color: var(--good-text); font-weight: 600; }
.step.done::before { background: var(--good); border-color: var(--good); }
.step.done::after { background: var(--good); }

/* ---------- Login (selector de perfiles) ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 30px 16px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(42, 120, 214, .16), transparent 60%),
    radial-gradient(800px 500px at 100% 110%, rgba(27, 175, 122, .14), transparent 60%),
    var(--page);
}
.login-card {
  width: 720px; max-width: 96vw; background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 18px; padding: 34px 38px; box-shadow: var(--shadow-lift); animation: rise .4s ease both;
}
.login-msg {
  text-align: center; font-size: 12.5px; border-radius: 9px; padding: 7px 12px; margin: 0 0 14px;
  background: #eef4e9; color: #2c5a24; border: 1px solid #d5e4cb;
}
.login-msg.error { background: #fbeeee; color: #8c2323; border-color: #efd3d3; }
.new-profile { margin-top: 2px; }
.new-profile > summary {
  list-style: none; cursor: pointer; text-align: center; font-size: 12.5px; font-weight: 600;
  color: var(--ink-2); border: 1px dashed var(--hairline); border-radius: 11px; padding: 9px;
  transition: all .15s; user-select: none;
}
.new-profile > summary::-webkit-details-marker { display: none; }
.new-profile > summary:hover { color: var(--accent-strong); border-color: var(--accent); background: #f6faff; }
.new-profile[open] > summary {
  color: var(--accent-strong); border-color: var(--accent-soft); background: #f6faff;
  border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom-style: solid;
}
.new-profile > form {
  border: 1px dashed var(--accent-soft); border-top: none; border-radius: 0 0 11px 11px;
  padding: 14px 16px 12px; background: #fbfdff; animation: rise .2s ease both;
}
.login-card .brand { justify-content: center; padding-bottom: 4px; }
.login-card .brand b, .login-card .brand small { color: inherit; }
.login-card .brand b { color: var(--ink); }
.login-card .brand small { color: var(--muted); }
.login-brand { text-align: center; margin-bottom: 10px; }
.login-logo { width: 132px; height: auto; display: block; margin: 0 auto 6px; }
.login-brand small {
  display: block; color: var(--muted); font-size: 10px; letter-spacing: .14em;
}
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.personas { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 9px; margin-bottom: 20px; }
.persona {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border: 1px solid var(--hairline); border-radius: 11px; background: var(--surface);
  color: var(--ink); transition: all .15s; animation: rise .35s ease both;
}
.persona:hover {
  text-decoration: none; border-color: var(--accent); box-shadow: var(--shadow-lift);
  transform: translateY(-2px); background: #fbfdff;
}
.persona .avatar { width: 34px; height: 34px; font-size: 12.5px; flex-shrink: 0; }
.persona b { display: block; font-size: 13px; line-height: 1.2; }
.persona small { color: var(--muted); font-size: 11px; display: block; }
.login-divider {
  display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .08em; margin: 4px 0 14px;
}
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--hairline); }
.login-free { display: flex; gap: 8px; }
.login-hint { font-size: 12px; color: var(--muted); margin-top: 16px; line-height: 1.6; text-align: center; }

/* ---------- Utilidades ---------- */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }
.tag { display: inline-block; white-space: nowrap; font-size: 11px; background: var(--page); border: 1px solid var(--hairline); border-radius: 6px; padding: 1px 7px; color: var(--ink-2); }

/* Canal de vente — le registre existe justement pour voir les 4 canaux au
   même endroit (§3.2), donc la colonne doit se lire d'un coup d'œil. Mêmes
   couleurs que le schéma du workflow eshop, pour garder un seul langage. */
.canal { display: inline-block; white-space: nowrap; font-size: 11px; font-weight: 600;
         border: 1px solid; border-radius: 6px; padding: 1px 7px; letter-spacing: .01em; }
.canal.c-woo       { background: #f3e8fa; color: #6b2f8f; border-color: #ddc2ec; }
.canal.c-systemeio { background: #e2f6ee; color: #0c6b4a; border-color: #b5e6d3; }
.canal.c-stripe    { background: #e9f1fc; color: #1c5cab; border-color: #c4dcf6; }
.canal.c-virement  { background: #fdf3dc; color: #8a5f00; border-color: #f3dda6; }
.canal.c-cheque    { background: var(--page);  color: var(--ink-2); border-color: var(--hairline); }
/* Origine automatique : un liseré indique que personne ne l'a saisie à la main. */
.canal.auto::after { content: "⟳"; margin-left: 4px; opacity: .65; font-weight: 400; }

/* ---------- Vente automatique en attente de validation ----------
   La ligne se distingue sans crier : liseré à gauche et fond très léger. */
tr.row-avalider > td { background: #fffaf0; }
tr.row-avalider > td:first-child { box-shadow: inset 3px 0 0 var(--serious); }
.badge-btn { cursor: pointer; font-family: inherit; font-size: inherit; }
.badge-btn:hover { filter: brightness(.96); text-decoration: none; }

/* Modal de validation : le brut du webhook à gauche, ce qu'on confirme à droite. */
.val-warn {
  background: #fdf3dc; border: 1px solid #f3dda6; border-left-width: 3px;
  color: #8a5f00; border-radius: 8px; padding: 10px 13px; font-size: 12.5px;
  margin-bottom: 14px;
}
.val-warn div + div { margin-top: 5px; }
.val-cols { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.val-raw { flex: 1; min-width: 280px; background: var(--page);
           border-radius: 10px; padding: 12px 14px; }
.val-edit { flex: 1; min-width: 280px; display: flex; flex-direction: column; gap: 10px; }
.val-edit label { display: flex; flex-direction: column; gap: 3px; }
.val-dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 12.5px; }
.val-dl dt { color: var(--muted); }
.val-dl dd { margin: 0; font-weight: 500; word-break: break-word; }
.val-sched { font-size: 12px; font-variant-numeric: tabular-nums; }
.vs-line { display: grid; grid-template-columns: 18px 1fr auto auto; gap: 8px;
           padding: 3px 0; border-bottom: 1px solid var(--hairline); }
.vs-line:last-child { border-bottom: 0; }
.vs-line.ok { color: var(--good-text); }
.vs-line span:first-child { color: var(--muted); }

/* Bandeaux d'alerte du tableau de bord (§3.1) — au-dessus des statistiques,
   cliquables, et absents quand il n'y a rien à traiter. */
.alert-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.al {
  display: flex; align-items: baseline; gap: 8px; flex: 1; min-width: 260px;
  padding: 9px 13px; border-radius: 10px; border: 1px solid; font-size: 13px;
  text-decoration: none; transition: box-shadow .15s, transform .12s;
}
.al:hover { text-decoration: none; box-shadow: var(--shadow); transform: translateY(-1px); }
.al b { font-weight: 650; }
.al-critical { background: #fbe4e4; border-color: #f2bcbc; color: #8f2020; }
.al-warning  { background: #fdf3dc; border-color: #f3dda6; color: #8a5f00; }
.al-accent   { background: #e9f1fc; border-color: #c4dcf6; color: #1c5cab; }
.al-who { font-size: 11.5px; opacity: .8; margin-left: auto; text-align: right;
          white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }

/* Échéancier — «payées / total» avec le même feu que l'écran de suivi (§3.5),
   pour repérer un dossier en défaut sans ouvrir la fiche. */
.ech { display: inline-block; white-space: nowrap; font-variant-numeric: tabular-nums;
       font-size: 12px; font-weight: 600; padding: 1px 6px; border-radius: 6px;
       border: 1px solid transparent; }
.ech::before { content: "●"; font-size: 7px; vertical-align: 2px; margin-right: 4px; }
.ech.t-vacio    { color: var(--muted); font-weight: 400; }
.ech.t-vacio::before { content: none; }
.ech.t-neutro   { color: var(--ink-2); background: var(--page); border-color: var(--hairline); }
.ech.t-neutro::before { color: var(--muted); }
.ech.t-good     { color: var(--good-text); background: #e7f6e7; border-color: #bfe6bf; }
.ech.t-warning  { color: #8a5f00;          background: #fdf3dc; border-color: #f3dda6; }
.ech.t-critical { color: #8f2020;          background: #fbe4e4; border-color: #f2bcbc; }
.empty {
  color: var(--muted); font-size: 13px; padding: 22px 10px; text-align: center;
  border: 1px dashed var(--hairline); border-radius: 9px; background: var(--page);
}
td.empty, tr .empty { border: none; background: none; padding: 16px 0; }
.divider { border: none; border-top: 1px solid var(--hairline); margin: 14px 0; }
.photo-cell { font-size: 20px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 700;
}

/* ---------- Impresión (PDF del presupuesto) ---------- */
@media print {
  .sidebar, .topbar, .no-print, .toasts { display: none !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { box-shadow: none; animation: none; }
}

/* ---------- Capa de interacción: tooltips y gráficos vivos ---------- */
#viz-tip {
  position: fixed; z-index: 300; background: var(--ink); color: #fff;
  font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 7px;
  pointer-events: none; opacity: 0; transform: translate(-50%, -100%) translateY(-8px);
  transition: opacity .12s; max-width: 280px; text-align: center;
  box-shadow: 0 6px 18px rgba(11, 11, 11, .28); line-height: 1.4; white-space: pre-line;
}
#viz-tip.on { opacity: 1; }
a[data-tip], .chart-group[data-tip] { cursor: pointer; }

.chart-bar { transition: opacity .15s, filter .15s; }
.chart-cols:has(.chart-group:hover) .chart-group:not(:hover) .chart-bar { opacity: .35; }
.chart-group:hover .chart-bar { filter: brightness(1.12); }
.chart-x { transition: color .15s; }
.chart-group:hover .chart-x { color: var(--ink); font-weight: 650; }

.hbar { border-radius: 8px; padding: 3px 6px; margin: 0 -6px; transition: background .15s; }
a.hbar { color: inherit; }
a.hbar:hover { text-decoration: none; }
.hbar .fill { transition: opacity .15s, filter .15s; }
.hbars:has(.hbar:hover) .hbar:not(:hover) .fill { opacity: .45; }
.hbar:hover { background: var(--page); }
.hbar:hover .fill { filter: brightness(1.12); }

.meter .fill { transition: filter .15s; }
.meter:hover .fill { filter: brightness(1.18); }

.card { transition: box-shadow .25s; }
.card:hover { box-shadow: 0 2px 4px rgba(11,11,11,.06), 0 10px 26px rgba(11,11,11,.09); }
.nav-item { transition: background .15s, color .15s, transform .15s; }
.nav-item:hover { transform: translateX(2px); }
.btn:active { transform: scale(.97); }

/* ---------- Respuesta rápida desde la bandeja (borrador IA) ---------- */
.quick-reply { position: relative; display: inline-block; margin-right: 4px; }
.quick-reply > summary {
  list-style: none; cursor: pointer; user-select: none; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; color: var(--ink);
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 8px; padding: 4px 10px; transition: background .15s, border-color .15s, color .15s;
}
.quick-reply > summary::-webkit-details-marker { display: none; }
.quick-reply > summary:hover { border-color: var(--accent); color: var(--accent-strong); background: #f6faff; }
.quick-reply[open] > summary { border-color: var(--accent); color: var(--accent-strong); background: #eef5fd; }
.quick-reply.good > summary { background: linear-gradient(180deg, #14b514, var(--good)); border-color: #0a8a0a; color: #fff; }
.quick-reply.good > summary:hover, .quick-reply.good[open] > summary { background: #0a8a0a; color: #fff; }
.qr-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  width: 480px; max-width: 82vw; text-align: left; white-space: normal;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px;
  box-shadow: var(--shadow-lift); padding: 14px 16px; animation: rise .18s ease both;
}
.qr-panel textarea { width: 100%; font: inherit; font-size: 13px; }
.qr-quote {
  font-size: 12px; color: var(--muted); background: var(--page);
  border-left: 3px solid var(--hairline); border-radius: 0 8px 8px 0;
  padding: 7px 10px; margin-bottom: 10px;
}

/* ---------- Ma journée ---------- */
a.day-block { text-decoration: none; color: inherit; display: block; }
a.day-block:hover { text-decoration: none; }
.day-ico {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-strong);
}
.day-ico.critical { background: #f8dcdc; color: var(--critical); }
.day-ico.warning { background: #fdeecb; color: #8a6510; }
.meter .fill.good { background: var(--good); }

/* ---------- Fil de conversation (care) ---------- */
.bubble {
  max-width: 88%; border-radius: 12px; padding: 9px 12px; margin-bottom: 8px;
  border: 1px solid var(--hairline);
}
.bubble.in { background: var(--page); border-top-left-radius: 4px; }
.bubble.out {
  background: #eef5fd; border-color: var(--accent-soft);
  margin-left: auto; border-top-right-radius: 4px;
}
.bubble .b-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ---------- Gráfico de meses clicable (KPIs) ---------- */
a.chart-group { text-decoration: none; color: inherit; cursor: pointer; }
a.chart-group:hover { text-decoration: none; }
a.chart-group.on .chart-bar { background: var(--accent-strong); }
a.chart-group.on .chart-x { color: var(--accent-strong); font-weight: 700; }

/* ---------- Combobox de recherche (client, etc.) ---------- */
.combo { position: relative; }
.combo-input { width: 100%; }
.combo-list {
  position: absolute; z-index: 50; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 260px; overflow-y: auto; display: none;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 10px;
  box-shadow: var(--shadow-lift); padding: 4px;
}
.combo.open .combo-list { display: block; }
.combo-item {
  padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 13px;
  line-height: 1.3;
}
.combo-item.hidden { display: none; }
.combo-item:hover, .combo-item.active { background: var(--accent-soft); }
.combo-item.is-new { color: var(--accent-strong); font-weight: 600; border-bottom: 1px solid var(--hairline); border-radius: 7px 7px 0 0; }
/* ---------- Select filtrable ----------
   Garde l'aspect d'un select fermé (chevron, curseur), devient un champ de
   recherche à l'ouverture. La liste est une vraie surface flottante : ombre,
   coins arrondis, ligne active marquée — pas la liste système. */
.sel-search .combo-input {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23898781' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 28px; cursor: pointer; text-overflow: ellipsis;
  transition: border-color .14s, box-shadow .14s, background-color .14s;
}
.sel-search .combo-input:hover { border-color: var(--muted); }
.sel-search.open .combo-input {
  cursor: text; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background-color: var(--surface);
}
/* Chevron retourné quand c'est ouvert : l'état se lit sans réfléchir. */
.sel-search.open .combo-input {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 5l4-4 4 4' fill='none' stroke='%232a78d6' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
}
.sel-search .combo-list {
  box-shadow: var(--shadow-lift); border-radius: 10px; padding: 4px;
  max-height: 280px; scrollbar-width: thin;
}
.sel-search .combo-item {
  border-radius: 7px; padding: 6px 10px 6px 26px; position: relative;
  line-height: 1.35;
}
.sel-search .combo-item.chosen { font-weight: 600; color: var(--accent-strong); }
.sel-search .combo-item.chosen::before {
  content: "✓"; position: absolute; left: 9px; color: var(--accent); font-size: 11px;
}
/* La ligne survolée et la ligne au clavier se ressemblent : une seule cible. */
.sel-search .combo-item.active, .sel-search .combo-item:hover {
  background: var(--accent-soft); box-shadow: none;
}
.sel-search .combo-list:empty::after,
.sel-search .combo-item.no-hit {
  content: "Aucun résultat"; display: block; padding: 8px 10px;
  color: var(--muted); font-size: 12.5px; font-style: italic;
}

/* ---------- Bouton flottant de support (portail élève) ---------- */
.fab-support { position: fixed; right: 26px; bottom: 26px; z-index: 80; }
.fab-support > summary {
  list-style: none; cursor: pointer; width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff;
  background: linear-gradient(135deg, #3987e5, #1c5cab);
  box-shadow: 0 6px 20px rgba(28, 92, 171, .45); transition: transform .15s, box-shadow .15s;
}
.fab-support > summary::-webkit-details-marker { display: none; }
.fab-support > summary:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(28, 92, 171, .5); }
.fab-support[open] > summary { transform: scale(.94); }
.fab-panel {
  position: absolute; right: 0; bottom: calc(100% + 12px); width: 320px; max-width: 86vw;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 14px;
  box-shadow: var(--shadow-lift); padding: 16px 18px; animation: rise .18s ease both;
}
.fab-head { display: flex; align-items: center; font-weight: 650; font-size: 14px; margin-bottom: 12px; }
.fab-close { margin-left: auto; color: var(--muted); font-size: 15px; }

/* ---------- Modal générique ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(11, 11, 11, .42); backdrop-filter: blur(2px);
  align-items: center; justify-content: center; padding: 24px;
}
.modal-overlay.open { display: flex; animation: rise .16s ease both; }
.modal-box {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lift);
  width: 620px; max-width: 94vw; max-height: 88vh; overflow-y: auto; padding: 20px 22px;
}
.modal-box.wide { width: 860px; }
.modal-head { display: flex; align-items: center; font-size: 15px; margin-bottom: 14px; }
.modal-head b { flex: 1; }
.modal-close { cursor: pointer; color: var(--muted); font-size: 16px; }
.modal-close:hover { color: var(--ink); }

/* ---------- Liste des e-mails d'une séquence ---------- */
.mail-list { max-height: 440px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.mail-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: var(--page); border: 1px solid var(--hairline); border-radius: 9px;
  padding: 8px 10px; cursor: pointer; font: inherit; transition: border-color .12s, background .12s;
}
.mail-row:hover { border-color: var(--accent); background: #f6faff; }
.mail-row.hidden { display: none; }
.mail-n {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-strong);
}
.mail-obj { flex: 1; min-width: 0; font-size: 13px; }
.mail-obj b { display: inline; }
.mail-go { color: var(--accent); font-size: 12px; font-weight: 600; flex-shrink: 0; }

/* ---------- Calendrier éditorial (vue mensuelle) ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-head { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 650; text-align: center; padding: 2px 0; }
.cal-cell {
  min-height: 88px; background: var(--page); border: 1px solid var(--hairline);
  border-radius: 9px; padding: 5px 6px; display: flex; flex-direction: column; gap: 3px;
}
.cal-cell.out { background: transparent; border-color: transparent; }
.cal-cell.out .cal-daynum { color: #cccabf; }
.cal-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-daynum { font-size: 11.5px; font-weight: 650; color: var(--ink-2); }
.cal-post {
  font: inherit; font-size: 10.5px; text-align: left; line-height: 1.25; cursor: pointer;
  border: none; border-radius: 6px; padding: 3px 6px; color: #fff; width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: filter .12s;
}
.cal-post:hover { filter: brightness(1.08); }
.net-instagram { background: #c2418b; } .net-facebook { background: #2f6fd6; }
.net-youtube  { background: #d03b3b; } .net-linkedin { background: #1c5cab; }
.cal-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; vertical-align: -1px; margin-right: 2px; }
.cal-preview { border-radius: 12px; padding: 14px 16px; border: 1px solid var(--hairline); background: var(--page); border-left: 4px solid var(--accent); }
.cal-preview.net-instagram { border-left-color: #c2418b; }
.cal-preview.net-facebook { border-left-color: #2f6fd6; }
.cal-preview.net-youtube { border-left-color: #d03b3b; }
.cal-preview.net-linkedin { border-left-color: #1c5cab; }
.cal-preview-net { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
@media (max-width: 900px) { .cal-cell { min-height: 66px; } .cal-post { font-size: 9.5px; } }

/* ============================================================
   Pulido estético v3 — desplegables, controles y micro-detalles
   ============================================================ */

/* --- Selects : garantizar hueco para el chevron incluso en los pequeños,
       y evitar el "salto" al pasar el ratón dentro de tablas densas --- */
select { padding-right: 28px !important; }
table.data select, .flex select, td select { transform: none !important; }
table.data select:hover { transform: none !important; box-shadow: 0 1px 2px rgba(11,11,11,.06); }

/* --- Checkboxes & radios : color de marca, tamaño cómodo --- */
input[type=checkbox], input[type=radio] {
  accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer;
  vertical-align: -2px;
}
.check { cursor: pointer; }
.check:hover { color: var(--ink); }
label.check.radio-tile {
  border: 1px solid var(--hairline); border-radius: 9px; padding: 8px 10px;
  background: var(--surface); transition: border-color .12s, background .12s;
}
label.check.radio-tile:hover { border-color: var(--accent-soft); background: #f6faff; }

/* --- Date / heure : indicador del picker más discreto y clicable --- */
input[type=date], input[type=datetime-local], input[type=time] { cursor: pointer; }
input[type=date]::-webkit-calendar-picker-indicator,
input[type=datetime-local]::-webkit-calendar-picker-indicator,
input[type=time]::-webkit-calendar-picker-indicator {
  opacity: .5; cursor: pointer; transition: opacity .12s;
}
input[type=date]:hover::-webkit-calendar-picker-indicator,
input[type=datetime-local]:hover::-webkit-calendar-picker-indicator { opacity: .85; }

/* --- Focus visible cohérent (accessibilité clavier) --- */
a:focus-visible, button:focus-visible, .nav-item:focus-visible,
.combo-item:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px;
}

/* --- Scrollbars claras (zonas desplegables) --- */
.mail-list, .combo-list, .table-scroll, .bell-menu, .qr-panel, .modal-box {
  scrollbar-width: thin; scrollbar-color: #cfcdc4 transparent;
}
.mail-list::-webkit-scrollbar, .combo-list::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar, .modal-box::-webkit-scrollbar { width: 9px; height: 9px; }
.mail-list::-webkit-scrollbar-thumb, .combo-list::-webkit-scrollbar-thumb,
.table-scroll::-webkit-scrollbar-thumb, .modal-box::-webkit-scrollbar-thumb {
  background: #d4d2c8; border-radius: 6px; border: 2px solid transparent; background-clip: content-box;
}
.mail-list::-webkit-scrollbar-thumb:hover, .modal-box::-webkit-scrollbar-thumb:hover { background: #b9b7ae; background-clip: content-box; }

/* --- KPI : ligera elevación al pasar el ratón --- */
.kpi { transition: box-shadow .18s, transform .18s, border-color .18s; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: #d7d5cc; }
a.kpi:hover { text-decoration: none; }

/* --- Botón primario : sombra de color al pasar el ratón --- */
.btn.primary:hover { box-shadow: 0 4px 12px rgba(42,120,214,.28); }
.btn.good:hover { box-shadow: 0 4px 12px rgba(12,163,12,.24); }

/* --- Tablas : cabecera con sutil separación al hacer scroll --- */
.table-scroll table.data th { box-shadow: 0 1px 0 var(--hairline); }
table.data tr:hover td { background: #f5f8fd; }

/* --- Tags : un pelín más suaves --- */
.tag { transition: border-color .12s, background .12s; }

/* --- Combobox : ítem activo con acento a la izquierda --- */
.combo-item.active, .combo-item:hover { box-shadow: inset 2px 0 0 var(--accent); }

/* --- Modal : cierre con giro sutil --- */
.modal-close, .fab-close { transition: color .12s, transform .12s; }
.modal-close:hover, .fab-close:hover { transform: rotate(90deg); }

/* --- Inputs : placeholder más claro y foco uniforme --- */
input::placeholder, textarea::placeholder { color: #b0aea6; }
textarea { resize: vertical; min-height: 40px; }

/* ============================================================
   Pulido v5 — utilidades, variantes y correcciones transversales
   (auditoría visual de las 34 páginas)
   ============================================================ */

/* Énfasis siempre visible, independientemente de la fuente del sistema */
b, strong { font-weight: 700; }

/* Utilidades de layout y texto */
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.clamp-1 { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt6 { margin-top: 6px; } .mt8 { margin-top: 8px; } .mt10 { margin-top: 10px; }
.mb8 { margin-bottom: 8px; } .mb14 { margin-bottom: 14px; }

/* Enlaces-componente sin cromo de hipervínculo */
a.card, a.card:hover { color: inherit; text-decoration: none; }
a.kpi { color: inherit; text-decoration: none; display: block; }

/* Avatar de persona (morado de marca, antes inline en 4 templates) */
.avatar-person { background: #4a3aa7; }

/* Tarjeta anidada dentro de otra tarjeta: plana, sin sombra ni animación */
.card .card { background: var(--page); box-shadow: none; animation: none; margin-bottom: 10px; }
.card .card:hover { box-shadow: none; }

/* Cabecera de tarjeta con título + tag que nunca se descuelga */
.card-head { display: flex; align-items: flex-start; gap: 8px; flex-wrap: nowrap; }
.card-head h2, .card-head h3 { min-width: 0; margin-bottom: 0; font-size: 13.5px; }
.card-head .tag { flex: none; margin-left: auto; }

/* Variantes de tarjeta */
.card.accent { background: #f4f9ff; border-color: var(--accent-soft); }
.card.accent > h2 { border-bottom: none; padding-bottom: 0; }
.card.accent table.data th { background: transparent; }
.card.critical { border-color: #f2bcbc; }

/* Un td nunca debe perder su display de celda (defensa ante td.flex) */
td.flex, th.flex { display: table-cell; }

/* Badges en columna alineada (listas de alertas) */
.badge.col { min-width: 112px; justify-content: center; }

/* Filas de lista con contenido multilínea: fecha/tag alineados arriba */
.check-item.top { align-items: flex-start; }
.check-item.top .tag, .check-item.top .badge { margin-top: 2px; }

/* Notificaciones no leídas: indicador real, no solo font-weight */
.timeline li.unread .t-ico { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.timeline li.unread b { font-weight: 700; }

/* Cabeceras de tabla ordenables */
table.data th a { color: inherit; }
table.data th a:hover { text-decoration: underline; }

/* ============================================================
   Portail élève v4 — espace personnel (onboarding/portal)
   ============================================================ */
.portal-hero {
  position: relative; overflow: hidden; border-radius: 16px; padding: 24px 28px;
  background:
    radial-gradient(560px 240px at 88% -40%, rgba(125, 180, 238, .38), transparent 65%),
    radial-gradient(460px 220px at 6% 140%, rgba(27, 175, 122, .20), transparent 60%),
    linear-gradient(120deg, #17203a, #1c3a66 55%, #1c5cab);
  color: #fff; display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  box-shadow: var(--shadow-lift); margin-bottom: 16px; animation: rise .35s ease both;
}
.portal-hero .avatar {
  width: 56px; height: 56px; font-size: 19px; font-weight: 700;
  background: rgba(255, 255, 255, .14); border: 2px solid rgba(255, 255, 255, .38);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
.portal-hero .hello {
  font-size: 11px; color: #a9bbdd; text-transform: uppercase; letter-spacing: .12em;
  margin-bottom: 3px; font-weight: 650;
}
.portal-hero h1 { color: #fff; font-size: 23px; margin: 0; letter-spacing: -0.01em; }
.portal-chips { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 9px; }
.portal-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600;
  color: #dce6f5; background: rgba(255, 255, 255, .10); border: 1px solid rgba(255, 255, 255, .17);
  border-radius: 99px; padding: 3.5px 11px; white-space: nowrap;
}
.portal-chip svg { opacity: .75; }
.portal-hero .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.btn.on-dark { background: rgba(255, 255, 255, .10); border-color: rgba(255, 255, 255, .30); color: #fff; }
.btn.on-dark:hover { background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .55); box-shadow: none; }

.portal-cols { display: grid; grid-template-columns: 5fr 4fr; gap: 0 14px; align-items: start; }
@media (max-width: 1100px) { .portal-cols { grid-template-columns: 1fr; } }

.formation-item {
  border: 1px solid var(--hairline); border-radius: 12px; background: var(--page);
  padding: 13px 15px;
}
.formation-item + .formation-item { margin-top: 10px; }
.f-head { display: flex; align-items: center; gap: 11px; }
.f-head b { font-size: 13.5px; line-height: 1.25; }
.f-ico {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-strong);
}
.f-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.f-progress { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.f-progress .meter { flex: 1; height: 8px; }
.f-progress .pct {
  font-size: 12px; font-weight: 650; color: var(--accent-strong);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.f-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 11px; border-top: 1px dashed var(--hairline);
}
.f-actions form.inline { display: inline-flex; align-items: center; gap: 6px; }
.f-actions select { width: auto; min-width: 84px; font-size: 12px; padding: 4px 26px 4px 8px; }

.echeance-strip {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  margin-top: 9px; padding: 8px 11px; font-size: 12px;
  background: var(--page); border: 1px dashed var(--hairline); border-radius: 9px;
}
.echeance-strip .lbl { color: var(--muted); font-weight: 600; margin-right: 2px; }

.date-tile {
  width: 42px; flex-shrink: 0; text-align: center; padding: 4px 0 5px;
  border: 1px solid var(--hairline); border-radius: 10px; background: var(--surface);
}
.date-tile b { display: block; font-size: 15px; line-height: 1.05; letter-spacing: -0.01em; }
.date-tile small {
  font-size: 9px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
}
.session-item {
  display: flex; align-items: center; gap: 11px; padding: 8px 0;
  border-bottom: 1px dashed var(--hairline); font-size: 13px;
}
.session-item:last-child { border-bottom: none; padding-bottom: 2px; }

.empty.sm { padding: 13px 10px; font-size: 12.5px; }

/* ---- Chercheur de rapprochement (Ventes / Échéances) ---- */
.rec-target { margin-bottom: 9px; font-size: 14px; }
#rec-search { width: 100%; margin-bottom: 4px; }
.rec-hint { margin-bottom: 6px; }
.rec-list {
  list-style: none; margin: 0; padding: 2px; max-height: 46vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
}
.rec-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--hairline); border-radius: 9px;
  background: var(--page);
}
.rec-item.rec-match { border-color: var(--good-tint-border); background: var(--good-tint); }
.rec-main { min-width: 0; }
.rec-badge {
  display: inline-block; font-size: 11px; font-weight: 650; color: var(--good);
  background: var(--surface); border: 1px solid var(--good-tint-border);
  border-radius: 20px; padding: 1px 7px;
}
.rec-empty { padding: 16px; text-align: center; color: var(--muted); }
