:root {
    --primary: #1B3A6B;
    --primary-light: #2A5298;
    --primary-dark: #0F2548;
    --accent: #DC143C;
    --accent-light: #EF4444;
    --accent-dark: #B91C1C;
    --gradient-start: #00BFFF;
    --gradient-mid: #6B21A8;
    --gradient-end: #DC143C;
    --dark-gray: #1F2937;
    --medium-gray: #4B5563;
    --light-gray: #9CA3AF;
    --bg-gray: #F3F4F6;
    --border-gray: #E5E7EB;
    --white: #FFFFFF;
    --black: #000000;
    --success: #10B981;
    --success-light: #34D399;
    --success-dark: #059669;
    --warning: #F59E0B;
    --warning-light: #FCD34D;
    --warning-dark: #D97706;
    --danger: #EF4444;
    --danger-light: #F87171;
    --danger-dark: #DC2626;
    --info: #3B82F6;
    --info-light: #60A5FA;
    --info-dark: #2563EB;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --transition-fast: all 0.15s ease;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-gray);
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--dark-gray);
    line-height: 1.6;
    font-size: 13px;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-gray); border-radius: var(--radius); }
::-webkit-scrollbar-thumb { background: var(--light-gray); border-radius: var(--radius); }
::-webkit-scrollbar-thumb:hover { background: var(--medium-gray); }

/* Login */
.login-container {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: linear-gradient(135deg, rgba(0,191,255,0.08) 0%, rgba(107,33,168,0.08) 50%, rgba(220,20,60,0.08) 100%);
    position: relative; overflow: hidden;
}
.login-container::before {
    content: ''; position: absolute; top: -50%; right: -50%; width: 200%; height: 200%;
    background: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(27,58,107,0.03) 10px, rgba(27,58,107,0.03) 20px);
    animation: backgroundMove 20s linear infinite;
}
@keyframes backgroundMove { 0% { transform: translate(0,0); } 100% { transform: translate(50px,50px); } }

.login-card {
    background: var(--white); border-radius: var(--radius-xl); box-shadow: var(--shadow-2xl);
    width: 100%; max-width: 500px; padding: 3rem; position: relative; z-index: 10;
    animation: slideUpFadeIn 0.5s ease-out; border: 1px solid rgba(27,58,107,0.1);
}
@keyframes slideUpFadeIn { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo img { max-width: 200px; height: auto; margin-bottom: 1rem; }
.logo-text {
    font-size: 1.8rem; font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 0.5rem; letter-spacing: -1px;
}
.logo-subtitle { color: var(--medium-gray); font-size: 0.875rem; letter-spacing: 3px; text-transform: uppercase; font-weight: 500; }

.form-group { margin-bottom: 1.5rem; position: relative; }
.form-label { display: block; margin-bottom: 0.5rem; color: var(--dark-gray); font-weight: 600; font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.5px; }
.form-control {
    width: 100%; padding: 0.75rem 0.875rem; border: 2px solid var(--border-gray);
    border-radius: var(--radius); font-size: 0.85rem; transition: var(--transition); background: var(--white);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27,58,107,0.1); }
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%234B5563'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 1.5em; padding-right: 2.5rem;
}

