@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg: #0b0f19;
    --bg-card: rgba(255,255,255,0.03);
    --bg-input: rgba(19,26,42,0.6);
    --bg-panel: #0f1422;
    --bg-secondary: #131a2a;
    --border: rgba(255,255,255,0.08);
    --border-focus: #3b82f6;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-hint: #64748b;
    --accent: #3b82f6;
    --accent-dark: #2563eb;
    --green: #27ae60;
    --green-bg: rgba(39,174,96,0.12);
    --green-border: rgba(39,174,96,0.3);
    --amber: #f59e0b;
    --amber-bg: rgba(245,158,11,0.12);
    --amber-border: rgba(245,158,11,0.3);
    --red: #e74c3c;
    --red-bg: rgba(231,76,60,0.12);
    --red-border: rgba(231,76,60,0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, sans-serif;
}

/* =============================
   LIGHT THEME OVERRIDES (cob vars)
   ============================= */
html[data-theme="light"] {
    --bg: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-panel: #ffffff;
    --bg-secondary: #fafafa;
    --border: rgba(0, 0, 0, 0.06);
    --border-focus: #3b82f6;
    --text: #1a1a1a;
    --text-muted: #4b5563;
    --text-hint: #6b7280;
    --accent: #3b82f6;
    --accent-dark: #2563eb;
    --green: #16a34a;
    --green-bg: rgba(22, 163, 74, 0.08);
    --green-border: rgba(22, 163, 74, 0.18);
    --amber: #d97706;
    --amber-bg: rgba(217, 119, 6, 0.08);
    --amber-border: rgba(217, 119, 6, 0.18);
    --red: #e53e3e;
    --red-bg: rgba(229, 62, 62, 0.08);
    --red-border: rgba(229, 62, 62, 0.18);
}

html[data-theme="light"] body {
    background: var(--bg);
    color: var(--text);
}

.cob-header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

html[data-theme="light"] .cob-header {
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.04);
}
html[data-theme="light"] .cob-logo {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
}
html[data-theme="light"] .cob-logo svg {
    color: #3b82f6 !important;
}

html[data-theme="light"] .cob-header-link {
    color: var(--text-muted);
    border-color: rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .cob-header-link:hover {
    background: rgba(59, 130, 246, 0.06);
    border-color: rgba(59, 130, 246, 0.2);
    color: var(--accent);
}

html[data-theme="light"] .cob-card {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.03);
}

html[data-theme="light"] .cob-input,
html[data-theme="light"] .cob-select,
html[data-theme="light"] .cob-textarea {
    background: #fafafa;
    border-color: rgba(0, 0, 0, 0.08);
    color: var(--text);
}

html[data-theme="light"] .cob-input:focus,
html[data-theme="light"] .cob-select:focus,
html[data-theme="light"] .cob-textarea:focus {
    background: #ffffff;
    border-color: var(--border-focus);
}
html[data-theme="light"] .bitacora-group--other {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
    opacity: 0.9;
}
html[data-theme="light"] .bitacora-group--other .bitacora-ref {
    color: #4b5563;
    border-bottom-color: rgba(0, 0, 0, 0.06);
}
html[data-theme="light"] .bitacora-group--other .bitacora-item {
    border-bottom-color: rgba(0, 0, 0, 0.04);
}
html[data-theme="light"] .badge-status--cancelado {
    color: #4b5563;
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.1);
}
html[data-theme="light"] .badge-status--pendiente {
    background: rgba(0, 0, 0, 0.03);
    color: #6b7280;
    border-color: rgba(0, 0, 0, 0.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    min-height: 100vh;
}

/* ── Header ── */
.cob-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 28px;
    background: rgba(11,13,16,.55);
    border-bottom: 1px solid rgba(148,163,184,.08);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 50;
}
.cob-logo { 
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, #63a4ff 0%, #93c5fd 60%, #7dd3fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    letter-spacing: -0.4px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.1s ease;
    flex-shrink: 0;
}
.cob-logo:hover {
    -webkit-text-fill-color: #7db8ff;
    background: none;
}
.cob-logo svg { color: #3b82f6; }
.cob-divider { width: 1px; height: 20px; background: var(--border); }
.cob-title { font-weight: 600; font-size: 0.95rem; color: var(--text); }
.cob-header-spacer { flex: 1; }
.cob-header-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 8px;
    transition: background 0.08s, color 0.08s;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font);
}
.cob-header-link:hover { background: rgba(255,255,255,0.06); color: var(--text); }

