/* ============================================================
   CYBERENTA CRM — Module Styles
   ============================================================ */

/* ── Invoice / Quote Preview ─────────────────────────────────── */
.invoice-preview {
    background: white;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-10);
    max-width: 800px;
    margin: 0 auto;
    box-shadow: var(--shadow-md);
}

.invoice-preview .invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-10);
    padding-bottom: var(--space-6);
    border-bottom: 2px solid var(--text-primary);
}

.invoice-preview .company-info h2 {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    letter-spacing: -0.03em;
    margin-bottom: var(--space-2);
}

.invoice-preview .company-info p {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

.invoice-preview .invoice-meta {
    text-align: right;
}

.invoice-preview .invoice-meta h3 {
    font-size: var(--text-xl);
    color: var(--accent);
    margin-bottom: var(--space-3);
}

.invoice-preview .invoice-meta p {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 2px 0;
}

.invoice-preview .invoice-meta .badge {
    margin-top: var(--space-2);
}

.invoice-preview .parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-8);
    margin-bottom: var(--space-8);
}

.invoice-preview .party h4 {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    margin-bottom: var(--space-2);
}

.invoice-preview .party p {
    font-size: var(--text-sm);
    color: var(--text-primary);
    margin: 2px 0;
    line-height: 1.6;
}

.invoice-preview .party .client-name {
    font-weight: var(--font-semibold);
    font-size: var(--text-base);
    color: var(--text-primary);
}

.invoice-preview .items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--space-8);
}

.invoice-preview .items-table thead {
    background: var(--bg-secondary);
}

.invoice-preview .items-table th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}

.invoice-preview .items-table th:last-child,
.invoice-preview .items-table td:last-child {
    text-align: right;
}

.invoice-preview .items-table td {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
}

.invoice-preview .totals {
    display: flex;
    justify-content: flex-end;
    margin-bottom: var(--space-8);
}

.invoice-preview .totals-table {
    width: 280px;
}

.invoice-preview .totals-table .total-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-2) 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.invoice-preview .totals-table .total-row.grand-total {
    border-top: 2px solid var(--text-primary);
    margin-top: var(--space-2);
    padding-top: var(--space-3);
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    color: var(--text-primary);
}

.invoice-preview .payment-info {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-5);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.invoice-preview .payment-info h4 {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

/* ── Form Layout ─────────────────────────────────────────────── */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-4);
}

@media (max-width: 768px) {
    .form-row, .form-row-3 {
        grid-template-columns: 1fr;
    }
}

/* ── Line Items Editor ───────────────────────────────────────── */
.line-items {
    margin-bottom: var(--space-6);
}

.line-items-header {
    display: grid;
    grid-template-columns: 3fr 0.8fr 1fr 0.8fr 1fr 40px;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-light);
    margin-bottom: var(--space-2);
}

.line-item-row {
    display: grid;
    grid-template-columns: 3fr 0.8fr 1fr 0.8fr 1fr 40px;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-2) 0;
    animation: fadeInUp 0.3s ease both;
}

.line-item-row .input {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
}

.line-item-row .line-total {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    text-align: right;
    padding-right: var(--space-3);
    color: var(--text-primary);
}

.line-item-row .btn-remove-line {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.line-item-row .btn-remove-line:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

@media (max-width: 768px) {
    .line-items-header {
        display: none;
    }
    .line-item-row {
        grid-template-columns: 1fr;
        gap: var(--space-2);
        padding: var(--space-3);
        background: var(--bg-secondary);
        border-radius: var(--radius-md);
        margin-bottom: var(--space-2);
    }
}

/* ── Totals Summary ──────────────────────────────────────────── */
.totals-summary {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-top: var(--space-4);
    width: 300px;
    margin-left: auto;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-5);
}

.total-line {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: var(--space-2) 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.total-line.grand {
    border-top: 2px solid var(--border);
    margin-top: var(--space-2);
    padding-top: var(--space-3);
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    color: var(--text-primary);
}

.totals-summary-box {
    width: 280px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-5);
}

.totals-summary-box .summary-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-2) 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.totals-summary-box .summary-row.total {
    border-top: 2px solid var(--border);
    margin-top: var(--space-2);
    padding-top: var(--space-3);
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    color: var(--text-primary);
}

/* ── Signature Canvas ────────────────────────────────────────── */
.signature-area {
    margin: var(--space-6) 0;
}

