/* ==========================================================================
   Salary Tracker — Premium Design System & Refined Responsive Layout
   ========================================================================== */

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

/* ── CSS Custom Properties ─────────────────────────────────────────────── */
:root, [data-theme="light"] {
    --bg-primary:          #F8FAFC;
    --bg-secondary:        #FFFFFF;
    --bg-tertiary:         #F1F5F9;
    --bg-quaternary:       #E2E8F0;
    --bg-glass:            rgba(255, 255, 255, 0.85);

    --text-primary:        #0F172A;
    --text-secondary:      #475569;
    --text-muted:          #64748B;

    --accent-primary:      #10B981;
    --accent-hover:        #059669;
    --accent-indigo:       #6366F1;
    --accent-indigo-hover: #4F46E5;
    
    --accent-gradient:     linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
    --accent-emerald:      linear-gradient(135deg, #10B981 0%, #059669 100%);

    --border-color:        #E2E8F0;
    --border-hover:        rgba(99, 102, 241, 0.35);

    --danger-color:        #EF4444;
    --danger-hover:        #DC2626;
    --positive-color:      #10B981;
    --negative-color:      #EF4444;

    --shadow-sm:           0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow-card:         0 10px 25px -5px rgba(15, 23, 42, 0.05), 0 4px 10px -2px rgba(15, 23, 42, 0.02);
    --shadow-glow:         0 12px 28px -6px rgba(99, 102, 241, 0.18);
}

[data-theme="dark"] {
    --bg-primary:          #0F172A;
    --bg-secondary:        #1E293B;
    --bg-tertiary:         #334155;
    --bg-quaternary:       #475569;
    --bg-glass:            rgba(30, 41, 59, 0.85);

    --text-primary:        #F8FAFC;
    --text-secondary:      #94A3B8;
    --text-muted:          #64748B;

    --accent-primary:      #10B981;
    --accent-hover:        #34D399;
    --accent-indigo:       #818CF8;
    --accent-indigo-hover: #6366F1;
    
    --accent-gradient:     linear-gradient(135deg, #818CF8 0%, #6366F1 100%);
    --accent-emerald:      linear-gradient(135deg, #34D399 0%, #10B981 100%);

    --border-color:        rgba(255, 255, 255, 0.08);
    --border-hover:        rgba(129, 140, 248, 0.35);

    --danger-color:        #F87171;
    --danger-hover:        #EF4444;
    --positive-color:      #34D399;
    --negative-color:      #F87171;

    --shadow-sm:           0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-card:         0 10px 30px -5px rgba(0, 0, 0, 0.35), 0 4px 10px -2px rgba(0, 0, 0, 0.2);
    --shadow-glow:         0 12px 30px -6px rgba(129, 140, 248, 0.25);
}

/* ── Typography & Base ─────────────────────────────────────────────────── */
body {
    font-family:      'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color:            var(--text-primary);
    line-height:      1.5;
    overflow-x:       hidden;
    transition:       background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    color:       var(--text-primary);
    letter-spacing: -0.02em;
}

h1 { font-size: 1.5rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 0; }
h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: 12px; }

/* Mono font utility for numeric currency data */
.metric-value, .stat-value, td, .numeric-data {
    font-family: 'JetBrains Mono', monospace;
}

/* ── App Container & Header ────────────────────────────────────────────── */
.container {
    max-width:     1280px;
    width:         100%;
    margin:        0 auto;
    padding:       24px 24px 40px;
}

.app-header {
    display:         flex;
    justify-content: space-between;
    align-items:     center;
    padding:         16px 24px;
    margin-bottom:   24px;
    background:      var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border:          1px solid var(--border-color);
    border-radius:   16px;
    box-shadow:      var(--shadow-sm);
}

.brand-container {
    display:     flex;
    align-items: center;
    gap:         14px;
}

.brand-icon {
    width:            42px;
    height:           42px;
    border-radius:    12px;
    background:       var(--accent-gradient);
    color:            #FFFFFF;
    display:          flex;
    align-items:      center;
    justify-content:  center;
    box-shadow:       0 4px 14px rgba(99, 102, 241, 0.35);
}

.brand-icon svg { width: 22px; height: 22px; }

.brand-text {
    display:        flex;
    align-items:    center;
    gap:            10px;
}

.brand-badge {
    font-family:    'Inter', sans-serif;
    font-size:      10px;
    font-weight:    700;
    letter-spacing: 0.08em;
    padding:        3px 8px;
    border-radius:  20px;
    background:     rgba(99, 102, 241, 0.12);
    color:          var(--accent-indigo);
    text-transform: uppercase;
}

/* Theme Toggle Button */
.theme-toggle {
    background:    var(--bg-tertiary);
    border:        1px solid var(--border-color);
    border-radius: 30px;
    padding:       6px 12px;
    cursor:        pointer;
    display:       flex;
    align-items:   center;
    gap:           6px;
    transition:    all 0.25s ease;
    min-width:     64px;
    justify-content: space-between;
}

.theme-toggle:hover {
    border-color: var(--border-hover);
    transform:    translateY(-1px);
    box-shadow:   var(--shadow-sm);
}

.theme-icon {
    font-size:  14px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Dashboard Layout ─────────────────────────────────────────────────── */
.dashboard-layout {
    display:        flex;
    flex-direction: column;
    gap:            24px;
}

.dashboard-body {
    display:               grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap:                   24px;
    align-items:           start;
}

.dashboard-main-col {
    display:        flex;
    flex-direction: column;
    gap:            24px;
    min-width:      0;
}

.dashboard-sidebar-col {
    display:        flex;
    flex-direction: column;
    gap:            24px;
    min-width:      0;
}

/* ── Section Cards (Glassmorphism + Subtle Hover) ────────────────────────── */
.analytics-section-unified,
.chart-section,
.history-section,
.data-section,
.statistics-section {
    background-color: var(--bg-secondary);
    border-radius:    18px;
    padding:          24px;
    border:           1px solid var(--border-color);
    box-shadow:       var(--shadow-card);
    transition:       border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

.analytics-section-unified:hover,
.chart-section:hover,
.history-section:hover,
.data-section:hover,
.statistics-section:hover {
    border-color: var(--border-hover);
    box-shadow:   var(--shadow-glow);
}

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

.analytics-section-unified .section-header {
    margin-bottom:  18px;
    padding-bottom: 14px;
    border-bottom:  1px solid var(--border-color);
}

.analytics-section-unified .section-header h2 {
    font-size:   1.35rem;
    font-weight: 700;
}

.settings-gear {
    cursor:        pointer;
    padding:       6px 8px;
    border-radius: 10px;
    background:    var(--bg-tertiary);
    border:        1px solid var(--border-color);
    transition:    all 0.2s ease;
}

.settings-gear:hover {
    background:   var(--bg-quaternary);
    border-color: var(--border-hover);
    transform:    rotate(20deg);
}

/* ── Overview Metrics Grid ─────────────────────────────────────────────── */
.summary-text {
    font-size:     14px;
    color:         var(--text-secondary);
    margin-bottom: 20px;
    line-height:   1.6;
}

.metrics-grid {
    display:               grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap:                   12px;
}

.metric-item {
    background-color: var(--bg-secondary);
    border:           1px solid var(--border-color);
    border-radius:    14px;
    padding:          14px 12px;
    box-shadow:       0 2px 6px rgba(0, 0, 0, 0.02);
    transition:       all 0.2s ease;
    display:          flex;
    flex-direction:   column;
    justify-content:  space-between;
    position:         relative;
    overflow:         hidden;
}

.metric-item::before {
    content:       '';
    position:      absolute;
    top:           0;
    left:          0;
    right:         0;
    height:        3px;
    background:    var(--accent-gradient);
    opacity:       0;
    transition:    opacity 0.2s ease;
}

.metric-item:hover {
    transform:    translateY(-2px);
    border-color: var(--border-hover);
    box-shadow:   var(--shadow-card);
}

.metric-item:hover::before { opacity: 1; }

.metric-label {
    font-size:      10px;
    font-weight:    700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color:          var(--text-muted);
    margin-bottom:  8px;
}

.metric-value {
    font-size:   16px;
    font-weight: 600;
    color:       var(--text-primary);
    word-break:  break-word;
}

.metric-value.positive { color: var(--positive-color); }
.metric-value.negative { color: var(--negative-color); }

/* Overview expand button */
.toggle-overview-btn {
    width:            100%;
    margin-top:       16px;
    padding:          11px;
    border-radius:    12px;
    background:       var(--bg-tertiary);
    border:           1px solid var(--border-color);
    color:            var(--text-secondary);
    font-family:      'Plus Jakarta Sans', sans-serif;
    font-weight:      600;
    font-size:        13px;
    cursor:           pointer;
    transition:       all 0.2s ease;
    display:          flex;
    align-items:      center;
    justify-content:  center;
    gap:              8px;
}

.toggle-overview-btn:hover {
    background:   var(--bg-quaternary);
    color:        var(--text-primary);
    border-color: var(--border-hover);
    box-shadow:   var(--shadow-sm);
}

.overview-details-hidden { display: none; }
.overview-details-hidden.visible { display: block; margin-top: 20px; }

/* Breakdown & Trends inside details */
.source-breakdown, .trends-section, .notable-months, .forecast-section {
    margin-top:    20px;
    padding:       18px;
    background:    var(--bg-tertiary);
    border-radius: 16px;
    border:        1px solid var(--border-color);
}

.source-breakdown h4, .trends-section h3, .notable-months h4, .forecast-section h3 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size:   15px;
    font-weight: 700;
    color:       var(--text-primary);
    margin-bottom: 14px;
}

.breakdown-grid, .trend-analysis, .forecast-grid {
    display:               grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap:                   14px;
    margin-top:            12px;
}

.pie-chart-wrap {
    width:     100%;
    max-width: 300px;
    height:    240px;
    margin:    16px auto 0;
}

/* Income Sources Item */
.source-item {
    background:    var(--bg-secondary);
    border:        1px solid var(--border-color);
    border-radius: 12px;
    padding:       14px;
    box-shadow:    var(--shadow-sm);
    transition:    all 0.2s ease;
}
.source-item:hover {
    border-color: var(--border-hover);
    transform:    translateY(-1px);
}
.source-name {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size:   13px;
    font-weight: 700;
    color:       var(--text-primary);
    margin-bottom: 4px;
}
.source-amount {
    font-family: 'JetBrains Mono', monospace;
    font-size:   15px;
    font-weight: 600;
    color:       var(--text-primary);
    margin-bottom: 4px;
}
.source-share {
    font-size:   11px;
    font-weight: 700;
    padding:     2px 6px;
    border-radius: 12px;
    background:  rgba(99, 102, 241, 0.1);
    color:       var(--accent-indigo);
}
.source-details {
    font-size: 12px;
    color:     var(--text-muted);
}

/* Trends Section Items */
.trend-item-unified {
    background:    var(--bg-secondary);
    border:        1px solid var(--border-color);
    border-radius: 14px;
    padding:       16px;
    box-shadow:    var(--shadow-sm);
    transition:    all 0.2s ease;
    display:       flex;
    flex-direction: column;
    gap:           10px;
}
.trend-item-unified:hover {
    border-color: var(--border-hover);
    transform:    translateY(-2px);
    box-shadow:   var(--shadow-card);
}
.trend-source-name {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size:   14px;
    font-weight: 700;
    color:       var(--text-primary);
}
.trend-badge {
    display:       inline-flex;
    align-items:   center;
    gap:           6px;
    padding:       4px 10px;
    border-radius: 20px;
    font-size:     12px;
    font-weight:   600;
    width:         fit-content;
}
.trend-badge.growing {
    background-color: rgba(16, 185, 129, 0.12);
    color:            var(--positive-color);
}
.trend-badge.declining {
    background-color: rgba(239, 68, 68, 0.12);
    color:            var(--negative-color);
}
.trend-badge.stable {
    background-color: rgba(99, 102, 241, 0.12);
    color:            var(--accent-indigo);
}
.trend-stats-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
}
.trend-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.trend-stat-label {
    color: var(--text-muted);
}
.trend-stat-val {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--text-primary);
}

/* Notable Months Section Items */
.notable-item-unified {
    background:    var(--bg-secondary);
    border:        1px solid var(--border-color);
    border-radius: 12px;
    padding:       14px 16px;
    margin-top:    10px;
    display:       flex;
    flex-direction: column;
    gap:           6px;
    transition:    all 0.2s ease;
}
.notable-item-unified.spike {
    border-left: 4px solid var(--positive-color);
}
.notable-item-unified.drop {
    border-left: 4px solid var(--negative-color);
}
.notable-header-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.notable-month-unified {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size:   14px;
    font-weight: 700;
    color:       var(--text-primary);
}
.notable-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
}
.notable-badge.spike {
    background: rgba(16, 185, 129, 0.12);
    color: var(--positive-color);
}
.notable-badge.drop {
    background: rgba(239, 68, 68, 0.12);
    color: var(--negative-color);
}
.notable-reason-unified {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Forecast Section Items */
.forecast-item-unified {
    background:    var(--bg-secondary);
    border:        1px solid var(--border-color);
    border-radius: 14px;
    padding:       16px;
    box-shadow:    var(--shadow-sm);
    display:       flex;
    flex-direction: column;
    gap:           8px;
    transition:    all 0.2s ease;
}
.forecast-item-unified:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}
.forecast-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.forecast-month-unified {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size:   14px;
    font-weight: 700;
    color:       var(--text-primary);
}
.forecast-amount-unified {
    font-family: 'JetBrains Mono', monospace;
    font-size:   20px;
    font-weight: 700;
    color:       var(--text-primary);
}
.forecast-range-unified {
    font-size:   12px;
    font-family: 'JetBrains Mono', monospace;
    color:       var(--text-muted);
}
.forecast-confidence-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    width: fit-content;
    background: rgba(16, 185, 129, 0.12);
    color: var(--positive-color);
}
.confidence-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--positive-color);
}
.forecast-breakdown-list {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.forecast-source-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}
.forecast-source-name {
    color: var(--text-secondary);
}
.forecast-source-val {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Chart Section ─────────────────────────────────────────────────────── */
.chart-title-container h2 { font-size: 1.25rem; }

.chart-canvas-wrap {
    position: relative;
    width:    100%;
    height:   380px;
    margin-top: 10px;
}

#salaryChart { width: 100% !important; height: 100% !important; }

/* ── Data Form (Add Salary) ────────────────────────────────────────────── */
.add-salary-section h2 { margin-bottom: 16px; }

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display:       block;
    font-size:     12px;
    font-weight:   600;
    color:         var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width:            100%;
    height:           44px;
    padding:          0 14px;
    font-family:      'Inter', sans-serif;
    font-size:        14px;
    color:            var(--text-primary);
    background-color: var(--bg-tertiary);
    border:           1.5px solid var(--border-color);
    border-radius:    10px;
    outline:          none;
    transition:       all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent-indigo);
    box-shadow:   0 0 0 3px rgba(99, 102, 241, 0.15);
    background:   var(--bg-secondary);
}

