/* ==========================================
   CRM Andes-Re — Jidox-style Dashboard
   Colors & fonts from andesre.cl
   ========================================== */

:root {
    /* Andes-Re palette */
    --primary: #2C4369;
    --primary-light: #3A5583;
    --primary-dark: #1A2A45;
    --primary-darkest: #0a1628;
    --accent: #C75D4F;
    --accent-light: #D67D71;
    --accent-dark: #A34A3D;
    --white: #F9F8F4;
    --off-white: #F4F2ED;
    --text-dark: #222222;
    --text-body: #555555;
    --text-muted: #888888;
    --text-light: #BBBBBB;
    --gray-light: #E5E5E5;
    --gray-lighter: #F0EDE8;

    /* Fonts */
    --font-primary: 'Raleway', 'Helvetica Neue', Arial, sans-serif;
    --font-display: 'Cormorant Garamond', Georgia, serif;

    /* Card colors — Jidox style */
    --card-blue: #3B82F6;
    --card-red: #EF4444;
    --card-green: #10B981;
    --card-orange: #F59E0B;
    --card-purple: #8B5CF6;
    --card-teal: #14B8A6;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.07);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);

    /* Layout */
    --sidebar-w: 250px;
    --header-h: 60px;
    --radius: 8px;
    --radius-lg: 12px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 400;
    color: var(--text-body);
    background: #f0f2f5;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--accent); }

/* ==========================================
   APP LAYOUT
   ========================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ==========================================
   SIDEBAR — Jidox style with Andes-Re branding
   ========================================== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--primary-darkest);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar { width: 0; }

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
}

.logo-img {
    height: 50px;
    width: auto;
    filter: brightness(0) invert(1);
}

/* User profile in sidebar — Jidox style */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.06);
    border-radius: 10px;
    padding: 10px 12px;
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-info { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--accent-light); font-weight: 500; }

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 8px 0;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.25);
    padding: 18px 20px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.55);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
    position: relative;
    margin: 1px 10px;
    border-radius: 8px;
}

.nav-item:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
}

