:root {
    --bg-dark: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary: #3b82f6;
    --success: #10b981;
    --danger: #ef4444;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    margin: 0;
    min-height: 100vh;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    position: relative;
    /* Ensure z-index works */
}

/* Ensure filter panel sits above other panels for dropdowns */
#filter-panel {
    z-index: 50;
}

.app-header {
    margin-bottom: 2rem;
    text-align: center;
    position: relative;
    z-index: 60;
    /* Ensure visible above filter panel */
}

/* Logout Button Positioning */
#logout-btn {
    position: absolute;
    top: 0;
    right: 0;
    padding: 0.5rem;
    font-size: 1.2rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    /* Tooltip logic relies on this creating a stacking context */
}

#logout-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Hide default btn styles for this specific button if needed */
/* Custom Tooltip */
#logout-btn {
    position: absolute;
    /* Anchor to header corner */
    top: 0;
    right: 0;
    /* Tooltip logic relies on this creating a stacking context, which 'absolute' does */
}

#logout-btn::after {
    content: "Logout";
    position: absolute;
    top: 110%;
    /* Below the button */
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    border: 1px solid var(--glass-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    z-index: 100;
}

#logout-btn:hover::after {
    opacity: 1;
}

/* Hide default btn styles for this specific button if needed */
#logout-btn.hidden {
    display: none;
}

h1 {
    font-size: 2.5rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    /* Default white for Traderscafe */
}

.highlight {
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 {
    font-size: 1.5rem;
    margin: 0;
    color: var(--text-primary);
}

p {
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Filter Bar */
.search-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    justify-content: center;
}

input {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    color: white;
    font-family: inherit;
}

/* --- HEATMAP STYLES --- */
#heatmap-grid {
    display: grid;
    /* Smaller columns: min 60px */
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 8px;
    /* Tighter gap */
    margin-bottom: 2rem;
}

.pnl-box {
    aspect-ratio: 1;
    border-radius: 8px;
    /* Smaller radius */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0.25rem;
    /* Reduced padding */
    transition: transform 0.1s, box-shadow 0.1s;
    cursor: pointer;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: #1e293b;
}

.pnl-box:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    z-index: 10;
    border-color: rgba(255, 255, 255, 0.5);
}

.pnl-box.selected {
    border: 2px solid #fff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.pnl-box .date {
    font-size: 0.7rem;
    /* Smaller date */
    font-weight: 600;
    margin-bottom: 2px;
    opacity: 0.8;
}

.pnl-box .amount {
    font-size: 0.75rem;
    /* Smaller amount */
    font-weight: 700;
    line-height: 1;
}

/* Detail View Styles */
#day-detail-panel {
    min-height: 0;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(-10px);
    display: none;
    /* Hidden by default */
    margin-bottom: 2rem;
}

#day-detail-panel.visible {
    opacity: 1;
    transform: translateY(0);
    display: block;
}

.detail-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
    text-align: center;
}

.detail-item label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-item .value {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
}

/* Gradient Backgrounds */
/* HSL Shading: Darker color for higher intensity */
.pnl-positive {
    /* Green: Hue 150. Lightness decreases as intensity increases (from 50% down to 20%) */
    background-color: hsl(150, 80%, calc(50% - (var(--intensity, 0) * 30%)));
    border: 1px solid rgba(16, 185, 129, 0.5);
    color: #fff;
    /* Adjust opacity so low intensity isn't too faded, but color shift does the work */
    opacity: calc(0.5 + (var(--intensity, 0) * 0.5));
}

.pnl-negative {
    /* Red: Hue 350. Lightness decreases as intensity increases */
    background-color: hsl(350, 80%, calc(50% - (var(--intensity, 0) * 30%)));
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #fff;
    opacity: calc(0.5 + (var(--intensity, 0) * 0.5));
}