.form-actions button,
.primary-btn {
    width:            100%;
    height:           44px;
    background:       var(--accent-gradient);
    color:            #FFFFFF;
    font-family:      'Plus Jakarta Sans', sans-serif;
    font-weight:      700;
    font-size:        14px;
    border:           none;
    border-radius:    10px;
    cursor:           pointer;
    box-shadow:       0 4px 14px rgba(99, 102, 241, 0.3);
    transition:       all 0.2s ease;
}

.form-actions button:hover,
.primary-btn:hover {
    transform:  translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.form-actions button:active,
.primary-btn:active {
    transform: translateY(0);
}

/* ── Statistics Panel ──────────────────────────────────────────────────── */
.statistics-header {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    flex-wrap:       wrap;
    gap:             12px;
    margin-bottom:   16px;
    padding-bottom:  12px;
    border-bottom:   1px solid var(--border-color);
}

.statistics-header h2 { margin: 0; }

.job-selector {
    display:     flex;
    align-items: center;
    gap:         8px;
    flex-shrink: 0;
}

.job-selector label {
    font-size:   12px;
    font-weight: 500;
    color:       var(--text-muted);
    white-space: nowrap;
}

.job-selector select {
    padding:       6px 12px;
    font-size:     13px;
    border-radius: 8px;
    border:        1px solid var(--border-color);
    background:    var(--bg-tertiary);
    color:         var(--text-primary);
    outline:       none;
}

.job-selector select:focus {
    border-color: var(--accent-indigo);
}

.current-entry h3 {
    font-size:     13px;
    color:         var(--text-muted);
    font-weight:   600;
    margin-bottom: 12px;
}

.stat-item {
    display:         flex;
    justify-content: space-between;
    align-items:     center;
    padding:         10px 0;
    border-bottom:   1px solid var(--border-color);
}

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

.stat-item .label {
    font-size: 13px;
    color:     var(--text-secondary);
}

.stat-item span:last-child {
    font-weight: 600;
    font-size:   14px;
    color:       var(--text-primary);
}

/* ── Salary History Table ──────────────────────────────────────────────── */
.table-container {
    width:          100%;
    overflow-x:     auto;
    border-radius:  14px;
    border:         1px solid var(--border-color);
    margin-bottom:  16px;
}

#salaryHistoryTable {
    width:           100%;
    border-collapse: collapse;
    text-align:      left;
}

