:root {
    --color-bg: #f0f2f5;
    --color-surface: #ffffff;
    --color-surface-hover: #f8f9fa;
    --color-border: #e4e7ec;
    --color-text: #1a1d21;
    --color-text-secondary: #6b7280;
    --color-text-muted: #9ca3af;
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-primary-light: #eef2ff;
    --color-success: #10b981;
    --color-success-light: #ecfdf5;
    --color-danger: #ef4444;
    --color-danger-light: #fef2f2;
    --color-warning: #f59e0b;
    --color-warning-light: #fffbeb;
    --color-purple: #8b5cf6;
    --color-purple-light: #f5f3ff;
    --color-sidebar: #111827;
    --color-sidebar-hover: #1f2937;
    --color-sidebar-active: #4f46e5;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-xl: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.logo i {
    font-size: 24px;
    color: var(--color-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: var(--color-sidebar);
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) var(--color-sidebar);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    color: #9ca3af;
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    font-size: 14px;
}

.nav-item:hover {
    background: var(--color-sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: var(--color-sidebar-active);
    color: #fff;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-toggle {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.nav-caret {
    margin-left: auto;
    transition: transform var(--transition);
}

.nav-toggle[aria-expanded="true"] {
    background: var(--color-sidebar-active);
    color: #fff;
}

.nav-toggle[aria-expanded="true"] .nav-caret {
    transform: rotate(180deg);
}

.nav-submenu {
    display: none;
    flex-direction: column;
    gap: 2px;
    margin: 2px 0 2px 16px;
    padding-left: 12px;
    border-left: 2px solid rgba(255,255,255,0.08);
}

.nav-toggle[aria-expanded="true"] + .nav-submenu {
    display: flex;
}

.nav-subitem {
    padding: 8px 12px;
    font-size: 13px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 13px;
}

.user-role {
    font-size: 12px;
    color: #9ca3af;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.content-area {
    flex: 1;
    padding: 32px;
    background-color: #fafafa;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
}

.page-subtitle {
    color: var(--color-text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-border);
}

.btn-ghost {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-border);
}

.btn-ghost:hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
}

.filter-chevron {
    margin-left: 4px;
    transition: transform 0.2s ease;
}

.filter-chevron.rotated {
    transform: rotate(180deg);
}

.btn-danger {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

.btn-danger:hover {
    background: var(--color-danger);
    color: #fff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon-sm:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.btn-icon-sm.danger:hover {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

/* Dashboard Cards */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.dashboard-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    transition: var(--transition);
    min-height: 96px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.dashboard-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.dashboard-card-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
}

.dashboard-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.dashboard-info-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-border);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
    margin-top: -24px;
    margin-right: -12px;
}

.dashboard-info-btn:hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
}

.dashboard-detail-template {
    display: none;
}

.detail-group + .detail-group {
    margin-top: 16px;
}

.detail-group-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}

.detail-group-title i {
    margin-right: 6px;
}

.detail-list {
    margin: 0;
    padding-left: 18px;
}

.detail-list li {
    font-size: 14px;
    color: var(--color-text);
    padding: 2px 0;
}

.dashboard-card-chart {
    width: 100%;
}

.line-chart {
    width: 100%;
    height: auto;
    display: block;
}

.chart-grid {
    stroke: var(--color-border);
    stroke-width: 1;
}

.chart-label-y {
    font-size: 11px;
    fill: var(--color-text-secondary);
}

.chart-label-x {
    font-size: 11px;
    fill: var(--color-text-secondary);
}

.chart-target {
    stroke: #16a34a;
    stroke-width: 2;
    stroke-dasharray: 6 4;
}

.chart-label-target {
    font-size: 11px;
    fill: #16a34a;
    font-weight: 600;
}