.nav-item.active {
    color: #fff;
    background: var(--primary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.8;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 8px 0 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.user-info {
    display: none;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.user-details { display: flex; flex-direction: column; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.35); }

.logout-link {
    font-size: 13px;
    margin: 0 10px;
    opacity: 0.5;
}

.logout-link:hover { opacity: 1; color: var(--accent-light); }

/* ==========================================
   TOPBAR — Jidox style: white, clean
   ========================================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    height: var(--header-h);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-title {
    font-family: var(--font-primary);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
}

.header-search {
    position: relative;
}

.header-search input {
    padding: 8px 12px 8px 36px;
    border: 1.5px solid #e8e8e8;
    border-radius: var(--radius);
    font-family: var(--font-primary);
    font-size: 13px;
    width: 240px;
    background: #f8f8f8;
    color: var(--text-dark);
    transition: all 0.15s ease;
}

.header-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(44,67,105,0.08);
}

.header-search input::placeholder { color: #bbb; }

.header-search svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: #bbb;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-date {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-body);
    padding: 7px 14px;
    border-radius: var(--radius);
    background: #f8f8f8;
    border: 1px solid #e8e8e8;
}

.header-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    border: 1px solid #e8e8e8;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--text-muted);
}

.header-icon-btn:hover { background: #f8f8f8; color: var(--primary); }
.header-icon-btn svg { width: 18px; height: 18px; }

.header-avatar {
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.content-body {
    padding: 24px 28px;
    flex: 1;
}

/* ==========================================
   METRIC CARDS — Jidox exact style
   ========================================== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 20px 18px 16px;
    border: 1px solid #eee;
    position: relative;
    transition: all 0.2s ease;
}

.metric-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* Colored top border — always visible like Jidox */
.metric-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.metric-card.mc-total::before { background: var(--primary); }
.metric-card.mc-nueva::before { background: var(--card-blue); }
.metric-card.mc-revision::before { background: var(--card-orange); }
.metric-card.mc-cotizada::before { background: var(--card-green); }
.metric-card.mc-cerrada::before { background: var(--card-purple); }
.metric-card.mc-rechazada::before { background: var(--accent); }

/* Circular icon — Jidox position */
.metric-icon-circle {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.metric-icon-circle svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.metric-icon-circle.ic-total { background: rgba(44,67,105,0.1); color: var(--primary); }
.metric-icon-circle.ic-nueva { background: rgba(59,130,246,0.1); color: var(--card-blue); }
.metric-icon-circle.ic-revision { background: rgba(245,158,11,0.1); color: var(--card-orange); }
.metric-icon-circle.ic-cotizada { background: rgba(16,185,129,0.1); color: var(--card-green); }
.metric-icon-circle.ic-cerrada { background: rgba(139,92,246,0.1); color: var(--card-purple); }
.metric-icon-circle.ic-rechazada { background: rgba(199,93,79,0.1); color: var(--accent); }

.metric-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1;
    margin-bottom: 14px;
    font-family: var(--font-primary);
}

.metric-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    border-top: 1px solid #f0f0f0;
    padding-top: 12px;
}

.metric-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

.metric-badge svg { width: 12px; height: 12px; }

.metric-badge.green { background: rgba(16,185,129,0.1); color: #059669; }
.metric-badge.red { background: rgba(239,68,68,0.1); color: #DC2626; }
.metric-badge.blue { background: rgba(59,130,246,0.1); color: #2563EB; }
.metric-badge.orange { background: rgba(245,158,11,0.1); color: #D97706; }
.metric-badge.purple { background: rgba(139,92,246,0.1); color: #7C3AED; }

.metric-footer-text {
    font-size: 11px;
    color: #aaa;
}

/* ==========================================
   CARDS
   ========================================== */
.card {
    background: #fff;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    border: 1px solid #eee;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
}

.card-body { padding: 20px; }

.card-meta .card-body {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 16px 20px;
}

.meta-item { font-size: 12px; color: var(--text-body); }
.meta-item strong { color: var(--text-dark); font-weight: 600; }

/* ==========================================
   TABLES — Jidox clean style
   ========================================== */
.table-responsive { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    padding: 12px 18px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: #fafafa;
    border-bottom: 1px solid #eee;
}

.table td {
    padding: 12px 18px;
    border-bottom: 1px solid #f5f5f5;
    font-size: 13px;
    color: var(--text-body);
}

.table tbody tr { transition: all 0.1s ease; }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: #f8f9ff; }

.table td strong {
    font-weight: 600;
    color: var(--primary);
}

.empty-state {
    text-align: center;
    color: var(--text-light);
    padding: 48px 20px !important;
    font-size: 14px;
}

.empty-state-sm {
    text-align: center;
    color: var(--text-light);
    padding: 24px 0;
    font-size: 13px;
}

/* ==========================================
   BADGES
   ========================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.badge-nueva { background: rgba(59,130,246,0.1); color: #2563EB; }
.badge-nueva::before { background: #3B82F6; }
.badge-en_revision { background: rgba(245,158,11,0.1); color: #B45309; }
.badge-en_revision::before { background: #F59E0B; }
.badge-cotizada { background: rgba(16,185,129,0.1); color: #047857; }
.badge-cotizada::before { background: #10B981; }
.badge-cerrada { background: rgba(139,92,246,0.1); color: #6D28D9; }
.badge-cerrada::before { background: #8B5CF6; }
.badge-rechazada { background: rgba(199,93,79,0.1); color: var(--accent-dark); }
.badge-rechazada::before { background: var(--accent); }

.badge-lg { padding: 5px 14px; font-size: 12px; }

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-family: var(--font-primary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border: 1px solid #e0e0e0;
    border-radius: var(--radius);
    background: #fff;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn:hover {
    background: #f5f5f5;
    color: var(--primary);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-light);
    color: #fff;
    border-color: var(--primary-light);
}
.btn-danger {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}
.btn-danger:hover {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}

/* Confirm delete popup */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}
.confirm-overlay.active {
    display: flex;
}
.confirm-box {
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: confirmIn 0.2s ease-out;
}
@keyframes confirmIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.confirm-icon {
    margin-bottom: 16px;
}
.confirm-title {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 8px 0;
}
.confirm-text {
    font-size: 14px;
    color: #666;
    margin: 0 0 24px 0;
    line-height: 1.5;
}
.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.confirm-actions .btn {
    min-width: 120px;
}

/* Edit form */
/* ── Edit form (fe-) ── */
.fe-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.fe-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.fe-field-full {
    grid-column: 1 / -1;
}
.fe-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #64748b;
}
.fe-req {
    color: #ef4444;
    margin-left: 2px;
}
.fe-input {
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 13.5px;
    font-family: inherit;
    color: #1e293b;
    background: #f8fafc;
    transition: all 0.2s ease;
}
.fe-input:hover {
    border-color: #cbd5e1;
    background: #fff;
}
.fe-input:focus {
    outline: none;
    border-color: #4f46e5;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.fe-input::placeholder {
    color: #94a3b8;
}
.fe-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}
.fe-input-prima {
    border-color: #bbf7d0;
    background: #f0fdf4;
}
.fe-input-prima:focus {
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(5,150,105,0.1);
}
.fe-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 20px 0 8px;
    border-top: 1px solid #f1f5f9;
    margin-top: 8px;
}
.fe-btn-cancel {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.fe-btn-cancel:hover {
    border-color: #cbd5e1;
    color: #475569;
    background: #f8fafc;
}
.fe-btn-save {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(79,70,229,0.3);
}
.fe-btn-save:hover {
    background: linear-gradient(135deg, #4338ca, #4f46e5);
    box-shadow: 0 4px 12px rgba(79,70,229,0.4);
    transform: translateY(-1px);
}
@media (max-width: 600px) {
    .fe-grid { grid-template-columns: 1fr; }
    .fe-actions { flex-direction: column; }
    .fe-btn-cancel, .fe-btn-save { width: 100%; justify-content: center; }
}

.btn-accent {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-accent:hover {
    background: var(--accent-dark);
    color: #fff;
}

.btn-sm { padding: 6px 12px; font-size: 11px; }
.btn-block { width: 100%; }

/* ── Usuarios modal & edit button ── */
.usr-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}
.usr-modal-box {
    background: #fff;
    border-radius: 12px;
    padding: 28px 32px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.usr-modal-title {
    margin: 0 0 20px;
    font-size: 18px;
    color: #1e293b;
}
.btn-edit-user {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-edit-user:hover {
    border-color: #4f46e5;
    color: #4f46e5;
    background: #eef2ff;
}

/* ==========================================
   FORMS
   ========================================== */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-body);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    font-family: var(--font-primary);
    font-size: 13px;
    border: 1.5px solid #e0e0e0;
    border-radius: var(--radius);
    background: #fff;
    color: var(--text-dark);
    transition: all 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(44,67,105,0.08);
}

.form-group input::placeholder { color: #bbb; }

select, .select-sm {
    padding: 8px 12px;
    font-family: var(--font-primary);
    font-size: 13px;
    border: 1.5px solid #e0e0e0;
    border-radius: var(--radius);
    background: #fff;
    transition: all 0.15s ease;
}

.select-sm:focus { outline: none; border-color: var(--primary); }

textarea {
    width: 100%;
    padding: 10px 14px;
    font-family: var(--font-primary);
    font-size: 13px;
    border: 1.5px solid #e0e0e0;
    border-radius: var(--radius);
    resize: vertical;
    min-height: 80px;
}

textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(44,67,105,0.08); }

/* Filters */
.filters-card { margin-bottom: 20px; }

.filters-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    padding: 16px 20px;
}

.filter-group label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.filter-group select,
.filter-group input {
    padding: 8px 12px;
    font-size: 13px;
    border: 1.5px solid #e0e0e0;
    border-radius: var(--radius);
    min-width: 140px;
    font-family: var(--font-primary);
    transition: all 0.15s ease;
}

.filter-group select:focus,
.filter-group input:focus { outline: none; border-color: var(--primary); }

.filter-search input { min-width: 220px; }
.filter-actions { display: flex; gap: 8px; }

/* Inline forms */
.inline-form { display: flex; align-items: center; gap: 10px; }
.detail-actions-row { display: flex; flex-wrap: wrap; gap: 16px; }

/* ==========================================
   DETAIL LAYOUT
   ========================================== */
.detail-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.detail-field-full { grid-column: 1 / -1; }

.field-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 3px;
}

.field-value {
    font-size: 14px;
    color: var(--text-dark);
    font-weight: 500;
}

/* Notes */
.note-form { margin-bottom: 16px; }
.note-form textarea { margin-bottom: 8px; }

.notes-list { border-top: 1px solid #f0f0f0; padding-top: 14px; }

.note-item { padding: 12px 0; border-bottom: 1px solid #f5f5f5; }
.note-item:last-child { border-bottom: none; }

.note-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.note-header strong { font-size: 13px; color: var(--text-dark); }
.note-date { font-size: 11px; color: var(--text-light); }
.note-text { font-size: 13px; color: var(--text-body); line-height: 1.6; }

/* Documents */
.upload-form { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.upload-form input[type="file"] { font-size: 12px; flex: 1; }

.docs-list { border-top: 1px solid #f0f0f0; padding-top: 10px; }
.doc-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f5f5f5; }
.doc-item:last-child { border-bottom: none; }
.doc-item a { font-size: 13px; font-weight: 500; }
.doc-date { font-size: 11px; color: var(--text-light); }

/* ==========================================
   ALERTS
   ========================================== */
.messages-container { padding: 16px 28px 0; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #DC2626; border: 1px solid #fca5a5; }
.alert-warning { background: #fffbeb; color: #B45309; border: 1px solid #fcd34d; }

.alert-close { background: none; border: none; font-size: 18px; cursor: pointer; color: inherit; opacity: 0.5; }
.alert-close:hover { opacity: 1; }

/* ==========================================
   LOGIN — Split panel, Andes-Re branding
   ========================================== */
.login-page { background: #f0f2f5; }

.login-container { display: flex; min-height: 100vh; }

.login-brand {
    flex: 1;
    background: linear-gradient(135deg, var(--primary-darkest) 0%, var(--primary-dark) 40%, var(--primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.login-brand::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 60px 60px;
}

.login-brand::after {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(199,93,79,0.1) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.brand-content { text-align: center; z-index: 1; padding: 40px; }

.brand-logo {
    font-family: var(--font-display);
    font-size: 52px;
    font-weight: 700;
    letter-spacing: 6px;
    color: #fff;
    margin-bottom: 12px;
}

.brand-logo-img {
    max-width: 340px;
    height: auto;
    margin-bottom: 24px;
    filter: brightness(0) invert(1);
}

.brand-tagline {
    font-family: var(--font-primary);
    font-size: 20px;
    font-weight: 400;
    letter-spacing: 5px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
    line-height: 2;
}

.brand-decoration { margin-top: 40px; display: flex; justify-content: center; gap: 8px; }

.deco-line { width: 35px; height: 2px; background: rgba(255,255,255,0.1); border-radius: 2px; }
.deco-line:nth-child(2) { width: 60px; background: var(--accent); }

.login-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    background: #fff;
}

.login-form-container { width: 100%; max-width: 380px; }

.login-title {
    font-family: var(--font-display);
    font-size: 38px;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 6px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.login-form .form-group input {
    padding: 12px 16px;
    border-radius: 10px;
}

.login-form .btn-block {
    margin-top: 8px;
    padding: 13px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    border-radius: 10px;
}

/* ==========================================
   RESPONSIVE
   ========================================== */
.sidebar-toggle {
    display: none;
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: var(--radius);
    width: 38px; height: 38px;
    font-size: 18px;
    color: var(--text-dark);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover { background: #f5f5f5; }

@media (max-width: 1500px) {
    .metrics-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1100px) {
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: flex; }

    .content-header { padding: 0 16px; height: 52px; }
    .page-title { font-size: 16px; }
    .content-body { padding: 16px; }
    .header-search { display: none; }

    .metrics-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .metric-card { padding: 14px; }
    .metric-value { font-size: 22px; }
    .metric-icon-circle { width: 34px; height: 34px; }
    .metric-icon-circle svg { width: 16px; height: 16px; }

    .filters-form { flex-direction: column; align-items: stretch; }
    .filter-group select, .filter-group input { width: 100%; min-width: auto; }
    .detail-grid { grid-template-columns: 1fr; }

    .login-container { flex-direction: column; }
    .login-brand { padding: 40px 24px; min-height: auto; }
    .brand-logo { font-size: 32px; letter-spacing: 4px; }
    .brand-logo-img { max-width: 220px; }
    .login-form-panel { padding: 32px 24px; }
}

/* ==========================================
   PROSPECT DETAIL MODAL
   ========================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 500px;
    max-width: 100%;
    height: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
}

.modal-overlay.active .modal-panel {
    transform: translateX(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.modal-ref {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
    margin-right: 10px;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    border: 1px solid #e8e8e8;
    background: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.modal-close:hover {
    background: #f5f5f5;
    color: var(--accent);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    text-align: center;
}

.modal-loading {
    text-align: center;
    color: var(--text-muted);
    padding: 48px 0;
    font-size: 14px;
}

.modal-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.modal-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.modal-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
}

.modal-field {}

.modal-field .field-label {
    margin-bottom: 1px;
}

.modal-field .field-value {
    font-size: 13px;
}

.modal-field-full {
    margin-top: 10px;
}

.modal-field-full .field-value {
    font-size: 13px;
    white-space: pre-wrap;
}

.modal-note {
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
}

.modal-note:last-child {
    border-bottom: none;
}

.modal-doc {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f5;
}

.modal-doc:last-child {
    border-bottom: none;
}

.modal-doc a {
    font-size: 13px;
    font-weight: 500;
}

/* Full detail modal (centered, large) */
.modal-full {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 900px;
    max-width: calc(100% - 40px);
    max-height: calc(100vh - 60px);
    background: #fff;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.modal-overlay.active .modal-full {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.modal-full .modal-header {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-full .modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-full .card {
    margin-bottom: 16px;
}

.modal-full .detail-actions-row {
    flex-wrap: wrap;
}

/* Full modal detail (fm-) — v2 */
.fm-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    padding: 20px 24px;
    border-radius: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.fm-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.fm-empresa-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    flex-shrink: 0;
}
.fm-empresa-name {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}
.fm-ref-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}
.fm-ref {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
}
.fm-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
}

/* Toolbar */
.fm-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: #f8f9fb;
    border: 1px solid #eee;
    border-radius: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.fm-toolbar .inline-form {
    display: flex;
    align-items: center;
    gap: 6px;
}
.fm-toolbar-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
}
.fm-toolbar-sep {
    width: 1px;
    height: 24px;
    background: #ddd;
}
.fm-select {
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    background: #fff;
}
.fm-btn-delete {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border: 1px solid #fecaca;
    border-radius: 6px;
    background: #fff;
    color: #ef4444;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.fm-btn-delete:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

/* Grid */
.fm-grid {
    display: grid;
    grid-template-columns: 1.3fr 0.7fr;
    gap: 16px;
}

/* Cards */
.fm-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    margin-bottom: 14px;
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.fm-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}
.fm-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px 0;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #333;
}
.fm-card-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.fm-card-body {
    padding: 14px 18px 18px;
}

/* Data fields */
.fm-data-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.fm-data {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.fm-data-full {
    grid-column: 1 / -1;
}
.fm-data-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #aaa;
}
.fm-data-value {
    font-size: 13px;
    color: #333;
    font-weight: 500;
}
.fm-data-value a {
    color: var(--primary);
    text-decoration: none;
}
.fm-data-value a:hover {
    text-decoration: underline;
}
.fm-data-highlight {
    font-size: 15px;
    font-weight: 700;
    color: #059669;
}

/* Risk rows */
.fm-risk-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f5;
    gap: 12px;
}
.fm-risk-row:last-child {
    border-bottom: none;
}
.fm-risk-q {
    font-size: 12.5px;
    color: #555;
    flex: 1;
    line-height: 1.4;
}
.fm-risk-tag {
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.fm-tag-si {
    background: #d1fae5;
    color: #059669;
}
.fm-tag-no {
    background: #fee2e2;
    color: #dc2626;
}

/* Limits / Cotizacion */
.fm-limits {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.fm-limit-item {
    background: #f8f9fb;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}
.fm-limit-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #aaa;
    letter-spacing: 0.5px;
}
.fm-limit-value {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a2e;
    margin-top: 4px;
}
.fm-limit-prima {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
}
.fm-limit-prima .fm-limit-value {
    color: #059669;
    font-size: 18px;
}

/* Documents */
.fm-docs-section {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #f0f0f0;
}
.fm-doc {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f8f9fb;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 6px;
    text-decoration: none;
    transition: all 0.15s;
}
.fm-doc:hover {
    background: #eef0f2;
    border-color: #ddd;
}
.fm-doc-icon {
    width: 36px;
    height: 36px;
    background: #eef2ff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4f46e5;
    flex-shrink: 0;
}
.fm-doc-info {
    flex: 1;
}
.fm-doc-name {
    font-size: 13px;
    font-weight: 600;
    color: #333;
}
.fm-doc-meta {
    font-size: 11px;
    color: #999;
}

/* Contact */
.fm-contact-card {
    text-align: center;
    padding: 10px 0 16px;
}
.fm-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    margin: 0 auto 10px;
}
.fm-contact-name {
    font-size: 17px;
    font-weight: 700;
    color: #1a1a2e;
}
.fm-contact-role {
    font-size: 13px;
    color: #888;
    margin-top: 2px;
}
.fm-contact-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.fm-contact-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: #f8f9fb;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    font-size: 13px;
    color: #333;
    text-decoration: none;
    transition: all 0.15s;
}
.fm-contact-row:hover {
    background: #eef0f2;
    border-color: #ddd;
}
.fm-contact-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.fm-msg {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #f0f0f0;
}
.fm-msg-text {
    font-size: 13px;
    color: #555;
    line-height: 1.6;
    margin-top: 6px;
    background: #f8f9fb;
    padding: 10px 14px;
    border-radius: 8px;
}

/* Notes */
.fm-note-form {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}
.fm-note-form textarea {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    min-height: 40px;
    transition: border-color 0.2s;
}
.fm-note-form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.fm-note-form .btn {
    align-self: flex-end;
}
.fm-notes {
    display: flex;
    flex-direction: column;
}
.fm-note {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
}
.fm-note:last-child {
    border-bottom: none;
}
.fm-note-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e0e7ff;
    color: #4f46e5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}
.fm-note-body {
    flex: 1;
    min-width: 0;
}
.fm-note-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}
.fm-note-top strong {
    font-size: 12px;
    color: #1a1a2e;
}
.fm-note-top span {
    font-size: 11px;
    color: #bbb;
}
.fm-note-body p {
    font-size: 13px;
    color: #555;
    line-height: 1.5;
    margin: 0;
}
.fm-empty {
    text-align: center;
    color: #ccc;
    font-size: 13px;
    padding: 20px 0;
}

@media (max-width: 768px) {
    .fm-grid { grid-template-columns: 1fr; }
    .fm-header { flex-direction: column; align-items: flex-start; }
    .fm-data-grid { grid-template-columns: 1fr; }
    .fm-limits { grid-template-columns: 1fr; }
    .fm-toolbar { flex-direction: column; align-items: flex-start; }
    .fm-toolbar-sep { display: none; }
}

@media (max-width: 768px) {
    .modal-panel {
        width: 100%;
    }

    .modal-full {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        top: 0;
        left: 0;
        transform: none;
        border-radius: 0;
        height: 100%;
    }

    .modal-overlay.active .modal-full {
        transform: none;
    }

    .modal-full .modal-header {
        border-radius: 0;
    }
}