.login-btn {
    width: 100%; padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white); border: none; border-radius: var(--radius); font-size: 1rem; font-weight: 600;
    cursor: pointer; transition: var(--transition); text-transform: uppercase; letter-spacing: 1px; position: relative; overflow: hidden;
}
.login-btn::before { content: ''; position: absolute; top: 50%; left: 50%; width: 0; height: 0; background: rgba(255,255,255,0.2); border-radius: 50%; transform: translate(-50%,-50%); transition: width 0.6s, height 0.6s; }
.login-btn:hover::before { width: 300px; height: 300px; }
.login-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.login-error { background: #FEE2E2; color: #991B1B; padding: 0.875rem; border-radius: var(--radius); margin-top: 1rem; font-size: 0.875rem; border: 1px solid var(--danger-light); animation: shake 0.5s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }

/* App Header */
.app-header {
    background: var(--white); box-shadow: var(--shadow-md); padding: 0 2rem;
    display: flex; justify-content: space-between; align-items: center;
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000; height: 70px;
    border-bottom: 3px solid transparent;
    border-image: linear-gradient(90deg, var(--gradient-start), var(--gradient-mid), var(--gradient-end)) 1;
}
.header-left { display: flex; align-items: center; gap: 2rem; }
.menu-toggle { background: none; border: none; font-size: 1.5rem; color: var(--dark-gray); cursor: pointer; transition: var(--transition); padding: 0.5rem; border-radius: var(--radius); }
.menu-toggle:hover { background: var(--bg-gray); color: var(--primary); }
.header-logo { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; }
.header-logo img { height: 40px; width: auto; }
.header-logo-text { font-size: 1.05rem; font-weight: 700; background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: -0.5px; }
.header-right { display: flex; align-items: center; gap: 1.5rem; }
.agency-info { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; background: var(--bg-gray); border-radius: var(--radius); border: 1px solid var(--border-gray); }
.agency-icon { color: var(--primary); font-size: 1rem; }
.agency-details { display: flex; flex-direction: column; }
.agency-label { font-size: 0.625rem; color: var(--medium-gray); text-transform: uppercase; letter-spacing: 0.5px; }
.agency-name { font-weight: 600; color: var(--dark-gray); font-size: 0.875rem; }
.header-actions { display: flex; align-items: center; gap: 1rem; }
.header-btn { position: relative; background: none; border: none; width: 40px; height: 40px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: var(--medium-gray); cursor: pointer; transition: var(--transition); }
.header-btn:hover { background: var(--bg-gray); color: var(--primary); }
.notification-badge { position: absolute; top: 8px; right: 8px; background: var(--danger); color: var(--white); font-size: 0.625rem; padding: 0.125rem 0.25rem; border-radius: var(--radius-full); min-width: 16px; text-align: center; }
.user-menu { display: flex; align-items: center; gap: 0.75rem; padding: 0.375rem 0.75rem; background: var(--bg-gray); border-radius: var(--radius); cursor: pointer; transition: var(--transition); }
.user-menu:hover { background: var(--border-gray); }
.user-avatar { width: 36px; height: 36px; background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%); border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; color: var(--white); font-weight: 600; font-size: 0.875rem; }
.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 0.875rem; font-weight: 600; color: var(--dark-gray); }
.user-role { font-size: 0.75rem; color: var(--medium-gray); }
.logout-btn { padding: 0.5rem 1rem; background: none; border: 2px solid var(--primary); color: var(--primary); border-radius: var(--radius); font-size: 0.875rem; font-weight: 600; cursor: pointer; transition: var(--transition); display: flex; align-items: center; gap: 0.5rem; text-decoration: none; }
.logout-btn:hover { background: var(--primary); color: var(--white); }

