:root {
    --primary: #1a365d;
    --primary-light: #2d4a7a;
    --accent: #3b82f6;
    --bg: #f0f4f8;
    --card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --warning-light: #fffbeb;
    --sidebar-w: 220px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg); color: var(--text); display: flex; min-height: 100vh;
}
/* Sidebar */
#sidebar {
    width: var(--sidebar-w); background: var(--primary); color: #fff;
    display: flex; flex-direction: column; padding: 1.5rem 0; position: fixed;
    top: 0; left: 0; height: 100vh; z-index: 100;
}
.logo { font-size: 1.3rem; font-weight: 700; padding: 0 1.5rem 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.nav-link {
    display: block; padding: 0.75rem 1.5rem; color: rgba(255,255,255,0.7);
    text-decoration: none; font-size: 0.9rem; transition: all 0.2s;
}
.nav-link:hover, .nav-link.active { color: #fff; background: rgba(255,255,255,0.1); }
.nav-spacer { flex: 1; }
/* Main content */
#page-content { margin-left: var(--sidebar-w); padding: 2rem; flex: 1; width: calc(100% - var(--sidebar-w)); }
.loading { text-align: center; padding: 3rem; color: var(--text-light); }
/* Cards */
.card { background: var(--card); border-radius: 10px; padding: 1.5rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin-bottom: 1rem; }
.card h2 { font-size: 1.1rem; color: var(--primary); margin-bottom: 1rem; }
.card h3 { font-size: 0.95rem; color: var(--text-light); margin-bottom: 0.75rem; }
/* Stats row */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--card); border-radius: 10px; padding: 1.25rem;
             box-shadow: 0 1px 3px rgba(0,0,0,0.06); text-align: center; }
.stat-card .number { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 0.8rem; color: var(--text-light); margin-top: 0.25rem; }
/* Tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 0.6rem 0.75rem; font-size: 0.75rem; color: var(--text-light);
     text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid var(--border); }
td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
tr:hover td { background: #f8fafc; }
tr { cursor: pointer; }
/* Badges */
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-activo { background: #dcfce7; color: #166534; }
.badge-critica { background: #fef2f2; color: #991b1b; }
.badge-alta { background: #fff7ed; color: #9a3412; }
.badge-media { background: #fffbeb; color: #92400e; }
.badge-baja { background: #f0f9ff; color: #075985; }
/* Alerts list */
.alert-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem;
              border-radius: 8px; margin-bottom: 0.5rem; }
.alert-item.critica { background: var(--danger-light); }
.alert-item.alta { background: #fff7ed; }
.alert-item.media { background: var(--warning-light); }
.alert-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.alert-dot.critica { background: var(--danger); }
.alert-dot.alta { background: #f97316; }
.alert-dot.media { background: var(--warning); }
.alert-dot.baja { background: var(--accent); }
.alert-info { flex: 1; }
.alert-info .title { font-weight: 600; font-size: 0.9rem; }
.alert-info .meta { font-size: 0.8rem; color: var(--text-light); }
/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 1rem;
       border-radius: 8px; font-size: 0.85rem; font-weight: 600; cursor: pointer;
       border: none; transition: all 0.2s; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.8rem; color: var(--text-light);
                    font-weight: 600; margin-bottom: 0.3rem; text-transform: uppercase;
                    letter-spacing: 0.3px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--border);
    border-radius: 8px; font-size: 0.9rem; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
/* Chat */
.chat-container { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.chat-messages { height: 550px; overflow-y: auto; padding: 1rem; background: #f8fafc; }
.chat-msg { margin-bottom: 1rem; max-width: 95%; }
.chat-msg.user { margin-left: auto; }
.chat-msg .bubble { padding: 0.75rem 1rem; border-radius: 12px; font-size: 0.9rem; line-height: 1.5; }
.chat-msg.user .bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.ai .bubble { background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-msg.ai .bubble p { margin-bottom: 0.5rem; }
.chat-msg.ai .bubble p:last-child { margin-bottom: 0; }
.chat-msg.ai .bubble strong { color: var(--primary); }
.chat-msg.ai .bubble ul, .chat-msg.ai .bubble ol { margin: 0.5rem 0; padding-left: 1.25rem; }
.chat-input { display: flex; border-top: 1px solid var(--border); }
.chat-input input { flex: 1; padding: 0.75rem 1rem; border: none; font-size: 0.9rem; font-family: inherit; }
.chat-input input:focus { outline: none; }
.chat-input button { padding: 0.75rem 1.5rem; background: var(--primary); color: #fff;
                     border: none; font-weight: 600; cursor: pointer; }
.chat-input button:hover { background: var(--primary-light); }
.chat-input button:disabled { opacity: 0.5; cursor: not-allowed; }
/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; color: var(--primary); }
/* Timeline */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 1.25rem; }
.timeline-item::before { content: ''; position: absolute; left: -2rem; top: 4px; width: 12px; height: 12px;
                         border-radius: 50%; background: var(--accent); border: 2px solid var(--card); z-index: 1; }
.timeline-item .date { font-size: 0.8rem; color: var(--text-light); font-weight: 600; }
.timeline-item .title { font-weight: 600; margin-top: 0.15rem; }
.timeline-item .desc { font-size: 0.85rem; color: var(--text-light); margin-top: 0.15rem; }
/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200;
                 display: flex; align-items: center; justify-content: center; }
.modal { background: var(--card); border-radius: 12px; padding: 1.5rem; width: 90%; max-width: 500px;
         max-height: 90vh; overflow-y: auto; }
.modal h2 { margin-bottom: 1rem; color: var(--primary); }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.5rem; }
/* Responsive */
@media (max-width: 768px) {
    #sidebar { width: 100%; height: auto; position: relative; flex-direction: row;
               flex-wrap: wrap; padding: 0.5rem; }
    .logo { padding: 0.5rem; border: none; }
    .nav-link { padding: 0.5rem 0.75rem; }
    .nav-spacer { display: none; }
    #page-content { margin-left: 0; padding: 1rem; width: 100%; }
    .form-row { grid-template-columns: 1fr; }
    body { flex-direction: column; }
}
