/* ==========================================================================
   FLEXYLEAD TRÉSORERIE PWA - V2 DESIGN 2026
   Inspiré iOS 26 Liquid Glass + Apple Motion Design
   ========================================================================== */

/* ---------- CSS Variables ---------- */
:root {
    /* Light Mode (Default) */
    --bg-base: #F8F9FB;
    --bg-elevated: #FFFFFF;
    --bg-glass: rgba(255, 255, 255, 0.72);
    --bg-glass-strong: rgba(255, 255, 255, 0.88);
    
    /* Surfaces */
    --surface-1: #FFFFFF;
    --surface-2: #F5F6F8;
    --surface-3: #EBEDF0;
    
    /* Borders */
    --border-subtle: rgba(0, 0, 0, 0.04);
    --border-default: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.12);
    
    /* Text */
    --text-primary: #1A1D21;
    --text-secondary: #5C6370;
    --text-muted: #8E95A2;
    --text-inverse: #FFFFFF;
    
    /* Brand - Flexylead Teal/Cyan */
    --brand-primary: #3A9DB5;
    --brand-primary-light: #5FBDCC;
    --brand-gradient: linear-gradient(165deg, #6BCAD8 0%, #4AAFBF 40%, #2B8A9E 100%);
    
    /* Semantic Colors */
    --color-success: #10B981;
    --color-success-bg: rgba(16, 185, 129, 0.08);
    --color-success-text: #059669;
    
    --color-danger: #EF4444;
    --color-danger-bg: rgba(239, 68, 68, 0.08);
    --color-danger-text: #DC2626;
    
    --color-warning: #F59E0B;
    --color-warning-bg: rgba(245, 158, 11, 0.08);
    --color-warning-text: #D97706;
    
    --color-info: #3B82F6;
    --color-info-bg: rgba(59, 130, 246, 0.08);
    --color-info-text: #2563EB;
    
    /* Shadows - Soft & Natural */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.10);
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.06);
    
    /* Animation - Apple-style spring */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
}

/* ---------- Dark Mode (Navy Charcoal 2026) ---------- */
[data-theme="dark"] {
    --bg-base: #0F1419;
    --bg-elevated: #1A1F2E;
    --bg-glass: rgba(26, 31, 46, 0.85);
    --bg-glass-strong: rgba(30, 36, 52, 0.92);
    
    --surface-1: #1E2433;
    --surface-2: #252B3B;
    --surface-3: #2D3444;
    
    --border-subtle: rgba(255, 255, 255, 0.04);
    --border-default: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.12);
    
    --text-primary: #F0F2F5;
    --text-secondary: #9BA3B0;
    --text-muted: #6B7280;
    
    --color-success-bg: rgba(16, 185, 129, 0.12);
    --color-success-text: #34D399;
    
    --color-danger-bg: rgba(239, 68, 68, 0.12);
    --color-danger-text: #F87171;
    
    --color-warning-bg: rgba(245, 158, 11, 0.12);
    --color-warning-text: #FBBF24;
    
    --color-info-bg: rgba(59, 130, 246, 0.12);
    --color-info-text: #60A5FA;
    
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.35);
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.25);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- App Container ---------- */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ---------- Header - Liquid Glass Style ---------- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: var(--space-md);
    padding-top: max(var(--space-md), env(safe-area-inset-top));
    background: var(--bg-glass);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid var(--border-subtle);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 600px;
    margin: 0 auto;
}

.header-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.header-logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
}

.header-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* ---------- Icon Buttons ---------- */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
}

.icon-btn:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

/* Theme toggle animation */
.theme-toggle {
    position: relative;
    overflow: hidden;
}

.theme-toggle svg {
    transition: transform 0.4s var(--ease-spring), opacity 0.2s;
}

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    padding: var(--space-md);
    padding-bottom: calc(70px + env(safe-area-inset-bottom) + var(--space-md));
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