/* Sidebar */
.app-sidebar {
    position: fixed; top: 70px; left: 0; bottom: 0; width: 280px;
    background: var(--dark-gray); box-shadow: var(--shadow-xl); transition: var(--transition);
    z-index: 999; overflow-y: auto; overflow-x: hidden;
}
.app-sidebar.collapsed { transform: translateX(-100%); }
.sidebar-nav { padding: 1.5rem 0; }
.nav-section { margin-bottom: 0.5rem; }
.nav-section-title { color: var(--light-gray); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1.5px; padding: 0 1.5rem; margin-bottom: 0; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.nav-section-title::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,0.1); }
.nav-collapsible { cursor: pointer; padding: 0.7rem 1.5rem; margin: 0; border-radius: 0; transition: background 0.2s, color 0.2s; user-select: none; }
.nav-collapsible:hover { background: rgba(255,255,255,0.05); color: var(--white); }
.nav-collapsible .nav-chevron { margin-left: auto; font-size: 0.55rem; transition: transform 0.3s ease; opacity: 0.5; }
.nav-collapsible.expanded .nav-chevron { transform: rotate(90deg); opacity: 0.8; }
.nav-section-items { max-height: 0; overflow: hidden; transition: max-height 0.35s ease; }
.nav-section-items.open { max-height: 500px; }
.nav-item { display: flex; align-items: center; padding: 0.875rem 1.5rem; color: var(--light-gray); text-decoration: none; transition: var(--transition); position: relative; gap: 0.875rem; }
.nav-item::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: transparent; transition: var(--transition); }
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--white); }
.nav-item.active { background: rgba(27,58,107,0.25); color: var(--white); }
.nav-item.active::before { background: linear-gradient(180deg, var(--gradient-start), var(--gradient-end)); }
.nav-icon { font-size: 1.125rem; width: 24px; text-align: center; opacity: 0.8; }
.nav-text { font-size: 0.8125rem; font-weight: 500; }
.nav-badge { margin-left: auto; background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end)); color: var(--white); font-size: 0.625rem; padding: 0.125rem 0.375rem; border-radius: var(--radius-full); font-weight: 600; text-transform: uppercase; }

/* Main Content */
.app-main { margin-left: 280px; padding-top: 70px; min-height: 100vh; transition: var(--transition); background: var(--bg-gray); }
.app-main.expanded { margin-left: 0; }
.main-content { padding: 2rem; animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Module Header */
.module-header { background: var(--white); border-radius: var(--radius-lg); padding: 1.5rem 2rem; margin-bottom: 2rem; box-shadow: var(--shadow-md); display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--border-gray); }
.module-header-content { display: flex; flex-direction: column; gap: 0.5rem; }
.module-title { font-size: 1.4rem; font-weight: 700; color: var(--dark-gray); display: flex; align-items: center; gap: 0.75rem; }
.module-title-icon { width: 40px; height: 40px; background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: var(--white); }
.module-breadcrumb { display: flex; align-items: center; gap: 0.5rem; color: var(--medium-gray); font-size: 0.75rem; }
.breadcrumb-link { color: var(--medium-gray); text-decoration: none; transition: var(--transition); }
.breadcrumb-link:hover { color: var(--primary); }
.breadcrumb-separator { color: var(--light-gray); font-size: 0.75rem; }
.module-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* Buttons */
.btn { padding: 0.5rem 1rem; border-radius: var(--radius); font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: var(--transition); border: none; display: inline-flex; align-items: center; gap: 0.5rem; position: relative; overflow: hidden; white-space: nowrap; text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: var(--white); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn-secondary { background: var(--white); color: var(--dark-gray); border: 2px solid var(--border-gray); }
.btn-secondary:hover { background: var(--bg-gray); border-color: var(--primary); color: var(--primary); }
.btn-success { background: linear-gradient(135deg, var(--success) 0%, var(--success-dark) 100%); color: var(--white); }
.btn-warning { background: linear-gradient(135deg, var(--warning) 0%, var(--warning-dark) 100%); color: var(--white); }
.btn-danger { background: linear-gradient(135deg, var(--danger) 0%, var(--danger-dark) 100%); color: var(--white); }
.btn-info { background: linear-gradient(135deg, var(--info) 0%, var(--info-dark) 100%); color: var(--white); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; }
.btn-lg { padding: 0.875rem 1.5rem; font-size: 1rem; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.stat-card { background: var(--white); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow-md); transition: var(--transition); position: relative; overflow: hidden; border: 1px solid var(--border-gray); }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--gradient-start), var(--gradient-mid), var(--gradient-end)); }
.stat-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-xl); }
.stat-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.stat-icon { width: 48px; height: 48px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.stat-icon.red { background: rgba(220,20,60,0.1); color: var(--accent); }
.stat-icon.green { background: rgba(16,185,129,0.1); color: var(--success); }
.stat-icon.blue { background: rgba(27,58,107,0.1); color: var(--primary); }
.stat-icon.yellow { background: rgba(245,158,11,0.1); color: var(--warning); }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--dark-gray); line-height: 1; margin-bottom: 0.5rem; }
.stat-label { color: var(--medium-gray); font-size: 0.75rem; margin-bottom: 1rem; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-footer { display: flex; align-items: center; gap: 0.5rem; padding-top: 1rem; border-top: 1px solid var(--border-gray); }
.stat-change { display: flex; align-items: center; gap: 0.375rem; font-size: 0.875rem; font-weight: 600; }
.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }
.stat-period { margin-left: auto; color: var(--light-gray); font-size: 0.75rem; }

