@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@500;600;700&display=swap');

:root {
    --bg-main: #F5F7FA;
    --bg-sidebar: #111827;
    --bg-card: #FFFFFF;
    --primary: #2563EB;
    --primary-dark: #1D4ED8;
    --danger: #EF4444;
    --warning: #FACC15;
    --info: #3B82F6;
    --purple: #8B5CF6;
    --success: #22C55E;
    --text-main: #0F172A;
    --text-soft: #6B7280;
    --text-muted: #9CA3AF;
    --radius-lg: 16px;
    --radius-md: 12px;
    --shadow-soft: 0 18px 40px rgba(15, 23, 42, 0.08);
    --shadow-subtle: 0 10px 24px rgba(15, 23, 42, 0.05);
    --cr-green: var(--primary);
    --cr-white: #ffffff;
    --cr-text: var(--text-main);
    --cr-red: var(--danger);
    --cr-red-hover: #F87171;
    --cr-ui: var(--bg-main);
    --cr-border: #E5E7EB;
    --cr-muted: var(--text-muted);
    --cr-shadow: rgba(15, 23, 42, 0.08);
    --cr-radius: var(--radius-md);
    --sap-yellow-bg: #FFF4CC;
    --sap-yellow-border: #E6D8A8;
    --sap-yellow-focus: #FFECB3;
}

body {
    background: var(--cr-ui);
    color: var(--cr-text);
    font-family: 'Inter', system-ui, sans-serif;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Poppins', system-ui, sans-serif;
    letter-spacing: 0.02em;
}

.content-wrapper,
.main-nav,
.panel,
.grid,
.table-wrapper {
    color: var(--cr-text);
}

.panel {
    background: var(--bg-card);
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: var(--shadow-soft);
    border-radius: var(--radius-lg);
}

.card {
    background: var(--bg-card);
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: var(--shadow-subtle);
    border-radius: var(--radius-lg);
}

.btn {
    border-radius: 999px;
    font-weight: 500;
    padding: 0.55rem 1rem;
    background: #E5E7EB;
    color: var(--text-main);
    border: 1px solid #E5E7EB;
    box-shadow: var(--shadow-subtle);
    transition: background 180ms ease-out, border-color 180ms ease-out, box-shadow 180ms ease-out, transform 180ms ease-out, color 180ms ease-out;
}

#btn-submit-loan,
#btn-submit-loan:hover,
#btn-submit-loan:focus,
#btn-submit-loan:active {
    background: #64bc33;
    border-color: #64bc33;
    color: #ffffff;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #F9FAFB;
    border: 1px solid var(--primary-dark);
    box-shadow: 0 14px 30px rgba(37, 99, 235, 0.36);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 36px rgba(37, 99, 235, 0.42);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #DC2626);
    color: #FEF2F2;
    border: 1px solid var(--danger);
    box-shadow: 0 12px 28px rgba(220, 38, 38, 0.35);
}

.btn-danger:hover {
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid rgba(148, 163, 184, 0.7);
}

.btn-outline:hover {
    background: rgba(15, 23, 42, 0.03);
    color: var(--primary-dark);
}

.alert {
    border-radius: var(--cr-radius);
    padding: 0.75rem 1rem;
    margin: 0;
}

.alert-success {
    border: 1px solid var(--cr-green);
    background: var(--cr-white);
    color: var(--cr-text);
}

.alert-danger,
.alert-error {
    border: 1px solid var(--cr-red);
    color: var(--cr-red);
    background: var(--cr-white);
}

.alert-warning {
    border: 1px solid var(--cr-border);
    color: var(--cr-muted);
    background: var(--cr-white);
}