/* --- LIST VIEW STYLES --- */
.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.list-item {
    display: grid;
    grid-template-columns: 100px 1fr 120px 40px;
    align-items: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.3);
    border-radius: 12px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.list-item:hover {
    background: rgba(15, 23, 42, 0.6);
    border-color: var(--glass-border);
}

.list-date {
    font-family: monospace;
    color: var(--text-secondary);
}

.list-desc {
    font-weight: 500;
}

/* FILTER CHIPS */
#client-chips-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.chip {
    padding: 8px 16px;
    border-radius: 6px;
    /* Boxy look */
    background: rgba(255, 255, 255, 0.05);
    /* Faint background */
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    color: var(--text-secondary);
    display: inline-block;
}

.chip:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
}

.chip.active {
    background: #3b82f6;
    /* Solid Blue */
    border-color: #3b82f6;
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
    opacity: 1;
}

.chip:not(.active) {
    opacity: 0.7;
    /* Slightly transparent when not selected */
}

.list-amount {
    font-weight: 700;
    text-align: right;
}

.list-amount.pos {
    color: var(--success);
}

.list-amount.neg {
    color: var(--danger);
}

/* --- HEATMAP STYLES --- */
#heatmap-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    /* Tighter gap */
    margin-bottom: 2rem;
    align-content: flex-start;
}

.pnl-box {
    width: 60px;
    /* FIXED WIDTH */
    height: 60px;
    /* FIXED HEIGHT */
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2px;
    transition: transform 0.1s;
    cursor: pointer;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: #1e293b;
    flex-shrink: 0;
    /* Prevent shrinking */
}

.pnl-box:hover {
    transform: scale(1.1);
    z-index: 10;
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.pnl-box.selected {
    border: 2px solid #fff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.pnl-box .date {
    font-size: 0.65rem;
    /* Reduced from 0.7rem */
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-secondary);
}

.pnl-box .amount {
    font-size: 0.7rem;
    /* Reduced from 0.75rem */
    font-weight: 700;
    line-height: 1;
}

.pnl-positive {
    color: var(--success);
    border-color: rgba(34, 197, 94, 0.3);
}

.pnl-negative {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    display: none;
    opacity: 0;
}

.modal {
    width: 90%;
    max-width: 500px;
    padding: 0;
    overflow: hidden;
}

.modal-header {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 2rem;
}

.modal-footer {
    padding: 1rem;
    text-align: right;
    background: rgba(0, 0, 0, 0.2);
}

.btn {
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: #2563eb;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

/* --- TABLE BORDERS (Added per request) --- */
#ledger-table {
    border-collapse: collapse;
    width: 100%;
}

#ledger-table th,
#ledger-table td {
    border: 1px solid rgba(255, 255, 255, 0.1);
    /* Subtle separation */
    padding: 0.75rem 1rem;
}

#ledger-table th {
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    border-top: none;
    /* Cleaner look */
}

#ledger-table tr:last-child td {
    border-bottom: none;
}

/* --- CUSTOM DROPDOWN (Added per request) --- */
.custom-dropdown {
    position: relative;
    user-select: none;
}

.dropdown-trigger {
    width: 100%;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: white;
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.dropdown-trigger:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.dropdown-menu {
    position: absolute;
    top: 110%;
    /* Just below the trigger */
    left: 0;
    width: 100%;
    background: #1e293b;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    /* High z-index to float above everything */
    max-height: 300px;
    overflow-y: auto;
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dropdown-menu.hidden {
    display: none;
}

.dropdown-item {
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.dropdown-item.selected {
    background: rgba(59, 130, 246, 0.2);
    color: white;
    font-weight: 500;
}

.dropdown-item .check {
    width: 16px;
    height: 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}


.dropdown-item.selected .check {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

/* --- TOAST NOTIFICATION (v8.1) --- */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--primary);
    border-left: 4px solid var(--primary);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 2000;
    transform: translateY(150%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-notification.show {
    transform: translateY(0);
}

.toast-notification span {
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
}

.toast-notification button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s;
}

.toast-notification button:hover {
    background: #2563eb;
}