/* --- MAC-STYLE MINIMALIST THEME --- */
:root {
    --bg-primary: #F5F5F7; /* Apple's signature light gray */
    --bg-secondary: rgba(255, 255, 255, 0.7); /* Translucent white for panels */
    --text-primary: #1D1D1F; /* Apple text color */
    --text-secondary: #86868B;
    --accent-gold: #0066CC; /* Changed to macOS default highlight blue for realism, but keeping var name for logic */
    --accent-gold-light: #EBF3FC;
    --accent-gold-hover: #0055AB;
    --border-color: rgba(0, 0, 0, 0.08); /* Very subtle borders */
    --border-light: rgba(255, 255, 255, 0.6);
    --success-color: #34C759; /* macOS Green */
    --error-color: #FF3B30; /* macOS Red */
    --sidebar-bg: rgba(245, 245, 247, 0.6);
    --header-bg: rgba(255, 255, 255, 0.5);
    
    /* WhatsApp Chat Colors adapted for Mac */
    --chat-bg: rgba(245, 245, 247, 0.5); 
    --bubble-user: #007AFF; /* iMessage Blue */
    --bubble-ai: rgba(255, 255, 255, 0.85); 
    
    --shadow-sm: 0 4px 10px rgba(0,0,0,0.03);
    --shadow-md: 0 10px 40px rgba(0,0,0,0.08);
    --radius-md: 14px; /* Slightly rounder like macOS Big Sur+ */
}

/* --- DARK MODE OVERRIDES --- */
body.dark-mode {
    --bg-primary: #1E1E1E;
    --bg-secondary: #2C2C2E;
    --text-primary: #F5F5F7;
    --text-secondary: #98989D;
    --border-color: rgba(255, 255, 255, 0.1);
    --border-light: rgba(255, 255, 255, 0.05);
    --sidebar-bg: rgba(30, 30, 30, 0.8);
    --header-bg: rgba(44, 44, 46, 0.8);
    --chat-bg: rgba(30, 30, 30, 0.5); 
    --bubble-ai: rgba(60, 60, 62, 0.9); 
    --shadow-sm: 0 4px 10px rgba(0,0,0,0.2);
    --shadow-md: 0 10px 40px rgba(0,0,0,0.4);
}

/* --- TOGGLE SWITCH UI --- */
.switch { position: relative; display: inline-block; width: 34px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: white; transition: .4s; }
input:checked + .slider { background-color: var(--accent-gold); }
input:checked + .slider:before { transform: translateX(14px); }
.slider.round { border-radius: 20px; }
.slider.round:before { border-radius: 50%; }

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

/* FIX VISUAL DANCING / MAC-LIKE SCROLLBARS */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.15); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.3); border: 2px solid transparent; background-clip: content-box; }
body.dark-mode ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border: 2px solid transparent; background-clip: content-box; }
body.dark-mode ::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); border: 2px solid transparent; background-clip: content-box; }

html { scrollbar-gutter: stable; }

body { background-color: var(--bg-primary); color: var(--text-primary); font-size: 14px; overflow: hidden; height: 100vh; }
body.landing-mode { overflow-y: auto !important; overflow-x: hidden !important; height: auto !important; }

.app-container { display: flex; height: 100vh; width: 100vw; }

/* --- SIDEBAR --- */
.sidebar { width: 260px; background-color: var(--sidebar-bg); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; transition: width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); box-shadow: 1px 0 15px rgba(0,0,0,0.02); z-index: 10; }
.sidebar.collapsed { width: 80px; }
.sidebar.collapsed .logo-text, .sidebar.collapsed .trigger-text, .sidebar.collapsed .menu-text { display: none; }
.sidebar.collapsed .menu-item { justify-content: center; padding: 1rem; }
.sidebar.collapsed .trigger-btn { border-radius: 50%; width: 50px; height: 50px; padding: 1rem; margin: 0 auto 1.5rem auto; justify-content: center; }
.sidebar.collapsed .submenu { margin-left: 0; border: none; padding-left: 0; }
.sidebar.collapsed .submenu .menu-item { justify-content: center; padding: 0.5rem; }

