* { box-sizing: border-box; margin: 0; padding: 0; }

/* Theme Variables */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #eee;
    --text-secondary: #aaa;
    --text-muted: #888;
    --accent: #e94560;
    --accent-hover: #ff6b6b;
    --border-color: #0f3460;
    --input-bg: #0f3460;
    --card-bg: #16213e;
    --success: #2ecc71;
    --shadow: rgba(0,0,0,0.3);
}

[data-theme="light"] {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8ecf1;
    --text-primary: #1a1a2e;
    --text-secondary: #555;
    --text-muted: #777;
    --accent: #e94560;
    --accent-hover: #d63850;
    --border-color: #ddd;
    --input-bg: #fff;
    --card-bg: #ffffff;
    --success: #27ae60;
    --shadow: rgba(0,0,0,0.1);
}

/* Theme Toggle Button - same style as sidebar-btn */
.sidebar-btn.theme-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.sidebar-btn.theme-toggle span {
    font-size: 14px;
}

/* Support Email */
.support-email {
    text-align: center;
    padding: 8px;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-secondary);
}

/* Light theme specific adjustments */
[data-theme="light"] input {
    border: 1px solid var(--border-color);
}
[data-theme="light"] .filter-group select,
[data-theme="light"] .filter-group input[type="text"] {
    border: 1px solid var(--border-color);
}
[data-theme="light"] .message.user {
    color: white;
}
[data-theme="light"] .google-btn {
    border: 1px solid var(--border-color) !important;
}
[data-theme="light"] code {
    color: var(--text-primary);
}
[data-theme="light"] .sidebar {
    box-shadow: 2px 0 10px var(--shadow);
}
[data-theme="light"] .toggle-sidebar {
    color: #1a1a2e !important;
    font-weight: bold;
}
[data-theme="light"] .toggle-sidebar:hover {
    background: #d0d5dd !important;
}
[data-theme="light"] .sidebar-btn {
    background: #e8eaed !important;
    color: #3c4043 !important;
}
[data-theme="light"] .sidebar-btn:hover {
    background: #dadce0 !important;
}
[data-theme="light"] .sidebar-btn.demo-btn {
    background: #e8f0fe !important;
    color: #1a56db !important;
}
[data-theme="light"] .sidebar-btn.demo-btn:hover {
    background: #d2e3fc !important;
}
[data-theme="light"] .sidebar-btn.dashboard-btn {
    background: #e6f4ea !important;
    color: #137333 !important;
}
[data-theme="light"] .sidebar-btn.dashboard-btn:hover {
    background: #ceead6 !important;
}
[data-theme="light"] .sidebar-btn.admin-btn {
    background: #fef7e0 !important;
    color: #945700 !important;
}
[data-theme="light"] .sidebar-btn.admin-btn:hover {
    background: #feefc3 !important;
}
[data-theme="light"] .sidebar-btn.settings-btn {
    background: #e8eaed !important;
    color: #5f6368 !important;
}
[data-theme="light"] .sidebar-btn.settings-btn:hover {
    background: #dadce0 !important;
    color: #3c4043 !important;
}
[data-theme="light"] .sidebar-btn.logout-btn {
    background: #fce8e6 !important;
    color: #c5221f !important;
}
[data-theme="light"] .sidebar-btn.logout-btn:hover {
    background: #f5c6c2 !important;
}
[data-theme="light"] .btn-clear {
    background: #d0d5dd !important;
    color: #1a1a2e !important;
}
[data-theme="light"] .btn-clear:hover {
    background: #c0c5cd !important;
}
[data-theme="light"] .suggestions button {
    background: #d0d5dd;
    color: #1a1a2e;
}
[data-theme="light"] .filter-tabs button {
    background: #d0d5dd;
    color: #1a1a2e;
}
[data-theme="light"] .admin-header button {
    background: #d0d5dd !important;
    color: #1a1a2e !important;
}
[data-theme="light"] .periodo-selector button {
    background: #d0d5dd;
    color: #1a1a2e;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg-primary); color: var(--text-primary); transition: background 0.3s, color 0.3s; }

/* Layout */
.app-container { height: 100vh; }
.login-container { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 20px; }
.login-box { background: var(--bg-secondary); border-radius: 16px; padding: 40px; width: 100%; max-width: 440px; box-shadow: 0 4px 20px var(--shadow); }
.login-box { position: relative; }
.login-box h1 { text-align: center; margin-bottom: 25px; font-size: 28px; }
.theme-toggle-login { position: absolute; top: 15px; right: 15px; background: transparent; border: none; font-size: 18px; cursor: pointer; padding: 6px 10px; border-radius: 8px; width: auto; }
.theme-toggle-login:hover { background: var(--bg-tertiary); }

/* Forms */
input, button { width: 100%; padding: 14px; margin: 8px 0; border-radius: 10px; font-size: 15px; border: none; }
input { background: var(--input-bg); color: var(--text-primary); }
input:focus { outline: 2px solid var(--accent); }
input::placeholder { color: var(--text-muted); }
button { background: var(--accent); color: white; cursor: pointer; font-weight: 600; transition: all 0.2s; }
button:hover { background: var(--accent-hover); transform: translateY(-1px); }
button:disabled { background: var(--text-muted); cursor: not-allowed; transform: none; }
.error { background: #ff6b6b22; color: #ff6b6b; padding: 12px; border-radius: 8px; margin: 10px 0; font-size: 14px; }
.mfa-info { color: var(--text-muted); font-size: 13px; margin: 10px 0; text-align: center; }
.qr-code { text-align: center; margin: 15px 0; }
.qr-code img { border-radius: 12px; }
code { background: var(--bg-tertiary); padding: 4px 8px; border-radius: 4px; font-size: 10px; word-break: break-all; }

/* Google Button */
.google-btn { background: white !important; color: #333 !important; display: flex; align-items: center; justify-content: center; gap: 10px; }
.google-btn:hover { background: #f5f5f5 !important; }

/* Demo Divider (login) */
.demo-divider { text-align: center; margin: 20px 0 10px; font-size: 13px; color: var(--text-muted); }


/* Chat Layout */
.chat-layout { display: flex; height: 100vh; }

/* Sidebar */
.sidebar { width: 280px; background: var(--bg-secondary); display: flex; flex-direction: column; transition: margin 0.3s; }
.sidebar:not(.open) { margin-left: -280px; }
.sidebar-header { padding: 20px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.sidebar-header h2 { font-size: 20px; }
.new-conv-btn { width: auto; padding: 8px 16px; font-size: 13px; background: var(--accent); }
.conv-list { flex: 1; overflow-y: auto; padding: 10px; }
.conv-item { padding: 12px 15px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; gap: 10px; margin-bottom: 5px; transition: background 0.2s; }
.conv-item:hover { background: var(--bg-tertiary); }
.conv-item.active { background: #e9456033; }
.conv-icon { font-size: 16px; }
.conv-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv-delete { background: none; border: none; color: var(--text-muted); font-size: 12px; line-height: 1; width: auto; padding: 0 2px; opacity: 0; flex-shrink: 0; }
.conv-item:hover .conv-delete { opacity: 1; color: var(--accent); }
.sidebar-footer { padding: 15px; border-top: 1px solid var(--border-color); }
.sidebar-btn { background: var(--bg-tertiary); margin: 5px 0; font-size: 14px; }
.sidebar-btn.demo-btn { background: #1e3a5f !important; color: #93c5fd !important; }
.sidebar-btn.demo-btn:hover { background: #1e40af !important; color: white !important; }
.sidebar-btn.dashboard-btn { background: #14332a !important; color: #6ee7b7 !important; }
.sidebar-btn.dashboard-btn:hover { background: #065f46 !important; color: white !important; }
.sidebar-btn.admin-btn { background: #451a03 !important; color: #fbbf24 !important; }
.sidebar-btn.admin-btn:hover { background: #78350f !important; color: white !important; }
.sidebar-btn.settings-btn { background: var(--bg-tertiary) !important; color: var(--text-muted) !important; }
.sidebar-btn.settings-btn:hover { color: var(--text-primary) !important; }
.logout-btn { background: #3b1520 !important; color: #fca5a5 !important; }
.logout-btn:hover { background: var(--accent) !important; color: white !important; }

/* Chat Main */
.chat-main { flex: 1; display: flex; flex-direction: column; background: var(--bg-primary); }
.chat-header { padding: 15px 20px; background: var(--bg-secondary); display: flex; align-items: center; gap: 15px; font-weight: 600; position: relative; }
.theme-toggle-header { position: absolute; right: 15px; width: auto; padding: 6px 10px; background: transparent; font-size: 18px; border: none; cursor: pointer; border-radius: 8px; }
.theme-toggle-header:hover { background: var(--bg-tertiary); }
.toggle-sidebar { width: auto; padding: 8px 12px; background: transparent; font-size: 20px; }
.toggle-sidebar:hover { background: var(--bg-tertiary); }

/* Messages */
.messages { flex: 1; overflow-y: auto; padding: 20px; }
.welcome { text-align: center; padding: 40px 20px; }
.welcome h2 { font-size: 28px; margin-bottom: 10px; }
.welcome p { color: var(--text-muted); margin-bottom: 20px; font-size: 14px; }

/* Filter Panel */
.filter-panel { background: var(--bg-secondary); border-radius: 12px; padding: 15px; margin-bottom: 25px; text-align: left; max-width: 800px; margin-left: auto; margin-right: auto; }
.filter-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; padding: 5px 0; }
.filter-header span:first-child { font-weight: 600; font-size: 15px; }
.filter-toggle { color: var(--text-muted); font-size: 12px; }
.filter-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-top: 15px; }
.filter-group { display: flex; flex-direction: column; gap: 5px; }
.filter-group label { font-size: 12px; color: var(--text-muted); }
.filter-group select, .filter-group input[type="text"] { padding: 10px 12px; border-radius: 8px; background: var(--input-bg); color: var(--text-primary); border: 1px solid var(--border-color); font-size: 13px; width: 100%; }
.filter-group select { cursor: pointer; }
.filter-group select:focus, .filter-group input[type="text"]:focus { outline: none; border-color: var(--accent); }
.filter-group select:disabled, .filter-group input[type="text"]:disabled { opacity: 0.5; cursor: not-allowed; }
.filter-group input[type="text"]::placeholder { color: var(--text-muted); }
.filter-group-multi { grid-column: span 2; }
.filter-group .hint { font-weight: normal; font-size: 10px; opacity: 0.7; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-label { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-primary); background: var(--input-bg); padding: 6px 10px; border-radius: 6px; cursor: pointer; border: 1px solid var(--border-color); transition: all 0.2s; }
.checkbox-label:hover { border-color: var(--accent); }
.checkbox-label input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }
.checkbox-label:has(input:checked) { background: var(--accent); border-color: var(--accent); color: white; }
.filter-actions { margin-top: 15px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; padding-top: 15px; border-top: 1px solid var(--border-color); }
.filter-preview { flex: 1; min-width: 200px; }
.preview-text { font-size: 13px; color: var(--success); background: #2ecc7115; padding: 8px 12px; border-radius: 6px; display: inline-block; }
.filter-buttons { display: flex; gap: 10px; }
.filter-buttons button { width: auto; padding: 10px 20px; font-size: 13px; }
.btn-clear { background: var(--bg-tertiary) !important; }
.btn-clear:hover { background: var(--border-color) !important; }
.btn-search { background: var(--accent) !important; }
.btn-search:disabled { background: var(--text-muted) !important; opacity: 0.6; }

.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; align-items: center; }
.suggestions-label { font-size: 13px; color: var(--text-muted); margin-right: 5px; }
.suggestions button { width: auto; padding: 10px 20px; background: var(--bg-tertiary); font-size: 13px; }
.suggestions button:hover { background: var(--accent); }

@media (max-width: 1200px) {
    .filter-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 800px) {
    .filter-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .filter-grid { grid-template-columns: 1fr; }
    .filter-actions { flex-direction: column; }
    .filter-preview { width: 100%; text-align: center; }
    .filter-buttons { width: 100%; justify-content: center; }
}

.message { max-width: 80%; margin: 12px 0; padding: 14px 18px; border-radius: 18px; line-height: 1.6; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.message.user { background: var(--accent); margin-left: auto; border-bottom-right-radius: 4px; }
.message.bot { background: var(--bg-secondary); border-bottom-left-radius: 4px; }
.message.streaming .cursor { animation: blink 0.8s infinite; }
@keyframes blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }
.message.loading { color: var(--text-secondary); font-style: italic; display: flex; align-items: center; gap: 10px; }
.message.loading::before { content: ''; width: 16px; height: 16px; border: 2px solid var(--accent); border-top-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Markdown in messages */
.message table { border-collapse: collapse; margin: 10px 0; width: 100%; font-size: 13px; }
.message th, .message td { border: 1px solid var(--border-color); padding: 8px; text-align: left; }
.message th { background: var(--bg-tertiary); }
.message code { background: var(--bg-tertiary); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.message pre { background: var(--bg-tertiary); padding: 12px; border-radius: 8px; overflow-x: auto; }
.message ul, .message ol { margin-left: 20px; }
.message p { margin: 8px 0; }

/* Input Area */
.input-area { padding: 20px; background: var(--bg-secondary); display: flex; gap: 12px; align-items: center; }
.input-area input { flex: 1; background: var(--input-bg); border-radius: 25px; padding: 15px 20px; }
.input-area > button[type="submit"] { width: 50px; height: 50px; border-radius: 50%; padding: 0; font-size: 18px; flex-shrink: 0; }

/* Toggle Registro Mercantil */
.borme-toggle {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 50% !important;
    background: var(--bg-tertiary) !important;
    border: 2px solid transparent !important;
    font-size: 16px !important;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0;
    opacity: 0.6;
}
.borme-toggle:hover {
    opacity: 1;
    background: var(--border-color) !important;
    transform: none !important;
}
.borme-toggle.active {
    opacity: 1;
    background: var(--bg-tertiary) !important;
    border-color: var(--success) !important;
    box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.3);
}

/* Admin */
.admin-container { max-width: 900px; margin: 0 auto; padding: 30px; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.admin-header h1 { font-size: 24px; }
.admin-header button { width: auto; padding: 10px 20px; background: var(--bg-tertiary); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 30px; }
.stat-card { background: var(--bg-secondary); padding: 20px; border-radius: 12px; text-align: center; }
.stat-num { display: block; font-size: 32px; font-weight: bold; color: var(--accent); }
.stat-label { font-size: 13px; color: var(--text-muted); }
h3 { margin: 25px 0 15px; font-size: 16px; }
table { width: 100%; border-collapse: collapse; background: var(--bg-secondary); border-radius: 12px; overflow: hidden; }
th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--border-color); }
th { background: var(--bg-tertiary); font-size: 13px; }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 11px; }
.badge.ok { background: #27ae6033; color: #27ae60; }
.badge.pending { background: #f39c1233; color: #f39c12; }
.badge.premium { background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%); color: white; }
.badge.enterprise { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); color: white; }
.activity-list { background: var(--bg-secondary); border-radius: 12px; max-height: 250px; overflow-y: auto; }
.activity-item { padding: 12px 15px; border-bottom: 1px solid var(--border-color); display: flex; gap: 15px; font-size: 13px; }
.activity-item span:first-child { color: var(--text-muted); white-space: nowrap; }
.activity-user { color: var(--accent); font-weight: 500; min-width: 100px; }

/* Charts */
.chart-container { height: 250px; margin-top: 15px; padding: 15px; background: var(--bg-tertiary); border-radius: 12px; }

/* Cookie Banner */
.cookie-banner { position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg-secondary); padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; z-index: 1000; border-top: 1px solid var(--border-color); }
.cookie-banner p { margin: 0; font-size: 14px; color: var(--text-secondary); }
.cookie-banner a { color: var(--accent); }
.cookie-banner button { width: auto; padding: 10px 25px; }

/* Settings */
.settings-section { background: var(--bg-secondary); padding: 20px; border-radius: 12px; margin-bottom: 20px; }
.settings-section h4 { margin: 0 0 10px; color: var(--text-primary); }
.settings-section p { color: var(--text-muted); font-size: 14px; margin-bottom: 15px; }
.settings-section button { width: auto; }
.settings-section.danger { border: 1px solid var(--accent); }
.danger-btn { background: #c0392b !important; }
.danger-btn:hover { background: #e74c3c !important; }

/* Subscription Section */
.subscription-section { border: 1px solid var(--border-color); }
.plan-info { text-align: center; padding: 20px; }
.plan-info.premium { background: linear-gradient(135deg, rgba(124, 58, 237, 0.1) 0%, rgba(99, 102, 241, 0.1) 100%); border-radius: 10px; }
.plan-info.free { background: rgba(255, 255, 255, 0.03); border-radius: 10px; }
.plan-badge-large { font-size: 24px; font-weight: 700; margin-bottom: 10px; }
.plan-badge-large.free { color: var(--text-muted); }
.plan-info p { color: var(--text-secondary); margin-bottom: 20px; }
.plan-actions { margin-top: 15px; }
.plan-actions button { padding: 12px 24px; font-size: 15px; }
.plan-hint { font-size: 12px; color: #666; margin-top: 10px; }
.upgrade-btn { background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%) !important; }
.upgrade-btn:hover { box-shadow: 0 5px 20px rgba(124, 58, 237, 0.4); }

/* Alerts Config */
.alerts-config { padding: 10px 0; }
.alert-toggle { margin-bottom: 20px; }
.toggle-label { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.toggle-label input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.toggle-text { font-size: 16px; font-weight: 500; }
.alert-options { background: var(--bg-tertiary); border-radius: 10px; padding: 20px; margin-bottom: 20px; opacity: 0.9; }
.alert-field { margin-bottom: 15px; }
.alert-field label { display: block; font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; }
.alert-field input, .alert-field select { width: 100%; padding: 12px; background: var(--input-bg); border: 1px solid var(--border-color); border-radius: 8px; color: var(--text-primary); font-size: 14px; }
.alert-field input:focus, .alert-field select:focus { outline: none; border-color: var(--accent); }
.alert-field select { cursor: pointer; }
.alert-hint { font-size: 13px; color: var(--text-muted); margin-top: 15px; padding: 10px; background: rgba(233, 69, 96, 0.1); border-radius: 6px; border-left: 3px solid var(--accent); }
.save-alerts-btn { background: var(--success) !important; margin-top: 10px; }
.save-alerts-btn:hover { background: #2ecc71 !important; }

/* Checkbox */
.checkbox-label { display: flex; align-items: flex-start; gap: 10px; margin: 15px 0; text-align: left; cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: auto; margin-top: 4px; accent-color: var(--accent); }
.checkbox-label span { font-size: 13px; color: var(--text-secondary); line-height: 1.4; }
.checkbox-label a { color: var(--accent); }
.legal-link { font-size: 12px; color: var(--text-muted); text-align: center; margin-top: 15px; }
.legal-link a { color: var(--accent); }
.support-contact { font-size: 12px; color: var(--text-muted); text-align: center; margin-top: 20px; border-top: 1px solid var(--border-color); padding-top: 15px; }
.login-footer { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: 12px; line-height: 1.6; }
.login-footer a { color: var(--text-muted); text-decoration: none; }
.login-footer a:hover { color: var(--text-primary); text-decoration: underline; }

/* Cookie Banner */
.cookie-banner { position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg-secondary); border-top: 1px solid var(--border-color); padding: 14px 20px; display: flex; align-items: center; justify-content: center; gap: 16px; z-index: 1000; box-shadow: 0 -2px 10px var(--shadow); }
.cookie-banner p { font-size: 13px; color: var(--text-secondary); margin: 0; }
.cookie-banner a { color: var(--accent); }
.cookie-banner button { padding: 8px 20px; background: var(--accent); color: white; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.cookie-banner button:hover { opacity: 0.9; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { position: fixed; z-index: 100; height: 100%; width: 260px; }
    .sidebar:not(.open) { margin-left: -260px; }
    .sidebar.open + .chat-main { pointer-events: none; }
    .chat-main { width: 100%; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .message { max-width: 90%; }
    .toggle-sidebar { display: block !important; }
}

/* Overlay when sidebar open on mobile */
.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 99; }
@media (max-width: 768px) {
    .sidebar.open ~ .sidebar-overlay { display: block; }
}

/* Forgot password link */
.forgot-link { text-align: center; margin-top: 10px; }
.forgot-link a { color: #888; font-size: 13px; cursor: pointer; }
.forgot-link a:hover { color: #e94560; }

/* Queries remaining indicator */
.queries-remaining {
    background: var(--bg-tertiary);
    padding: 12px 15px;
    border-radius: 10px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}
.queries-remaining span { color: var(--text-muted); }
.upgrade-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 12px;
}
.upgrade-link:hover { text-decoration: underline; }

/* Plan badge */
.plan-badge {
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 10px;
}
.plan-badge.premium {
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
    color: white;
}
.plan-badge.enterprise {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

/* Limit message styling */
.message.limit-reached {
    background: linear-gradient(135deg, #7c3aed22 0%, #6366f122 100%);
    border: 1px solid #7c3aed;
}
.message a {
    color: #7c3aed;
    font-weight: 600;
}

/* Subscription Button in Sidebar */
.subscription-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    font-weight: 600;
}
.subscription-btn.premium {
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%) !important;
}
.subscription-btn.enterprise {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
}
.subscription-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

/* Subscription Modal */
.subscription-modal {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 30px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}
.subscription-modal h2 {
    text-align: center;
    font-size: 28px;
    margin-bottom: 5px;
}
.modal-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 30px;
}
.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    width: auto;
    padding: 5px 10px;
}
.modal-close:hover {
    color: var(--text-primary);
    background: transparent;
}

/* Plans Grid */
.plans-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
@media (max-width: 768px) {
    .plans-grid {
        grid-template-columns: 1fr;
    }
}

/* Plan Card */
.plan-card {
    background: var(--bg-tertiary);
    border-radius: 16px;
    padding: 25px;
    position: relative;
    transition: all 0.3s;
    border: 2px solid transparent;
}
.plan-card:hover {
    transform: translateY(-5px);
    border-color: #667eea;
}
.plan-card.current {
    border-color: #7c3aed;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.1) 0%, rgba(99, 102, 241, 0.1) 100%);
}
.plan-card.popular {
    border-color: var(--accent);
}
.plan-card h3 {
    font-size: 22px;
    margin-bottom: 15px;
    color: var(--text-primary);
}
.popular-tag {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: #e94560;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.current-tag {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: #7c3aed;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

/* Plan Price */
.plan-price {
    margin-bottom: 20px;
}
.plan-price .price {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
}
.plan-price .period {
    font-size: 14px;
    color: var(--text-muted);
}

/* Plan Features */
.plan-features {
    list-style: none;
    margin: 0 0 20px 0;
    padding: 0;
}
.plan-features li {
    padding: 8px 0;
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.plan-features .check {
    color: var(--success);
    font-weight: bold;
}
.plan-features .cross {
    color: #e74c3c;
}
.plan-features .limitation {
    color: var(--text-muted);
}

/* Plan Action Buttons */
.plan-action button {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
}
.upgrade-btn-modal {
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%) !important;
}
.upgrade-btn-modal:hover {
    box-shadow: 0 5px 20px rgba(124, 58, 237, 0.4);
}
.manage-btn {
    background: var(--bg-tertiary) !important;
    border: 1px solid #7c3aed !important;
}
.current-plan-btn {
    background: var(--border-color) !important;
    color: var(--text-muted) !important;
    cursor: default !important;
}
.downgrade-btn {
    background: var(--border-color) !important;
    color: var(--text-muted) !important;
    cursor: default !important;
}
.contact-btn {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
}

/* Save Empresa Button */
.save-empresa-btn {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}
.save-empresa-btn button {
    width: auto;
    padding: 6px 12px;
    font-size: 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
}
.save-empresa-btn button:hover {
    background: var(--accent);
}

/* Save Empresa Modal */
.save-empresa-modal {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 25px;
    width: 100%;
    max-width: 400px;
}
.save-empresa-modal h3 {
    margin-bottom: 15px;
    font-size: 18px;
    text-align: center;
}
.save-empresa-modal input {
    margin-bottom: 15px;
}
.save-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}
.save-buttons button {
    flex: 1;
    padding: 12px;
    font-size: 13px;
}
.btn-actual {
    background: #27ae60 !important;
}
.btn-actual:hover {
    background: #2ecc71 !important;
}
.btn-watchlist {
    background: #3498db !important;
}
.btn-watchlist:hover {
    background: #5dade2 !important;
}
.btn-cancel {
    background: var(--border-color) !important;
    color: var(--text-muted) !important;
}
.btn-cancel:hover {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

/* ============================================
   EMPRESAS DASHBOARD
   ============================================ */
.dashboard-container {
    min-height: 100vh;
    background: var(--bg-primary);
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}
.dashboard-header h1 {
    font-size: 24px;
    margin: 0;
}
.back-btn {
    background: #0f3460 !important;
    width: auto;
    padding: 10px 20px;
}
.back-btn:hover {
    background: #e94560 !important;
}
.logout-btn-small {
    background: #e94560 !important;
    width: auto;
    padding: 10px 20px;
}

/* Dashboard Stats */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.stat-box {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}
.stat-box:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
}
.stat-box.alertas {
    border-color: #f39c12;
}
.stat-number {
    display: block;
    font-size: 36px;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 5px;
}
.stat-label {
    font-size: 14px;
    color: var(--text-muted);
}

/* Dashboard Actions */
.dashboard-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}
.filter-tabs {
    display: flex;
    gap: 10px;
}
.filter-tabs button {
    background: var(--bg-tertiary);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    width: auto;
}
.filter-tabs button.active {
    background: var(--accent);
}
.filter-tabs button:hover {
    background: var(--accent);
}
.add-empresa-btn {
    background: #27ae60 !important;
    width: auto;
    padding: 12px 24px;
}
.add-empresa-btn:hover {
    background: #2ecc71 !important;
}
.action-buttons {
    display: flex;
    gap: 10px;
}
.novedades-btn {
    background: #9b59b6 !important;
    width: auto;
    padding: 12px 20px;
}
.novedades-btn:hover {
    background: #8e44ad !important;
}
.noticias-btn {
    background: #3498db !important;
    width: auto;
    padding: 12px 20px;
}
.noticias-btn:hover {
    background: #2980b9 !important;
}

/* Noticias styles */
.noticia-item {
    display: block;
    background: var(--bg-primary);
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 8px;
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.2s;
    border-left: 3px solid #3498db;
}
.noticia-item:hover {
    background: var(--bg-tertiary);
}
.noticia-titulo {
    display: block;
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 5px;
}
.noticia-meta {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
}
.noticia-fuente {
    color: #3498db;
}
.noticias-list {
    margin-top: 10px;
}

/* Alerts Config Panel */
.alerts-config-panel {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}
.alerts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
.alerts-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text-primary);
}
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    border-radius: 26px;
    transition: 0.3s;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-primary);
    border-radius: 50%;
    transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider {
    background-color: var(--success);
}
.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}
.alerts-options {
    margin-top: 15px;
}
.alert-field-row {
    display: flex;
    gap: 10px;
    align-items: center;
}
.alert-field-row input {
    flex: 1;
    margin: 0;
    padding: 10px 12px;
}
.alert-field-row select {
    width: auto;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
}
.save-alert-btn {
    width: auto !important;
    padding: 10px 16px !important;
    background: #3498db !important;
}
.save-alert-btn:hover {
    background: #2980b9 !important;
}
.alert-msg {
    display: block;
    margin-top: 10px;
    font-size: 13px;
    color: #27ae60;
}

/* Novedades Modal */
.novedades-modal {
    background: var(--bg-secondary);
    border-radius: 16px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.novedades-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 10px;
}
.novedades-header h3 {
    margin: 0;
    font-size: 18px;
}
.periodo-selector {
    display: flex;
    gap: 8px;
}
.periodo-selector button {
    width: auto;
    padding: 8px 16px;
    font-size: 13px;
    background: var(--bg-tertiary);
}
.periodo-selector button.active {
    background: #9b59b6;
}
.refresh-btn {
    background: #3498db !important;
    padding: 8px 12px !important;
}
.close-modal {
    background: transparent !important;
    width: auto !important;
    padding: 8px 12px !important;
    font-size: 18px;
}
.novedades-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}
.novedades-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.novedad-card {
    background: var(--bg-tertiary);
    border-radius: 10px;
    padding: 15px;
    border-left: 4px solid #9b59b6;
}
.novedad-empresa {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.novedad-empresa strong {
    font-size: 15px;
}
.tipo-badge {
    font-size: 14px;
}
.novedad-pubs {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.pub-item {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #aaa;
    padding: 5px 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 5px;
}
.pub-tipo {
    text-transform: capitalize;
}
.pub-fecha {
    color: var(--text-muted);
}
.pub-provincia {
    color: var(--text-secondary);
    font-size: 0.8em;
    background: rgba(255,255,255,0.1);
    padding: 1px 6px;
    border-radius: 3px;
}
.pub-nombre {
    color: var(--text-secondary);
    font-size: 0.85em;
    font-style: italic;
}
.pub-link {
    color: #4fc3f7;
    text-decoration: none;
    font-size: 0.8em;
}
.pub-link:hover {
    text-decoration: underline;
}
.pub-item {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* Empresas List */
.empresas-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.empresa-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--border-color);
    transition: all 0.2s;
}
.empresa-card.actual {
    border-left-color: var(--success);
}
.empresa-card.watchlist {
    border-left-color: #3498db;
}
.empresa-card.has-alerta {
    border-left-color: #f39c12;
    background: var(--bg-secondary);
    box-shadow: 0 0 10px rgba(243, 156, 18, 0.2);
}
.empresa-card:hover {
    transform: translateX(5px);
}
.empresa-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}
.empresa-tipo {
    font-size: 24px;
}
.empresa-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.empresa-nombre {
    font-weight: 600;
    font-size: 16px;
}
.empresa-nif, .empresa-fecha {
    font-size: 12px;
    color: var(--text-muted);
}

/* Notas de empresas */
.empresa-notas {
    margin-top: 4px;
}
.empresa-nota-text {
    font-size: 12px;
    color: var(--accent);
    cursor: pointer;
    display: inline-block;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.empresa-nota-text.empty {
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.6;
}
.empresa-nota-text:hover {
    text-decoration: underline;
}
.empresa-notas-input {
    font-size: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 6px 8px;
    width: 280px;
    max-width: 100%;
    min-height: 36px;
    resize: vertical;
    font-family: inherit;
}
.empresa-notas-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

/* DB Update Info */
.db-update-info {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 20px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.db-update-date {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.db-update-detail {
    font-size: 11px;
    color: var(--text-muted);
}
.db-disclaimer {
    margin-top: 12px;
    padding: 0 10px;
}
.db-disclaimer p {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
    opacity: 0.7;
    text-align: center;
}

/* Noticia fecha */
.noticia-fecha {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 8px;
}
.noticia-fuente {
    font-size: 11px;
}

.alerta-badge {
    background: #f39c12;
    color: #000;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: auto;
    margin-right: 15px;
}
.delete-btn {
    background: transparent !important;
    width: auto;
    padding: 8px;
    font-size: 18px;
    opacity: 0.5;
}
.delete-btn:hover {
    opacity: 1;
    background: #e74c3c !important;
}

/* Empty & Loading States */
.empty-state, .loading-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state p {
    margin-bottom: 10px;
}
.empty-state .hint {
    font-size: 13px;
    color: var(--text-muted);
}

/* Alertas Section */
.alertas-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
}
.alertas-section h3 {
    margin-bottom: 20px;
    color: #f39c12;
}
.alerta-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    border-left: 4px solid #f39c12;
}
.alerta-card strong {
    display: block;
    margin-bottom: 8px;
    font-size: 16px;
}
.alerta-tipo {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 10px;
}
.alerta-pub {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Tipo Selector in Modal */
.tipo-selector {
    margin-bottom: 15px;
}
.tipo-selector label {
    display: block;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}
.tipo-selector label:hover {
    background: var(--border-color);
}
.tipo-selector input[type="radio"] {
    width: auto;
    margin-right: 10px;
}

/* Dashboard Button in Sidebar */
.dashboard-btn {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%) !important;
}
.dashboard-btn:hover {
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

/* Security Logs */
.security-logs {
    margin-top: 15px;
    max-height: 400px;
    overflow-y: auto;
}
.security-logs table {
    font-size: 12px;
}
.security-logs td, .security-logs th {
    padding: 8px 10px;
}
.badge.severity-low { background: #3498db; color: white; }
.badge.severity-medium { background: #f39c12; color: white; }
.badge.severity-high { background: #e67e22; color: white; }
.badge.severity-critical { background: #e74c3c; color: white; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
tr.severity-high { background: rgba(230, 126, 34, 0.1); }
tr.severity-critical { background: rgba(231, 76, 60, 0.15); }

/* Mobile Responsive */
@media (max-width: 768px) {
    .dashboard-stats {
        grid-template-columns: 1fr;
    }
    .dashboard-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-tabs {
        justify-content: center;
    }
    .empresa-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .alerta-badge {
        margin-left: 0;
        margin-top: 10px;
    }
    .empresa-nota-text {
        max-width: 200px;
    }
    .empresa-notas-input {
        width: 100%;
    }
    .db-update-info {
        padding: 10px 15px;
    }
}