/* Charts */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(500px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.chart-card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); border: 1px solid var(--border-gray); overflow: hidden; }
.chart-header { display: flex; justify-content: space-between; align-items: center; padding: 1.5rem; border-bottom: 1px solid var(--border-gray); }
.chart-title { font-size: 0.95rem; font-weight: 600; color: var(--dark-gray); display: flex; align-items: center; gap: 0.5rem; }
.chart-subtitle { color: var(--medium-gray); font-size: 0.875rem; margin-top: 0.25rem; }
.chart-actions { display: flex; gap: 0.25rem; }
.chart-action-btn { padding: 0.375rem 0.75rem; background: var(--bg-gray); border: 1px solid var(--border-gray); border-radius: var(--radius-sm); font-size: 0.75rem; cursor: pointer; transition: var(--transition); color: var(--medium-gray); }
.chart-action-btn.active, .chart-action-btn:hover { background: var(--primary); color: var(--white); border-color: var(--primary); }
.chart-body { padding: 1.5rem; height: 300px; position: relative; }

/* Tables */
.table-card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); border: 1px solid var(--border-gray); margin-bottom: 2rem; overflow: hidden; }
.table-header { display: flex; justify-content: space-between; align-items: center; padding: 1.5rem; border-bottom: 1px solid var(--border-gray); }
.table-title { font-size: 0.95rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.table-actions { display: flex; gap: 0.75rem; align-items: center; }
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg-gray); }
th { padding: 0.625rem 0.75rem; text-align: left; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--medium-gray); border-bottom: 2px solid var(--border-gray); white-space: nowrap; }
td { padding: 0.625rem 0.75rem; border-bottom: 1px solid var(--border-gray); font-size: 0.8rem; }
tr:hover { background: rgba(27,58,107,0.02); }
.table-cell-currency { font-weight: 600; color: var(--dark-gray); }
.table-cell-numeric { text-align: right; }
.table-cell-badge { display: inline-flex; align-items: center; padding: 0.25rem 0.625rem; border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 600; }
.table-cell-badge.success { background: rgba(16,185,129,0.1); color: var(--success-dark); }
.table-cell-badge.warning { background: rgba(245,158,11,0.1); color: var(--warning-dark); }
.table-cell-badge.danger { background: rgba(239,68,68,0.1); color: var(--danger-dark); }
.table-cell-badge.info { background: rgba(59,130,246,0.1); color: var(--info-dark); }

/* Search */
.search-box { position: relative; }
.search-icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--light-gray); }
.search-input { padding: 0.5rem 0.75rem 0.5rem 2.25rem; border: 1px solid var(--border-gray); border-radius: var(--radius); font-size: 0.875rem; width: 250px; transition: var(--transition); }
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27,58,107,0.1); }