/* ---------- Last Update Badge ---------- */
.update-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    margin-bottom: var(--space-md);
    font-size: 0.6875rem;
    color: var(--text-muted);
    background: var(--surface-2);
    border-radius: var(--radius-full);
    width: fit-content;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    animation: fadeInUp 0.5s var(--ease-out-expo);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.update-badge.loading {
    color: var(--color-info-text);
}

.update-badge svg {
    width: 14px;
    height: 14px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.update-badge.loading svg {
    animation: spin 1s linear infinite;
}

/* ---------- Summary Cards - Bento Grid ---------- */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.summary-card {
    background: var(--surface-1);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    border: 2px solid transparent;
    box-shadow: var(--shadow-card);
    transition: all 0.3s var(--ease-spring);
    animation: fadeInUp 0.5s var(--ease-out-expo) backwards;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

/* Mobile: urgent-card prend toute la largeur */
.summary-card.urgent-card {
    grid-column: 1 / -1;
}

.summary-card:nth-child(1) { animation-delay: 0.05s; }
.summary-card:nth-child(2) { animation-delay: 0.1s; }
.summary-card:nth-child(3) { animation-delay: 0.15s; }
.summary-card:nth-child(4) { animation-delay: 0.2s; }

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.summary-card:active {
    transform: scale(0.98);
}

/* État actif/sélectionné */
.summary-card.active {
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-md), 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.summary-card.active::before {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--brand-primary);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Tuile urgences style spécial quand active */
.summary-card.urgent-card.active {
    border-color: var(--color-warning);
    box-shadow: var(--shadow-md), 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.summary-card.urgent-card.active::before {
    background: var(--color-warning);
}

/* Cartes cliquables */
.summary-card.clickable {
    cursor: pointer;
    position: relative;
}

.summary-card.clickable::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    border: 2px solid transparent;
    transition: border-color 0.25s var(--ease-smooth);
    pointer-events: none;
}

.summary-card.clickable:hover::after {
    border-color: var(--border-strong);
}

.summary-card.clickable.active::after {
    border-color: var(--brand-primary);
}

.summary-card.clickable.active {
    box-shadow: var(--shadow-md);
}

/* Badge de filtre actif */
.filter-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--brand-primary);
    border-radius: 50%;
    opacity: 0;
    transform: scale(0);
    transition: all 0.25s var(--ease-spring);
}

.summary-card.active .filter-badge {
    opacity: 1;
    transform: scale(1);
}

/* Indicateur cliquable */
.click-hint {
    position: absolute;
    bottom: 8px;
    right: 8px;
    font-size: 0.625rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
}

.summary-card.clickable:hover .click-hint {
    opacity: 0.7;
}

/* Full-width card for balance */
.summary-card.full-width {
    grid-column: 1 / -1;
    background: var(--brand-gradient);
    color: white;
    border: 2px solid transparent;
}

.summary-card.full-width:hover {
    filter: brightness(1.05);
    transform: translateY(-2px);
}

.summary-card.full-width.active {
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-lg), 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.summary-card.full-width.active::before {
    background: white;
}

.summary-card.full-width .summary-label {
    color: rgba(255, 255, 255, 0.85);
}

.summary-card.full-width .summary-value {
    color: white;
}

/* Filter active badge */
.filter-badge {
    display: none;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    margin-bottom: var(--space-md);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--brand-primary);
    background: var(--color-info-bg);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: var(--radius-full);
    width: fit-content;
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
    animation: fadeInUp 0.3s var(--ease-out-expo);
}

.filter-badge.visible {
    display: inline-flex;
}

.filter-badge:hover {
    background: rgba(37, 99, 235, 0.15);
}

.filter-badge svg {
    width: 14px;
    height: 14px;
}

/* Warning style filter badge */
.filter-badge.warning {
    color: var(--color-warning-text);
    background: var(--color-warning-bg);
    border-color: rgba(245, 158, 11, 0.2);
}

.filter-badge.warning:hover {
    background: rgba(245, 158, 11, 0.15);
}

