:root {
    /* Brand New Luxury Indigo Palette */
    --bg-main: #0c0b11; 
    --bg-panel: rgba(22, 19, 32, 0.65);
    --bg-input: rgba(255, 255, 255, 0.03);
    --bg-input-hover: rgba(255, 255, 255, 0.06);
    --border-color: rgba(255, 255, 255, 0.05);
    
    --text-primary: #f8fafc;
    --text-muted: #8b8996;
    
    --accent-blue: #dc2626; /* Ruby Red */
    --accent-blue-hover: #ef4444; /* Lighter Red */
    --accent-blue-subtle: rgba(220, 38, 38, 0.15);
    
    --accent-success: #10b981; /* Emerald for profit */
    --accent-danger: #f43f5e; /* Rose for loss */
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-pill: 99px;
    
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 4px 25px rgba(220, 38, 38, 0.45);
    
    --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --font-body: 'Inter', sans-serif;
}

/* Light Mode Overrides */
body.light-mode {
    --bg-main: #f1f5f9;
    --bg-panel: rgba(255, 255, 255, 0.85);
    --bg-input: rgba(15, 23, 42, 0.05);
    --bg-input-hover: rgba(15, 23, 42, 0.08);
    --border-color: rgba(15, 23, 42, 0.1);
    
    --text-primary: #0f172a;
    --text-muted: #64748b;
    
    --accent-blue-subtle: rgba(220, 38, 38, 0.15);
    background-image: none;
}
body.light-mode .stat-card, body.light-mode .house-card, body.light-mode .modal-content {
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}
body.light-mode .txt-success {
    text-shadow: none;
    font-weight: 800;
}
body.light-mode .btn-outline {
    background-color: white;
}
body.light-mode .btn-outline:hover {
    background-color: var(--bg-input);
}
body.light-mode .form-group input, body.light-mode .form-group textarea {
    background-color: white;
    border: 1px solid var(--border-color);
}
body.light-mode .login-panel {
    background-color: white;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

/* Cyber Mode Overrides */
body.cyber-mode {
    --bg-main: #030305;
    --bg-panel: rgba(5, 5, 10, 0.7);
    --bg-input: rgba(14, 165, 233, 0.05);
    --bg-input-hover: rgba(14, 165, 233, 0.1);
    --border-color: rgba(14, 165, 233, 0.25);
    
    --text-primary: #e0f2fe;
    --text-muted: #7dd3fc;
    
    --accent-blue: #0ea5e9; /* Cyber Cyan */
    --accent-blue-hover: #38bdf8;
    --accent-blue-subtle: rgba(14, 165, 233, 0.15);
    
    --accent-success: #059669; /* Neon Emerald */
    --accent-danger: #e11d48; /* Neon Rose */
    
    --shadow-soft: 0 0 15px rgba(14, 165, 233, 0.1);
    --shadow-glow: 0 0 20px rgba(14, 165, 233, 0.6);
    
    background-image: linear-gradient(0deg, rgba(14, 165, 233, 0.05) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(14, 165, 233, 0.05) 1px, transparent 1px);
    background-size: 30px 30px;
    font-family: 'Space Grotesk', 'Inter', sans-serif; /* Fallback to Inter if space grotesk not available */
}
body.cyber-mode .stat-card, body.cyber-mode .house-card, body.cyber-mode .modal-content, body.cyber-mode .panel {
    border: 1px solid var(--border-color);
    box-shadow: inset 0 0 20px rgba(14, 165, 233, 0.05), var(--shadow-soft);
}
body.cyber-mode .btn-primary {
    background: transparent;
    border: 1px solid var(--accent-blue);
    box-shadow: inset 0 0 10px rgba(14, 165, 233, 0.3), var(--shadow-glow);
    color: var(--accent-blue);
}
body.cyber-mode .btn-primary:hover {
    background: rgba(14, 165, 233, 0.2);
    box-shadow: inset 0 0 20px rgba(14, 165, 233, 0.5), var(--shadow-glow);
}
body.cyber-mode * {
    letter-spacing: 0.02em;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: var(--font-body); }
body { 
    background-color: var(--bg-main); 
    background-image: radial-gradient(circle at 10% 20%, rgba(220, 38, 38, 0.03) 0%, transparent 40%),
                      radial-gradient(circle at 90% 80%, rgba(220, 38, 38, 0.03) 0%, transparent 40%);
    color: var(--text-primary); 
    min-height: 100vh; 
}

.text-muted { color: var(--text-muted); font-size: 0.875rem; }
.txt-success { color: var(--accent-success) !important; text-shadow: 0 0 10px rgba(16, 185, 129, 0.2); }
.txt-danger { color: var(--accent-danger) !important; }
.txt-blue { color: #3b82f6 !important; text-shadow: 0 0 10px rgba(59, 130, 246, 0.2); }
.mb-4 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }

/* Panels = Glassmorphism */
.panel {
    background-color: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-soft);
}

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border-radius: var(--radius-md); font-size: 0.875rem; font-weight: 600;
    cursor: pointer; transition: all var(--transition); border: none; outline: none;
}
.btn-primary { 
    background: linear-gradient(135deg, var(--accent-blue), #4f46e5);
    color: white; 
    box-shadow: var(--shadow-glow);
}
.btn-primary:hover { 
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(220, 38, 38, 0.6); 
}
.btn-secondary { background-color: var(--bg-input); color: var(--text-primary); }
.btn-secondary:hover { background-color: var(--bg-input-hover); }
.btn-outline { background-color: transparent; color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-outline:hover { background-color: var(--bg-input); border-color: transparent;}
.btn-icon { background: transparent; border: none; cursor: pointer; color: var(--text-muted); transition: color var(--transition); }
.btn-icon:hover { color: var(--accent-blue-hover); }
.circle-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border-color); background-color: var(--bg-main); display: flex; align-items: center; justify-content: center; transition: all var(--transition);}
.circle-btn:hover { background-color: var(--accent-blue-subtle); border-color: var(--accent-blue); color: var(--accent-blue); }
.btn-text { background: transparent; border: none; color: var(--text-primary); cursor: pointer; font-size: 0.875rem; display: inline-flex; align-items: center; gap: 8px; font-weight: 500;}
.btn-text.text-muted { color: var(--text-muted); }
.btn-text:hover { color: var(--accent-blue); }
.text-hover-danger { transition: color var(--transition); }
.text-hover-danger:hover { color: var(--accent-danger) !important; }