#salaryHistoryTable th {
    background-color: var(--bg-tertiary);
    color:            var(--text-muted);
    font-size:        11px;
    font-weight:      700;
    text-transform:   uppercase;
    letter-spacing:   0.05em;
    padding:          14px 16px;
    border-bottom:    1px solid var(--border-color);
}

#salaryHistoryTable td {
    padding:       14px 16px;
    font-size:     13.5px;
    color:         var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    white-space:   nowrap;
}

#salaryHistoryTable tbody tr {
    transition: background-color 0.15s ease;
}

#salaryHistoryTable tbody tr:hover {
    background-color: var(--bg-tertiary);
}

#salaryHistoryTable tbody tr:last-child td {
    border-bottom: none;
}

#salaryHistoryTable td.positive {
    color:       var(--positive-color);
    font-weight: 600;
}

#salaryHistoryTable td.negative {
    color:       var(--negative-color);
    font-weight: 600;
}

/* Table Pagination Bar */
.pagination {
    display:         flex;
    align-items:     center;
    justify-content: center;
    gap:             6px;
    padding:         14px;
    background:      var(--bg-tertiary);
    border-top:      1px solid var(--border-color);
}

.pagination button {
    min-width:        34px;
    height:           34px;
    padding:          0 10px;
    border-radius:    8px;
    border:           1px solid var(--border-color);
    background-color: var(--bg-secondary);
    color:            var(--text-primary);
    font-family:      'Inter', sans-serif;
    font-size:        13px;
    font-weight:      500;
    cursor:           pointer;
    transition:       all 0.15s ease;
    display:          inline-flex;
    align-items:      center;
    justify-content:  center;
}

