* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #667eea;
    --primary-dark: #5568d3;
    --secondary: #764ba2;
    --accent: #f093fb;
    --success: #43e97b;
    --danger: #f5576c;
    --warning: #feca57;
    --info: #48cae4;
    --dark: #2c3e50;
    --light: #f8f9fa;
    --gray: #6c757d;
    --border: #e0e0e0;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.15);
    --sidebar-width: 280px;
    --topbar-height: 70px;
    --safe-area-top: env(safe-area-inset-top, 0);
    --safe-area-bottom: env(safe-area-inset-bottom, 0);
    --safe-area-left: env(safe-area-inset-left, 0);
    --safe-area-right: env(safe-area-inset-right, 0);
}

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    min-height: calc(100vh - var(--safe-area-top) - var(--safe-area-bottom));
    color: var(--dark);
    overflow-x: hidden;
    padding-left: var(--safe-area-left);
    padding-right: var(--safe-area-right);
}

body.sidebar-open {
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
    color: white;
    z-index: 1000;
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-xl);
}

.sidebar-header {
    padding: 25px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar .logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar .logo i {
    font-size: 2rem;
    color: var(--primary);
    background: white;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.sidebar .logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.logo-accent {
    color: var(--primary);
    font-weight: 300;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 0;
}

.sidebar-menu li {
    margin: 5px 15px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.3s;
    font-weight: 500;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(5px);
}

.sidebar-menu a i {
    width: 20px;
    font-size: 1.1rem;
}

/* Sidebar overlay (mobile): shown when sidebar is open */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    min-height: calc(56px + var(--safe-area-top));
    padding: var(--safe-area-top) max(30px, var(--safe-area-right)) 0 max(30px, var(--safe-area-left));
    background: white;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--dark);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.3s;
}

.sidebar-toggle:hover {
    background: var(--light);
}

.topbar h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--dark);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 25px;
}

.notifications {
    position: relative;
    cursor: pointer;
    font-size: 1.3rem;
    color: var(--gray);
    transition: color 0.3s;
}

.notifications:hover {
    color: var(--primary);
}

.badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 8px 15px;
    border-radius: 25px;
    transition: background 0.3s;
}

.user-profile:hover {
    background: var(--light);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info span:first-child {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--gray);
}

/* Content Sections */
.content-section {
    display: none;
    padding: 30px;
    animation: fadeIn 0.3s;
}

.content-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.section-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-actions {
    display: flex;
    gap: 10px;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card {
    background: white;
    border-radius: 20px;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.kpi-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.kpi-icon {
    width: 70px;
    height: 70px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.8rem;
    flex-shrink: 0;
}

.kpi-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.kpi-label {
    font-size: 0.875rem;
    color: var(--gray);
    margin-bottom: 5px;
    font-weight: 500;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 5px;
}

.kpi-change {
    font-size: 0.75rem;
    color: var(--gray);
}

.kpi-change.positive {
    color: var(--success);
    font-weight: 600;
}

/* Charts */
.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.chart-card {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--light);
}

.chart-legend {
    display: flex;
    gap: 15px;
    font-size: 0.875rem;
}

.chart-legend span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.chart-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-controls select {
    padding: 8px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    cursor: pointer;
}

.chart-card canvas {
    position: relative;
    width: 100% !important;
    max-width: 100% !important;
    height: 350px !important;
    max-height: 400px !important;
}

/* Activity Row */
.activity-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.activity-card,
.quick-actions-card {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--light);
}

.card-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-weight: 500;
    text-decoration: underline;
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--light);
    border-radius: 12px;
    transition: transform 0.3s;
}

.activity-item:hover {
    transform: translateX(5px);
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
}

.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px;
    background: var(--light);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.action-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-3px);
}

.action-btn i {
    font-size: 1.5rem;
}

/* Accounts Grid */
.accounts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.account-card {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    overflow: hidden;
}

.account-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.account-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.account-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--dark);
}

.account-type {
    display: inline-block;
    padding: 6px 14px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 15px;
}

.account-balance {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 15px 0;
}

.account-details {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    font-size: 0.875rem;
    color: var(--gray);
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.card-item {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    padding: 30px;
    color: white;
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
    min-height: 220px;
}

.card-item::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
}

.card-item h3 {
    font-size: 1.1rem;
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
    opacity: 0.9;
}

.card-number {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: 3px;
    margin-bottom: 25px;
    position: relative;
    z-index: 1;
    font-family: 'Courier New', monospace;
}

.card-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
    position: relative;
    z-index: 1;
}