.chart-total {
    fill: none;
    stroke: var(--color-primary);
    stroke-width: 2.5;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.chart-total-dot {
    fill: var(--color-primary);
}

.chart-legend-swatch {
    fill: var(--color-primary);
}

.chart-legend {
    font-size: 11px;
    fill: var(--color-text);
}

.goal-cad {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.goal-bar {
    width: 100%;
    height: 14px;
    border-radius: 999px;
    background: var(--color-surface-alt, #eef0f5);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.goal-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-hover));
    transition: width 0.6s ease;
}

.goal-bar-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
}

.goal-bar-pct {
    font-weight: 700;
    color: var(--color-primary);
}

.goal-bar-amount {
    color: var(--color-text-secondary);
}

.goal-cad-no-target {
    font-size: 13px;
    color: var(--color-text-muted);
}

/* Balance CAD card */
.balance-cad {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.balance-cad-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
}

.balance-cad-label {
    color: var(--color-text-secondary);
}

.balance-cad-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.balance-cad-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
}

.balance-cad-status--ok {
    background: var(--color-success-light);
    color: var(--color-success);
}

.balance-cad-status--diff {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

.owner-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.owner-summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
}

.owner-summary-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.owner-summary-value {
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Total Rubriques CAD card */
.total-cad {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 2px;
    padding: 8px 0 4px;
}

.total-cad-main {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    justify-content: flex-start;
    gap: 10px;
}

.total-cad-value,
.total-cad-currency {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.2;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
    text-align: left;
}

.total-cad-value--negative {
    color: var(--color-danger);
}

.total-cad-currency {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--color-text-secondary);
}

.total-cad-currency--negative {
    color: var(--color-danger);
}

.negative-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

.negative-list::-webkit-scrollbar {
    width: 6px;
}

.negative-list::-webkit-scrollbar-track {
    background: transparent;
}

.negative-list::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 999px;
}

.negative-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    background-color: white;
    padding: 0px;
    border-radius: var(--radius-sm);
}

.negative-name {
    color: var(--color-text-secondary);
}

.negative-amount {
    font-weight: 700;
    color: var(--color-danger);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.negative-empty {
    font-size: 13px;
    color: var(--color-text-muted);
}

.top10-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.top10-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    padding: 2px 0;
}

.top10-rank {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #999;
    background-color: #E7E7E7;
    border-radius: var(--radius-sm);
}

.top10-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text);
}

.top10-amount {
    font-weight: 700;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.top10-empty {
    font-size: 13px;
    color: var(--color-text-muted);
}

.exchange-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

.exchange-list::-webkit-scrollbar {
    width: 6px;
}

.exchange-list::-webkit-scrollbar-track {
    background: transparent;
}

.exchange-list::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 999px;
}

.exchange-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    background-color: white;
    border-radius: var(--radius-sm);
}

.exchange-name {
    color: var(--color-text-secondary);
    font-weight: 600;
}