.summary-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--space-xs);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.summary-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.summary-value.positive { color: var(--color-success-text); }
.summary-value.negative { color: var(--color-danger-text); }
.summary-card.full-width .summary-value.positive,
.summary-card.full-width .summary-value.negative { color: white; }

/* HT/TTC breakdown */
.summary-breakdown {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-subtle);
}

.summary-card.full-width .summary-breakdown {
    border-top-color: rgba(255, 255, 255, 0.2);
}

.breakdown-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.breakdown-label {
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    opacity: 0.7;
}

.breakdown-value {
    font-size: 0.875rem;
    font-weight: 600;
}

/* ---------- TVA Card ---------- */
.tva-card {
    background: var(--surface-1);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-card);
    animation: fadeInUp 0.5s var(--ease-out-expo) 0.25s backwards;
}

.tva-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.tva-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.tva-period {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 4px 10px;
    border-radius: var(--radius-full);
}

.tva-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-sm);
}

.tva-item {
    text-align: center;
    padding: var(--space-sm);
    background: var(--surface-2);
    border-radius: var(--radius-md);
}

.tva-item-label {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.tva-item-value {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.tva-item-value.collectee { color: var(--color-success-text); }
.tva-item-value.deductible { color: var(--color-danger-text); }
.tva-item-value.solde-positive { color: var(--color-danger-text); }
.tva-item-value.solde-negative { color: var(--color-success-text); }

/* ---------- Search & Filters ---------- */
.list-controls {
    margin-bottom: var(--space-md);
    animation: fadeInUp 0.4s var(--ease-out-expo) 0.25s backwards;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(58, 157, 181, 0.15);
}

.search-bar svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.9375rem;
    color: var(--text-primary);
    outline: none;
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: var(--surface-2);
    border-radius: var(--radius-full);
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.search-clear:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

.filter-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.filter-chips {
    display: flex;
    gap: 6px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 2px 0;
}

.filter-chips::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s var(--ease-spring);
    white-space: nowrap;
}

.filter-chip:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

.filter-chip.active {
    background: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
}

.filter-chip.has-results::after {
    content: attr(data-count);
    margin-left: 4px;
    font-size: 0.6875rem;
    opacity: 0.8;
}

.sort-dropdown {
    flex-shrink: 0;
}

.sort-dropdown select {
    padding: 6px 28px 6px 10px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%235C6370' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: all 0.2s;
}

.sort-dropdown select:hover {
    background-color: var(--surface-3);
}

.sort-dropdown select:focus {
    outline: none;
    border-color: var(--brand-primary);
}

/* ---------- Tabs - Segmented Control ---------- */
.tabs-container {
    margin-bottom: var(--space-md);
    animation: fadeInUp 0.5s var(--ease-out-expo) 0.3s backwards;
}

.tabs {
    display: flex;
    background: var(--surface-2);
    border-radius: var(--radius-lg);
    padding: 4px;
    position: relative;
}

.tab-indicator {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc(50% - 4px);
    background: var(--surface-1);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: transform 0.35s var(--ease-spring);
}

.tabs[data-active="fournisseurs"] .tab-indicator {
    transform: translateX(100%);
}

.tab-btn {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    border: none;
    background: transparent;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    z-index: 1;
    transition: color 0.25s var(--ease-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
}

.tab-btn.active {
    color: var(--text-primary);
}

.tab-btn:not(.active):hover {
    color: var(--text-secondary);
}

.tab-count {
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--brand-primary);
    color: white;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
}

.tab-btn:not(.active) .tab-count {
    background: var(--text-muted);
}

/* ---------- Invoice List ---------- */
.invoice-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
    padding: 0 var(--space-xs);
}

.invoice-list-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.active-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--brand-primary);
    color: white;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
    animation: fadeInUp 0.3s var(--ease-out-expo);
}

.active-filter-tag:hover {
    background: var(--brand-primary-light);
}

.active-filter-tag svg {
    width: 12px;
    height: 12px;
}