.card-info-item {
    background: rgba(255, 255, 255, 0.2);
    padding: 12px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.card-info-item .label {
    font-size: 0.75rem;
    opacity: 0.9;
    margin-bottom: 5px;
}

.card-info-item .value {
    font-size: 1rem;
    font-weight: 600;
}

.card-actions {
    margin-top: 20px;
    position: relative;
    z-index: 1;
}

/* Filters Panel */
.filters-panel {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-select,
.filter-input {
    padding: 10px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.3s;
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Transactions List */
.transactions-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.transaction-item {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 20px;
    align-items: center;
    transition: all 0.3s;
    cursor: pointer;
}

.transaction-item:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow-lg);
}

.transaction-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: white;
}

.transaction-icon.debit {
    background: linear-gradient(135deg, var(--danger), #ff6b9d);
}

.transaction-icon.credit {
    background: linear-gradient(135deg, var(--success), #38f9d7);
}

.transaction-details {
    flex: 1;
}

.transaction-details .description {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 5px;
    color: var(--dark);
}

.transaction-details .meta {
    color: var(--gray);
    font-size: 0.875rem;
}

.transaction-amount {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: right;
}

.transaction-amount.debit {
    color: var(--danger);
}

.transaction-amount.credit {
    color: var(--success);
}

.transaction-status {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.transaction-status.posted {
    background: var(--success);
    color: white;
}

.transaction-status.pending {
    background: var(--warning);
    color: var(--dark);
}

.transaction-status.disputed {
    background: var(--danger);
    color: white;
}

/* Analytics */
.analytics-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.analytics-card {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    min-height: 0;
}

.analytics-card.large {
    grid-column: span 2;
}

/* Conteneur à hauteur fixe pour chaque graphique Analytics (Chart.js s'adapte à ce parent) */
.analytics-chart-wrap {
    position: relative;
    width: 100%;
    height: 280px;
    min-height: 280px;
    max-height: 280px;
    flex-shrink: 0;
}

.analytics-chart-wrap canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-height: 280px !important;
}

.insights-panel {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--shadow-lg);
}

.insights-panel h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.insights-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.insight-item {
    padding: 20px;
    background: var(--light);
    border-radius: 12px;
    border-left: 4px solid var(--primary);
}

.insight-item h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--dark);
}

.insight-item p {
    color: var(--gray);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Settings */
.settings-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-card {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--shadow-lg);
}

.settings-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-form label {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 8px;
}

.settings-form input {
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.settings-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.settings-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.switch-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.switch-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.settings-select {
    padding: 10px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-secondary {
    background: var(--light);
    color: var(--dark);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s;
}

.modal-content.large {
    max-width: 800px;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 2px solid var(--light);
}

.modal-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 12px;
}

.close {
    font-size: 2rem;
    font-weight: 300;
    color: var(--gray);
    cursor: pointer;
    transition: color 0.3s;
    line-height: 1;
}

.close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 30px;
}

.modal-body label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
}

.modal-body input,
.modal-body select,
.modal-body textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 20px;
    transition: border-color 0.3s;
    font-family: inherit;
}

.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 12px;
    background: var(--light);
    border-radius: 8px;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 25px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    text-align: center;
    color: white;
}