.logo { padding: 1.5rem; display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 1.2rem; color: var(--accent-gold); border-bottom: 1px solid var(--border-color); }
.logo i { font-size: 1.5rem; }

.sidebar-menu { padding: 1rem 0; flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.25rem; }
.menu-item { display: flex; align-items: center; padding: 0.75rem 1.5rem; color: var(--text-secondary); text-decoration: none; transition: all 0.2s; font-weight: 500; border-left: 3px solid transparent; }
.menu-item i { width: 24px; font-size: 1.1rem; margin-right: 12px; text-align: center; }
.menu-item:hover { background-color: var(--bg-primary); color: var(--text-primary); }
.menu-item.active { background-color: var(--accent-gold-light); color: var(--accent-gold-hover); border-left-color: var(--accent-gold); font-weight: 600; }
.menu-label { font-size: 0.75rem; text-transform: uppercase; color: var(--text-secondary); font-weight: 700; margin: 1rem 1.5rem 0.5rem 1.5rem; letter-spacing: 0.5px; }
.sidebar.collapsed .menu-label { display: none; }

.spacer { flex-grow: 1; }

.trigger-btn { margin: 1.5rem; padding: 1rem; background-color: var(--accent-gold); color: white; border: none; border-radius: var(--radius-md); cursor: pointer; font-weight: 600; transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 0.75rem; box-shadow: 0 4px 12px rgba(192, 152, 88, 0.3); }
.trigger-btn:hover { background-color: var(--accent-gold-hover); transform: translateY(-1px); }

/* --- MAIN LAYOUT --- */
.main-content { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; padding: 1rem; }
.view-section { display: none; height: 100%; width: 100%; flex-direction: column; }
.view-section.active { display: flex; }

.horizontal-split-container { display: flex; flex-direction: column; height: 100%; width: 100%; gap: 1rem; }
.top-horizontal-pane { display: flex; flex-direction: row; height: 55%; gap: 1rem; min-height: 300px; }
.bottom-horizontal-pane { height: 45%; display: flex; flex-direction: column; overflow: hidden; border-radius: var(--radius-md); }

.glass-panel { background: var(--bg-secondary); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px); border-radius: var(--radius-md); border: 1px solid var(--border-color); border-top: 1px solid var(--border-light); box-shadow: var(--shadow-md); display: flex; flex-direction: column; overflow: hidden; }
.panel-header { padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--border-color); background: var(--header-bg); display: flex; align-items: center; justify-content: space-between; }
.panel-header h2 { font-size: 1rem; font-weight: 600; color: var(--text-primary); }