/* ── Main layout ── */
.cob-main {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 24px;
    width: 100%;
}

.cob-main--wide { max-width: 1400px; }

/* ── Card ── */
.cob-card {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.7) 0%, rgba(15, 23, 42, 0.5) 100%);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 20px;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.03);
    transition: all 0.1s ease;
}
.cob-card:hover {
    border-color: rgba(99, 102, 241, 0.2);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(99, 102, 241, 0.08);
}
.cob-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.cob-card-title .badge {
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--accent);
    color: #fff;
    border-radius: 20px;
    padding: 2px 10px;
}

/* ── Form fields ── */
.cob-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.cob-input, .cob-select {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9rem;
    padding: 10px 14px;
    transition: border-color 0.08s;
    outline: none;
    appearance: none;
}
.cob-input:focus, .cob-select:focus { border-color: var(--border-focus); }
.cob-input::placeholder { color: var(--text-hint); }
.cob-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.cob-select option { background: #131a2a; }

.cob-field { margin-bottom: 16px; }
.cob-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cob-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Buttons ── */
.cob-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.08s, transform 0.05s;
}
.cob-btn:active { transform: scale(0.98); }
.cob-btn--primary { background: linear-gradient(135deg,#3b82f6,#2563eb); color: #fff; }
.cob-btn--primary:hover { opacity: 0.9; }
.cob-btn--secondary { background: rgba(255,255,255,0.06); color: var(--text); border: 1px solid var(--border); }
.cob-btn--secondary:hover { background: rgba(255,255,255,0.1); }
.cob-btn--danger { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.cob-btn--danger:hover { background: rgba(231,76,60,0.2); }
.cob-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.cob-btn--primary { background: rgba(59,130,246,0.15); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.cob-btn--primary:hover { background: rgba(59,130,246,0.25); }

/* Light theme: primary button with proper contrast */
html[data-theme="light"] .cob-btn--primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}
html[data-theme="light"] .cob-btn--primary:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}
html[data-theme="light"] .cob-btn--secondary {
    background: #fafafa;
    color: #374151;
    border-color: rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] .cob-btn--secondary:hover {
    background: #f3f4f6;
    border-color: rgba(59, 130, 246, 0.2);
    color: #1a1a1a;
}

/* ── Bitácora timeline ── */
.bitacora-timeline { display: flex; flex-direction: column; gap: 0; }
.bitacora-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.bitacora-item:last-child { border-bottom: none; }
.bitacora-icon { font-size: 16px; flex-shrink: 0; width: 24px; text-align: center; margin-top: 1px; }
.bitacora-body { flex: 1; min-width: 0; }
.bitacora-desc { font-size: 13px; color: var(--text); line-height: 1.45; }
.bitacora-meta { font-size: 11px; color: var(--text-hint); margin-top: 2px; }
.bitacora-group--other { background: rgba(6,13,26,0.5); border: 1px solid rgba(148,163,184,0.15); border-radius: 8px; padding: 10px 12px; margin: 4px 0; opacity: 0.75; }
.bitacora-group--other .bitacora-ref { font-size: 0.72rem; color: #94a3b8; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 6px; border-bottom: 1px solid rgba(148,163,184,0.1); padding-bottom: 5px; }
.bitacora-group--other .bitacora-item { padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.bitacora-group--other .bitacora-item:last-child { border-bottom: none; padding-bottom: 0; }

/* ── Table ── */
.cob-table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.cob-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.cob-table th {
    background: rgba(255,255,255,0.04);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.cob-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--text);
    vertical-align: middle;
}
.cob-table tr:last-child td { border-bottom: none; }
.cob-table tr:hover td { background: rgba(255,255,255,0.02); }
.cob-table .mono { font-family: monospace; font-size: 0.8rem; color: var(--text-muted); }

/* ── Badges de estatus ── */
.badge-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-status--corriente { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.badge-status--atraso    { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }
.badge-status--grave     { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.badge-status--liquidado { background: rgba(59,130,246,0.12); color: var(--accent); border: 1px solid rgba(59,130,246,0.3); }
.badge-status--pagado    { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.badge-status--pendiente { background: rgba(255,255,255,0.05); color: var(--text-muted); border: 1px solid var(--border); }
.badge-status--parcial   { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }
.badge-status--cancelado { background: rgba(127,127,127,0.12); color: #94a3b8; border: 1px solid rgba(127,127,127,0.3); }

/* ── Ícono de estatus en tabla de amortización ── */
.amort-status-icon { display: inline-flex; align-items: center; justify-content: center; }
.amort-status-icon svg { width: 20px; height: 20px; display: block; }
.amort-status-icon--pagado    { color: var(--green); }
.amort-status-icon--parcial   { color: var(--amber); }
.amort-status-icon--pendiente { color: var(--text-muted); }
.amort-status-icon--vencido   { color: var(--red); }

/* ── Semáforo de cobranza ── */
.cob-semaforo {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.cob-semaforo-item {
    flex: 1;
    min-width: 140px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.cob-semaforo-item .num { font-size: 2rem; font-weight: 800; line-height: 1; }
.cob-semaforo-item .lbl { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.cob-semaforo-item--green .num { color: var(--green); }
.cob-semaforo-item--amber .num { color: var(--amber); }
.cob-semaforo-item--red   .num { color: var(--red); }
.cob-semaforo-item--blue  .num { color: var(--accent); }

/* ── Estado de cuenta ── */
.cob-cuenta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.cob-cuenta-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}
.cob-cuenta-item .lbl { font-size: 0.72rem; color: var(--text-hint); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.cob-cuenta-item .val { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.cob-cuenta-item .val--green { color: var(--green); }
.cob-cuenta-item .val--amber { color: var(--amber); }
.cob-cuenta-item .val--red   { color: var(--red); }

/* ── Aviso de contrato preliminar / requiere actualización ── */
.cob-preliminar-banner {
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 20px;
    font-size: 0.85rem;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.cob-preliminar-banner .cob-pb-icon { font-size: 1.1rem; line-height: 1; flex-shrink: 0; }
.cob-preliminar-banner .cob-pb-body { flex: 1; min-width: 0; }
.cob-preliminar-banner .cob-pb-title { font-weight: 700; margin-bottom: 2px; }
.cob-preliminar-banner .cob-pb-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.cob-preliminar-banner--info {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.35);
    color: #c7d2fe;
}
.cob-preliminar-banner--warn {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #fcd34d;
}
html[data-theme="light"] .cob-preliminar-banner--info { color: #4338ca; }
html[data-theme="light"] .cob-preliminar-banner--warn { color: #b45309; }

/* ── Conversión de apartado (moneda apartado ≠ moneda contrato) ── */
.apartado-conv-card {
    border-radius: var(--radius-sm);
    padding: 16px;
    margin: 4px 0 16px;
    background: rgba(245, 158, 11, 0.10);
    border: 1px solid rgba(245, 158, 11, 0.4);
    font-size: 0.85rem;
    line-height: 1.5;
}
.apartado-conv-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.apartado-conv-icon { font-size: 1.2rem; line-height: 1; flex-shrink: 0; }
.apartado-conv-title { font-weight: 700; color: #fcd34d; }
.apartado-conv-sub { color: var(--text-muted, #94a3b8); margin-top: 2px; }
.apartado-conv-row { margin-bottom: 10px; }
.apartado-conv-row .cob-input { max-width: 220px; }
.apartado-conv-hint { display: block; margin-top: 4px; color: var(--text-muted, #94a3b8); font-size: 0.78rem; }
.apartado-conv-result {
    background: rgba(0, 0, 0, 0.18);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 12px;
    font-weight: 600;
}
/* Aviso al reconvertir montos del contrato por cambio de moneda del switch */
.moneda-conv-notice {
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin: 4px 0 16px;
    background: rgba(96, 165, 250, 0.10);
    border: 1px solid rgba(96, 165, 250, 0.4);
    color: #bfdbfe;
    font-size: 0.8rem;
    line-height: 1.5;
}
html[data-theme="light"] .moneda-conv-notice { color: #1d4ed8; }

.apartado-conv-accept { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.apartado-conv-accept input { margin-top: 3px; flex-shrink: 0; }
html[data-theme="light"] .apartado-conv-title { color: #b45309; }
html[data-theme="light"] .apartado-conv-result { background: rgba(0, 0, 0, 0.05); }

/* ── Modal ── */
.cob-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
    padding: 16px;
}
.cob-modal-overlay.hidden { display: none; }
.cob-modal {
    background: #0f1422;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}
.cob-modal-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.cob-modal-close {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 1.2rem; padding: 4px;
}

/* ── Misc ── */
.cob-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.cob-section-title { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.cob-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-hint);
}
.cob-back-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--text-muted); text-decoration: none; font-size: 0.85rem;
    margin-bottom: 20px;
}
.cob-back-link:hover { color: var(--text); }
.cob-info-row {
    display: flex; gap: 6px; align-items: baseline;
    font-size: 0.85rem; color: var(--text-muted);
    margin-bottom: 8px;
}
.cob-info-row strong { color: var(--text); font-weight: 600; }
.cob-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

/* ── Loading ── */
.cob-loading { text-align: center; padding: 64px; color: var(--text-hint); }

/* ── List card grid (contratos, abonos, etc.) ── */
.cob-listgrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}
.cob-listcard {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.08s;
}
.cob-listcard:hover { border-color: rgba(59,130,246,0.35); }
.cob-listcard--warn { border-color: rgba(231,76,60,0.35); }
.cob-listcard--warn:hover { border-color: rgba(231,76,60,0.55); }
.cob-listcard--cancelled { opacity: 0.55; border-color: rgba(127,127,127,0.25); }
.cob-listcard--cancelled:hover { opacity: 0.8; border-color: rgba(127,127,127,0.4); }

.cob-listcard-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.cob-listcard-ref {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}
.cob-listcard-date {
    font-size: 0.72rem;
    color: var(--text-hint);
    background: rgba(255,255,255,0.04);
    padding: 2px 8px;
    border-radius: 6px;
}
.cob-listcard-title {
    font-weight: 700;
    font-size: 0.98rem;
    color: var(--text);
    line-height: 1.2;
}
.cob-listcard-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.72rem;
}
.cob-listcard-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}

/* Chips */
.cob-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(148,163,184,0.1);
    color: var(--text-muted);
}
.cob-chip--mono { font-family: monospace; background: rgba(59,130,246,0.12); color: #93c5fd; }
.cob-chip--success { background: rgba(39,174,96,0.14); color: #6ee7a7; }
.cob-chip--warn { background: rgba(231,76,60,0.14); color: #fca5a5; }

/* Montos destacados */
.cob-amount { font-size: 1.05rem; font-weight: 800; letter-spacing: 0.01em; color: var(--text); }
.cob-amount--success { color: #6ee7a7; }
.cob-amount--warn { color: #fca5a5; }

/* Grid de métricas dentro de card */
.cob-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 10px 0 2px;
    border-top: 1px dashed var(--border);
}
.cob-metric { min-width: 0; }
.cob-metric-lbl {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-hint);
    margin-bottom: 3px;
}
.cob-metric-val {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cob-metric-val--ok { color: var(--green); }
.cob-metric-val--warn { color: var(--red); }
.cob-metric-val--muted { color: var(--text-hint); font-weight: 500; }

/* Acciones dentro de card */
.cob-listcard-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.cob-listcard-actions .cob-btn { justify-content: center; padding: 8px 12px; font-size: 0.82rem; }

@media (max-width: 600px) {
    .cob-listgrid { grid-template-columns: 1fr; }
    .cob-listcard { padding: 12px 14px; border-radius: 12px; }
}

/* ── Mobile ── */
@media (max-width: 780px) {
    .cob-header {
        padding: 10px 12px;
        gap: 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .cob-header::-webkit-scrollbar { display: none; }
    .cob-logo { font-size: 18px; flex-shrink: 0; }
    .cob-divider { display: none; }
    .cob-title {
        font-size: 0.82rem;
        font-weight: 600;
        flex-shrink: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 40vw;
    }
    .cob-header-spacer { flex: 1; min-width: 4px; }
    .cob-header-link {
        font-size: 0.76rem;
        padding: 5px 9px;
        flex-shrink: 0;
        white-space: nowrap;
    }

    .cob-main { padding: 16px 12px; }
    .cob-card { padding: 16px; margin-bottom: 14px; border-radius: 10px; }

    .cob-section-header { flex-direction: column; align-items: stretch; gap: 10px; }
    .cob-section-header .cob-btn { width: 100%; justify-content: center; }

    .cob-cuenta { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .cob-cuenta-item { padding: 10px 12px; }
    .cob-cuenta-item .val { font-size: 0.95rem; }

    .cob-semaforo-item { min-width: 0; padding: 12px; }
    .cob-semaforo-item .num { font-size: 1.5rem; }

    .cob-table { font-size: 0.78rem; }
    .cob-table th { padding: 8px 10px; font-size: 0.7rem; }
    .cob-table td { padding: 9px 10px; }
    .cob-table .mono { font-size: 0.72rem; }

    .cob-btn { padding: 9px 14px; font-size: 0.82rem; }

    .cob-modal { padding: 18px; border-radius: 10px; }
    .cob-modal-title { font-size: 0.95rem; margin-bottom: 14px; }
}

/* =============================
   CONTRATOS PAGE — LIGHT THEME
   ============================= */
html[data-theme="light"] .ct-resumen .cob-cuenta-item {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
html[data-theme="light"] .ct-resumen .cob-cuenta-item:hover {
    border-color: rgba(59, 130, 246, 0.2);
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
html[data-theme="light"] .ct-resumen .lbl {
    color: #4b5563;
}
html[data-theme="light"] .ct-resumen .val {
    color: #1a1a1a;
}
html[data-theme="light"] .ct-resumen .val--warn {
    color: #dc2626;
}

/* Banner de contratos — tema claro */
html[data-theme="light"] .ct-banner,
html[data-theme="light"] .ct-banner-contratos {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(99, 102, 241, 0.05) 100%);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 14px;
    color: #2563eb;
    font-size: 0.9rem;
    backdrop-filter: blur(8px);
    padding: 16px 20px;
    margin-bottom: 20px;
}
html[data-theme="light"] .ct-banner strong,
html[data-theme="light"] .ct-banner-contratos strong {
    color: #1d4ed8;
    font-weight: 600;
}

/* Banner de contratos — tema oscuro (default) */
.ct-banner {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(99, 102, 241, 0.1) 100%);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 14px;
    color: #93c5fd;
    font-size: 0.9rem;
    backdrop-filter: blur(8px);
    padding: 16px 20px;
    margin-bottom: 20px;
}
.ct-banner strong {
    font-weight: 600;
}

@media (max-width: 600px) {
    .cob-row, .cob-row-3 { grid-template-columns: 1fr; gap: 12px; }
    .cob-cuenta { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .cob-cuenta-item { padding: 10px 12px; }
    .cob-cuenta-item .val { font-size: 0.9rem; }
    .cob-semaforo { gap: 8px; margin-bottom: 16px; }
    .cob-actions .cob-btn { flex: 1 1 100%; justify-content: center; }
}

/* ── Panel colapsable de datos opcionales ── */
.cls-datos-opcionales summary::-webkit-details-marker { display: none; }
.cls-datos-opcionales summary span { display: inline-block; }
.cls-datos-opcionales[open] summary span { transform: rotate(90deg); }

/* Light theme overrides para panel colapsable */
html[data-theme="light"] .cls-datos-opcionales {
    border-color: rgba(0, 0, 0, 0.08) !important;
}
html[data-theme="light"] .cls-datos-opcionales summary {
    background: #f8fafc !important;
    color: #64748b !important;
}

/* ── Menú de exportar (consolida CSV/Excel/PDF) ── */
.cob-export-menu { position: relative; margin-left: auto; }
.cob-export-menu > summary { list-style: none; cursor: pointer; user-select: none; }
.cob-export-menu > summary::-webkit-details-marker { display: none; }
.cob-export-menu-list {
    position: absolute; right: 0; top: calc(100% + 4px); z-index: 30;
    display: flex; flex-direction: column; min-width: 148px; padding: 4px;
    background: var(--bg-secondary, #1e293b);
    border: 1px solid rgba(148,163,184,0.2); border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.cob-export-item {
    display: flex; align-items: center; gap: 6px; width: 100%;
    padding: 8px 10px; border: 0; border-radius: 6px; background: transparent;
    color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.cob-export-item:hover { background: rgba(148,163,184,0.12); }
.cob-beta-badge {
    font-size: 0.55rem; font-weight: 700; padding: 1px 5px; border-radius: 20px;
    background: rgba(251,191,36,0.18); color: #fbbf24;
    border: 1px solid rgba(251,191,36,0.35); letter-spacing: 0.04em;
}

/* Detalle de cargos moratorios en calendario de pagos */
.amort-list #tbody-amort {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.amort-mora {
    flex: 0 0 100%;
    margin: 0;
    padding: 9px 12px;
    border: 1px solid rgba(239, 68, 68, 0.18);
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.055);
    color: var(--text-muted);
    font-size: 0.78rem;
    display: flex;
    flex-direction: column;
    gap: 3px;
    line-height: 1.35;
}
.amort-mora--info {
    background: rgba(59, 130, 246, 0.055);
    border-color: rgba(59, 130, 246, 0.18);
}
.amort-mora--warning {
    background: rgba(245, 158, 11, 0.06);
    border-color: rgba(245, 158, 11, 0.2);
}
.amort-mora--danger {
    background: rgba(239, 68, 68, 0.055);
    border-color: rgba(239, 68, 68, 0.18);
}
.amort-list .amort-row.amort-row--with-mora {
    align-items: flex-start;
    flex-wrap: wrap;
    row-gap: 10px;
}
.amort-mora-line { color: #a8b3c7; }
.amort-mora-note { color: var(--text-hint); }
.amort-mora-state { color: #cbd5e1; }
.amort-mora-state--cobrado { color: var(--green); }
.amort-mora-state--parcial { color: var(--amber); }
.amort-mora-state--pendiente { color: #ef4444; }
html[data-theme="light"] .amort-mora {
    background: rgba(239,68,68,0.045);
    border-color: rgba(220,38,38,0.14);
}
html[data-theme="light"] .amort-mora--info {
    background: rgba(59,130,246,0.045);
    border-color: rgba(37,99,235,0.14);
}
html[data-theme="light"] .amort-mora--warning {
    background: rgba(217,119,6,0.055);
    border-color: rgba(217,119,6,0.16);
}
html[data-theme="light"] .amort-mora--danger {
    background: rgba(239,68,68,0.045);
    border-color: rgba(220,38,38,0.14);
}
html[data-theme="light"] .amort-mora-line { color: #334155; }
html[data-theme="light"] .amort-mora-note { color: #64748b; }
html[data-theme="light"] .amort-mora-state { color: #475569; }
html[data-theme="light"] .amort-mora-state--cobrado { color: #16a34a; }
html[data-theme="light"] .amort-mora-state--parcial { color: #d97706; }
html[data-theme="light"] .amort-mora-state--pendiente { color: #dc2626; }

@media (max-width: 720px) {
    .amort-mora {
        grid-column: 1 / -1;
        margin: 6px 0 0 0;
        padding: 10px 12px;
        width: 100%;
    }
}

/* Abono: toggle "sólo capital" (deja pendiente el interés moratorio) */
.abono-solo-capital { margin: 0 0 12px; }
.abono-solo-capital[hidden] { display: none; }
.abono-solo-capital-label {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border: 1px solid rgba(245, 158, 11, 0.45);
    border-radius: 10px;
    background: rgba(245, 158, 11, 0.10);
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease;
}
.abono-solo-capital-label input { margin-top: 3px; flex-shrink: 0; }
.abono-solo-capital-label strong { font-size: 0.9rem; }
.abono-solo-capital-label small {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 2px;
    line-height: 1.4;
}
.abono-solo-capital.is-active .abono-solo-capital-label {
    border-color: rgba(59, 130, 246, 0.55);
    background: rgba(59, 130, 246, 0.12);
}
.abono-solo-capital.is-disabled .abono-solo-capital-label {
    border-color: var(--border);
    background: rgba(148, 163, 184, 0.08);
    cursor: not-allowed;
    opacity: 0.72;
}

/* Abono: gestión de interés moratorio (condonar) */
.abono-mora-gestion { margin: 0 0 12px; padding: 12px 14px; border: 1px solid rgba(239, 68, 68, 0.3); border-radius: 10px; background: rgba(239, 68, 68, 0.06); }
.abono-mora-gestion[hidden] { display: none; }
.abono-mora-gestion-title { font-size: 0.9rem; font-weight: 700; color: #fca5a5; margin-bottom: 2px; }
.abono-mora-gestion-hint { font-size: 0.76rem; color: var(--text-muted); margin-bottom: 10px; }
.abono-mora-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid rgba(239, 68, 68, 0.18); }
.abono-mora-item:first-of-type { border-top: none; }
.abono-mora-item-info { display: flex; flex-direction: column; gap: 2px; }
.abono-mora-item-cuota { font-size: 0.82rem; color: var(--text-muted); }
.abono-mora-item-monto { font-size: 0.88rem; font-weight: 700; color: #fca5a5; }
.abono-mora-condonar { padding: 5px 12px; font-size: 0.76rem; }
.abono-mora-collapsed-total { font-size: 0.95rem; font-weight: 800; color: #fca5a5; }