.sap-box {
    background: var(--sap-yellow-bg);
    border: 1px solid var(--sap-yellow-border);
    border-radius: 6px;
    padding: 10px 14px;
    color: var(--cr-text);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.sap-box strong {
    font-weight: 600;
}

.sap-focus:focus {
    background: var(--sap-yellow-focus);
    border-color: var(--sap-yellow-border);
    outline: none;
}

.sap-row-active {
    background: var(--sap-yellow-bg);
}

.info-note {
    font-size: 0.85rem;
    color: var(--cr-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.info-note .info-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid var(--cr-muted);
    color: var(--cr-muted);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: 0.75rem;
    background: var(--cr-ui);
}

.document-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.document-item {
    border: 1px solid var(--cr-border);
    border-radius: 10px;
    padding: 1rem;
    background: var(--cr-white);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.document-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--cr-text);
}

.document-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.document-inputs label {
    font-size: 0.85rem;
    color: var(--cr-muted);
    margin-bottom: 0.15rem;
    display: block;
}

.document-inputs input[type="file"],
.document-inputs textarea {
    width: 100%;
    border: 1px solid var(--cr-border);
    border-radius: 6px;
    padding: 0.55rem;
    font-family: inherit;
}

.document-inputs textarea {
    min-height: 72px;
    resize: vertical;
    max-height: 110px;
}

.loan-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 720px) {
    .loan-form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.loan-form-grid .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.loan-form-grid .form-group.full {
    grid-column: 1 / -1;
}

.loan-form-grid label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--cr-muted);
}

.loan-form-grid input,
.loan-form-grid select,
.loan-form-grid textarea {
    padding: 0.65rem;
    border: 1px solid var(--cr-border);
    border-radius: 0.4rem;
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--cr-white);
    height: 42px;
    box-sizing: border-box;
}

.loan-form-grid textarea {
    height: auto;
}
.document-divider {
    height: 1px;
    background: var(--cr-border);
    margin: 0;
}

@media (max-width: 768px) {
    .document-inputs textarea {
        min-height: 100px;
    }
}

.form-card {
    background: var(--bg-card);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-soft);
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 1rem;
    align-items: stretch;
}