/* MacOS Window Controls */
.mac-window-controls { display: flex; gap: 8px; margin-right: 15px; }
.mac-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.mac-close { background-color: #FF5F56; border: 1px solid #E0443E; }
.mac-min { background-color: #FFBD2E; border: 1px solid #DEA123; }
.mac-max { background-color: #27C93F; border: 1px solid #1AAB29; }

.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.hidden { display: none !important; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }

/* --- WHATSAPP CHAT --- */
.chat-container { flex: 0 0 40%; display: flex; flex-direction: column; background-color: var(--chat-bg); }
.chat-messages-area { flex-grow: 1; background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png'); background-size: contain; background-repeat: repeat; opacity: 0.8; position: relative; overflow-y: auto; display: flex; flex-direction: column; padding: 1rem; gap: 0.75rem; }

.chat-bubble { max-width: 85%; padding: 0.5rem 0.75rem; border-radius: 8px; position: relative; box-shadow: var(--shadow-sm); font-size: 0.95rem; line-height: 1.4; word-wrap: break-word; }
.chat-sender { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.25rem; }
.chat-bubble.user { color: white; background-color: var(--bubble-user); align-self: flex-end; border-bottom-right-radius: 4px; border-top-right-radius: 18px; border-top-left-radius: 18px; border-bottom-left-radius: 18px; padding: 0.6rem 1rem; }
.chat-bubble.ai { background-color: var(--bubble-ai); align-self: flex-start; border-bottom-left-radius: 4px; border-top-right-radius: 18px; border-top-left-radius: 18px; border-bottom-right-radius: 18px; padding: 0.6rem 1rem; box-shadow: 0 1px 5px rgba(0,0,0,0.06); border: 1px solid rgba(0,0,0,0.03); }
.chat-bubble.user .chat-time { color: rgba(255,255,255,0.8); }
.chat-bubble.user .chat-sender { display: none; }
.chat-time { float: right; font-size: 0.7rem; color: var(--text-secondary); margin-left: 0.5rem; margin-top: 0.5rem; }

.doc-attachment { display: flex; align-items: center; background-color: rgba(0,0,0,0.04); border-radius: 6px; padding: 0.5rem; margin-top: 0.5rem; cursor: pointer; transition: all 0.2s; border: 1px solid transparent; }
.doc-attachment:hover { background-color: #FFFFFF; border-color: var(--accent-gold); box-shadow: var(--shadow-sm); }
.doc-attachment i { font-size: 1.8rem; color: #EF4444; margin-right: 0.75rem; }
.doc-info h4 { font-size: 0.85rem; margin: 0; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.doc-info span { font-size: 0.75rem; color: var(--text-secondary); }

.chat-input-area { padding: 0.75rem; background: var(--bg-secondary); display: flex; gap: 0.5rem; align-items: center; border-top: 1px solid var(--border-color); }
.chat-input-area input { flex-grow: 1; border: none; background: var(--bg-primary); padding: 0.75rem 1rem; border-radius: 20px; outline: none; font-size: 0.95rem; }
.send-btn { background: var(--accent-gold); color: white; border: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.send-btn:hover { background: var(--accent-gold-hover); transform: scale(1.05); }

/* --- PDF VIEWER --- */
.pdf-container { flex: 1; display: flex; flex-direction: column; }
.pdf-container iframe { width: 100%; height: 100%; border: none; flex-grow: 1; }
.status-badge { padding: 0.25rem 0.5rem; border-radius: 12px; font-size: 0.75rem; font-weight: 600; }
.status-pending { background-color: #FEF3C7; color: #D97706; }
.status-accounted { background-color: #D1FAE5; color: #059669; }

/* --- SAGE GRID --- */
.sage-grid-wrapper { display: flex; flex-direction: column; height: 100%; }
.sage-grid-content { flex-grow: 1; overflow-y: auto; padding: 0.5rem; }
.sage-grid { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.sage-grid th { background-color: var(--bg-primary); padding: 0.5rem; text-align: left; font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid var(--border-color); position: sticky; top: 0; z-index: 5; }
.sage-grid td { padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.sage-grid input { width: 100%; padding: 0.4rem 0.5rem; border: 1px solid transparent; border-radius: 4px; background: transparent; transition: all 0.2s; font-family: 'Inter', sans-serif; font-size: 0.95rem; }
.sage-grid input:focus { background: var(--bg-secondary); border-color: var(--accent-gold); outline: none; box-shadow: 0 0 0 2px var(--accent-gold-light); }
.sage-grid input.account-input { font-family: monospace; font-size: 1rem; font-weight: 600; color: var(--accent-gold); letter-spacing: 1px; }
.sage-grid input.amount-input { text-align: right; }

.journal-footer { padding: 0.75rem 1.5rem; border-top: 1px solid var(--border-color); background: var(--bg-primary); display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.totals-display { display: flex; gap: 1.5rem; font-weight: 600; font-size: 1.1rem; }
.debit-color { color: var(--text-primary); }
.credit-color { color: var(--text-primary); }
.diff-color { color: var(--error-color); }

.primary-btn { padding: 0.6rem 1.5rem; background: var(--accent-gold); color: white; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 0.5rem; }
.primary-btn:hover { background: var(--accent-gold-hover); transform: translateY(-1px); }
.primary-btn:disabled { background: var(--text-secondary); cursor: not-allowed; transform: none; opacity: 0.7; }

/* Lists (Pendientes / Contabilizados) */
.document-list { display: flex; flex-direction: column; gap: 0.75rem; padding: 1.5rem; overflow-y: auto; height: 100%; max-width: 800px; margin: 0 auto; width: 100%; }
.document-item { display: flex; align-items: center; padding: 1.25rem; border-radius: var(--radius-md); background: var(--bg-secondary); border: 1px solid var(--border-color); cursor: pointer; transition: 0.2s; box-shadow: var(--shadow-sm); }
.document-item:hover { border-color: var(--accent-gold); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.document-item.accounted { border-left: 4px solid var(--success-color); }
.document-item.pending { border-left: 4px solid var(--error-color); }

/* Mac Segmented Control */
.mac-segmented-control { display: flex; background: rgba(0, 0, 0, 0.05); padding: 4px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.05); }
.mac-segmented-control button { background: transparent; border: none; cursor: pointer; padding: 0.4rem 1rem; border-radius: 6px; font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); transition: all 0.2s; box-shadow: none; }
.mac-segmented-control button:hover { color: var(--text-primary); }
.mac-segmented-control button.active { background: #007AFF; color: white; box-shadow: 0 1px 4px rgba(0,0,0,0.15); font-weight: 600; }

.document-icon { font-size: 1.8rem; color: var(--text-secondary); width: 60px; text-align: center; }
.document-details { flex-grow: 1; }
.document-details h4 { font-size: 1.1rem; color: var(--text-primary); margin-bottom: 0.25rem; }
.document-details p { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.25rem; }
.document-seat { font-weight: bold; font-family: monospace; color: var(--success-color); font-size: 0.85rem; background: var(--bg-primary); padding: 0.25rem 0.5rem; border-radius: 4px; }

/* Modals */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.modal { background: var(--bg-secondary); width: 90%; max-width: 500px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; max-height: 90vh; }
.modal-header { padding: 1.25rem; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 1.25rem; overflow-y: auto; }
.account-list { list-style: none; margin-top: 1rem; max-height: 300px; overflow-y: auto; }
.account-list li { padding: 0.75rem; border-bottom: 1px solid var(--border-color); cursor: pointer; display: flex; justify-content: space-between; }
.account-list li:hover { background-color: var(--bg-primary); }
.icon-btn { background: transparent; border: none; cursor: pointer; color: var(--text-secondary); font-size: 1.1rem; transition: 0.2s; }
.icon-btn:hover { color: var(--text-primary); }

.search-box { display: flex; align-items: center; background: var(--bg-primary); padding: 0.75rem 1rem; border-radius: 8px; border: 1px solid var(--border-color); }
.search-box input { border: none; background: transparent; margin-left: 0.5rem; outline: none; width: 100%; }

/* Intro Overlay */
.intro-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--bg-primary); z-index: 2000; display: flex; justify-content: center; align-items: center; transition: opacity 0.5s; }
.login-container { width: 100%; max-width: 480px; background: var(--bg-secondary); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 2.5rem; border: 1px solid var(--border-color); }
.login-header { text-align: center; margin-bottom: 2rem; }
.login-logo-icon { font-size: 3rem; color: var(--accent-gold); margin-bottom: 1rem; }
.login-title { font-size: 1.5rem; color: var(--text-primary); margin-bottom: 0.5rem; }
.login-subtitle { color: var(--text-secondary); font-size: 0.9rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.5rem; }
.form-control { width: 100%; padding: 0.75rem 1rem; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-primary); font-family: inherit; font-size: 1rem; color: var(--text-primary); outline: none; transition: 0.2s; }
.form-control:focus { border-color: var(--accent-gold); box-shadow: 0 0 0 3px var(--accent-gold-light); background: var(--bg-secondary); }
.login-footer { margin-top: 1.5rem; text-align: center; font-size: 0.8rem; color: var(--text-secondary); }

/* ===== AUTH OVERLAY ===== */
.auth-overlay { position: fixed; inset: 0; background: radial-gradient(ellipse at 30% 40%, #0A1628 0%, #111827 100%); display: flex; align-items: center; justify-content: center; z-index: 9999; transition: opacity 0.4s ease; }
.auth-card { background: rgba(255,255,255,0.05); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px); border: 1px solid rgba(255,255,255,0.1); border-radius: 28px; padding: 3rem 3.5rem; width: 100%; max-width: 500px; box-shadow: 0 30px 80px rgba(0,0,0,0.5); color: #F5F5F7; }
.auth-brand { text-align: center; margin-bottom: 2.25rem; }
.auth-logo-wrap { width: 72px; height: 72px; background: linear-gradient(135deg, #0066CC, #5AC8FA); border-radius: 20px; display: inline-flex; align-items: center; justify-content: center; font-size: 2rem; color: white; margin-bottom: 1.25rem; box-shadow: 0 8px 24px rgba(0,102,204,0.4); }
.auth-brand h1 { font-size: 1.6rem; font-weight: 700; color: #F5F5F7; margin: 0 0 0.35rem; }
.auth-brand p { color: #98989D; font-size: 0.9rem; margin: 0; }
.auth-tabs { display: flex; gap: 0.5rem; background: rgba(0,0,0,0.3); border-radius: 12px; padding: 0.35rem; margin-bottom: 2rem; }
.auth-tab { flex: 1; padding: 0.7rem; border: none; background: transparent; border-radius: 9px; cursor: pointer; color: #98989D; font-weight: 600; font-size: 0.9rem; transition: all 0.2s; }
.auth-tab.active { background: rgba(255,255,255,0.12); color: #F5F5F7; }
.auth-error { background: rgba(255,59,48,0.15); border: 1px solid rgba(255,59,48,0.3); color: #FF6B6B; border-radius: 10px; padding: 0.85rem 1.1rem; font-size: 0.85rem; margin-bottom: 1.25rem; }
.auth-form { display: flex; flex-direction: column; gap: 1.25rem; }
.auth-field { display: flex; flex-direction: column; gap: 0.5rem; }
.auth-field label { font-size: 0.8rem; font-weight: 600; color: #98989D; text-transform: uppercase; letter-spacing: 0.5px; }
.auth-field input { width: 100%; box-sizing: border-box; background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12); border-radius: 12px; padding: 0.9rem 1.1rem; color: #F5F5F7; font-size: 1rem; font-family: 'Inter', sans-serif; outline: none; transition: 0.2s; }
.auth-field input:focus { border-color: #0066CC; box-shadow: 0 0 0 3px rgba(0,102,204,0.2); }
.auth-field input::placeholder { color: rgba(255,255,255,0.25); }
.password-wrap { position: relative; display: flex; align-items: center; }
.password-wrap input { width: 100%; box-sizing: border-box; padding-right: 2.75rem; background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12); border-radius: 12px; padding: 0.9rem 2.75rem 0.9rem 1.1rem; color: #F5F5F7; font-family: 'Inter', sans-serif; font-size: 1rem; outline: none; transition: 0.2s; }
.password-wrap input:focus { border-color: #0066CC; box-shadow: 0 0 0 3px rgba(0,102,204,0.2); }
.toggle-pw { position: absolute; right: 0.85rem; background: none; border: none; color: #98989D; cursor: pointer; padding: 0.25rem; font-size: 1rem; transition: color 0.2s; }
.toggle-pw:hover { color: #F5F5F7; }
.auth-submit-btn { display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 1rem; background: linear-gradient(135deg, #0066CC, #0055AB); color: white; border: none; border-radius: 14px; font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.2s; margin-top: 0.5rem; font-family: 'Inter', sans-serif; }
.auth-submit-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0,102,204,0.4); }
.auth-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.auth-divider { display: flex; align-items: center; gap: 0.75rem; color: #98989D; font-size: 0.8rem; margin: 0.25rem 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,0.1); }
.auth-google-btn { display: flex; align-items: center; justify-content: center; gap: 0.75rem; padding: 0.85rem; background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12); border-radius: 14px; color: #F5F5F7; font-size: 0.95rem; font-weight: 500; cursor: pointer; font-family: 'Inter', sans-serif; transition: all 0.2s; }
.auth-google-btn:hover { background: rgba(255,255,255,0.12); }
.mode-selector { display: flex; gap: 0.75rem; }
.mode-option { flex: 1; display: flex; }
.mode-option input { display: none; }
.mode-option span { flex: 1; display: flex; gap: 0.5rem; align-items: center; justify-content: center; padding: 0.65rem; background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12); border-radius: 10px; cursor: pointer; font-size: 0.85rem; color: #98989D; transition: all 0.2s; }
.mode-option input:checked + span { background: rgba(0,102,204,0.2); border-color: #0066CC; color: #F5F5F7; }
.auth-footer { text-align: center; margin-top: 2rem; font-size: 0.78rem; color: rgba(255,255,255,0.25); }


/* Toasts */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }

/* ===== BANK PORTAL (Kutxabank Empresas Style) ===== */
.bank-portal { display: flex; flex-direction: column; height: 100%; background: #0A1628; color: #E8EBF0; overflow: hidden; }
/* Top bar */
.bank-topbar { display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; height: 58px; background: #0E1E35; border-bottom: 1px solid rgba(255,255,255,0.07); flex-shrink: 0; }
.bank-brand { display: flex; align-items: center; gap: 0.85rem; }
.bank-logo-icon { width: 40px; height: 40px; background: linear-gradient(135deg, #F26724, #E05A10); border-radius: 10px; display: flex; align-items: center; justify-content: center; color: white; font-weight: 900; font-size: 1.2rem; box-shadow: 0 4px 12px rgba(242,103,36,0.4); }
.bank-brand-text { display: flex; flex-direction: column; }
.bank-name { font-weight: 700; font-size: 0.95rem; color: #E8EBF0; }
.bank-entity { font-size: 0.72rem; color: #7A8BA0; }
.bank-topbar-actions { display: flex; gap: 0.5rem; }
.bank-topbar-btn { display: flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.9rem; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; color: #C8D0DC; font-size: 0.82rem; font-weight: 500; cursor: pointer; font-family: 'Inter', sans-serif; transition: all 0.2s; }
.bank-topbar-btn:hover { background: rgba(255,255,255,0.12); color: white; }
.bank-topbar-btn.accent { background: #F26724; border-color: transparent; color: white; }
.bank-topbar-btn.accent:hover { background: #E05A10; }
/* Balance section */
.bank-balance-section { display: grid; grid-template-columns: 1fr auto; gap: 1.25rem; padding: 1.25rem 1.5rem; flex-shrink: 0; }
.bank-balance-card { background: linear-gradient(135deg, #0E2A4A 0%, #163A5F 100%); border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; padding: 1.25rem 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.bank-balance-header { display: flex; justify-content: space-between; align-items: flex-start; }
.bank-account-label { font-size: 0.78rem; font-weight: 600; color: #7A8BA0; text-transform: uppercase; letter-spacing: 0.5px; }
.bank-iban { font-size: 0.85rem; color: #C8D0DC; font-family: 'Courier New', monospace; margin-top: 0.2rem; letter-spacing: 1px; }
.bank-balance-tag { display: flex; align-items: center; gap: 0.3rem; font-size: 0.72rem; color: #34D399; background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.25); padding: 0.2rem 0.6rem; border-radius: 20px; white-space: nowrap; }
.bank-balance-amount { font-size: 2.2rem; font-weight: 700; color: white; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.bank-balance-footer { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; color: #7A8BA0; }
.bank-balance-date { font-style: italic; }
/* Quick stat chips */
.bank-quick-stats { display: flex; flex-direction: column; gap: 0.6rem; min-width: 200px; }
.bank-stat-card { display: flex; align-items: center; gap: 0.75rem; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07); border-radius: 12px; padding: 0.75rem 1rem; }
.bank-stat-card i { font-size: 1rem; flex-shrink: 0; }
.bank-stat-label { font-size: 0.72rem; color: #7A8BA0; }
.bank-stat-value { font-size: 1rem; font-weight: 600; color: #E8EBF0; }
/* Movements */
.bank-movements-section { flex: 1; display: flex; flex-direction: column; padding: 0 1.5rem 1.5rem; min-height: 0; }
.bank-movements-header { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 0; margin-bottom: 0.5rem; }
.bank-movements-title { font-size: 0.9rem; font-weight: 600; color: #C8D0DC; display: flex; align-items: center; gap: 0.5rem; }
.bank-filter-pills { display: flex; gap: 0.4rem; }
.bank-pill { padding: 0.3rem 0.8rem; border-radius: 20px; border: 1px solid rgba(255,255,255,0.1); background: transparent; color: #7A8BA0; font-size: 0.78rem; cursor: pointer; font-family: 'Inter', sans-serif; transition: all 0.2s; }
.bank-pill.active, .bank-pill:hover { background: rgba(242,103,36,0.15); border-color: #F26724; color: #F2882A; }
.bank-table-wrap { flex: 1; overflow-y: auto; border-radius: 12px; border: 1px solid rgba(255,255,255,0.07); }
.bank-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.bank-table thead tr { background: rgba(255,255,255,0.04); }
.bank-table th { padding: 0.6rem 1rem; text-align: left; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: #7A8BA0; border-bottom: 1px solid rgba(255,255,255,0.07); }
.bank-table td { padding: 0.8rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.04); color: #C8D0DC; vertical-align: middle; }
.bank-table tbody tr:hover td { background: rgba(255,255,255,0.03); }
.bank-table tbody tr:last-child td { border-bottom: none; }
.bank-amount-in { color: #34D399; font-weight: 600; }
.bank-amount-out { color: #F87171; font-weight: 600; }
.bank-type-badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.72rem; font-weight: 500; }
.bank-type-badge.in { background: rgba(52,211,153,0.1); color: #34D399; }
.bank-type-badge.out { background: rgba(248,113,113,0.1); color: #F87171; }
.bank-empty { text-align: center; padding: 3rem; color: #7A8BA0; font-style: italic; }

/* ===== FACTURAS LUMINA MODULE ===== */
.lumina-inv-kpi { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 110px; text-align: center; padding: 0.4rem 0.75rem; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 10px; }
.lumina-inv-kpi-val { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }
.lumina-inv-kpi-label { font-size: 0.68rem; color: var(--text-secondary); margin-top: 0.1rem; }
.lumina-badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.72rem; font-weight: 600; white-space: nowrap; }
.lumina-badge.emitida { background: rgba(52,199,89,0.12); color: #34C759; }
.lumina-badge.pendiente { background: rgba(134,134,139,0.1); color: #86868B; }
.lumina-badge.vencida { background: rgba(255,59,48,0.12); color: #FF3B30; }
.lumina-action-btn { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.3rem 0.75rem; background: var(--accent-gold); color: white; border: none; border-radius: 7px; font-size: 0.78rem; font-weight: 600; cursor: pointer; font-family: 'Inter', sans-serif; transition: opacity 0.2s; white-space: nowrap; }
.lumina-action-btn:hover { opacity: 0.85; }
.lumina-row-alert td { background: rgba(255,59,48,0.04) !important; }
.form-control { width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-secondary); color: var(--text-primary); font-family: 'Inter', sans-serif; font-size: 0.9rem; outline: none; transition: border-color 0.2s; }
.form-control:focus { border-color: var(--accent-gold); }

/* ===== TUTOR IA WIDGET ===== */
#tutor-widget-container { position: fixed; bottom: 30px; right: 30px; z-index: 9999; display: flex; flex-direction: column; align-items: flex-end; gap: 15px; }
.tutor-fab-btn { width: 60px; height: 60px; border-radius: 50%; background: linear-gradient(135deg, #4F46E5, #3B82F6); color: white; border: none; font-size: 1.8rem; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 25px rgba(59, 130, 246, 0.5); transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); position: relative; }
.tutor-fab-btn:hover { transform: scale(1.1) translateY(-5px); box-shadow: 0 15px 35px rgba(59, 130, 246, 0.6); }
.tutor-fab-badge { position: absolute; top: -5px; right: -5px; background: #EF4444; color: white; font-size: 0.75rem; font-weight: bold; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 5px rgba(0,0,0,0.2); border: 2px solid var(--bg-primary); }
#tutor-chat-window { width: 380px; height: 500px; max-height: calc(100vh - 120px); resize: both; overflow: hidden; transform-origin: bottom right; animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; box-shadow: 0 20px 50px rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; position: absolute; bottom: 80px; right: 0; min-width: 300px; min-height: 400px; }
@keyframes popIn { 0% { opacity: 0; transform: scale(0.8) translateY(20px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }
#tutor-chat-messages { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; scrollbar-width: thin; }
#tutor-chat-messages .chat-bubble { max-width: 90%; font-size: 0.9rem; }
#tutor-chat-messages .chat-bubble.ai { background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.2); }
body.dark-mode #tutor-chat-messages .chat-bubble.ai { background: rgba(59, 130, 246, 0.15); border-color: rgba(59, 130, 246, 0.3); }

/* Table formatting for Tutor AI output */
.tutor-table { width: 100%; border-collapse: collapse; margin-top: 5px; font-size: 0.85rem; }
.tutor-table th { background: rgba(59, 130, 246, 0.2); text-align: left; padding: 4px 8px; border: 1px solid rgba(59, 130, 246, 0.3); color: var(--text-primary); }
.tutor-table td { border: 1px solid rgba(59, 130, 246, 0.2); padding: 4px 8px; }



/* =========================================================================
   MOBILE RESPONSIVENESS
   ========================================================================= */
@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        position: fixed;
        left: -300px; /* Hide off-screen by default */
        top: 0;
        bottom: 0;
        z-index: 1000;
        transition: left 0.3s ease;
        width: 280px;
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    }
    
    .sidebar:not(.sidebar-collapsed) {
        left: 0; /* Show when not collapsed! */
    }
    
    .main-content {
        width: 100%;
        margin-left: 0;
        padding: 10px;
    }
    
    /* Document View Header Mobile */
    .document-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    /* Layout split (PDF vs Right Panel) */
    .view-layout {
        flex-direction: column;
        overflow-y: auto;
    }
    
    .document-panel, .interaction-panel {
        width: 100%;
        height: 60vh; /* Give them fixed heights or let them expand */
        min-height: 400px;
    }

    /* Auth screen */
    .auth-card {
        width: 90%;
        padding: 1.5rem;
    }
    
    /* Add a floating button on mobile to open sidebar if it's hidden */
    #mobile-menu-btn {
        display: block !important;
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 999;
        background: var(--blue-accent);
        color: white;
        border-radius: 50%;
        width: 50px;
        height: 50px;
        display: flex;
        justify-content: center;
        align-items: center;
        box-shadow: 0 4px 10px rgba(0,0,0,0.3);
        border: none;
        cursor: pointer;
    }
}
@media (min-width: 901px) {
    #mobile-menu-btn {
        display: none !important;
    }
}

@media (max-width: 900px) {
    /* Mobile Split Overrides */
    
    .horizontal-split-container {
        display: flex;
        flex-direction: column;
        height: 100vh;
        overflow-y: auto;
    }
    
    .top-horizontal-pane {
        flex-direction: column;
        height: auto;
        min-height: unset;
        display: flex; /* force column flex */
    }
    
    .bottom-horizontal-pane {
        height: auto;
        min-height: 500px;
    }
    
    .chat-container {
        height: 40vh;
        width: 100%;
        margin-bottom: 10px;
    }
    
    /* PDF Container Collapsible Mobile Behavior */
    .pdf-container {
        width: 100%;
        height: 50px; /* Collapsed by default on mobile! */
        overflow: hidden;
        transition: height 0.3s ease;
        position: relative;
    }
    
    .pdf-container.expanded-mobile {
        height: 60vh;
    }
    
    .pdf-container .panel-header {
        cursor: pointer; /* Make header clickable to expand */
    }
    
    .pdf-container .panel-header::after {
        content: '▼ Tocar para ver PDF';
        font-size: 0.8rem;
        color: var(--blue-accent);
        font-weight: 600;
        margin-left: auto;
    }
    
    .pdf-container.expanded-mobile .panel-header::after {
        content: '▲ Ocultar PDF';
    }
    
    /* Facturas Lumina View Mobile */
    .facturas-layout {
        flex-direction: column;
    }
    
    .facturas-form-panel, .facturas-list-panel {
        width: 100% !important;
        height: auto !important;
    }

}
