:root {
    --color-primario: #2563eb;
    --color-exito: #16a34a;
    --color-alerta: #f59e0b;
    --color-peligro: #dc2626;
    --color-fondo: #f5f7fa;
    --color-card: #ffffff;
    --color-texto: #1f2937;
}

body {
    background: var(--color-fondo);
    font-family: Arial, sans-serif;
    margin: 0;
}

.container {
    width: 90%;
    margin: auto;
}

.card {
    background: var(--color-card);
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.btn {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.btn-primary {
    background: var(--color-primario);
    color: white;
}

.btn-danger {
    background: var(--color-peligro);
    color: white;
}

.btn-success {
    background: var(--color-exito);
    color: white;
}

.btn-secondary {
    background: #e5e7eb;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.metric {
    font-size: 20px;
    font-weight: bold;
}

.metric-small {
    font-size: 12px;
    opacity: 0.7;
    color: gray;
}

.alert-danger {
    color: var(--color-peligro);
    font-weight: bold;
}

.alert-warning {
    color: var(--color-alerta);
    font-weight: bold;
}

.activity-item {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.cuota {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--color-primario);
    color: white;
    border: none;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #eee;
}

.item-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.text-muted {
    color: gray;
}

.badge {
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 12px;
    color: white;
    font-weight: bold;
    text-align: center;
}

.badge.success {
    background: #dcfce7;
    color: green;
}

.badge.danger {
    background: #fee2e2;
    color: red;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #eee;
}

.item-actions {
    display: flex;
    gap: 10px;
}

.text-muted {
    color: gray;
}

.deuda {
    color: var(--color-peligro);
    font-weight: bold;
}

.form-container {
    max-width: 500px;
    margin: 40px auto;
}

.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
}

.input-group label {
    margin-bottom: 5px;
    font-weight: bold;
}

.input-group input {
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #ccc;
}

.inline-form {
    display: flex;
    gap: 10px;
    margin: 10px 0;
}

.inline-form input {
    border-radius: 6px;
    border: 1px solid #ccc;
}

.order-controls a {
    margin: 0 5px;
    text-decoration: none;
}

body.login {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(to top, #1e3c72, #2a5298);
}

.fila-prestamo {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fila-prestamo .input-group {
    width: 100%;
}

.fila-prestamo .btn-danger {
    width: 100%;
    text-align: center;
}

.drag-handle {
    font-size: 18px;
    cursor: grab;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

@media (max-width: 768px) {
    .item-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px
    }

    .item-actions .btn,
    .item-actions a,
    .inline-form {
        width: 100%;
    }

    .inline-form input {
        width: 100%;
    }

    .fila-prestamo {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 90%;
    }

    /* 🔑 CLAVE: evitar que inputs se desborden */
    .fila-prestamo select,
    .fila-prestamo input {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* botón ocupa toda la línea */
    .fila-prestamo .btn-danger {
        width: 100%;
    }
}