.pagination button:hover:not(:disabled) {
    border-color:     var(--accent-indigo);
    color:            var(--accent-indigo);
    background-color: rgba(99, 102, 241, 0.08);
}

.pagination button.active {
    background:   var(--accent-gradient);
    color:        #FFFFFF;
    border:       none;
    font-weight:  700;
    box-shadow:   0 2px 8px rgba(99, 102, 241, 0.3);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor:  not-allowed;
}

.pagination .page-info {
    color:     var(--text-muted);
    font-size: 13px;
    padding:   0 4px;
}

/* Action buttons in table */
.icon-btn {
    border:        none;
    background:    transparent;
    cursor:        pointer;
    padding:       6px;
    border-radius: 6px;
    color:         var(--text-secondary);
    transition:    all 0.15s ease;
}

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

.icon-btn.delete-btn:hover {
    background-color: rgba(239, 68, 68, 0.15);
    color:            var(--danger-color);
}

/* Danger Button */
.danger-button {
    background-color: var(--danger-color);
    color:            #FFFFFF;
    border:           none;
    padding:          10px 18px;
    border-radius:    10px;
    font-weight:      600;
    font-size:        13px;
    cursor:           pointer;
    transition:       all 0.2s ease;
}

.danger-button:hover {
    background-color: var(--danger-hover);
    box-shadow:       0 4px 12px rgba(239, 68, 68, 0.3);
}