.signature-canvas-wrapper {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    background: white;
    margin-bottom: var(--space-4);
    overflow: hidden;
}

.signature-canvas-wrapper canvas {
    width: 100%;
    height: 200px;
    cursor: crosshair;
    display: block;
    touch-action: none;
}

.signature-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-tertiary);
    font-size: var(--text-sm);
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.signature-canvas-wrapper.has-signature .signature-placeholder {
    opacity: 0;
}

.signature-actions {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

/* ── Chart Containers ────────────────────────────────────────── */
.chart-container {
    position: relative;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
}

.chart-container h3 {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-4);
}

.chart-container canvas {
    width: 100%;
    display: block;
}

.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-6);
    margin-bottom: var(--space-6);
}

@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Client Detail Tabs ──────────────────────────────────────── */
.client-tabs {
    margin-top: var(--space-6);
}

.client-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
}

@media (max-width: 768px) {
    .client-info-grid {
        grid-template-columns: 1fr;
    }
}

.info-field {
    margin-bottom: var(--space-4);
}

.info-field label {
    display: block;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: var(--space-1);
}

.info-field .info-value {
    font-size: var(--text-sm);
    color: var(--text-primary);
    line-height: 1.5;
}

/* ── Activity List ───────────────────────────────────────────── */
.activity-list {
    list-style: none;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border-light);
}

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

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-icon.invoice {
    background: var(--accent-light);
    color: var(--accent);
}

.activity-icon.quote {
    background: rgba(94, 92, 230, 0.08);
    color: #5e5ce6;
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-content .activity-title {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
}

.activity-content .activity-sub {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.activity-amount {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    white-space: nowrap;
}

/* ── Recurring Payments ──────────────────────────────────────── */
.recurring-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    transition: all var(--transition-fast);
}

.recurring-item:hover {
    background: var(--surface-hover);
}

.recurring-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.recurring-info .recurring-desc {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
}

.recurring-info .recurring-client {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.recurring-meta {
    text-align: right;
}

.recurring-meta .recurring-amount {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

.recurring-meta .recurring-next {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

/* ── Status Actions ──────────────────────────────────────────── */
.status-actions {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-top: var(--space-4);
}

/* ── Public Signature Page ───────────────────────────────────── */
.sign-page {
    min-height: 100vh;
    background: var(--bg-secondary);
    padding: var(--space-8) var(--space-6);
}

.sign-container {
    max-width: 800px;
    margin: 0 auto;
}

.sign-header {
    text-align: center;
    margin-bottom: var(--space-8);
}

.sign-header h1 {
    font-size: var(--text-2xl);
    margin-bottom: var(--space-2);
}

.sign-header p {
    font-size: var(--text-base);
}

.sign-decision {
    display: flex;
    gap: var(--space-4);
    justify-content: center;
    margin-top: var(--space-6);
}

.sign-result {
    text-align: center;
    padding: var(--space-10) var(--space-6);
}

.sign-result .result-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-4);
}

.sign-result .result-icon.success {
    background: var(--success-bg);
    color: var(--success);
}

.sign-result .result-icon.refused {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ── Clickable Table Rows ────────────────────────────────────── */
.table-modern.clickable tbody tr {
    cursor: pointer;
}

/* ── Filter Tabs ─────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}

.filter-bar .search-bar {
    flex: 1;
    min-width: 200px;
}

/* ── Dashboard Grid ──────────────────────────────────────────── */
.dashboard-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
}

@media (max-width: 1024px) {
    .dashboard-bottom {
        grid-template-columns: 1fr;
    }
}

/* ── Quick Actions ───────────────────────────────────────────── */
.quick-actions {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

/* ── Signature Link ──────────────────────────────────────────── */
.signature-link-box {
    background: var(--accent-light);
    border: 1px solid rgba(0, 113, 227, 0.15);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-5);
    margin: var(--space-4) 0;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.signature-link-box .link-text {
    flex: 1;
    font-size: var(--text-sm);
    color: var(--accent);
    word-break: break-all;
    font-family: monospace;
}

/* ── Print Styles ────────────────────────────────────────────── */
@media print {
    .invoice-preview {
        box-shadow: none;
        border: none;
        padding: 0;
    }

    .status-actions,
    .no-print {
        display: none !important;
    }
}

/* ── Back Link ───────────────────────────────────────────────── */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: var(--space-4);
    transition: color var(--transition-fast);
}

.back-link:hover {
    color: var(--accent);
}

/* ── Mobile sidebar toggle ───────────────────────────────────── */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    z-index: 250;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

/* ── Hamburger + overlay (mobile, créés par crm.js) ──────────── */
.crm-hamburger {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 320;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--border-light);
    background: var(--surface, #fff);
    color: var(--text-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}
.crm-hamburger svg { width: 22px; height: 22px; }

.crm-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 290;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.crm-mobile-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }

    /* Sidebar = tiroir coulissant (et non plus display:none) */
    .sidebar {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 300;
        box-shadow: var(--shadow-lg);
        overflow-y: auto;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding-top: 64px;   /* place pour le hamburger */
    }

    .crm-hamburger { display: flex; }
    .crm-mobile-overlay { display: block; }

    .invoice-preview .parties {
        grid-template-columns: 1fr;
    }
}

/* ── Signature (devis signé) ─────────────────────────────────── */
.signature-block {
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-light);
}
.signature-block h4 {
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: var(--space-2);
}
.sig-img {
    max-width: 280px;
    max-height: 120px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: #fff;
    padding: 4px;
}