.form-column {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.form-field label {
    font-size: 0.85rem;
    color: var(--cr-muted);
    margin-bottom: 0.35rem;
    display: block;
}

.form-actions {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.75rem;
}

.form-actions-top {
    justify-content: flex-start;
    padding-bottom: 1rem;
}


.form-actions--stack {
    flex-direction: column;
    gap: 0.65rem;
    align-items: flex-end;
}

.form-actions button {
    width: 100%;
}

@media (max-width: 900px) {
    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .form-column--actions .form-actions {
        align-items: center;
    }
}

@media (max-width: 1100px) {
    .loans-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

table {
    border-collapse: collapse;
    background: var(--bg-card);
}

th {
    background: linear-gradient(90deg, #EEF2FF, #E0F2FE);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
}

tr:nth-child(even) {
    background: #F9FAFB;
}

tr:hover {
    background: #EFF6FF;
}

.badge {
    padding: 0.2rem 0.8rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.badge-success {
    background: rgba(34, 197, 94, 0.16);
    color: #15803D;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.16);
    color: #B91C1C;
}

.badge-muted {
    background: var(--cr-border);
    color: var(--cr-muted);
}

.badge-warning {
    background: rgba(250, 204, 21, 0.18);
    color: #854D0E;
}

.badge-info {
    background: rgba(59, 130, 246, 0.14);
    color: #1D4ED8;
}

.badge-purple {
    background: rgba(139, 92, 246, 0.14);
    color: #6D28D9;
}

.badge-status::before {
    content: "";
    display: inline-block;
    width: 22px;
    height: 10px;
    border-radius: 999px;
    margin-right: 2px;
    background: radial-gradient(circle at 4px 50%, rgba(55, 65, 81, 0.16) 0, rgba(55, 65, 81, 0.16) 45%, transparent 60%), radial-gradient(circle at 11px 50%, rgba(55, 65, 81, 0.16) 0, rgba(55, 65, 81, 0.16) 45%, transparent 60%), radial-gradient(circle at 18px 50%, rgba(55, 65, 81, 0.16) 0, rgba(55, 65, 81, 0.16) 45%, transparent 60%);
}

.badge-status.badge-pendiente::before,
.badge-status.badge-revision::before {
    background: radial-gradient(circle at 4px 50%, rgba(148, 163, 184, 0.25) 0, rgba(148, 163, 184, 0.25) 42%, transparent 60%), radial-gradient(circle at 11px 50%, rgba(250, 204, 21, 0.9) 0, rgba(250, 204, 21, 0.9) 45%, transparent 60%), radial-gradient(circle at 18px 50%, rgba(148, 163, 184, 0.25) 0, rgba(148, 163, 184, 0.25) 45%, transparent 60%);
}

.badge-status.badge-gestion::before,
.badge-status.badge-liquidacion::before {
    background: radial-gradient(circle at 4px 50%, rgba(239, 68, 68, 0.88) 0, rgba(239, 68, 68, 0.88) 42%, transparent 60%), radial-gradient(circle at 11px 50%, rgba(148, 163, 184, 0.25) 0, rgba(148, 163, 184, 0.25) 45%, transparent 60%), radial-gradient(circle at 18px 50%, rgba(148, 163, 184, 0.25) 0, rgba(148, 163, 184, 0.25) 45%, transparent 60%);
}

.badge-status.badge-cerrado::before {
    background: radial-gradient(circle at 4px 50%, rgba(148, 163, 184, 0.25) 0, rgba(148, 163, 184, 0.25) 42%, transparent 60%), radial-gradient(circle at 11px 50%, rgba(148, 163, 184, 0.25) 0, rgba(148, 163, 184, 0.25) 45%, transparent 60%), radial-gradient(circle at 18px 50%, rgba(34, 197, 94, 0.95) 0, rgba(34, 197, 94, 0.95) 45%, transparent 60%);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    align-items: flex-end;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-field--checkbox label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 500;
}

.form-field label {
    font-size: 0.85rem;
    color: var(--cr-muted);
}

.form-field button {
    height: 38px;
}

.form-field--actions {
    justify-content: flex-end;
}

.page-grid {
    display: grid;
    gap: 1.5rem;
}

.loans-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.4fr) minmax(0, 0.6fr);
    gap: 1.5rem;
    align-items: start;
}

.loans-grid > .action-panel {
    order: 2;
}

.loans-grid > .control-panel {
    order: 1;
}

.action-panel,
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.action-panel .panel,
.control-panel .panel {
    width: 100%;
}

.action-panel .panel {
    border-radius: var(--cr-radius);
}

.control-panel .panel {
    border-radius: var(--cr-radius);
}

.loans-grid .panel {
    margin: 0;
}

.loans-grid .panel + .panel {
    margin-top: 0;
}

.action-card {
    background: var(--cr-white);
    border: 1px solid var(--cr-border);
    border-radius: var(--cr-radius);
    padding: 1rem 1.25rem;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.action-card h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--cr-text);
}

.action-card--evaluation .sap-box {
    padding: 0.8rem 1rem;
    background: #f7f9fb;
}

.action-card--actions {
    margin-bottom: 1rem;
}

.loans-grid .panel.panel-action > form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.filter-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.filter-row .filter-label {
    flex: 1 1 auto;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.filter-row select {
    min-width: 180px;
}

.filter-row button {
    white-space: nowrap;
    flex: 0 0 auto;
    align-self: flex-end;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.chart-card {
    background: var(--cr-white);
    border: 1px solid var(--cr-border);
    border-radius: var(--cr-radius);
    padding: 1rem;
    min-height: 240px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.06);
}

.chart-card h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--cr-text);
}

.chart-card canvas {
    height: 200px !important;
    max-height: 220px;
}

.panel-scroller table thead th {
    font-size: 0.82rem;
}

.panel-scroller {
    max-height: 460px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.panel-scroller::-webkit-scrollbar {
    width: 6px;
}

.panel-scroller::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 999px;
}

.document-section {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.document-item {
    border: 1px solid var(--cr-border);
    border-radius: var(--cr-radius);
    padding: 0.75rem;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.document-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
}

.document-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0.6rem;
}

.document-inputs label {
    display: block;
    font-size: 0.85rem;
    color: var(--cr-muted);
    margin-bottom: 0.25rem;
}

.document-inputs textarea {
    height: 72px;
    min-height: 72px;
    resize: vertical;
    font-size: 0.9rem;
}

.document-inputs input[type="file"] {
    padding: 0.4rem 0.2rem;
}

@media (max-width: 1200px) {
    .loans-grid {
        grid-template-columns: minmax(0, 0.45fr) minmax(0, 0.55fr);
    }
    .panel-scroller {
        max-height: 420px;
    }
}