/* Insights */
.insights-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.insight-card { background: var(--white); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow-md); border: 1px solid var(--border-gray); border-left: 4px solid; }
.insight-card.success { border-left-color: var(--success); }
.insight-card.warning { border-left-color: var(--warning); }
.insight-card.info { border-left-color: var(--info); }
.insight-card.danger { border-left-color: var(--danger); }
.insight-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.insight-icon { width: 40px; height: 40px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; }
.insight-icon.success { background: rgba(16,185,129,0.1); color: var(--success); }
.insight-icon.warning { background: rgba(245,158,11,0.1); color: var(--warning); }
.insight-icon.info { background: rgba(59,130,246,0.1); color: var(--info); }
.insight-icon.danger { background: rgba(239,68,68,0.1); color: var(--danger); }
.insight-title { font-weight: 600; font-size: 0.875rem; }
.insight-content { color: var(--medium-gray); font-size: 0.8125rem; line-height: 1.6; margin-bottom: 1rem; }
.insight-action { color: var(--primary); text-decoration: none; font-weight: 600; font-size: 0.875rem; display: flex; align-items: center; gap: 0.375rem; transition: var(--transition); }
.insight-action:hover { gap: 0.625rem; }

/* Process Flow */
.process-flow { display: flex; justify-content: space-between; align-items: center; padding: 2rem; background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); position: relative; overflow: hidden; }
.process-flow::before { content: ''; position: absolute; top: 50%; left: 80px; right: 80px; height: 2px; background: var(--border-gray); z-index: 0; }
.process-step { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; position: relative; z-index: 1; }
.process-icon { width: 50px; height: 50px; border-radius: 50%; background: var(--bg-gray); border: 3px solid var(--border-gray); display: flex; align-items: center; justify-content: center; font-size: 1.125rem; color: var(--medium-gray); transition: var(--transition); }
.process-step.completed .process-icon { background: var(--success); border-color: var(--success); color: var(--white); }
.process-step.active .process-icon { background: var(--primary); border-color: var(--primary); color: var(--white); animation: pulse 2s infinite; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }
.process-label { font-weight: 600; font-size: 0.8125rem; text-align: center; }
.process-sublabel { color: var(--light-gray); font-size: 0.75rem; }

/* Trend Card */
.trend-card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); border: 1px solid var(--border-gray); margin-bottom: 2rem; overflow: hidden; }
.trend-header { display: flex; justify-content: space-between; align-items: center; padding: 1.5rem; border-bottom: 1px solid var(--border-gray); }
.trend-title { font-size: 0.95rem; font-weight: 600; }
.trend-period-selector { display: flex; gap: 0.25rem; }
.trend-period-btn { padding: 0.375rem 0.75rem; background: var(--bg-gray); border: 1px solid var(--border-gray); border-radius: var(--radius-sm); font-size: 0.75rem; cursor: pointer; transition: var(--transition); }
.trend-period-btn.active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.trend-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; padding: 1.5rem; }
.trend-metric { text-align: center; }
.trend-metric-label { color: var(--medium-gray); font-size: 0.875rem; margin-bottom: 0.5rem; }
.trend-metric-value { font-size: 1.2rem; font-weight: 700; color: var(--dark-gray); margin-bottom: 0.25rem; }
.trend-metric-change { font-size: 0.8125rem; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 0.25rem; }
.trend-metric-change.positive { color: var(--success); }
.trend-metric-change.negative { color: var(--danger); }

/* Upload Section */
.upload-section { background: var(--white); border-radius: var(--radius-lg); padding: 3rem; box-shadow: var(--shadow-md); text-align: center; margin-bottom: 2rem; border: 1px solid var(--border-gray); }
.upload-icon { font-size: 4rem; background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 1.5rem; }
.upload-title { font-size: 1.3rem; font-weight: 700; color: var(--dark-gray); margin-bottom: 0.5rem; }
.upload-description { color: var(--medium-gray); margin-bottom: 2rem; font-size: 0.85rem; }
.upload-area { border: 2px dashed var(--light-gray); border-radius: var(--radius-lg); padding: 3rem 2rem; transition: var(--transition); cursor: pointer; position: relative; background: var(--bg-gray); }
.upload-area:hover { border-color: var(--primary); background: rgba(27,58,107,0.02); }