/* ── Impression A4 (facture / devis → PDF) ───────────────────────
   @page margin:0 → supprime les en-têtes/pieds injectés par le navigateur
   (titre + URL dans les coins). Les marges du document sont gérées par le
   padding de .invoice-preview. On force .card en position:static pour que le
   document s'ancre en haut de la PAGE (et non sous une bannière masquée). */
@media print {
    @page { size: A4; margin: 0; }
    html, body { background: #fff !important; }
    body * { visibility: hidden; }
    .invoice-preview, .invoice-preview * { visibility: visible; }
    .card { position: static !important; box-shadow: none !important; border: none !important; }
    .invoice-preview {
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        padding: 14mm !important;   /* marges du document (car @page = 0) */
        box-shadow: none !important;
        border: none !important;
    }
    .crm-hamburger, .crm-mobile-overlay, .no-print { display: none !important; }
}

/* ============================================================
   Thème sombre (bascule via html[data-theme="dark"])
   ============================================================ */
html[data-theme="dark"] {
  --bg-primary: #1c1c1e;
  --bg-secondary: #0b0b0c;
  --bg-tertiary: #161618;
  --bg-elevated: #2c2c2e;
  --surface: #1c1c1e;
  --surface-hover: #2c2c2e;
  --surface-active: #3a3a3c;
  --border: #3a3a3c;
  --border-light: #2c2c2e;
  --text-primary: #f5f5f7;
  --text-secondary: #aeaeb2;
  --text-tertiary: #8e8e93;
  --text-inverse: #1d1d1f;
  --success-bg: rgba(52, 199, 89, 0.16);
  --warning-bg: rgba(255, 159, 10, 0.16);
  --danger-bg: rgba(255, 59, 48, 0.16);
  --info-bg: rgba(90, 200, 250, 0.16);
  --shadow-xs: 0 1px 2px rgba(0,0,0,.5);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.5);
  --shadow-md: 0 4px 6px rgba(0,0,0,.5);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.6);
  --shadow-xl: 0 20px 40px rgba(0,0,0,.7);
  color-scheme: dark;
}
html[data-theme="dark"] body { background: var(--bg-secondary); color: var(--text-primary); }

/* Bouton flottant de bascule de thème */
.theme-toggle {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 1200;
  width: 44px;
  height: 44px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast);
}
.theme-toggle:hover { transform: scale(1.06); background: var(--surface-hover); }
.theme-toggle svg { width: 20px; height: 20px; }
@media print { .theme-toggle { display: none !important; } }

/* ============================================================
   Histogramme CA mensuel (CSS pur — robuste, responsive, theme-aware)
   ============================================================ */