.exchange-rate {
    font-weight: 700;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.exchange-empty {
    font-size: 13px;
    color: var(--color-text-muted);
}

.goldprice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.goldprice-tile {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.goldprice-label {
    font-size: 13px;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.goldprice-value {
    font-size: 30px;
    font-weight: 700;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

.goldprice-currency {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-muted);
}

.dashboard-space {
    min-height: 40px;
}

@media (max-width: 768px) {
    .dashboard-card {
        grid-column: span 12 !important;
    }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-icon--blue { background: var(--color-primary-light); color: var(--color-primary); }
.stat-icon--green { background: var(--color-success-light); color: var(--color-success); }
.stat-icon--red { background: var(--color-danger-light); color: var(--color-danger); }
.stat-icon--purple { background: var(--color-purple-light); color: var(--color-purple); }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 12px;
    color: var(--color-text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-top: 2px;
}

/* Card */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
}

.card-header h2 {
    font-size: 16px;
    font-weight: 700;
}

.card-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.card-body {
    padding: 15px;
}

.details-card {
    margin-bottom: 24px;
}

.details-list {
    padding: 24px;
    margin: 0;
}

.details-list dt {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.details-list dd {
    margin: 0 0 16px;
    font-size: 15px;
}

.json-pre {
    margin: 0;
    padding: 24px;
    background: var(--color-surface-alt, #f8fafc);
    border-radius: 12px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow: auto;
}

.text-muted {
    color: var(--color-text-secondary);
    margin: 0;
    padding: 24px;
}

.accent-swatch {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    vertical-align: middle;
}

.panel-body {
    padding: 24px;
}

.page-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ua-cell {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.break-all {
    word-break: break-all;
}

.inline-form {
    display: inline-block;
    margin: 0;
}

.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
}

.alert--danger {
    background: var(--color-danger-light);
    color: var(--color-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert--success {
    background: var(--color-success-light);
    color: var(--color-success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

/* Search & Filter */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 12px;
    color: var(--color-text-muted);
    font-size: 14px;
}

.search-box input {
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 13px;
    width: 240px;
    transition: var(--transition);
    font-family: inherit;
    background: var(--color-bg);
}

.search-box input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background: var(--color-surface);
}

.filter-group select {
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 13px;
    background: var(--color-bg);
    cursor: pointer;
    font-family: inherit;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.filter-form {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group input,
.filter-group select {
    width: 100%;
}

.filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: none;
    letter-spacing: 0.3px;
}

.filter-group input {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-family: inherit;
    background: var(--color-bg);
    transition: var(--transition);
}

.filter-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background: var(--color-surface);
}

.filter-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* Table */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--color-bg);
}

.data-table th {
    padding: 12px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--color-border);
}

.data-table td {
    padding: 8px 20px;
    border-bottom: 1px solid var(--color-border);
    font-size: 14px;
    vertical-align: middle;
}

.data-table th.text-right,
.data-table td.text-right {
    text-align: right;
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: var(--color-surface-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tfoot td {
    border-top: 1px solid var(--color-border);
    font-weight: 600;
}

.data-table tbody tr.group-line td {
    background: var(--color-surface-hover);
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: 13px;
    padding: 8px 20px;
}

.data-table tbody tr.group-line:hover {
    background: var(--color-surface-hover);
}

/* Account name cell */
.account-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.account-logo {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--color-surface-alt, #eef0f5);
    border: 1px solid var(--color-border);
}

.account-logo--lg {
    width: 48px;
    height: 48px;
}

.account-logo--icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    background: var(--color-primary-light);
}

.account-name {
    font-weight: 600;
    color: var(--color-text);
}

/* Accounts view toggle: cards (default) / table */
.accounts-view.mode-cards .accounts-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.accounts-view.mode-cards .accounts-table-wrap {
    display: none;
}

.accounts-view.mode-table .accounts-cards {
    display: none;
}

.accounts-view.mode-table .accounts-table-wrap {
    display: block;
}

.account-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 11px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 90px;
}

.account-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.account-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
}

.account-card-header .account-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-card-balance {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: -23px;
}

.account-card-amount {
    font-size: 20px;
    font-weight: 700;
}

.account-card-currency {
    font-size: 13px;
    color: var(--color-text-secondary);
}

.account-desc {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* Transfer note */
.transfer-note {
    font-size: 13px;
    color: var(--color-text-muted);
}

/* Income source tag in rubrique list */
.source-tag {
    display: inline-block;
    margin: 2px 4px 2px 0;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: var(--color-primary-light);
    color: var(--color-primary);
    white-space: nowrap;
}

/* Type badge */
.type-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.type-badge--asset { background: var(--color-success-light); color: var(--color-success); }
.type-badge--liability { background: var(--color-danger-light); color: var(--color-danger); }
.type-badge--income { background: var(--color-primary-light); color: var(--color-primary); }
.type-badge--expense { background: var(--color-warning-light); color: var(--color-warning); }

/* Status badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot--active { background: var(--color-success); }
.status-dot--inactive { background: var(--color-text-muted); }

/* Role badge */
.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.role-badge--Admin { background: var(--color-primary-light); color: var(--color-primary); }
.role-badge--Viewer { background: var(--color-surface-alt); color: var(--color-text-secondary); }

/* Change log action badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge--success { background: var(--color-success-light); color: var(--color-success); }
.badge--warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge--danger { background: var(--color-danger-light); color: var(--color-danger); }

.access-denied-user {
    margin: 0 0 16px;
    font-size: 14px;
    color: var(--color-text-secondary);
    text-align: center;
}

.access-denied-form {
    margin: 0;
}

/* Balance */
.balance {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.balance--positive { color: var(--color-success); }
.balance--negative { color: var(--color-danger); }
.balance--zero { color: var(--color-text-muted); }

/* Transaction type badge */
.tx-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.tx-badge--in {
    background: var(--color-success-light);
    color: var(--color-success);
}

.tx-badge--out {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

.tx-badge--transfer {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

/* Actions cell */
.actions-cell {
    display: flex;
    gap: 4px;
}

/* Loading */
.loading-row td {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-muted);
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 48px;
    color: var(--color-border);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 16px;
    color: var(--color-text);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--color-text-muted);
    font-size: 14px;
    margin-bottom: 20px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    width: 480px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.2s ease;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
    scrollbar-gutter: stable;
}

.modal::-webkit-scrollbar {
    width: 8px;
}

.modal::-webkit-scrollbar-track {
    background: transparent;
}

.modal::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 999px;
}

.modal::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 0;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.btn-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--color-bg);
    color: var(--color-text-secondary);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-close:hover {
    background: var(--color-border);
    color: var(--color-text);
}

.modal-body {
    padding: 24px;
}

/* Form */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
    color: var(--color-text);
}

.form-group input,
.form-group select,
.form-group textarea,
.section-amount {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    background: var(--color-surface);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.section-amount:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group .form-control-color {
    width: 64px;
    height: 42px;
    padding: 4px;
    border-radius: var(--radius-md);
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row--3 {
    grid-template-columns: repeat(3, 1fr);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
}

.form-check label {
    margin-bottom: 0;
    font-weight: 500;
}

/* Login */
.login-body {
    background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-layout {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 40px 40px 32px;
}

.login-card-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    background: var(--color-primary-light);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    margin: 0 auto 16px;
}

.login-card-header h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.4px;
}

.login-card-header p {
    color: var(--color-text-secondary);
    font-size: 14px;
    margin-top: 6px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.login-form .form-group {
    margin-bottom: 16px;
}

.login-form .form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    background: var(--color-surface);
}

.login-form .form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.validation-summary {
    background: var(--color-danger-light);
    color: var(--color-danger);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 13px;
}

.validation-summary ul {
    list-style: none;
    margin: 0;
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 12px 20px;
}

.login-form-footer {
    margin-top: 18px;
    text-align: center;
    font-size: 14px;
}

.login-form-footer a {
    color: var(--color-primary);
    font-weight: 600;
    text-decoration: none;
}

.login-form-footer a:hover {
    text-decoration: underline;
}

.data-table td.text-danger {
    color: var(--color-danger);
    display: table-cell;
    font-size: inherit;
    font-weight: inherit;
    margin: 0;
    line-height: inherit;
}

.text-danger {
    color: var(--color-danger);
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

/* Logout in sidebar */
.logout-form {
    margin-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 12px;
}

.logout-form .btn-secondary {
    background: rgba(255,255,255,0.06);
    border-color: transparent;
    color: #9ca3af;
}

.logout-form .btn-secondary:hover {
    background: rgba(255,255,255,0.14);
    color: #fff;
}

/* Toast */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border);
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
    min-width: 280px;
}

.toast--success { border-left: 4px solid var(--color-success); }
.toast--error { border-left: 4px solid var(--color-danger); }
.toast--info { border-left: 4px solid var(--color-primary); }

.toast i {
    font-size: 18px;
}

.toast--success i { color: var(--color-success); }
.toast--error i { color: var(--color-danger); }
.toast--info i { color: var(--color-primary); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Responsive */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 64px;
    }
    .sidebar .logo span,
    .sidebar .nav-item span,
    .sidebar .user-details {
        display: none;
    }
    .sidebar .logo {
        justify-content: center;
    }
    .sidebar .nav-item {
        justify-content: center;
        padding: 12px;
    }
    .nav-submenu {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
    }
    .sidebar .user-info {
        justify-content: center;
    }
    .main-content {
        margin-left: 64px;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .card-header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    .card-header-right {
        flex-direction: column;
    }
    .search-box input {
        width: 100%;
    }
    .page-header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.form-section-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
}

.form-section-hint {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-bottom: 16px;
}

.section-total {
    margin-top: 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-danger);
}

.section-total.ok {
    color: #16a34a;
}

.section-hint-empty {
    font-size: 13px;
    color: var(--color-text-muted);
}

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.section-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(79, 70, 229, 0.08);
    color: var(--color-primary-dark, #312e81);
    border: 1px solid rgba(79, 70, 229, 0.18);
}

.muted {
    color: var(--color-text-secondary);
}

.reorder-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

.order-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 999px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
}

.btn-icon-sm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.drag-handle {
    cursor: grab;
    color: var(--color-text-muted);
    font-size: 14px;
    margin-right: 6px;
    padding: 4px 2px;
}

tbody.is-filtered .drag-handle {
    pointer-events: none;
    opacity: 0.4;
    cursor: not-allowed;
}

tbody.is-filtered .order-badge {
    opacity: 0.4;
}

.drag-handle:active {
    cursor: grabbing;
}

tr.sortable-dragging {
    opacity: 0.5;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    cursor: pointer;
    font-size: 14px;
}

.checkbox-item:hover {
    border-color: var(--color-primary);
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px;
    padding:10px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.filter-group input,
.filter-group select {
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.filter-actions {
    display: flex;
    gap: 8px;
}

.checkbox-item input {
    accent-color: var(--color-primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.price-chart-card .chart-wrap {
    position: relative;
    height: 300px;
}

.chart-legend {
    display: flex;
    gap: 16px;
    color: var(--color-text-secondary);
    font-size: 13px;
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chart-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.chart-dot--buy {
    background: var(--color-primary);
}

.chart-dot--sell {
    background: var(--color-success);
}

.chart-dot--spot {
    background: #f59e0b;
}