.login-wrapper { height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-panel { width: 100%; max-width: 420px; }

.app-container { max-width: 1400px; margin: 0 auto; padding: 32px 24px; }

.top-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; }
.header-left, .header-right { display: flex; align-items: center; gap: 16px; }

.filters-row { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.btn-filter { background-color: transparent; border: 1px solid var(--border-color); color: var(--text-primary); padding: 8px 16px; border-radius: var(--radius-pill); font-weight: 500; font-size: 0.875rem;}
.btn-filter.active { background-color: var(--accent-blue-subtle); color: var(--accent-blue-hover); border-color: transparent; }
.date-picker-group { display: flex; align-items: center; gap: 8px; }
.date-input { display: flex; align-items: center; gap: 8px; background-color: var(--bg-input); border: 1px solid transparent; padding: 8px 16px; border-radius: var(--radius-pill); }
.date-input i { color: var(--accent-blue); }
.date-input input { background: transparent; border: none; color: var(--text-primary); outline: none; font-size: 0.875rem; width: 85px; }
.date-input input::placeholder { color: var(--text-muted); }

.chart-section { margin-bottom: 40px; }
.chart-panel { min-height: 380px; padding: 24px; }
@media (max-width: 1024px) {
    .chart-section { grid-template-columns: 1fr !important; }
}
.section-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 20px; letter-spacing: -0.02em; }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 40px; }
.stat-card { background-color: var(--bg-panel); backdrop-filter: blur(12px); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 24px; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; transition: transform var(--transition); }
.stat-card:hover { transform: translateY(-3px); border-color: var(--accent-blue); }
.stat-card::after { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--accent-blue); opacity: 0; transition: opacity var(--transition); }
.stat-card:hover::after { opacity: 1; }
.stat-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.stat-label { color: var(--text-muted); font-size: 0.875rem; font-weight: 500; }
.stat-header i { font-size: 1.25rem; color: var(--accent-blue-hover); opacity: 0.7;}
.stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1.2; letter-spacing: -0.03em; }

.houses-controls { display: flex; justify-content: space-between; margin-bottom: 24px; }
.search-bar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; width: 350px; border-radius: var(--radius-pill); }
.search-bar input { background: transparent; border: none; outline: none; color: var(--text-primary); width: 100%; font-size: 0.95rem; }
.select-wrapper select { background: transparent; border: none; color: var(--text-primary); outline: none; cursor: pointer; font-weight: 500; }

.houses-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 24px; }
.house-card { background-color: var(--bg-panel); backdrop-filter: blur(10px); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 24px; transition: all var(--transition); cursor: pointer; }
.house-card:hover { border-color: var(--accent-blue); transform: translateY(-4px); box-shadow: 0 12px 40px rgba(0,0,0, 0.4); }
.house-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.house-title { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }
.house-meta { display: flex; align-items: center; gap: 12px; font-size: 0.8rem; color: var(--text-muted); font-weight: 500;}
.house-delete { background: var(--bg-input); padding: 6px; border-radius: var(--radius-md); }
.house-delete:hover { color: white; background: var(--accent-danger); }
.house-stats { display: flex; flex-direction: column; gap: 14px; }
.h-stat-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; }
.h-stat-label { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-weight: 500; }
.h-stat-value { font-weight: 700; }