.bar-chart {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 250px;
  padding: 8px 4px 0;
}
.bar-chart-note {
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  pointer-events: none;
}
.bar-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}
.bar-val {
  font-size: 11px;
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  margin-bottom: 4px;
  height: 14px;
  white-space: nowrap;
}
.bar-track {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.bar-fill {
  width: 66%;
  max-width: 46px;
  background: var(--accent, #2f6df6); /* repli si linear-gradient/color-mix non supporté */
  background: linear-gradient(180deg, var(--accent, #2f6df6), color-mix(in srgb, var(--accent, #2f6df6) 65%, transparent));
  border-radius: 6px 6px 0 0;
  min-height: 2px;
  transition: height .45s cubic-bezier(.22,.61,.36,1);
}
.bar-lbl {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 6px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.bar-chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}

/* Contrôles du graphe de CA (granularité + comparatif N-1) */
.revenue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.revenue-controls { display: flex; align-items: center; gap: 10px; }
.select-sm {
  font: inherit;
  font-size: 13px;
  padding: 5px 28px 5px 10px;
  border: 1px solid var(--border, #d2d2d7);
  border-radius: var(--radius-sm, 8px);
  background-color: var(--surface, #fff);
  color: var(--text-primary, #1d1d1f);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.revenue-compare {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-secondary, #6e6e73);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
/* Checkbox personnalisée (cohérente avec l'accent du thème) */
.revenue-compare input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1.5px solid var(--border, #d2d2d7);
  border-radius: 5px;
  background: var(--surface, #fff);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background .15s, border-color .15s;
}
.revenue-compare input[type="checkbox"]:hover { border-color: var(--accent, #2f6df6); }
.revenue-compare input[type="checkbox"]:checked {
  background: var(--accent, #2f6df6);
  border-color: var(--accent, #2f6df6);
}
.revenue-compare input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1.5px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.revenue-compare input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent, #2f6df6);
  outline-offset: 2px;
}
.revenue-compare input[type="checkbox"]:disabled { opacity: .4; cursor: not-allowed; }
.revenue-compare:has(input:disabled) { opacity: .5; cursor: not-allowed; }

.revenue-total {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 22px;
  margin-bottom: 8px;
}
.rev-total-main { font-size: 18px; font-weight: var(--font-bold, 700); color: var(--text-primary); }
.rev-total-year { font-size: 13px; color: var(--text-tertiary); }
.rev-legend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-tertiary);
}
.rev-dot { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.rev-dot-cur  { background: var(--accent, #2f6df6); margin-left: 8px; }
.rev-dot-prev { background: var(--text-tertiary, #9aa0a6); opacity: .55; margin-left: 12px; }
.rev-delta {
  font-size: 12px;
  font-weight: var(--font-semibold, 600);
  padding: 1px 8px;
  border-radius: 999px;
}
.rev-up   { color: var(--success, #34c759); background: var(--success-bg, rgba(52,199,89,.14)); }
.rev-down { color: var(--danger, #ff3b30);  background: var(--danger-bg, rgba(255,59,48,.14)); }

/* Barres groupées (mode comparatif N-1) */
.bar-group {
  flex: 1;                    /* occupe la hauteur dispo (comme .bar-track en mode simple) */
  width: 100%;
  display: flex;
  align-items: stretch;       /* les pistes s'étirent en hauteur → height:% des barres valide */
  justify-content: center;
  gap: 3px;
}
.bar-group .bar-track { flex: 1 1 0; width: auto; max-width: 24px; }
.bar-fill.bar-prev { background: var(--text-tertiary, #9aa0a6); opacity: .5; }

/* Listes du dashboard (activité récente / récurrents) : hauteur bornée + scroll
   interne → l'écran du dashboard reste fixe quelle que soit la quantité. */
.dash-list-scroll {
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.dash-list-scroll::-webkit-scrollbar { width: 8px; }
.dash-list-scroll::-webkit-scrollbar-thumb { background: var(--border, #d2d2d7); border-radius: 4px; }
.dash-list-scroll::-webkit-scrollbar-track { background: transparent; }

/* ── Demandes de contact : mise en avant claire des non-lues ───── */
.demande-card.unread {
  border-left: 4px solid var(--accent, #2f6df6);
  background: rgba(47, 109, 246, .06);                               /* repli */
  background: color-mix(in srgb, var(--accent, #2f6df6) 7%, var(--surface));
}
.demande-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent, #2f6df6);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
}
.demande-flag::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
}
.demande-count {
  background: var(--danger, #ff3b30);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

/* Logo de marque sur les documents (factures / devis) */
.doc-logo {
  max-height: 70px;
  max-width: 220px;
  object-fit: contain;
  display: block;
  margin-bottom: 10px;
}

/* ── Calendrier partagé ──────────────────────────────────────── */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-filters { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.cal-filter-mine { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); cursor: pointer; white-space: nowrap; }
.cal-color-filter { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.cal-chip {
  width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: .35; transition: opacity .15s, transform .1s;
}
.cal-chip.on { opacity: 1; }
.cal-chip:hover { transform: translateY(-1px); }
.cal-chip .dot { width: 12px; height: 12px; border-radius: 3px; }

.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: var(--bg-tertiary); border-bottom: 1px solid var(--border);
}
.cal-weekdays > div { padding: 8px; text-align: center; font-size: 12px; font-weight: var(--font-semibold); color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .03em; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell {
  min-height: 108px; border-right: 1px solid var(--border-light); border-bottom: 1px solid var(--border-light);
  padding: 4px 6px; cursor: pointer; position: relative; overflow: hidden; transition: background .12s;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell:hover { background: var(--surface-hover); }
.cal-cell.other { background: var(--bg-tertiary); }
.cal-cell.other .cal-daynum { color: var(--text-tertiary); opacity: .6; }
.cal-cell.today { background: color-mix(in srgb, var(--accent, #2f6df6) 8%, var(--surface)); }
.cal-cell.today .cal-daynum {
  background: var(--accent, #2f6df6); color: #fff; border-radius: 50%;
  width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center;
}
.cal-daynum { font-size: 13px; font-weight: var(--font-medium); color: var(--text-secondary); }
.cal-events { margin-top: 4px; display: flex; flex-direction: column; gap: 3px; }
.cal-event {
  font-size: 11.5px; line-height: 1.3; padding: 2px 6px; border-radius: 5px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text-primary);
  background: rgba(47,109,246,.12);                                   /* repli */
  background: color-mix(in srgb, var(--evc, #2f6df6) 16%, var(--surface));
  border-left: 3px solid var(--evc, #2f6df6);
}
.cal-event:hover { filter: brightness(0.97); }
.cal-event.declined { opacity: .5; text-decoration: line-through; }
.cal-event-dot { display: none; }

/* Modale événement */
.ev-colors { display: flex; gap: 8px; flex-wrap: wrap; }
.ev-color { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; transition: transform .1s; }
.ev-color:hover { transform: scale(1.08); }
.ev-color.sel { border-color: var(--text-primary); box-shadow: 0 0 0 2px var(--surface) inset; }
.ev-attendees { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.ev-att { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; padding: 4px 0; border-bottom: 1px solid var(--border-light); }
.ev-respond { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-light); }

@media (max-width: 640px) {
  .cal-cell { min-height: 74px; }
  .cal-event { font-size: 10.5px; }
}

/* ── Dialogue de confirmation (remplace window.confirm) ────────── */
.confirm-modal { max-width: 440px; }
.confirm-body {
  display: flex;
  gap: 16px;
  padding: 24px 24px 8px;
}
.confirm-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--info-bg, rgba(90,200,250,.16));
  color: var(--info, #5ac8fa);
}
.confirm-icon i { width: 22px; height: 22px; }
.confirm-icon.is-danger { background: var(--danger-bg, rgba(255,59,48,.14)); color: var(--danger, #ff3b30); }
.confirm-text h3 { font-size: 16px; margin: 2px 0 6px; color: var(--text-primary); }
.confirm-text p { font-size: 14px; line-height: 1.5; margin: 0; color: var(--text-secondary); }

/* ============================================================
   Document facture / devis : TOUJOURS en clair (impression-fidèle),
   quel que soit le thème de l'application. On ré-ancre les tokens
   de couleur sur la palette claire au niveau du document : tous ses
   descendants héritent donc des couleurs claires même en mode sombre.
   ============================================================ */
.invoice-preview {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-tertiary: #f5f5f7;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-hover: #f5f5f7;
  --surface-active: #ececec;
  --border: #d2d2d7;
  --border-light: #e8e8ed;
  --text-primary: #1d1d1f;
  --text-secondary: #424245;
  --text-tertiary: #6e6e73;
  --text-inverse: #ffffff;
  --success-bg: rgba(52, 199, 89, 0.12);
  --warning-bg: rgba(255, 159, 10, 0.12);
  --danger-bg: rgba(255, 59, 48, 0.12);
  --info-bg: rgba(90, 200, 250, 0.12);
  background: #ffffff;
  color: #1d1d1f;
  color-scheme: light;
}
/* Cadre qui enveloppe l'aperçu : neutre/clair en mode sombre aussi. */
#invoice-preview.card,
#quote-preview.card {
  background: #ffffff;
  border-color: #e8e8ed;
}