.invoice-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.list-empty {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-muted);
}

.list-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

/* ---------- Invoice Card - Compact & Clear ---------- */
.invoice-card {
    background: var(--surface-1);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-xs);
    transition: all 0.25s var(--ease-smooth);
    animation: fadeInUp 0.4s var(--ease-out-expo) backwards;
}

.invoice-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--border-default);
}

.invoice-card:active {
    transform: scale(0.99);
}

/* Staggered animation */
.invoice-card:nth-child(1) { animation-delay: 0.02s; }
.invoice-card:nth-child(2) { animation-delay: 0.04s; }
.invoice-card:nth-child(3) { animation-delay: 0.06s; }
.invoice-card:nth-child(4) { animation-delay: 0.08s; }
.invoice-card:nth-child(5) { animation-delay: 0.1s; }
.invoice-card:nth-child(n+6) { animation-delay: 0.12s; }

/* Card Header */
.invoice-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.invoice-info {
    flex: 1;
    min-width: 0;
}

.invoice-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.invoice-number {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* Amount display */
.invoice-amount {
    text-align: right;
    flex-shrink: 0;
}

.amount-ttc {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.amount-ttc.positive { color: var(--color-success-text); }
.amount-ttc.negative { color: var(--color-danger-text); }

.amount-ht {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Card Footer */
.invoice-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-subtle);
}

.invoice-dates {
    display: flex;
    gap: var(--space-md);
}

.date-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.date-label {
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.date-value {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    transition: transform 0.2s var(--ease-spring);
}

.status-badge:active {
    transform: scale(0.95);
}

.status-badge svg {
    width: 12px;
    height: 12px;
}

.status-badge.paid {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.status-badge.overdue {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
}

.status-badge.urgent {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
}

.status-badge.pending {
    background: var(--color-info-bg);
    color: var(--color-info-text);
}

/* ---------- Bottom Navigation - Liquid Glass ---------- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-sm) var(--space-md);
    padding-bottom: max(var(--space-sm), env(safe-area-inset-bottom));
    background: var(--bg-glass-strong);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-top: 1px solid var(--border-subtle);
    z-index: 100;
}

.nav-content {
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
    max-width: 400px;
    margin: 0 auto;
}

.nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    border: none;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
}

.nav-btn:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

.nav-btn:active {
    transform: scale(0.96);
}

.nav-btn.primary {
    background: var(--brand-gradient);
    color: white;
}

.nav-btn.primary:hover {
    filter: brightness(1.05);
}

.nav-btn svg {
    width: 18px;
    height: 18px;
}

/* ---------- Animations ---------- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes glow {
    0%, 100% { 
        box-shadow: 0 4px 20px rgba(59, 157, 181, 0.25);
    }
    50% { 
        box-shadow: 0 4px 30px rgba(59, 157, 181, 0.4);
    }
}

@keyframes countPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Staggered animation delays */
.summary-card:nth-child(1) { animation-delay: 0s; }
.summary-card:nth-child(2) { animation-delay: 0.05s; }
.summary-card:nth-child(3) { animation-delay: 0.1s; }
.summary-card:nth-child(4) { animation-delay: 0.15s; }

.invoice-card { 
    animation: fadeInUp 0.4s var(--ease-spring) backwards;
}
.invoice-card:nth-child(1) { animation-delay: 0s; }
.invoice-card:nth-child(2) { animation-delay: 0.03s; }
.invoice-card:nth-child(3) { animation-delay: 0.04s; }
.invoice-card:nth-child(4) { animation-delay: 0.05s; }
.invoice-card:nth-child(5) { animation-delay: 0.06s; }
.invoice-card:nth-child(n+6) { animation-delay: 0.07s; }

/* Glow effect for highlight card */
.summary-card.highlight {
    animation: scaleIn 0.5s var(--ease-spring), glow 3s ease-in-out infinite 0.5s;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--surface-2) 25%,
        var(--surface-3) 50%,
        var(--surface-2) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* ---------- Error State ---------- */
.error-state {
    text-align: center;
    padding: var(--space-xl);
    color: var(--color-danger-text);
    animation: fadeIn 0.3s var(--ease-smooth);
}

.error-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-md);
}

.error-state p {
    margin-bottom: var(--space-md);
}

/* ---------- Utilities ---------- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 380px) {
    .summary-value {
        font-size: 1.25rem;
    }
    
    .invoice-name {
        font-size: 0.875rem;
    }
    
    .amount-ttc {
        font-size: 1rem;
    }
}

/* ---------- Tablette (768px+) ---------- */
@media (min-width: 768px) {
    .main-content {
        max-width: 680px;
        margin: 0 auto;
        padding: var(--space-lg) var(--space-xl);
    }
    
    .header {
        padding: var(--space-sm) var(--space-xl);
    }
    
    .header-content {
        max-width: 680px;
    }
    
    .header-title {
        gap: var(--space-md);
    }
    
    .header-logo {
        width: 32px;
        height: 32px;
    }
    
    .header-title h1 {
        font-size: 1.125rem;
    }
    
    .icon-btn {
        width: 36px;
        height: 36px;
    }
    
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-sm);
    }
    
    .summary-card.full-width {
        grid-column: span 2;
    }
    
    /* Tablette: urgent-card prend toute la largeur */
    .summary-card.urgent-card {
        grid-column: 1 / -1;
    }
    
    .summary-card {
        padding: var(--space-md);
    }
    
    .summary-value {
        font-size: 1.5rem;
    }
    
    .highlight-value {
        font-size: 2rem;
    }
    
    .tva-card {
        max-width: 500px;
        margin: 0 auto var(--space-md);
    }
    
    .tva-grid {
        gap: var(--space-md);
    }
    
    /* Search & Filters - centré et compact */
    .list-controls {
        max-width: 450px;
        margin: 0 auto var(--space-md);
    }
    
    .search-bar {
        max-width: 240px;
        margin: 0 auto var(--space-sm);
    }
    
    .filter-row {
        justify-content: center;
        gap: var(--space-sm);
        flex-wrap: nowrap;
    }
    
    .filter-chips {
        flex: 0 1 auto;
        justify-content: center;
    }
    
    /* Masquer les tabs sur tablette - on voit les 2 listes */
    .tabs-container {
        display: none !important;
    }
    
    .invoices-section {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--space-md);
    }
    
    .invoices-section .invoice-list {
        display: flex !important;
        flex-direction: column;
        max-height: 450px;
        overflow-y: auto;
        background: var(--surface-1);
        border-radius: var(--radius-lg);
        padding: 0;
        box-shadow: var(--shadow-sm);
    }
    
    /* Header de liste pour tablette - Glass effect */
    .invoice-list::before {
        content: attr(data-title);
        display: block;
        font-size: 0.6875rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--text-secondary);
        padding: var(--space-sm) var(--space-sm);
        border-bottom: 1px solid var(--border-subtle);
        position: sticky;
        top: 0;
        background: var(--bg-glass);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        z-index: 10;
        margin-bottom: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    
    .invoice-card {
        padding: var(--space-sm);
        margin: 0 var(--space-sm) var(--space-xs);
    }
    
    .invoice-card:first-of-type {
        margin-top: var(--space-xs);
    }
    
    .invoice-card:last-child {
        margin-bottom: var(--space-sm);
    }
    
    .invoice-name {
        font-size: 0.8125rem;
    }
    
    .amount-ttc {
        font-size: 0.9375rem;
    }
    
    .bottom-nav {
        display: none;
    }
}