@media (max-width: 900px) {
    .loans-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .loans-grid > .action-panel {
        order: 2;
    }
    .loans-grid > .control-panel {
        order: 1;
    }
    .action-card {
        margin-top: 0.5rem;
    }
    .panel-scroller {
        max-height: 320px;
    }
}

@media (max-width: 640px) {
    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-row button {
        width: 100%;
        align-self: stretch;
    }
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.card-consistent {
    background: var(--cr-white);
    border: 1px solid var(--cr-border);
    border-radius: var(--cr-radius);
    padding: 1.25rem;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
}

.card-consistent h2 {
    margin: 0 0 0.75rem;
    color: var(--cr-green);
}

.two-col-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
}

.register-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.register-form .form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.register-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.register-form .form-group.full {
    grid-column: 1 / -1;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    align-items: start;
}

.form-grid .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-grid .form-group.full {
    grid-column: 1 / -1;
}

.form-grid label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--cr-muted);
}

.form-grid input,
.form-grid select,
.form-grid textarea {
    border: 1px solid var(--cr-border);
    border-radius: 0.45rem;
    padding: 0.65rem;
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--cr-white);
    box-sizing: border-box;
    height: 44px;
}

.form-grid textarea {
    height: 96px;
    resize: vertical;
}

.register-form label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--cr-muted);
}

.register-form input,
.register-form select,
.register-form textarea {
    border: 1px solid var(--cr-border);
    border-radius: 0.45rem;
    padding: 0.65rem;
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--cr-white);
    box-sizing: border-box;
    height: 44px;
}

.register-form textarea {
    height: 90px;
    resize: vertical;
}

.card-header .subtitle {
    font-size: 0.9rem;
    color: var(--cr-muted);
    margin: 0;
}
.register-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.register-form .form-grid-general {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.register-form button {
    align-self: flex-end;
}

.history-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.filter-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

.filter-bar input,
.filter-bar select {
    width: 100%;
    border: 1px solid var(--cr-border);
    border-radius: 0.45rem;
    padding: 0.55rem;
    font-family: inherit;
}

.table-wrapper {
    overflow-x: auto;
}

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

.table-wrapper th,
.table-wrapper td {
    padding: 0.65rem 0.8rem;
    border-bottom: 1px solid var(--cr-border);
    text-align: left;
}

.table-wrapper th {
    background: var(--cr-ui);
    font-weight: 700;
}

.table-wrapper tbody tr:hover {
    background: var(--cr-ui);
}

.export-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.export-actions a {
    padding: 0.35rem 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--cr-border);
    background: var(--cr-white);
    color: var(--cr-green);
    font-size: 0.85rem;
    text-decoration: none;
    font-weight: 600;
}

.export-actions a:hover {
    background: var(--cr-green);
    color: var(--cr-white);
}

.panel-form {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: flex-end;
    gap: 12px;
    margin: 0;
    width: 100%;
    flex-wrap: wrap;
}

.panel-form .form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 0 1 160px;
}

.panel-form .form-field--actions {
    flex: 0 0 auto;
    align-self: flex-end;
}

.panel-form .form-field--checkbox label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.panel-form input,
.panel-form select {
    height: 38px;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--cr-ui);
}

.login-card {
    width: 420px;
    max-width: 92vw;
    background: var(--cr-white);
    border: 1px solid var(--cr-border);
    border-radius: var(--cr-radius);
    box-shadow: 0 10px 24px var(--cr-shadow);
    padding: 1.5rem 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.25rem;
}

.login-brand img {
    max-width: 220px;
    height: auto;
    display: block;
}

.login-card h2 {
    margin: 0.25rem 0 0.5rem;
    text-align: center;
    font-weight: 700;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.login-form label {
    display: block;
    font-size: 0.9rem;
    color: var(--cr-muted);
    margin-bottom: 0.25rem;
}

.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    border: 1px solid var(--cr-border);
    border-radius: 10px;
    padding: 0.6rem 0.7rem;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    background: var(--cr-white);
}

.login-actions {
    display: flex;
    justify-content: center;
    margin-top: 0.5rem;
}

.login-hint {
    text-align: center;
    color: var(--cr-muted);
    font-size: 0.85rem;
    margin: 0.5rem 0 0;
}