/* Details View Specifics */
.details-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.details-titles h1 { font-size: 2rem; font-weight: 800; margin-bottom: 6px; letter-spacing: -0.04em; }
.tabs-row { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 20px; margin-bottom: 32px; }
.tabs-left { display: flex; gap: 12px; }
.btn-tab { padding: 8px 20px; border-radius: var(--radius-pill); font-size: 0.875rem; font-weight: 600; border: 1px solid transparent; background: transparent; color: var(--text-muted); cursor: pointer; transition: all var(--transition); }
.btn-tab.active { background: var(--accent-blue-subtle); color: var(--accent-blue-hover); border-color: var(--accent-blue); }
.btn-tab.text-muted { border-color: var(--border-color); }
.btn-tab.text-muted:hover { background: var(--bg-input); }

.contas-controls { display: flex; gap: 12px; align-items: center; }
.dark-select { 
    background-color: var(--bg-input); 
    color: var(--text-primary); 
    border: 1px solid var(--border-color); 
    padding: 8px 16px; 
    border-radius: var(--radius-md); 
    outline: none; 
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.dark-select:hover {
    background-color: var(--bg-input-hover);
}
.dark-select option {
    background-color: #1a1726; /* Darker fixed color for dropdown compatibility */
    color: white;
}
body.light-mode .dark-select option {
    background-color: white;
    color: #0f172a;
}

table { width: 100%; border-collapse: separate; border-spacing: 0 8px; text-align: left; }
th { color: var(--text-muted); font-size: 0.8rem; font-weight: 600; padding: 0 16px 8px 16px; text-transform: uppercase; letter-spacing: 0.05em; border: none;}
td { padding: 4px; border: none; }

/* Redesigned to isolated pills */
tbody tr { background: transparent; transition: all var(--transition); border-radius: var(--radius-md); }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
tbody td:first-child { padding-left: 12px; }
tbody td:last-child { padding-right: 12px; }

.inline-input { 
    background-color: var(--bg-input); border: 1px solid transparent; 
    color: var(--text-primary); padding: 10px 16px; border-radius: var(--radius-pill); 
    width: 100%; max-width: 110px; outline: none; transition: all var(--transition);
    font-weight: 500; font-size: 0.9rem;
}
.inline-input:focus { background-color: var(--bg-panel); border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--accent-blue-subtle); }
.inline-input:hover:not(:focus) { background-color: var(--bg-input-hover); }
.inline-input.no-border { width: 100%; max-width: none; border-radius: var(--radius-md); font-size: 1rem; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 100; opacity: 0; visibility: hidden; transition: all var(--transition); }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-content { width: 100%; max-width: 420px; padding: 32px; transform: scale(0.95); transition: all var(--transition); background-color: var(--bg-panel); border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius-lg); box-shadow: 0 25px 50px rgba(0,0,0,0.5); }
.modal-overlay.active .modal-content { transform: scale(1); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-header h2 { font-size: 1.5rem; letter-spacing: -0.03em;}
.close-btn { background: var(--bg-input); border: none; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-muted); cursor: pointer; transition: all var(--transition); }
.close-btn:hover { background: var(--bg-input-hover); color: white; }
.form-group { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.form-group label { font-size: 0.9rem; color: var(--text-muted); font-weight: 500; }
.form-group input { background-color: rgba(0,0,0,0.2); border: 1px solid var(--border-color); padding: 12px 16px; border-radius: var(--radius-md); color: var(--text-primary); font-size: 1rem; outline: none; transition: all var(--transition);}
.form-group input:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--accent-blue-subtle);}
.form-group textarea { background-color: rgba(0,0,0,0.2); border: 1px solid var(--border-color); padding: 16px; border-radius: var(--radius-md); color: var(--text-primary); font-size: 0.95rem; line-height: 1.5; outline: none; transition: all var(--transition); resize: vertical;}
.form-group textarea:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--accent-blue-subtle);}
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; }

/* House Switcher Dropdown */
.house-switcher-wrapper {
    position: relative;
    display: inline-block;
}
.house-switcher-btn {
    font-size: 0.8rem !important;
    padding: 7px 14px !important;
    border-radius: var(--radius-pill) !important;
    gap: 6px !important;
}
.house-switcher-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 300px;
    max-height: 420px;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 200ms ease;
    overflow: hidden;
}
.house-switcher-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.house-switcher-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 16px 10px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}
.house-switcher-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
}
.house-switcher-search input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    width: 100%;
}
.house-switcher-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 6px;
}
.house-switcher-list::-webkit-scrollbar {
    width: 4px;
}
.house-switcher-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 99px;
}
.house-switcher-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 150ms ease;
    gap: 12px;
}
.house-switcher-item:hover {
    background: var(--bg-input-hover);
}
.house-switcher-item.active {
    background: var(--accent-blue-subtle);
    border: 1px solid var(--accent-blue);
}
.house-switcher-item .hs-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.house-switcher-item .hs-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.house-switcher-item .hs-icon {
    font-size: 1.1rem;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    flex-shrink: 0;
}
.house-switcher-item.active .hs-icon {
    background: var(--accent-blue);
    color: white;
}
.house-switcher-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Mobile responsive adjustments for new features */
@media (max-width: 768px) {
    .house-switcher-dropdown {
        width: 260px;
    }
    .house-switcher-btn span {
        display: none;
    }
    .contas-controls {
        flex-wrap: wrap;
    }
}