.spinner-ring {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* Toast Notifications */
/* Banner when opened as file:// */
.file-protocol-banner {
    position: fixed;
    top: var(--topbar-height);
    left: var(--sidebar-width);
    right: 0;
    z-index: 2000;
    background: linear-gradient(90deg, #f5576c 0%, #f093fb 100%);
    color: white;
    padding: 12px 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
    box-shadow: var(--shadow);
}
.file-protocol-banner code {
    background: rgba(0,0,0,0.2);
    padding: 2px 6px;
    border-radius: 4px;
}
.file-protocol-banner a {
    color: #fff;
    text-decoration: underline;
}

.toast-container {
    position: fixed;
    top: 90px;
    right: 30px;
    z-index: 2500;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    border-radius: 12px;
    padding: 15px 20px;
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 300px;
    animation: slideInRight 0.3s;
    border-left: 4px solid var(--primary);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.warning {
    border-left-color: var(--warning);
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 30px;
}

.pagination button {
    padding: 10px 15px;
    border: 2px solid var(--border);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.pagination button:hover,
.pagination button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ========== Responsive – Mobile-first experience ========== */
@media (max-width: 1024px) {
    .charts-row,
    .activity-row,
    .analytics-grid {
        grid-template-columns: 1fr;
    }
    
    .analytics-card.large {
        grid-column: span 1;
    }
    
    .chart-card canvas {
        height: 280px !important;
        max-height: 320px !important;
    }
    .analytics-chart-wrap {
        height: 280px;
        min-height: 280px;
        max-height: 280px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: min(100vw - 56px, var(--sidebar-width));
        padding-left: var(--safe-area-left);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        display: block;
        pointer-events: none;
    }
    
    .sidebar.open + .sidebar-overlay {
        pointer-events: auto;
        opacity: 1;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .topbar {
        padding-left: max(16px, var(--safe-area-left));
        padding-right: max(16px, var(--safe-area-right));
    }
    
    .topbar h2 {
        font-size: 1.2rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 50vw;
    }
    
    .topbar-right .user-info,
    .topbar-right .user-profile > .fa-chevron-down {
        display: none !important;
    }
    
    .user-profile {
        padding: 6px 0;
    }
    
    .sidebar-toggle {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .notifications {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .content-section {
        padding: 20px max(16px, var(--safe-area-left)) max(30px, var(--safe-area-bottom)) max(16px, var(--safe-area-right));
    }
    
    .kpi-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .kpi-card {
        padding: 20px;
    }
    
    .kpi-value {
        font-size: 1.5rem;
    }
    
    .chart-card {
        padding: 20px;
    }
    
    .chart-card canvas {
        height: 240px !important;
        max-height: 280px !important;
    }
    .analytics-chart-wrap {
        height: 240px;
        min-height: 240px;
        max-height: 240px;
    }
    .analytics-chart-wrap canvas {
        max-height: 240px !important;
    }
    
    .accounts-grid,
    .cards-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .card-item {
        min-height: 200px;
        padding: 24px;
    }
    
    .card-number {
        font-size: 1.4rem;
        letter-spacing: 2px;
    }
    
    .filters-panel {
        grid-template-columns: 1fr;
        padding: 16px;
    }
    
    .filter-select,
    .filter-input {
        min-height: 44px;
    }
    
    .transaction-item {
        grid-template-columns: 1fr;
        text-align: left;
        padding: 16px;
        gap: 12px;
    }
    
    .transaction-icon {
        width: 44px;
        height: 44px;
    }
    
    .transaction-amount {
        text-align: left;
        font-size: 1.25rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .btn {
        min-height: 44px;
        padding: 12px 20px;
    }
    
    .modal-content {
        width: calc(100% - 24px);
        max-width: none;
        margin: 12px;
        max-height: calc(100vh - 24px - var(--safe-area-top) - var(--safe-area-bottom));
        border-radius: 16px;
    }
    
    .modal-content.large {
        max-width: none;
    }
    
    .modal-header,
    .modal-body {
        padding: 20px;
    }
    
    .close {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .modal-actions {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .modal-actions .btn {
        flex: 1;
        min-width: 120px;
    }
    
    .toast-container {
        top: auto;
        right: 12px;
        left: max(12px, var(--safe-area-left));
        bottom: max(16px, var(--safe-area-bottom));
    }
    
    .toast {
        min-width: auto;
        width: 100%;
        max-width: 100%;
    }
    
    .file-protocol-banner {
        left: 0;
        padding: 12px max(16px, var(--safe-area-right)) 12px max(16px, var(--safe-area-left));
        padding-bottom: max(12px, var(--safe-area-bottom));
    }
    
    .pagination button {
        min-width: 44px;
        min-height: 44px;
    }
    
    .sidebar-menu a {
        min-height: 48px;
        padding: 14px 20px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .section-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .topbar h2 {
        font-size: 1.1rem;
        max-width: 45vw;
    }
    
    .content-section {
        padding: 16px max(12px, var(--safe-area-left)) max(24px, var(--safe-area-bottom)) max(12px, var(--safe-area-right));
    }
    
    .section-header h2 {
        font-size: 1.4rem;
    }
    
    .kpi-icon {
        width: 56px;
        height: 56px;
        font-size: 1.4rem;
    }
    
    .kpi-value {
        font-size: 1.35rem;
    }
    
    .chart-card canvas {
        height: 220px !important;
    }
    .analytics-chart-wrap {
        height: 220px;
        min-height: 220px;
        max-height: 220px;
    }
    .analytics-chart-wrap canvas {
        max-height: 220px !important;
    }
    
    .card-number {
        font-size: 1.2rem;
    }
    
    .modal-content {
        width: calc(100% - 16px);
        margin: 8px;
        max-height: calc(100vh - 16px - var(--safe-area-top) - var(--safe-area-bottom));
    }
    
    .modal-header h3 {
        font-size: 1.25rem;
    }
}