/* Filters */
.filters-card { background: var(--white); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow-md); border: 1px solid var(--border-gray); margin-bottom: 2rem; }
.filters-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.filters-title { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.filter-group { display: flex; flex-direction: column; gap: 0.375rem; }
.filter-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--medium-gray); }
.filter-control { padding: 0.5rem 0.75rem; border: 1px solid var(--border-gray); border-radius: var(--radius); font-size: 0.875rem; transition: var(--transition); }
.filter-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27,58,107,0.1); }

/* Timeline */
.timeline { padding: 2rem; background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); margin-bottom: 2rem; }
.timeline-item { display: flex; gap: 1.5rem; padding-bottom: 2rem; position: relative; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before { content: ''; position: absolute; left: 14px; top: 30px; bottom: 0; width: 2px; background: var(--border-gray); }
.timeline-item:last-child::before { display: none; }
.timeline-marker { width: 30px; height: 30px; min-width: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent)); display: flex; align-items: center; justify-content: center; }
.timeline-marker::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--white); }
.timeline-content { flex: 1; }
.timeline-date { font-size: 0.8125rem; color: var(--medium-gray); margin-bottom: 0.25rem; }
.timeline-title { font-weight: 600; font-size: 1rem; margin-bottom: 0.5rem; }
.timeline-description { color: var(--medium-gray); font-size: 0.9375rem; line-height: 1.6; }

/* Heatmap */
.heatmap-grid { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; padding: 1.5rem; }
.heatmap-cell { padding: 0.375rem; text-align: center; font-size: 0.625rem; font-weight: 600; border-radius: 3px; color: var(--white); }
.heatmap-cell.low { background: rgba(27,58,107,0.2); color: var(--dark-gray); }
.heatmap-cell.medium { background: rgba(27,58,107,0.5); }
.heatmap-cell.high { background: var(--primary); }

/* Report Builder */
.report-builder { display: grid; grid-template-columns: 280px 1fr; gap: 1.5rem; }
.report-sidebar { background: var(--white); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow-md); }
.report-canvas { background: var(--white); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow-md); }
.report-widget { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem; border-radius: var(--radius); cursor: grab; transition: var(--transition); margin-bottom: 0.5rem; border: 1px solid var(--border-gray); }
.report-widget:hover { background: var(--bg-gray); border-color: var(--primary); }
.report-widget-icon { width: 36px; height: 36px; background: linear-gradient(135deg, var(--primary), var(--accent)); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: var(--white); font-size: 0.875rem; }
.report-widget-title { font-weight: 600; font-size: 0.875rem; }
.report-widget-description { color: var(--medium-gray); font-size: 0.75rem; }

/* Gauge */
.gauge-container { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.gauge-value { font-weight: 700; color: var(--dark-gray); }

/* Loading */
.loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.8); z-index: 9999; display: none; align-items: center; justify-content: center; }
.loading-overlay.active { display: flex; }
.loading-spinner { width: 48px; height: 48px; border: 4px solid var(--border-gray); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 768px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .charts-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
    .module-header { flex-direction: column; gap: 1rem; }
    .header-right { display: none; }
    .report-builder { grid-template-columns: 1fr; }
}

/* ===================== MaverickCharts 3D (D3) ===================== */
.chart-body { overflow: hidden; }
.chart-body svg { display: block; max-width: 100%; max-height: 100%; }

.mc-tooltip {
    position: absolute;
    background: rgba(31,41,55,0.95);
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    line-height: 1.5;
    pointer-events: none;
    z-index: 100;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    max-width: 280px;
}

.mc-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: 0.75rem;
    color: #4B5563;
}
.mc-legend-bottom {
    justify-content: center;
    padding: 8px 0 0;
}
.mc-legend-right {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    flex-direction: column;
    max-width: 130px;
    padding-left: 8px;
}
.mc-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    user-select: none;
    transition: opacity 0.2s;
}
.mc-legend-item.mc-legend-hidden {
    opacity: 0.35;
    text-decoration: line-through;
}
.mc-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.mc-legend-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mc-grid line { shape-rendering: crispEdges; }

@media print {
    .mc-tooltip { display: none !important; }
}