/* ── Settings Container ────────────────────────────────────────────────── */
.settings-container {
    display:   grid;
    grid-template-columns: repeat(2, 1fr);
    gap:       12px;
}

.settings-button {
    background-color: var(--bg-secondary);
    border:           1px solid var(--border-color);
    color:            var(--text-primary);
    padding:          14px 16px;
    border-radius:    12px;
    font-family:      'Plus Jakarta Sans', sans-serif;
    font-weight:      600;
    font-size:        13px;
    cursor:           pointer;
    box-shadow:       var(--shadow-sm);
    transition:       all 0.2s ease;
    text-align:       center;
    display:          flex;
    align-items:      center;
    justify-content:  center;
}

.settings-button:hover {
    border-color: var(--border-hover);
    transform:    translateY(-1px);
    box-shadow:   var(--shadow-card);
    background:   var(--bg-tertiary);
}

/* ── Base Rates Footer Card ────────────────────────────────────────────── */
footer {
    margin-top:       32px;
    padding:          20px 24px;
    background-color: var(--bg-secondary);
    border:           1px solid var(--border-color);
    border-radius:    16px;
    box-shadow:       var(--shadow-card);
}

.base-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.base-info > div:first-child {
    font-family:    'Plus Jakarta Sans', sans-serif;
    font-size:      13px;
    font-weight:    700;
    color:          var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.base-rates-container {
    display:   flex;
    flex-wrap: wrap;
    gap:       10px;
}

.base-rate-item {
    background:    var(--bg-tertiary);
    border:        1px solid var(--border-color);
    padding:       10px 14px;
    border-radius: 10px;
    font-size:     13px;
    color:         var(--text-secondary);
    line-height:   1.4;
}

.base-rate-item strong {
    color:       var(--text-primary);
    font-weight: 600;
}

/* ── Modals (Glassmorphism Overlay & Card) ─────────────────────────────── */
.modal {
    display:          none;
    position:         fixed;
    inset:            0;
    z-index:          1000;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter:  blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow-y:       auto;
    padding:          20px;
}

.modal-content {
    background-color: var(--bg-secondary);
    position:         relative;
    margin:           40px auto;
    width:            90%;
    max-width:        540px;
    border-radius:    20px;
    border:           1px solid var(--border-color);
    box-shadow:       0 20px 40px rgba(0, 0, 0, 0.25);
    overflow:         hidden;
    animation:        modalPopIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.modal-header {
    padding:          18px 24px;
    background-color: var(--bg-tertiary);
    border-bottom:    1px solid var(--border-color);
    display:          flex;
    justify-content:  space-between;
    align-items:      center;
}

.modal-header h2 { font-size: 1.15rem; margin: 0; }

.close-modal {
    font-size:   24px;
    font-weight: 700;
    color:       var(--text-muted);
    cursor:      pointer;
    transition:  color 0.15s ease;
}

.close-modal:hover { color: var(--text-primary); }

.modal-body {
    padding: 20px 24px 24px;
}

.modal-actions {
    display:         flex;
    justify-content: flex-end;
    gap:             12px;
    margin-top:      20px;
    padding-top:     16px;
    border-top:      1px solid var(--border-color);
}

/* ── Tooltips ──────────────────────────────────────────────────────────── */
.tooltip {
    position:         fixed;
    z-index:          1100;
    padding:          8px 12px;
    background:       #1E293B;
    color:            #F8FAFC;
    font-size:        12px;
    border-radius:    8px;
    box-shadow:       0 4px 14px rgba(0, 0, 0, 0.25);
    pointer-events:   none;
    opacity:          0;
    transition:       opacity 0.15s ease;
    max-width:        280px;
}

.tooltip.visible { opacity: 1; }

/* ── Loading Overlay ───────────────────────────────────────────────────── */
.loading-overlay {
    position:        fixed;
    inset:           0;
    z-index:         9999;
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    justify-content: center;
    gap:             16px;
    background:      rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(6px);
    transition:      opacity 0.25s ease;
}

.loading-overlay.hidden {
    opacity:        0;
    pointer-events: none;
}

.spinner {
    width:         44px;
    height:        44px;
    border:        3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent-indigo);
    border-radius: 50%;
    animation:     spin 0.8s linear infinite;
}

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

.loading-text {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size:   14px;
    font-weight: 600;
    color:       #F8FAFC;
}


/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

/* ── Desktop XL / Large screens ────────────────────────────────────────── */
@media (min-width: 1400px) {
    .container { max-width: 1360px; }
}

/* ── Tablet / Medium screens (<= 1100px) ────────────────────────────────── */
@media (max-width: 1100px) {
    .container { padding: 20px 20px 32px; }

    .dashboard-layout {
        grid-template-columns: 1fr 300px;
        gap: 18px;
    }

    .metrics-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* ── Small Tablet & Large Phones (<= 900px) ────────────────────────────── */
@media (max-width: 900px) {
    .container {
        padding:        12px 14px 24px;
        padding-top:    max(16px, env(safe-area-inset-top));
        padding-left:   max(12px, env(safe-area-inset-left));
        padding-right:  max(12px, env(safe-area-inset-right));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }

    .app-header {
        padding:       12px 16px;
        margin-bottom: 16px;
        border-radius: 14px;
    }

    .brand-icon { width: 36px; height: 36px; }
    .brand-icon svg { width: 18px; height: 18px; }
    h1 { font-size: 1.25rem; }
    .brand-badge { font-size: 9px; padding: 2px 6px; }

    .dashboard-layout {
        gap: 16px;
    }

    .dashboard-body {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .analytics-section-unified,
    .chart-section,
    .history-section,
    .data-section,
    .statistics-section {
        padding: 16px;
        border-radius: 14px;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .metric-item { padding: 12px; }
    .metric-label { font-size: 10px; }
    .metric-value { font-size: 16px; }

    .chart-canvas-wrap { height: 320px; }

    /* Modals: bottom sheet layout on mobile */
    .modal {
        padding: 0;
        display: none;
        align-items: flex-end;
    }

    .modal-content {
        margin:        0;
        width:         100%;
        max-width:     100%;
        max-height:    min(90vh, 100%);
        border-radius: 20px 20px 0 0;
        animation:     mobileSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes mobileSlideUp {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }

    .modal-body {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }

    /* History table stacked card view on mobile */
    #salaryHistoryTable,
    #salaryHistoryTable thead,
    #salaryHistoryTable tbody,
    #salaryHistoryTable th,
    #salaryHistoryTable td,
    #salaryHistoryTable tr {
        display: block;
        width:   100%;
    }

    #salaryHistoryTable thead {
        position: absolute;
        width:    1px;
        height:   1px;
        padding:  0;
        margin:   -1px;
        overflow: hidden;
        clip:     rect(0, 0, 0, 0);
        border:   0;
    }

    #salaryHistoryTable tbody tr {
        background-color: var(--bg-tertiary);
        border:           1px solid var(--border-color);
        border-radius:    12px;
        padding:          14px;
        margin-bottom:    12px;
    }

    #salaryHistoryTable td {
        display:         flex;
        justify-content: space-between;
        align-items:     center;
        padding:         8px 0;
        border:          none;
        border-bottom:   1px solid var(--border-color);
        white-space:     normal;
    }

    #salaryHistoryTable td:last-child {
        border-bottom: none;
        padding-top:   12px;
    }

    #salaryHistoryTable td::before {
        content:     attr(data-label);
        font-weight: 600;
        font-size:   12px;
        color:       var(--text-muted);
        text-align:  left;
        flex-shrink: 0;
    }
}

/* ── Compact Mobile (<= 480px) ─────────────────────────────────────────── */
@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .metric-item  { padding: 10px 8px; }
    .metric-value { font-size: 15px; }

    .chart-canvas-wrap { height: 340px; }

    .settings-container {
        grid-template-columns: 1fr;
    }
}
