/* ==========================================================================
   Wafi CRM - Application shell & component refinements
   Loaded after main.css and components.css on every CRM page.
   Charte « Casbah » : un accent (bleu Casbah), ocre en décor, motif zellige en signature.
   Light / dark aware.
   ========================================================================== */

body { letter-spacing: -0.005em; }
.num, .amount, td.text-right, .stat-value, .kpi-value { font-variant-numeric: tabular-nums; }
a:hover { text-decoration: none; }
::selection { background: var(--primary-light); color: var(--primary-active); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Sidebar ---------- */
.app-sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
}
/* Signature Casbah : bande de zellige en haut du menu */
.app-sidebar::before { content: ""; display: block; flex: none; height: 12px; background: var(--zellige-band); background-size: 12px 12px; }
.sidebar-header { height: calc(var(--header-height) - 12px); padding: 0 18px; border-bottom: 0; }
.brand-logo { gap: 11px; font-size: 15px; letter-spacing: -0.02em; min-width: 0; }
.brand-logo:hover { text-decoration: none; }
/* Logo : étoile à huit branches (remplace le carré « W ») */
.brand-icon {
  width: 36px; height: 36px; flex: none; border-radius: 0; box-shadow: none;
  background: url("../assets/brand/wafi-icon.svg") center / contain no-repeat;
  color: transparent; font-size: 0; overflow: hidden;
}
html[data-theme="dark"] .brand-icon { background-image: url("../assets/brand/wafi-icon-white.svg"); }
.brand-wordmark { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 17px; letter-spacing: -0.025em; color: var(--text-primary); line-height: 1.1; }
.brand-wordmark .brand-sep { width: 1.5px; height: 14px; background: var(--brand-ochre); flex: none; }
.brand-wordmark .brand-ar { color: var(--primary); letter-spacing: 0; font-weight: 600; }
.brand-store-tag { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.sidebar-nav { padding: 8px 12px 16px; }
.nav-section { margin-bottom: 18px; }
.nav-section-title { padding: 6px 12px; font-size: 11px; letter-spacing: .06em; color: var(--text-subdued); }
.nav-item { margin-bottom: 2px; }
.nav-link {
  position: relative; padding: 9px 12px; border-radius: 12px; color: var(--text-secondary);
  font-weight: 550; transition: background-color var(--transition-fast), color var(--transition-fast);
}
.nav-link svg { width: 19px; height: 19px; color: var(--text-subdued); }
.nav-link:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.nav-link:hover svg { color: var(--text-primary); }
.nav-link.active,
html[data-theme="dark"] .nav-link.active { background: var(--primary-light); color: var(--primary-active); font-weight: 650; }
html[data-theme="dark"] .nav-link.active { color: var(--primary); }
.nav-link.active svg { color: var(--primary); }
.nav-link.active::before {
  content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav-badge { font-variant-numeric: tabular-nums; }
.sidebar-footer { border-top: 1px solid var(--border-subtle); padding: 12px; }
.user-quick-profile { border-radius: 12px; }
.user-quick-profile:hover { text-decoration: none; }
.user-avatar-sm, .header-avatar { background: var(--primary); color: var(--text-on-primary); }

/* ---------- Top bar ---------- */
.app-header {
  background: var(--header-bg);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: none;
  padding: 0 28px;
  gap: 16px;
}
.mobile-menu-btn { color: var(--text-primary); border-radius: 10px; }
.mobile-menu-btn:hover { background: var(--bg-surface-hover); }
.global-search-input {
  height: 40px; border-radius: 999px; background: var(--bg-app); border-color: var(--border-default);
  color: var(--text-primary); padding-left: 40px; font-size: 14px;
}
.global-search-input::placeholder { color: var(--text-subdued); }
.global-search-input:focus { background: var(--bg-surface); border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }
.search-icon { left: 14px; }
.search-shortcut { background: var(--bg-surface); color: var(--text-subdued); border: 1px solid var(--border-default); border-radius: 6px; font-family: var(--font-mono); right: 12px; }
.header-icon-btn { width: 40px; height: 40px; border-radius: 12px; color: var(--text-secondary); }
.header-icon-btn:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.notification-dot { top: 9px; right: 9px; border-color: var(--bg-surface); }
.header-user-btn { padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--border-default); background: var(--bg-surface); }
.header-user-btn:hover { background: var(--bg-surface-hover); }
.header-avatar { width: 32px; height: 32px; }
.header-username { color: var(--text-primary); font-weight: 600; }

/* ---------- Page ---------- */
.page-container { padding: 28px 32px 48px; max-width: 1480px; }
.page-title { font-size: 1.75rem; letter-spacing: -0.035em; font-weight: 700; }
.page-subtitle { font-size: 14px; }

/* ---------- Components polish ---------- */
.card { border-color: var(--border-subtle); box-shadow: var(--shadow-card); }
.card-header { padding: 18px 22px; }
.card-title { font-size: 15.5px; font-weight: 650; letter-spacing: -0.01em; }
.card-body { padding: 22px; }
.card-footer { padding: 12px 22px; }
.stat-card { border-radius: var(--radius-lg); border-color: var(--border-subtle); box-shadow: var(--shadow-card); }
.stat-card-value { letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.btn { border-radius: 10px; font-weight: 600; padding: 8px 16px; transition: background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast); }
.btn:active { transform: scale(.98); }
.btn-primary { border-color: transparent; box-shadow: 0 6px 16px -8px rgba(21, 82, 163, .7), inset 0 1px 0 rgba(255, 255, 255, .15); }
.btn-secondary { border-color: var(--border-default); box-shadow: var(--shadow-xs); }
.btn-sm { padding: 5px 11px; }
.btn-lg { padding: 11px 20px; }
.btn:focus-visible { box-shadow: 0 0 0 3px var(--primary-light), 0 0 0 1px var(--primary); }
.form-control, .form-select, .form-textarea { height: 40px; border-color: var(--border-default); border-radius: 10px; }
.form-textarea { height: auto; }
.form-control:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }
.data-table-container { border-radius: var(--radius-lg); border-color: var(--border-subtle); box-shadow: var(--shadow-card); }
.data-table th { font-size: 12px; letter-spacing: .02em; }
.table-tab-btn { border-radius: 999px; }
.modal-dialog { border-radius: 20px; }
.dropdown-menu { border-radius: 16px; border-color: var(--border-subtle); padding: 6px; }
.dropdown-item { border-radius: 10px; }
.badge { font-weight: 600; }

