* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f2f4f7;
    color: #1a1a1a;
    margin: 0;
    padding: 0;
}

header {
    background: #1e293b;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    flex-wrap: wrap;
    gap: 8px;
}
header h1 { font-size: 1.15rem; margin: 0; }

main {
    max-width: 800px;
    margin: 20px auto;
    padding: 0 16px 40px;
}

.card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}
.card h2 { margin: 0 0 8px; font-size: 1.05rem; }
.card h3 { margin-top: 20px; font-size: 0.95rem; }

table { width: 100%; border-collapse: collapse; margin-top: 8px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid #eee; font-size: 0.92rem; }
th { color: #555; font-weight: 600; }
.tabla-datos th { width: 40%; color: #555; }

.grid-inquilinos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}
.tarjeta-inquilino {
    display: flex;
    flex-direction: column;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px;
    text-decoration: none;
    color: #1a1a1a;
    transition: box-shadow .15s;
}
.tarjeta-inquilino:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.tarjeta-inquilino .nombre { font-weight: 600; }
.tarjeta-inquilino .detalle { font-size: 0.85rem; color: #666; margin-top: 4px; }
.tarjeta-inquilino.inactivo { opacity: 0.55; }

.btn {
    display: inline-block;
    background: #e2e8f0;
    color: #1a1a1a;
    padding: 8px 14px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-peligro { background: #fee2e2; color: #991b1b; }
.btn-logout { color: #fff; text-decoration: none; font-size: 0.9rem; }
.btn-grande { width: 100%; text-align: center; padding: 14px; font-size: 1rem; }

.acciones { display: flex; gap: 8px; flex-wrap: wrap; }

.vacio { color: #888; font-style: italic; }
.ayuda { color: #666; font-size: 0.88rem; margin-top: -4px; }
.error { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.ok { background: #dcfce7; color: #166534; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }

form label { display: block; margin-top: 12px; margin-bottom: 4px; font-size: 0.9rem; font-weight: 600; }
form input, form select, form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}
.form-inline { display: flex; gap: 8px; }
.form-inline input, .form-inline select { width: auto; flex: 1; }
button[type="submit"] { margin-top: 20px; padding: 12px 20px; border-radius: 8px; font-size: 1rem; cursor: pointer; }

.pago-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px;
    border-radius: 8px;
    background: #fef9c3;
}
.pago-box.pagado { background: #dcfce7; }
.pago-box.vencido { background: #e5e7eb; }
.badge {
    display: inline-block;
    margin-left: 10px;
    padding: 2px 10px;
    border-radius: 12px;
    background: rgba(0,0,0,0.08);
    font-size: 0.8rem;
}

.contrato-historico {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}
.contrato-historico:last-child { border-bottom: none; }

/* Login / Setup */
.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-box {
    background: #fff; padding: 40px 30px; border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1); width: 90%; max-width: 340px; text-align: center;
}
.login-box input { width: 100%; padding: 12px; margin: 10px 0; border-radius: 8px; border: 1px solid #ccc; font-size: 1rem; }
.login-box button {
    width: 100%; padding: 12px; background: #2563eb; color: #fff; border: none;
    border-radius: 8px; font-size: 1rem; cursor: pointer; margin-top: 6px;
}

/* Vista de impresión */
.imprimir-body { background: #fff; }
.hoja-contrato { max-width: 700px; margin: 0 auto; padding: 30px; line-height: 1.6; }
.hoja-contrato h1 { text-align: center; font-size: 1.4rem; }
.clausulas-texto { white-space: pre-wrap; background: #fafafa; padding: 14px; border-radius: 6px; margin-top: 10px; }
.firmas { display: flex; justify-content: space-between; margin-top: 60px; }
.firma { text-align: center; width: 45%; }
.linea-firma { border-top: 1px solid #333; margin-bottom: 6px; }
.no-imprimir { max-width: 700px; margin: 20px auto; display: flex; gap: 8px; }

@media print {
    .no-imprimir { display: none; }
}

/* Modal de confirmación dentro de la página */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}
.modal-caja {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.modal-caja p {
    margin: 0 0 20px;
    line-height: 1.5;
    font-size: 0.95rem;
}
.modal-botones {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