/* ---------- Desktop (1024px+) ---------- */
@media (min-width: 1024px) {
    .main-content {
        max-width: 850px;
        padding: var(--space-xl) var(--space-2xl);
    }
    
    .header {
        padding: var(--space-md) var(--space-2xl);
    }
    
    .header-content {
        max-width: 850px;
        gap: var(--space-lg);
    }
    
    .header-title {
        gap: var(--space-md);
    }
    
    .header-logo {
        width: 36px;
        height: 36px;
    }
    
    .header-title h1 {
        font-size: 1.375rem;
    }
    
    .header-actions {
        gap: var(--space-sm);
    }
    
    .icon-btn {
        width: 40px;
        height: 40px;
    }
    
    .bottom-nav {
        display: none;
    }
    
    /* Grille 3 colonnes - Encaisser | Décaisser | Solde */
    .summary-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-sm);
    }
    
    .summary-card {
        padding: var(--space-md);
    }
    
    /* Sur desktop, le solde prévu ne prend qu'une colonne */
    .summary-card.full-width {
        grid-column: span 1;
    }
    
    /* La carte urgente prend toute la largeur (3 colonnes) */
    .summary-card.urgent-card {
        grid-column: 1 / -1;
    }
    
    .summary-value {
        font-size: 1.5rem;
    }
    
    .highlight-value {
        font-size: 2rem;
    }
    
    /* Search & Filters - tout centré sur une ligne */
    .list-controls {
        max-width: 100%;
        margin: 0 auto var(--space-lg);
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: var(--space-sm);
    }
    
    .search-bar {
        max-width: 260px;
        width: 260px;
    }
    
    .filter-row {
        justify-content: center;
        gap: var(--space-md);
        width: 100%;
    }
    
    .filter-chips {
        flex: 0 1 auto;
        justify-content: center;
    }
    
    .sort-dropdown {
        position: relative;
    }
    
    /* Masquer les tabs sur desktop - on voit les 2 listes */
    .tabs-container {
        display: none !important;
    }
    
    /* Listes côte à côte */
    .invoices-section {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--space-lg);
        align-items: start;
    }
    
    .invoices-section .invoice-list {
        display: flex !important;
        flex-direction: column;
        max-height: 500px;
        overflow-y: auto;
        background: var(--surface-1);
        border-radius: var(--radius-lg);
        padding: 0;
        box-shadow: var(--shadow-sm);
    }
    
    /* Header de liste pour desktop - Glass effect */
    .invoice-list::before {
        content: attr(data-title);
        display: block;
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-secondary);
        padding: var(--space-md) var(--space-md);
        border-bottom: 1px solid var(--border-subtle);
        position: sticky;
        top: 0;
        background: var(--bg-glass);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        z-index: 10;
        margin-bottom: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    
    .invoice-card {
        padding: var(--space-md);
        margin: 0 var(--space-md) var(--space-sm);
    }
    
    .invoice-card:first-of-type {
        margin-top: var(--space-sm);
    }
    
    .invoice-card:last-child {
        margin-bottom: var(--space-md);
    }
    
    .invoice-name {
        font-size: 0.875rem;
    }
    
    .amount-ttc {
        font-size: 1rem;
    }
    
    /* TVA card centrée et compacte */
    .tva-card {
        max-width: 550px;
        margin: 0 auto var(--space-lg);
    }
    
    .tva-grid {
        gap: var(--space-md);
    }
}

/* ---------- Large Desktop (1280px+) ---------- */
@media (min-width: 1280px) {
    .main-content {
        max-width: 950px;
        padding: var(--space-xl) var(--space-3xl);
    }
    
    .header {
        padding: var(--space-md) var(--space-3xl);
    }
    
    .header-content {
        max-width: 950px;
    }
    
    .summary-grid {
        gap: var(--space-md);
    }
    
    .summary-value {
        font-size: 1.625rem;
    }
    
    .highlight-value {
        font-size: 2.25rem;
    }
    
    .invoices-section {
        gap: var(--space-xl);
    }
    
    .invoice-list {
        max-height: 550px;
    }
    
    .tva-card {
        max-width: 600px;
    }
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- Print ---------- */
@media print {
    .header, .bottom-nav {
        display: none;
    }
    
    .main-content {
        padding: 0;
    }
}