/* ---------- Mobile tab bar (phones) ---------- */
.mobile-tabbar { display: none; }
@media (max-width: 767px) {
  .mobile-tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-header);
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--header-bg);
    backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
    border-top: 1px solid var(--border-subtle);
  }
  .tabbar-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: 11px; font-weight: 600; color: var(--text-subdued); position: relative;
  }
  .tabbar-item svg { width: 22px; height: 22px; }
  .tabbar-item.active { color: var(--primary); }
  .tabbar-item.active::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary); }
  .tabbar-badge { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--status-critical-text); color: #fff; font-size: 10px; display: grid; place-items: center; }
  .page-container { padding: 20px 16px calc(var(--tabbar-height) + 28px + env(safe-area-inset-bottom)); }
  .app-header { padding: 0 12px; }
  .header-user-btn { border: 0; padding: 2px; background: transparent; }
  .header-user-btn > svg { display: none; }
  .toast-container { bottom: calc(var(--tabbar-height) + 12px) !important; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Thème sombre : le bleu de marque est plus clair, les boutons principaux prennent un texte foncé (WCAG AA) */
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn-primary:hover { color: #081022; }

/* ---------- Phones: generic single-column layout for inline multi-column grids ---------- */
@media (max-width: 767px) {
  .page-container [style*="grid-template-columns"]:not(.keep-grid) { grid-template-columns: minmax(0, 1fr) !important; }
  .page-title { font-size: 1.45rem; }
  .page-header { gap: 12px; margin-bottom: 18px; }
  .page-actions { flex-wrap: wrap; }
  .page-actions .btn { flex: 1 1 auto; justify-content: center; }
  .modal-dialog { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; }

  .row-actions { opacity: 1; }

  /* Tables become a list of cards (labels added by js/common.js initResponsiveTables) */
  .table-cards { min-width: 0 !important; border-collapse: separate; }
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody { display: block; width: 100%; }
  .table-cards tbody { padding: 8px; }
  .table-cards tbody tr {
    display: block; margin-bottom: 10px; padding: 8px 14px; border: 1px solid var(--border-subtle);
    border-radius: 14px; background: var(--bg-surface); box-shadow: var(--shadow-xs);
  }
  .table-cards tbody tr:last-child { margin-bottom: 0; }
  .table-cards tbody tr:hover td { background: transparent; }
  .table-cards td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 7px 0 !important; border: 0 !important; text-align: right !important; min-height: 36px;
    white-space: normal !important; width: auto !important;
  }
  .table-cards td + td { border-top: 1px dashed var(--border-subtle) !important; }
  .table-cards td::before {
    content: attr(data-label); flex: none; max-width: 45%;
    font-size: 12px; font-weight: 600; color: var(--text-subdued); text-align: left;
  }
  .table-cards td[data-label=""]::before { content: none; }
  .table-cards td[data-label=""] { justify-content: flex-start; text-align: left !important; }
  /* First meaningful cell = card title: full width, no label */
  .table-cards td:first-child:not(:has(input[type="checkbox"])) { justify-content: flex-start; text-align: left !important; font-size: 15px; font-weight: 600; }
  .table-cards td:first-child:not(:has(input[type="checkbox"]))::before { content: none; }
  .table-cards td:first-child:has(input[type="checkbox"]) { display: none; }
  .table-cards td:first-child:has(input[type="checkbox"]) + td { justify-content: flex-start; text-align: left !important; border-top: 0 !important; }
  .table-cards td:first-child:has(input[type="checkbox"]) + td::before { content: none; }
  .table-cards td[colspan] { display: block; text-align: center !important; }
  .table-cards td[colspan]::before { content: none; }
  .table-cards .row-actions, .table-cards td > div[style*="inline-flex"] { justify-content: flex-end; flex-wrap: wrap; }
  .table-cards .user-cell { justify-content: flex-start; }
  .table-responsive:has(.table-cards) { overflow: visible; }
}

/* The document editor grid must be allowed to shrink (its line table scrolls inside) */
#documentEditorForm > div[style*="grid-template-columns: 1fr 340px"] { grid-template-columns: minmax(0, 1fr) 340px !important; }
@media (max-width: 1100px) { #documentEditorForm > div[style*="grid-template-columns: 1fr 340px"] { grid-template-columns: minmax(0, 1fr) !important; } }

/* ---------- Status chips (shared) ---------- */
.chip { display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 650; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.chip-late { background: var(--status-critical-bg); color: var(--status-critical-text); }
.chip-today { background: var(--status-warning-bg); color: var(--status-warning-text); }
.chip-soon { background: var(--status-info-bg); color: var(--status-info-text); }
.chip-muted { background: var(--status-neutral-bg); color: var(--text-secondary); }

/* ---------- Pipeline (kanban) ---------- */
.kanban-board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(184px, 1fr); gap: 12px;
  overflow-x: auto; min-height: 0; padding-bottom: 12px; align-items: start;
  scroll-snap-type: x proximity; scrollbar-width: thin;
}
.kanban-column { width: auto; flex: none; background: var(--bg-surface-secondary); border-color: var(--border-subtle); max-height: calc(100dvh - 230px); scroll-snap-align: start; }
.kanban-column-header { flex-wrap: wrap; gap: 4px 8px; padding: 12px 14px; }
.column-total-amount { font-variant-numeric: tabular-nums; }
.kanban-cards-list { padding: 10px; gap: 10px; }
.kanban-cards-list.drag-over { background: var(--primary-light); outline: 2px dashed var(--primary); }
.deal-card { cursor: pointer; border-color: var(--border-subtle); border-radius: 12px; transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast); }
.deal-card:hover { border-color: var(--primary-border); box-shadow: var(--shadow-card-hover); transform: translateY(-1px); }
.deal-card:active { cursor: grabbing; }
.deal-footer { flex-wrap: wrap; gap: 6px; }
@media (max-width: 767px) {
  .kanban-board { grid-auto-columns: 84vw; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px 12px; scroll-padding: 0 16px; }
  .kanban-column { max-height: none; }
}

/* ---------- Team summary (collaborateurs) ---------- */
.team-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.team-summary > div { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 2px; }
.team-summary span { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.team-summary strong { font-size: 1.2rem; letter-spacing: -0.02em; }
@media (max-width: 767px) { .team-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Phones: headers and tab bars ---------- */
@media (max-width: 767px) {
  /* Title + badge rows wrap instead of squeezing the title word by word */
  .page-title-group > div[style*="display: flex"], .page-title-group > div[style*="display:flex"] { flex-wrap: wrap; row-gap: 6px; }
  .page-title-group .page-title { flex: 1 1 100%; }
  /* Tab bars scroll horizontally, one line */
  .table-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .table-tabs::-webkit-scrollbar { display: none; }
  .table-tab-btn { white-space: nowrap; flex: none; }
  .table-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .table-toolbar .search-field, .table-toolbar .table-actions { width: 100%; }
  .table-toolbar .search-field input { width: 100%; }
}

/* ---------- Phones: document preview header (document-detail) stacks vertically ---------- */
@media (max-width: 767px) {
  .doc-header-component > div[style*="display: flex"] { flex-direction: column; gap: 14px !important; }
  .doc-header-component > div[style*="display: flex"] > div { max-width: none !important; min-width: 0 !important; height: auto !important; min-height: 0 !important; justify-content: flex-start !important; }
  .doc-header-component > div[style*="display: flex"] > div > div { height: auto !important; justify-content: flex-start !important; }
  .doc-header-component > div[style*="display: flex"]:first-child > div:last-child > div { flex-direction: row-reverse; }
  .doc-header-component { overflow-wrap: anywhere; }
}

/* ── Pièces jointes ─────────────────────────────────────────── */
.pj-card { position: relative; }
.pj-card.is-dragging { outline: 2px dashed var(--primary); outline-offset: -4px; }
.pj-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pj-count { display: inline-flex; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--bg-surface-secondary); color: var(--text-secondary); font-size: 11.5px; align-items: center; justify-content: center; font-weight: 600; margin-left: 4px; }
.pj-add { cursor: pointer; }
.pj-drop { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--bg-surface, #fff) 88%, transparent); font-weight: 600; color: var(--primary); border-radius: inherit; z-index: 2; pointer-events: none; }
.pj-drop[hidden] { display: none; }
.pj-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.pj-list li { display: grid; grid-template-columns: 38px minmax(0, 1fr) 24px; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border-subtle, #F0F0F0); }
.pj-list li:last-child { border-bottom: 0; }
.pj-list li.pj-pending { display: block; font-size: 12.5px; color: var(--text-subdued); }
.pj-ext { grid-row: 1 / span 2; width: 38px; height: 38px; border-radius: 8px; background: var(--primary-light, #E3ECF8); color: var(--primary); font-size: 10.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; letter-spacing: .3px; }
.pj-ext.is-img { background: #FBEFD9; color: #8A5A12; }
.pj-name { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.pj-name:hover { color: var(--primary); }
.pj-meta { grid-column: 2; font-size: 11.5px; color: var(--text-subdued); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-del { grid-column: 3; grid-row: 1 / span 2; width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: var(--text-subdued); font-size: 18px; line-height: 1; cursor: pointer; }
.pj-del:hover, .pj-del:focus-visible { background: var(--status-critical-bg, #FDECEA); color: var(--status-critical-text, #B42318); }
.pj-empty { margin: 0; font-size: 12.5px; color: var(--text-subdued); }

/* ── Factures récurrentes ───────────────────────────────────── */
.rec-page-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: var(--space-4); }
.rec-crumb { font-size: var(--font-size-xs, 12px); color: var(--text-secondary); margin-bottom: 4px; }
.rec-crumb a { color: var(--text-secondary); text-decoration: none; }
.rec-crumb a:hover { color: var(--primary); }
.rec-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-6); }
.rec-kpi { padding: var(--space-4); display: flex; flex-direction: column; gap: 4px; }
.rec-kpi span { font-size: 12.5px; color: var(--text-secondary); }
.rec-kpi strong { font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.rec-sub { font-size: 11.5px; color: var(--text-subdued); margin: 2px 0 0; }
.rec-actions { white-space: nowrap; }
.rec-actions .btn + .btn { margin-left: 4px; }
.rec-del:hover { color: var(--status-critical-text, #B42318); }
.rec-empty { text-align: center; padding: var(--space-8, 48px) var(--space-4); }
.rec-empty h2 { font-size: 17px; margin: 0 0 6px; }
.rec-empty p { color: var(--text-secondary); max-width: 46ch; margin: 0 auto var(--space-4); }
.rec-note { font-size: 12px; color: var(--text-subdued); margin-top: var(--space-4); }
.rec-help { font-size: 13px; color: var(--text-secondary); margin: 0 0 var(--space-4); }
.rec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.rec-suffix { display: flex; align-items: center; gap: 8px; }
.rec-suffix span, .rec-hint { font-size: 12px; color: var(--text-subdued); }
.rec-mode { border: 1px solid var(--border-default, #E3E3E3); border-radius: 10px; padding: 10px 14px; margin: 4px 0 0; display: grid; gap: 6px; }
.rec-mode legend { padding: 0 4px; margin: 0; }
.rec-mode label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.rec-mode .rec-email { padding-left: 24px; }
.rec-mode .rec-email[hidden] { display: none; }
.rec-card .card-header { display: flex; justify-content: space-between; align-items: center; }
.rec-card p { margin: 0 0 8px; font-size: 13.5px; }
@media (max-width: 560px) { .rec-grid { grid-template-columns: 1fr; } }

/* ── Agenda ─────────────────────────────────────────────────── */
.ag-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: var(--space-4); }
.ag-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.ag-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--space-6); align-items: start; }
.ag-side { display: flex; flex-direction: column; gap: var(--space-4); }
.ag-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border-subtle, #EFEFEF); }
.ag-nav { display: flex; align-items: center; gap: 6px; }
.ag-nav .btn-icon { font-size: 18px; line-height: 1; width: 30px; height: 30px; text-decoration: none; }
.ag-month { font-size: 18px; font-weight: 650; letter-spacing: -.2px; margin: 0 0 0 8px; }
.ag-legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-secondary); margin-left: auto; }
.ag-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ag-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--ag-c); }
.ag-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.ag-dow { padding: 8px 10px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-subdued); border-bottom: 1px solid var(--border-subtle, #EFEFEF); }
.ag-day { min-height: 112px; padding: 6px 6px 8px; border-right: 1px solid var(--border-subtle, #EFEFEF); border-bottom: 1px solid var(--border-subtle, #EFEFEF); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ag-day:nth-child(7n) { border-right: 0; }
.ag-day.is-weekend { background: var(--bg-surface-secondary, #FAFAF8); }
.ag-day.is-out { background: transparent; }
.ag-day.is-out .ag-daynum { color: var(--text-disabled, #B5B5B5); }
.ag-day.is-focus { box-shadow: inset 0 0 0 2px var(--primary); }
.ag-daynum { align-self: flex-start; min-width: 26px; height: 26px; padding: 0 6px; border: 0; border-radius: 99px; background: transparent; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.ag-daynum:hover, .ag-daynum:focus-visible { background: var(--primary-light, #E3ECF8); color: var(--primary); }
.ag-day.is-today .ag-daynum { background: var(--primary); color: #fff; }
.ag-items { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ag-chip { --ag-c: #1552A3; display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--ag-c); border-radius: 5px; background: color-mix(in srgb, var(--ag-c) 10%, transparent); color: var(--text-primary); font: inherit; font-size: 12px; line-height: 1.35; padding: 3px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; text-decoration: none; transition: background .15s; }
.ag-chip:hover, .ag-chip:focus-visible { background: color-mix(in srgb, var(--ag-c) 20%, transparent); }
.ag-chip b { font-weight: 650; font-variant-numeric: tabular-nums; }
.ag-chip.is-late { --ag-c: #B42318; }
.ag-t-rdv { --ag-c: #1552A3; } .ag-t-appel { --ag-c: #0E7C66; } .ag-t-visite { --ag-c: #7A4BC2; }
.ag-t-reunion { --ag-c: #34495E; } .ag-t-livraison { --ag-c: #B76E00; } .ag-t-autre { --ag-c: #6B7280; }
.ag-t-tache { --ag-c: #C2410C; } .ag-t-facture { --ag-c: #9A7B1F; }
.ag-more { font-size: 11.5px; color: var(--text-secondary); padding-left: 6px; text-decoration: none; }
.ag-more:hover { color: var(--primary); }
.ag-list { display: none; list-style: none; margin: 0; padding: 0; }
.ag-list li { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border-subtle, #EFEFEF); }
.ag-list li.is-today .ag-list-date strong { color: var(--primary); }
.ag-list-date { display: flex; flex-direction: column; align-items: center; }
.ag-list-date span { font-size: 11px; text-transform: uppercase; color: var(--text-subdued); letter-spacing: .4px; }
.ag-list-date strong { font-size: 20px; line-height: 1.1; }
.ag-list-items { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ag-list-items .ag-chip { font-size: 13.5px; padding: 6px 8px; }
.ag-list-empty { display: block !important; color: var(--text-subdued); text-align: center; }
.ag-upcoming { display: flex; flex-direction: column; gap: 4px; }
.ag-upcoming .ag-chip { font-size: 13px; padding: 5px 8px; }
.ag-up-day { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-subdued); margin: 10px 0 2px; font-weight: 600; }
.ag-up-day:first-child { margin-top: 0; }
.ag-up-meta { font-size: 11.5px; color: var(--text-subdued); padding-left: 9px; margin-top: -2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-empty, .ag-help, .ag-hint { font-size: 13px; color: var(--text-secondary); margin: 0; }
.ag-hint { font-size: 12px; color: var(--text-subdued); margin-top: 10px; }
.ag-help { margin-bottom: 14px; }
.ag-ical { display: flex; gap: 8px; }
.ag-ical input { font-family: var(--font-mono, ui-monospace, monospace); font-size: 12px; }
.ag-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.ag-time[hidden] { display: none; }
.ag-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; margin: -4px 0 12px; cursor: pointer; }
.ag-links { font-size: 13px; margin: 0; }
.ag-modal-foot { display: flex; align-items: center; gap: 8px; }
.ag-spacer { flex: 1; }
@media (max-width: 1100px) { .ag-layout { grid-template-columns: 1fr; } .ag-legend { display: none; } }
@media (max-width: 720px) {
  .ag-grid { display: none; }
  .ag-list { display: block; }
  .ag-form-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .ag-chip { transition: none; } }

/* ── Sélecteur de langue (menu utilisateur) ─────────────────── */
.dropdown-lang { display: flex; align-items: center; gap: 6px; padding: 8px 14px; }
.dropdown-lang-label { font-size: 12px; color: var(--text-subdued); margin-inline-end: auto; }
.dropdown-lang-btn { border: 1px solid var(--border-default); background: transparent; color: var(--text-secondary); border-radius: 99px; padding: 3px 10px; font: inherit; font-size: 12.5px; cursor: pointer; }
.dropdown-lang-btn:hover, .dropdown-lang-btn:focus-visible { border-color: var(--primary); color: var(--primary); }
.dropdown-lang-btn.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Un bouton masqué par l'attribut hidden reste masqué */
.btn[hidden], [hidden].btn { display: none !important; }

/* Wafi 3.4 : bandeau de l'offre de lancement, version */
.offer-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 18px; padding: 9px 14px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-surface, #fff); font-size: 13px; color: var(--text-secondary, #33405A); }
.offer-strip strong { color: var(--text-primary, #0C1A33); font-weight: 650; }
.offer-strip-dot { width: 7px; height: 7px; border-radius: 50%; background: #1552A3; flex: none; }
.offer-strip-text { flex: 1 1 320px; }
.offer-strip-timer { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-secondary, #33405A); direction: ltr; unicode-bidi: isolate; }
.offer-strip-timer b { color: #1552A3; font-weight: 700; }
.offer-strip-timer.is-over { display: none; }
.sidebar-version { margin-top: 8px; padding: 0 6px; font-size: 11px; color: var(--text-tertiary, #8A94A6); letter-spacing: .02em; }

/* Wafi 3.4 : cloche de notifications */
.notif-count { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--primary); color: #fff; font-size: 10.5px; font-weight: 600; line-height: 17px; text-align: center; font-variant-numeric: tabular-nums; border: 2px solid var(--bg-surface); box-sizing: content-box; }
.notif-count[hidden] { display: none; }
.notif-menu { width: 360px; max-width: calc(100vw - 24px); right: 0; left: auto; padding: 0; }
.notif-menu-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); font-weight: 600; font-size: 13.5px; }
.notif-link { background: none; border: 0; padding: 0; color: var(--primary); font-size: 12px; font-weight: 500; cursor: pointer; }
.notif-link[hidden] { display: none; }
.notif-menu-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border-subtle); color: var(--text-primary); text-decoration: none; }
.notif-item:hover { background: var(--bg-surface-hover); }
.notif-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 6px; flex: none; background: transparent; }
.notif-item.is-unread .notif-dot { background: var(--primary); }
.notif-body { display: grid; gap: 2px; min-width: 0; font-size: 12.5px; }
.notif-body strong { font-weight: 600; font-size: 13px; }
.notif-item:not(.is-unread) .notif-body strong { font-weight: 500; color: var(--text-secondary); }
.notif-body span { color: var(--text-secondary); line-height: 1.4; overflow-wrap: anywhere; }
.notif-body time { color: var(--text-tertiary, #8A94A6); font-size: 11px; font-variant-numeric: tabular-nums; }
.notif-empty { margin: 0; padding: 22px 14px; text-align: center; color: var(--text-secondary); font-size: 13px; }
.notif-menu-foot { display: block; padding: 10px 14px; text-align: center; font-size: 12.5px; font-weight: 500; color: var(--primary); text-decoration: none; }
.notif-menu-foot:hover { background: var(--bg-surface-hover); }
html[dir="rtl"] .notif-count { right: auto; left: 2px; }
html[dir="rtl"] .notif-menu { left: 0; right: auto; }
/* Page « Toutes les notifications » */
.notif-page-list { border-top: 1px solid var(--border-subtle); }
.notif-page-list .notif-item { padding: 12px 4px; }
.notif-filter { display: inline-flex; gap: 4px; }
